Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

settingsNetwork.html 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. <!--
  2. VM Network Settings
  3. Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
  4. $Id: settingsNetwork.html 597 2015-04-20 11:41:28Z imoore76 $
  5. -->
  6. <div id='vboxSettingsTabNetAdapter' title='Adapter' style='display: none'>
  7. <table class='vboxVertical'>
  8. <tr>
  9. <td colspan='2'><label><input name='vboxSettingsNetEnabled' class='vboxCheckbox vboxEnablerCheckbox' type='checkbox' /> <span class='translate'>Enable Network Adapter</span></label></td>
  10. </tr>
  11. <tr>
  12. <th style='min-width: 120px'><span class='translate'>Attached to:</span></th>
  13. <td style='width: 100%' class='vboxEnablerTrigger'>
  14. <select name='vboxSettingsNetAttachedTo' onchange='vboxSettingsUpdateNetworkOptions(this);' style='width: 100%'>
  15. <option value='Null' class='translate'>Not attached</option>
  16. <option value='NAT' class='translate'>NAT</option>
  17. <option value='NATNetwork' class='translate'>NAT Network</option>
  18. <option value='Bridged' class='translate'>Bridged Adapter</option>
  19. <option value='Internal' class='translate'>Internal Network</option>
  20. <option value='HostOnly' class='translate'>Host-only Adapter</option>
  21. <option value='Generic' class='translate'>Generic Driver</option>
  22. <option value='VDE' class='translate'>VDE Adapter</option>
  23. </select>
  24. </td>
  25. </tr>
  26. <tr>
  27. <th class='vboxSettingsNetAdapterNamedLabel'><span class='translate'>Name:</span></th>
  28. <td>
  29. <select name='vboxSettingsNetName' class='vboxSettingsNetAdapterNamed' style='width: 100%'>
  30. <option value=''></option>
  31. </select>
  32. </td>
  33. </tr>
  34. <!-- Advanced NAT Settings -->
  35. <tr class='vboxSettingsAdvancedNat' style='display: none'>
  36. <th><span class='translate'>NAT Alias Mode:</span></th>
  37. <td>
  38. <label><input type='checkbox' class='vboxCheckbox' class='vboxEnablerListen' name='vboxSettingsNetAliasModeProxyOnly' /> <span class='translate vboxEnablerListen'>Proxy Only</span></label><br />
  39. <label><input type='checkbox' class='vboxCheckbox' class='vboxEnablerListen' name='vboxSettingsNetAliasModeSamePorts' /> <span class='translate vboxEnablerListen'>Same Ports</span></label><br />
  40. </td>
  41. </tr>
  42. <tr class='vboxSettingsAdvancedNat' style='display: none'>
  43. <th><span class='translate'>Advanced NAT Options</span> :</th>
  44. <td>
  45. <label><input type='checkbox' class='vboxCheckbox' class='vboxEnablerListen' name='vboxSettingsNetPassDNSDomain' /> <span class='translate vboxEnablerListen'>Pass DNS Domain</span></label><br />
  46. <label><input type='checkbox' class='vboxCheckbox' class='vboxEnablerListen' name='vboxSettingsNetDNSProxy' /> <span class='translate vboxEnablerListen'>DNS Proxy</span></label><br />
  47. <label><input type='checkbox' class='vboxCheckbox' class='vboxEnablerListen' name='vboxSettingsNetUseHostResolver' /> <span class='translate vboxEnablerListen'>Use Host Resolver</span></label><br />
  48. <span class='translate vboxEnablerListen'>Bind to IP</span> <input type='text' class='vboxTextbox' class='vboxEnablerListen' name='vboxSettingsNetBindIp' size='16'/>
  49. </td>
  50. </tr>
  51. <tr>
  52. <th>
  53. <input class="netImgAdvanced vboxImgButton" style='background: url(images/rightArrow.png) 3px 2px no-repeat; width: 14px; height: 14px;' type="button" value="" />
  54. <span class='translate'>Advanced</span></th>
  55. <td></td>
  56. </tr>
  57. <tr class='vboxSettingsNetToggleAdvanced' style='display: none'>
  58. <th><span class='translate'>Adapter Type:</span></th>
  59. <td>
  60. <select name='vboxSettingsNetAdapter' style='width: 100%'>
  61. </select>
  62. </td>
  63. </tr>
  64. <tr class='vboxSettingsNetToggleAdvanced' style='display: none'>
  65. <th><span class='translate'>MAC Address:</span></th>
  66. <td style='white-space: nowrap'><input type='text' class='vboxText' style='width: 200px' name='vboxSettingsNetMAC' size='40' />
  67. <input class="vboxSettingsNetMacGen vboxImgButton" style='background: url(images/vbox/refresh_16px.png) 1px 1px no-repeat; width: 18px; height: 18px; vertical-align:bottom' type="button" value="" />
  68. </td>
  69. </tr>
  70. <tr class='vboxSettingsNetToggleAdvanced vboxSettingsNetPromiscuousMode' style='display: none'>
  71. <th class='vboxSettingsNetPromiscuousMode'><span class='translate'>Promiscuous Mode:</span></th>
  72. <td>
  73. <select class='vboxSettingsNetPromiscuousMode' name='vboxSettingsNetAdapterPromiscuousMode' style='width: 100%'>
  74. <option value='Deny'>Deny</option>
  75. <option value='AllowNetwork'>Allow VMs</option>
  76. <option value='AllowAll'>Allow All</option>
  77. </select>
  78. </td>
  79. </tr>
  80. <tr class='vboxSettingsNetToggleAdvanced vboxSettingsNetGenPropsRow' style='display: none'>
  81. <th><span class='translate vboxRunningEnabled'>Generic Properties:</span></th>
  82. <td style='white-space: nowrap'>
  83. <textarea class='vboxRunningEnabled' rows='3' cols='20' name='vboxSettingsNetGenericProps'></textarea>
  84. </td>
  85. </tr>
  86. <tr class='vboxSettingsNetToggleAdvanced' style='display: none'>
  87. <th></th>
  88. <td><label><input type='checkbox' class='vboxCheckbox' class='vboxEnablerListen' name='vboxSettingsNetConnected' /> <span class='translate vboxEnablerListen'>Cable Connected</span></label></td>
  89. </tr>
  90. <tr class='vboxSettingsNetToggleAdvanced vboxSettingsNetPFButton' style='display: none'>
  91. <th></th>
  92. <td><input type='button' class='vboxButton' class='vboxEnablerListen' name='vboxSettingsNetPF' value='Port Forwarding' /></td>
  93. </tr>
  94. </table>
  95. </div>
  96. <script type='text/javascript'>
  97. /* Translations */
  98. $(document.forms['frmVboxSettings'].vboxSettingsNetAttachedTo).find('option').html(function(i,h){return trans(h,'VBoxGlobal');});
  99. $(document.forms['frmVboxSettings'].vboxSettingsNetAdapterPromiscuousMode).find('option').html(function(i,h){return trans(h,'VBoxGlobal');});
  100. $('#vboxSettingsTabNetAdapter').find(".translate").html(function(i,h){return trans($('<div />').html(h).text(),'UIMachineSettingsNetwork');}).removeClass('translate');
  101. /*
  102. *
  103. * Setup data for networking options.
  104. *
  105. */
  106. var vboxSettingsNetAdaptersBridged = new Array();
  107. var vboxSettingsNetAdaptersHostOnly = new Array();
  108. var vboxSettingsNetNetworks = new Array();
  109. /*
  110. * Fill Adapter Types
  111. */
  112. var nics = $('#vboxSettingsDialog').data('vboxNetworkAdapterTypes');
  113. for(var i = 1; i < nics.length; i++) { // index 0 is 'Null' and not used
  114. var opt = new Option(trans(vboxNetworkAdapterType(nics[i]),'VBoxGlobal'),nics[i]);
  115. document.forms['frmVboxSettings'].vboxSettingsNetAdapter.options[document.forms['frmVboxSettings'].vboxSettingsNetAdapter.options.length] = opt;
  116. }
  117. // Shorthand
  118. var vboxNetworking = $('#vboxSettingsDialog').data('vboxNetworking');
  119. vboxNetworking.networkInterfaces = $('#vboxSettingsDialog').data('vboxHostDetails').networkInterfaces;
  120. for(var i = 0; i < vboxNetworking.networkInterfaces.length; i++) {
  121. if(vboxNetworking.networkInterfaces[i].interfaceType == 'Bridged') {
  122. vboxSettingsNetAdaptersBridged[vboxSettingsNetAdaptersBridged.length] = vboxNetworking.networkInterfaces[i].name;
  123. } else if(vboxNetworking.networkInterfaces[i].interfaceType == 'HostOnly') {
  124. vboxSettingsNetAdaptersHostOnly[vboxSettingsNetAdaptersHostOnly.length] = vboxNetworking.networkInterfaces[i].name;
  125. } else {
  126. vboxAlert('Unknown interface type :' + vboxNetworking.networkInterfaces[i].interfaceType);
  127. }
  128. }
  129. // Check for sub / virtual interfaces. These will not be reported by VirtualBox
  130. var vboxGuestNet = $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters;
  131. for(var i = 0; i < vboxGuestNet.length; i++) {
  132. if(!vboxGuestNet[i].bridgedInterface || vboxGuestNet[i].bridgedInterface == '') continue;
  133. if(jQuery.inArray(vboxGuestNet[i].bridgedInterface,vboxSettingsNetAdaptersBridged) < 0) {
  134. vboxSettingsNetAdaptersBridged[vboxSettingsNetAdaptersBridged.length] = vboxGuestNet[i].bridgedInterface;
  135. }
  136. }
  137. var vboxSettingsNetTemplate = document.getElementById('vboxSettingsTabNetAdapter');
  138. var vboxSettingsNetContainer = $(vboxSettingsNetTemplate).parent();
  139. /* Network advanced show / hide */
  140. $('#vboxSettingsTabNetAdapter').find('input.netImgAdvanced').click(function(){
  141. if(!$(this).data('toggleClicked')) {
  142. $(this).data('toggleClicked', true);
  143. $(this).data('vboxAdvancedEnabled',true);
  144. $(this).closest('table').find('.vboxSettingsNetToggleAdvanced:not(.vboxForceHide)').css('display','');
  145. $(this).css('background-image','url(images/downArrow.png)');
  146. } else {
  147. $(this).data('toggleClicked', false);
  148. $(this).data('vboxAdvancedEnabled',false);
  149. $(this).closest('table').find('.vboxSettingsNetToggleAdvanced').css('display','none');
  150. $(this).css('background-image','url(images/rightArrow.png)');
  151. }
  152. });
  153. /* Mac address generator */
  154. $('#vboxSettingsTabNetAdapter').find('input.vboxSettingsNetMacGen').click(function(){
  155. var t = $(this).siblings('input').first();
  156. var oval = $(t).val();
  157. $(t).val('...').prop('disabled',true);
  158. var l = new vboxLoader();
  159. l.add('vboxGenerateMacAddress',function(d){
  160. if(d && d.success) $(t).val(d.responseData);
  161. else $(t).val(oval);
  162. $(t).prop('disabled',false);
  163. });
  164. l.noLoadingScreen = true;
  165. l.run();
  166. });
  167. /* Network adapter tab links */
  168. var ul = $('<ul />');
  169. $(vboxSettingsNetContainer).append(ul);
  170. for(var i = 0; i < parseInt($('#vboxPane').data('vboxConfig').nicMax); i++) {
  171. /* tab */
  172. $(ul).append($('<li />').html('<a href="#' + vboxSettingsNetTemplate.id + (i + 1) +'"><span>' + trans('Adapter %1','VBoxGlobal').replace('%1',(i + 1)) + '</span></a>'));
  173. /* tab content */
  174. var newTab = $("#vboxSettingsTabNetAdapter").clone(true);
  175. newTab.attr({'id':vboxSettingsNetTemplate.id + (i + 1)}).css({'display':'block'}).find('.vboxEnablerTrigger').on('enable',function(){
  176. $(this).children('select').first().trigger('change');
  177. });
  178. newTab.appendTo(vboxSettingsNetContainer);
  179. /* Form elements must be unique */
  180. $("#vboxSettingsTabNetAdapter" + (i + 1)).find('[name]').each(function() {
  181. $(this).attr('name',$(this).attr('name') + (i + 1));
  182. });
  183. }
  184. /* Remove Template */
  185. $("#vboxSettingsTabNetAdapter").empty().remove();
  186. /* preload network 'advanced' down arrow image */
  187. var netDnAdvImg = new Image();
  188. netDnAdvImg.src = 'images/downArrow.png';
  189. /*
  190. * Called when network adpater 'attached to' changes
  191. */
  192. function vboxSettingsUpdateNetworkOptions(sel) {
  193. var ptable = $(sel).closest('table');
  194. var th = $(ptable).find('th.vboxSettingsNetAdapterNamedLabel').first();
  195. var nsel = $(ptable).find('.vboxSettingsNetAdapterNamed').first();
  196. var advEnabled = ptable.find('input.netImgAdvanced').first().data('vboxAdvancedEnabled');
  197. // Promiscuous mode selection
  198. if(sel.value == 'NAT' || sel.value == 'Null' || sel.value == 'Generic') {
  199. $(ptable).find('tr.vboxSettingsNetPromiscuousMode').addClass('vboxForceHide').hide();
  200. } else {
  201. $(ptable).find('tr.vboxSettingsNetPromiscuousMode').removeClass('vboxForceHide');
  202. if(advEnabled) $(ptable).find('tr.vboxSettingsNetPromiscuousMode').show();
  203. }
  204. // Generic properties
  205. if(sel.value == 'Generic') {
  206. $(ptable).find('tr.vboxSettingsNetGenPropsRow').removeClass('vboxForceHide');
  207. if(advEnabled) $(ptable).find('tr.vboxSettingsNetGenPropsRow').show();
  208. } else {
  209. $(ptable).find('tr.vboxSettingsNetGenPropsRow').hide().addClass('vboxForceHide');
  210. }
  211. // Port forward button
  212. if(sel.value == 'NAT') {
  213. $(ptable).find('tr.vboxSettingsNetPFButton').removeClass('vboxForceHide');
  214. if(advEnabled) $(ptable).find('tr.vboxSettingsNetPFButton').show();
  215. } else {
  216. $(ptable).find('tr.vboxSettingsNetPFButton').addClass('vboxForceHide').hide();
  217. }
  218. // Name box
  219. if(sel.value == 'Null' || sel.value == 'NAT') {
  220. $(th).addClass('vboxDisabled');
  221. $(nsel).children().remove();
  222. $(nsel).prop('disabled',true);
  223. if(sel.value == 'NAT' && $('#vboxPane').data('vboxConfig').enableAdvancedConfig) ptable.find('tr.vboxSettingsAdvancedNat').css('display','');
  224. else ptable.find('tr.vboxSettingsAdvancedNat').css('display','none');
  225. } else {
  226. ptable.find('tr.vboxSettingsAdvancedNat').css('display','none');
  227. $(th).removeClass('vboxDisabled');
  228. $(nsel).children().remove();
  229. $(nsel).prop('disabled',false);
  230. // Special case for certian network selects
  231. if(sel.value == 'Internal' || sel.value == 'VDE' || sel.value=='Generic' || sel.value=='Bridged' || sel.value=='NATNetwork') {
  232. var isel = $(nsel).clone(false);
  233. $(nsel).replaceWith(isel);
  234. nsel = isel;
  235. }
  236. var defaultSel = $(sel).data('vboxDefault');
  237. switch(sel.value) {
  238. case 'Bridged':
  239. src = vboxSettingsNetAdaptersBridged;
  240. break;
  241. case 'HostOnly':
  242. src = vboxSettingsNetAdaptersHostOnly;
  243. break;
  244. case 'Internal':
  245. src = $('#vboxSettingsDialog').data('vboxNetworking').networks;
  246. break;
  247. case 'Generic':
  248. src = $('#vboxSettingsDialog').data('vboxNetworking').genericDrivers;
  249. break;
  250. case 'NATNetwork':
  251. src = $('#vboxSettingsDialog').data('vboxNetworking').natNetworks;
  252. break;
  253. case 'VDE':
  254. src = $('#vboxSettingsDialog').data('vboxNetworking').vdenetworks;
  255. break;
  256. default:
  257. vboxAlert('Unknown network binding type: ' + sel.value);
  258. }
  259. for(var i = 0; i < src.length; i++) {
  260. var hSrc = $('<div />').text(src[i]).html();
  261. $(nsel).append('<option ' + (src[i] == defaultSel ? ' selected ' : '') + ' value="' + hSrc + '">' + hSrc + '</option>');
  262. }
  263. }
  264. // Special case for Internal, Generic, and VDE network selects
  265. if(sel.value == 'Internal' || sel.value == 'VDE' || sel.value == 'Generic' || sel.value == 'Bridged') {
  266. $(nsel).jec();
  267. }
  268. }
  269. /* Change settings onShow() when VM is running */
  270. $('#vboxSettingsDialog').on('dataLoaded',function(){
  271. /* Net values */
  272. var vboxVDEFound = false; // check for VDE attachments
  273. for(var i = 0; i < parseInt($('#vboxPane').data('vboxConfig').nicMax); i++) {
  274. var a = (i + 1);
  275. // attached to
  276. $(document.forms['frmVboxSettings'].elements['vboxSettingsNetAttachedTo'+a]).val($('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].attachmentType).trigger('change');
  277. $(document.forms['frmVboxSettings'].elements['vboxSettingsNetAttachedTo'+a].options[document.forms['frmVboxSettings'].elements['vboxSettingsNetAttachedTo'+a].selectedIndex]).attr('selected','selected');
  278. $(document.forms['frmVboxSettings'].elements['vboxSettingsNetAttachedTo'+a]).change();
  279. // Device or network name, depending on what 'attached to' is
  280. var netName = '';
  281. switch($('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].attachmentType) {
  282. case 'Bridged':
  283. netName = $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].bridgedInterface;
  284. break;
  285. case 'HostOnly':
  286. netName = $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].hostOnlyInterface;
  287. break;
  288. case 'Internal':
  289. netName = $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].internalNetwork;
  290. break;
  291. case 'Generic':
  292. netName = $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].genericDriver;
  293. break;
  294. case 'NATNetwork':
  295. netName = $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATNetwork;
  296. break;
  297. case 'VDE':
  298. netName = $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].VDENetwork;
  299. vboxVDEFound = true;
  300. break;
  301. }
  302. // hold default value
  303. $(document.forms['frmVboxSettings'].elements['vboxSettingsNetAttachedTo'+a]).data('vboxDefault', netName);
  304. document.forms['frmVboxSettings'].elements['vboxSettingsNetName'+a].value = netName;
  305. document.forms['frmVboxSettings'].elements['vboxSettingsNetAdapter'+a].value = $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].adapterType;
  306. document.forms['frmVboxSettings'].elements['vboxSettingsNetMAC'+a].value = $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].MACAddress;
  307. document.forms['frmVboxSettings'].elements['vboxSettingsNetConnected'+a].checked = ($('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].cableConnected ? true : false);
  308. $(document.forms['frmVboxSettings'].elements['vboxSettingsNetAdapterPromiscuousMode'+a]).val($('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].promiscModePolicy);
  309. document.forms['frmVboxSettings'].elements['vboxSettingsNetGenericProps'+a].innerHTML = $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].properties;
  310. // Enabled adapter
  311. $(document.forms['frmVboxSettings'].elements['vboxSettingsNetEnabled'+a]).prop('checked',$('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].enabled).triggerHandler('click');;
  312. $(document.forms['frmVboxSettings'].elements['vboxSettingsNetPF'+a]).unbind('click');
  313. $(document.forms['frmVboxSettings'].elements['vboxSettingsNetPF'+a]).click(function(){
  314. var nicIndex = (parseInt($(this).attr('name').substr(17))-1);
  315. $.when(vboxPortForwardConfigDialog($('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[nicIndex].redirects))
  316. .done(function(rules){
  317. for(var i = 0; i < rules.length; i++) {
  318. rules[i] = rules[i].join(',');
  319. }
  320. $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[nicIndex].redirects = rules;
  321. });
  322. }).val(trans('Port Forwarding','UIMachineSettingsNetwork'));
  323. // Set Nat values
  324. if($('#vboxPane').data('vboxConfig').enableAdvancedConfig) {
  325. document.forms['frmVboxSettings'].elements['vboxSettingsNetAliasModeProxyOnly'+a].checked = (($('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATEngine.aliasMode & 2) ? true : false);
  326. document.forms['frmVboxSettings'].elements['vboxSettingsNetAliasModeSamePorts'+a].checked = (($('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATEngine.aliasMode & 4) ? true : false);
  327. document.forms['frmVboxSettings'].elements['vboxSettingsNetPassDNSDomain'+a].checked = ($('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATEngine.DNSPassDomain ? true : false);
  328. document.forms['frmVboxSettings'].elements['vboxSettingsNetDNSProxy'+a].checked = ($('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATEngine.DNSProxy ? true : false);
  329. document.forms['frmVboxSettings'].elements['vboxSettingsNetUseHostResolver'+a].checked = ($('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATEngine.DNSUseHostResolver ? true : false);
  330. $(document.forms['frmVboxSettings'].elements['vboxSettingsNetBindIp'+a]).val($('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATEngine.hostIP);
  331. }
  332. }
  333. /* Disable VDE selection? */
  334. if(!vboxVDEFound && !$('#vboxPane').data('vboxConfig').enableVDE) {
  335. for(var i = 0; i < parseInt($('#vboxPane').data('vboxConfig').nicMax); i++) {
  336. $(document.forms['frmVboxSettings'].elements['vboxSettingsNetAttachedTo'+(i+1)]).children("[value='VDE']").remove();
  337. }
  338. }
  339. if(!$('#vboxSettingsDialog').data('vboxFullEdit')) {
  340. for(var i = 0; i < parseInt($('#vboxPane').data('vboxConfig').nicMax); i++) {
  341. var a = (i + 1);
  342. /* Disable these inputs */
  343. document.forms['frmVboxSettings'].elements['vboxSettingsNetEnabled'+a].disabled ='disabled';
  344. document.forms['frmVboxSettings'].elements['vboxSettingsNetAdapter'+a].disabled ='disabled';
  345. document.forms['frmVboxSettings'].elements['vboxSettingsNetMAC'+a].disabled ='disabled';
  346. $(document.forms['frmVboxSettings'].elements['vboxSettingsNetMAC'+a]).siblings('input').css('display','none');
  347. /* Disable these labels */
  348. $(document.forms['frmVboxSettings'].elements['vboxSettingsNetEnabled'+a]).closest('tr').children().addClass('vboxDisabled');
  349. $(document.forms['frmVboxSettings'].elements['vboxSettingsNetAdapter'+a]).closest('tr').children().addClass('vboxDisabled');
  350. $(document.forms['frmVboxSettings'].elements['vboxSettingsNetMAC'+a]).closest('tr').children().addClass('vboxDisabled');
  351. }
  352. // Expand all advanced settings
  353. $('#vboxSettingsDialog').find('input.netImgAdvanced').each(function(){
  354. if(!$(this).data('vboxAdvancedEnabled')) $(this).trigger('click');
  355. });
  356. // Disable mac address generation
  357. $('#vboxSettingsDialog').find('input.vboxSettingsNetMacGen').prop('disabled',true);
  358. } else {
  359. for(var i = 0; i < parseInt($('#vboxPane').data('vboxConfig').nicMax); i++) {
  360. var a = (i + 1);
  361. /* Enable these inputs */
  362. document.forms['frmVboxSettings'].elements['vboxSettingsNetEnabled'+a].disabled ='';
  363. document.forms['frmVboxSettings'].elements['vboxSettingsNetAdapter'+a].disabled ='';
  364. document.forms['frmVboxSettings'].elements['vboxSettingsNetMAC'+a].disabled ='';
  365. $(document.forms['frmVboxSettings'].elements['vboxSettingsNetMAC'+a]).siblings('input').css('display','');
  366. /* Enable these labels */
  367. $(document.forms['frmVboxSettings'].elements['vboxSettingsNetEnabled'+a]).closest('tr').children().removeClass('vboxDisabled');
  368. $(document.forms['frmVboxSettings'].elements['vboxSettingsNetAdapter'+a]).closest('tr').children().removeClass('vboxDisabled');
  369. $(document.forms['frmVboxSettings'].elements['vboxSettingsNetMAC'+a]).closest('tr').children().removeClass('vboxDisabled');
  370. }
  371. // Enable mac address generation
  372. $('#vboxSettingsDialog').find('input.vboxSettingsNetMacGen').prop('disabled',false);
  373. }
  374. /* Change settings onSave() */
  375. }).on('save',function(){
  376. /* Net */
  377. for(var i = 0; i < parseInt($('#vboxPane').data('vboxConfig').nicMax); i++) {
  378. var a = (i + 1);
  379. // attached to
  380. $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].attachmentType = document.forms['frmVboxSettings'].elements['vboxSettingsNetAttachedTo'+a].value;
  381. // Device or network name, depending on what 'attached to' is
  382. switch($('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].attachmentType) {
  383. case 'Bridged':
  384. $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].bridgedInterface = document.forms['frmVboxSettings'].elements['vboxSettingsNetName'+a].value;;
  385. case 'HostOnly':
  386. $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].hostOnlyInterface = document.forms['frmVboxSettings'].elements['vboxSettingsNetName'+a].value;;
  387. break;
  388. case 'Generic':
  389. $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].genericDriver = document.forms['frmVboxSettings'].elements['vboxSettingsNetName'+a].value;
  390. break;
  391. case 'Internal':
  392. $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].internalNetwork = document.forms['frmVboxSettings'].elements['vboxSettingsNetName'+a].value;
  393. break;
  394. case 'NATNetwork':
  395. $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATNetwork = document.forms['frmVboxSettings'].elements['vboxSettingsNetName'+a].value;
  396. break;
  397. case 'VDE':
  398. $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].VDENetwork = document.forms['frmVboxSettings'].elements['vboxSettingsNetName'+a].value;
  399. break;
  400. }
  401. // Set Nat values
  402. if($('#vboxPane').data('vboxConfig').enableAdvancedConfig) {
  403. var aliasMode = $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATEngine.aliasMode & 1;
  404. if(document.forms['frmVboxSettings'].elements['vboxSettingsNetAliasModeProxyOnly'+a].checked) {
  405. aliasMode |= 2;
  406. }
  407. if(document.forms['frmVboxSettings'].elements['vboxSettingsNetAliasModeSamePorts'+a].checked) {
  408. aliasMode |= 4;
  409. }
  410. $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATEngine.aliasMode = aliasMode;
  411. $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATEngine.DNSPassDomain = document.forms['frmVboxSettings'].elements['vboxSettingsNetPassDNSDomain'+a].checked;
  412. $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATEngine.DNSProxy = document.forms['frmVboxSettings'].elements['vboxSettingsNetDNSProxy'+a].checked;
  413. $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATEngine.DNSUseHostResolver = document.forms['frmVboxSettings'].elements['vboxSettingsNetUseHostResolver'+a].checked;
  414. $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATEngine.hostIP = $(document.forms['frmVboxSettings'].elements['vboxSettingsNetBindIp'+a]).val();
  415. }
  416. $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].properties = $(document.forms['frmVboxSettings'].elements['vboxSettingsNetGenericProps'+a]).val();
  417. $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].promiscModePolicy = $(document.forms['frmVboxSettings'].elements['vboxSettingsNetAdapterPromiscuousMode'+a]).val();
  418. $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].adapterType = document.forms['frmVboxSettings'].elements['vboxSettingsNetAdapter'+a].value;
  419. $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].MACAddress = document.forms['frmVboxSettings'].elements['vboxSettingsNetMAC'+a].value;
  420. $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].cableConnected = document.forms['frmVboxSettings'].elements['vboxSettingsNetConnected'+a].checked;
  421. $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].enabled = document.forms['frmVboxSettings'].elements['vboxSettingsNetEnabled'+a].checked;
  422. }
  423. });
  424. </script>