forked from phpvirtualbox/phpvirtualbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwizardNewVMAdvanced.html
276 lines (221 loc) · 10.5 KB
/
wizardNewVMAdvanced.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
<!--
Advanced panes for new virtual machine wizard. Logic in vboxWizard()
Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
$Id: wizardNewVMAdvanced.html 595 2015-04-17 09:50:36Z imoore76 $
-->
<!-- Step 1 -->
<div id='wizardNewVMStep1' style='display: none'>
<span class='vboxTableLabel translate'>Name and operating system</span>
<div class='vboxOptions'>
<table class='vboxOptions vboxOSTypeOptions' style='width:100%'>
<tr>
<th style='width: 1%'><span class='translate'>Name:</span></th>
<td colspan='2'><input type='text' class='vboxText' name='newVMName' style='width: 95%' /></td>
</tr>
<tr>
<th><span class='translate'>Type:</span></th>
<td style='width: 100%'><select name='newVMOSFamily' id='newVMOSFamily' style='width: 100%'>
<option value='Linux'>Linux</option>
</select></td>
<td rowspan='2'><img name='vboxOSTypeImg' height='32' width='32' /></td>
</tr>
<tr>
<th><span class='translate'>Version:</span></th>
<td><select id='newVMOSType' name='newVMOSType' style='width: 100%'>
<option value='Debian'>Debian</option>
</select></td>
</tr>
</table>
</div>
<span class='vboxTableLabel translate'>Memory size</span>
<div class='vboxOptions'>
<table style='width: 100%'>
<tr>
<td style='width: 100%; border: 0px; margin: 0px; padding: 0px;'>
<div style='margin-top: 4px' id='wizardNewVMSize' class='slider translateglob'><div class='sliderScale'></div></div>
</td>
<td style='white-space: nowrap'><input type='text' class='vboxText' name='wizardNewVMSizeValue' size='5' class='sliderValue' /> <span class='translate'>MB</span></td>
</tr>
<tr style='vertical-align: top;'>
<td style='border: 0px; margin: 0px; padding: 0px;'>
<table style='width: 100%; border: 0px; margin: 0px; padding: 0px;'>
<tr style='vertical-align: top'>
<td style='text-align: left;'><span id='wizardNewVMMin'>1</span> <span class='translate'>MB</span></td>
<td style='text-align: right;'><span id='wizardNewVMMax'>128</span> <span class='translate'>MB</span></td>
</tr>
</table>
</td>
<td></td>
</tr>
</table>
</div>
<span class='vboxTableLabel translate'>Hard disk</span>
<div class='vboxOptions'>
<table class='vboxOptions' id='newVMBootDiskTable' style='width:100%;'>
<tr>
<td style='padding:2px; padding-left: 14px'><label><input type="radio" class="vboxRadio" name="newVMDisk" value="none" onClick="newVMToggleNewDisk(true)" /> <span class='translate vboxEnablerListen'>Do not add a virtual hard disk</span></label></td>
</tr>
<tr id='newVMHDTriggerBind' class='vboxEnablerTrigger'>
<td style='padding:2px; padding-left: 14px'><label><input type="radio" class="vboxRadio" name="newVMDisk" value="create" onClick="newVMToggleNewDisk(true)" checked='checked' /> <span class='translate vboxEnablerListen'>Create a virtual hard disk now</span></label></td>
</tr>
<tr>
<td style='padding:2px; padding-left: 14px'><label><input type="radio" class="vboxRadio" name="newVMDisk" value="existing" onClick="newVMToggleNewDisk(false)" /> <span class='translate vboxEnablerListen'>Use an existing virtual hard disk file</span></label></td>
</tr>
<tr>
<td style='padding-left: 24px; white-space: nowrap'>
<table class='vboxInvisible' style='width: 99%;'>
<tr>
<td><select id="newVMDiskSelectId" name="newVMDiskSelect" disabled='disabled'></select></td>
<td style='width:1%' id='newVMDiskVMM'></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</div>
<script type='text/javascript'>
/* Translations */
$('#wizardNewVMStep1').find('table.vboxOSTypeOptions').find('span.translate').html(function(i,h) {
return trans(h,'UINameAndSystemEditor');
}).removeClass('translate');
var wizardNewVMToolbar = new vboxToolbarSingle({button: {
/* Add Attachment Button */
'name' : 'mselecthdbtn',
'label' : 'Choose a virtual hard disk file...',
'language_context': 'UIMachineSettingsStorage',
'icon' : 'select_file',
'click' : function () {
vboxMedia.actions.choose(null,'HardDisk',function(med){
if(med) vmNewFillExistingDisks(med.base);
});
}
}});
wizardNewVMToolbar.renderTo('newVMDiskVMM');
/* Toggle new / existing */
function newVMToggleNewDisk(dis) {
if(dis) {
wizardNewVMToolbar.disable();
document.forms['frmwizardNewVM'].newVMDiskSelect.disabled = true;
$('#wizardNewVMStep1').find('.vboxMediumSelect').trigger('disable');
} else {
wizardNewVMToolbar.enable();
document.forms['frmwizardNewVM'].newVMDiskSelect.disabled = (document.forms['frmwizardNewVM'].newVMDiskSelect.options.length > 0 ? false : true);
$('#wizardNewVMStep1').find('.vboxMediumSelect').trigger('enable');
}
}
/* Mem size slider */
var min = 4;
var max = parseInt($('#vboxPane').data('vboxHostDetails').memorySize);
$('#wizardNewVMSize').data('form','frmwizardNewVM');
$('#wizardNewVMSize').slider({'min':min,'max':max,'step':1});
$('#wizardNewVMSize').slider('value',4);
$('#wizardNewVMMin').html(min);
$('#wizardNewVMMax').html(max);
/* Fill existing attachments */
function vmNewFillExistingDisks(sel) {
document.forms['frmwizardNewVM'].newVMDiskSelect.options.length = 0;
$(document.forms['frmwizardNewVM'].newVMDiskSelect).children().remove();
var s = vboxMedia.mediaForAttachmentType('HardDisk');
// Sort media
s.sort(function(a,b){return strnatcasecmp(a.name,b.name);});
var mediumSelects = [];
var selectedIndex = -1;
for(var i = 0; i < s.length; i++) {
document.forms['frmwizardNewVM'].newVMDiskSelect.options[i] = new Option(vboxMedia.mediumPrint(s[i]),s[i].id, (sel && sel == s[i].id));
if(s[i].readOnly && s[i].deviceType == 'HardDisk') $(document.forms['frmwizardNewVM'].newVMDiskSelect.options[i]).addClass('vboxMediumReadOnly');
mediumSelects[i] = {'attachedId':s[i].id,'id':s[i].id,'base':s[i].base,'label':vboxMedia.mediumPrint(s[i])};
if(sel == s[i].id) {
selectedIndex = i;
}
}
if(selectedIndex > -1) {
document.forms['frmwizardNewVM'].newVMDiskSelect.selectedIndex = selectedIndex;
}
$(document.forms['frmwizardNewVM'].newVMDiskSelect).mediumselect({'type':'HardDisk','showdiff':false,'media':mediumSelects});
if(sel) {
$(document.forms['frmwizardNewVM'].newVMDiskSelect).mediumselect({'selectMedium':sel});
$(document.forms['frmwizardNewVM'].newVMDiskSelect).val(sel);
}
}
vmNewFillExistingDisks();
/*
*
* Called when OS family type changes
*
*/
function newVMUpdateOSList(osfam) {
document.forms['frmwizardNewVM'].newVMOSType.options.length = 0;
$(document.forms['frmwizardNewVM'].newVMOSType).children().remove();
for(var i = 0; i < newVMOSTypes[osfam].osTypes.length; i++) {
document.forms['frmwizardNewVM'].newVMOSType.options[i] = new Option(newVMOSTypes[osfam].osTypes[i].description, newVMOSTypes[osfam].osTypes[i].id);
}
// Trigger change
newVMUpdateOS(newVMOSTypes[osfam].osTypes[0].id);
}
function newVMUpdateOS(ostype) {
document.images["vboxOSTypeImg"].src = "images/vbox/" + vboxGuestOSTypeIcon(ostype);
ostype = newVMOSTypesObj[ostype];
$('#wizardNewVMSize').slider('value',ostype.recommendedRAM);
$('#newVMSizeLabel').html(trans('The recommended memory size is <b>%1</b> MB.','UIWizardNewVMPage3').replace('%1',ostype.recommendedRAM));
$('#newVMHDSizeLabel').html(trans('<p>If you wish you can add a virtual hard disk to the new machine. You can either create a new hard disk file or select one from the list or from another location using the folder icon.</p><p>If you need a more complex storage set-up you can skip this step and make the changes to the machine settings once the machine is created.</p><p>The recommended size of the hard disk is <b>%1</b>.</p>','UIWizardNewVMPage4').replace('%1',vboxMbytesConvert(ostype.recommendedHDD)));
}
var newVMOSTypes = new Array();
var newVMOSTypesObj = {};
// shorthand
var vboxOSTypes = $('#vboxPane').data('vboxOSTypes');
// Default OS Type set to my fav :) Eventually will move to config.php
var vboxDefaultOSTypeId = 'Debian';
var dosfam = null; // holds defaultostype family id
for(var i in vboxOSTypes) {
// Skip unsupported OS types
if(!vboxOSTypes[i].supported) continue;
// create array of os family types
if(!newVMOSTypes[vboxOSTypes[i].familyId]) {
newVMOSTypes[vboxOSTypes[i].familyId] = {'id':vboxOSTypes[i].familyId,'description':vboxOSTypes[i].familyDescription,'osTypes':[]};
}
// We're on the default os type, record family id and index number
// so that we can set it later on
if(vboxOSTypes[i].id == vboxDefaultOSTypeId) {
dosfam = vboxOSTypes[i].familyId;
vboxDefaultOSTypeId = newVMOSTypes[vboxOSTypes[i].familyId].osTypes.length;
}
newVMOSTypes[vboxOSTypes[i].familyId].osTypes[newVMOSTypes[vboxOSTypes[i].familyId].osTypes.length] = {'id':vboxOSTypes[i].id,'description':vboxOSTypes[i].description };
newVMOSTypesObj[vboxOSTypes[i].id] = vboxOSTypes[i];
// Preload icons
vboxOSTypes[i].icon = new Image();
vboxOSTypes[i].icon.src = "images/vbox/" + vboxGuestOSTypeIcon(vboxOSTypes[i].id);
}
// clear all options
document.forms['frmwizardNewVM'].newVMOSFamily.options.length = 0;
$(document.forms['frmwizardNewVM'].newVMOSFamily).children().remove();
for(var i in newVMOSTypes) {
// default os type family? record in dosfam
if(i == dosfam) dosfam = document.forms['frmwizardNewVM'].newVMOSFamily.options.length;
document.forms['frmwizardNewVM'].newVMOSFamily.options[document.forms['frmwizardNewVM'].newVMOSFamily.options.length] = new Option(newVMOSTypes[i].description, newVMOSTypes[i].id);
}
// OnChange, update os type list and icon
document.getElementById('newVMOSFamily').setAttribute('onChange','newVMUpdateOSList(this.value)');
document.getElementById('newVMOSType').setAttribute('onChange','newVMUpdateOS(this.value)');
document.forms['frmwizardNewVM'].newVMOSFamily.selectedIndex = dosfam;
newVMUpdateOSList(document.forms['frmwizardNewVM'].newVMOSFamily.value);
document.forms['frmwizardNewVM'].newVMOSType.selectedIndex = vboxDefaultOSTypeId;
newVMUpdateOS(document.forms['frmwizardNewVM'].newVMOSType.options[document.forms['frmwizardNewVM'].newVMOSType.selectedIndex].value);
/*
* END OS TYPES
*/
/* When hard disk is enabled / disabled */
$('#newVMHDTriggerBind').on('enable',function(){
// Update disabled / enabled items
if(document.forms['frmwizardNewVM'].newVMDisk[0].checked) {
$(document.forms['frmwizardNewVM'].newVMDisk[0]).trigger('click');
} else {
$(document.forms['frmwizardNewVM'].newVMDisk[1]).trigger('click');
}
}).on('disable',function(){
newVMToggleNewDisk(true);
}).trigger('disable');
$('#wizardNewVMStep1').on('show',function() {
$(document.forms['frmwizardNewVM'].newVMName).focus();
});
</script>