Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

settingsSerialPorts.html 9.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <!--
  2. Serial port settings
  3. Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
  4. $Id: settingsSerialPorts.html 597 2015-04-20 11:41:28Z imoore76 $
  5. -->
  6. <div id='vboxSettingsTabSerialPort' style='display: none'>
  7. <table class='vboxVertical'>
  8. <tr>
  9. <td colspan='2'><label><input name='vboxSettingsSPortEnabled' class='vboxCheckbox vboxEnablerCheckbox' type='checkbox' /> <span class='translate'>Enable Serial Port</span></label></td>
  10. </tr>
  11. <tr>
  12. <th style='min-width: 120px'><span class='translate'>Port Number:</span></th>
  13. <td class='vboxEnablerTrigger'>
  14. <select style='width: auto' name='vboxSettingsPortNumber' onchange='vboxSettingsUpdateSPortOptions(this);'>
  15. <option value='COM1'>COM1</option>
  16. <option value='COM2'>COM2</option>
  17. <option value='COM3'>COM3</option>
  18. <option value='COM4'>COM4</option>
  19. <option value='User-defined' class='translate'>User-defined</option>
  20. </select>
  21. <span class='vboxEnablerListen'><span class='translate'>IRQ:</span></span> <input type='text' name='vboxSettingsSPortIRQ' size='2' />
  22. <span class='vboxEnablerListen'><span class='translate'>I/O Port:</span></span> <input type='text' name='vboxSettingsSPortIO' size='5' />
  23. </td>
  24. </tr>
  25. <tr>
  26. <th><span class='translate'>Port Mode:</span></th>
  27. <td class='vboxEnablerTrigger'>
  28. <select style='width: auto' name='vboxSettingsPortMode' onchange='vboxSettingsUpdateSPortMode(this);'>
  29. <option value='Disconnected' >Disconnected</option>
  30. <option value='HostPipe' >HostPipe</option>
  31. <option value='HostDevice' >HostDevice</option>
  32. <option value='RawFile' >RawFile</option>
  33. </select>
  34. </td>
  35. </tr>
  36. <tr>
  37. <th></th>
  38. <td>
  39. <label><input type='checkbox' class='vboxCheckbox vboxSettingsSPortCreatePipe' name='vboxSettingsSPortCreatePipe' />
  40. <span class='translate vboxEnablerListen'>Create Pipe</span></label>
  41. </td>
  42. </tr>
  43. <tr>
  44. <th class='vboxSPortPathLabel'><span class='translate'>Port/File Path:</span></th>
  45. <td>
  46. <input type='text' class='vboxText vboxSPortPathBox' style='width: 100%' name='vboxSettingsSPortPath'/>
  47. </td>
  48. </tr>
  49. </table>
  50. </div>
  51. <script type='text/javascript'>
  52. /*
  53. *
  54. * Setup data for serial port options
  55. *
  56. */
  57. var vboxSettingsSPortTemplate = document.getElementById('vboxSettingsTabSerialPort');
  58. var vboxSettingsSPortContainer = $(vboxSettingsSPortTemplate).parent();
  59. /* translated select values */
  60. for(var i = 0; i < document.forms['frmVboxSettings'].vboxSettingsPortNumber.options.length; i++) {
  61. if($(document.forms['frmVboxSettings'].vboxSettingsPortNumber.options[i]).hasClass('translate'))
  62. $(document.forms['frmVboxSettings'].vboxSettingsPortNumber.options[i]).text(trans(document.forms['frmVboxSettings'].vboxSettingsPortNumber.options[i].text,'VBoxGlobal')).removeClass('translate');
  63. }
  64. for(var i = 0; i < document.forms['frmVboxSettings'].vboxSettingsPortMode.options.length; i++) {
  65. document.forms['frmVboxSettings'].vboxSettingsPortMode.options[i].text = trans(vboxSerialMode(document.forms['frmVboxSettings'].vboxSettingsPortMode.options[i].text),'VBoxGlobal');
  66. }
  67. // Translations
  68. $('#vboxSettingsTabSerialPort').find(".translate").html(function(i,h){return trans($('<div />').html(h).text(),'UIMachineSettingsSerial');}).removeClass('translate');
  69. /* Serial Port tab links */
  70. var ul = $('<ul />');
  71. $(vboxSettingsSPortContainer).append(ul);
  72. for(var i = 0; i < parseInt($('#vboxPane').data('vboxSystemProperties').serialPortCount); i++) {
  73. /* tab */
  74. ul.append($('<li />').html('<a href="#' + vboxSettingsSPortTemplate.id + (i + 1) +'"><span>' + trans('Port %1','UIMachineSettingsSerial').replace('%1',i + 1) + '</span></a>'));
  75. /* tab content */
  76. var newTab = $("#vboxSettingsTabSerialPort").clone(true);
  77. newTab.attr({'id':vboxSettingsSPortTemplate.id + (i + 1)}).css({'display':'block'}).find('.vboxEnablerTrigger').on('enable',function(){
  78. $(this).find('select').trigger('change');
  79. });
  80. newTab.appendTo(vboxSettingsSPortContainer);
  81. /* Form elements must be unique */
  82. $("#vboxSettingsTabSerialPort" + (i + 1)).find('[name]').each(function() {
  83. $(this).attr('name',$(this).attr('name') + (i + 1));
  84. });
  85. }
  86. /* Remove Template */
  87. $("#vboxSettingsTabSerialPort").empty().remove();
  88. // Tell jQuery to set up tabs
  89. $(vboxSettingsSPortContainer).tabs();
  90. /*
  91. * Called when serial port options change
  92. */
  93. function vboxSettingsUpdateSPortOptions(sel) {
  94. // IRQ and IO text boxes
  95. if(sel.value == 'User-defined') {
  96. $(sel).siblings('input').prop('disabled',false);
  97. $(sel).siblings('span').removeClass('vboxDisabled');
  98. } else {
  99. $(sel).siblings('input').prop('disabled',true);
  100. $(sel).siblings('span').addClass('vboxDisabled');
  101. for(var i = 0; i < vboxSerialPorts.ports.length; i++) {
  102. if(vboxSerialPorts.ports[i].name == sel.value) {
  103. $(sel).siblings('input').first().val(vboxSerialPorts.ports[i].irq);
  104. $(sel).siblings('input').last().val(vboxSerialPorts.ports[i].port);
  105. return;
  106. }
  107. }
  108. }
  109. }
  110. /*
  111. * When serial port mode changes
  112. */
  113. function vboxSettingsUpdateSPortMode(sel) {
  114. var ptable = $(sel).closest('table');
  115. if(sel.value == 'HostPipe') {
  116. ptable.find('input.vboxSettingsSPortCreatePipe').prop({'disabled':false}).siblings().removeClass('vboxDisabled');
  117. } else {
  118. ptable.find('input.vboxSettingsSPortCreatePipe').prop({'disabled':true}).siblings().addClass('vboxDisabled');
  119. }
  120. if(sel.value == 'Disconnected') {
  121. ptable.find('.vboxSPortPathLabel').addClass('vboxDisabled');
  122. ptable.find('.vboxSPortPathBox').prop('disabled',true);
  123. } else {
  124. ptable.find('.vboxSPortPathLabel').removeClass('vboxDisabled');
  125. ptable.find('.vboxSPortPathBox').prop('disabled',false);
  126. }
  127. }
  128. /* When data is loaded */
  129. $('#vboxSettingsDialog').on('dataLoaded',function(){
  130. /*
  131. * Serial ports
  132. *
  133. */
  134. for(var i = 0; i < parseInt($('#vboxSettingsDialog').data('vboxMachineData').serialPorts.length); i++) {
  135. var a = (i + 1);
  136. if(a > $('#vboxPane').data('vboxSystemProperties').serialPortCount) continue;
  137. // Port Number
  138. var pNum = vboxSerialPorts.getPortName($('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].IRQ,$('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].IOBase);
  139. $(document.forms['frmVboxSettings'].elements['vboxSettingsPortNumber'+a]).val(pNum);
  140. $(document.forms['frmVboxSettings'].elements['vboxSettingsPortNumber'+a].options[document.forms['frmVboxSettings'].elements['vboxSettingsPortNumber'+a].selectedIndex]).attr('selected','selected');
  141. $(document.forms['frmVboxSettings'].elements['vboxSettingsPortNumber'+a]).change();
  142. $(document.forms['frmVboxSettings'].elements['vboxSettingsSPortIRQ'+a]).val($('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].IRQ);
  143. $(document.forms['frmVboxSettings'].elements['vboxSettingsSPortIO'+a]).val($('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].IOBase);
  144. // Port Mode
  145. $(document.forms['frmVboxSettings'].elements['vboxSettingsPortMode'+a]).val($('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].hostMode);
  146. $(document.forms['frmVboxSettings'].elements['vboxSettingsPortMode'+a].options[document.forms['frmVboxSettings'].elements['vboxSettingsPortMode'+a].selectedIndex]).attr('selected','selected');
  147. $(document.forms['frmVboxSettings'].elements['vboxSettingsPortMode'+a]).change();
  148. // Create pipe
  149. $(document.forms['frmVboxSettings'].elements['vboxSettingsSPortCreatePipe'+a]).prop('checked',($('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].server ? true : false)).triggerHandler('click');
  150. // Path
  151. $(document.forms['frmVboxSettings'].elements['vboxSettingsSPortPath'+a]).val($('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].path);
  152. // Enabled
  153. $(document.forms['frmVboxSettings'].elements['vboxSettingsSPortEnabled'+a]).prop('checked',($('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].enabled));
  154. }
  155. if(!$('#vboxSettingsDialog').data('vboxFullEdit')) {
  156. vboxSettingsSPortContainer.find('input.vboxEnablerCheckbox').triggerHandler('click');
  157. vboxSettingsSPortContainer.children(':not(ul)').find('span').addClass('disabled');
  158. vboxSettingsSPortContainer.find('input,select,textarea').prop('disabled',true);
  159. } else {
  160. vboxSettingsSPortContainer.find('span').removeClass('disabled');
  161. vboxSettingsSPortContainer.find('input,select,textarea').prop('disabled',false);
  162. vboxSettingsSPortContainer.find('input.vboxEnablerCheckbox').triggerHandler('click');
  163. }
  164. });
  165. /* Change settings onSave() */
  166. $('#vboxSettingsDialog').on('save',function(){
  167. /* Net */
  168. for(var i = 0; i < parseInt($('#vboxPane').data('vboxSystemProperties').serialPortCount); i++) {
  169. var a = (i + 1);
  170. // Port IRQ and IO
  171. $('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].IRQ = $(document.forms['frmVboxSettings'].elements['vboxSettingsSPortIRQ'+a]).val();
  172. $('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].IOBase = $(document.forms['frmVboxSettings'].elements['vboxSettingsSPortIO'+a]).val();
  173. // Port Mode
  174. $('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].hostMode = $(document.forms['frmVboxSettings'].elements['vboxSettingsPortMode'+a]).val();
  175. // Create pipe
  176. $('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].server = document.forms['frmVboxSettings'].elements['vboxSettingsSPortCreatePipe'+a].checked;
  177. // Path
  178. $('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].path = $(document.forms['frmVboxSettings'].elements['vboxSettingsSPortPath'+a]).val();
  179. // Enabled port
  180. $('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].enabled = document.forms['frmVboxSettings'].elements['vboxSettingsSPortEnabled'+a].checked;
  181. }
  182. });
  183. </script>