1 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML
4.0//EN'
>
4 Copyright (C) 2006-2010 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.
12 <meta http-equiv='content-type' content='text/html;charset=utf-
8'
>
13 <meta name='robots' content='noindex,nofollow'
>
14 <title>[<%
ident(); %>] Scheduler
</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>
21 <style type='text/css'
>
31 <script type='text/javascript' src='debug.js'
></script>
33 <script type='text/javascript'
>
35 // <% nvram("sch_rboot,sch_rcon,sch_c1,sch_c1_cmd,sch_c2,sch_c2_cmd,sch_c3,sch_c3_cmd"); %>
37 var dowNames
= ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
38 var dowLow
= ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
42 for (i
= 0; i
< 1440; i
+= 15) {
43 tm
.push([i
, timeString(i
)]);
47 [-1, 'Every minute'], [-3, 'Every 3 minutes'], [-5, 'Every 5 minutes'], [-15, 'Every 15 minutes'], [-30, 'Every 30 minutes'],
48 [-60, 'Every hour'], [-(12 * 60), 'Every 12 hours'], [-(24 * 60), 'Every 24 hours'],
57 function makeSched(key
, custom
)
64 s
= nvram
['sch_' + key
] || '';
65 if ((v
= s
.match(/^(0|1),(-?\d+),(\d+)$/)) == null) {
66 v
= custom
? ['', 0, -30, 0] : ['', 0, 0, 0];
78 for (i
= 0; i
< tm
.length
; ++i
) {
79 if ((tm
[i
][0] >= 0) || (tm
[i
][0] <= -60) || (tm
[i
][0] == 'e')) t
.push(tm
[i
]);
84 for (i
= 0; i
< t
.length
; ++i
) {
85 if (v
[2] == t
[i
][0]) {
92 { title
: 'Enabled', name
: key
+ 'enabled', type
: 'checkbox', value
: v
[1] == '1' },
93 { title
: 'Time', multi
: [
94 { name
: key
+ 'time', type
: 'select', options
: t
, value
: oe
? 'e' : v
[2] },
95 { name
: key
+ 'every', type
: 'text', maxlen
: 10, size
: 10, value
: (v
[2] < 0) ? -v
[2] : 30,
96 prefix
: ' ', suffix
: ' <small id="_' + key
+ 'mins"><i>minutes</i></small>' } ] },
97 { title
: 'Days', multi
: [
98 { name
: key
+ 'sun', type
: 'checkbox', suffix
: ' Sun ', value
: w
& 1 },
99 { name
: key
+ 'mon', type
: 'checkbox', suffix
: ' Mon ', value
: w
& 2 },
100 { name
: key
+ 'tue', type
: 'checkbox', suffix
: ' Tue ', value
: w
& 4 },
101 { name
: key
+ 'wed', type
: 'checkbox', suffix
: ' Wed ', value
: w
& 8 },
102 { name
: key
+ 'thu', type
: 'checkbox', suffix
: ' Thu ', value
: w
& 16 },
103 { name
: key
+ 'fri', type
: 'checkbox', suffix
: ' Fri ', value
: w
& 32 },
104 { name
: key
+ 'sat', type
: 'checkbox', suffix
: ' Sat ', value
: w
& 64 },
105 { name
: key
+ 'everyday', type
: 'checkbox', suffix
: ' Everyday', value
: (w
& 0x7F) == 0x7F } ] }
109 a
.push({ title
: 'Command', name
: 'sch_' + key
+ 'cmd', type
: 'textarea', value
: nvram
['sch_' + key
+ 'cmd' ] });
112 createFieldTable('', a
);
115 function verifySched(focused
, quiet
, key
)
118 var eTime
, eEvery
, eEveryday
, eCmd
;
120 key
= '_' + key
+ '_';
122 eTime
= E(key
+ 'time');
123 eEvery
= E(key
+ 'every');
124 eEvery
.style
.visibility
= E(key
+ 'mins').style
.visibility
= (eTime
.value
== 'e') ? 'visible' : 'hidden';
126 eCmd
= E('_sch' + key
+ 'cmd');
127 eEveryday
= E(key
+ 'everyday');
129 if (E(key
+ 'enabled').checked
) {
130 eEveryday
.disabled
= 0;
133 if (eCmd
) eCmd
.disabled
= 0;
135 if (focused
== eEveryday
) {
136 for (i
= 0; i
< 7; ++i
) {
137 f
= E(key
+ dowLow
[i
]);
139 f
.checked
= eEveryday
.checked
;
144 for (i
= 0; i
< 7; ++i
) {
145 f
= E(key
+ dowLow
[i
]);
149 eEveryday
.checked
= (n
== 7);
152 if ((eTime
.value
== 'e') && (!v_mins(eEvery
, quiet
, eCmd
? 1 : 60, 60 * 24 * 60))) return 0;
154 if ((eCmd
) && (!v_length(eCmd
, quiet
, quiet
? 0 : 1, 2048))) return 0;
157 eEveryday
.disabled
= 1;
160 for (i
= 0; i
< 7; ++i
) {
161 E(key
+ dowLow
[i
]).disabled
= 1;
163 if (eCmd
) eCmd
.disabled
= 1;
167 if ((eCmd
.value
.length
) || (!eTime
.disabled
)) {
168 elem
.removeClass(eCmd
, 'empty');
171 elem
.addClass(eCmd
, 'empty');
178 function verifyFields(focused
, quiet
)
180 for (var i
= 0; i
< scheds
.length
; ++i
) {
181 if (!verifySched(focused
, quiet
, scheds
[i
])) return 0;
186 function saveSched(fom
, key
)
188 var s
, i
, n
, k
, en
, e
;
192 en
= E(k
+ 'enabled').checked
;
196 e
= E(k
+ 'time').value
;
197 if (e
== 'e') s
+= -(E(k
+ 'every').value
* 1);
201 for (i
= 0; i
< 7; ++i
) {
202 if (E(k
+ dowLow
[i
]).checked
) n
|= (1 << i
);
206 e
= E(k
+ 'everyday');
211 e
= fom
['sch_' + key
];
212 e
.value
= s
+ ',' + n
;
219 if (!verifyFields(null, false)) return;
222 for (i
= 0; i
< scheds
.length
; ++i
) {
223 saveSched(fom
, scheds
[i
]);
231 verifyFields(null, 1);
232 E('content').style
.visibility
= 'visible';
236 <body onload='init()'
>
237 <form name='_fom' id='_fom' method='post' action='tomato.cgi'
>
238 <table id='container' cellspacing=
0>
239 <tr><td colspan=
2 id='header'
>
240 <div class='title'
>Tomato
</div>
241 <div class='version'
>Version <%
version() %></div>
243 <tr id='body'
><td id='navi'
><script type='text/javascript'
>navi()</script></td>
244 <td id='content' style='visibility:hidden'
>
245 <div id='ident'
><%
ident(); %></div>
249 <input type='hidden' name='_nextpage' value='admin-sched.asp'
>
250 <input type='hidden' name='_service' value='sched-restart'
>
251 <input type='hidden' name='sch_rboot' value=''
>
252 <input type='hidden' name='sch_rcon' value=''
>
253 <input type='hidden' name='sch_c1' value=''
>
254 <input type='hidden' name='sch_c2' value=''
>
255 <input type='hidden' name='sch_c3' value=''
>
257 <div class='section-title'
>Reboot
</div>
258 <div class='section'
>
259 <script type='text/javascript'
>
264 <div class='section-title'
>Reconnect
</div>
265 <div class='section'
>
266 <script type='text/javascript'
>
271 <div class='section-title'
>Custom
1</div>
272 <div class='section'
>
273 <script type='text/javascript'
>
278 <div class='section-title'
>Custom
2</div>
279 <div class='section'
>
280 <script type='text/javascript'
>
285 <div class='section-title'
>Custom
3</div>
286 <div class='section'
>
287 <script type='text/javascript'
>
295 <tr><td id='footer' colspan=
2>
296 <span id='footer-msg'
></span>
297 <input type='button' value='Save' id='save-button' onclick='save()'
>
298 <input type='button' value='Cancel' id='cancel-button' onclick='javascript:reloadPage();'
>