Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. <!--
  2. USB port settings
  3. Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
  4. $Id: settingsUSB.html 597 2015-04-20 11:41:28Z imoore76 $
  5. -->
  6. <table id='vboxSettingsUSBTable' style='width: 100%'>
  7. <tr>
  8. <td><label><input type='checkbox' class='vboxCheckbox vboxEnablerCheckbox' name='vboxSettingsUSBEnabled' /> <span class='translate'>Enable USB Controller</span></label></td>
  9. </tr>
  10. <tr>
  11. <td style='width: 100%; padding-left: 20px;'><label><input type='radio' class='vboxCheckbox' name='vboxSettingsUSBControllerType' value='OHCI'/> <span class='translate vboxEnablerListen'>USB 1.1 (OHCI) Controller</span></label></td>
  12. </tr>
  13. <tr>
  14. <td style='width: 100%; padding-left: 20px;'><label><input type='radio' class='vboxCheckbox' name='vboxSettingsUSBControllerType' value='EHCI'/> <span class='translate vboxEnablerListen'>USB 2.0 (EHCI) Controller</span></label></td>
  15. </tr>
  16. <tr>
  17. <td style='width: 100%; padding-left: 20px;'><label><input type='radio' class='vboxCheckbox' name='vboxSettingsUSBControllerType' value='XHCI'/> <span class='translate vboxEnablerListen'>USB 3.0 (xHCI) Controller</span></label></td>
  18. </tr>
  19. <tr style='vertical-align: middle' class='vboxRunningEnabled'>
  20. <td style='width: 100%; padding-left: 20px;'>
  21. <table class='vboxSettingsHeadingLine' style='width:100%;border-spacing:0;border:0px;margin:0px;padding:0px;'><tr style='vertical-align:middle' class='vboxRunningEnabled'><td style='white-space: nowrap; width: auto'><span class='translate vboxEnablerListen'>USB Device Filters</span></td><td style='width: 100%'><hr style='width: 100%;' class='vboxSeparatorLine'/></td></tr></table>
  22. </td>
  23. </tr>
  24. <tr class='vboxRunningEnabled'>
  25. <td style='width: 100%; padding-left: 20px;'>
  26. <table style='width: 100%'>
  27. <tr class='vboxRunningEnabled'>
  28. <td id='vboxSettingsUSBFilters' style='width: 100%;' class='vboxBordered vboxEnablerListen'>
  29. <!-- Hidden div for context menu -->
  30. <div id='vboxSettingsUSBAddDeviceClick' style='display: none' />
  31. <ul id='vboxSettingsUSBFilterList' class='vboxList vboxHover' style='width: 100%'>
  32. <li class='vboxListItem'><input type='checkbox' class='vboxCheckbox' />a</li>
  33. </ul>
  34. </td>
  35. <td id='vboxSettingsUSBButtons' class='vboxEnablerListen'></td>
  36. </tr>
  37. </table>
  38. </td>
  39. </tr>
  40. </table>
  41. <script type='text/javascript'>
  42. /*
  43. * USB Buttons and Toolbar
  44. */
  45. //Translations
  46. $('#vboxSettingsTabPortsUSB').find(".translate").html(function(i,h){return trans($('<div />').html(h).text(),'UIMachineSettingsUSB');}).removeClass('translate');
  47. var sButtons = new Array(
  48. {
  49. 'name' : 'usbnew',
  50. 'label' : 'Add Empty Filter',
  51. 'icon' : 'usb_new',
  52. 'click' : function () {
  53. var list = $('#vboxSettingsUSBFilterList');
  54. var currUsbName = 1;
  55. for(; currUsbName < 99; currUsbName++) {
  56. if(!$(list).find('span.vboxSettingsUSBFilterTitle').filter(function(){
  57. return ($(this).text() == trans('New Filter %1','UIMachineSettingsUSB').replace('%1',currUsbName));
  58. }).length) break;
  59. }
  60. vboxSettingsAddUSBFilter({'active':1,'name':trans('New Filter %1','UIMachineSettingsUSB').replace('%1',currUsbName)});
  61. if(!$('#vboxSettingsUSBFilterList').find('.vboxListItemSelected').first().trigger('click').html()) {
  62. $('#vboxSettingsUSBFilterList').trigger('select',null); }
  63. }
  64. },
  65. {
  66. 'name' : 'usbnewdevice',
  67. 'label' : 'Add Filter From Device',
  68. 'icon' : 'usb_add',
  69. 'click' : function (e) {
  70. // Update menu
  71. var menu = $("#vboxSettingsUSBAddDevice");
  72. menu.children().remove();
  73. menu.append($('<li />').html('<span><img src="images/jqueryFileTree/spinner.gif" /></span>').css({'width':'100px','text-align':'center'}));
  74. var l = new vboxLoader();
  75. l.add('hostGetUSBDevices',function(res){
  76. var hostUSB = res.responseData;
  77. $(menu).children().remove();
  78. for(var i = 0; i < hostUSB.length; i++) {
  79. var dname = '';
  80. if(!hostUSB[i].product)
  81. dname = trans('Unknown device %1:%2','VBoxGlobal').replace('%1',hostUSB[i].vendorId).replace('%2',hostUSB[i].productId);
  82. else
  83. dname = hostUSB[i].manufacturer + ' ' + hostUSB[i].product;
  84. dname += ' [' + hostUSB[i].revision + ']';
  85. $(menu).append($('<li />').append($('<a />').attr({'href':'#usbDev'+i}).html(dname).data({'device':hostUSB[i]})));
  86. }
  87. // No devices?
  88. if(hostUSB.length == 0) {
  89. $(menu).append($('<li />').append($('<a />').attr({'href':'#usbNoop'}).html($('<div />').text(trans('<no devices available>','VBoxUSBMenu')).html()).data({'device':hostUSB[i]})));
  90. }
  91. $(menu).trigger('menuLoaded');
  92. vboxPositionToWindow(menu);
  93. },{});
  94. l.noLoadingScreen = true;
  95. l.run();
  96. // Trigger mouse up / down on hidden element
  97. var md = jQuery.Event("mousedown");
  98. var mu = jQuery.Event("mouseup");
  99. for(var i in e) { (md[i] ? null : md[i] = mu[i] = e[i]); }
  100. // Fix mouse button for MSIE
  101. if(jQuery.browser.msie && e.button == 0) md.button = mu.button = 1;
  102. $("#vboxSettingsUSBAddDeviceClick").trigger(md).trigger(mu);
  103. }
  104. },
  105. {
  106. 'name' : 'usbedit',
  107. 'label' : 'Edit Filter',
  108. 'icon' : 'usb_filter_edit',
  109. 'enabled' : function (item) { return (item && $(item).data('filter') && $(item).data('filter').name); },
  110. 'click' : function () {
  111. var d = $('<div />').attr({'id':'vboxSettingsUSBFilterEdit','style':'display: none','class':'vboxNonTabbed vboxDialogContent'});
  112. var tbl = $('<table />').attr({'style':'width: 100%','class':'vboxSettingsTable'});
  113. var vboxSettingsUSBFilterProps = [
  114. ['Name','name'],['Vendor ID','vendorId'],['Product ID','productId'],
  115. ['Revision','revision'],['Manufacturer','manufacturer'],['Product','product'],
  116. ['Serial No.','serialNumber'],['Port','port']];
  117. /* Get Defaults */
  118. var filter = $('#vboxSettingsUSBFilterList').find('li.vboxListItemSelected').first().data('filter');
  119. for(var i = 0; i < vboxSettingsUSBFilterProps.length; i++) {
  120. var val = (filter[vboxSettingsUSBFilterProps[i][1]]||'');
  121. $('<tr />').append($('<th />').attr({'style':'white-space: nowrap; width: auto; text-align: right;'}).html(trans(vboxSettingsUSBFilterProps[i][0]+':','UIMachineSettingsUSBFilterDetails'))).append($('<td />').attr({'style':'width: 100%'}).html('<input type="text" class="vboxText" style="width: 100%" id="vboxSettingsUSBF'+vboxSettingsUSBFilterProps[i][1]+'" value="'+$('<div />').text((filter[vboxSettingsUSBFilterProps[i][1]]||'')).html()+'"/>')).appendTo(tbl);
  122. }
  123. // Generate select box
  124. var sel = $('<select />').attr({'id':'vboxSettingsUSBFRemote'});
  125. var opts = [['',trans('Any','UIMachineSettingsUSBFilterDetails')],['yes',trans('Yes','UIMachineSettingsUSBFilterDetails')],['no',trans('No','UIMachineSettingsUSBFilterDetails')]];
  126. for(var i = 0; i < opts.length; i++) {
  127. var o = new Option(opts[i][1],opts[i][0],((filter['remote']||'')==opts[i][0]));
  128. $(sel).prop('options').add(o);
  129. }
  130. $('<tr />').append($('<th />').attr({'style':'white-space: nowrap; width: auto; text-align: right;'}).html(trans('Remote:','UIMachineSettingsUSBFilterDetails'))).append($('<td />').attr({'style':'width: 100%'}).append(sel)).appendTo(tbl);
  131. $(d).append(tbl).appendTo($('#vboxPane'));
  132. var buttons = { };
  133. buttons[trans('OK','QIMessageBox')] = function() {
  134. var item = $('#vboxSettingsUSBFilterList').find('.vboxListItemSelected').first();
  135. for(var i = 0; i < vboxSettingsUSBFilterProps.length; i++) {
  136. $(item).data('filter')[vboxSettingsUSBFilterProps[i][1]] = $('#vboxSettingsUSBF'+(vboxSettingsUSBFilterProps[i][1])).val();
  137. }
  138. $(item).data('filter').remote = ($('#vboxSettingsUSBFRemote').val()||'');
  139. // Change display name
  140. $(item).find('span.vboxSettingsUSBFilterTitle').first().text($(item).data('filter').name);
  141. $('#vboxSettingsUSBFilterEdit').remove();
  142. };
  143. buttons[trans('Cancel','QIMessageBox')] = function() { $('#vboxSettingsUSBFilterEdit').remove(); };
  144. $('#vboxSettingsUSBFilterEdit').dialog({'buttons':buttons,'closeOnEscape':false,'width':400,'modal':true,'autoOpen':true,'dialogClass':'vboxDialogContent vboxNonTabbed','title':'<img src="images/vbox/usb_16px.png" class="vboxDialogTitleIcon" /> '+trans('USB Filter Details','UIMachineSettingsUSBFilterDetails')});
  145. }
  146. },
  147. {
  148. 'name' : 'usbremove',
  149. 'label' : 'Remove Filter',
  150. 'icon' : 'usb_remove',
  151. 'enabled' : function (item) { return (item && $(item).data('filter') && $(item).data('filter').name); },
  152. 'click' : function () {
  153. var item = $('#vboxSettingsUSBFilterList').find('.vboxListItemSelected').first();
  154. // determine next target
  155. var target = $(item).next();
  156. if(!$(target).length) target = $(item).prev();
  157. if(!$(target).length) target = null;
  158. $(item).empty().remove();
  159. if(!$(target).trigger('click').length) {
  160. $('#vboxSettingsUSBFilterList').trigger('select',null);
  161. }
  162. vboxColorRows($('#vboxSettingsUSBFilterList'));
  163. }
  164. },
  165. {
  166. 'name' : 'usbup',
  167. 'label' : 'Move Filter Up',
  168. 'icon' : 'usb_moveup',
  169. 'enabled' : function (item) {
  170. return (item && $(item).data('filter') && $(item).data('filter').name && $(item).attr('id') != $('#vboxSettingsUSBFilterList').children().first().attr('id'));
  171. },
  172. 'click' : function () {
  173. var item = $('#vboxSettingsUSBFilterList').find('.vboxListItemSelected').first();
  174. var prev = $(item).prev();
  175. if(!$(prev).length) return;
  176. var mv = $(item).detach();
  177. $(prev).before(mv);
  178. vboxColorRows($('#vboxSettingsUSBFilterList'));
  179. $('#vboxSettingsUSBFilterList').find('.vboxListItemSelected').first().trigger('click');
  180. }
  181. },
  182. {
  183. 'name' : 'usbdown',
  184. 'label' : 'Move Filter Down',
  185. 'icon' : 'usb_movedown',
  186. 'enabled' : function (item) {
  187. return (item && $(item).data('filter') && $(item).data('filter').name && $(item).attr('id') != $('#vboxSettingsUSBFilterList').children().last().attr('id'));
  188. },
  189. 'click' : function () {
  190. var item = $('#vboxSettingsUSBFilterList').find('.vboxListItemSelected').first();
  191. var next = $(item).next();
  192. if(!$(next).length) return;
  193. var mv = $(item).detach();
  194. $(next).after(mv);
  195. vboxColorRows($('#vboxSettingsUSBFilterList'));
  196. $('#vboxSettingsUSBFilterList').find('.vboxListItemSelected').first().trigger('click');
  197. }
  198. }
  199. );
  200. var usbToolbar = new vboxToolbarSmall({buttons: sButtons,
  201. language_context: 'UIMachineSettingsUSB', renderTo: 'vboxSettingsUSBButtons'});
  202. $('#vboxSettingsUSBFilterList').on('select',function(e,el){usbToolbar.update(el);});
  203. /* Adds a USB filter to list */
  204. function vboxSettingsAddUSBFilter(f,noColor) {
  205. var li = $('<li />').data({'filter':f}).attr({'id':'vboxSettingsUSBFilterNumber' + (Math.floor(Math.random()*1000)),'class':'vboxListItem'});
  206. if(document.forms['frmVboxSettings'].vboxSettingsUSBEnabled.checked) {
  207. li.click(function(){
  208. $(this).parent().children().removeClass('vboxListItemSelected');
  209. $(this).addClass('vboxListItemSelected');
  210. $('#vboxSettingsUSBFilterList').trigger('select',this);
  211. }).dblclick(function(e){
  212. e.preventDefault();
  213. usbToolbar.click('usbedit');
  214. }).hoverClass('vboxHover').disableSelection();
  215. }
  216. $('<input />').attr({'type':'checkbox'}).prop('checked',(f.active ? true : false)).appendTo(li);
  217. $(li).append(' <span class="vboxSettingsUSBFilterTitle">'+$('<div/>').text(f.name).html()+'</span>').appendTo($('#vboxSettingsUSBFilterList'));
  218. if(!noColor) vboxColorRows($('#vboxSettingsUSBFilterList'));
  219. }
  220. /* Menu for adding existing USB device */
  221. var exUsb = new vboxMenu({id: 'vboxSettingsUSBAddDevice', menuItems: []});
  222. /* Add attachment button menu initialization */
  223. $("#vboxSettingsUSBAddDeviceClick").contextMenu({
  224. menu: 'vboxSettingsUSBAddDevice',
  225. button: 0
  226. },
  227. function(action, el, pos, menuItem) {
  228. if(action == 'usbNoop') return;
  229. // usb data kept in elm
  230. var usb = $(menuItem).data('device');
  231. delete usb.port, usb.version, usb.portVersion;
  232. usb.name = $(menuItem).html();
  233. usb.active = 1;
  234. vboxSettingsAddUSBFilter(usb);
  235. $('#vboxSettingsUSBFilterList').trigger('select',$('#vboxSettingsUSBFilterList').find('.vboxListItemSelected').first());
  236. }
  237. );
  238. /*
  239. * USB data
  240. */
  241. $('#vboxSettingsDialog').on('dataLoaded',function(){
  242. // set checkboxes for USB and EHCI
  243. if($('#vboxSettingsDialog').data('vboxMachineData').USBControllers.length) {
  244. var usbType = 'OHCI';
  245. var enabled = false;
  246. for(var i = 0; i < $('#vboxSettingsDialog').data('vboxMachineData').USBControllers.length; i++) {
  247. var listUSBType = $('#vboxSettingsDialog').data('vboxMachineData').USBControllers[i].type;
  248. if(listUSBType == 'OHCI') {
  249. enabled = true;
  250. }
  251. switch(listUSBType) {
  252. case 'OHCI':
  253. if(usbType == 'EHCI')
  254. break;
  255. case 'EHCI':
  256. if(usbType == 'XHCI')
  257. break;
  258. default:
  259. usbType = listUSBType;
  260. }
  261. }
  262. $(document.forms['frmVboxSettings'].vboxSettingsUSBEnabled).prop('checked',enabled).triggerHandler('click');
  263. $(document.forms['frmVboxSettings']).find('input[value="'+usbType+'"]').prop('checked',true);
  264. } else {
  265. $(document.forms['frmVboxSettings'].vboxSettingsUSBEnabled).prop('checked',false).triggerHandler('click');
  266. $(document.forms['frmVboxSettings']).find('input[value="OHCI"]').prop('checked',true);
  267. }
  268. // clear list
  269. var list = $('#vboxSettingsUSBFilterList');
  270. $(list).empty().children().remove();
  271. // add filters
  272. for(var i = 0; i < $('#vboxSettingsDialog').data('vboxMachineData').USBDeviceFilters.length; i++) {
  273. vboxSettingsAddUSBFilter($('#vboxSettingsDialog').data('vboxMachineData').USBDeviceFilters[i],true);
  274. }
  275. vboxColorRows($('#vboxSettingsUSBFilterList'));
  276. if(!$('#vboxSettingsUSBFilterList').find('li.vboxListItem').first().trigger('click')) {
  277. $('#vboxSettingsUSBFilterList').trigger('select',null);
  278. }
  279. var p = $('#vboxSettingsUSBTable');
  280. if(!$('#vboxSettingsDialog').data('vboxFullEdit')) {
  281. $(p).find('tr:not(.vboxRunningEnabled)').find('span').addClass('disabled');
  282. $(p).find('tr:not(.vboxRunningEnabled)').find('input,select,textarea').prop('disabled',true);
  283. } else {
  284. $(p).find('tr:not(.vboxRunningEnabled)').find('span').removeClass('disabled');
  285. $(p).find('tr:not(.vboxRunningEnabled)').find('input,select,textarea').prop('disabled',false);
  286. }
  287. });
  288. /* Change settings onSave() */
  289. $('#vboxSettingsDialog').on('save',function(){
  290. // get checkboxes for USB and EHCI
  291. var frmEnabled = document.forms['frmVboxSettings'].vboxSettingsUSBEnabled.checked;
  292. var frmType = $(document.forms['frmVboxSettings']).find('input[name="vboxSettingsUSBControllerType"]:checked').val();
  293. $('#vboxSettingsDialog').data('vboxMachineData').USBControllers = new Array();
  294. if(frmEnabled) {
  295. $('#vboxSettingsDialog').data('vboxMachineData').USBControllers = [{
  296. 'name': 'OHCI',
  297. 'type': 'OHCI'
  298. }];
  299. }
  300. if(frmType != 'OHCI') {
  301. $('#vboxSettingsDialog').data('vboxMachineData').USBControllers.push({
  302. 'name': frmType,
  303. 'type': frmType
  304. });
  305. }
  306. $('#vboxSettingsDialog').data('vboxMachineData').USBDeviceFilters = new Array();
  307. $('#vboxSettingsUSBFilterList').children('li').each(function(){
  308. $(this).data('filter').active = $(this).children('input:checkbox').first().prop('checked');
  309. $('#vboxSettingsDialog').data('vboxMachineData').USBDeviceFilters[$('#vboxSettingsDialog').data('vboxMachineData').USBDeviceFilters.length] = $(this).data('filter');
  310. });
  311. });
  312. </script>