Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

wizardNewHD.html 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <!--
  2. Panes for new hard disk wizard. Logic in vboxWizard()
  3. Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
  4. $Id: wizardNewHD.html 595 2015-04-17 09:50:36Z imoore76 $
  5. -->
  6. <!-- Step 1 -->
  7. <div id='wizardNewHDStep1' title='Hard disk file type' style='display: none'>
  8. <p class='translate'>Please choose the type of file that you would like to use for the new virtual hard disk. If you do not need to use it with other virtualization software you can leave this setting unchanged.</p>
  9. <div class='vboxOptions'>
  10. <table class='vboxOptions'>
  11. <tr style='vertical-align: top;'>
  12. <td><label><input type='radio' class='vboxRadio' checked='checked' name='newHardDiskFileType' value='vdi' /> <span class='translate'>VDI (VirtualBox Disk Image)</span></label></td>
  13. </tr>
  14. <tr style='vertical-align: top;'>
  15. <td><label><input type='radio' class='vboxRadio' name='newHardDiskFileType' value='vmdk' /> <span class='translate'>VMDK (Virtual Machine Disk)</span></label></td>
  16. </tr>
  17. <tr style='vertical-align: top;'>
  18. <td><label><input type='radio' class='vboxRadio' name='newHardDiskFileType' value='vhd' /> <span class='translate'>VHD (Virtual Hard Disk)</span></label></td>
  19. </tr>
  20. </table>
  21. </div>
  22. </div>
  23. <!-- Step 2 -->
  24. <div id='wizardNewHDStep2' title='Storage on physical hard disk' style='display: none'>
  25. <p class='translate'>Please choose whether the new virtual hard disk file should grow as it is used (dynamically allocated) or if it should be created at its maximum size (fixed size).</p>
  26. <span class='translate vboxCreateDynamic'>&lt;p&gt;A &lt;b&gt;dynamically allocated&lt;/b&gt; hard disk file will only use space on your physical hard disk as it fills up (up to a maximum &lt;b&gt;fixed size&lt;/b&gt;), although it will not shrink again automatically when space on it is freed.&lt;/p&gt;</span>
  27. <span class='translate vboxCreateFixed'>&lt;p&gt;A &lt;b&gt;fixed size&lt;/b&gt; hard disk file may take longer to create on some systems but is often faster to use.&lt;/p&gt;</span>
  28. <span class='translate vboxCreateSplit2G'>&lt;p&gt;You can also choose to &lt;b&gt;split&lt;/b&gt; the hard disk file into several files of up to two gigabytes each. This is mainly useful if you wish to store the virtual machine on removable USB devices or old systems, some of which cannot handle very large files.</span>
  29. <div class='vboxOptions'>
  30. <table class='vboxOptions'>
  31. <tr style='vertical-align: top;' class='vboxCreateDynamic'>
  32. <td><label><input type='radio' class='vboxRadio' checked='checked' name='newHardDiskType' value='dynamic' /> <span class='translate'>Dynamically allocated</span></label></td>
  33. </tr>
  34. <tr style='vertical-align: top;' class='vboxCreateFixed'>
  35. <td><label><input type='radio' class='vboxRadio' name='newHardDiskType' value='fixed' /> <span class='translate'>Fixed size</span></label></td>
  36. </tr>
  37. <tr style='vertical-align: top;' class='vboxCreateSplit2G'>
  38. <td><label><input type='checkbox' class='vboxCheckbox' name='newHardDiskSplit' /> <span class='translate'>Split into files of less than 2GB</span></label></td>
  39. </tr>
  40. </table>
  41. </div>
  42. </div>
  43. <!-- Step 3 -->
  44. <div id='wizardNewHDStep3' title='File location and size' style='display: none'>
  45. <p class='translate'>Please type the name of the new virtual hard disk file into the box below or click on the folder icon to select a different folder to create the file in.</p>
  46. <div class='vboxOptions'>
  47. <table class='vboxOptions'>
  48. <tr>
  49. <td style='width: 100%; white-space: nowrap'>
  50. <input type='text' class='vboxText' name='wizardNewHDLocation' style='width: 100%'/>
  51. </td>
  52. <td style='width: 1%;' id='wizardHDBrowseLocationButton'></td>
  53. </tr>
  54. </table>
  55. </div>
  56. <p class='translate'>Select the size of the virtual hard disk in megabytes. This size is the limit on the amount of file data that a virtual machine will be able to store on the hard disk.</p>
  57. <div class='vboxOptions'>
  58. <table>
  59. <tr>
  60. <td style='width: 100%; border: 0px; margin: 0px; padding: 0px;'>
  61. <div style='margin-top: 4px' id='wizardNewHDSize' class='slider'><div class='sliderScale'></div></div>
  62. </td>
  63. <td><input type='text' class='vboxText' name='wizardNewHDSizeValue' size='8' class='sliderValue' /></td>
  64. </tr>
  65. <tr style='vertical-align: top;'>
  66. <td style='border: 0px; margin: 0px; padding: 0px;'>
  67. <table style='width: 100%; border: 0px; margin: 0px; padding: 0px;'>
  68. <tr style='vertical-align: top'>
  69. <td style='text-align: left;'><span id='wizardNewHDMin'>1</span></td>
  70. <td style='text-align: right;'><span id='wizardNewHDMax'>128</span></td>
  71. </tr>
  72. </table>
  73. </td>
  74. <td></td>
  75. </tr>
  76. </table>
  77. </div>
  78. </div>
  79. <script type='text/javascript'>
  80. //Fill HD type options
  81. var vboxHDTypesTbl = $('#wizardNewHDStep1').find('table.vboxOptions').first();
  82. vboxHDTypesTbl.children().remove();
  83. var vboxHDTypes = $('#vboxPane').data('vboxSystemProperties').mediumFormats;
  84. for(var i = 0; i < vboxHDTypes.length; i++) {
  85. if(jQuery.inArray('CreateFixed',vboxHDTypes[i].capabilities) < 0 && jQuery.inArray('CreateDynamic',vboxHDTypes[i].capabilities) < 0) continue;
  86. if(jQuery.inArray('HardDisk',vboxHDTypes[i].deviceTypes) > -1) {
  87. vboxHDTypesTbl.append("<tr style='vertical-align: top;'><td><label><input type='radio' class='vboxRadio' name='newHardDiskFileType' value='"+vboxHDTypes[i].id+"' /> "+vboxMedia.getFormat({'format':vboxHDTypes[i].name})+"</label></td></tr>");
  88. vboxHDTypesTbl.find('tr').last().data('vboxFormat', vboxHDTypes[i]);
  89. }
  90. }
  91. // Select default HD format and place it at the top
  92. vboxHDTypesTbl.find('input[value='+$('#vboxPane').data('vboxSystemProperties').defaultHardDiskFormat+']').prop('checked',true).closest('tr').detach().prependTo(vboxHDTypesTbl);
  93. /*
  94. * Translations
  95. */
  96. $('#wizardNewHDStep2').find('span.translatevar').html(function(i,h){return trans(h,'UIWizardNewVDPageVariant');});
  97. /*
  98. * Location button
  99. */
  100. /* Choose location of new file button */
  101. new vboxToolbarSingle({button: {
  102. 'name' : 'mselecthdbtn',
  103. 'label' : 'Choose a location for new virtual hard disk file...',
  104. 'language_context': 'UIWizardNewVD',
  105. 'icon' : 'select_file',
  106. 'click' : function () {
  107. wizardHDBrowseLocation();
  108. }
  109. }}).renderTo('wizardHDBrowseLocationButton');
  110. /* Browse for new VDI location */
  111. function wizardHDBrowseLocation() {
  112. // Get current location
  113. var loc = $('<div />').html(document.forms['frmwizardNewHD'].elements.wizardNewHDLocation.value).text();
  114. if(!loc) {
  115. // no path set
  116. loc = $('#vboxPane').data('vboxSystemProperties').homeFolder;
  117. } else {
  118. loc = vboxDirname(loc);
  119. }
  120. if(loc.indexOf($('#vboxPane').data('vboxConfig').DSEP) < 0 && $('#wizardNewHDStep1').data('wizSuggested')['path']) {
  121. loc = $('#wizardNewHDStep1').data('wizSuggested')['path'];
  122. }
  123. vboxFileBrowser(loc,function(f){
  124. if(!f) return;
  125. // get file name
  126. prefile = document.forms['frmwizardNewHD'].elements.wizardNewHDLocation.value;
  127. var lastindex = -1;
  128. if(prefile.lastIndexOf("\\") >= 0){ lastindex = prefile.lastIndexOf("\\"); }
  129. if(prefile.lastIndexOf("/") >= 0) { lastindex = prefile.lastIndexOf("/"); }
  130. filename = prefile.substring(lastindex+1,prefile.length);
  131. var laststring = f.charAt(f.length-1);
  132. if(laststring=="\\" || laststring=="/"){
  133. // has slash at end so get rid off it...
  134. f=f.substring(0,f.length-1);
  135. }
  136. var path = f+$('#vboxPane').data('vboxConfig').DSEP+filename;
  137. document.forms['frmwizardNewHD'].elements.wizardNewHDLocation.value = path;
  138. },true,trans('Location','UIWizardNewVD'));
  139. }
  140. /* Keep suggested options */
  141. $('#wizardNewHDStep1').on('show',function(e,wiz){
  142. $('#wizardNewHDStep1').data('wizSuggested', (wiz.suggested ? wiz.suggested : {}));
  143. });
  144. /* WHen showing step 2, show / hide split option */
  145. $('#wizardNewHDStep2').on('show',function(e,wiz){
  146. var caps = 0;
  147. for(var i = 0; i < document.forms['frmwizardNewHD'].newHardDiskFileType.length; i++) {
  148. if(document.forms['frmwizardNewHD'].newHardDiskFileType[i].checked) {
  149. caps = $(document.forms['frmwizardNewHD'].newHardDiskFileType[i]).closest('tr').data('vboxFormat').capabilities;
  150. break;
  151. }
  152. }
  153. var capOpts = ['CreateFixed','CreateDynamic','CreateSplit2G'];
  154. for(var i = 0; i < capOpts.length; i++) {
  155. if(jQuery.inArray(capOpts[i],caps) < 0) {
  156. $('#wizardNewHDStep2').find('.vbox'+capOpts[i]).hide();
  157. } else {
  158. $('#wizardNewHDStep2').find('.vbox'+capOpts[i]).show();
  159. }
  160. }
  161. // Select first visible option
  162. $('#wizardNewHDStep2').find('tr:visible').first().find('input').prop('checked',true);
  163. if(!(wiz && wiz.suggested && wiz.suggested.name))
  164. vboxWizardNewHDElectName(wiz);
  165. });
  166. /* When last list of options */
  167. $('#wizardNewHDStep3').on('show',function(e,wiz){
  168. var format = document.forms['frmwizardNewHD'].elements['newHardDiskFileType'];
  169. var formatOpts = {};
  170. for(var i = 0; i < format.length; i++) {
  171. if(format[i].checked) {
  172. formatOpts = $(format[i]).closest('tr').data('vboxFormat');
  173. format=format[i].value;
  174. break;
  175. }
  176. }
  177. // uncheck vboxHDSplitOption if not supported
  178. if(jQuery.inArray('CreateSplit2G',formatOpts.capabilities) < 0)
  179. document.forms['frmwizardNewHD'].newHardDiskSplit.checked = false;
  180. });
  181. /*
  182. *
  183. * Elect a filename for use
  184. *
  185. */
  186. function vboxWizardNewHDElectName(wiz) {
  187. // check for path and use it to elect name
  188. var baseName = null;
  189. var start = 1;
  190. if(wiz && wiz.suggested && wiz.suggested.vmName) {
  191. baseName = wiz.suggested.vmName;
  192. start = 2;
  193. }
  194. document.forms['frmwizardNewHD'].elements.wizardNewHDLocation.value = vboxMedia.electHardDiskName(baseName,start);
  195. }
  196. /* Size slider */
  197. var min = 1024;
  198. var max = Math.max(parseInt($('#vboxPane').data('vboxSystemProperties').infoVDSize),2199022206980) / 1048576;
  199. // Over 512GB and the slider becomes useless
  200. max = Math.min(max,512*1024);
  201. $('#wizardNewHDSize').data('form','frmwizardNewHD');
  202. $('#wizardNewHDSize').data('display',vboxMbytesConvert);
  203. $('#wizardNewHDSize').slider({'min':min,'max':max,'step':1024});
  204. $('#wizardNewHDSize').slider('value',2048);
  205. $('#wizardNewHDMin').html(vboxMbytesConvert(min));
  206. $('#wizardNewHDMax').html(vboxMbytesConvert(max));
  207. /* Suggested Data exists */
  208. $('#wizardNewHDStep1').on('show',function(e,wiz){
  209. // Already initialized?
  210. if($('#wizardNewHDStep1').data('init') || !wiz || !wiz.suggested) return;
  211. if(wiz.suggested.name) {
  212. document.forms['frmwizardNewHD'].elements.wizardNewHDLocation.value = wiz.suggested.name;
  213. }
  214. if(wiz.suggested.size) {
  215. $('#wizardNewHDSize').slider('value',wiz.suggested.size);
  216. }
  217. if(wiz.suggested.path && wiz.suggested.name){
  218. if($('#vboxPane').data('vboxConfig').enforceVMOwnership==true){
  219. var nameIndex = wiz.suggested.path.lastIndexOf(wiz.suggested.name+$('#vboxPane').data('vboxConfig').DSEP);
  220. var path = wiz.suggested.path.substr(0,nameIndex);
  221. wiz.suggested.path = path + $('#vboxPane').data('vboxSession').user + "_" + wiz.suggested.name+$('#vboxPane').data('vboxConfig').DSEP;
  222. }
  223. $('#wizardNewHDStep3').data('suggestedpath',wiz.suggested.path);
  224. }
  225. $('#wizardNewHDStep1').data('init',true);
  226. });
  227. </script>