Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

wizardNewHDAdvanced.html 9.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <!--
  2. Advanced panes for new hard disk wizard. Logic in vboxWizard()
  3. Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
  4. $Id: wizardNewHDAdvanced.html 595 2015-04-17 09:50:36Z imoore76 $
  5. -->
  6. <!-- Step 1 -->
  7. <div id='wizardNewHDStep1' style='display: none'>
  8. <span class='vboxTableLabel translate'>File location</span>
  9. <div class='vboxOptions'>
  10. <table class='vboxOptions'>
  11. <tr>
  12. <td style='width: 100%; white-space: nowrap'>
  13. <input type='text' class='vboxText' name='wizardNewHDLocation' style='width: 100%'/>
  14. </td>
  15. <td style='width: 1%' id='wizardHDBrowseLocationButton'></td>
  16. </tr>
  17. </table>
  18. </div>
  19. <span class='vboxTableLabel translate'>File size</span>
  20. <div class='vboxOptions'>
  21. <table>
  22. <tr>
  23. <td style='width: 100%; border: 0px; margin: 0px; padding: 0px;'>
  24. <div style='margin-top: 4px' id='wizardNewHDSize' class='slider'><div class='sliderScale'></div></div>
  25. </td>
  26. <td><input type='text' class='vboxText' name='wizardNewHDSizeValue' size='8' class='sliderValue' /></td>
  27. </tr>
  28. <tr style='vertical-align: top;'>
  29. <td style='border: 0px; margin: 0px; padding: 0px;'>
  30. <table style='width: 100%; border: 0px; margin: 0px; padding: 0px;'>
  31. <tr style='vertical-align: top'>
  32. <td style='text-align: left;'><span id='wizardNewHDMin'>1</span></td>
  33. <td style='text-align: right;'><span id='wizardNewHDMax'>128</span></td>
  34. </tr>
  35. </table>
  36. </td>
  37. <td></td>
  38. </tr>
  39. </table>
  40. </div>
  41. <table class='vboxInvisible' style='border: 0px solid transparent; border-spacing: 4px;'>
  42. <tr style='vertical-align: top'>
  43. <td>
  44. <span class='vboxTableLabel translate'>Hard disk file type</span>
  45. <div class='vboxOptions'>
  46. <table class='vboxOptions vboxNewHDWizardFileTypes'>
  47. <tr style='vertical-align: top;'>
  48. <td><label><input type='radio' class='vboxRadio' checked='checked' name='newHardDiskFileType' value='vdi' /> <span class='translate'>VDI (VirtualBox Disk Image)</span></label></td>
  49. </tr>
  50. <tr style='vertical-align: top;'>
  51. <td><label><input type='radio' class='vboxRadio' name='newHardDiskFileType' value='vmdk' /> <span class='translate'>VMDK (Virtual Machine Disk)</span></label></td>
  52. </tr>
  53. <tr style='vertical-align: top;'>
  54. <td><label><input type='radio' class='vboxRadio' name='newHardDiskFileType' value='vhd' /> <span class='translate'>VHD (Virtual Hard Disk)</span></label></td>
  55. </tr>
  56. </table>
  57. </div>
  58. </td>
  59. <td>
  60. <span class='vboxTableLabel translate'>Storage on physical hard disk</span>
  61. <div class='vboxOptions'>
  62. <table class='vboxOptions'>
  63. <tr style='vertical-align: top;' class='vboxCreateDynamic'>
  64. <td><label><input type='radio' class='vboxRadio' checked='checked' name='newHardDiskType' value='dynamic' /> <span class='translate'>Dynamically allocated</span></label></td>
  65. </tr>
  66. <tr style='vertical-align: top;' class='vboxCreateFixed'>
  67. <td><label><input type='radio' class='vboxRadio' name='newHardDiskType' value='fixed' /> <span class='translate'>Fixed size</span></label></td>
  68. </tr>
  69. <tr style='vertical-align: top;' class='vboxCreateSplit2G'>
  70. <td><label><input type='checkbox' class='vboxCheckbox' name='newHardDiskSplit' disabled/> <span class='translate'>Split into files of less than 2GB</span></label></td>
  71. </tr>
  72. </table>
  73. </div>
  74. </td>
  75. </tr>
  76. </table>
  77. </div>
  78. <script type='text/javascript'>
  79. //Fill HD type options
  80. var vboxHDTypesTbl = $('#wizardNewHDStep1').find('table.vboxNewHDWizardFileTypes').first();
  81. vboxHDTypesTbl.children().remove();
  82. var vboxHDTypes = $('#vboxPane').data('vboxSystemProperties').mediumFormats;
  83. for(var i = 0; i < vboxHDTypes.length; i++) {
  84. if(jQuery.inArray('CreateFixed',vboxHDTypes[i].capabilities) < 0 && jQuery.inArray('CreateDynamic',vboxHDTypes[i].capabilities) < 0) continue;
  85. if(jQuery.inArray('HardDisk',vboxHDTypes[i].deviceTypes) > -1) {
  86. vboxHDTypesTbl.append("<tr style='vertical-align: top;'><td><label><input type='radio' onClick='wizardHDUpdateOptions()' class='vboxRadio' name='newHardDiskFileType' value='"+vboxHDTypes[i].id+"' /> "+vboxMedia.getFormat({'format':vboxHDTypes[i].name})+"</label></td></tr>");
  87. vboxHDTypesTbl.find('tr').last().data('vboxFormat', vboxHDTypes[i]);
  88. }
  89. }
  90. // Select default HD format and place it at the top
  91. vboxHDTypesTbl.find('input[value='+$('#vboxPane').data('vboxSystemProperties').defaultHardDiskFormat+']').prop('checked',true).closest('tr').detach().prependTo(vboxHDTypesTbl);
  92. wizardHDUpdateOptions();
  93. /*
  94. * Location button
  95. */
  96. /* Choose location of new file button */
  97. new vboxToolbarSingle({button: {
  98. 'name' : 'mselecthdbtn',
  99. 'label' : 'Choose a location for new virtual hard disk file...',
  100. 'language_context': 'UIWizardNewVD',
  101. 'icon' : 'select_file',
  102. 'click' : function () {
  103. wizardHDBrowseLocation();
  104. }
  105. }}).renderTo('wizardHDBrowseLocationButton');
  106. /*
  107. * Translations
  108. */
  109. $('#wizardNewHDStep1').find('span.translatevar').html(function(i,h){return trans(h,'UIWizardNewVDPageVariant');});
  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. /* Changing HD type, show / hide split option */
  141. function wizardHDUpdateOptions() {
  142. var caps = 0;
  143. for(var i = 0; i < document.forms['frmwizardNewHD'].newHardDiskFileType.length; i++) {
  144. if(document.forms['frmwizardNewHD'].newHardDiskFileType[i].checked) {
  145. caps = $(document.forms['frmwizardNewHD'].newHardDiskFileType[i]).closest('tr').data('vboxFormat').capabilities;
  146. break;
  147. }
  148. }
  149. var capOpts = ['CreateFixed','CreateDynamic','CreateSplit2G'];
  150. for(var i = 0; i < capOpts.length; i++) {
  151. if(jQuery.inArray(capOpts[i],caps) < 0) {
  152. $('#wizardNewHDStep1').find('tr.vbox'+capOpts[i]).addClass('disabled').find('input').prop({'disabled':true,'checked':false});
  153. } else {
  154. $('#wizardNewHDStep1').find('tr.vbox'+capOpts[i]).removeClass('disabled').find('input').prop('disabled',false);
  155. }
  156. }
  157. }
  158. /*
  159. *
  160. * Elect a filename for use
  161. *
  162. */
  163. function vboxWizardNewHDElectName(wiz) {
  164. // check for path and use it to elect name
  165. var baseName = null;
  166. var start = 1;
  167. if(wiz && wiz.suggested && wiz.suggested.vmName) {
  168. baseName = wiz.suggested.vmName;
  169. start = 2;
  170. }
  171. document.forms['frmwizardNewHD'].elements.wizardNewHDLocation.value = vboxMedia.electHardDiskName(baseName, start);
  172. }
  173. /* Size slider */
  174. var min = 1024;
  175. var max = Math.max(parseInt($('#vboxPane').data('vboxSystemProperties').infoVDSize),2199022206980) / 1048576;
  176. // Over 512GB and the slider becomes useless
  177. max = Math.min(max,512*1024);
  178. $('#wizardNewHDSize').data('form','frmwizardNewHD');
  179. $('#wizardNewHDSize').data('display',vboxMbytesConvert);
  180. $('#wizardNewHDSize').slider({'min':min,'max':max,'step':1024});
  181. $('#wizardNewHDSize').slider('value',2048);
  182. $('#wizardNewHDMin').html(vboxMbytesConvert(min));
  183. $('#wizardNewHDMax').html(vboxMbytesConvert(max));
  184. /* Suggested Data exists */
  185. $('#wizardNewHDStep1').on('show',function(e,wiz){
  186. // Already initialized?
  187. if($('#wizardNewHDStep1').data('init') || !wiz || !wiz.suggested) return;
  188. $(document.forms['frmwizardNewHD'].elements.wizardNewHDLocation).focus();
  189. /* Keep suggested options */
  190. $('#wizardNewHDStep1').data('wizSuggested', wiz.suggested);
  191. if(wiz.suggested.name) {
  192. document.forms['frmwizardNewHD'].elements.wizardNewHDLocation.value = wiz.suggested.name;
  193. }
  194. if(wiz.suggested.size) {
  195. $('#wizardNewHDSize').slider('value',wiz.suggested.size);
  196. }
  197. if(wiz.suggested.path && wiz.suggested.name){
  198. if($('#vboxPane').data('vboxConfig').enforceVMOwnership==true){
  199. var nameIndex = wiz.suggested.path.lastIndexOf(wiz.suggested.name+$('#vboxPane').data('vboxConfig').DSEP);
  200. var path = wiz.suggested.path.substr(0,nameIndex);
  201. wiz.suggested.path = path + $('#vboxPane').data('vboxSession').user + "_" + wiz.suggested.name+$('#vboxPane').data('vboxConfig').DSEP;
  202. }
  203. }
  204. if(!(wiz && wiz.suggested && wiz.suggested.name))
  205. vboxWizardNewHDElectName(wiz);
  206. $('#wizardNewHDStep1').data('init',true);
  207. });
  208. </script>