Tomato 1.26 beta (1786)
[tomato.git] / release / src / router / www / basic-time.asp
blob37bfd0a21749e1ae1b126761be3f6322ab0e8c1c
1 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0//EN'>
2 <!--
3 Tomato GUI
4 Copyright (C) 2006-2009 Jonathan Zarate
5 http://www.polarcloud.com/tomato/
7 For use with Tomato Firmware only.
8 No part of this file may be used without permission.
9 -->
10 <html>
11 <head>
12 <meta http-equiv='content-type' content='text/html;charset=utf-8'>
13 <meta name='robots' content='noindex,nofollow'>
14 <title>[<% ident(); %>] Basic: Time</title>
15 <link rel='stylesheet' type='text/css' href='tomato.css'>
16 <link rel='stylesheet' type='text/css' href='color.css'>
17 <script type='text/javascript' src='tomato.js'></script>
19 <!-- / / / -->
21 <script type='text/javascript' src='debug.js'></script>
23 <script type='text/javascript'>
25 // <% nvram("tm_sel,tm_dst,tm_tz,ntp_updates,ntp_server,ntp_tdod,ntp_kiss"); %>
28 var ntpList = [
29 ['custom', 'Custom...'],
30 ['', 'Default'],
31 ['africa', 'Africa'],
32 ['asia', 'Asia'],
33 ['europe', 'Europe'],
34 ['oceania', 'Oceania'],
35 ['north-america', 'North America'],
36 ['south-america', 'South America'],
37 ['us', 'US']
40 function ntpString(name)
42 if (name == '') name = 'pool.ntp.org';
43 else name = name + '.pool.ntp.org';
44 return '0.' + name + ' 1.' + name + ' 2.' + name;
47 function verifyFields(focused, quiet)
49 var ok = 1;
51 var s = E('_tm_sel').value;
52 var f_dst = E('_f_tm_dst');
53 var f_tz = E('_f_tm_tz');
54 if (s == 'custom') {
55 f_dst.disabled = true;
56 f_tz.disabled = false;
57 PR(f_dst).style.display = 'none';
58 PR(f_tz).style.display = '';
60 else {
61 f_tz.disabled = true;
62 PR(f_tz).style.display = 'none';
63 PR(f_dst).style.display = '';
64 if (s.match(/^([A-Z]+[\d:-]+)[A-Z]+/)) {
65 if (!f_dst.checked) s = RegExp.$1;
66 f_dst.disabled = false;
68 else {
69 f_dst.disabled = true;
71 f_tz.value = s;
74 var a = 1;
75 var b = 1;
76 switch (E('_ntp_updates').value * 1) {
77 case -1:
78 b = 0;
79 case 0:
80 a = 0;
81 break;
83 elem.display(PR('_f_ntp_tdod'), a);
85 elem.display(PR('_f_ntp_server'), b);
86 a = (E('_f_ntp_server').value == 'custom');
87 elem.display(PR('_f_ntp_1'), PR('_f_ntp_2'), PR('_f_ntp_3'), a && b);
89 elem.display(PR('ntp-preset'), !a && b);
91 if (a) {
92 if ((E('_f_ntp_1').value == '') && (E('_f_ntp_2').value == '') && ((E('_f_ntp_3').value == ''))) {
93 ferror.set('_f_ntp_1', 'At least one NTP server is required', quiet);
94 return 0;
97 else {
98 E('ntp-preset').innerHTML = ntpString(E('_f_ntp_server').value).replace(/\s+/, ', ');
101 ferror.clear('_f_ntp_1');
102 return 1;
105 function save(clearKiss)
107 if (!verifyFields(null, 0)) return;
109 var fom, a, i;
111 fom = E('_fom');
112 fom.tm_dst.value = fom.f_tm_dst.checked ? 1 : 0;
113 fom.tm_tz.value = fom.f_tm_tz.value;
115 if (E('_f_ntp_server').value != 'custom') {
116 fom.ntp_server.value = ntpString(E('_f_ntp_server').value);
118 else {
119 a = [fom.f_ntp_1.value, fom.f_ntp_2.value, fom.f_ntp_3.value];
120 for (i = 0; i < a.length; ) {
121 if (a[i] == '') a.splice(i, 1);
122 else ++i;
124 fom.ntp_server.value = a.join(' ');
127 fom.ntp_tdod.value = fom.f_ntp_tdod.checked ? 1 : 0;
128 fom.ntp_kiss.disabled = !clearKiss;
129 form.submit(fom);
132 function earlyInit()
134 if (nvram.ntp_kiss != '') {
135 E('ntpkiss-ip').innerHTML = nvram.ntp_kiss;
136 E('ntpkiss').style.display = '';
138 verifyFields(null, 1);
140 </script>
141 </head>
142 <body>
143 <form id='_fom' method='post' action='tomato.cgi'>
144 <table id='container' cellspacing=0>
145 <tr><td colspan=2 id='header'>
146 <div class='title'>Tomato</div>
147 <div class='version'>Version <% version(); %></div>
148 </td></tr>
149 <tr id='body'><td id='navi'><script type='text/javascript'>navi()</script></td>
150 <td id='content'>
151 <div id='ident'><% ident(); %></div>
153 <!-- / / / -->
155 <input type='hidden' name='_nextpage' value='basic-time.asp'>
156 <input type='hidden' name='_nextwait' value='5'>
157 <input type='hidden' name='_service' value='ntpc-restart'>
158 <input type='hidden' name='_sleep' value='3'>
160 <input type='hidden' name='tm_dst'>
161 <input type='hidden' name='tm_tz'>
162 <input type='hidden' name='ntp_server'>
163 <input type='hidden' name='ntp_tdod'>
164 <input type='hidden' name='ntp_kiss' value='' disabled>
167 <div class='section-title'>Time</div>
168 <div class='section'>
169 <script type='text/javascript'>
171 ntp = nvram.ntp_server.split(/\s+/);
173 ntpSel = 'custom';
174 for (i = ntpList.length - 1; i > 0; --i) {
175 if (ntpString(ntpList[i][0]) == nvram.ntp_server) ntpSel = ntpList[i][0];
178 /* REMOVE-BEGIN
180 http://tldp.org/HOWTO/TimePrecision-HOWTO/tz.html
181 http://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html
183 Canada
184 http://www3.sympatico.ca/c.walton/canada_dst.html
185 http://home-4.tiscali.nl/~t876506/Multizones.html#ca
186 http://www3.sympatico.ca/c.walton/canada_dst.html
188 Brazil
189 http://www.timeanddate.com/worldclock/clockchange.html?n=233
190 http://www.timeanddate.com/worldclock/city.html?n=479
192 Finland
193 http://www.timeanddate.com/worldclock/city.html?n=101
195 New Zeland
196 http://www.dia.govt.nz/diawebsite.nsf/wpg_URL/Services-Daylight-Saving-Index
198 Australia
199 http://en.wikipedia.org/wiki/Time_in_Australia
200 http://www.timeanddate.com/library/abbreviations/timezones/au/
202 REMOVE-END */
204 createFieldTable('', [
205 { title: 'Router Time', text: '<span id="clock"><% time(); %></span>' },
206 null,
207 { title: 'Time Zone', name: 'tm_sel', type: 'select', options: [
208 ['custom','Custom...'],
209 ['UTC12','UTC-12:00 Kwajalein'],
210 ['UTC11','UTC-11:00 Midway Island, Samoa'],
211 ['UTC10','UTC-10:00 Hawaii'],
212 ['NAST9NADT,M3.2.0/2,M11.1.0/2','UTC-09:00 Alaska'],
213 ['PST8PDT,M3.2.0/2,M11.1.0/2','UTC-08:00 Pacific Time'],
214 ['UTC7','UTC-07:00 Arizona'],
215 ['MST7MDT,M3.2.0/2,M11.1.0/2','UTC-07:00 Mountain Time'],
216 ['UTC6','UTC-06:00 Mexico'],
217 ['CST6CDT,M3.2.0/2,M11.1.0/2','UTC-06:00 Central Time'],
218 ['UTC5','UTC-05:00 Colombia, Panama'],
219 ['EST5EDT,M3.2.0/2,M11.1.0/2','UTC-05:00 Eastern Time'],
220 ['VET4:30','UTC-04:30 Venezuela'],
221 ['BOT4','UTC-04:00 Bolivia'],
222 ['AST4ADT,M3.2.0/2,M11.1.0/2','UTC-04:00 Atlantic Time'],
223 ['BRWST4BRWDT,M10.3.0/0,M2.5.0/0','UTC-04:00 Brazil West'],
224 ['NST3:30NDT,M3.2.0/0:01,M11.1.0/0:01','UTC-03:30 Newfoundland'],
225 ['WGST3WGDT,M3.5.6/22,M10.5.6/23','UTC-03:00 Greenland'],
226 ['BRST3BRDT,M10.3.0/0,M2.5.0/0','UTC-03:00 Brazil East'],
227 ['UTC3','UTC-03:00 Guyana'],
228 ['UTC2','UTC-02:00 Mid-Atlantic'],
229 ['STD1DST,M3.5.0/2,M10.5.0/2','UTC-01:00 Azores'],
230 ['UTC0','UTC+00:00 Gambia, Liberia, Morocco'],
231 ['GMT0BST,M3.5.0/2,M10.5.0/2','UTC+00:00 England'],
232 ['UTC-1','UTC+01:00 Tunisia'],
233 ['CET-1CEST,M3.5.0/2,M10.5.0/3','UTC+01:00 France, Germany, Italy, Poland, Sweden'],
234 ['EET-2EEST-3,M3.5.0/3,M10.5.0/4','UTC+02:00 Finland'],
235 ['UTC-2','UTC+02:00 South Africa'],
236 ['STD-2DST,M3.5.0/2,M10.5.0/2','UTC+02:00 Greece, Ukraine, Romania, Turkey, Latvia'],
237 ['UTC-3','UTC+03:00 Iraq, Jordan, Kuwait'],
238 ['MSK-3MSD,M3.5.0/3,M10.5.0/4','UTC+03:00 Moscow'],
239 ['UTC-4','UTC+04:00 Armenia'],
240 ['UTC-4:30','UTC+04:30 Kabul'],
241 ['UTC-5','UTC+05:00 Pakistan, Russia'],
242 ['UTC-5:30','UTC+05:30 Bombay, Calcutta, Madras, New Delhi'],
243 ['UTC-6','UTC+06:00 Bangladesh, Russia'],
244 ['UTC-7','UTC+07:00 Thailand, Russia'],
245 ['UTC-8','UTC+08:00 China, Hong Kong, Western Australia, Singapore, Taiwan, Russia'],
246 ['UTC-9','UTC+09:00 Japan, Korea'],
247 ['ACST-9:30ACDT,M10.1.0/2,M4.1.0/3', 'UTC+09:30 South Australia'],
248 ['ACST-9:30', 'UTC+09:30 Darwin'],
249 ['UTC-10','UTC+10:00 Guam, Russia'],
250 ['AEST-10AEDT,M10.1.0,M4.1.0/3', 'UTC+10:00 Australia'],
251 ['AEST-10', 'UTC+10:00 Brisbane'],
252 ['UTC-11','UTC+11:00 Solomon Islands'],
253 ['UTC-12','UTC+12:00 Fiji'],
254 ['NZST-12NZDT,M9.5.0/2,M4.1.0/3','UTC+12:00 New Zealand']
255 ], value: nvram.tm_sel },
256 { title: 'Auto Daylight Savings Time', indent: 2, name: 'f_tm_dst', type: 'checkbox', value: nvram.tm_dst != '0' },
257 { title: 'Custom TZ String', indent: 2, name: 'f_tm_tz', type: 'text', maxlen: 32, size: 34, value: nvram.tm_tz || '' },
258 null,
259 { title: 'Auto Update Time', name: 'ntp_updates', type: 'select', options: [[-1,'Never'],[0,'Only at startup'],[1,'Every hour'],[2,'Every 2 hours'],[4,'Every 4 hours'],[6,'Every 6 hours'],[8,'Every 8 hours'],[12,'Every 12 hours'],[24,'Every 24 hours']],
260 value: nvram.ntp_updates },
261 { title: 'Trigger Connect On Demand', indent: 2, name: 'f_ntp_tdod', type: 'checkbox', value: nvram.ntp_tdod != '0' },
262 { title: 'NTP Time Server', name: 'f_ntp_server', type: 'select', options: ntpList, value: ntpSel },
263 { title: '&nbsp;', text: '<small><span id="ntp-preset">xx</span></small>', hidden: 1 },
264 { title: '', name: 'f_ntp_1', type: 'text', maxlen: 48, size: 50, value: ntp[0] || 'pool.ntp.org', hidden: 1 },
265 { title: '', name: 'f_ntp_2', type: 'text', maxlen: 48, size: 50, value: ntp[1] || '', hidden: 1 },
266 { title: '', name: 'f_ntp_3', type: 'text', maxlen: 48, size: 50, value: ntp[2] || '', hidden: 1 }
268 </script>
269 </div>
270 <br><br>
272 <div id='ntpkiss' style='display:none'>
273 The following NTP servers have been automatically blocked by request from the server:
274 <b id='ntpkiss-ip'></b>
275 <div>
276 <input type='button' value='Clear' onclick='save(1)'>
277 </div>
278 </div>
280 <!-- / / / -->
282 </td></tr>
283 <tr><td id='footer' colspan=2>
284 <span id='footer-msg'></span>
285 <input type='button' value='Save' id='save-button' onclick='save(0)'>
286 <input type='button' value='Cancel' id='cancel-button' onclick='reloadPage();'>
287 </td></tr>
288 </table>
289 </form>
290 <script type='text/javascript'>earlyInit()</script>
291 </body>
292 </html>