1 /* -------------------------------------------------------------------------- */
3 (c) 2005-2006 U.S. Robotics Corporation
5 /* -------------------------------------------------------------------------- */
8 /* --------------------------------------------------------------------------
10 Return appropriate product name, based on wireless feature.
13 function getProductName(strWireless)
15 if (strWireless == "1")
16 return "U.S. Robotics Wireless MAXg ADSL Gateway";
18 return "U.S. Robotics ADSL 4-Port Router";
22 function getProductNameHTML(strWireless)
24 if (strWireless == "1")
25 return "U.S. Robotics Wireless <i>MAX</i>g ADSL Gateway";
27 return "U.S. Robotics ADSL 4-Port Router";
31 /* --------------------------------------------------------------------------
33 Return <title> string for the page.
36 function setPageTitle(strWireless)
38 if (document.title == "")
39 document.title = getProductName(strWireless);
41 document.title = getProductName(strWireless) + " ยป " + document.title;
45 /* --------------------------------------------------------------------------
47 Page header and footer functions
52 This function returns the filename of the current page.
53 It looks for both slash and backward slash.
55 function getPageFilename()
57 var strFilename = document.URL;
58 var ixSeparator = strFilename.lastIndexOf("/");
59 var ixSeparator2 = strFilename.lastIndexOf("\\");
60 if (ixSeparator2 > ixSeparator)
61 ixSeparator = ixSeparator2;
62 if (ixSeparator != -1)
63 strFilename = strFilename.substr(ixSeparator + 1);
68 This writes out a page's header, including the optional menu bar.
69 The title parameter is optional. If passed, it's written out
73 <li><label>Sunfishes</label>
75 <li><a href="#">Blackbanded sunfish</a></li>
76 <li><a href="#">Shadow bass</a></li>
77 <li><a href="#">Ozark bass</a></li>
78 <li><a href="#">White crappie</a></li>
82 <li><label>Grunts</label>
84 <li><a href="#">Smallmouth grunt</a></li>
85 <li><a href="#">Burrito</a></li>
86 <li><a href="#">Pigfish</a></li>
90 <li><label>Remoras</label>
92 <li><a href="#">Whalesucker</a></li>
93 <li><a href="#">Marlinsucker</a></li>
94 <li><a href="#">Ceylonese remora</a></li>
95 <li><a href="#">Spearfish remora</a></li>
96 <li><a href="#">Slender suckerfish</a></li>
101 function writeHeader(strTitle)
103 // var strFilename = getPageFilename(); // get filename of current page
105 document.write("<img id=\"idImgHeader\" src=\"usr_banner.gif\">\n");
107 document.write("<div id=\"idHeader\">" + strTitle + "<\/div>\n");
109 var menuMain = createMenu();
112 document.write("<div id=\"idContent\">");
117 This outputs the header for a Setup page.
118 The passed number indicates which step this is and how many steps there are.
120 <img id="idImgHeader" src="banner.gif">
122 <h2 class="clsSteps">Setup
123 <span class="clsStepCurrent">1</span>
124 <span class="clsStepNotDone">… 2 … 3</span>
127 <h2 class="clsSteps">Setup
128 <span class="clsStepDone">1 …</span>
129 <span class="clsStepCurrent">2</span>
130 <span class="clsStepNotDone">… 3</span>
134 <h2 class="clsSteps">Setup
135 <span class="clsStepDone">1 … 2 …</span>
136 <span class="clsStepCurrent">3</span>
139 function writeHeaderSetup(iStep, iSteps)
141 document.write("<img id=\"idImgHeader\" src=\"usr_banner.gif\">");
143 document.write("<div id=\"idSteps\">Setup ");
145 for (var i = 1; i <= iSteps; ++i)
148 document.write("<span class=\"clsStepCurrent\">" + i + "<\/span> ");
150 document.write("<span class=\"clsStepNotDone\">" + i + "<\/span> ");
153 document.write("<span class=\"clsStepNotDone\">…<\/span> ");
155 document.write("<\/div>");
157 document.write("<div id=\"idContent\">");
162 This writes the header for an "information" page.
164 function writeHeaderInfo(strName)
166 document.write("<img id=\"idImgHeader\" src=\"usr_banner.gif\">");
167 document.write("<div id=\"idHeader\">" + strName + "<\/div>");
168 document.write("<div id=\"idContent\">");
172 function writeFooter()
174 document.write("<\/div>"); // close "idContent"
176 document.write("<p class=\"clsCopyright\">© 2004-2006 <a href=\"http://www.usr.com\">U.S. Robotics Corporation<\/a>.<\/p>");
181 /* --------------------------------------------------------------------------
183 Wireless info functions
188 This is called to set the visibility of fields on
189 the Status and Tutorial pages.
191 // initializeSecurity("<%ejGetWl(wlAuthMode)%>", "<%ejGetWl(wlWep)%>")
192 function initializeSecurity(strAuthMode, strWEPmode)
194 var method = getSecurityMethod(strAuthMode, strWEPmode);
195 if (method.indexOf("RADIUS") != -1)
197 // only show Encryption if also WPA
198 if (method.indexOf("WPA") != -1)
199 setVisibility("idEncrypt", true);
201 setVisibility("idRADIUSkey", true);
204 setVisibility("idKey8021x1", true);
205 setVisibility("idKey8021x2", true);
206 setVisibility("idKey8021x3", true);
208 else if (method.indexOf("WPA") != -1)
210 setVisibility("idEncrypt", true);
211 setVisibility("idKeyWPA", true);
213 else if (method.indexOf("WEP") != -1)
215 setVisibility("idKeyWEP", true);
219 // getSecurityMethod("<%ejGetWl(wlAuthMode)%>", "<%ejGetWl(wlWep)%>")
220 function getSecurityMethod(strAuthMode, strWEPmode)
225 if (strWEPmode == "enabled")
229 case "shared": return "WEP shared";
231 case "psk": return "WPA";
232 case "psk2": return "WPA2";
233 case "psk2mix": return "WPA2 and WPA";
235 case "wpa": return "WPA with 802.1x (RADIUS)";
236 case "wpa2": return "WPA2 with 802.1x (RADIUS)";
237 case "wpa2mix": return "WPA2 and WPA with 802.1x (RADIUS)";
238 case "radius": return "802.1x (RADIUS)";
240 default: return "None";
248 Return encryption method used for WPA or WEP
250 function getEncryption(strEncrypt)
254 case "aes": return "AES";
255 case "tkip": return "TKIP";
256 case "tkip+aes": return "AES and TKIP";
263 Return the WEP key specified by the current index.
265 function getWEPkey(strWEPkeyIx, strKey1, strKey2, strKey3, strKey4)
267 if (strWEPkeyIx == "")
270 var ixKey = parseInt(strWEPkeyIx);
271 if ((ixKey >= 1) && (ixKey <= 4))
273 var keys = new Array(strKey1, strKey2, strKey3, strKey4);
274 return keys[ixKey - 1];
280 function getWEPkeyType(strKey)
282 return _getKeySize(strKey) + "-" + (_isKeyASCII(strKey) ? "ASCII" : "hex");
286 Functions to determine key type from the key length
289 function _isKeyASCII(strKey)
291 var len = strKey.length;
292 return ((len == 5) || (len == 13));
294 function _isKeyHex(strKey)
296 var len = strKey.length;
297 return ((len == 10) || (len == 26));
300 function _getKeySize(strKey)
302 var len = strKey.length;
303 if ((len == 5) || (len == 10))
305 if ((len == 13) || (len == 26))
316 This is called when the user changes a sub-type of
317 encryption (WEP ASCII 128-bit, WEP hex 64-bit, ...).
325 function setMaxLength(bClearValues, strType, eltKeys)
327 var bHex = ((strType == "type128hex") || (strType == "type64hex"));
330 if ((strType == "type64ASCII") || (strType == "type64hex"))
333 var iMaxLength = getKeyLength(iBits, bHex);
335 document.getElementById("idKeyNumChars").innerHTML = iMaxLength;
338 some page(s) might have only one key field,
339 instead of an array of them, so check for that
341 if (eltKeys.length == null)
343 eltKeys.maxLength = iMaxLength;
349 for (var i = 0; i < eltKeys.length; ++i)
351 eltKeys[i].maxLength = iMaxLength;
353 eltKeys[i].value = "";
363 function getKeyLength(bits, bHex)
372 case 64: len = 10; break;
374 default: len = 26; break;
382 case 64: len = 5; break;
384 default: len = 13; break;
393 /* --------------------------------------------------------------------------
395 General helper functions
400 This function tests the passed element's value for being inside
401 the passed range--inclusive. If it's not, it displays an error
402 and sets focus to the field...and returns false.
404 function inRange(strName, elt, min, max)
406 if ((elt.value == "") || (elt.value < min) || (elt.value > max))
408 alert("The " + strName + " setting must be between " + min + " and " + max + ", inclusive.");
416 This function tests the passed element's length for being at least the
417 passed number of characters. If it's not, it displays an error and sets
418 focus to the field...and returns false.
420 function minLength(strName, elt, min)
422 if (elt.value.length < min)
424 alert("The " + strName + " field must have at least " + min + " characters.");
433 function toggleVisibility(id)
435 var elt = document.getElementById(id);
436 if ((elt == null) || !elt.style || (elt.style.display == null))
439 if (elt.style.display == "none")
440 elt.style.display = "";
442 elt.style.display = "none";
446 function setVisibility(id, state)
448 var elt = document.getElementById(id);
449 if ((elt == null) || !elt.style || (elt.style.display == null))
453 elt.style.display = "";
455 elt.style.display = "none";
459 function setEnabled(id, state)
461 var elt = document.getElementById(id);
462 if ((elt == null) || !elt.style || (elt.style.display == null))
465 elt.disabled = !state;
469 function validateUsername(elt)
471 if (elt.value.length == 0)
473 alert("Please enter a user name.");
478 return isPrintable("User name", elt);
481 function validatePassword(elt)
483 if (elt.value.length == 0)
485 alert("Please enter a password.");
490 return isPrintable("Password", elt);
495 This function determines if the passed string contains only printable characters.
496 It returns true if the string is okay. It displays an error and returns false
497 if the string contains an invalid character.
499 95 "printable" characters:
500 <space>!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
502 We support ALL "printable" characters in the ASCII and Extended ASCII table.
503 These are character codes 32-126, 128-254, inclusive (decimal), or
504 0x20-0x7E, 0x80-0xFE, inclusive (hex).
507 function isPrintable(strFieldName, elt)
510 Note: We have to escape characters both for Javascript and for RegExp.
511 Thus, " must be escaped ONLY for Javascript: \"
512 \ and [ and ] must be escaped for RegExp and then the
513 escape characters have to be escaped for Javascript:
516 // Kludge to fix Safari regex bug with Unicode escape sequences
517 var re = new RegExp("[^\\x20-\\x7E\\x80-\\xFE]", "g");
519 var arMatch = elt.value.match(re);
520 // Most browsers return null; Safari returns an empty match object
521 if ((arMatch == null) || (arMatch.length == 0))
524 var strIllegalChars = "";
525 for (var i = 0; i < arMatch.length; ++i)
526 strIllegalChars += arMatch[i];
528 // There should be some illegal chars at this point, but just in case...
529 if (strIllegalChars == "")
533 var strMsg2 = "\n\nPlease use only a-z, A-Z, 0-9, space, punctuation, or charcters in the extended ASCII set, such as accented characters.";
534 if (arMatch.length == 1)
535 alert("The " + strFieldName + " entry contains an invalid character: " + strIllegalChars + strMsg2);
537 alert("The " + strFieldName + " entry contains invalid characters: " + strIllegalChars + strMsg2);