finally in sync with archive
[bcm963xx.git] / userapps / broadcom / cfm / html / sntpcfg.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <!--
3         (c) 2005 U.S. Robotics Corporation
4 -->
5 <html>
6 <head>
7         <title>Device &raquo; Time</title>
8
9         <link href="usr_main.css" rel="stylesheet" type="text/css">
10         <link href="usr_menus.css" rel="stylesheet" type="text/css"><script src="usr_menus.js" type="text/javascript"></script><script src="usr_menus_build.js" type="text/javascript"></script>
11         <script src="usr_common.js" type="text/javascript"></script
12
13         <meta HTTP-EQUIV='Pragma' CONTENT='no-cache'>
14         <script type="text/javascript">
15 <!-- hide
16
17 setPageTitle("<%ejGetWlJS(wlInterface)%>");
18
19 var state = '<%ejGetSntp(sntpRefresh)%>';
20 if ( state == '1' ) {
21    var code = 'location = "sntpcfg.sntp?sntpRefresh=0"';
22    eval(code);
23 }
24
25 var ntpServers = new Array(
26                                                                         "clock.fmt.he.net",
27                                                                         "clock.nyc.he.net",
28                                                                         "clock.sjc.he.net",
29                                                                         "clock.via.net",
30                                                                         "ntp1.tummy.com",
31                                                                         "time.cachenetworks.com",
32                                                                         "time.nist.gov"
33                                                                 );
34
35 var timeZones = new Array(
36                                                                         "(UTC-12:00) International Date Line West",
37                                                                         "(UTC-11:00) Midway Island, Samoa",
38                                                                         "(UTC-10:00) Hawaii",
39                                                                         "(UTC-09:00) Alaska",
40                                                                         "(UTC-08:00) Pacific Time, Tijuana",
41                                                                         "(UTC-07:00) Arizona, Mazatlan",
42                                                                         "(UTC-07:00) Chihuahua, La Paz",
43                                                                         "(UTC-07:00) Mountain Time",
44                                                                         "(UTC-06:00) Central America",
45                                                                         "(UTC-06:00) Central Time",
46                                                                         "(UTC-06:00) Guadalajara, Mexico City, Monterrey",
47                                                                         "(UTC-06:00) Saskatchewan",
48                                                                         "(UTC-05:00) Bogota, Lima, Quito",
49                                                                         "(UTC-05:00) Eastern Time",
50                                                                         "(UTC-05:00) Indiana",
51                                                                         "(UTC-04:00) Atlantic Time",
52                                                                         "(UTC-04:00) Caracas, La Paz",
53                                                                         "(UTC-04:00) Santiago",
54                                                                         "(UTC-03:30) Newfoundland",
55                                                                         "(UTC-03:00) Brasilia",
56                                                                         "(UTC-03:00) Buenos Aires, Georgetown",
57                                                                         "(UTC-03:00) Greenland",
58                                                                         "(UTC-02:00) Mid-Atlantic",
59                                                                         "(UTC-01:00) Azores",
60                                                                         "(UTC-01:00) Cape Verde Is.",
61                                                                         "(UTC) Casablanca, Monrovia",
62                                                                         "(UTC) Universal Coordinated Time: Dublin, Edinburgh, Lisbon, London",
63                                                                         "(UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna",
64                                                                         "(UTC+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague",
65                                                                         "(UTC+01:00) Brussels, Copenhagen, Madrid, Paris",
66                                                                         "(UTC+01:00) Sarajevo, Skopje, Warsaw, Zagreb",
67                                                                         "(UTC+01:00) West Central Africa",
68                                                                         "(UTC+02:00) Athens, Istanbul, Minsk",
69                                                                         "(UTC+02:00) Bucharest",
70                                                                         "(UTC+02:00) Cairo",
71                                                                         "(UTC+02:00) Harare, Pretoria",
72                                                                         "(UTC+02:00) Helsinki, Kyiv, Riga, Sofia, Tallinn, Vilnius",
73                                                                         "(UTC+02:00) Jerusalem",
74                                                                         "(UTC+03:00) Baghdad",
75                                                                         "(UTC+03:00) Kuwait, Riyadh",
76                                                                         "(UTC+03:00) Moscow, St. Petersburg, Volgograd",
77                                                                         "(UTC+03:00) Nairobi",
78                                                                         "(UTC+03:30) Tehran",
79                                                                         "(UTC+04:00) Abu Dhabi, Muscat",
80                                                                         "(UTC+04:00) Baku, Tbilisi, Yerevan",
81                                                                         "(UTC+04:30) Kabul",
82                                                                         "(UTC+05:00) Ekaterinburg",
83                                                                         "(UTC+05:00) Islamabad, Karachi, Tashkent",
84                                                                         "(UTC+05:30) Chennai, Kolkata, Mumbai, New Delhi",
85                                                                         "(UTC+05:45) Kathmandu",
86                                                                         "(UTC+06:00) Almaty, Novosibirsk",
87                                                                         "(UTC+06:00) Astana, Dhaka",
88                                                                         "(UTC+06:00) Sri Jayawardenepura",
89                                                                         "(UTC+06:30) Rangoon",
90                                                                         "(UTC+07:00) Bangkok, Hanoi, Jakarta",
91                                                                         "(UTC+07:00) Krasnoyarsk",
92                                                                         "(UTC+08:00) Beijing, Chongquing, Hong Kong, Urumqi",
93                                                                         "(UTC+08:00) Irkutsk, Ulaan Bataar",
94                                                                         "(UTC+08:00) Kuala Lumpur, Singapore",
95                                                                         "(UTC+08:00) Perth",
96                                                                         "(UTC+08:00) Taipei",
97                                                                         "(UTC+09:00) Osaka, Sapporo, Tokyo",
98                                                                         "(UTC+09:00) Seoul",
99                                                                         "(UTC+09:00) Yakutsk",
100                                                                         "(UTC+09:30) Adelaide",
101                                                                         "(UTC+09:30) Darwin",
102                                                                         "(UTC+10:00) Brisbane",
103                                                                         "(UTC+10:00) Canberra, Melbourne, Sydney",
104                                                                         "(UTC+10:00) Guam, Port Moresby",
105                                                                         "(UTC+10:00) Hobart",
106                                                                         "(UTC+10:00) Vladivostok",
107                                                                         "(UTC+11:00) Magadan",
108                                                                         "(UTC+11:00) Solomon Is., New Caledonia",
109                                                                         "(UTC+12:00) Auckland, Wellington",
110                                                                         "(UTC+12:00) Fiji, Kamchatka, Marshall Is."
111                                                                 );
112
113 function getTimeZoneIndex(timeZoneName) {
114   var i = 0, ret = 4;  // default to Pacific time
115
116   for ( var i = 0; i < timeZones.length; i++ ) {
117     if ( timeZones[i].search(timeZoneName) != -1 )
118       break;
119   }
120
121   if ( i < timeZones.length )
122     ret = i;
123
124   return ret;
125 }
126
127 function getTimeZoneName(idx) {
128   var str = timeZones[idx];
129   var ret = '';
130
131   if ( idx != 25 && idx != 26 )
132     ret = str.substr(12);
133   else
134     ret = str.substr(6);
135
136   return ret;
137 }
138
139 function getTimeZoneOffset(idx) {
140   var str = timeZones[idx];
141   var ret = '';
142
143   if ( idx != 25 && idx != 26 )
144     ret = str.substr(4, 6);
145
146   return ret;
147 }
148
149 function writeTimeZoneList() {
150   for( var i = 0; i < timeZones.length; i++ )
151     document.writeln("<option value=" + getTimeZoneOffset(i) + ">" + timeZones[i] + "</option>");
152 }
153
154 function ntpChange(optionlist,textbox) {
155   if( optionlist[optionlist.selectedIndex].value == "Other" )
156     textbox.disabled = false;
157   else {
158     textbox.value = "";
159     textbox.disabled = true;
160   }
161 }
162
163 function btnApply() {
164   var loc = 'sntpcfg.sntp?ntp_enabled=';
165
166   with( document.forms[0] ) {
167     if( ntpEnabled.checked ) {
168       loc += '1&ntpServer1=';
169       if( ntpServer1.selectedIndex == ntpServers.length ) {
170         if( ntpServerOther1.value.length == 0 ) { // == Other
171           alert("The first time server is \"Other,\" but the IP address field is blank.");
172           return;
173         } else {
174           loc += ntpServerOther1.value;
175         }
176       } else {
177         loc += ntpServer1[ntpServer1.selectedIndex].value;
178       }
179
180       loc += '&ntpServer2=';
181       if( ntpServer2.selectedIndex == ntpServers.length+1 ) {
182         if( ntpServerOther2.value.length == 0 ) { // == Other
183           alert("The second time server is \"Other,\" but the IP address field is blank.");
184           return;
185         } else {
186           loc += ntpServerOther2.value;
187         }
188       } else {
189         if( ntpServer2.selectedIndex > 0 )
190           loc += ntpServer2[ntpServer2.selectedIndex].value;
191       }
192
193       loc += '&timezone_offset=' + cboTimeZone[cboTimeZone.selectedIndex].value;
194       loc += '&timezone=' + getTimeZoneName(cboTimeZone.selectedIndex);
195
196       loc += '&use_dst=0';
197     } else {
198       loc += '0';
199     }
200   }
201   var code = 'location = "' + loc + '";';
202   eval(code);
203 }
204
205 function frmLoad() {
206   var i = 0;
207   var ntp1 = "<%ejGetSntp(ntpServer1)%>";
208   var ntp2 = "<%ejGetSntp(ntpServer2)%>";
209   var ntp_enabled = "<%ejGetSntp(ntp_enabled)%>";
210   var tz_name = "<%ejGetSntp(timezone)%>";
211
212   with (document.forms[0]) {
213     if( ntp_enabled == "1" ) {
214       ntpEnabled.checked = true;
215     } else {
216       ntpEnabled.checked = false;
217     }
218
219     if( ntp1.length ) {
220       for( i = 0; i < ntpServers.length; i++ ) {
221         if( ntp1 == ntpServers[i] ) {
222           ntpServer1.selectedIndex = i;
223           break;
224         }
225       }
226       if( i == ntpServers.length ) {
227         ntpServer1.selectedIndex = i; // Set to 'Other'
228         ntpServerOther1.value = ntp1;
229       }
230     }
231     ntpChange(ntpServer1,ntpServerOther1);
232
233     if( ntp2.length ) {
234       for( i = 0; i < ntpServers.length; i++ ) {
235         if( ntp2 == ntpServers[i] ) {
236           ntpServer2.selectedIndex = i+1;
237           break;
238         }
239       }
240       if( i == ntpServers.length ) {
241         ntpServer2.selectedIndex = i+1; // Set to 'Other'
242         ntpServerOther2.value = ntp2;
243       }
244     }
245     ntpChange(ntpServer2,ntpServerOther2);
246
247     cboTimeZone.selectedIndex = getTimeZoneIndex(tz_name);
248
249     ntpEnblChange();
250   }
251 }
252
253 function hideNtpConfig(hide) {
254   var status = 'visible';
255
256   if(hide)
257     status = 'hidden';
258
259   if( document.getElementById )
260     document.getElementById('ntpConfig').style.visibility = status;
261   else
262     if(!document.layers)
263       document.all.ntpConfig.style.visibility = status;
264 }
265
266 function ntpEnblChange() {
267   if( document.forms[0].ntpEnabled.checked )
268     hideNtpConfig(0);
269   else
270     hideNtpConfig(1);
271 }
272
273 function writeNtpList(needed) {
274         if(!needed)
275                 document.writeln("<option value=\"None\">Disable</option>");
276         for( var i = 0; i < ntpServers.length; i++ )
277                 document.writeln("<option value=" + ntpServers[i] + ">" + ntpServers[i] + "</option>");
278         document.writeln("<option value=\"Other\">(specify IP address manually)</option>");
279 }
280
281         // done hiding -->
282         </script>
283 </head>
284 <body onload="initMenu(); frmLoad();">
285
286 <script type="text/javascript">
287         writeHeader("Device", "<%ejGetJS(curUserName)%>", "<%ejGetOther(sysInfo, adslStd)%>", "<%ejGetOther(sysInfo, noBrPrtcl)%>", <%ejGetOther(sysInfo, pppIpExtension)%>, <%ejGetOther(sysInfo, enblFirewall)%>, <%ejGetOther(sysInfo, enblNat)%>, "<%ejGetWlJS(wlInterface)%>", <%ejGetJS(enblQos)%>);
288 </script>
289
290 <h3>Time</h3>
291
292 <p>This page allows you to configure the router&rsquo;s time servers.</p>
293
294 <form>
295         <p><input type="checkbox" name="ntpEnabled" id="ntpEnabled" onClick="ntpEnblChange()"> <label for="ntpEnabled">Automatically synchronize with Internet time servers</label></p>
296
297         <div id="ntpConfig">
298                 <table border="0" cellpadding="2" cellspacing="0">
299                         <tr>
300                                 <td><label for="">Time server 1:</label></td>
301                                 <td>
302                                         <select name="ntpServer1" id="ntpServer1" onChange="ntpChange(this.form.ntpServer1,this.form.ntpServerOther1)">
303 <script type="text/javascript">
304         writeNtpList(true);
305 </script>
306                                         </select>
307                                 </td>
308                                 <td><input type="text" name="ntpServerOther1" id="ntpServerOther1"></td>
309                         </tr>
310                         <tr>
311                                 <td><label for="">Time server 2:</label></td>
312                                 <td>
313                                         <select name="ntpServer2" id="ntpServer2" onChange="ntpChange(this.form.ntpServer2,this.form.ntpServerOther2)">
314 <script type="text/javascript">
315         writeNtpList(false);
316 </script>
317                                         </select>
318                                 </td>
319                                 <td><input type="text" name="ntpServerOther2" id="ntpServerOther2"></td>
320                         </tr>
321
322                         <tr>
323                                 <td><label for="">Time zone offset:</label></td>
324                                 <td colspan="2">
325                                         <select name="cboTimeZone" id="cboTimeZone">
326 <script type="text/javascript">
327         writeTimeZoneList();
328 </script>
329                                         </select>
330                                 </td>
331                         </tr>
332                 </table>
333         </div>
334
335         <p><input type="button" value="Save" onClick="btnApply()"></p>
336 </form>
337
338 <script type="text/javascript">
339         writeFooter();
340 </script>
341
342 </body>
343 </html>