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