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_mmc,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,usb_3g"); %>
52 // <% usbdevices(); %>
58 function _umountHost(host
)
60 form
.submitHidden('usbcmd.cgi', { remove
: host
});
63 function _mountHost(host
)
65 form
.submitHidden('usbcmd.cgi', { mount
: host
});
68 function _forceRefresh()
70 if (!ref
.running
) ref
.once
= 1;
74 function umountHost(a
, host
)
78 if ((xob
= new XmlHttp()) == null) {
84 a
.innerHTML
= 'Please wait...';
86 xob
.onCompleted = function(text
, xml
) {
88 if (usb
.length
== 1) {
90 ferror
.set(a
, 'The device is busy. Please make sure no applications are using it, and try again.', 0);
96 xob
.onError = function() {
101 xob
.post('usbcmd.cgi', 'remove=' + host
);
104 function mountHost(a
, host
)
108 if ((xob
= new XmlHttp()) == null) {
114 a
.innerHTML
= 'Please wait...';
116 xob
.onCompleted = function(text
, xml
) {
118 if (usb
.length
== 1) {
120 ferror
.set(a
, 'Failed to mount. Verify the device is plugged in, and try again.', 0);
126 xob
.onError = function() {
131 xob
.post('usbcmd.cgi', 'mount=' + host
);
134 var ref
= new TomatoRefresh('update.cgi', 'exec=usbdevices', 0, 'nas_usb_refresh');
136 ref
.refresh = function(text
)
149 var dg
= new TomatoGrid();
151 dg
.sortCompare = function(a
, b
) {
152 var col
= this.sortColumn
;
153 var ra
= a
.getRowData();
154 var rb
= b
.getRowData();
159 if (ra
.type
== 'Storage' && ra
.type
== rb
.type
)
160 r
= cmpInt(ra
.host
, rb
.host
);
162 r
= cmpText(ra
.host
, rb
.host
);
165 r
= cmpText(a
.cells
[col
].innerHTML
, b
.cells
[col
].innerHTML
);
167 return this.sortAscending
? r
: -r
;
170 dg
.populate = function()
172 var i
, j
, k
, a
, b
, c
, e
, s
, desc
, d
, parts
, p
;
176 for (i
= 0; i
< list
.length
; ++i
) {
180 list
[i
].product
= '';
183 list
[i
].is_mounted
= 0;
186 for (i
= usbdev
.length
- 1; i
>= 0; --i
) {
200 for (i
= list
.length
- 1; i
>= 0; --i
) {
203 if (e
.type
!= 'Storage')
204 s
= ' <br><small> </small>';
207 s
= ((e
.is_mounted
== 0) ? 'No' : 'Yes') + '<br><small>Please wait...</small>';
208 else if (e
.is_mounted
== 0)
209 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>';
211 s
= 'Yes<br><small><a href="javascript:umountHost(\'L' + i
+ '\',\'' + e
.host
+ '\')" title="Safely Remove Storage Device" id="L' + i
+ '">[ Unmount ]</a></small>';
213 desc
= (e
.vendor
+ ' ' + e
.product
).trim() + '<small>'; // + (e.serial == '' ? '' : '<br>Serial No: ' + e.serial);
215 for (j
= 0; j
<= e
.discs
.length
- 1; ++j
) {
218 for (k
= 0; k
<= parts
.length
- 1; ++k
) {
221 desc
= desc
+ '<br>Partition \'' + p
[0] + '\'' + (p
[3] != '' ? ' ' + p
[3] : '') +
222 ((p
[5] != 0) ? ' (' + doScaleSize(p
[5], 0) +
223 ((p
[1] == 1) ? ' / ' + doScaleSize(p
[6], 0) + ' free' : '') +
225 ((p
[1] != 0) ? '' : 'not ') + ((p
[3] == 'swap') ? 'active' : 'mounted') +
226 ((p
[2] != '') ? ' on ' + p
[2] : '');
231 desc
= desc
+ '</small>';
232 this.insert(-1, e
, [e
.type
, e
.host
, desc
, s
], false);
238 dg
.setup = function()
240 this.init('dev-grid', 'sort');
241 this.headerSet(['Type', 'Host', 'Description', 'Mounted?']);
257 function verifyFields(focused
, quiet
)
259 var b
= !E('_f_usb').checked
;
260 var a
= !E('_f_storage').checked
;
262 E('_f_uhci').disabled
= b
|| nvram
.usb_uhci
== -1;
263 E('_f_ohci').disabled
= b
|| nvram
.usb_ohci
== -1;
264 E('_f_usb2').disabled
= b
;
265 E('_f_print').disabled
= b
;
266 E('_f_storage').disabled
= b
;
270 E('_f_mmc').disabled
= a
|| b
|| nvram
.usb_mmc
== -1;
271 elem
.display(PR('_f_mmc'), nvram
.usb_mmc
!= -1);
275 E('_f_ext3').disabled
= b
|| a
;
276 E('_f_fat').disabled
= b
|| a
;
279 E('_f_idle_enable').disabled
= b
|| a
;
280 E('_f_usb_3g').disabled
= b
;
283 E('_f_ntfs').disabled
= b
|| a
;
285 E('_f_hfs').disabled
= b
|| a
; //!Victek
286 E('_f_hfsplus').disabled
= b
|| a
; //!Victek
287 E('_f_automount').disabled
= b
|| a
;
288 E('_f_bprint').disabled
= b
|| !E('_f_print').checked
;
290 elem
.display(PR('_f_automount'), !b
&& !a
);
291 elem
.display(PR('_script_usbmount'), PR('_script_usbumount'), !b
&& !a
&& E('_f_automount').checked
);
292 elem
.display(PR('_script_usbhotplug'), !b
&& (!a
|| E('_f_print').checked
));
294 if (!v_length('_script_usbmount', quiet
, 0, 2048)) return 0;
295 if (!v_length('_script_usbumount', quiet
, 0, 2048)) return 0;
296 if (!v_length('_script_usbhotplug', quiet
, 0, 2048)) return 0;
305 if (!verifyFields(null, 0)) return;
308 fom
.usb_enable
.value
= E('_f_usb').checked
? 1 : 0;
309 fom
.usb_uhci
.value
= nvram
.usb_uhci
== -1 ? -1 : (E('_f_uhci').checked
? 1 : 0);
310 fom
.usb_ohci
.value
= nvram
.usb_ohci
== -1 ? -1 : (E('_f_ohci').checked
? 1 : 0);
311 fom
.usb_usb2
.value
= E('_f_usb2').checked
? 1 : 0;
312 fom
.usb_storage
.value
= E('_f_storage').checked
? 1 : 0;
313 fom
.usb_printer
.value
= E('_f_print').checked
? 1 : 0;
314 fom
.usb_printer_bidirect
.value
= E('_f_bprint').checked
? 1 : 0;
318 fom
.usb_mmc
.value
= nvram
.usb_mmc
== -1 ? -1 : (E('_f_mmc').checked
? 1 : 0);
322 fom
.usb_fs_ext3
.value
= E('_f_ext3').checked
? 1 : 0;
323 fom
.usb_fs_fat
.value
= E('_f_fat').checked
? 1 : 0;
325 fom
.usb_fs_ntfs
.value
= E('_f_ntfs').checked
? 1 : 0;
327 fom
.usb_fs_hfs
.value
= E('_f_hfs').checked
? 1 : 0; //!Victek
328 fom
.usb_fs_hfsplus
.value
= E('_f_hfsplus').checked
? 1 : 0; //!Victek
329 fom
.usb_automount
.value
= E('_f_automount').checked
? 1 : 0;
331 fom
.idle_enable
.value
= E('_f_idle_enable').checked
? 1 : 0;
332 fom
.usb_3g
.value
= E('_f_usb_3g').checked
? 1 : 0;
338 function submit_complete()
345 <body onload='init()'
>
346 <form id='_fom' method='post' action='tomato.cgi'
>
347 <table id='container' cellspacing=
0>
348 <tr><td colspan=
2 id='header'
>
349 <div class='title'
>Tomato
</div>
350 <div class='version'
>Version <%
version(); %></div>
352 <tr id='body'
><td id='navi'
><script type='text/javascript'
>navi()</script></td>
354 <div id='ident'
><%
ident(); %></div>
358 <input type='hidden' name='_nextpage' value='nas-usb.asp'
>
359 <input type='hidden' name='_service' value='usb-restart'
>
361 <input type='hidden' name='usb_enable'
>
362 <input type='hidden' name='usb_uhci'
>
363 <input type='hidden' name='usb_ohci'
>
364 <input type='hidden' name='usb_usb2'
>
365 <input type='hidden' name='usb_mmc'
>
366 <input type='hidden' name='usb_storage'
>
367 <input type='hidden' name='usb_printer'
>
368 <input type='hidden' name='usb_printer_bidirect'
>
369 <input type='hidden' name='usb_fs_ext3'
>
370 <input type='hidden' name='usb_fs_fat'
>
372 <input type='hidden' name='usb_fs_ntfs'>
374 <input type='hidden' name='usb_fs_hfs'
>
375 <input type='hidden' name='usb_fs_hfsplus'
>
376 <input type='hidden' name='usb_automount'
>
378 <input type='hidden' name='idle_enable'
>
379 <input type='hidden' name='usb_3g'
>
382 <div class='section-title'
>USB Support
</div>
383 <div class='section'
>
384 <script type='text/javascript'
>
386 createFieldTable('', [
387 { title
: 'Core USB Support', name
: 'f_usb', type
: 'checkbox', value
: nvram
.usb_enable
== 1 },
388 { title
: 'USB 2.0 Support', indent
: 2, name
: 'f_usb2', type
: 'checkbox', value
: nvram
.usb_usb2
== 1 },
389 { title
: 'USB 1.1 Support', indent
: 2, multi
: [
390 { suffix
: ' OHCI ', name
: 'f_ohci', type
: 'checkbox', value
: nvram
.usb_ohci
== 1 },
391 { suffix
: ' UHCI ', name
: 'f_uhci', type
: 'checkbox', value
: nvram
.usb_uhci
== 1 }
394 { title
: 'USB Printer Support', name
: 'f_print', type
: 'checkbox', value
: nvram
.usb_printer
== 1 },
395 { title
: 'Bidirectional copying', indent
: 2, name
: 'f_bprint', type
: 'checkbox', value
: nvram
.usb_printer_bidirect
== 1 },
397 { title
: 'USB Storage Support', name
: 'f_storage', type
: 'checkbox', value
: nvram
.usb_storage
== 1 },
398 { title
: 'File Systems Support', indent
: 2, multi
: [
399 { suffix
: ' Ext2 / Ext3 ', name
: 'f_ext3', type
: 'checkbox', value
: nvram
.usb_fs_ext3
== 1 },
401 { suffix
: ' NTFS ', name
: 'f_ntfs', type
: 'checkbox', value
: nvram
.usb_fs_ntfs
== 1 },
403 { suffix
: ' FAT ', name
: 'f_fat', type
: 'checkbox', value
: nvram
.usb_fs_fat
== 1 },
404 { suffix
: ' HFS ', name
: 'f_hfs', type
: 'checkbox', value
: nvram
.usb_fs_hfs
== 1 },
405 { suffix
: ' HFS+ ', name
: 'f_hfsplus', type
: 'checkbox', value
: nvram
.usb_fs_hfsplus
== 1 }
409 { title
: 'SD/MMC Card Support', indent
: 2, name
: 'f_mmc', type
: 'checkbox', value
: nvram
.usb_mmc
== 1 },
412 { title
: 'Automount', indent
: 2, name
: 'f_automount', type
: 'checkbox',
413 suffix
: ' <small>Automatically mount all partitions to sub-directories in <i>/mnt</i>.</small>', value
: nvram
.usb_automount
== 1 },
414 { title
: 'Run after mounting', indent
: 2, name
: 'script_usbmount', type
: 'textarea', value
: nvram
.script_usbmount
},
415 { title
: 'Run before unmounting', indent
: 2, name
: 'script_usbumount', type
: 'textarea', value
: nvram
.script_usbumount
},
418 { title
: 'HDD Spindown', name
: 'f_idle_enable', type
: 'checkbox',
419 suffix
: ' <small>Spin down each HDD when idle (not for use with Flashdrive)</small>', value
: nvram
.idle_enable
== 1 },
421 { title
: 'USB 3G Modem support', name
: 'f_usb_3g', type
: 'checkbox',
422 suffix
: ' <small>Before disconnecting 3G Modem from USB port, remember to uncheck this box first. If your modem uses the usbserial module, you may have to reboot your router before plugging/unplugging the modem.</small>', value
: nvram
.usb_3g
== 1 },
425 { title
: 'Hotplug script<br><small>(called when any USB device is attached or removed)</small>', name
: 'script_usbhotplug', type
: 'textarea', value
: nvram
.script_usbhotplug
},
427 { text
: '<small>Some of the changes will take effect only after a restart.</small>' }
434 <div class='section-title'
>Attached Devices
</div>
435 <div class='section'
>
436 <table id='dev-grid' class='tomato-grid' cellspacing=
0></table>
437 <div id='usb-controls'
>
438 <script type='text/javascript'
>genStdRefresh(1,0,'ref.toggle()');</script>
440 <script type='text/javascript'
></script>
446 <tr><td id='footer' colspan=
2>
447 <span id='footer-msg'
></span>
448 <input type='button' value='Save' id='save-button' onclick='save()'
>
449 <input type='button' value='Cancel' id='cancel-button' onclick='javascript:reloadPage();'
>
453 <script type='text/javascript'
>earlyInit();verifyFields(null, 1);</script>