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