You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

wizardCopyHD.html 9.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <!--
  2. Panes for copy hard disk wizard. Logic in vboxWizard()
  3. Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
  4. $Id: wizardCopyHD.html 595 2015-04-17 09:50:36Z imoore76 $
  5. -->
  6. <!-- Step 1 -->
  7. <div id='wizardCopyHDStep1' title='Hard disk to copy' style='display: none'>
  8. <span class='translate'>&lt;p&gt;Please select the virtual hard disk file that you would like to copy if it is not already selected. You can either choose one from the list or use the folder icon beside the list to select one.&lt;/p&gt;</span>
  9. <div class='vboxOptions'>
  10. <table class='vboxOptions'>
  11. <tr style='vertical-align: top;'>
  12. <td><select id="copyHDDiskSelectId" name="copyHDDiskSelect" onchange='wizardCopyHDUpdateName(this)'></select></td>
  13. <td style='width:1%' id='newVMDiskVMM'></td>
  14. </tr>
  15. </table>
  16. </div>
  17. </div>
  18. <!-- Step 2 -->
  19. <div id='wizardCopyHDStep2' title='Hard disk file type' style='display: none'>
  20. <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>
  21. <div class='vboxOptions'>
  22. <table class='vboxOptions'>
  23. <tr style='vertical-align: top;'>
  24. <td><label><input type='radio' class='vboxRadio' checked='checked' name='copyHDFileType' value='vdi' /> <span class='translate'>VDI (VirtualBox Disk Image)</span></label></td>
  25. </tr>
  26. <tr style='vertical-align: top;'>
  27. <td><label><input type='radio' class='vboxRadio' name='copyHDFileType' value='vmdk' /> <span class='translate'>VMDK (Virtual Machine Disk)</span></label></td>
  28. </tr>
  29. <tr style='vertical-align: top;'>
  30. <td><label><input type='radio' class='vboxRadio' name='copyHDFileType' value='vhd' /> <span class='translate'>VHD (Virtual Hard Disk)</span></label></td>
  31. </tr>
  32. </table>
  33. </div>
  34. </div>
  35. <!-- Step 3 -->
  36. <div id='wizardCopyHDStep3' title='Storage on physical hard disk' style='display: none'>
  37. <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>
  38. <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>
  39. <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>
  40. <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>
  41. <div class='vboxOptions'>
  42. <table class='vboxOptions'>
  43. <tr style='vertical-align: top;' class='vboxCreateDynamic'>
  44. <td><label><input type='radio' class='vboxRadio' checked='checked' name='newHardDiskType' value='dynamic' /> <span class='translate'>Dynamically allocated</span></label></td>
  45. </tr>
  46. <tr style='vertical-align: top;' class='vboxCreateFixed'>
  47. <td><label><input type='radio' class='vboxRadio' name='newHardDiskType' value='fixed' /> <span class='translate'>Fixed size</span></label></td>
  48. </tr>
  49. <tr style='vertical-align: top;' class='vboxCreateSplit2G'>
  50. <td><label><input type='checkbox' class='vboxCheckbox' name='newHardDiskSplit' /> <span class='translate'>Split into files of less than 2GB</span></label></td>
  51. </tr>
  52. </table>
  53. </div>
  54. </div>
  55. <!-- Step 4 -->
  56. <div id='wizardCopyHDStep4' title='New hard disk to create' style='display: none'>
  57. <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>
  58. <div class='vboxOptions'>
  59. <table class='vboxOptions'>
  60. <tr>
  61. <td style='width: 100%; white-space: nowrap'>
  62. <input type='text' class='vboxText' name='wizardCopyHDLocation' style='width: 100%'/>
  63. </td>
  64. <td style='width: 1%;' id='newVMDiskVMMDest'></td>
  65. </tr>
  66. </table>
  67. </div>
  68. </div>
  69. <script type='text/javascript'>
  70. // Fill HD type options
  71. var vboxHDTypesTbl = $('#wizardCopyHDStep2').find('table.vboxOptions').first();
  72. vboxHDTypesTbl.children().remove();
  73. var vboxHDTypes = $('#vboxPane').data('vboxSystemProperties').mediumFormats;
  74. for(var i = 0; i < vboxHDTypes.length; i++) {
  75. if(jQuery.inArray('CreateFixed',vboxHDTypes[i].capabilities) < 0 && jQuery.inArray('CreateDynamic',vboxHDTypes[i].capabilities) < 0) continue;
  76. if(jQuery.inArray('HardDisk',vboxHDTypes[i].deviceTypes) > -1) {
  77. vboxHDTypesTbl.append("<tr style='vertical-align: top;'><td><label><input type='radio' class='vboxRadio' name='copyHDFileType' value='"+vboxHDTypes[i].id+"' /> "+vboxMedia.getFormat({'format':vboxHDTypes[i].name})+"</label></td></tr>");
  78. vboxHDTypesTbl.find('tr').last().data('vboxFormat', vboxHDTypes[i]);
  79. }
  80. }
  81. // Select default HD format and place it at the top
  82. vboxHDTypesTbl.find('input[value='+$('#vboxPane').data('vboxSystemProperties').defaultHardDiskFormat+']').prop('checked',true).closest('tr').detach().prependTo(vboxHDTypesTbl);
  83. /* Choose virtual hard disk button */
  84. new vboxToolbarSingle({button: {
  85. 'name' : 'mselecthdbtn',
  86. 'label' : 'Choose a virtual hard disk file to copy...',
  87. 'language_context': 'UIWizardCloneVD',
  88. 'icon' : 'select_file',
  89. 'click' : function () {
  90. vboxMedia.actions.choose(null,'HardDisk',function(med){
  91. if(med) copyHDFillDisks(med.base);
  92. });
  93. }
  94. }}).renderTo('newVMDiskVMM');
  95. /* Choose location of new file button */
  96. new vboxToolbarSingle({button: {
  97. 'name' : 'mselecthdbtn',
  98. 'label' : 'Choose a location for new virtual hard disk file...',
  99. 'language_context': 'UIWizardNewVD',
  100. 'icon' : 'select_file',
  101. 'click' : function () {
  102. wizardCopyHDBrowseLocation();
  103. }
  104. }}).renderTo('newVMDiskVMMDest');
  105. /* Set up disk selection box */
  106. function copyHDFillDisks(sel) {
  107. document.forms['frmwizardCopyHD'].copyHDDiskSelect.options.length = 0;
  108. $(document.forms['frmwizardCopyHD'].copyHDDiskSelect).children().remove();
  109. var s = vboxMedia.mediaForAttachmentType('HardDisk');
  110. // Sort media
  111. s.sort(function(a,b){return strnatcasecmp(a.name,b.name);});
  112. var mediumSelects = [];
  113. for(var i = 0; i < s.length; i++) {
  114. document.forms['frmwizardCopyHD'].copyHDDiskSelect.options[i] = new Option(vboxMedia.mediumPrint(s[i]),s[i].id);
  115. if(s[i].readOnly && s[i].deviceType == 'HardDisk') $(document.forms['frmwizardCopyHD'].copyHDDiskSelect.options[i]).addClass('vboxMediumReadOnly');
  116. mediumSelects[i] = {'attachedId':s[i].id,'id':s[i].id,'base':s[i].base,'label':vboxMedia.mediumPrint(s[i])};
  117. }
  118. if(sel) {
  119. $(document.forms['frmwizardCopyHD'].copyHDDiskSelect).val(sel);
  120. }
  121. $(document.forms['frmwizardCopyHD'].copyHDDiskSelect).mediumselect({'type':'HardDisk','showdiff':false,'media':mediumSelects});
  122. }
  123. copyHDFillDisks();
  124. /* Browse for new disk location */
  125. function wizardCopyHDBrowseLocation() {
  126. // Get current location
  127. var loc = document.forms['frmwizardCopyHD'].elements.wizardCopyHDLocation.value;
  128. if(loc.indexOf(':') > 0) {
  129. // windows
  130. loc = loc.replace(/.*\\/,'');
  131. } else if(loc.indexOf('/') != -1) {
  132. // *nix
  133. loc = loc.replace(/.*\//,'');
  134. } else {
  135. // no path set, use src location
  136. loc = vboxDirname(vboxMedia.getMediumById($(document.forms['frmwizardCopyHD'].copyHDDiskSelect).val()).location);
  137. }
  138. vboxFileBrowser(loc,function(f){
  139. if(!f) return;
  140. // get file name
  141. file = document.forms['frmwizardCopyHD'].elements.wizardCopyHDLocation.value;
  142. document.forms['frmwizardCopyHD'].elements.wizardCopyHDLocation.value = f+$('#vboxPane').data('vboxConfig').DSEP+file;
  143. },true);
  144. }
  145. /* Update new HD name */
  146. function wizardCopyHDUpdateName(sel) {
  147. var n = $(sel).val();
  148. var m = vboxMedia.getMediumById(n);
  149. if(!m) return;
  150. document.forms['frmwizardCopyHD'].elements.wizardCopyHDLocation.value = trans('%1_copy','UIWizardNewVD').replace('%1',m.name.replace(/\.[^\.]+?$/,''));
  151. }
  152. /* Suggested Data exists */
  153. $('#wizardCopyHDStep1').on('show',function(e,wiz){
  154. // Already initialized?
  155. if($('#wizardCopyHDStep1').data('init')) return;
  156. if(wiz && wiz.suggested && wiz.suggested.medium)
  157. $(document.forms['frmwizardCopyHD'].copyHDDiskSelect).mediumselect({'selectMedium':wiz.suggested.medium});
  158. $('#wizardCopyHDStep1').data('init',true);
  159. });
  160. $('#wizardCopyHDStep2').on('show',function(e,wiz){
  161. wiz._lastStep = 2;
  162. });
  163. $('#wizardCopyHDStep4').on('show',function(e,wiz){
  164. wiz._lastStep = 4;
  165. });
  166. /* WHen showing step 3, show / hide split option */
  167. $('#wizardCopyHDStep3').on('show',function(e,wiz){
  168. var caps = new Array();
  169. for(var i = 0; i < document.forms['frmwizardCopyHD'].copyHDFileType.length; i++) {
  170. if(document.forms['frmwizardCopyHD'].copyHDFileType[i].checked) {
  171. caps = $(document.forms['frmwizardCopyHD'].copyHDFileType[i]).closest('tr').data('vboxFormat').capabilities;
  172. break;
  173. }
  174. }
  175. var capOpts = ['CreateFixed','CreateDynamic','CreateSplit2G'];
  176. for(var i = 0; i < capOpts.length; i++) {
  177. if(jQuery.inArray(capOpts[i],caps) < 0) {
  178. $('#wizardCopyHDStep3').find('.vbox'+capOpts[i]).hide();
  179. } else {
  180. $('#wizardCopyHDStep3').find('.vbox'+capOpts[i]).show();
  181. }
  182. }
  183. // Select first visible option
  184. $('#wizardCopyHDStep3').find('tr:visible').first().find('input').prop('checked',true);
  185. if($('#wizardCopyHDStep3').find('tr:visible').length == 1) {
  186. if(wiz._lastStep == 2) wiz.displayStep(4);
  187. else if(wiz._lastStep == 4) wiz.displayStep(2);
  188. }
  189. });
  190. </script>