1 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML
4.0//EN'
>
6 For use with Tomato Firmware only.
7 No part of this file may be used without permission.
11 <meta http-equiv='content-type' content='text/html;charset=utf-
8'
>
12 <meta name='robots' content='noindex,nofollow'
>
13 <title>[<%
ident(); %>] NAS: USB Support
</title>
14 <link rel='stylesheet' type='text/css' href='tomato.css'
>
15 <link rel='stylesheet' type='text/css' href='color.css'
>
16 <script type='text/javascript' src='tomato.js'
></script>
20 <style type='text/css'
>
27 <style type='text/css'
>
46 <script type='text/javascript' src='debug.js'
></script>
48 <script type='text/javascript'
>
50 // <% nvram("usb_enable,usb_uhci,usb_ohci,usb_usb2,usb_storage,usb_printer,usb_printer_bidirect,usb_automount,usb_fs_ext3,usb_fs_fat,usb_fs_ntfs,usb_fs_hfs,usb_fs_hfsplus,script_usbmount,script_usbumount,script_usbhotplug,idle_enable"); %>
51 // <% usbdevices(); %>
57 function _umountHost(host
)
59 form
.submitHidden('usbcmd.cgi', { remove
: host
});
62 function _mountHost(host
)
64 form
.submitHidden('usbcmd.cgi', { mount
: host
});
67 function _forceRefresh()
69 if (!ref
.running
) ref
.once
= 1;
73 function umountHost(a
, host
)
77 if ((xob
= new XmlHttp()) == null) {
83 a
.innerHTML
= 'Please wait...';
85 xob
.onCompleted = function(text
, xml
) {
87 if (usb
.length
== 1) {
89 ferror
.set(a
, 'The device is busy. Please make sure no applications are using it, and try again.', 0);
95 xob
.onError = function() {
100 xob
.post('usbcmd.cgi', 'remove=' + host
);
103 function mountHost(a
, host
)
107 if ((xob
= new XmlHttp()) == null) {
113 a
.innerHTML
= 'Please wait...';
115 xob
.onCompleted = function(text
, xml
) {
117 if (usb
.length
== 1) {
119 ferror
.set(a
, 'Failed to mount. Verify the device is plugged in, and try again.', 0);
125 xob
.onError = function() {
130 xob
.post('usbcmd.cgi', 'mount=' + host
);
133 var ref
= new TomatoRefresh('update.cgi', 'exec=usbdevices', 0, 'nas_usb_refresh');
135 ref
.refresh = function(text
)
148 var dg
= new TomatoGrid();
150 dg
.sortCompare = function(a
, b
) {
151 var col
= this.sortColumn
;
152 var ra
= a
.getRowData();
153 var rb
= b
.getRowData();
158 if (ra
.type
== 'Storage' && ra
.type
== rb
.type
)
159 r
= cmpInt(ra
.host
, rb
.host
);
161 r
= cmpText(ra
.host
, rb
.host
);
164 r
= cmpText(a
.cells
[col
].innerHTML
, b
.cells
[col
].innerHTML
);
166 return this.sortAscending
? r
: -r
;
169 dg
.populate = function()
171 var i
, j
, k
, a
, b
, c
, e
, s
, desc
, d
, parts
, p
;
175 for (i
= 0; i
< list
.length
; ++i
) {
179 list
[i
].product
= '';
182 list
[i
].is_mounted
= 0;
185 for (i
= usbdev
.length
- 1; i
>= 0; --i
) {
199 for (i
= list
.length
- 1; i
>= 0; --i
) {
202 if (e
.type
!= 'Storage')
203 s
= ' <br><small> </small>';
206 s
= ((e
.is_mounted
== 0) ? 'No' : 'Yes') + '<br><small>Please wait...</small>';
207 else if (e
.is_mounted
== 0)
208 s
= 'No<br><small><a href="javascript:mountHost(\'L' + i
+ '\',\'' + e
.host
+ '\')" title="Mount all Partitions of Storage Device" id="L' + i
+ '">[ Mount ]</a></small>';
210 s
= 'Yes<br><small><a href="javascript:umountHost(\'L' + i
+ '\',\'' + e
.host
+ '\')" title="Safely Remove Storage Device" id="L' + i
+ '">[ Unmount ]</a></small>';
212 desc
= (e
.vendor
+ ' ' + e
.product
).trim() + '<small>'; // + (e.serial == '' ? '' : '<br>Serial No: ' + e.serial);
214 for (j
= 0; j
<= e
.discs
.length
- 1; ++j
) {
217 for (k
= 0; k
<= parts
.length
- 1; ++k
) {
220 desc
= desc
+ '<br>Partition \'' + p
[0] + '\'' + (p
[3] != '' ? ' ' + p
[3] : '') +
221 ((p
[5] != 0) ? ' (' + doScaleSize(p
[5], 0) +
222 ((p
[1] == 1) ? ' / ' + doScaleSize(p
[6], 0) + ' free' : '') +
224 ((p
[1] != 0) ? '' : 'not ') + ((p
[3] == 'swap') ? 'active' : 'mounted') +
225 ((p
[2] != '') ? ' on ' + p
[2] : '');
230 desc
= desc
+ '</small>';
231 this.insert(-1, e
, [e
.type
, e
.host
, desc
, s
], false);
237 dg
.setup = function()
239 this.init('dev-grid', 'sort');
240 this.headerSet(['Type', 'Host', 'Description', 'Mounted?']);
256 function verifyFields(focused
, quiet
)
258 var b
= !E('_f_usb').checked
;
259 var a
= !E('_f_storage').checked
;
261 E('_f_uhci').disabled
= b
|| nvram
.usb_uhci
== -1;
262 E('_f_ohci').disabled
= b
|| nvram
.usb_ohci
== -1;
263 E('_f_usb2').disabled
= b
;
264 E('_f_print').disabled
= b
;
265 E('_f_storage').disabled
= b
;
267 E('_f_ext3').disabled
= b
|| a
;
268 E('_f_fat').disabled
= b
|| a
;
269 E('_f_idle_enable').disabled
= b
|| a
;
271 E('_f_ntfs').disabled
= b
|| a
;
273 E('_f_hfs').disabled
= b
|| a
; //!Victek
274 E('_f_hfsplus').disabled
= b
|| a
; //!Victek
275 E('_f_automount').disabled
= b
|| a
;
276 E('_f_bprint').disabled
= b
|| !E('_f_print').checked
;
278 elem
.display(PR('_f_automount'), !b
&& !a
);
279 elem
.display(PR('_script_usbmount'), PR('_script_usbumount'), !b
&& !a
&& E('_f_automount').checked
);
280 elem
.display(PR('_script_usbhotplug'), !b
&& (!a
|| E('_f_print').checked
));
282 if (!v_length('_script_usbmount', quiet
, 0, 2048)) return 0;
283 if (!v_length('_script_usbumount', quiet
, 0, 2048)) return 0;
284 if (!v_length('_script_usbhotplug', quiet
, 0, 2048)) return 0;
293 if (!verifyFields(null, 0)) return;
296 fom
.usb_enable
.value
= E('_f_usb').checked
? 1 : 0;
297 fom
.usb_uhci
.value
= nvram
.usb_uhci
== -1 ? -1 : (E('_f_uhci').checked
? 1 : 0);
298 fom
.usb_ohci
.value
= nvram
.usb_ohci
== -1 ? -1 : (E('_f_ohci').checked
? 1 : 0);
299 fom
.usb_usb2
.value
= E('_f_usb2').checked
? 1 : 0;
300 fom
.usb_storage
.value
= E('_f_storage').checked
? 1 : 0;
301 fom
.usb_printer
.value
= E('_f_print').checked
? 1 : 0;
302 fom
.usb_printer_bidirect
.value
= E('_f_bprint').checked
? 1 : 0;
303 fom
.usb_fs_ext3
.value
= E('_f_ext3').checked
? 1 : 0;
304 fom
.usb_fs_fat
.value
= E('_f_fat').checked
? 1 : 0;
306 fom
.usb_fs_ntfs
.value
= E('_f_ntfs').checked
? 1 : 0;
308 fom
.usb_fs_hfs
.value
= E('_f_hfs').checked
? 1 : 0; //!Victek
309 fom
.usb_fs_hfsplus
.value
= E('_f_hfsplus').checked
? 1 : 0; //!Victek
310 fom
.usb_automount
.value
= E('_f_automount').checked
? 1 : 0;
311 fom
.idle_enable
.value
= E('_f_idle_enable').checked
? 1 : 0;
316 function submit_complete()
323 <body onload='init()'
>
324 <form id='_fom' method='post' action='tomato.cgi'
>
325 <table id='container' cellspacing=
0>
326 <tr><td colspan=
2 id='header'
>
327 <div class='title'
>Tomato
</div>
328 <div class='version'
>Version <%
version(); %></div>
330 <tr id='body'
><td id='navi'
><script type='text/javascript'
>navi()</script></td>
332 <div id='ident'
><%
ident(); %></div>
336 <input type='hidden' name='_nextpage' value='nas-usb.asp'
>
337 <input type='hidden' name='_service' value='usb-restart'
>
339 <input type='hidden' name='usb_enable'
>
340 <input type='hidden' name='usb_uhci'
>
341 <input type='hidden' name='usb_ohci'
>
342 <input type='hidden' name='usb_usb2'
>
343 <input type='hidden' name='usb_storage'
>
344 <input type='hidden' name='usb_printer'
>
345 <input type='hidden' name='usb_printer_bidirect'
>
346 <input type='hidden' name='usb_fs_ext3'
>
347 <input type='hidden' name='usb_fs_fat'
>
349 <input type='hidden' name='usb_fs_ntfs'>
351 <input type='hidden' name='usb_fs_hfs'
>
352 <input type='hidden' name='usb_fs_hfsplus'
>
353 <input type='hidden' name='usb_automount'
>
354 <input type='hidden' name='idle_enable'
>
356 <div class='section-title'
>USB Support
</div>
357 <div class='section'
>
358 <script type='text/javascript'
>
360 createFieldTable('', [
361 { title
: 'Core USB Support', name
: 'f_usb', type
: 'checkbox', value
: nvram
.usb_enable
== 1 },
362 { title
: 'USB 2.0 Support', indent
: 2, name
: 'f_usb2', type
: 'checkbox', value
: nvram
.usb_usb2
== 1 },
363 { title
: 'USB 1.1 Support', indent
: 2, multi
: [
364 { suffix
: ' OHCI ', name
: 'f_ohci', type
: 'checkbox', value
: nvram
.usb_ohci
== 1 },
365 { suffix
: ' UHCI ', name
: 'f_uhci', type
: 'checkbox', value
: nvram
.usb_uhci
== 1 }
368 { title
: 'USB Printer Support', name
: 'f_print', type
: 'checkbox', value
: nvram
.usb_printer
== 1 },
369 { title
: 'Bidirectional copying', indent
: 2, name
: 'f_bprint', type
: 'checkbox', value
: nvram
.usb_printer_bidirect
== 1 },
371 { title
: 'USB Storage Support', name
: 'f_storage', type
: 'checkbox', value
: nvram
.usb_storage
== 1 },
372 { title
: 'File Systems Support', indent
: 2, multi
: [
373 { suffix
: ' Ext2 / Ext3 ', name
: 'f_ext3', type
: 'checkbox', value
: nvram
.usb_fs_ext3
== 1 },
375 { suffix
: ' NTFS ', name
: 'f_ntfs', type
: 'checkbox', value
: nvram
.usb_fs_ntfs
== 1 },
377 { suffix
: ' FAT ', name
: 'f_fat', type
: 'checkbox', value
: nvram
.usb_fs_fat
== 1 },
378 { suffix
: ' HFS ', name
: 'f_hfs', type
: 'checkbox', value
: nvram
.usb_fs_hfs
== 1 },
379 { suffix
: ' HFS+ ', name
: 'f_hfsplus', type
: 'checkbox', value
: nvram
.usb_fs_hfsplus
== 1 }
381 { title
: 'Automount', indent
: 2, name
: 'f_automount', type
: 'checkbox',
382 suffix
: ' <small>Automatically mount all partitions to sub-directories in <i>/mnt</i>.</small>', value
: nvram
.usb_automount
== 1 },
383 { title
: 'Run after mounting', indent
: 2, name
: 'script_usbmount', type
: 'textarea', value
: nvram
.script_usbmount
},
384 { title
: 'Run before unmounting', indent
: 2, name
: 'script_usbumount', type
: 'textarea', value
: nvram
.script_usbumount
},
387 { title
: 'HDD Spindown', name
: 'f_idle_enable', type
: 'checkbox',
388 suffix
: ' <small>Spin down each HDD when idle (not for use with Flashdrive)</small>', value
: nvram
.idle_enable
== 1 },
391 { title
: 'Hotplug script<br><small>(called when any USB device is attached or removed)</small>', name
: 'script_usbhotplug', type
: 'textarea', value
: nvram
.script_usbhotplug
},
393 { text
: '<small>Some of the changes will take effect only after a restart.</small>' }
400 <div class='section-title'
>Attached Devices
</div>
401 <div class='section'
>
402 <table id='dev-grid' class='tomato-grid' cellspacing=
0></table>
403 <div id='usb-controls'
>
404 <script type='text/javascript'
>genStdRefresh(1,0,'ref.toggle()');</script>
406 <script type='text/javascript'
></script>
412 <tr><td id='footer' colspan=
2>
413 <span id='footer-msg'
></span>
414 <input type='button' value='Save' id='save-button' onclick='save()'
>
415 <input type='button' value='Cancel' id='cancel-button' onclick='javascript:reloadPage();'
>
419 <script type='text/javascript'
>earlyInit();verifyFields(null, 1);</script>