1 /* --------------------------------------------------------------------------
3 (c) 2005-2006 U.S. Robotics Corporation
5 -------------------------------------------------------------------------- */
8 /* --------------------------------------------------------------------------
12 This outputs the header for a Setup page.
13 The passed number indicates which step this is and how many steps there are.
15 <img id="idImgHeaderSetup" src="logo.gif">
17 If there are three steps, there will be three different headers:
19 <div class="idHeader">
20 <span class="clsStepDone">Setup</span>
21 <span class="clsStepCurrent">1</span>
22 <span class="clsStepNotDone">… 2 … 3</span>
25 <div class="idHeader">
26 <span class="clsStepDone">Setup 1 …</span>
27 <span class="clsStepCurrent">2</span>
28 <span class="clsStepNotDone">… 3</span>
31 <div class="idHeader">
32 <span class="clsStepDone">Setup 1 … 2 …</span>
33 <span class="clsStepCurrent">3</span>
36 function writeHeaderSetup(iStep, iSteps)
38 var strSteps = "<span class=\"clsStepDone\">Setup";
39 for (var i = 1; i <= iSteps; ++i)
42 strSteps += "<\/span> <span class=\"clsStepCurrent\">" + i + "<\/span><span class=\"clsStepNotDone\">";
47 strSteps += " …";
49 strSteps += "<\/span>";
51 setPageTitle(document.title);
52 _writeHeader(strSteps);
57 /* --------------------------------------------------------------------------
59 GENERAL HELPER FUNCTIONS
64 This function prompts the user to add a bookmark if the browser's not IE.
66 <script type="text/javascript">
67 document.write('<a href="' + document.location.href + '" title="USRobotics Router" rel="sidebar" onclick="bookmark(this); return false;">Bookmark the router</a>');
70 function bookmark(anchor)
72 if ((navigator.userAgent.indexOf('MSIE') >= 0) && (navigator.userAgent.indexOf('Opera') < 0))
73 window.external.AddFavorite(anchor.getAttribute('href'), anchor.getAttribute('title'));
77 function toggleVisibility(id)
79 var elt = document.getElementById(id);
80 if ((elt == null) || !elt.style || (elt.style.display == null))
83 if (elt.style.display == "none")
84 elt.style.display = "";
86 elt.style.display = "none";
90 function setVisibility(id, state)
92 var elt = document.getElementById(id);
93 if ((elt == null) || !elt.style || (elt.style.display == null))
97 elt.style.display = "";
99 elt.style.display = "none";
103 function setEnabled(id, state)
105 var elt = document.getElementById(id);
106 if ((elt == null) || !elt.style || (elt.style.display == null))
109 elt.disabled = !state;
114 /* --------------------------------------------------------------------------
116 FUNCTIONS TO HIDE/SHOW AN HTML TAG WHEN A CHECK BOX IS IN A CERTAIN STATE.
122 mapChkToRegions.push(new MapChkToRegion(document.forms[0].chkRelay, "idDHCPrelay", true));
123 setRegionVisibility(null);
127 <input type="checkbox" name="chkRelay" id="chkRelay" onclick="setRegionVisibility(this);">
130 function MapChkToRegion(eltChk, idRegion, bVisibleState)
132 this._eltChk = eltChk;
133 this._eltRegion = document.getElementById(idRegion);
134 this._bVisibleState = bVisibleState;
137 var mapChkToRegions = new Array(); // of MapChkToRegion objects
140 Pass null as the element if you want to set every region.
141 Pass an element if you only want to set the visibility of
142 the region(s) associated with that element.
144 function setRegionVisibility(eltChk)
146 for (var i = 0; i < mapChkToRegions.length; ++i)
148 if ((eltChk == null) || (eltChk == mapChkToRegions[i]._eltChk))
150 if ((mapChkToRegions[i]._bVisibleState && mapChkToRegions[i]._eltChk.checked) ||
151 (!mapChkToRegions[i]._bVisibleState && !mapChkToRegions[i]._eltChk.checked))
152 mapChkToRegions[i]._eltRegion.style.display = "";
154 mapChkToRegions[i]._eltRegion.style.display = "none";
161 /* --------------------------------------------------------------------------
168 This function validates that the passed string is a valid format for a
169 MAC address. The format is six hexadecimal bytes delimited by
170 punctuation marks. The hex bytes can be lower or upper case.
172 This function returns true if the passed value is a valid MAC format.
173 It returns false if it's invalid and displays an error message.
179 function validateMAC(mac)
181 var re = new RegExp("^[\\dA-F]{2}([:\\.\\-,;/][\\dA-F]{2}){5}$", "i");
182 var bOK = (mac.match(re) != null);
184 alert("Please enter a valid MAC address.\r\rA MAC address is a set of six bytes separated by colons, periods, dashes, commas, semicolons, or slashes. (A byte consists of two hexadecimal digits: 0-9 and A-F.) For example: \"00:C0:49:AA:22:43.\"");
190 This function converts the MAC address byte delimiters to colons.
192 function normalizeMAC(mac)
194 mac = mac.toUpperCase();
195 return mac.replace(/\W/g, ":");
199 function validateUsername(elt)
201 if (elt.value.length == 0)
203 alert("Please enter a user name.");
208 return isPrintable("User name", elt);
211 function validatePassword(elt)
213 if (elt.value.length == 0)
215 alert("Please enter a password.");
220 return isPrintable("Password", elt);
224 This function determines if the passed string contains only printable characters.
225 It returns true if the string is okay. It displays an error and returns false
226 if the string contains an invalid character.
228 95 "printable" characters:
229 <space>!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
231 We support ALL "printable" characters in the ASCII and Extended ASCII table.
232 These are character codes 32-126, 128-254, inclusive (decimal), or
233 0x20-0x7E, 0x80-0xFE, inclusive (hex).
236 function isPrintable(strFieldName, elt)
239 Note: We have to escape characters both for Javascript and for RegExp.
240 Thus, " must be escaped ONLY for Javascript: \"
241 \ and [ and ] must be escaped for RegExp and then the
242 escape characters have to be escaped for Javascript:
245 // Kludge to fix Safari regex bug with Unicode escape sequences
246 var re = new RegExp("[^\\x20-\\x7E\\x80-\\xFE]", "g");
248 var arMatch = elt.value.match(re);
249 // Most browsers return null; Safari returns an empty match object
250 if ((arMatch == null) || (arMatch.length == 0))
253 var strIllegalChars = "";
254 for (var i = 0; i < arMatch.length; ++i) //> This comment is required for some reason.
255 strIllegalChars += arMatch[i];
257 // There should be some illegal chars at this point, but just in case...
258 if (strIllegalChars == "")
262 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.";
263 if (arMatch.length == 1)
264 alert("The " + strFieldName + " entry contains an invalid character: " + strIllegalChars + strMsg2);
266 alert("The " + strFieldName + " entry contains invalid characters: " + strIllegalChars + strMsg2);
274 /* --------------------------------------------------------------------------
276 WIRELESS SECURITY FUNCTIONS
287 bits the number of bits in the key being generated
288 hex flag indicating if the key is hex
290 function getKeyLength(bits, bHex)
293 return bHex ? 10 : 5;
294 else if (bits == 128)
295 return bHex ? 26 : 13;
297 return bHex ? 58: 29;
302 Functions to determine key type from the key length
305 function isKeyASCII(strKey)
307 var len = strKey.length;
308 return ((len == 5) || (len == 13) || (len == 29));
310 function isKeyHex(strKey)
312 var len = strKey.length;
313 return ((len == 10) || (len == 26) || (len == 58));
318 Returns the number of bits in the passed key.
320 function getKeySize(strKey)
322 var len = strKey.length;
323 if ((len == 5) || (len == 10))
325 if ((len == 13) || (len == 26))
327 if ((len == 29) || (len == 58))