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ů.

wizardNewVM.html 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. <!--
  2. Panes for new virtual machine wizard. Logic in vboxWizard()
  3. Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
  4. $Id: wizardNewVM.html 595 2015-04-17 09:50:36Z imoore76 $
  5. -->
  6. <!-- Step 1 -->
  7. <div id='wizardNewVMStep1' title='Name and operating system' style='display: none'>
  8. <p class='translate vboxWizardDescription'>Please choose a descriptive name for the new virtual machine and select the type of operating system you intend to install on it. The name you choose will be used throughout VirtualBox to identify this machine.</p>
  9. <div class='vboxOptions'>
  10. <table class='vboxOptions' style='width:100%'>
  11. <tr>
  12. <th style='width: 1%'><span class='translate'>Name:</span></th>
  13. <td colspan='2'><input type='text' class='vboxText' name='newVMName' style='width: 95%' /></td>
  14. </tr>
  15. <tr>
  16. <th><span class='translate'>Type:</span></th>
  17. <td style='width: 100%'><select name='newVMOSFamily' id='newVMOSFamily' style='width: 100%'>
  18. <option value='Linux'>Linux</option>
  19. </select></td>
  20. <td rowspan='2'><img name='vboxOSTypeImg' height='32' width='32' /></td>
  21. </tr>
  22. <tr>
  23. <th><span class='translate'>Version:</span></th>
  24. <td><select id='newVMOSType' name='newVMOSType' style='width: 100%'>
  25. <option value='Debian'>Debian</option>
  26. </select></td>
  27. </tr>
  28. </table>
  29. </div>
  30. </div>
  31. <!-- Step 2 -->
  32. <div id='wizardNewVMStep2' title='Memory size' style='display: none'>
  33. <span id='newVMSizeLabel'></span>
  34. <div class='vboxOptions'>
  35. <table style='width: 100%'>
  36. <tr>
  37. <td style='width: 100%; border: 0px; margin: 0px; padding: 0px;'>
  38. <div style='margin-top: 4px' id='wizardNewVMSize' class='slider translateglob'><div class='sliderScale'></div></div>
  39. </td>
  40. <td style='white-space: nowrap'><input type='text' class='vboxText' name='wizardNewVMSizeValue' size='5' class='sliderValue' /> <span class='translate'>MB</span></td>
  41. </tr>
  42. <tr style='vertical-align: top;'>
  43. <td style='border: 0px; margin: 0px; padding: 0px;'>
  44. <table style='width: 100%; border: 0px; margin: 0px; padding: 0px;'>
  45. <tr style='vertical-align: top'>
  46. <td style='text-align: left;'><span id='wizardNewVMMin'>1</span> <span class='translate'>MB</span></td>
  47. <td style='text-align: right;'><span id='wizardNewVMMax'>128</span> <span class='translate'>MB</span></td>
  48. </tr>
  49. </table>
  50. </td>
  51. <td></td>
  52. </tr>
  53. </table>
  54. </div>
  55. </div>
  56. <!-- Step 3 -->
  57. <div id='wizardNewVMStep3' title='Hard disk' style='display: none'>
  58. <span id='newVMHDSizeLabel'></span>
  59. <div class='vboxOptions'>
  60. <table class='vboxOptions' id='newVMBootDiskTable' style='width:100%;'>
  61. <tr>
  62. <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>
  63. </tr>
  64. <tr id='newVMHDTriggerBind' class='vboxEnablerTrigger'>
  65. <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>
  66. </tr>
  67. <tr>
  68. <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>
  69. </tr>
  70. <tr>
  71. <td style='padding-left: 24px; white-space: nowrap'>
  72. <table class='vboxInvisible' style='width: 99%;'>
  73. <tr>
  74. <td><select id="newVMDiskSelectId" name="newVMDiskSelect" disabled='disabled'></select></td>
  75. <td style='width:1%' id='newVMDiskVMM'></td>
  76. </tr>
  77. </table>
  78. </td>
  79. </tr>
  80. </table>
  81. </div>
  82. </div>
  83. <script type='text/javascript'>
  84. /* Translations */
  85. $('#wizardNewVMStep1').find('table.vboxOptions').find('span.translate').html(function(i,h) {
  86. return trans(h,'UINameAndSystemEditor');
  87. }).removeClass('translate');
  88. var wizardNewVMToolbar = new vboxToolbarSingle({button: {
  89. /* Add Attachment Button */
  90. 'name' : 'mselecthdbtn',
  91. 'label' : 'Choose a virtual hard disk file...',
  92. 'language_context': 'UIMachineSettingsStorage',
  93. 'icon' : 'select_file',
  94. 'click' : function () {
  95. vboxMedia.actions.choose(null,'HardDisk',function(med){
  96. if(med) vmNewFillExistingDisks(med.base);
  97. });
  98. }
  99. }});
  100. wizardNewVMToolbar.renderTo('newVMDiskVMM');
  101. /* Toggle new / existing */
  102. function newVMToggleNewDisk(dis) {
  103. if(dis) {
  104. wizardNewVMToolbar.disable();
  105. document.forms['frmwizardNewVM'].newVMDiskSelect.disabled = true;
  106. $('#wizardNewVMStep3').find('.vboxMediumSelect').trigger('disable');
  107. } else {
  108. wizardNewVMToolbar.enable();
  109. document.forms['frmwizardNewVM'].newVMDiskSelect.disabled = (document.forms['frmwizardNewVM'].newVMDiskSelect.options.length > 0 ? false : true);
  110. $('#wizardNewVMStep3').find('.vboxMediumSelect').trigger('enable');
  111. }
  112. }
  113. /* Mem size slider */
  114. var min = 4;
  115. var max = parseInt($('#vboxPane').data('vboxHostDetails').memorySize);
  116. $('#wizardNewVMSize').data('form','frmwizardNewVM');
  117. $('#wizardNewVMSize').slider({'min':min,'max':max,'step':1});
  118. $('#wizardNewVMSize').slider('value',4);
  119. $('#wizardNewVMMin').html(min);
  120. $('#wizardNewVMMax').html(max);
  121. /* Fill existing attachments */
  122. function vmNewFillExistingDisks(sel) {
  123. document.forms['frmwizardNewVM'].newVMDiskSelect.options.length = 0;
  124. $(document.forms['frmwizardNewVM'].newVMDiskSelect).children().remove();
  125. var s = vboxMedia.mediaForAttachmentType('HardDisk');
  126. // Sort media
  127. s.sort(function(a,b){return strnatcasecmp(a.name,b.name);});
  128. var mediumSelects = [];
  129. var selectedIndex = 0;
  130. for(var i = 0; i < s.length; i++) {
  131. document.forms['frmwizardNewVM'].newVMDiskSelect.options[i] = new Option(vboxMedia.mediumPrint(s[i]),s[i].id);
  132. if(s[i].readOnly && s[i].deviceType == 'HardDisk') $(document.forms['frmwizardNewVM'].newVMDiskSelect.options[i]).addClass('vboxMediumReadOnly');
  133. mediumSelects[i] = {'attachedId':s[i].id,'id':s[i].id,'base':s[i].base,'label':vboxMedia.mediumPrint(s[i])};
  134. if(sel == s[i].id) {
  135. selectedIndex = i;
  136. }
  137. }
  138. if(selectedIndex) {
  139. document.forms['frmwizardNewVM'].newVMDiskSelect.selectedIndex = selectedIndex;
  140. }
  141. $(document.forms['frmwizardNewVM'].newVMDiskSelect).mediumselect({'type':'HardDisk','showdiff':false,'media':mediumSelects});
  142. }
  143. vmNewFillExistingDisks();
  144. /*
  145. *
  146. * Called when OS family type changes
  147. *
  148. */
  149. function newVMUpdateOSList(osfam) {
  150. document.forms['frmwizardNewVM'].newVMOSType.options.length = 0;
  151. $(document.forms['frmwizardNewVM'].newVMOSType).children().remove();
  152. for(var i = 0; i < newVMOSTypes[osfam].osTypes.length; i++) {
  153. document.forms['frmwizardNewVM'].newVMOSType.options[i] = new Option(newVMOSTypes[osfam].osTypes[i].description, newVMOSTypes[osfam].osTypes[i].id);
  154. }
  155. // Trigger change
  156. newVMUpdateOS(newVMOSTypes[osfam].osTypes[0].id);
  157. }
  158. function newVMUpdateOS(ostype) {
  159. document.images["vboxOSTypeImg"].src = "images/vbox/" + vboxGuestOSTypeIcon(ostype);
  160. ostype = newVMOSTypesObj[ostype];
  161. $('#wizardNewVMSize').slider('value',ostype.recommendedRAM);
  162. $('#newVMSizeLabel').html(trans("<p>Select the amount of memory (RAM) in megabytes "+
  163. "to be allocated to the virtual machine.</p>"+
  164. "<p>The recommended memory size is <b>%1</b> MB.</p>",'UIWizardNewVM').replace('%1',ostype.recommendedRAM));
  165. $('#newVMHDSizeLabel').html(trans("<p>If you wish you can add a virtual hard disk to the new machine. "+
  166. "You can either create a new hard disk file or select one from the list or from another location "+
  167. "using the folder icon.</p><p>If you need a more complex storage set-up you can skip this step "+
  168. "and make the changes to the machine settings once the machine is created.</p><p>The recommended "+
  169. "size of the hard disk is <b>%1</b>.</p>",'UIWizardNewVM').replace('%1',vboxMbytesConvert(ostype.recommendedHDD)));
  170. }
  171. var newVMOSTypes = new Array();
  172. var newVMOSTypesObj = {};
  173. // shorthand
  174. var vboxOSTypes = $('#vboxPane').data('vboxOSTypes');
  175. // Default OS Type set to my fav :) Eventually will move to config.php
  176. var vboxDefaultOSTypeId = 'Debian';
  177. var dosfam = null; // holds defaultostype family id
  178. for(var i in vboxOSTypes) {
  179. // Skip unsupported OS types
  180. if(!vboxOSTypes[i].supported) continue;
  181. // create array of os family types
  182. if(!newVMOSTypes[vboxOSTypes[i].familyId]) {
  183. newVMOSTypes[vboxOSTypes[i].familyId] = {'id':vboxOSTypes[i].familyId,'description':vboxOSTypes[i].familyDescription,'osTypes':[]};
  184. }
  185. // We're on the default os type, record family id and index number
  186. // so that we can set it later on
  187. if(vboxOSTypes[i].id == vboxDefaultOSTypeId) {
  188. dosfam = vboxOSTypes[i].familyId;
  189. vboxDefaultOSTypeId = newVMOSTypes[vboxOSTypes[i].familyId].osTypes.length;
  190. }
  191. newVMOSTypes[vboxOSTypes[i].familyId].osTypes[newVMOSTypes[vboxOSTypes[i].familyId].osTypes.length] = {'id':vboxOSTypes[i].id,'description':vboxOSTypes[i].description };
  192. newVMOSTypesObj[vboxOSTypes[i].id] = vboxOSTypes[i];
  193. // Preload icons
  194. vboxOSTypes[i].icon = new Image();
  195. vboxOSTypes[i].icon.src = "images/vbox/" + vboxGuestOSTypeIcon(vboxOSTypes[i].id);
  196. }
  197. // clear all options
  198. document.forms['frmwizardNewVM'].newVMOSFamily.options.length = 0;
  199. $(document.forms['frmwizardNewVM'].newVMOSFamily).children().remove();
  200. for(var i in newVMOSTypes) {
  201. // default os type family? record in dosfam
  202. if(i == dosfam) dosfam = document.forms['frmwizardNewVM'].newVMOSFamily.options.length;
  203. document.forms['frmwizardNewVM'].newVMOSFamily.options[document.forms['frmwizardNewVM'].newVMOSFamily.options.length] = new Option(newVMOSTypes[i].description, newVMOSTypes[i].id);
  204. }
  205. // OnChange, update os type list and icon
  206. document.getElementById('newVMOSFamily').setAttribute('onChange','newVMUpdateOSList(this.value)');
  207. document.getElementById('newVMOSType').setAttribute('onChange','newVMUpdateOS(this.value)');
  208. document.forms['frmwizardNewVM'].newVMOSFamily.selectedIndex = dosfam;
  209. newVMUpdateOSList(document.forms['frmwizardNewVM'].newVMOSFamily.value);
  210. document.forms['frmwizardNewVM'].newVMOSType.selectedIndex = vboxDefaultOSTypeId;
  211. newVMUpdateOS(document.forms['frmwizardNewVM'].newVMOSType.options[document.forms['frmwizardNewVM'].newVMOSType.selectedIndex].value);
  212. /*
  213. * END OS TYPES
  214. */
  215. $('#wizardNewVMStep1').on('show',function(e,wiz){
  216. $(document.forms['frmwizardNewVM'].newVMName).focus();
  217. });
  218. /* When going to step2, make sure a name is entered */
  219. $('#wizardNewVMStep2').on('show',function(e,wiz){
  220. document.forms['frmwizardNewVM'].newVMName.value = jQuery.trim(document.forms['frmwizardNewVM'].newVMName.value);
  221. if(!document.forms['frmwizardNewVM'].newVMName.value) {
  222. $(document.forms['frmwizardNewVM'].newVMName).addClass('vboxRequired');
  223. // Go back
  224. wiz.displayStep(1);
  225. return;
  226. }
  227. var l = new vboxLoader();
  228. l.add('vboxGetComposedMachineFilename',function(d){
  229. loc = vboxDirname(d.responseData);
  230. var fe = new vboxLoader();
  231. fe.add('fileExists',function(d){
  232. fileExists = d.responseData;
  233. },{'file':loc});
  234. fe.onLoad = function() {
  235. if(fileExists) {
  236. vboxAlert(trans('<p>Cannot create the machine folder <b>%1</b> in the parent folder <nobr><b>%2</b>.</nobr></p><p>This folder already exists and possibly belongs to another machine.</p>','UIMessageCenter').replace('%1',vboxBasename(loc)).replace('%2',vboxDirname(loc)));
  237. // Go back
  238. wiz.displayStep(1);
  239. return;
  240. }
  241. $(document.forms['frmwizardNewVM'].newVMName).removeClass('vboxRequired');
  242. // Update disabled / enabled items
  243. if(document.forms['frmwizardNewVM'].newVMDisk[0].checked) {
  244. $(document.forms['frmwizardNewVM'].newVMDisk[0]).trigger('click');
  245. } else {
  246. $(document.forms['frmwizardNewVM'].newVMDisk[1]).trigger('click');
  247. }
  248. };
  249. fe.run();
  250. },{'name':document.forms['frmwizardNewVM'].newVMName.value, 'group':wiz.vmgroup});
  251. l.run();
  252. });
  253. /* When hard disk is enabled / disabled */
  254. $('#newVMHDTriggerBind').on('enable',function(){
  255. // Update disabled / enabled items
  256. if(document.forms['frmwizardNewVM'].newVMDisk[0].checked) {
  257. $(document.forms['frmwizardNewVM'].newVMDisk[0]).trigger('click');
  258. } else {
  259. $(document.forms['frmwizardNewVM'].newVMDisk[1]).trigger('click');
  260. }
  261. }).on('disable',function(){
  262. newVMToggleNewDisk(true);
  263. });
  264. </script>