summaryrefslogtreecommitdiffstats
path: root/panes
diff options
context:
space:
mode:
authorTudor Holton <tudor@tudorholton.com>2018-07-13 17:44:24 +1000
committerTudor Holton <tudor@tudorholton.com>2018-07-13 17:44:24 +1000
commit81e287733d904e8f8fce1c91e42cf2933007c9cc (patch)
tree01146078eecd1a0fc610ae225192debed7925999 /panes
parentf3e62d8bce52f392b4faed4792e6e112d1777757 (diff)
parent3c61d5eae51e27082945f629d0076edf0c309f96 (diff)
downloadphpvirtualbox-81e287733d904e8f8fce1c91e42cf2933007c9cc.zip
phpvirtualbox-81e287733d904e8f8fce1c91e42cf2933007c9cc.tar.gz
phpvirtualbox-81e287733d904e8f8fce1c91e42cf2933007c9cc.tar.bz2
Ready for release 5.2-1
Diffstat (limited to 'panes')
-rw-r--r--panes/about.html36
-rw-r--r--panes/chooser.html192
-rw-r--r--panes/guestNetAdapters.html226
-rw-r--r--panes/login.html72
-rw-r--r--panes/settingsAudio.html232
-rw-r--r--panes/settingsDisplay.html392
-rw-r--r--panes/settingsGeneral.html892
-rw-r--r--panes/settingsGlobalGeneral.html194
-rw-r--r--panes/settingsGlobalLanguage.html144
-rw-r--r--panes/settingsGlobalNetwork.html1314
-rw-r--r--panes/settingsGlobalUsers.html516
-rw-r--r--panes/settingsNetwork.html1058
-rw-r--r--panes/settingsParallelPorts.html384
-rw-r--r--panes/settingsPortForwarding.html390
-rw-r--r--panes/settingsSerialPorts.html462
-rw-r--r--panes/settingsSharedFolders.html730
-rw-r--r--panes/settingsStorage.html3408
-rw-r--r--panes/settingsSystem.html932
-rw-r--r--panes/settingsUSB.html826
-rw-r--r--panes/tabVMConsole.html82
-rw-r--r--panes/tabVMConsoleRDP.html1008
-rw-r--r--panes/tabVMConsoleVNC.html376
-rw-r--r--panes/tabVMDetails.html1502
-rw-r--r--panes/tabVMSnapshots.html1775
-rw-r--r--panes/tabs.html354
-rw-r--r--panes/toolbar.html1112
-rw-r--r--panes/topmenu.html572
-rw-r--r--panes/userEdit.html128
-rw-r--r--panes/vmlogs.html210
-rw-r--r--panes/vmm.html2264
-rw-r--r--panes/vmmISCSI.html100
-rw-r--r--panes/vmmModify.html68
-rw-r--r--panes/wizardCloneVM.html253
-rw-r--r--panes/wizardCloneVMAdvanced.html197
-rw-r--r--panes/wizardCopyHD.html490
-rw-r--r--panes/wizardCopyHDAdvanced.html434
-rw-r--r--panes/wizardExportAppliance.html680
-rw-r--r--panes/wizardExportApplianceAdvanced.html640
-rw-r--r--panes/wizardFirstRun.html156
-rw-r--r--panes/wizardImportAppliance.html1104
-rw-r--r--panes/wizardImportApplianceAdvanced.html1072
-rw-r--r--panes/wizardNewVM.html686
-rw-r--r--panes/wizardNewVMAdvanced.html552
43 files changed, 14142 insertions, 14073 deletions
diff --git a/panes/about.html b/panes/about.html
index 1982e15..fb035ab 100644
--- a/panes/about.html
+++ b/panes/about.html
@@ -1,19 +1,19 @@
-<!-- $Id: about.html 595 2015-04-17 09:50:36Z imoore76 $ -->
-<div style='text-align: center'>
-<h3 align='center' id='vboxAboutHeader'>phpVirtualBox X -/- VirtualBox X compatible</h3>
-<p style='text-align: center'>Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com) - <a href='LICENSE.txt' target='_new'>LICENSE</a></p>
-<p style='text-align: center'><a target='_blank' href='http://sourceforge.net/projects/phpvirtualbox/'>http://sourceforge.net/projects/phpvirtualbox/</a></p>
-<p style='text-align: left'>
-I develop and support phpVirtualBox in my spare time - free of charge. I do not receive payments from VirtualBox (Oracle) nor am
-I affiliated with them in any way. If you find this program useful, I ask that you please donate.
-</p>
-<p align=center>
-<a href='https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=UB2BVHBDUJ2D2' target=_blank><img src='images/donate.gif' style='border: 0px;'></a>
-</p>
-<div style='margin-top: 10px; border-top: 1px solid #000;' id='vboxAboutVbox'><p>VirtualBox</p>
- <script type='text/javascript'>
- $('#vboxAboutHeader').html('phpVirtualBox '+$('#vboxPane').data('vboxConfig').phpvboxver+' -/- VirtualBox '+$('#vboxPane').data('vboxConfig').phpvboxver.substring(0,$('#vboxPane').data('vboxConfig').phpvboxver.indexOf('-'))+'.x compatible');
- $('#vboxAboutVbox').html('Virtual Box '+$('#vboxPane').data('vboxConfig').version.string+' ('+$('#vboxPane').data('vboxConfig').version.revision+')<br />' + $('#vboxPane').data('vboxConfig').version.settingsFilePath);
- </script>
-</div>
+<!-- $Id: about.html 595 2015-04-17 09:50:36Z imoore76 $ -->
+<div style='text-align: center'>
+<h3 align='center' id='vboxAboutHeader'>phpVirtualBox X -/- VirtualBox X compatible</h3>
+<p style='text-align: center'>Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com) - <a href='LICENSE.txt' target='_new'>LICENSE</a></p>
+<p style='text-align: center'><a target='_blank' href='http://sourceforge.net/projects/phpvirtualbox/'>http://sourceforge.net/projects/phpvirtualbox/</a></p>
+<p style='text-align: left'>
+I develop and support phpVirtualBox in my spare time - free of charge. I do not receive payments from VirtualBox (Oracle) nor am
+I affiliated with them in any way. If you find this program useful, I ask that you please donate.
+</p>
+<p align=center>
+<a href='https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=UB2BVHBDUJ2D2' target=_blank><img src='images/donate.gif' style='border: 0px;'></a>
+</p>
+<div style='margin-top: 10px; border-top: 1px solid #000;' id='vboxAboutVbox'><p>VirtualBox</p>
+ <script type='text/javascript'>
+ $('#vboxAboutHeader').html('phpVirtualBox '+$('#vboxPane').data('vboxConfig').phpvboxver+' -/- VirtualBox '+$('#vboxPane').data('vboxConfig').phpvboxver.substring(0,$('#vboxPane').data('vboxConfig').phpvboxver.indexOf('-'))+'.x compatible');
+ $('#vboxAboutVbox').html('Virtual Box '+$('#vboxPane').data('vboxConfig').version.string+' ('+$('#vboxPane').data('vboxConfig').version.revision+')<br />' + $('#vboxPane').data('vboxConfig').version.settingsFilePath);
+ </script>
+</div>
</div> \ No newline at end of file
diff --git a/panes/chooser.html b/panes/chooser.html
index 765d42d..dd33010 100644
--- a/panes/chooser.html
+++ b/panes/chooser.html
@@ -1,96 +1,96 @@
-<!--
-
- Virtual Machine List
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: chooser.html 595 2015-04-17 09:50:36Z imoore76 $
-
- @see js/chooser.js
-
- -->
-<div id='vboxChooserDiv'></div>
-<script type='text/javascript'>
-
-
-/*
- *
- *
- * Startup for VM List
- *
- */
-
-vboxChooser.setAnchorId('vboxChooserDiv');
-
-// Stop actions
-var sChildren = [];
-for(var i = 0; i < vboxVMActions.stop_actions.length; i++) {
- sChildren[sChildren.length] = $.extend(true,{},vboxVMActions[vboxVMActions.stop_actions[i]],{'iconStringDisabled':'_disabled'});
-}
-
-// VM List Group context menu
-vboxChooser.setContextMenu('group', [
- vboxVMGroupActions['newmachine'],
- vboxVMGroupActions['addmachine'],
- $.extend({}, vboxVMGroupActions['rename'], {separator: true}),
- vboxVMGroupActions['ungroup'],
- $.extend({}, vboxVMActions['start'], {'separator' : true}),
- vboxVMActions['pause'],
- vboxVMActions['reset'],
- $.extend({},vboxVMActions['stop'], {'children':sChildren}),
- $.extend({},vboxVMActions['discard'], {separator: true}),
- vboxVMActions['refresh'],
- $.extend({}, vboxVMGroupActions['sort'], {separator:true}),
-]);
-
-
-/*
- * VM Context menu setup (menu per VM in list)
- */
-
-vboxChooser.setContextMenu('vm',[
- vboxVMActions['settings'],
- vboxVMActions['clone'],
- vboxVMActions['remove'],
- vboxVMActions['group'],
- $.extend({},vboxVMActions['start'], {'separator' : true}),
- vboxVMActions['pause'],
- vboxVMActions['reset'],
- $.extend({},vboxVMActions['stop'], {'children': sChildren}),
- $.extend({},vboxVMActions['discard'], {'separator' : true}),
- vboxVMActions['logs'],
- vboxVMActions['refresh']
-]);
-
-// Don't need thse anymore
-sChildren = null;
-
-/*
- * VM list context menu setup
- */
-vboxChooser.setContextMenu('anchor', [
- vboxVMActions['new'],
- vboxVMActions['add'],
- {
- 'name':'fileImport',
- 'label':'Import Appliance...',
- 'icon':'import',
- 'click':function(){
- new vboxWizardImportApplianceDialog().run();
- },
- 'separator': true
- },
- {
- 'name':'fileExport',
- 'label':'Export Appliance...',
- 'icon':'export',
- 'click':function(){new vboxWizardExportApplianceDialog().run(); }
- },
- $.extend({},vboxVMGroupActions['sort'],{'separator':true,click:function(){
- vboxChooser.sortSelectedGroup(true);
- }})
-]);
-
-
-vboxChooser.start();
-
-</script>
+<!--
+
+ Virtual Machine List
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: chooser.html 595 2015-04-17 09:50:36Z imoore76 $
+
+ @see js/chooser.js
+
+ -->
+<div id='vboxChooserDiv'></div>
+<script type='text/javascript'>
+
+
+/*
+ *
+ *
+ * Startup for VM List
+ *
+ */
+
+vboxChooser.setAnchorId('vboxChooserDiv');
+
+// Stop actions
+var sChildren = [];
+for(var i = 0; i < vboxVMActions.stop_actions.length; i++) {
+ sChildren[sChildren.length] = $.extend(true,{},vboxVMActions[vboxVMActions.stop_actions[i]],{'iconStringDisabled':'_disabled'});
+}
+
+// VM List Group context menu
+vboxChooser.setContextMenu('group', [
+ vboxVMGroupActions['newmachine'],
+ vboxVMGroupActions['addmachine'],
+ $.extend({}, vboxVMGroupActions['rename'], {separator: true}),
+ vboxVMGroupActions['ungroup'],
+ $.extend({}, vboxVMActions['start'], {'separator' : true}),
+ vboxVMActions['pause'],
+ vboxVMActions['reset'],
+ $.extend({},vboxVMActions['stop'], {'children':sChildren}),
+ $.extend({},vboxVMActions['discard'], {separator: true}),
+ vboxVMActions['refresh'],
+ $.extend({}, vboxVMGroupActions['sort'], {separator:true}),
+]);
+
+
+/*
+ * VM Context menu setup (menu per VM in list)
+ */
+
+vboxChooser.setContextMenu('vm',[
+ vboxVMActions['settings'],
+ vboxVMActions['clone'],
+ vboxVMActions['remove'],
+ vboxVMActions['group'],
+ $.extend({},vboxVMActions['start'], {'separator' : true}),
+ vboxVMActions['pause'],
+ vboxVMActions['reset'],
+ $.extend({},vboxVMActions['stop'], {'children': sChildren}),
+ $.extend({},vboxVMActions['discard'], {'separator' : true}),
+ vboxVMActions['logs'],
+ vboxVMActions['refresh']
+]);
+
+// Don't need thse anymore
+sChildren = null;
+
+/*
+ * VM list context menu setup
+ */
+vboxChooser.setContextMenu('anchor', [
+ vboxVMActions['new'],
+ vboxVMActions['add'],
+ {
+ 'name':'fileImport',
+ 'label':'Import Appliance...',
+ 'icon':'import',
+ 'click':function(){
+ new vboxWizardImportApplianceDialog().run();
+ },
+ 'separator': true
+ },
+ {
+ 'name':'fileExport',
+ 'label':'Export Appliance...',
+ 'icon':'export',
+ 'click':function(){new vboxWizardExportApplianceDialog().run(); }
+ },
+ $.extend({},vboxVMGroupActions['sort'],{'separator':true,click:function(){
+ vboxChooser.sortSelectedGroup(true);
+ }})
+]);
+
+
+vboxChooser.start();
+
+</script>
diff --git a/panes/guestNetAdapters.html b/panes/guestNetAdapters.html
index e13e048..bcf2be7 100644
--- a/panes/guestNetAdapters.html
+++ b/panes/guestNetAdapters.html
@@ -1,113 +1,113 @@
-<!--
-
- Shows guest networking adapters. This requires that Guest Additions be
- installed in the Guest VM
-
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: guestNetAdapters.html 595 2015-04-17 09:50:36Z imoore76 $
-
--->
-<div id='vboxGuestNetAdapters'>
-
-</div>
-<!-- Used as a Template -->
-<div id='vboxGuestNetAdapterTemplate' class='vboxDialogContent vboxTabContent' style='display: none'>
- <table class="vboxVertical">
- <tr>
- <th><span class='translate'>IPv4 Address</span>:</th>
- <td><span title='/V4/IP'></span></td>
- </tr>
- <tr>
- <th><span class='translate'>IPv4 Network Mask</span>:</th>
- <td><span title='/V4/Netmask'></span></td>
- </tr>
- <tr class='vboxIPv6' style='display: none'>
- <th><span class='translate'>IPv6 Address</span>:</th>
- <td><span title='/V6/Ip'></span></td>
- </tr>
- <tr class='vboxIPv6' style='display: none'>
- <th><span class='translate'>IPv6 Network Mask Length</span>:</th>
- <td><span title='/V6/Netmask'></span></td>
- </tr>
- <tr>
- <th><span class='vboxGuestMac'>MAC Address:</span></th>
- <td><span title='/MAC'></span></td>
- </tr>
- </table>
-</div>
-
-<script type='text/javascript'>
-
-/* Translate */
-// Mac is special
-$('#vboxGuestNetAdapterTemplate').find('span.vboxGuestMac').html(trans('Mac Address:','UIMachineSettingsNetwork'));
-
-$('#vboxGuestNetAdapterTemplate').find(".translate").html(function(i,h){return trans(h,'UIGlobalSettingsNetwork');}).removeClass('translate');
-
-/*
- * Get data and pass to init function
- */
-function vboxVMNetAdaptersInit(vm) {
-
- // Add spinner and remove tab list if it exists
- $('#vboxGuestNetAdapterList').remove();
- $('#vboxGuestNetAdapters').prepend("<div class='vboxTabLoading'><img src='images/spinner.gif'></div>");
-
- var pattern = '/VirtualBox/GuestInfo/Net/*';
- $.when(vboxAjaxRequest('machineEnumerateGuestProperties',{'vm':vm,'pattern':pattern})).done(function(d){
- vboxVMNetAdaptersDisplay(d.responseData);
- });
-}
-
-function vboxVMNetAdaptersDisplay(d) {
-
- // Create hash / assoc array / mapping
- var data = {};
- for(var a = 0; a < d[0].length; a++) {
- data[d[0][a].replace('/VirtualBox/GuestInfo/Net/','')] = d[1][a];
- }
-
- // Remove spinner
- $('#vboxGuestNetAdapters').children().first().remove();
-
- // Append tab list
- var adl = $('<div />').attr({'id':'vboxGuestNetAdapterList','class':'vboxTabbed'});
-
- // Check for data
- if(!data['Count'] || data['Count'] < 1) {
- $(adl).html(trans('Unable to retrieve guest properties. Make sure the virtual machine is running and has the VirtualBox Guest Additions installed.','phpVirtualBox'));
- $('#vboxGuestNetAdapters').prepend(adl);
- return;
- }
-
- // Create list
- var ul = $('<ul />');
-
- // Each net adapter
- for(var i = 0; i < data['Count']; i++) {
-
- // Tab link
- $(ul).append($('<li />').html('<a href="#vboxGuestNetAdapter' + (i + 1) +'"><span>' + trans('Adapter %1','VBoxGlobal').replace('%1',(i + 1)) + '</span></a>'));
-
- // Tab content
- var tmpl = $("#vboxGuestNetAdapterTemplate").clone(true);
- tmpl.find('span[title]').each(function(){
- $(this).html(data[i+$(this).attr('title')]);
- });
- $(tmpl).attr('id','vboxGuestNetAdapter'+(i+1)).css({'display':''}).appendTo(adl);
-
- }
-
- // Tab links UL
- $(adl).prepend(ul);
-
- // prepend tabs
- $("#vboxGuestNetAdapters").prepend(adl);
-
- // Init display
- vboxInitDisplay('vboxGuestNetAdapters');
-
-}
-
-</script>
+<!--
+
+ Shows guest networking adapters. This requires that Guest Additions be
+ installed in the Guest VM
+
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: guestNetAdapters.html 595 2015-04-17 09:50:36Z imoore76 $
+
+-->
+<div id='vboxGuestNetAdapters'>
+
+</div>
+<!-- Used as a Template -->
+<div id='vboxGuestNetAdapterTemplate' class='vboxDialogContent vboxTabContent' style='display: none'>
+ <table class="vboxVertical">
+ <tr>
+ <th><span class='translate'>IPv4 Address</span>:</th>
+ <td><span title='/V4/IP'></span></td>
+ </tr>
+ <tr>
+ <th><span class='translate'>IPv4 Network Mask</span>:</th>
+ <td><span title='/V4/Netmask'></span></td>
+ </tr>
+ <tr class='vboxIPv6' style='display: none'>
+ <th><span class='translate'>IPv6 Address</span>:</th>
+ <td><span title='/V6/Ip'></span></td>
+ </tr>
+ <tr class='vboxIPv6' style='display: none'>
+ <th><span class='translate'>IPv6 Network Mask Length</span>:</th>
+ <td><span title='/V6/Netmask'></span></td>
+ </tr>
+ <tr>
+ <th><span class='vboxGuestMac'>MAC Address:</span></th>
+ <td><span title='/MAC'></span></td>
+ </tr>
+ </table>
+</div>
+
+<script type='text/javascript'>
+
+/* Translate */
+// Mac is special
+$('#vboxGuestNetAdapterTemplate').find('span.vboxGuestMac').html(trans('Mac Address:','UIMachineSettingsNetwork'));
+
+$('#vboxGuestNetAdapterTemplate').find(".translate").html(function(i,h){return trans(h,'UIGlobalSettingsNetwork');}).removeClass('translate');
+
+/*
+ * Get data and pass to init function
+ */
+function vboxVMNetAdaptersInit(vm) {
+
+ // Add spinner and remove tab list if it exists
+ $('#vboxGuestNetAdapterList').remove();
+ $('#vboxGuestNetAdapters').prepend("<div class='vboxTabLoading'><img src='images/spinner.gif'></div>");
+
+ var pattern = '/VirtualBox/GuestInfo/Net/*';
+ $.when(vboxAjaxRequest('machineEnumerateGuestProperties',{'vm':vm,'pattern':pattern})).done(function(d){
+ vboxVMNetAdaptersDisplay(d.responseData);
+ });
+}
+
+function vboxVMNetAdaptersDisplay(d) {
+
+ // Create hash / assoc array / mapping
+ var data = {};
+ for(var a = 0; a < d[0].length; a++) {
+ data[d[0][a].replace('/VirtualBox/GuestInfo/Net/','')] = d[1][a];
+ }
+
+ // Remove spinner
+ $('#vboxGuestNetAdapters').children().first().remove();
+
+ // Append tab list
+ var adl = $('<div />').attr({'id':'vboxGuestNetAdapterList','class':'vboxTabbed'});
+
+ // Check for data
+ if(!data['Count'] || data['Count'] < 1) {
+ $(adl).html(trans('Unable to retrieve guest properties. Make sure the virtual machine is running and has the VirtualBox Guest Additions installed.','phpVirtualBox'));
+ $('#vboxGuestNetAdapters').prepend(adl);
+ return;
+ }
+
+ // Create list
+ var ul = $('<ul />');
+
+ // Each net adapter
+ for(var i = 0; i < data['Count']; i++) {
+
+ // Tab link
+ $(ul).append($('<li />').html('<a href="#vboxGuestNetAdapter' + (i + 1) +'"><span>' + trans('Adapter %1','VBoxGlobal').replace('%1',(i + 1)) + '</span></a>'));
+
+ // Tab content
+ var tmpl = $("#vboxGuestNetAdapterTemplate").clone(true);
+ tmpl.find('span[title]').each(function(){
+ $(this).html(data[i+$(this).attr('title')]);
+ });
+ $(tmpl).attr('id','vboxGuestNetAdapter'+(i+1)).css({'display':''}).appendTo(adl);
+
+ }
+
+ // Tab links UL
+ $(adl).prepend(ul);
+
+ // prepend tabs
+ $("#vboxGuestNetAdapters").prepend(adl);
+
+ // Init display
+ vboxInitDisplay('vboxGuestNetAdapters');
+
+}
+
+</script>
diff --git a/panes/login.html b/panes/login.html
index 4c54ead..0888bc6 100644
--- a/panes/login.html
+++ b/panes/login.html
@@ -1,37 +1,37 @@
-<!--
- Login dialog
-
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: login.html 595 2015-04-17 09:50:36Z imoore76 $
--->
-<div id='vboxLogin'>
-<form>
-<table class='vboxVertical' style='margin:0px;'>
-<tr>
- <th><span class='translate'>Username</span>:</th>
- <td><input type='text' name='username' class='vboxText' /></td>
-</tr>
-<tr>
- <th><span class='translate'>Password</span>:</th>
- <td><input type='password' name='password' class='vboxText' /></td>
-</tr>
-<tr id='vboxLoginBtnRow' style='display:none;padding:0px;margin:0px;border:0px;'>
- <th style='padding:0px;margin:0px;border:0px'></th>
- <td style='padding:0px;margin:0px;border:0px'><input type='submit' value='' style='border:0px;margin:0px;display:inline;background:#fff;text:#fff;padding:0px;height:1px;' /></td>
-</tr>
-</table>
-</form>
-</div>
-<script type='text/javascript'>
-
-$('#vboxLogin').find(".translate").html(function(i,h){return trans(h,'UIUsers');}).removeClass('translate');
-
-if($.browser.msie || $.browser.webkit) $('#vboxLoginBtnRow').css({'display':''});
-$('#vboxLogin form').on('submit', function(e) {
- $('#vboxLogin').dialog( "option", "buttons" )[trans('Log in','UIUsers')]();
- e.stopPropagation();
- e.preventDefault();
- return false;
-});
+<!--
+ Login dialog
+
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: login.html 595 2015-04-17 09:50:36Z imoore76 $
+-->
+<div id='vboxLogin'>
+<form>
+<table class='vboxVertical' style='margin:0px;'>
+<tr>
+ <th><span class='translate'>Username</span>:</th>
+ <td><input type='text' name='username' class='vboxText' /></td>
+</tr>
+<tr>
+ <th><span class='translate'>Password</span>:</th>
+ <td><input type='password' name='password' class='vboxText' /></td>
+</tr>
+<tr id='vboxLoginBtnRow' style='display:none;padding:0px;margin:0px;border:0px;'>
+ <th style='padding:0px;margin:0px;border:0px'></th>
+ <td style='padding:0px;margin:0px;border:0px'><input type='submit' value='' style='border:0px;margin:0px;display:inline;background:#fff;text:#fff;padding:0px;height:1px;' /></td>
+</tr>
+</table>
+</form>
+</div>
+<script type='text/javascript'>
+
+$('#vboxLogin').find(".translate").html(function(i,h){return trans(h,'UIUsers');}).removeClass('translate');
+
+if($.browser.msie || $.browser.webkit) $('#vboxLoginBtnRow').css({'display':''});
+$('#vboxLogin form').on('submit', function(e) {
+ $('#vboxLogin').dialog( "option", "buttons" )[trans('Log in','UIUsers')]();
+ e.stopPropagation();
+ e.preventDefault();
+ return false;
+});
</script> \ No newline at end of file
diff --git a/panes/settingsAudio.html b/panes/settingsAudio.html
index 64be7b3..1985778 100644
--- a/panes/settingsAudio.html
+++ b/panes/settingsAudio.html
@@ -1,117 +1,117 @@
-<!--
-
- Audio Settings
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: settingsAudio.html 597 2015-04-20 11:41:28Z imoore76 $
-
--->
-<table class='vboxVertical'>
- <tr>
- <td colspan='2'><label><input type='checkbox' class='vboxCheckbox vboxEnablerCheckbox' name='vboxSettingsAudioEnabled' /> <span class='translate'>Enable Audio</span></label></td>
- </tr>
- <tr>
- <th><span class='translate'>Host Audio Driver:</span></th>
- <td>
- <select name='vboxSettingsAudioDriver'>
- </select>
- </td>
- </tr>
- <tr>
- <th><span class='translate'>Audio Controller:</span></th>
- <td>
- <select name='vboxSettingsAudioController'>
- </select>
- </td>
- </tr>
-</table>
-<script type='text/javascript'>
-
-/* Audio */
-
-/*
- *
- * Static Audio Drivers
- *
- */
-// Not sure if mac returns 'mac' or 'macintosh' or 'apple' for OS name
-// Not sure if solaris returns 'solaris' or 'sun' for OS name
-// Using just the first letter should take care of this
-var vboxSettingsAudioDrivers = {
- 'w' : ['Null','WinMM','DirectSound'], // windows
- 'l' : ['Null','OSS','ALSA','Pulse'], // linux
- 'd' : ['Null','CoreAudio'], // darwin
- 'm' : ['Null','CoreAudio'], // mac
- 'a' : ['Null','CoreAudio'], // apple
- 'o' : ['Null','CoreAudio'], // os x
- 's' : ['Null','SolAudio'] // solaris / sun
-};
-
-
-/* Disable non-editable items when VM is running */
-$('#vboxSettingsDialog').on('dataLoaded',function(){
-
- /*
- * Load audio controller types
- */
-
- var ad = $('#vboxSettingsDialog').data('vboxAudioControllerTypes');
-
- // Failsafe
- if(!ad) ad = [];
- if(jQuery.inArray($('#vboxSettingsDialog').data('vboxMachineData').audioAdapter.audioController, ad) < 0)
- ad[ad.length] = $('#vboxSettingsDialog').data('vboxMachineData').audioAdapter.audioController;
-
- // clear options first
- document.forms['frmVboxSettings'].vboxSettingsAudioController.options.length = 0;
-
- for(var i = 0; i < ad.length; i++) {
- var opt = new Option(trans(vboxAudioController(ad[i]),'VBoxGlobal'),ad[i]);
- document.forms['frmVboxSettings'].vboxSettingsAudioController.options[document.forms['frmVboxSettings'].vboxSettingsAudioController.options.length] = opt;
- }
-
-
- /*
- * Load audio driver types
- */
- var ad = vboxSettingsAudioDrivers[$('#vboxSettingsDialog').data('vboxHostDetails').operatingSystem.toLowerCase().substring(0,1)];
-
- // Failsafe
- if(!ad) {
- ad = [$('#vboxPane').data('vboxSystemProperties').defaultAudioDriver];
- }
- if(jQuery.inArray($('#vboxSettingsDialog').data('vboxMachineData').audioAdapter.audioDriver, ad) < 0)
- ad[ad.length] = $('#vboxSettingsDialog').data('vboxMachineData').audioAdapter.audioDriver;
-
- for(var i = 0; i < ad.length; i++) {
- var opt = new Option(trans(vboxAudioDriver(ad[i]),'VBoxGlobal'),ad[i]);
- document.forms['frmVboxSettings'].vboxSettingsAudioDriver.options[document.forms['frmVboxSettings'].vboxSettingsAudioDriver.options.length] = opt;
- }
-
- $(document.forms['frmVboxSettings'].vboxSettingsAudioDriver).val($('#vboxSettingsDialog').data('vboxMachineData').audioAdapter.audioDriver);
- $(document.forms['frmVboxSettings'].vboxSettingsAudioController).val($('#vboxSettingsDialog').data('vboxMachineData').audioAdapter.audioController);
-
-
- var p = $(document.forms['frmVboxSettings'].vboxSettingsAudioController).closest('table');
- if(!$('#vboxSettingsDialog').data('vboxFullEdit')) {
- $(document.forms['frmVboxSettings'].vboxSettingsAudioEnabled).prop('checked',$('#vboxSettingsDialog').data('vboxMachineData').audioAdapter.enabled).triggerHandler('click');
- $(p).find('span').addClass('disabled');
- $(p).find('input,select,textarea').prop('disabled',true);
- } else {
- $(p).find('span').removeClass('disabled');
- $(p).find('input,select,textarea').prop('disabled',false);
- $(document.forms['frmVboxSettings'].vboxSettingsAudioEnabled).prop('checked',$('#vboxSettingsDialog').data('vboxMachineData').audioAdapter.enabled).triggerHandler('click');
- }
-});
-
-/* Change settings onSave() */
-$('#vboxSettingsDialog').on('save',function(){
-
- $('#vboxSettingsDialog').data('vboxMachineData').audioAdapter.audioDriver = document.forms['frmVboxSettings'].vboxSettingsAudioDriver.value;
- $('#vboxSettingsDialog').data('vboxMachineData').audioAdapter.audioController = document.forms['frmVboxSettings'].vboxSettingsAudioController.value;
- $('#vboxSettingsDialog').data('vboxMachineData').audioAdapter.enabled = document.forms['frmVboxSettings'].vboxSettingsAudioEnabled.checked;
-
-});
-
-</script>
+<!--
+
+ Audio Settings
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: settingsAudio.html 597 2015-04-20 11:41:28Z imoore76 $
+
+-->
+<table class='vboxVertical'>
+ <tr>
+ <td colspan='2'><label><input type='checkbox' class='vboxCheckbox vboxEnablerCheckbox' name='vboxSettingsAudioEnabled' /> <span class='translate'>Enable Audio</span></label></td>
+ </tr>
+ <tr>
+ <th><span class='translate'>Host Audio Driver:</span></th>
+ <td>
+ <select name='vboxSettingsAudioDriver'>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <th><span class='translate'>Audio Controller:</span></th>
+ <td>
+ <select name='vboxSettingsAudioController'>
+ </select>
+ </td>
+ </tr>
+</table>
+<script type='text/javascript'>
+
+/* Audio */
+
+/*
+ *
+ * Static Audio Drivers
+ *
+ */
+// Not sure if mac returns 'mac' or 'macintosh' or 'apple' for OS name
+// Not sure if solaris returns 'solaris' or 'sun' for OS name
+// Using just the first letter should take care of this
+var vboxSettingsAudioDrivers = {
+ 'w' : ['Null','WinMM','DirectSound'], // windows
+ 'l' : ['Null','OSS','ALSA','Pulse'], // linux
+ 'd' : ['Null','CoreAudio'], // darwin
+ 'm' : ['Null','CoreAudio'], // mac
+ 'a' : ['Null','CoreAudio'], // apple
+ 'o' : ['Null','CoreAudio'], // os x
+ 's' : ['Null','SolAudio'] // solaris / sun
+};
+
+
+/* Disable non-editable items when VM is running */
+$('#vboxSettingsDialog').on('dataLoaded',function(){
+
+ /*
+ * Load audio controller types
+ */
+
+ var ad = $('#vboxSettingsDialog').data('vboxAudioControllerTypes');
+
+ // Failsafe
+ if(!ad) ad = [];
+ if(jQuery.inArray($('#vboxSettingsDialog').data('vboxMachineData').audioAdapter.audioController, ad) < 0)
+ ad[ad.length] = $('#vboxSettingsDialog').data('vboxMachineData').audioAdapter.audioController;
+
+ // clear options first
+ document.forms['frmVboxSettings'].vboxSettingsAudioController.options.length = 0;
+
+ for(var i = 0; i < ad.length; i++) {
+ var opt = new Option(trans(vboxAudioController(ad[i]),'VBoxGlobal'),ad[i]);
+ document.forms['frmVboxSettings'].vboxSettingsAudioController.options[document.forms['frmVboxSettings'].vboxSettingsAudioController.options.length] = opt;
+ }
+
+
+ /*
+ * Load audio driver types
+ */
+ var ad = vboxSettingsAudioDrivers[$('#vboxSettingsDialog').data('vboxHostDetails').operatingSystem.toLowerCase().substring(0,1)];
+
+ // Failsafe
+ if(!ad) {
+ ad = [$('#vboxPane').data('vboxSystemProperties').defaultAudioDriver];
+ }
+ if(jQuery.inArray($('#vboxSettingsDialog').data('vboxMachineData').audioAdapter.audioDriver, ad) < 0)
+ ad[ad.length] = $('#vboxSettingsDialog').data('vboxMachineData').audioAdapter.audioDriver;
+
+ for(var i = 0; i < ad.length; i++) {
+ var opt = new Option(trans(vboxAudioDriver(ad[i]),'VBoxGlobal'),ad[i]);
+ document.forms['frmVboxSettings'].vboxSettingsAudioDriver.options[document.forms['frmVboxSettings'].vboxSettingsAudioDriver.options.length] = opt;
+ }
+
+ $(document.forms['frmVboxSettings'].vboxSettingsAudioDriver).val($('#vboxSettingsDialog').data('vboxMachineData').audioAdapter.audioDriver);
+ $(document.forms['frmVboxSettings'].vboxSettingsAudioController).val($('#vboxSettingsDialog').data('vboxMachineData').audioAdapter.audioController);
+
+
+ var p = $(document.forms['frmVboxSettings'].vboxSettingsAudioController).closest('table');
+ if(!$('#vboxSettingsDialog').data('vboxFullEdit')) {
+ $(document.forms['frmVboxSettings'].vboxSettingsAudioEnabled).prop('checked',$('#vboxSettingsDialog').data('vboxMachineData').audioAdapter.enabled).triggerHandler('click');
+ $(p).find('span').addClass('disabled');
+ $(p).find('input,select,textarea').prop('disabled',true);
+ } else {
+ $(p).find('span').removeClass('disabled');
+ $(p).find('input,select,textarea').prop('disabled',false);
+ $(document.forms['frmVboxSettings'].vboxSettingsAudioEnabled).prop('checked',$('#vboxSettingsDialog').data('vboxMachineData').audioAdapter.enabled).triggerHandler('click');
+ }
+});
+
+/* Change settings onSave() */
+$('#vboxSettingsDialog').on('save',function(){
+
+ $('#vboxSettingsDialog').data('vboxMachineData').audioAdapter.audioDriver = document.forms['frmVboxSettings'].vboxSettingsAudioDriver.value;
+ $('#vboxSettingsDialog').data('vboxMachineData').audioAdapter.audioController = document.forms['frmVboxSettings'].vboxSettingsAudioController.value;
+ $('#vboxSettingsDialog').data('vboxMachineData').audioAdapter.enabled = document.forms['frmVboxSettings'].vboxSettingsAudioEnabled.checked;
+
+});
+
+</script>
\ No newline at end of file
diff --git a/panes/settingsDisplay.html b/panes/settingsDisplay.html
index 4b74214..b7996da 100644
--- a/panes/settingsDisplay.html
+++ b/panes/settingsDisplay.html
@@ -1,196 +1,196 @@
-<!--
-
- Display Settings
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: settingsDisplay.html 595 2015-04-17 09:50:36Z imoore76 $
-
--->
-<ul>
- <li><a href="#vboxSettingsTabDisplayVideo"><span class='translate'>Screen</span></a></li>
- <li><a href="#vboxSettingsTabDisplayRemote"><span class='translate'>Remote Display</span></a></li>
-</ul>
-
-<!-- Video Tab -->
-<div id='vboxSettingsTabDisplayVideo' title='Screen'>
-<table style='width: 100%'>
- <tr>
- <th><span class='translate'>Video Memory:</span></th>
- <td style='width: 100%; white-space: nowrap'>
- <table style='width: 100%'>
- <tr>
- <td style='width: 100%; border: 0px; margin: 0px; padding: 0px;'>
- <div style='margin-top: 4px' id='vboxSettingsDisplayMemory' class='slider'><div class='sliderScale'></div></div>
- </td>
- <td><input type='text' class='vboxText sliderValue' name='vboxSettingsDisplayMemoryValue' size='2' /> <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 class='vboxSliderMin'>%1 MB</span></td>
- <td style='text-align: right;'><span class='vboxSliderMax'>%1 MB</span></td>
- </tr>
- </table>
- </td>
- <td> </td>
- </tr>
- </table>
-
- </td>
- </tr>
- <tr>
- <th><span class='translate'>Extended Features:</span></th>
- <td><label><input type='checkbox' class='vboxCheckbox' name='vboxSettingsDisplay3d' /> <span class='translate'>Enable 3D Acceleration</span></label></td>
- </tr>
- <tr>
- <th></th>
- <td><label><input type='checkbox' class='vboxCheckbox' name='vboxSettingsDisplay2d' /> <span class='translate'>Enable 2D Video Acceleration</span></label></td>
- </tr>
-</table>
-</div>
-
-<!-- Remote Display Tab -->
-<div id='vboxSettingsTabDisplayRemote' title='Remote Display'>
-<table class='vboxVertical'>
- <tr class='vboxRunningEnabled'>
- <td colspan='2'><label><input type='checkbox' class='vboxCheckbox vboxEnablerCheckbox' name='vboxSettingsDisplayVRDEEnabled' /> <span class='translate'>Enable Server</span></label></td>
- </tr>
- <tr class='vboxRunningEnabled'>
- <th><span class='translate'>Server Port:</span></th>
- <td><input type='text' class='vboxText' style='width: 100%' name='vboxSettingsDisplayVRDEPort' /></td>
- </tr>
- <tr id='vboxSettingsDisplayVRDEAddrRow'>
- <th><span class='translate'>Net Address:</span></th>
- <td><input type='text' class='vboxText' style='width: 100%' name='vboxSettingsDisplayVRDEAddr' /></td>
- </tr>
- <tr class='vboxRunningEnabled vboxSettingsDisplayRDP'>
- <th><span class='translate'>Authentication Method:</span></th>
- <td>
- <select name='vboxSettingsDisplayVRDEAuth' id='vboxSettingsDisplayVRDEAuthID' style='width: 100%'>
- <option value='' >None</option>
- <option value='External'>External</option>
- <option value='Guest'>Guest</option>
- </select>
- </td>
- </tr>
- <tr class='vboxRunningEnabled vboxSettingsDisplayRDP'>
- <th><span class='translate'>Authentication Timeout:</span></th>
- <td><input type='text' class='vboxText' style='width: 100%' name='vboxSettingsDisplayVRDEAuthTimeout' /></td>
- </tr>
- <tr class='vboxSettingsDisplayRDP'>
- <th><span class='translate'>Extended Features:</span></th>
- <td><label><input type='checkbox' class='vboxCheckbox' name='vboxSettingsDisplayVRDEMulti' /> <span class='translate vboxEnablerListen'>Allow Multiple Connections</span></label></td>
- </tr>
- <tr class='vboxRunningEnabled vboxSettingsDisplayVNC'>
- <th><span class='translate'>VNC Password:</span></th>
- <td><input type='text' class='vboxText' style='width: 100%' name='vboxSettingsDisplayVNCPassword' /></td>
- </tr>
-
-</table>
-</div>
-<script type='text/javascript'>
-
-/* Display */
-
-/* auth method translations */
-$('#vboxSettingsDisplayVRDEAuthID').find('option').html(function(i,h){return trans(h,'VBoxGlobal');});
-
-$('#vboxSettingsDisplayMemory').data('form','frmVboxSettings');
-$('#vboxSettingsDisplayMemory').slider({'min':parseInt($('#vboxPane').data('vboxSystemProperties').minGuestVRAM),'max':parseInt($('#vboxPane').data('vboxSystemProperties').maxGuestVRAM)});
-
-
-
-/* CHange values when data is loaded */
-$('#vboxSettingsDialog').on('dataLoaded', function(){
-
-
- $('#vboxSettingsDisplayMemory').slider('value',parseInt($('#vboxSettingsDialog').data('vboxMachineData').VRAMSize));
-
- document.forms['frmVboxSettings'].vboxSettingsDisplay3d.checked = ($('#vboxSettingsDialog').data('vboxMachineData').accelerate3DEnabled);
- document.forms['frmVboxSettings'].vboxSettingsDisplay2d.checked = ($('#vboxSettingsDialog').data('vboxMachineData').accelerate2DVideoEnabled);
-
- var p = $('#vboxSettingsTabDisplayVideo').parent().children('div');
- if(!$('#vboxSettingsDialog').data('vboxFullEdit')) {
- $(p).find('tr:not(.vboxRunningEnabled)').find('span').addClass('disabled');
- $(p).find('tr:not(.vboxRunningEnabled)').find('input,select,textarea').addClass('disabled').prop('disabled',true);
- $('#vboxSettingsDisplayMemory').slider('disable');
- } else {
- $(p).find('tr:not(.vboxRunningEnabled)').find('span').removeClass('disabled');
- $(p).find('tr:not(.vboxRunningEnabled)').find('input,select,textarea').removeClass('disabled').prop('disabled',false);
- $('#vboxSettingsDisplayMemory').slider('enable');
-
- if(!$('#vboxSettingsDialog').data('vboxHostDetails').acceleration3DAvailable) {
- $(document.forms['frmVboxSettings'].vboxSettingsDisplay3d).addClass('disabled').prop('disabled', true)
- .parent().addClass('disabled');
- } else {
- $(document.forms['frmVboxSettings'].vboxSettingsDisplay3d).removeClass('disabled').prop('disabled', false)
- .parent().removeClass('disabled');
- }
- }
-
-
- /*
- * No VRDE?
- *
- */
- if(!($('#vboxSettingsDialog').data('vboxMachineData').VRDEServer && $('#vboxSettingsDialog').data('vboxMachineData').VRDEServer.VRDEExtPack)) {
-
- $('#vboxSettingsTabDisplayVideo').parent().tabs('disable',1);
-
-
- } else {
-
- $('#vboxSettingsTabDisplayVideo').parent().tabs('enable',1);
-
- // Show / hide VNC / RDP sections
- if($('#vboxSettingsDialog').data('vboxMachineData').VRDEServer.VRDEExtPack.indexOf("VNC") > -1) {
- $('#vboxSettingsTabDisplayRemote').find('tr.vboxSettingsDisplayRDP').css({'display':'none'});
- $('#vboxSettingsTabDisplayRemote').find('tr.vboxSettingsDisplayVNC').css({'display':''});
- } else {
- $('#vboxSettingsTabDisplayRemote').find('tr.vboxSettingsDisplayRDP').css({'display':''});
- $('#vboxSettingsTabDisplayRemote').find('tr.vboxSettingsDisplayVNC').css({'display':'none'});
- }
- document.forms['frmVboxSettings'].vboxSettingsDisplayVRDEPort.value = $('#vboxSettingsDialog').data('vboxMachineData').VRDEServer.ports;
- document.forms['frmVboxSettings'].vboxSettingsDisplayVRDEAuth.value = $('#vboxSettingsDialog').data('vboxMachineData').VRDEServer.authType;
- document.forms['frmVboxSettings'].vboxSettingsDisplayVRDEAuthTimeout.value = $('#vboxSettingsDialog').data('vboxMachineData').VRDEServer.authTimeout;
- document.forms['frmVboxSettings'].vboxSettingsDisplayVRDEAddr.value = $('#vboxSettingsDialog').data('vboxMachineData').VRDEServer.netAddress;
- document.forms['frmVboxSettings'].vboxSettingsDisplayVNCPassword.value = $('#vboxSettingsDialog').data('vboxMachineData').VRDEServer.VNCPassword;
-
- $(document.forms['frmVboxSettings'].vboxSettingsDisplayVRDEEnabled).attr('checked',(!$('#vboxSettingsDialog').data('vboxMachineData').VRDEServer.enabled)).trigger('click');
-
- if($('#vboxSettingsDialog').data('vboxMachineData').VRDEServer.allowMultiConnection) {
- document.forms['frmVboxSettings'].vboxSettingsDisplayVRDEMulti.checked = true;
- } else {
- document.forms['frmVboxSettings'].vboxSettingsDisplayVRDEMulti.checked = false;
- }
-
- if(!$('#vboxPane').data('vboxConfig').enableAdvancedConfig)
- $('#vboxSettingsDisplayVRDEAddrRow').css('display','none');
- }
-
-
-});
-
-/* Change settings onSave() */
-$('#vboxSettingsDialog').on('save',function(){
-
- $('#vboxSettingsDialog').data('vboxMachineData').VRAMSize = $(document.forms['frmVboxSettings'].vboxSettingsDisplayMemoryValue).val();
-
- $('#vboxSettingsDialog').data('vboxMachineData').accelerate3DEnabled = document.forms['frmVboxSettings'].vboxSettingsDisplay3d.checked;
- $('#vboxSettingsDialog').data('vboxMachineData').accelerate2DVideoEnabled = document.forms['frmVboxSettings'].vboxSettingsDisplay2d.checked;
-
- if($('#vboxSettingsDialog').data('vboxMachineData').VRDEServer && $('#vboxSettingsDialog').data('vboxMachineData').VRDEServer.VRDEExtPack) {
- $('#vboxSettingsDialog').data('vboxMachineData').VRDEServer.ports = document.forms['frmVboxSettings'].vboxSettingsDisplayVRDEPort.value;
- $('#vboxSettingsDialog').data('vboxMachineData').VRDEServer.netAddress = document.forms['frmVboxSettings'].vboxSettingsDisplayVRDEAddr.value;
- $('#vboxSettingsDialog').data('vboxMachineData').VRDEServer.authType = document.forms['frmVboxSettings'].vboxSettingsDisplayVRDEAuth.value;
- $('#vboxSettingsDialog').data('vboxMachineData').VRDEServer.authTimeout = document.forms['frmVboxSettings'].vboxSettingsDisplayVRDEAuthTimeout.value;
- $('#vboxSettingsDialog').data('vboxMachineData').VRDEServer.enabled = document.forms['frmVboxSettings'].vboxSettingsDisplayVRDEEnabled.checked;
- $('#vboxSettingsDialog').data('vboxMachineData').VRDEServer.allowMultiConnection = document.forms['frmVboxSettings'].vboxSettingsDisplayVRDEMulti.checked;
- $('#vboxSettingsDialog').data('vboxMachineData').VRDEServer.VNCPassword = document.forms['frmVboxSettings'].vboxSettingsDisplayVNCPassword.value;
- }
-});
-
-</script>
-
-
+<!--
+
+ Display Settings
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: settingsDisplay.html 595 2015-04-17 09:50:36Z imoore76 $
+
+-->
+<ul>
+ <li><a href="#vboxSettingsTabDisplayVideo"><span class='translate'>Screen</span></a></li>
+ <li><a href="#vboxSettingsTabDisplayRemote"><span class='translate'>Remote Display</span></a></li>
+</ul>
+
+<!-- Video Tab -->
+<div id='vboxSettingsTabDisplayVideo' title='Screen'>
+<table style='width: 100%'>
+ <tr>
+ <th><span class='translate'>Video Memory:</span></th>
+ <td style='width: 100%; white-space: nowrap'>
+ <table style='width: 100%'>
+ <tr>
+ <td style='width: 100%; border: 0px; margin: 0px; padding: 0px;'>
+ <div style='margin-top: 4px' id='vboxSettingsDisplayMemory' class='slider'><div class='sliderScale'></div></div>
+ </td>
+ <td><input type='text' class='vboxText sliderValue' name='vboxSettingsDisplayMemoryValue' size='2' /> <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 class='vboxSliderMin'>%1 MB</span></td>
+ <td style='text-align: right;'><span class='vboxSliderMax'>%1 MB</span></td>
+ </tr>
+ </table>
+ </td>
+ <td> </td>
+ </tr>
+ </table>
+
+ </td>
+ </tr>
+ <tr>
+ <th><span class='translate'>Extended Features:</span></th>
+ <td><label><input type='checkbox' class='vboxCheckbox' name='vboxSettingsDisplay3d' /> <span class='translate'>Enable 3D Acceleration</span></label></td>
+ </tr>
+ <tr>
+ <th></th>
+ <td><label><input type='checkbox' class='vboxCheckbox' name='vboxSettingsDisplay2d' /> <span class='translate'>Enable 2D Video Acceleration</span></label></td>
+ </tr>
+</table>
+</div>
+
+<!-- Remote Display Tab -->
+<div id='vboxSettingsTabDisplayRemote' title='Remote Display'>
+<table class='vboxVertical'>
+ <tr class='vboxRunningEnabled'>
+ <td colspan='2'><label><input type='checkbox' class='vboxCheckbox vboxEnablerCheckbox' name='vboxSettingsDisplayVRDEEnabled' /> <span class='translate'>Enable Server</span></label></td>
+ </tr>
+ <tr class='vboxRunningEnabled'>
+ <th><span class='translate'>Server Port:</span></th>
+ <td><input type='text' class='vboxText' style='width: 100%' name='vboxSettingsDisplayVRDEPort' /></td>
+ </tr>
+ <tr id='vboxSettingsDisplayVRDEAddrRow'>
+ <th><span class='translate'>Net Address:</span></th>
+ <td><input type='text' class='vboxText' style='width: 100%' name='vboxSettingsDisplayVRDEAddr' /></td>
+ </tr>
+ <tr class='vboxRunningEnabled vboxSettingsDisplayRDP'>
+ <th><span class='translate'>Authentication Method:</span></th>
+ <td>
+ <select name='vboxSettingsDisplayVRDEAuth' id='vboxSettingsDisplayVRDEAuthID' style='width: 100%'>
+ <option value='' >None</option>
+ <option value='External'>External</option>
+ <option value='Guest'>Guest</option>
+ </select>
+ </td>
+ </tr>
+ <tr class='vboxRunningEnabled vboxSettingsDisplayRDP'>
+ <th><span class='translate'>Authentication Timeout:</span></th>
+ <td><input type='text' class='vboxText' style='width: 100%' name='vboxSettingsDisplayVRDEAuthTimeout' /></td>
+ </tr>
+ <tr class='vboxSettingsDisplayRDP'>
+ <th><span class='translate'>Extended Features:</span></th>
+ <td><label><input type='checkbox' class='vboxCheckbox' name='vboxSettingsDisplayVRDEMulti' /> <span class='translate vboxEnablerListen'>Allow Multiple Connections</span></label></td>
+ </tr>
+ <tr class='vboxRunningEnabled vboxSettingsDisplayVNC'>
+ <th><span class='translate'>VNC Password:</span></th>
+ <td><input type='text' class='vboxText' style='width: 100%' name='vboxSettingsDisplayVNCPassword' /></td>
+ </tr>
+
+</table>
+</div>
+<script type='text/javascript'>
+
+/* Display */
+
+/* auth method translations */
+$('#vboxSettingsDisplayVRDEAuthID').find('option').html(function(i,h){return trans(h,'VBoxGlobal');});
+
+$('#vboxSettingsDisplayMemory').data('form','frmVboxSettings');
+$('#vboxSettingsDisplayMemory').slider({'min':parseInt($('#vboxPane').data('vboxSystemProperties').minGuestVRAM),'max':parseInt($('#vboxPane').data('vboxSystemProperties').maxGuestVRAM)});
+
+
+
+/* CHange values when data is loaded */
+$('#vboxSettingsDialog').on('dataLoaded', function(){
+
+
+ $('#vboxSettingsDisplayMemory').slider('value',parseInt($('#vboxSettingsDialog').data('vboxMachineData').VRAMSize));
+
+ document.forms['frmVboxSettings'].vboxSettingsDisplay3d.checked = ($('#vboxSettingsDialog').data('vboxMachineData').accelerate3DEnabled);
+ document.forms['frmVboxSettings'].vboxSettingsDisplay2d.checked = ($('#vboxSettingsDialog').data('vboxMachineData').accelerate2DVideoEnabled);
+
+ var p = $('#vboxSettingsTabDisplayVideo').parent().children('div');
+ if(!$('#vboxSettingsDialog').data('vboxFullEdit')) {
+ $(p).find('tr:not(.vboxRunningEnabled)').find('span').addClass('disabled');
+ $(p).find('tr:not(.vboxRunningEnabled)').find('input,select,textarea').addClass('disabled').prop('disabled',true);
+ $('#vboxSettingsDisplayMemory').slider('disable');
+ } else {
+ $(p).find('tr:not(.vboxRunningEnabled)').find('span').removeClass('disabled');
+ $(p).find('tr:not(.vboxRunningEnabled)').find('input,select,textarea').removeClass('disabled').prop('disabled',false);
+ $('#vboxSettingsDisplayMemory').slider('enable');
+
+ if(!$('#vboxSettingsDialog').data('vboxHostDetails').acceleration3DAvailable) {
+ $(document.forms['frmVboxSettings'].vboxSettingsDisplay3d).addClass('disabled').prop('disabled', true)
+ .parent().addClass('disabled');
+ } else {
+ $(document.forms['frmVboxSettings'].vboxSettingsDisplay3d).removeClass('disabled').prop('disabled', false)
+ .parent().removeClass('disabled');
+ }
+ }
+
+
+ /*
+ * No VRDE?
+ *
+ */
+ if(!($('#vboxSettingsDialog').data('vboxMachineData').VRDEServer && $('#vboxSettingsDialog').data('vboxMachineData').VRDEServer.VRDEExtPack)) {
+
+ $('#vboxSettingsTabDisplayVideo').parent().tabs('disable',1);
+
+
+ } else {
+
+ $('#vboxSettingsTabDisplayVideo').parent().tabs('enable',1);
+
+ // Show / hide VNC / RDP sections
+ if($('#vboxSettingsDialog').data('vboxMachineData').VRDEServer.VRDEExtPack.indexOf("VNC") > -1) {
+ $('#vboxSettingsTabDisplayRemote').find('tr.vboxSettingsDisplayRDP').css({'display':'none'});
+ $('#vboxSettingsTabDisplayRemote').find('tr.vboxSettingsDisplayVNC').css({'display':''});
+ } else {
+ $('#vboxSettingsTabDisplayRemote').find('tr.vboxSettingsDisplayRDP').css({'display':''});
+ $('#vboxSettingsTabDisplayRemote').find('tr.vboxSettingsDisplayVNC').css({'display':'none'});
+ }
+ document.forms['frmVboxSettings'].vboxSettingsDisplayVRDEPort.value = $('#vboxSettingsDialog').data('vboxMachineData').VRDEServer.ports;
+ document.forms['frmVboxSettings'].vboxSettingsDisplayVRDEAuth.value = $('#vboxSettingsDialog').data('vboxMachineData').VRDEServer.authType;
+ document.forms['frmVboxSettings'].vboxSettingsDisplayVRDEAuthTimeout.value = $('#vboxSettingsDialog').data('vboxMachineData').VRDEServer.authTimeout;
+ document.forms['frmVboxSettings'].vboxSettingsDisplayVRDEAddr.value = $('#vboxSettingsDialog').data('vboxMachineData').VRDEServer.netAddress;
+ document.forms['frmVboxSettings'].vboxSettingsDisplayVNCPassword.value = $('#vboxSettingsDialog').data('vboxMachineData').VRDEServer.VNCPassword;
+
+ $(document.forms['frmVboxSettings'].vboxSettingsDisplayVRDEEnabled).attr('checked',(!$('#vboxSettingsDialog').data('vboxMachineData').VRDEServer.enabled)).trigger('click');
+
+ if($('#vboxSettingsDialog').data('vboxMachineData').VRDEServer.allowMultiConnection) {
+ document.forms['frmVboxSettings'].vboxSettingsDisplayVRDEMulti.checked = true;
+ } else {
+ document.forms['frmVboxSettings'].vboxSettingsDisplayVRDEMulti.checked = false;
+ }
+
+ if(!$('#vboxPane').data('vboxConfig').enableAdvancedConfig)
+ $('#vboxSettingsDisplayVRDEAddrRow').css('display','none');
+ }
+
+
+});
+
+/* Change settings onSave() */
+$('#vboxSettingsDialog').on('save',function(){
+
+ $('#vboxSettingsDialog').data('vboxMachineData').VRAMSize = $(document.forms['frmVboxSettings'].vboxSettingsDisplayMemoryValue).val();
+
+ $('#vboxSettingsDialog').data('vboxMachineData').accelerate3DEnabled = document.forms['frmVboxSettings'].vboxSettingsDisplay3d.checked;
+ $('#vboxSettingsDialog').data('vboxMachineData').accelerate2DVideoEnabled = document.forms['frmVboxSettings'].vboxSettingsDisplay2d.checked;
+
+ if($('#vboxSettingsDialog').data('vboxMachineData').VRDEServer && $('#vboxSettingsDialog').data('vboxMachineData').VRDEServer.VRDEExtPack) {
+ $('#vboxSettingsDialog').data('vboxMachineData').VRDEServer.ports = document.forms['frmVboxSettings'].vboxSettingsDisplayVRDEPort.value;
+ $('#vboxSettingsDialog').data('vboxMachineData').VRDEServer.netAddress = document.forms['frmVboxSettings'].vboxSettingsDisplayVRDEAddr.value;
+ $('#vboxSettingsDialog').data('vboxMachineData').VRDEServer.authType = document.forms['frmVboxSettings'].vboxSettingsDisplayVRDEAuth.value;
+ $('#vboxSettingsDialog').data('vboxMachineData').VRDEServer.authTimeout = document.forms['frmVboxSettings'].vboxSettingsDisplayVRDEAuthTimeout.value;
+ $('#vboxSettingsDialog').data('vboxMachineData').VRDEServer.enabled = document.forms['frmVboxSettings'].vboxSettingsDisplayVRDEEnabled.checked;
+ $('#vboxSettingsDialog').data('vboxMachineData').VRDEServer.allowMultiConnection = document.forms['frmVboxSettings'].vboxSettingsDisplayVRDEMulti.checked;
+ $('#vboxSettingsDialog').data('vboxMachineData').VRDEServer.VNCPassword = document.forms['frmVboxSettings'].vboxSettingsDisplayVNCPassword.value;
+ }
+});
+
+</script>
+
+
diff --git a/panes/settingsGeneral.html b/panes/settingsGeneral.html
index 610d029..e383545 100644
--- a/panes/settingsGeneral.html
+++ b/panes/settingsGeneral.html
@@ -1,446 +1,446 @@
-<!--
-
- General Machine Settings
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: settingsGeneral.html 599 2015-07-27 10:40:37Z imoore76 $
-
- -->
-<ul>
- <li><a href="#vboxSettingsTabGeneralBasic"><span class='translate'>Basic</span></a></li>
- <li><a href="#vboxSettingsTabGeneralAdvanced"><span class='translate'>Advanced</span></a></li>
- <li><a href="#vboxSettingsTabGeneralDescription"><span class='translate'>Description</span></a></li>
- <li><a href="#vboxSettingsTabGeneralEncryption"><span class='translate'>Encryption</span></a></li>
- <li id='vboxSettingsTabGeneralInputTab'><a href="#vboxSettingsTabGeneralInput"><span class='translateinputtab'>Input</span></a></li>
-</ul>
-
-<!-- Basic Tab -->
-<div id='vboxSettingsTabGeneralBasic' title='Basic'>
-<table class='vboxVertical'>
- <tr>
- <th><span class='translateos'>Name:</span></th>
- <td colspan='2'><input type='text' class='vboxText' name='vboxSettingsGeneralName' /></td>
- </tr>
- <tr>
- <th><span class='translateos'>Type:</span></th>
- <td><select name='vboxSettingsGeneralOSFamily' id='vboxSettingsGeneralOSFamily' >
- <option value='Linux'>Linux</option>
- </select></td>
- <td rowspan='2'><img name='vboxOSTypeImg' height='32' width='32' /></td>
- </tr>
- <tr>
- <th><span class='translateos'>Version:</span></th>
- <td><select id='vboxSettingsGeneralOSType' name='vboxSettingsGeneralOSType'>
- <option value='Debian'>Debian</option>
- </select></td>
- </tr>
- <tr id='vboxSettingsRowVMIcon' class='vboxRunningEnabled' style='display:none'>
- <th><span class='translate'>Icon URL:</span></th>
- <td><input name='vboxSettingsGeneralIcon' type='text' class='vboxText' style='width:99%'/></td>
- <td style='text-align:center;'><img src='images/vbox/blank.gif' id='vboxSettingsGeneralIconImg' height='32' width='32' /></td>
- </tr>
- <tr class='vboxStartStopConfig vboxRunningEnabled'>
- <th><span class='translate'>Startup Mode:</span></th>
- <td colspan='2'>
- <select name='vboxStartStopConfigStartup'>
- <option value='auto'>Automatic</option>
- <option value='manual'>Manual</option>
- </select>
- </td>
- </tr>
- <!-- Autostart shutdown options -->
- <tr class='vboxAutostartConfig vboxRunningEnabled' id='vboxAutostartConfigShutdown'>
- <th><span class='translate'>Shutdown mode:</span></th>
- <td colspan='2'>
- <select name='vboxAutostartConfigShutdownOptions'>
- <option value='Disabled'>Disabled</option>
- <option value='SaveState'>Save State</option>
- <option value='PowerOff'>Power Off</option>
- <option value='AcpiShutdown'>ACPI Shutdown</option>
- </select>
- </td>
- </tr>
- <!-- Autostart options -->
- <tr class='vboxAutostartConfig vboxRunningEnabled' id='vboxAutostartConfigStartup'>
- <th><span class='translate'>Enable auto-start:</span></th>
- <td colspan='2'>
- <input type='checkbox' class='vboxCheckbox' name='autostartEnabled'/> <span class='translate'>after</span>
- <input type='text' class='vboxText' size='3' name='autostartDelay' style='width: 30px'/>
- <span class='translate'>second(s)</span>
- </td>
- </tr>
-</table>
-</div>
-
-<!-- Advanced Tab -->
-<div id='vboxSettingsTabGeneralAdvanced' title='Advanced'>
-<table class='vboxVertical'>
- <tr>
- <th><span class='translate'>Snapshot Folder:</span></th>
- <td class='vboxFileFolderInput'>
- <input type='text' class='vboxText' name='vboxSettingsGeneralSnapshotFolder' /><input type="button" class="vboxImgButton" style="background-image: url(images/vbox/select_file_16px.png)"
- onClick="vboxSnapshotBrowseFolder(this);" />
- </td>
- </tr>
-</table>
-</div>
-
-<!-- Description Tab -->
-<div id='vboxSettingsTabGeneralDescription' title='Description'>
- <textarea class='vboxRunningEnabled' rows='16' cols='20' name='vboxSettingsGeneralDescription'></textarea>
-</div>
-
-<!-- Encryption Tab -->
-<div id='vboxSettingsTabGeneralEncryption' title='Encryption'>
-<table class='vboxVertical'>
- <tr>
- <td colspan='2'>
- <label><input type='checkbox' class='vboxCheckbox vboxEnablerCheckbox' name='vboxSettingsGeneralEncryptionEnable' />
- <span class='translate'>Enable Encryption</span>
- </label>
- </td>
- </tr>
- <tr>
- <th><span class='translate'>Encryption Cipher:</span></th>
- <td>
- <select name='vboxSettingsTabGeneralEncryptionCipher'>
- <option value=''>Leave Unchanged</option>
- <option value='AES-XTS256-PLAIN64'>AES-XTS256-PLAIN64</option>
- <option value='AES-XTS128-PLAIN64'>AES-XTS128-PLAIN64</option>
- </select>
- </td>
- </tr>
- <tr>
- <th><span class='translate'>Enter New Password:</span></th>
- <td><input type='password' class='vboxText' name='vboxGeneralEncryptionPassword'/></td>
- </tr>
- <tr>
- <th><span class='translate'>Confirm New Password:</span></th>
- <td><input type='password' class='vboxText' name='vboxGeneralEncryptionPassword2'/></td>
- </tr>
-
-</table>
-</div>
-
-<!-- Input Tab -->
-<div id='vboxSettingsTabGeneralInput' title='Input'>
- <table class='vboxVertical'>
- <tr>
- <th><span class='translateinput'>Keyboard</span><span> :</span></th>
- <td><select name='vboxSettingsTabGeneralInputKeyboard'>
- <option value='PS2Keyboard'>PS/2 Keyboard</option>
- <option value='USBKeyboard'>USB Keyboard</option>
- </select>
- </td>
- </tr>
- <tr>
- <th><span class='translateinput'>Mouse</span><span> :</span></th>
- <td><select name='vboxSettingsTabGeneralInputMouse'>
- <option value='PS2Mouse'>PS/2 Mouse</option>
- <option value='USBMouse'>USB Mouse</option>
- <option value='USBTablet'>USB Tablet</option>
- </select>
- </td>
- </tr>
- </table>
-</div>
-<script type='text/javascript'>
-
-/* Translations */
-$('#vboxSettingsTabGeneralInput').find(".translateinput").html(function(i,h){return trans(h,'UIActionPool');});
-$('#vboxSettingsTabGeneralInputTab').find(".translateinputtab").html(function(i,h){return trans(h,'UISettingsDialogGlobal');});
-$('#vboxSettingsTabGeneralBasic').find(".translateos").html(function(i,h){return trans(h,'UINameAndSystemEditor');});
-if($('#vboxPane').data('vboxConfig').vboxAutostartConfig) {
-
- // Shutdown options select buttons
- $('#vboxAutostartConfigShutdown').find('option').each(function(i,opt){
- $(opt).text(i == 0 ? trans('Disabled','UIGDetails',null,'details (audio)') : trans($(opt).text(),'UIActionPool'));
- if($(opt).val() == $('#vboxSettingsDialog').data('vboxMachineData').autostopType)
- $(opt).prop('selected', true);
- });
-
-} else {
- $('#vboxSettingsTabGeneralBasic .vboxAutostartConfig').empty().remove();
-}
-
-$('#vboxSettingsTabGeneralEncryption').find('option').html(function(i,h){ return trans(h, 'UIMachineSettingsGeneral', 'cipher type')});
-$('#vboxSettingsTabGeneralInput').find('option').html(function(i,h){ return trans(h, 'VBoxGlobal')});
-
-/* Browse for snapshot folder */
-function vboxSnapshotBrowseFolder(btn) {
- vboxFileBrowser($(btn).siblings('input').first().val(),function(f){
- if(f) $(btn).siblings('input').first().val(f);
- },true,trans('Snapshot Folder:','UIMachineSettingsGeneral').replace(':',''));
-}
-
-/*
- * Hide start / stop config if not enabled
- */
-if(!$('#vboxPane').data('vboxConfig').startStopConfig) {
-
- $('#vboxSettingsTabGeneralBasic').find('tr.vboxStartStopConfig').hide();
-
-}
-
-/* Custom icons */
-if($('#vboxPane').data('vboxConfig').enableCustomIcons) {
-
- $('#vboxSettingsRowVMIcon').css('display','');
-
- $(document.forms['frmVboxSettings'].vboxSettingsGeneralIcon).blur(function(){
- $('#vboxSettingsGeneralIconImg').attr('src',(this.value ? this.value : 'images/vbox/blank.gif'));
- });
-}
-
-/*
- * Called when OS family type changes
- */
-function vboxSettingsUpdateOSList(osfam) {
- document.forms['frmVboxSettings'].vboxSettingsGeneralOSType.options.length = 0;
- $(document.forms['frmVboxSettings'].vboxSettingsGeneralOSType).children().remove();
- for(var i = 0; i < vboxSettingsOSTypes[osfam].osTypes.length; i++) {
- document.forms['frmVboxSettings'].vboxSettingsGeneralOSType.options[i] = new Option(vboxSettingsOSTypes[osfam].osTypes[i].description, vboxSettingsOSTypes[osfam].osTypes[i].id);
- }
- // Update image
- document.images["vboxOSTypeImg"].src = "images/vbox/" + vboxGuestOSTypeIcon(vboxSettingsOSTypes[osfam].osTypes[0].id);
-}
-
-var vboxSettingsOSTypes = new Array();
-var vboxSettingsOSTypesObj = {};
-
-// shorthand
-var vboxOSTypes = $('#vboxPane').data('vboxOSTypes');
-
-// Default OS Type set to my fav :) Eventually will move to config.php
-var vboxDefaultOSTypeId = 'Debian';
-
-var myOSType = $('#vboxSettingsDialog').data('vboxMachineData').OSTypeId;
-var dosfam = null; // holds defaultostype family id
-for(var i in vboxOSTypes) {
-
- // Only ostypes supported by this install
- if(!vboxOSTypes[i].supported && myOSType != vboxOSTypes[i].id) continue;
-
- // create array of os family types
- if(!vboxSettingsOSTypes[vboxOSTypes[i].familyId]) {
- vboxSettingsOSTypes[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 = vboxSettingsOSTypes[vboxOSTypes[i].familyId].osTypes.length;
- }
-
- vboxSettingsOSTypes[vboxOSTypes[i].familyId].osTypes[vboxSettingsOSTypes[vboxOSTypes[i].familyId].osTypes.length] = {'id':vboxOSTypes[i].id,'description':vboxOSTypes[i].description };
-
- vboxSettingsOSTypesObj[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['frmVboxSettings'].vboxSettingsGeneralOSFamily.options.length = 0;
-$(document.forms['frmVboxSettings'].vboxSettingsGeneralOSFamily).children().remove();
-for(var i in vboxSettingsOSTypes) {
- // default os type family? record in dosfam
- if(i == dosfam) dosfam = document.forms['frmVboxSettings'].vboxSettingsGeneralOSFamily.options.length;
- document.forms['frmVboxSettings'].vboxSettingsGeneralOSFamily.options[document.forms['frmVboxSettings'].vboxSettingsGeneralOSFamily.options.length] = new Option(vboxSettingsOSTypes[i].description, vboxSettingsOSTypes[i].id);
-}
-// OnChange, update os type list and icon
-document.getElementById('vboxSettingsGeneralOSFamily').setAttribute('onChange','vboxSettingsUpdateOSList(this.value)');
-document.getElementById('vboxSettingsGeneralOSType').setAttribute('onChange','document.images["vboxOSTypeImg"].src = "images/vbox/" + vboxGuestOSTypeIcon(this.value)');
-
-
-
-
-/* Update settings when data is loaded */
-$('#vboxSettingsDialog').on('dataLoaded', function(){
-
- /* Defaults from machine */
- document.forms['frmVboxSettings'].vboxSettingsGeneralName.value = $('#vboxSettingsDialog').data('vboxMachineData').name;
- document.forms['frmVboxSettings'].vboxSettingsGeneralOSFamily.value = vboxSettingsOSTypesObj[$('#vboxSettingsDialog').data('vboxMachineData').OSTypeId].familyId;
- $(document.forms['frmVboxSettings'].vboxSettingsGeneralOSFamily).change();
- document.forms['frmVboxSettings'].vboxSettingsGeneralOSType.value = $('#vboxSettingsDialog').data('vboxMachineData').OSTypeId;
- $(document.forms['frmVboxSettings'].vboxSettingsGeneralOSType).change();
- document.forms['frmVboxSettings'].vboxSettingsGeneralSnapshotFolder.value = $('#vboxSettingsDialog').data('vboxMachineData').snapshotFolder;
- document.forms['frmVboxSettings'].vboxSettingsGeneralDescription.innerHTML = $('#vboxSettingsDialog').data('vboxMachineData').description;
-
- /* Advanced config options */
- $(document.forms['frmVboxSettings'].vboxSettingsTabGeneralInputKeyboard).val($('#vboxSettingsDialog').data('vboxMachineData').keyboardHIDType);
- $(document.forms['frmVboxSettings'].vboxSettingsTabGeneralInputMouse).val($('#vboxSettingsDialog').data('vboxMachineData').pointingHIDType);
-
- /* OS Type */
-
- // shorthand
- var vboxOSTypes = $('#vboxPane').data('vboxOSTypes');
- for(var i = 0; i < vboxOSTypes.length; i++) {
- if(vboxOSTypes[i].id == $('#vboxSettingsDialog').data('vboxMachineData').OSTypeId) {
- // Set the family then os type
- $(document.forms['frmVboxSettings'].vboxSettingsGeneralOSFamily).children('[value="'+vboxOSTypes[i].familyId+'"]').prop('selected',true);
- $(document.forms['frmVboxSettings'].vboxSettingsGeneralOSFamily).trigger('change');
- $(document.forms['frmVboxSettings'].vboxSettingsGeneralOSType).children('[value="'+vboxOSTypes[i].id+'"]').prop('selected',true);
- $(document.forms['frmVboxSettings'].vboxSettingsGeneralOSType).trigger('change');
- break;
- }
- }
-
- /* Custom icons */
- if($('#vboxPane').data('vboxConfig').enableCustomIcons) {
-
- if($('#vboxSettingsDialog').data('vboxMachineData').customIcon) {
- $(document.forms['frmVboxSettings'].vboxSettingsGeneralIcon).val($('#vboxSettingsDialog').data('vboxMachineData').customIcon);
- $('#vboxSettingsGeneralIconImg').attr('src',$('#vboxSettingsDialog').data('vboxMachineData').customIcon);
- } else {
- $(document.forms['frmVboxSettings'].vboxSettingsGeneralIcon).val('');
- $('#vboxSettingsGeneralIconImg').attr('src','images/vbox/blank.gif');
- }
-
- }
-
- /* Autostart options */
- if($('#vboxPane').data('vboxConfig').vboxAutostartConfig) {
- document.forms['frmVboxSettings'].autostartEnabled.checked = ($('#vboxSettingsDialog').data('vboxMachineData').autostartEnabled);
- document.forms['frmVboxSettings'].autostartDelay.value = $('#vboxSettingsDialog').data('vboxMachineData').autostartDelay;
- }
-
- /* Start / stop config */
- if($('#vboxPane').data('vboxConfig').startStopConfig) {
- document.forms['frmVboxSettings'].vboxStartStopConfigStartup.selectedIndex = ($('#vboxSettingsDialog').data('vboxMachineData').startupMode == 'auto' ? 0 : 1);
- }
-
- /* Settings that are disabled / enabled depending on if VM is mutable */
- var p = $('#vboxSettingsTabGeneralBasic').parent().children('div');
- if(!$('#vboxSettingsDialog').data('vboxFullEdit')) {
- $(p).find('tr:not(.vboxRunningEnabled)').find('span').addClass('disabled');
- $(p).find('tr:not(.vboxRunningEnabled)').find('input,select,textarea').prop('disabled',true);
- $('#vboxSettingsTabGeneralAdvanced').find('input.vboxImgButton').css('background-image','url(images/vbox/select_file_disabled_16px.png)');
- $(document.images["vboxOSTypeImg"]).addClass('vboxDisabled');
- } else {
- $(p).find('tr:not(.vboxRunningEnabled)').find('span').removeClass('disabled');
- $(p).find('tr:not(.vboxRunningEnabled)').find('input,select,textarea').prop('disabled',false);
- $('#vboxSettingsTabGeneralAdvanced').find('input.vboxImgButton').css('background-image','url(images/vbox/select_file_16px.png)');
- $(document.images["vboxOSTypeImg"]).removeClass('vboxDisabled');
- }
-
- /*
- * This is a poor way to determine extpack installation status, but the web service can't access IExtPackManager :(
- */
- if(!($('#vboxSettingsDialog').data('vboxMachineData').VRDEServer && $('#vboxSettingsDialog').data('vboxMachineData').VRDEServer.VRDEExtPack)) {
- $('#vboxSettingsTabGeneralEncryption').parent().tabs('disable', 3);
- } else {
- $('#vboxSettingsTabGeneralEncryption').parent().tabs('enable', 3);
-
- // Encrypted media
- var encIds = vboxMedia.getEncryptedMediaIds(
- vboxStorage.getAttachedBaseMedia($('#vboxSettingsDialog').data('vboxMachineData'))
- );
-
- var lastCipher = null;
- var uniqueCiphers = true;
- for(var i = 0; i < encIds.length; i++) {
- if(lastCipher && (lastCipher != encIds[i].cipher)) {
- uniqueCiphers = false;
- break;
- }
- lastCipher = encIds[i].cipher;
- }
- $(document.forms['frmVboxSettings'].vboxSettingsGeneralEncryptionEnable).prop('checked', (encIds.length))
- .triggerHandler('click');
-
- if(uniqueCiphers) {
- $(document.forms['frmVboxSettings'].vboxSettingsTabGeneralEncryptionCipher).val(lastCipher);
- }
-
- $('#vboxSettingsDialog').data('vboxEncSettings', {
- enabled: $(document.forms['frmVboxSettings'].vboxSettingsGeneralEncryptionEnable).prop('checked'),
- uniqueCiphers: $(document.forms['frmVboxSettings'].vboxSettingsTabGeneralEncryptionCipher).val()
- });
- }
-
-
-/* Change general settings onSave() */
-}).on('save',function(){
-
- // Start / stop config
- if($('#vboxPane').data('vboxConfig').startStopConfig) {
- $('#vboxSettingsDialog').data('vboxMachineData').startupMode = document.forms['frmVboxSettings'].vboxStartStopConfigStartup.value;
- }
-
- // VirtualBox style start / stop config
- if($('#vboxPane').data('vboxConfig').vboxAutostartConfig) {
-
- $('#vboxSettingsDialog').data('vboxMachineData').autostopType = document.forms['frmVboxSettings'].vboxAutostartConfigShutdownOptions.value;
- $('#vboxSettingsDialog').data('vboxMachineData').autostartEnabled = document.forms['frmVboxSettings'].autostartEnabled.checked;
- if(isNaN(document.forms['frmVboxSettings'].autostartDelay.value))
- document.forms['frmVboxSettings'].autostartDelay.value = 0;
- $('#vboxSettingsDialog').data('vboxMachineData').autostartDelay = parseInt(document.forms['frmVboxSettings'].autostartDelay.value);
-
-
- }
-
- if(jQuery.trim(document.forms['frmVboxSettings'].vboxSettingsGeneralName.value))
- $('#vboxSettingsDialog').data('vboxMachineData').name = jQuery.trim(document.forms['frmVboxSettings'].vboxSettingsGeneralName.value);
-
- $('#vboxSettingsDialog').data('vboxMachineData').OSTypeId = document.forms['frmVboxSettings'].vboxSettingsGeneralOSType.value;
- $('#vboxSettingsDialog').data('vboxMachineData').snapshotFolder = document.forms['frmVboxSettings'].vboxSettingsGeneralSnapshotFolder.value;
- $('#vboxSettingsDialog').data('vboxMachineData').description = $(document.forms['frmVboxSettings'].vboxSettingsGeneralDescription).val();
-
- $('#vboxSettingsDialog').data('vboxMachineData').keyboardHIDType = $(document.forms['frmVboxSettings'].vboxSettingsTabGeneralInputKeyboard).val();
- $('#vboxSettingsDialog').data('vboxMachineData').pointingHIDType = $(document.forms['frmVboxSettings'].vboxSettingsTabGeneralInputMouse).val();
-
- if($('#vboxPane').data('vboxConfig').enableCustomIcons)
- $('#vboxSettingsDialog').data('vboxMachineData').customIcon = $(document.forms['frmVboxSettings'].vboxSettingsGeneralIcon).val();
-
- var encSettings = $('#vboxSettingsDialog').data('vboxEncSettings');
- if(encSettings) {
- var encSettingsChanged = (encSettings.enabled != $(document.forms['frmVboxSettings'].vboxSettingsGeneralEncryptionEnable).prop('checked')) ||
- (encSettings.uniqueCiphers != $(document.forms['frmVboxSettings'].vboxSettingsTabGeneralEncryptionCipher).val()) ||
- $(document.forms['frmVboxSettings'].vboxGeneralEncryptionPassword).val().length > 0;
-
- if(!encSettings.enabled && !$(document.forms['frmVboxSettings'].vboxSettingsGeneralEncryptionEnable).prop('checked'))
- encSettingsChanged = false;
-
- $('#vboxSettingsDialog').data('vboxEncSettingsChanged', encSettingsChanged);
- $('#vboxSettingsDialog').data('vboxEncEnabled', $(document.forms['frmVboxSettings'].vboxSettingsGeneralEncryptionEnable).prop('checked'));
- $('#vboxSettingsDialog').data('vboxEncCipher', $(document.forms['frmVboxSettings'].vboxSettingsTabGeneralEncryptionCipher).val());
- $('#vboxSettingsDialog').data('vboxEncPw', $(document.forms['frmVboxSettings'].vboxGeneralEncryptionPassword).val());
- } else {
- $('#vboxSettingsDialog').data('vboxEncSettingsChanged', false);
- }
-
-});
-
-function vboxSettingsGeneralValidate() {
-
- var encSettings = $('#vboxSettingsDialog').data('vboxEncSettings');
-
- // Going from disabled to enabled
- if(!encSettings.enabled && $(document.forms['frmVboxSettings'].vboxSettingsGeneralEncryptionEnable).prop('checked')) {
-
- if(!$(document.forms['frmVboxSettings'].vboxSettingsTabGeneralEncryptionCipher).val()) {
- vboxAlert(trans("Encryption cipher type not specified.", 'UIMachineSettingsGeneral'));
- return false;
- } else if(!$(document.forms['frmVboxSettings'].vboxGeneralEncryptionPassword).val()) {
- vboxAlert(trans("Encryption password empty.", 'UIMachineSettingsGeneral'));
- return false;
- } else if($(document.forms['frmVboxSettings'].vboxGeneralEncryptionPassword).val() != $(document.forms['frmVboxSettings'].vboxGeneralEncryptionPassword2).val()) {
- vboxAlert(trans("Encryption passwords do not match.", 'UIMachineSettingsGeneral'));
- return false;
- }
-
- // If enabled and poasswords don't match
- } else if($(document.forms['frmVboxSettings'].vboxSettingsGeneralEncryptionEnable).prop('checked')) {
- if($(document.forms['frmVboxSettings'].vboxGeneralEncryptionPassword).val() != $(document.forms['frmVboxSettings'].vboxGeneralEncryptionPassword2).val()) {
- vboxAlert(trans("Encryption passwords do not match.", 'UIMachineSettingsGeneral'));
- return false;
- }
- }
- return true;
-}
-
-</script>
-
+<!--
+
+ General Machine Settings
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: settingsGeneral.html 599 2015-07-27 10:40:37Z imoore76 $
+
+ -->
+<ul>
+ <li><a href="#vboxSettingsTabGeneralBasic"><span class='translate'>Basic</span></a></li>
+ <li><a href="#vboxSettingsTabGeneralAdvanced"><span class='translate'>Advanced</span></a></li>
+ <li><a href="#vboxSettingsTabGeneralDescription"><span class='translate'>Description</span></a></li>
+ <li><a href="#vboxSettingsTabGeneralEncryption"><span class='translate'>Encryption</span></a></li>
+ <li id='vboxSettingsTabGeneralInputTab'><a href="#vboxSettingsTabGeneralInput"><span class='translateinputtab'>Input</span></a></li>
+</ul>
+
+<!-- Basic Tab -->
+<div id='vboxSettingsTabGeneralBasic' title='Basic'>
+<table class='vboxVertical'>
+ <tr>
+ <th><span class='translateos'>Name:</span></th>
+ <td colspan='2'><input type='text' class='vboxText' name='vboxSettingsGeneralName' /></td>
+ </tr>
+ <tr>
+ <th><span class='translateos'>Type:</span></th>
+ <td><select name='vboxSettingsGeneralOSFamily' id='vboxSettingsGeneralOSFamily' >
+ <option value='Linux'>Linux</option>
+ </select></td>
+ <td rowspan='2'><img name='vboxOSTypeImg' height='32' width='32' /></td>
+ </tr>
+ <tr>
+ <th><span class='translateos'>Version:</span></th>
+ <td><select id='vboxSettingsGeneralOSType' name='vboxSettingsGeneralOSType'>
+ <option value='Debian'>Debian</option>
+ </select></td>
+ </tr>
+ <tr id='vboxSettingsRowVMIcon' class='vboxRunningEnabled' style='display:none'>
+ <th><span class='translate'>Icon URL:</span></th>
+ <td><input name='vboxSettingsGeneralIcon' type='text' class='vboxText' style='width:99%'/></td>
+ <td style='text-align:center;'><img src='images/vbox/blank.gif' id='vboxSettingsGeneralIconImg' height='32' width='32' /></td>
+ </tr>
+ <tr class='vboxStartStopConfig vboxRunningEnabled'>
+ <th><span class='translate'>Startup Mode:</span></th>
+ <td colspan='2'>
+ <select name='vboxStartStopConfigStartup'>
+ <option value='auto'>Automatic</option>
+ <option value='manual'>Manual</option>
+ </select>
+ </td>
+ </tr>
+ <!-- Autostart shutdown options -->
+ <tr class='vboxAutostartConfig vboxRunningEnabled' id='vboxAutostartConfigShutdown'>
+ <th><span class='translate'>Shutdown mode:</span></th>
+ <td colspan='2'>
+ <select name='vboxAutostartConfigShutdownOptions'>
+ <option value='Disabled'>Disabled</option>
+ <option value='SaveState'>Save State</option>
+ <option value='PowerOff'>Power Off</option>
+ <option value='AcpiShutdown'>ACPI Shutdown</option>
+ </select>
+ </td>
+ </tr>
+ <!-- Autostart options -->
+ <tr class='vboxAutostartConfig vboxRunningEnabled' id='vboxAutostartConfigStartup'>
+ <th><span class='translate'>Enable auto-start:</span></th>
+ <td colspan='2'>
+ <input type='checkbox' class='vboxCheckbox' name='autostartEnabled'/> <span class='translate'>after</span>
+ <input type='text' class='vboxText' size='3' name='autostartDelay' style='width: 30px'/>
+ <span class='translate'>second(s)</span>
+ </td>
+ </tr>
+</table>
+</div>
+
+<!-- Advanced Tab -->
+<div id='vboxSettingsTabGeneralAdvanced' title='Advanced'>
+<table class='vboxVertical'>
+ <tr>
+ <th><span class='translate'>Snapshot Folder:</span></th>
+ <td class='vboxFileFolderInput'>
+ <input type='text' class='vboxText' name='vboxSettingsGeneralSnapshotFolder' /><input type="button" class="vboxImgButton" style="background-image: url(images/vbox/select_file_16px.png)"
+ onClick="vboxSnapshotBrowseFolder(this);" />
+ </td>
+ </tr>
+</table>
+</div>
+
+<!-- Description Tab -->
+<div id='vboxSettingsTabGeneralDescription' title='Description'>
+ <textarea class='vboxRunningEnabled' rows='16' cols='20' name='vboxSettingsGeneralDescription'></textarea>
+</div>
+
+<!-- Encryption Tab -->
+<div id='vboxSettingsTabGeneralEncryption' title='Encryption'>
+<table class='vboxVertical'>
+ <tr>
+ <td colspan='2'>
+ <label><input type='checkbox' class='vboxCheckbox vboxEnablerCheckbox' name='vboxSettingsGeneralEncryptionEnable' />
+ <span class='translate'>Enable Encryption</span>
+ </label>
+ </td>
+ </tr>
+ <tr>
+ <th><span class='translate'>Encryption Cipher:</span></th>
+ <td>
+ <select name='vboxSettingsTabGeneralEncryptionCipher'>
+ <option value=''>Leave Unchanged</option>
+ <option value='AES-XTS256-PLAIN64'>AES-XTS256-PLAIN64</option>
+ <option value='AES-XTS128-PLAIN64'>AES-XTS128-PLAIN64</option>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <th><span class='translate'>Enter New Password:</span></th>
+ <td><input type='password' class='vboxText' name='vboxGeneralEncryptionPassword'/></td>
+ </tr>
+ <tr>
+ <th><span class='translate'>Confirm New Password:</span></th>
+ <td><input type='password' class='vboxText' name='vboxGeneralEncryptionPassword2'/></td>
+ </tr>
+
+</table>
+</div>
+
+<!-- Input Tab -->
+<div id='vboxSettingsTabGeneralInput' title='Input'>
+ <table class='vboxVertical'>
+ <tr>
+ <th><span class='translateinput'>Keyboard</span><span> :</span></th>
+ <td><select name='vboxSettingsTabGeneralInputKeyboard'>
+ <option value='PS2Keyboard'>PS/2 Keyboard</option>
+ <option value='USBKeyboard'>USB Keyboard</option>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <th><span class='translateinput'>Mouse</span><span> :</span></th>
+ <td><select name='vboxSettingsTabGeneralInputMouse'>
+ <option value='PS2Mouse'>PS/2 Mouse</option>
+ <option value='USBMouse'>USB Mouse</option>
+ <option value='USBTablet'>USB Tablet</option>
+ </select>
+ </td>
+ </tr>
+ </table>
+</div>
+<script type='text/javascript'>
+
+/* Translations */
+$('#vboxSettingsTabGeneralInput').find(".translateinput").html(function(i,h){return trans(h,'UIActionPool');});
+$('#vboxSettingsTabGeneralInputTab').find(".translateinputtab").html(function(i,h){return trans(h,'UISettingsDialogGlobal');});
+$('#vboxSettingsTabGeneralBasic').find(".translateos").html(function(i,h){return trans(h,'UINameAndSystemEditor');});
+if($('#vboxPane').data('vboxConfig').vboxAutostartConfig) {
+
+ // Shutdown options select buttons
+ $('#vboxAutostartConfigShutdown').find('option').each(function(i,opt){
+ $(opt).text(i == 0 ? trans('Disabled','UIGDetails',null,'details (audio)') : trans($(opt).text(),'UIActionPool'));
+ if($(opt).val() == $('#vboxSettingsDialog').data('vboxMachineData').autostopType)
+ $(opt).prop('selected', true);
+ });
+
+} else {
+ $('#vboxSettingsTabGeneralBasic .vboxAutostartConfig').empty().remove();
+}
+
+$('#vboxSettingsTabGeneralEncryption').find('option').html(function(i,h){ return trans(h, 'UIMachineSettingsGeneral', 'cipher type')});
+$('#vboxSettingsTabGeneralInput').find('option').html(function(i,h){ return trans(h, 'VBoxGlobal')});
+
+/* Browse for snapshot folder */
+function vboxSnapshotBrowseFolder(btn) {
+ vboxFileBrowser($(btn).siblings('input').first().val(),function(f){
+ if(f) $(btn).siblings('input').first().val(f);
+ },true,trans('Snapshot Folder:','UIMachineSettingsGeneral').replace(':',''));
+}
+
+/*
+ * Hide start / stop config if not enabled
+ */
+if(!$('#vboxPane').data('vboxConfig').startStopConfig) {
+
+ $('#vboxSettingsTabGeneralBasic').find('tr.vboxStartStopConfig').hide();
+
+}
+
+/* Custom icons */
+if($('#vboxPane').data('vboxConfig').enableCustomIcons) {
+
+ $('#vboxSettingsRowVMIcon').css('display','');
+
+ $(document.forms['frmVboxSettings'].vboxSettingsGeneralIcon).blur(function(){
+ $('#vboxSettingsGeneralIconImg').attr('src',(this.value ? this.value : 'images/vbox/blank.gif'));
+ });
+}
+
+/*
+ * Called when OS family type changes
+ */
+function vboxSettingsUpdateOSList(osfam) {
+ document.forms['frmVboxSettings'].vboxSettingsGeneralOSType.options.length = 0;
+ $(document.forms['frmVboxSettings'].vboxSettingsGeneralOSType).children().remove();
+ for(var i = 0; i < vboxSettingsOSTypes[osfam].osTypes.length; i++) {
+ document.forms['frmVboxSettings'].vboxSettingsGeneralOSType.options[i] = new Option(vboxSettingsOSTypes[osfam].osTypes[i].description, vboxSettingsOSTypes[osfam].osTypes[i].id);
+ }
+ // Update image
+ document.images["vboxOSTypeImg"].src = "images/vbox/" + vboxGuestOSTypeIcon(vboxSettingsOSTypes[osfam].osTypes[0].id);
+}
+
+var vboxSettingsOSTypes = new Array();
+var vboxSettingsOSTypesObj = {};
+
+// shorthand
+var vboxOSTypes = $('#vboxPane').data('vboxOSTypes');
+
+// Default OS Type set to my fav :) Eventually will move to config.php
+var vboxDefaultOSTypeId = 'Debian';
+
+var myOSType = $('#vboxSettingsDialog').data('vboxMachineData').OSTypeId;
+var dosfam = null; // holds defaultostype family id
+for(var i in vboxOSTypes) {
+
+ // Only ostypes supported by this install
+ if(!vboxOSTypes[i].supported && myOSType != vboxOSTypes[i].id) continue;
+
+ // create array of os family types
+ if(!vboxSettingsOSTypes[vboxOSTypes[i].familyId]) {
+ vboxSettingsOSTypes[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 = vboxSettingsOSTypes[vboxOSTypes[i].familyId].osTypes.length;
+ }
+
+ vboxSettingsOSTypes[vboxOSTypes[i].familyId].osTypes[vboxSettingsOSTypes[vboxOSTypes[i].familyId].osTypes.length] = {'id':vboxOSTypes[i].id,'description':vboxOSTypes[i].description };
+
+ vboxSettingsOSTypesObj[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['frmVboxSettings'].vboxSettingsGeneralOSFamily.options.length = 0;
+$(document.forms['frmVboxSettings'].vboxSettingsGeneralOSFamily).children().remove();
+for(var i in vboxSettingsOSTypes) {
+ // default os type family? record in dosfam
+ if(i == dosfam) dosfam = document.forms['frmVboxSettings'].vboxSettingsGeneralOSFamily.options.length;
+ document.forms['frmVboxSettings'].vboxSettingsGeneralOSFamily.options[document.forms['frmVboxSettings'].vboxSettingsGeneralOSFamily.options.length] = new Option(vboxSettingsOSTypes[i].description, vboxSettingsOSTypes[i].id);
+}
+// OnChange, update os type list and icon
+document.getElementById('vboxSettingsGeneralOSFamily').setAttribute('onChange','vboxSettingsUpdateOSList(this.value)');
+document.getElementById('vboxSettingsGeneralOSType').setAttribute('onChange','document.images["vboxOSTypeImg"].src = "images/vbox/" + vboxGuestOSTypeIcon(this.value)');
+
+
+
+
+/* Update settings when data is loaded */
+$('#vboxSettingsDialog').on('dataLoaded', function(){
+
+ /* Defaults from machine */
+ document.forms['frmVboxSettings'].vboxSettingsGeneralName.value = $('#vboxSettingsDialog').data('vboxMachineData').name;
+ document.forms['frmVboxSettings'].vboxSettingsGeneralOSFamily.value = vboxSettingsOSTypesObj[$('#vboxSettingsDialog').data('vboxMachineData').OSTypeId].familyId;
+ $(document.forms['frmVboxSettings'].vboxSettingsGeneralOSFamily).change();
+ document.forms['frmVboxSettings'].vboxSettingsGeneralOSType.value = $('#vboxSettingsDialog').data('vboxMachineData').OSTypeId;
+ $(document.forms['frmVboxSettings'].vboxSettingsGeneralOSType).change();
+ document.forms['frmVboxSettings'].vboxSettingsGeneralSnapshotFolder.value = $('#vboxSettingsDialog').data('vboxMachineData').snapshotFolder;
+ document.forms['frmVboxSettings'].vboxSettingsGeneralDescription.innerHTML = $('#vboxSettingsDialog').data('vboxMachineData').description;
+
+ /* Advanced config options */
+ $(document.forms['frmVboxSettings'].vboxSettingsTabGeneralInputKeyboard).val($('#vboxSettingsDialog').data('vboxMachineData').keyboardHIDType);
+ $(document.forms['frmVboxSettings'].vboxSettingsTabGeneralInputMouse).val($('#vboxSettingsDialog').data('vboxMachineData').pointingHIDType);
+
+ /* OS Type */
+
+ // shorthand
+ var vboxOSTypes = $('#vboxPane').data('vboxOSTypes');
+ for(var i = 0; i < vboxOSTypes.length; i++) {
+ if(vboxOSTypes[i].id == $('#vboxSettingsDialog').data('vboxMachineData').OSTypeId) {
+ // Set the family then os type
+ $(document.forms['frmVboxSettings'].vboxSettingsGeneralOSFamily).children('[value="'+vboxOSTypes[i].familyId+'"]').prop('selected',true);
+ $(document.forms['frmVboxSettings'].vboxSettingsGeneralOSFamily).trigger('change');
+ $(document.forms['frmVboxSettings'].vboxSettingsGeneralOSType).children('[value="'+vboxOSTypes[i].id+'"]').prop('selected',true);
+ $(document.forms['frmVboxSettings'].vboxSettingsGeneralOSType).trigger('change');
+ break;
+ }
+ }
+
+ /* Custom icons */
+ if($('#vboxPane').data('vboxConfig').enableCustomIcons) {
+
+ if($('#vboxSettingsDialog').data('vboxMachineData').customIcon) {
+ $(document.forms['frmVboxSettings'].vboxSettingsGeneralIcon).val($('#vboxSettingsDialog').data('vboxMachineData').customIcon);
+ $('#vboxSettingsGeneralIconImg').attr('src',$('#vboxSettingsDialog').data('vboxMachineData').customIcon);
+ } else {
+ $(document.forms['frmVboxSettings'].vboxSettingsGeneralIcon).val('');
+ $('#vboxSettingsGeneralIconImg').attr('src','images/vbox/blank.gif');
+ }
+
+ }
+
+ /* Autostart options */
+ if($('#vboxPane').data('vboxConfig').vboxAutostartConfig) {
+ document.forms['frmVboxSettings'].autostartEnabled.checked = ($('#vboxSettingsDialog').data('vboxMachineData').autostartEnabled);
+ document.forms['frmVboxSettings'].autostartDelay.value = $('#vboxSettingsDialog').data('vboxMachineData').autostartDelay;
+ }
+
+ /* Start / stop config */
+ if($('#vboxPane').data('vboxConfig').startStopConfig) {
+ document.forms['frmVboxSettings'].vboxStartStopConfigStartup.selectedIndex = ($('#vboxSettingsDialog').data('vboxMachineData').startupMode == 'auto' ? 0 : 1);
+ }
+
+ /* Settings that are disabled / enabled depending on if VM is mutable */
+ var p = $('#vboxSettingsTabGeneralBasic').parent().children('div');
+ if(!$('#vboxSettingsDialog').data('vboxFullEdit')) {
+ $(p).find('tr:not(.vboxRunningEnabled)').find('span').addClass('disabled');
+ $(p).find('tr:not(.vboxRunningEnabled)').find('input,select,textarea').prop('disabled',true);
+ $('#vboxSettingsTabGeneralAdvanced').find('input.vboxImgButton').css('background-image','url(images/vbox/select_file_disabled_16px.png)');
+ $(document.images["vboxOSTypeImg"]).addClass('vboxDisabled');
+ } else {
+ $(p).find('tr:not(.vboxRunningEnabled)').find('span').removeClass('disabled');
+ $(p).find('tr:not(.vboxRunningEnabled)').find('input,select,textarea').prop('disabled',false);
+ $('#vboxSettingsTabGeneralAdvanced').find('input.vboxImgButton').css('background-image','url(images/vbox/select_file_16px.png)');
+ $(document.images["vboxOSTypeImg"]).removeClass('vboxDisabled');
+ }
+
+ /*
+ * This is a poor way to determine extpack installation status, but the web service can't access IExtPackManager :(
+ */
+ if(!($('#vboxSettingsDialog').data('vboxMachineData').VRDEServer && $('#vboxSettingsDialog').data('vboxMachineData').VRDEServer.VRDEExtPack)) {
+ $('#vboxSettingsTabGeneralEncryption').parent().tabs('disable', 3);
+ } else {
+ $('#vboxSettingsTabGeneralEncryption').parent().tabs('enable', 3);
+
+ // Encrypted media
+ var encIds = vboxMedia.getEncryptedMediaIds(
+ vboxStorage.getAttachedBaseMedia($('#vboxSettingsDialog').data('vboxMachineData'))
+ );
+
+ var lastCipher = null;
+ var uniqueCiphers = true;
+ for(var i = 0; i < encIds.length; i++) {
+ if(lastCipher && (lastCipher != encIds[i].cipher)) {
+ uniqueCiphers = false;
+ break;
+ }
+ lastCipher = encIds[i].cipher;
+ }
+ $(document.forms['frmVboxSettings'].vboxSettingsGeneralEncryptionEnable).prop('checked', (encIds.length))
+ .triggerHandler('click');
+
+ if(uniqueCiphers) {
+ $(document.forms['frmVboxSettings'].vboxSettingsTabGeneralEncryptionCipher).val(lastCipher);
+ }
+
+ $('#vboxSettingsDialog').data('vboxEncSettings', {
+ enabled: $(document.forms['frmVboxSettings'].vboxSettingsGeneralEncryptionEnable).prop('checked'),
+ uniqueCiphers: $(document.forms['frmVboxSettings'].vboxSettingsTabGeneralEncryptionCipher).val()
+ });
+ }
+
+
+/* Change general settings onSave() */
+}).on('save',function(){
+
+ // Start / stop config
+ if($('#vboxPane').data('vboxConfig').startStopConfig) {
+ $('#vboxSettingsDialog').data('vboxMachineData').startupMode = document.forms['frmVboxSettings'].vboxStartStopConfigStartup.value;
+ }
+
+ // VirtualBox style start / stop config
+ if($('#vboxPane').data('vboxConfig').vboxAutostartConfig) {
+
+ $('#vboxSettingsDialog').data('vboxMachineData').autostopType = document.forms['frmVboxSettings'].vboxAutostartConfigShutdownOptions.value;
+ $('#vboxSettingsDialog').data('vboxMachineData').autostartEnabled = document.forms['frmVboxSettings'].autostartEnabled.checked;
+ if(isNaN(document.forms['frmVboxSettings'].autostartDelay.value))
+ document.forms['frmVboxSettings'].autostartDelay.value = 0;
+ $('#vboxSettingsDialog').data('vboxMachineData').autostartDelay = parseInt(document.forms['frmVboxSettings'].autostartDelay.value);
+
+
+ }
+
+ if(jQuery.trim(document.forms['frmVboxSettings'].vboxSettingsGeneralName.value))
+ $('#vboxSettingsDialog').data('vboxMachineData').name = jQuery.trim(document.forms['frmVboxSettings'].vboxSettingsGeneralName.value);
+
+ $('#vboxSettingsDialog').data('vboxMachineData').OSTypeId = document.forms['frmVboxSettings'].vboxSettingsGeneralOSType.value;
+ $('#vboxSettingsDialog').data('vboxMachineData').snapshotFolder = document.forms['frmVboxSettings'].vboxSettingsGeneralSnapshotFolder.value;
+ $('#vboxSettingsDialog').data('vboxMachineData').description = $(document.forms['frmVboxSettings'].vboxSettingsGeneralDescription).val();
+
+ $('#vboxSettingsDialog').data('vboxMachineData').keyboardHIDType = $(document.forms['frmVboxSettings'].vboxSettingsTabGeneralInputKeyboard).val();
+ $('#vboxSettingsDialog').data('vboxMachineData').pointingHIDType = $(document.forms['frmVboxSettings'].vboxSettingsTabGeneralInputMouse).val();
+
+ if($('#vboxPane').data('vboxConfig').enableCustomIcons)
+ $('#vboxSettingsDialog').data('vboxMachineData').customIcon = $(document.forms['frmVboxSettings'].vboxSettingsGeneralIcon).val();
+
+ var encSettings = $('#vboxSettingsDialog').data('vboxEncSettings');
+ if(encSettings) {
+ var encSettingsChanged = (encSettings.enabled != $(document.forms['frmVboxSettings'].vboxSettingsGeneralEncryptionEnable).prop('checked')) ||
+ (encSettings.uniqueCiphers != $(document.forms['frmVboxSettings'].vboxSettingsTabGeneralEncryptionCipher).val()) ||
+ $(document.forms['frmVboxSettings'].vboxGeneralEncryptionPassword).val().length > 0;
+
+ if(!encSettings.enabled && !$(document.forms['frmVboxSettings'].vboxSettingsGeneralEncryptionEnable).prop('checked'))
+ encSettingsChanged = false;
+
+ $('#vboxSettingsDialog').data('vboxEncSettingsChanged', encSettingsChanged);
+ $('#vboxSettingsDialog').data('vboxEncEnabled', $(document.forms['frmVboxSettings'].vboxSettingsGeneralEncryptionEnable).prop('checked'));
+ $('#vboxSettingsDialog').data('vboxEncCipher', $(document.forms['frmVboxSettings'].vboxSettingsTabGeneralEncryptionCipher).val());
+ $('#vboxSettingsDialog').data('vboxEncPw', $(document.forms['frmVboxSettings'].vboxGeneralEncryptionPassword).val());
+ } else {
+ $('#vboxSettingsDialog').data('vboxEncSettingsChanged', false);
+ }
+
+});
+
+function vboxSettingsGeneralValidate() {
+
+ var encSettings = $('#vboxSettingsDialog').data('vboxEncSettings');
+
+ // Going from disabled to enabled
+ if(!encSettings.enabled && $(document.forms['frmVboxSettings'].vboxSettingsGeneralEncryptionEnable).prop('checked')) {
+
+ if(!$(document.forms['frmVboxSettings'].vboxSettingsTabGeneralEncryptionCipher).val()) {
+ vboxAlert(trans("Encryption cipher type not specified.", 'UIMachineSettingsGeneral'));
+ return false;
+ } else if(!$(document.forms['frmVboxSettings'].vboxGeneralEncryptionPassword).val()) {
+ vboxAlert(trans("Encryption password empty.", 'UIMachineSettingsGeneral'));
+ return false;
+ } else if($(document.forms['frmVboxSettings'].vboxGeneralEncryptionPassword).val() != $(document.forms['frmVboxSettings'].vboxGeneralEncryptionPassword2).val()) {
+ vboxAlert(trans("Encryption passwords do not match.", 'UIMachineSettingsGeneral'));
+ return false;
+ }
+
+ // If enabled and poasswords don't match
+ } else if($(document.forms['frmVboxSettings'].vboxSettingsGeneralEncryptionEnable).prop('checked')) {
+ if($(document.forms['frmVboxSettings'].vboxGeneralEncryptionPassword).val() != $(document.forms['frmVboxSettings'].vboxGeneralEncryptionPassword2).val()) {
+ vboxAlert(trans("Encryption passwords do not match.", 'UIMachineSettingsGeneral'));
+ return false;
+ }
+ }
+ return true;
+}
+
+</script>
+
diff --git a/panes/settingsGlobalGeneral.html b/panes/settingsGlobalGeneral.html
index 7339e34..cc22e0b 100644
--- a/panes/settingsGlobalGeneral.html
+++ b/panes/settingsGlobalGeneral.html
@@ -1,98 +1,98 @@
-<!--
-
- General Global Settings / Preferences
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: settingsGlobalGeneral.html 595 2015-04-17 09:50:36Z imoore76 $
-
- -->
-<table style='width: 100%' class='vboxVertical'>
- <tr style='vertical-align: middle'>
- <th><span class='translate'>Default Machine Folder:</span></th>
- <td>
- <table class="vboxInvisible" style='width: 100%'>
- <tr style='vertical-align: top'>
- <td style="width: auto; white-space: nowrap;" class="vboxFileFolderInput">
- <input type='text' class='vboxText' name='vboxSettingsDefaultMachineFolder' />
- <input type="button" class="vboxImgButton" style="background-image: url(images/vbox/select_file_16px.png)"
- onClick="vboxSettingsBrowseMachineFolder(this)" />
- </td>
- </tr>
- </table>
- </td>
- </tr>
-
- <tr><td colspan='2'><hr style='width: 100%' class='vboxSeparatorLine'/></td></tr>
-
- <tr style='vertical-align: middle'>
- <th><span class='translate'>VRDP Authentication Library:</span></th>
- <td>
- <table class="vboxInvisible" style='width: 100%'>
- <tr style='vertical-align: top'>
- <td style="width: auto; white-space: nowrap;" class="vboxFileFolderInput">
- <input type='text' class='vboxText' name='vboxSettingsVRDEAuthLibrary' />
- <input type="button" class="vboxImgButton" style="background-image: url(images/vbox/select_file_16px.png)"
- onClick="vboxSettingsBrowseVRDPAuthLibrary(this)" />
- </td>
- </tr>
- </table>
- </td>
- </tr>
-
- <tr style='vertical-align: middle' id='vboxAutostartConfigPropsGeneral'>
- <th><span class='translate'>Auto-start DB Path:</span></th>
- <td>
- <input type='text' class='vboxText' name='vboxAutostartConfigDBPath' />
- </td>
- </tr>
-
-</table>
-<script type='text/javascript'>
-
-/* Set Defaults */
-
-document.frmVboxSettings.vboxSettingsDefaultMachineFolder.value = $('#vboxSettingsDialog').data('vboxSystemProperties').defaultMachineFolder;
-document.frmVboxSettings.vboxSettingsVRDEAuthLibrary.value = $('#vboxSettingsDialog').data('vboxSystemProperties').VRDEAuthLibrary;
-
-// Autostart config path
-if($('#vboxPane').data('vboxConfig').vboxAutostartConfig) {
-
- document.frmVboxSettings.vboxAutostartConfigDBPath.value = $('#vboxSettingsDialog').data('vboxSystemProperties').autostartDatabasePath;
-
-} else {
-
- $('#vboxAutostartConfigPropsGeneral').hide();
-}
-
-/* Browsers */
-function vboxSettingsBrowseMachineFolder(btn) {
- var def = $(btn).siblings('input').first();
- vboxFileBrowser($(def).val(),function(f){
- if(f) $(def).val(f);
- },true,trans('Default Machine Folder:','UIGlobalSettingsGeneral').replace(':',''));
-}
-
-function vboxSettingsBrowseVRDPAuthLibrary(btn) {
- var def = $(btn).siblings('input').first();
- vboxFileBrowser($(def).val(),function(f){
- if(f) $(def).val(f);
- },false,trans('VRDP Authentication Library:','UIGlobalSettingsGeneral').replace(':',''));
-}
-
-/*
- *
- * Update Data onSave()
- *
- */
-$('#vboxSettingsDialog').on('save',function(){
-
- $('#vboxSettingsDialog').data('vboxSystemProperties').defaultMachineFolder = document.frmVboxSettings.vboxSettingsDefaultMachineFolder.value;
- $('#vboxSettingsDialog').data('vboxSystemProperties').VRDEAuthLibrary = document.frmVboxSettings.vboxSettingsVRDEAuthLibrary.value;
-
- // Autostart config path
- if($('#vboxPane').data('vboxConfig').vboxAutostartConfig) {
- $('#vboxSettingsDialog').data('vboxSystemProperties').autostartDatabasePath = document.frmVboxSettings.vboxAutostartConfigDBPath.value;
- }
-
-});
+<!--
+
+ General Global Settings / Preferences
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: settingsGlobalGeneral.html 595 2015-04-17 09:50:36Z imoore76 $
+
+ -->
+<table style='width: 100%' class='vboxVertical'>
+ <tr style='vertical-align: middle'>
+ <th><span class='translate'>Default Machine Folder:</span></th>
+ <td>
+ <table class="vboxInvisible" style='width: 100%'>
+ <tr style='vertical-align: top'>
+ <td style="width: auto; white-space: nowrap;" class="vboxFileFolderInput">
+ <input type='text' class='vboxText' name='vboxSettingsDefaultMachineFolder' />
+ <input type="button" class="vboxImgButton" style="background-image: url(images/vbox/select_file_16px.png)"
+ onClick="vboxSettingsBrowseMachineFolder(this)" />
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+
+ <tr><td colspan='2'><hr style='width: 100%' class='vboxSeparatorLine'/></td></tr>
+
+ <tr style='vertical-align: middle'>
+ <th><span class='translate'>VRDP Authentication Library:</span></th>
+ <td>
+ <table class="vboxInvisible" style='width: 100%'>
+ <tr style='vertical-align: top'>
+ <td style="width: auto; white-space: nowrap;" class="vboxFileFolderInput">
+ <input type='text' class='vboxText' name='vboxSettingsVRDEAuthLibrary' />
+ <input type="button" class="vboxImgButton" style="background-image: url(images/vbox/select_file_16px.png)"
+ onClick="vboxSettingsBrowseVRDPAuthLibrary(this)" />
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+
+ <tr style='vertical-align: middle' id='vboxAutostartConfigPropsGeneral'>
+ <th><span class='translate'>Auto-start DB Path:</span></th>
+ <td>
+ <input type='text' class='vboxText' name='vboxAutostartConfigDBPath' />
+ </td>
+ </tr>
+
+</table>
+<script type='text/javascript'>
+
+/* Set Defaults */
+
+document.frmVboxSettings.vboxSettingsDefaultMachineFolder.value = $('#vboxSettingsDialog').data('vboxSystemProperties').defaultMachineFolder;
+document.frmVboxSettings.vboxSettingsVRDEAuthLibrary.value = $('#vboxSettingsDialog').data('vboxSystemProperties').VRDEAuthLibrary;
+
+// Autostart config path
+if($('#vboxPane').data('vboxConfig').vboxAutostartConfig) {
+
+ document.frmVboxSettings.vboxAutostartConfigDBPath.value = $('#vboxSettingsDialog').data('vboxSystemProperties').autostartDatabasePath;
+
+} else {
+
+ $('#vboxAutostartConfigPropsGeneral').hide();
+}
+
+/* Browsers */
+function vboxSettingsBrowseMachineFolder(btn) {
+ var def = $(btn).siblings('input').first();
+ vboxFileBrowser($(def).val(),function(f){
+ if(f) $(def).val(f);
+ },true,trans('Default Machine Folder:','UIGlobalSettingsGeneral').replace(':',''));
+}
+
+function vboxSettingsBrowseVRDPAuthLibrary(btn) {
+ var def = $(btn).siblings('input').first();
+ vboxFileBrowser($(def).val(),function(f){
+ if(f) $(def).val(f);
+ },false,trans('VRDP Authentication Library:','UIGlobalSettingsGeneral').replace(':',''));
+}
+
+/*
+ *
+ * Update Data onSave()
+ *
+ */
+$('#vboxSettingsDialog').on('save',function(){
+
+ $('#vboxSettingsDialog').data('vboxSystemProperties').defaultMachineFolder = document.frmVboxSettings.vboxSettingsDefaultMachineFolder.value;
+ $('#vboxSettingsDialog').data('vboxSystemProperties').VRDEAuthLibrary = document.frmVboxSettings.vboxSettingsVRDEAuthLibrary.value;
+
+ // Autostart config path
+ if($('#vboxPane').data('vboxConfig').vboxAutostartConfig) {
+ $('#vboxSettingsDialog').data('vboxSystemProperties').autostartDatabasePath = document.frmVboxSettings.vboxAutostartConfigDBPath.value;
+ }
+
+});
</script> \ No newline at end of file
diff --git a/panes/settingsGlobalLanguage.html b/panes/settingsGlobalLanguage.html
index 2505f1a..fc2a78b 100644
--- a/panes/settingsGlobalLanguage.html
+++ b/panes/settingsGlobalLanguage.html
@@ -1,72 +1,72 @@
-<!--
-
- Language Settings
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: settingsGlobalLanguage.html 595 2015-04-17 09:50:36Z imoore76 $
-
- -->
-<table style='width: auto; margin-left:auto; margin-right:auto;' class='vboxInvisible'>
-<tr>
-<td style='text-align: left'><span class='translate'>Interface Language:</span></td>
-</tr>
-<tr>
-<td>
- <div style='width: 100%; height: 100%;'>
- <ul id='vboxLanguageList' class='vboxBordered vboxList vboxHover'>
- <li class='vboxListItem'>Default</li>
- </ul>
- <div id='vboxLanguageName' style='text-align: center; padding: 4px;'></div>
- </div>
-</td>
-</tr>
-</table>
-<script type='text/javascript'>
-
-/* Fill Languages */
-var vboxLanguages = [
- {'id':'en','name':'English'},
- {'id':'pt_br','name':'Portuguese (Brazil)','name_tr':'Português (Brasil)'},
- {'id':'ru','name':'Russian','name_tr':'Русский'},
- {'id':'it','name':'Italian','name_tr':'Italiano'},
- {'id':'fr','name':'French','name_tr':'Français'},
- {'id':'de','name':'German','name_tr':'Deutsch'},
- {'id':'es','name':'Spanish','name_tr':'Español'},
- {'id':'ja','name':'Japanese','name_tr':'日本語'},
- {'id':'pl','name':'Polish','name_tr':'Polski'},
- {'id':'zh_cn','name':'Chinese (China)','name_tr':'简体中文 (中国)'},
- {'id':'zh_tw','name':'Traditional Chinese','name_tr':'正體中文'},
- {'id':'ro','name':'Romanian','name_tr':'Română'},
- {'id':'nl','name':'Dutch','name_tr':'Nederlands (Nederland)'},
- {'id':'cs','name':'Czech','name_tr':'čeština'},
-];
-var lList = $('#vboxLanguageList');
-$(lList).children().remove();
-var defLang = __vboxLangName;
-if (!defLang) defLang = 'en';
-for(var i = 0; i < vboxLanguages.length; i++) {
-
- var li = $('<li />').data({'language':vboxLanguages[i]}).html((vboxLanguages[i].name_tr ? vboxLanguages[i].name_tr : vboxLanguages[i].name)).attr('class','vboxListItem').hoverClass("vboxHover");
-
- if(defLang == vboxLanguages[i].id) {
- $(li).addClass('vboxListItemSelected');
- $('#vboxLanguageName').html(vboxLanguages[i].name + (vboxLanguages[i].name_tr ? (' / ' + vboxLanguages[i].name_tr) : ''));
- }
- $(li).click(function(){
- $(this).addClass('vboxListItemSelected').siblings().removeClass('vboxListItemSelected');
- $('#vboxLanguageName').html($(this).data('language').name + ($(this).data('language').name_tr ? (' / ' + $(this).data('language').name_tr) : ''));
- });
- $(lList).append(li);
-}
-
-/*
- *
- * Update Data onSave()
- *
- */
-$('#vboxSettingsDialog').on('save',function(){
- var lang = $('#vboxLanguageList').children('li.vboxListItemSelected').first().data('language');
- if(!lang) return;
- $('#vboxSettingsDialog').data('language', lang.id);
-});
-</script>
+<!--
+
+ Language Settings
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: settingsGlobalLanguage.html 595 2015-04-17 09:50:36Z imoore76 $
+
+ -->
+<table style='width: auto; margin-left:auto; margin-right:auto;' class='vboxInvisible'>
+<tr>
+<td style='text-align: left'><span class='translate'>Interface Language:</span></td>
+</tr>
+<tr>
+<td>
+ <div style='width: 100%; height: 100%;'>
+ <ul id='vboxLanguageList' class='vboxBordered vboxList vboxHover'>
+ <li class='vboxListItem'>Default</li>
+ </ul>
+ <div id='vboxLanguageName' style='text-align: center; padding: 4px;'></div>
+ </div>
+</td>
+</tr>
+</table>
+<script type='text/javascript'>
+
+/* Fill Languages */
+var vboxLanguages = [
+ {'id':'en','name':'English'},
+ {'id':'pt_br','name':'Portuguese (Brazil)','name_tr':'Português (Brasil)'},
+ {'id':'ru','name':'Russian','name_tr':'Русский'},
+ {'id':'it','name':'Italian','name_tr':'Italiano'},
+ {'id':'fr','name':'French','name_tr':'Français'},
+ {'id':'de','name':'German','name_tr':'Deutsch'},
+ {'id':'es','name':'Spanish','name_tr':'Español'},
+ {'id':'ja','name':'Japanese','name_tr':'日本語'},
+ {'id':'pl','name':'Polish','name_tr':'Polski'},
+ {'id':'zh_cn','name':'Chinese (China)','name_tr':'简体中文 (中国)'},
+ {'id':'zh_tw','name':'Traditional Chinese','name_tr':'正體中文'},
+ {'id':'ro','name':'Romanian','name_tr':'Română'},
+ {'id':'nl','name':'Dutch','name_tr':'Nederlands (Nederland)'},
+ {'id':'cs','name':'Czech','name_tr':'čeština'},
+];
+var lList = $('#vboxLanguageList');
+$(lList).children().remove();
+var defLang = __vboxLangName;
+if (!defLang) defLang = 'en';
+for(var i = 0; i < vboxLanguages.length; i++) {
+
+ var li = $('<li />').data({'language':vboxLanguages[i]}).html((vboxLanguages[i].name_tr ? vboxLanguages[i].name_tr : vboxLanguages[i].name)).attr('class','vboxListItem').hoverClass("vboxHover");
+
+ if(defLang == vboxLanguages[i].id) {
+ $(li).addClass('vboxListItemSelected');
+ $('#vboxLanguageName').html(vboxLanguages[i].name + (vboxLanguages[i].name_tr ? (' / ' + vboxLanguages[i].name_tr) : ''));
+ }
+ $(li).click(function(){
+ $(this).addClass('vboxListItemSelected').siblings().removeClass('vboxListItemSelected');
+ $('#vboxLanguageName').html($(this).data('language').name + ($(this).data('language').name_tr ? (' / ' + $(this).data('language').name_tr) : ''));
+ });
+ $(lList).append(li);
+}
+
+/*
+ *
+ * Update Data onSave()
+ *
+ */
+$('#vboxSettingsDialog').on('save',function(){
+ var lang = $('#vboxLanguageList').children('li.vboxListItemSelected').first().data('language');
+ if(!lang) return;
+ $('#vboxSettingsDialog').data('language', lang.id);
+});
+</script>
diff --git a/panes/settingsGlobalNetwork.html b/panes/settingsGlobalNetwork.html
index 0fe0b56..557b36e 100644
--- a/panes/settingsGlobalNetwork.html
+++ b/panes/settingsGlobalNetwork.html
@@ -1,658 +1,658 @@
-<!--
-
- General Network Preferences
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: settingsGlobalNetwork.html 597 2015-04-20 11:41:28Z imoore76 $
-
- -->
-<ul>
- <li><a href="#vboxGlobalNATNetworks"><span class='translate'>NAT Networks</span></a>
- <li><a href="#vboxGlobalHostNetworking"><span class='translate'>Host-only Networks</span></a>
-</ul>
-<div id='vboxGlobalNATNetworks'>
- <table style='width: 100%; margin-left:auto; margin-right:auto;' class='vboxInvisible'>
- <tr style='vertical-align:top'>
- <td>
- <div class='vboxBordered' style='height: 280px'>
- <table style='width:100%; border-spacing: 0px;' class='vboxList vboxHover'>
- <thead>
- <tr>
- <th style='width: 140px; padding-left: 4px;text-align:left' class='translate'>Active</th>
- <th style='text-align:left' class='translate'>Name</th>
- </tr>
- </thead>
- <tbody id='vboxSettingsGlobalNATNetList'>
- <tr><td>asdf</td><td>asdf</td></tr>
- </tbody>
- </table>
- </div>
- </td>
- <td style='width: 1%; padding: 4px;' id='vboxSettingsGlobalNATNetToolbar'></td>
- </tr>
- </table>
-</div>
-<div id='vboxGlobalHostNetworking'>
- <table style='width: 100%; margin-left:auto; margin-right:auto;' class='vboxInvisible'>
- <tr style='vertical-align:top'>
- <td >
- <ul id='vboxSettingsGlobalNetList' class='vboxBordered vboxList vboxHover' style='width: 100%; margin-top: 0px;'>
- <li>interface</li>
- </ul>
- </td>
- <td style='width: 1%; padding: 4px;' id='vboxSettingsGlobalNetToolbar'></td>
- </tr>
- </table>
-</div>
-
-<!-- Edit Host Networking Properties Dialog -->
-<div id='vboxSettingsGlobalNetEditDialog' style='display: none'>
-
- <div id='vboxSettingsGlobalNetEdit' class='vboxTabbed'>
- <ul>
- <li><a href="#vboxSettingsGlobalNetEditAdapter"><span class='translate'>Adapter</span></a></li>
- <li><a href="#vboxSettingsGlobalNetEditDHCP"><span class='translate'>DHCP Server</span></a></li>
- </ul>
- <div id="vboxSettingsGlobalNetEditAdapter" class="vboxDialogContent vboxTabContent">
- <table class="vboxSettingsTable">
- <tr>
- <th><span class='translate'>IPv4 Address:</span></th>
- <td><input type='text' class='vboxText' id='vboxSettingsGlobalNetIPv4' /></td>
- </tr>
- <tr>
- <th><span class='translate'>IPv4 Network Mask:</span></th>
- <td><input type='text' class='vboxText' id='vboxSettingsGlobalNetIPv4Mask' /></td>
- </tr>
- <tr>
- <th><span class='translate'>IPv6 Address:</span></th>
- <td><input type='text' class='vboxText' id='vboxSettingsGlobalNetIPv6' /></td>
- </tr>
- <tr>
- <th><span class='translate'>IPv6 Network Mask Length:</span></th>
- <td><input type='text' class='vboxText' id='vboxSettingsGlobalNetIPv6Mask' /></td>
- </tr>
- </table>
- </div>
- <div id="vboxSettingsGlobalNetEditDHCP" class='vboxDialogContent vboxTabContent'>
- <table class="vboxSettingsTable">
- <tr>
- <td colspan='2'><label><input type='checkbox' class='vboxCheckbox vboxEnablerCheckbox' id='vboxSettingsGlobalNetDHCPEnabled' /> <span class='translate'>Enable Server</span></label></td>
- </tr>
- <tr>
- <th><span class='translate'>Server Address:</span></th>
- <td><input type='text' class='vboxText' id='vboxSettingsGlobalNetServerAddress' /></td>
- </tr>
- <tr>
- <th><span class='translate'>Server Mask:</span></th>
- <td><input type='text' class='vboxText' id='vboxSettingsGlobalNetServerMask' /></td>
- </tr>
- <tr>
- <th><span class='translate'>Lower Address Bound:</span></th>
- <td><input type='text' class='vboxText' id='vboxSettingsGlobalNetLower' /></td>
- </tr>
- <tr>
- <th><span class='translate'>Upper Address Bound:</span></th>
- <td><input type='text' class='vboxText' id='vboxSettingsGlobalNetUpper' /></td>
- </tr>
- </table>
- </div>
- </div>
-</div>
-
-
-<!-- Edit NAT NET Networking Properties Dialog -->
-<div id='vboxSettingsGlobalNATNetworkEditDialog' style='display: none'>
-
-
- <div class='vboxDialogContent'>
- <table class="vboxSettingsTable">
- <tr>
- <td colspan='2'><label><input type='checkbox' class='vboxCheckbox vboxEnablerCheckbox' id='vboxSettingsGlobalNATNetEnabled' /> <span class='translate'>Enable Network</span></label></td>
- </tr>
- <tr>
- <th><span class='translate'>Network Name:</span></th>
- <td><input type='text' class='vboxText' id='vboxSettingsGlobalNATNetName' style='width:200px' /></td>
- </tr>
- <tr>
- <th><span class='translate'>Network CIDR:</span></th>
- <td><input type='text' class='vboxText' id='vboxSettingsGlobalNATNetNetwork' style='width:200px' /></td>
- </tr>
- <tr>
- <th><span class='translate'>Network Options:</span></th>
- <td><label><input type='checkbox' class='vboxCheckbox' id='vboxSettingsGlobalNATNetDHCP' /> <span class='translate vboxEnablerListen'>Supports DHCP</span></label></td>
- </tr>
- <tr>
- <th></th>
- <td><label><input type='checkbox' class='vboxCheckbox vboxEnablerTrigger' id='vboxSettingsGlobalNATNetIPv6' /> <span class='translate vboxEnablerListen'>Supports IPv6</span></label></td>
- </tr>
- <tr>
- <th></th>
- <td><label><input type='checkbox' class='vboxCheckbox' id='vboxSettingsGlobalNATNetIPv6Route' /> <span class='translate vboxEnablerListen'>Advertise Default IPv6 Route</span></label></td>
- </tr>
- <tr>
- <th></th>
- <td><input type='button' class='vboxButton' id='vboxSettingsGlobalNATNetRules' value='Port Forwarding' /></td>
- </tr>
- </table>
- </div>
-</div>
-
-
-
-
-<script type='text/javascript'>
-
-/* Build Host interface Toolbar */
-
-var sButtons = new Array(
-
- {
- 'name' : 'addNet',
- 'label' : 'Add host-only network',
- 'icon' : 'add_host_iface',
- 'enabled' : function () { return true; },
- 'click' : function () {
-
- var refreshInterfaces = function(){
- var l = new vboxLoader();
- l.add('hostOnlyInterfacesGet',function(d){$('#vboxSettingsDialog').data('vboxHostOnlyInterfaces',d.responseData);});
- l.onLoad = function(){
- vboxSettingsGlobalNetworkAddAdpaters();
- vboxVMDataMediator.refreshVMData('host');
- };
- l.run();
- };
-
- var l = new vboxLoader();
- l.add('hostOnlyInterfaceCreate',function(d){
-
- if(d && d.responseData && d.responseData.progress) {
- vboxProgress({'progress':d.responseData.progress,'persist':d.persist},function(){
- $('#vboxSettingsGlobalNetList').html('<li><img src="images/spinner.gif" /></li>');
- setTimeout(refreshInterfaces,2000);
- },null,trans('Add host-only network','UIGlobalSettingsNetwork'),'',true);
- }
-
- });
-
- l.run();
-
- }
- },
-
- {
- 'name' : 'delNet',
- 'label' : 'Remove host-only network',
- 'icon' : 'remove_host_iface',
- 'enabled' : function (item) { return ($(item).data('interface')); },
- 'click' : function () {
-
- var item = $('#vboxSettingsGlobalNetList').children('li.vboxListItemSelected').first();
-
- var buttons = {};
- buttons[trans('OK','QIMessageBox')] = function() {
-
- var dialog = this;
- var item = $('#vboxSettingsGlobalNetList').children('li.vboxListItemSelected').first();
-
- var l = new vboxLoader();
- l.add('hostOnlyInterfaceRemove',function(d){
-
- if(d && d.responseData && d.responseData.progress) {
- vboxProgress({'progress':d.responseData.progress,'persist':d.persist},function(){
- var l2 = new vboxLoader();
- l2.add('hostOnlyInterfacesGet',function(d){$('#vboxSettingsDialog').data('vboxHostOnlyInterfaces',d.responseData);});
- l2.onLoad = function(){
- vboxSettingsGlobalNetworkAddAdpaters();
- vboxVMDataMediator.refreshVMData('host');
- };
- l2.run();
- },null,trans('Remove host-only network','UIGlobalSettingsNetwork'),'',true);
- }
-
- },{'id':$(item).data('interface').id});
-
- l.onLoad = function(){$(dialog).empty().remove();};
- l.run();
- };
- vboxConfirm(trans("<p>Deleting this host-only network will remove " +
- "the host-only interface this network is based on. Do you want to " +
- "remove the (host-only network) interface <nobr><b>%1</b>?</nobr></p>" +
- "<p><b>Note:</b> this interface may be in use by one or more " +
- "virtual network adapters belonging to one of your VMs. " +
- "After it is removed, these adapters will no longer be usable until " +
- "you correct their settings by either choosing a different interface " +
- "name or a different adapter attachment type.</p>",'UIMessageCenter').replace('%1',$(item).data('interface').name),buttons);
- }
- },
- {
- 'name' : 'editNet',
- 'label' : 'Edit host-only network',
- 'icon' : 'guesttools',
- 'enabled' : function (item) { return ($(item).data('interface')); },
- 'click' : function () {
- vboxSettingsGlobalNetEditDialog();
- }
- },{
- name : 'refreshNet',
- 'label' : 'Refresh',
- 'language_context': 'UIVMLogViewer',
- 'icon' : 'refresh',
- click: function() {
- var l = new vboxLoader();
- l.add('hostOnlyInterfacesGet',function(d){$('#vboxSettingsDialog').data('vboxHostOnlyInterfaces',d.responseData);});
- l.onLoad = function(){
- vboxSettingsGlobalNetworkAddAdpaters();
- };
- l.run();
- }
- }
-);
-
-var netToolbar = new vboxToolbarSmall({buttons: sButtons, language_context: 'UIGlobalSettingsNetwork'});
-netToolbar.renderTo('vboxSettingsGlobalNetToolbar');
-
-$('#vboxSettingsGlobalNetList').on('select',function(e,i){
- netToolbar.update(i);
-});
-
-
-/* Build nat network Toolbar */
-
-var sButtons = new Array(
-
- {
- 'name' : 'addNet',
- 'label' : 'Add NAT network',
- 'icon' : 'add_host_iface',
- 'click' : function () {
-
- // Elect name...
- var netNameTpl = 'NatNetwork';
- var number = 1;
- var netName = netNameTpl + number++;
-
- while($('#vboxSettingsGlobalNATNetList').find('td:contains("'+netName+'")').length) {
- netName = netNameTpl + number++;
- }
- vboxSettingsGlobalNATNetworksAddNet({'enabled':false,'networkName':netName,'portForwardRules4':[],'portForwardRules6':[]});
-
-
- }
- },
-
- {
- 'name' : 'delNet',
- 'label' : 'Remove NAT network',
- 'icon' : 'remove_host_iface',
- 'enabled' : function (item) { return (item); },
- 'click' : function () {
-
- var item = $('#vboxSettingsGlobalNATNetList').children('tr.vboxListItemSelected').first();
-
- var buttons = {};
- buttons[trans('OK','QIMessageBox')] = function() {
-
- $(item).remove();
- $('#vboxSettingsGlobalNATNetList').trigger('select', null);
- $(this).empty().remove();
- };
- vboxConfirm(trans("<p>Deleting this host-only network will remove " +
- "the host-only interface this network is based on. Do you want to " +
- "remove the (host-only network) interface <nobr><b>%1</b>?</nobr></p>" +
- "<p><b>Note:</b> this interface may be in use by one or more " +
- "virtual network adapters belonging to one of your VMs. " +
- "After it is removed, these adapters will no longer be usable until " +
- "you correct their settings by either choosing a different interface " +
- "name or a different adapter attachment type.</p>",'UIMessageCenter').replace('%1',$(item).data('NATNetwork').networkName),buttons);
- }
- },
- {
- 'name' : 'editNet',
- 'label' : 'Edit NAT network',
- 'icon' : 'guesttools',
- 'enabled' : function (item) { return (item); },
- 'click' : function () {
- vboxSettingsGlobalNATNetworkEditDialog();
- }
- },{
- name : 'refreshNet',
- 'label' : 'Refresh',
- 'language_context': 'UIVMLogViewer',
- 'icon' : 'refresh',
- click: function() {
- var l = new vboxLoader();
- l.add('vboxNATNetworksGet',function(d){$('#vboxSettingsDialog').data('vboxNATNetworks',d.responseData);});
- l.onLoad = function(){
- vboxSettingsGlobalNATNetworksAdd();
- };
- l.run();
- }
- }
-);
-
-var natNetToolbar = new vboxToolbarSmall({buttons: sButtons, language_context: 'UIGlobalSettingsNetwork'});
-natNetToolbar.renderTo('vboxSettingsGlobalNATNetToolbar');
-
-$('#vboxSettingsGlobalNATNetList').on('select',function(e,i){
- natNetToolbar.update(i);
-});
-
-/*
- *
- * Function to fill network adapters
- *
- */
-function vboxSettingsGlobalNetworkAddAdpater(n) {
-
- // If the adapter exists, don't add it
- var exists = false;
- $('#vboxSettingsGlobalNetList').children('li').each(function(){
- if($(this).data('interface').id == n.id) {
- exists = true;
- return false;
- }
- });
-
- if(exists) return;
-
- $('<li />').attr({'class':'vboxListItem'}).html($('<div />').text(n.name).html()).hoverClass('vboxHover').data('interface',n).click(function(){
- $(this).parent().children('li.vboxListItemSelected').removeClass('vboxListItemSelected').addClass('vboxListItem');
- $(this).addClass('vboxListItemSelected').removeClass('vboxListItem');
- $('#vboxSettingsGlobalNetList').trigger('select',this);
- }).appendTo($('#vboxSettingsGlobalNetList'));
-
-}
-
-/*
- *
- * Fill network adapters
- *
- */
-function vboxSettingsGlobalNetworkAddAdpaters() {
- $('#vboxSettingsGlobalNetList').children().remove();
- var nics = $('#vboxSettingsDialog').data('vboxHostOnlyInterfaces').networkInterfaces;
- for(var i = 0; i < nics.length; i++) {
- vboxSettingsGlobalNetworkAddAdpater(nics[i]);
- }
- $('#vboxSettingsGlobalNetList').trigger('select',null);
-}
-vboxSettingsGlobalNetworkAddAdpaters();
-
-/*
- *
- * FIll nat networks
- */
-function vboxSettingsGlobalNATNetworksAdd() {
- var nets = $('#vboxSettingsDialog').data('vboxNATNetworks');
- $('#vboxSettingsGlobalNATNetList').empty();
- for(var i = 0; i < nets.length; i++) {
- nets[i].orig_networkName = nets[i].networkName;
- vboxSettingsGlobalNATNetworksAddNet(nets[i]);
- }
- $('#vboxSettingsGlobalNATNetList').trigger('select',null);
-}
-
-function vboxSettingsGlobalNATNetworksAddNet(net) {
-
- $('<tr />').data({'NATNetwork':net}).hoverClass('vboxHover').addClass('vboxListItem').append(
- $('<td />').append(
- $('<input />').attr({'type':'checkbox'}).click(function(){
- $(this).closest('tr').data('NATNetwork').enabled = this.checked;
- $(this).closest('tr').data('NATNetwork')._modified = true;
- }).prop('checked', net.enabled)
-
- ).click(function(){
- $(this).parent().parent().children('tr.vboxListItemSelected').removeClass('vboxListItemSelected').addClass('vboxListItem');
- $(this).parent().addClass('vboxListItemSelected').removeClass('vboxListItem');
- $('#vboxSettingsGlobalNATNetList').trigger('select',this);
- })
- ).append(
- $('<td />').html($('<div />').html(net.networkName).text()).click(function(){
- $(this).parent().parent().children('tr.vboxListItemSelected').removeClass('vboxListItemSelected').addClass('vboxListItem');
- $(this).parent().addClass('vboxListItemSelected').removeClass('vboxListItem');
- $('#vboxSettingsGlobalNATNetList').trigger('select',this);
- })
- ).appendTo($('#vboxSettingsGlobalNATNetList'));
-
-}
-
-vboxSettingsGlobalNATNetworksAdd();
-
-/*
- *
- * Edit Network Interface Dialog
- *
- */
-vboxInitDisplay('vboxSettingsGlobalNetEditDialog','UIGlobalSettingsNetworkDetails');
-
-var buttons = {};
-buttons[trans('OK','QIMessageBox')] = function(){
-
- var nic = $('#vboxSettingsGlobalNetList').children('li.vboxListItemSelected').first().data('interface');
-
- nic.IPAddress = $('#vboxSettingsGlobalNetIPv4').val();
- nic.networkMask = $('#vboxSettingsGlobalNetIPv4Mask').val();
- nic.IPV6Address = $('#vboxSettingsGlobalNetIPv6').val();
- nic.IPV6NetworkMaskPrefixLength = $('#vboxSettingsGlobalNetIPv6Mask').val();
- nic.dhcpServer = {};
- nic.dhcpServer.networkName = nic.networkName;
- nic.dhcpServer.enabled = $('#vboxSettingsGlobalNetDHCPEnabled').prop('checked');
- nic.dhcpServer.IPAddress = $('#vboxSettingsGlobalNetServerAddress').val();
- nic.dhcpServer.networkMask = $('#vboxSettingsGlobalNetServerMask').val();
- nic.dhcpServer.lowerIP = $('#vboxSettingsGlobalNetLower').val();
- nic.dhcpServer.upperIP = $('#vboxSettingsGlobalNetUpper').val();
-
- $('#vboxSettingsGlobalNetList').children('li.vboxListItemSelected').first().data('interface',nic);
-
- $(this).dialog("close");
-};
-buttons[trans('Cancel','QIMessageBox')] = function(){$(this).dialog("close");};
-$('#vboxSettingsGlobalNetEditDialog').dialog({'buttons':buttons,'width':500,'modal':true,'autoOpen':false,'dialogClass':'vboxDialogContent','title':'<img src="images/vbox/nw_16px.png" class="vboxDialogTitleIcon" /> ' +trans('Host-only Network Details','UIGlobalSettingsNetworkDetails')});
-
-
-function vboxSettingsGlobalNetEditDialog() {
-
- var nic = $('#vboxSettingsGlobalNetList').children('li.vboxListItemSelected').first().data('interface');
-
- // Set Form Values
- $('#vboxSettingsGlobalNetIPv4').val(nic.IPAddress);
- $('#vboxSettingsGlobalNetIPv4Mask').val(nic.networkMask);
-
- if(nic.IPV6Supported) {
- $('#vboxSettingsGlobalNetIPv6').prop('disabled',false).val(nic.IPV6Address).closest('tr').find('span').removeClass('vboxDisabled');
- $('#vboxSettingsGlobalNetIPv6Mask').prop('disabled',false).val(nic.IPV6NetworkMaskPrefixLength).closest('tr').find('span').removeClass('vboxDisabled');
- } else {
- $('#vboxSettingsGlobalNetIPv6').prop('disabled',true).val('').closest('tr').find('span').addClass('vboxDisabled');
- $('#vboxSettingsGlobalNetIPv6Mask').prop('disabled',true).val('').closest('tr').find('span').addClass('vboxDisabled');
- }
-
- if(nic.dhcpServer && nic.dhcpServer.networkName) {
- $('#vboxSettingsGlobalNetServerAddress').val(nic.dhcpServer.IPAddress);
- $('#vboxSettingsGlobalNetServerMask').val(nic.dhcpServer.networkMask);
- $('#vboxSettingsGlobalNetLower').val(nic.dhcpServer.lowerIP);
- $('#vboxSettingsGlobalNetUpper').val(nic.dhcpServer.upperIP);
- } else {
- $('#vboxSettingsGlobalNetServerAddress').val('');
- $('#vboxSettingsGlobalNetServerMask').val('');
- $('#vboxSettingsGlobalNetLower').val('');
- $('#vboxSettingsGlobalNetUpper').val('');
- }
-
-
- $('#vboxSettingsGlobalNetEdit').tabs('option','active',0);
- $('#vboxSettingsGlobalNetDHCPEnabled').trigger('click');
-
- if(nic.dhcpServer && nic.dhcpServer.enabled && !$('#vboxSettingsGlobalNetDHCPEnabled').prop('checked')) {
- $('#vboxSettingsGlobalNetDHCPEnabled').trigger('click');
- } else if(nic.dhcpServer && !nic.dhcpServer.enabled && $('#vboxSettingsGlobalNetDHCPEnabled').prop('checked')) {
- $('#vboxSettingsGlobalNetDHCPEnabled').trigger('click');
- }
-
- $('#vboxSettingsGlobalNetEditDialog').dialog('open');
-
-}
-
-/*
-*
-* Edit NAT Network Interface Dialog
-*
-*/
-vboxInitDisplay('vboxSettingsGlobalNATNetworkEditDialog', 'UIGlobalSettingsNetworkDetailsNAT');
-
-var buttons = {};
-buttons[trans('OK','QIMessageBox')] = function(){
-
- var net = $('#vboxSettingsGlobalNATNetList').children('tr.vboxListItemSelected').first().data('NATNetwork');
-
- // Get Form Values
- net.enabled = $('#vboxSettingsGlobalNATNetEnabled').prop('checked');
- net.networkName = $('#vboxSettingsGlobalNATNetName').val();
- net.network = $('#vboxSettingsGlobalNATNetNetwork').val();
- net.needDhcpServer = $('#vboxSettingsGlobalNATNetDHCP').prop('checked');
- net.IPv6Enabled = $('#vboxSettingsGlobalNATNetIPv6').prop('checked');
- net.advertiseDefaultIPv6RouteEnabled = $('#vboxSettingsGlobalNATNetIPv6Route').prop('checked');
- net._modified = true;
-
- $('#vboxSettingsGlobalNATNetList').children('tr.vboxListItemSelected').first().data('NATNetwork',net).find('input').prop('checked', net.enabled);
-
- $(this).dialog("close");
-};
-buttons[trans('Cancel','QIMessageBox')] = function(){$(this).dialog("close");};
-$('#vboxSettingsGlobalNATNetworkEditDialog').dialog({'buttons':buttons,'width':500,'modal':true,'autoOpen':false,'dialogClass':'vboxDialogContent','title':'<img src="images/vbox/nw_16px.png" class="vboxDialogTitleIcon" /> ' +trans('Host-only Network Details','UIGlobalSettingsNetworkDetails')});
-$('#vboxSettingsGlobalNATNetIPv6').on('enable',function() {
- if(this.checked) {
- $('#vboxSettingsGlobalNATNetIPv6Route').prop('disabled', false).siblings().removeClass('vboxDisabled');
- } else {
- $('#vboxSettingsGlobalNATNetIPv6Route').prop('disabled', true).siblings().addClass('vboxDisabled');
- }
-}).on('click',function(){
- $(this).trigger('enable');
-});
-
-function vboxSettingsGlobalNATNetworkEditDialog() {
-
- var net = $('#vboxSettingsGlobalNATNetList').children('tr.vboxListItemSelected').first().data('NATNetwork');
-
- // Set Form Values
- $('#vboxSettingsGlobalNATNetEnabled').prop('checked', net.enabled);
- $('#vboxSettingsGlobalNATNetName').val(net.networkName);
- $('#vboxSettingsGlobalNATNetNetwork').val(net.network);
- $('#vboxSettingsGlobalNATNetDHCP').prop('checked', net.needDhcpServer)
- $('#vboxSettingsGlobalNATNetIPv6').prop('checked', net.IPv6Enabled)
- $('#vboxSettingsGlobalNATNetIPv6Route').prop('checked', net.advertiseDefaultIPv6RouteEnabled)
-
- $('#vboxSettingsGlobalNATNetEnabled').triggerHandler('click');
- $('#vboxSettingsGlobalNATNetIPv6').triggerHandler('click');
-
- $('#vboxSettingsGlobalNATNetRules').val(trans('Port Forwarding', 'UIGlobalSettingsNetworkDetailsNAT')).off('click').on('click',function(){
- vboxSettingsGlobalNetworkNatPortForwardingDialog(net, $('#vboxSettingsGlobalNATNetList').children('tr.vboxListItemSelected').first());
- });
-
- $('#vboxSettingsGlobalNATNetworkEditDialog').dialog('open');
-
-}
-
-
-function vboxSettingsGlobalNetworkNatPortForwardingDialog(net, row) {
-
- if($('#vboxSettingsGlobalNetworkNatPortForwardingDialog')[0])
- $('#vboxSettingsGlobalNetworkNatPortForwardingDialog').empty().remove();
-
- var l = new vboxLoader();
- l.addFileToDOM("panes/settingsGlobalNetworkNATPortForwarding.html");
- l.onLoad = function(){
-
- vboxSettingsGlobalNetworkNatPortForwardingInit(net.portForwardRules4, false);
- vboxSettingsGlobalNetworkNatPortForwardingInit(net.portForwardRules6, true);
-
- var buttons = {};
- buttons[trans('OK','QIMessageBox')] = function(){
-
- // wrap ips in []
- var wrapIp = function(ip) {
- ip = ip.trim();
- if(!ip) return '[]';
- if(ip[0] != '[') $ip = '[' + ip;
- if(ip[ip.length-1] != ']') ip += ']';
- return ip;
- }
-
- // Get rules
- var none=0;
- do {
- var ruleNum = 4 + (none*2);
- var rules = $('#vboxSettingsGlobalNetworkNatPortForwardingListIPv'+ruleNum).children('tr');
- var rulesToPass = new Array();
- for(var i = 0; i < rules.length; i++) {
- if($(rules[i]).data('vboxRule')[3] == 0 || $(rules[i]).data('vboxRule')[5] == 0) {
- vboxAlert(trans("The current port forwarding rules are not valid. " +
- "None of the host or guest port values may be set to zero.",'UIMessageCenter'));
- return;
- }
-
- rulesToPass[i] = $(rules[i]).data('vboxRule');
-
- rulesToPass[i][0] = rulesToPass[i][0].replace(':','');
- rulesToPass[i][2] = wrapIp(rulesToPass[i][2]);
- rulesToPass[i][4] = wrapIp(rulesToPass[i][4]);
-
- rulesToPass[i] = rulesToPass[i].join(':');
- }
- $('#vboxSettingsGlobalNATNetList').children('tr.vboxListItemSelected').first().data('NATNetwork')['portForwardRules'+ruleNum] = rulesToPass;
-
- } while(none++ < 1)
-
- $(this).trigger('close').empty().remove();
-
-
- };
- buttons[trans('Cancel','QIMessageBox')] = function(){
- $(this).trigger('close').empty().remove();
- };
-
- vboxInitDisplay($('#vboxSettingsGlobalNetworkNatPortForwardingDialog'), 'UIPortForwardingModel');
-
- $('#vboxSettingsGlobalNetworkNatPortForwardingDialog').tabs();
-
- $('#vboxSettingsGlobalNetworkNatPortForwardingDialog').dialog({'closeOnEscape':true,'width':840,'height':400,'buttons':buttons,'modal':true,'autoOpen':true,'dialogClass':'vboxDialogContent','title':'<img src="images/vbox/nw_16px.png" class="vboxDialogTitleIcon" /> ' + trans('Port Forwarding Rules','UIMachineSettingsPortForwardingDlg')}).on("dialogbeforeclose",function(){
- $(this).parent().find('span:contains("'+trans('Cancel','QIMessageBox')+'")').trigger('click');
- });
-
-
- };
- l.run();
-
-}
-
-/*
- *
- * Update Data onSave()
- *
- */
-$('#vboxSettingsDialog').on('save',function(){
-
- $('#vboxSettingsDialog').data('vboxHostOnlyInterfaces').networkInterfaces = new Array();
-
- $('#vboxSettingsGlobalNetList').children('li').each(function(){
- $('#vboxSettingsDialog').data('vboxHostOnlyInterfaces').networkInterfaces.push($(this).data('interface'));
- });
-
- var nets = [];
-
- $('#vboxSettingsGlobalNATNetList').children('tr').each(function(){
- nets.push($(this).data('NATNetwork'));
- });
- $('#vboxSettingsDialog').data('vboxNATNetworks',nets);
-
-});
-
-/*
- * Remove dialogs on close
- */
-$('#vboxSettingsDialog').on('close',function(){
- $('#vboxSettingsGlobalNetEditDialog').remove();
- $('#vboxSettingsGlobalNATNetworkEditDialog').remove();
-});
-
+<!--
+
+ General Network Preferences
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: settingsGlobalNetwork.html 597 2015-04-20 11:41:28Z imoore76 $
+
+ -->
+<ul>
+ <li><a href="#vboxGlobalNATNetworks"><span class='translate'>NAT Networks</span></a>
+ <li><a href="#vboxGlobalHostNetworking"><span class='translate'>Host-only Networks</span></a>
+</ul>
+<div id='vboxGlobalNATNetworks'>
+ <table style='width: 100%; margin-left:auto; margin-right:auto;' class='vboxInvisible'>
+ <tr style='vertical-align:top'>
+ <td>
+ <div class='vboxBordered' style='height: 280px'>
+ <table style='width:100%; border-spacing: 0px;' class='vboxList vboxHover'>
+ <thead>
+ <tr>
+ <th style='width: 140px; padding-left: 4px;text-align:left' class='translate'>Active</th>
+ <th style='text-align:left' class='translate'>Name</th>
+ </tr>
+ </thead>
+ <tbody id='vboxSettingsGlobalNATNetList'>
+ <tr><td>asdf</td><td>asdf</td></tr>
+ </tbody>
+ </table>
+ </div>
+ </td>
+ <td style='width: 1%; padding: 4px;' id='vboxSettingsGlobalNATNetToolbar'></td>
+ </tr>
+ </table>
+</div>
+<div id='vboxGlobalHostNetworking'>
+ <table style='width: 100%; margin-left:auto; margin-right:auto;' class='vboxInvisible'>
+ <tr style='vertical-align:top'>
+ <td >
+ <ul id='vboxSettingsGlobalNetList' class='vboxBordered vboxList vboxHover' style='width: 100%; margin-top: 0px;'>
+ <li>interface</li>
+ </ul>
+ </td>
+ <td style='width: 1%; padding: 4px;' id='vboxSettingsGlobalNetToolbar'></td>
+ </tr>
+ </table>
+</div>
+
+<!-- Edit Host Networking Properties Dialog -->
+<div id='vboxSettingsGlobalNetEditDialog' style='display: none'>
+
+ <div id='vboxSettingsGlobalNetEdit' class='vboxTabbed'>
+ <ul>
+ <li><a href="#vboxSettingsGlobalNetEditAdapter"><span class='translate'>Adapter</span></a></li>
+ <li><a href="#vboxSettingsGlobalNetEditDHCP"><span class='translate'>DHCP Server</span></a></li>
+ </ul>
+ <div id="vboxSettingsGlobalNetEditAdapter" class="vboxDialogContent vboxTabContent">
+ <table class="vboxSettingsTable">
+ <tr>
+ <th><span class='translate'>IPv4 Address:</span></th>
+ <td><input type='text' class='vboxText' id='vboxSettingsGlobalNetIPv4' /></td>
+ </tr>
+ <tr>
+ <th><span class='translate'>IPv4 Network Mask:</span></th>
+ <td><input type='text' class='vboxText' id='vboxSettingsGlobalNetIPv4Mask' /></td>
+ </tr>
+ <tr>
+ <th><span class='translate'>IPv6 Address:</span></th>
+ <td><input type='text' class='vboxText' id='vboxSettingsGlobalNetIPv6' /></td>
+ </tr>
+ <tr>
+ <th><span class='translate'>IPv6 Network Mask Length:</span></th>
+ <td><input type='text' class='vboxText' id='vboxSettingsGlobalNetIPv6Mask' /></td>
+ </tr>
+ </table>
+ </div>
+ <div id="vboxSettingsGlobalNetEditDHCP" class='vboxDialogContent vboxTabContent'>
+ <table class="vboxSettingsTable">
+ <tr>
+ <td colspan='2'><label><input type='checkbox' class='vboxCheckbox vboxEnablerCheckbox' id='vboxSettingsGlobalNetDHCPEnabled' /> <span class='translate'>Enable Server</span></label></td>
+ </tr>
+ <tr>
+ <th><span class='translate'>Server Address:</span></th>
+ <td><input type='text' class='vboxText' id='vboxSettingsGlobalNetServerAddress' /></td>
+ </tr>
+ <tr>
+ <th><span class='translate'>Server Mask:</span></th>
+ <td><input type='text' class='vboxText' id='vboxSettingsGlobalNetServerMask' /></td>
+ </tr>
+ <tr>
+ <th><span class='translate'>Lower Address Bound:</span></th>
+ <td><input type='text' class='vboxText' id='vboxSettingsGlobalNetLower' /></td>
+ </tr>
+ <tr>
+ <th><span class='translate'>Upper Address Bound:</span></th>
+ <td><input type='text' class='vboxText' id='vboxSettingsGlobalNetUpper' /></td>
+ </tr>
+ </table>
+ </div>
+ </div>
+</div>
+
+
+<!-- Edit NAT NET Networking Properties Dialog -->
+<div id='vboxSettingsGlobalNATNetworkEditDialog' style='display: none'>
+
+
+ <div class='vboxDialogContent'>
+ <table class="vboxSettingsTable">
+ <tr>
+ <td colspan='2'><label><input type='checkbox' class='vboxCheckbox vboxEnablerCheckbox' id='vboxSettingsGlobalNATNetEnabled' /> <span class='translate'>Enable Network</span></label></td>
+ </tr>
+ <tr>
+ <th><span class='translate'>Network Name:</span></th>
+ <td><input type='text' class='vboxText' id='vboxSettingsGlobalNATNetName' style='width:200px' /></td>
+ </tr>
+ <tr>
+ <th><span class='translate'>Network CIDR:</span></th>
+ <td><input type='text' class='vboxText' id='vboxSettingsGlobalNATNetNetwork' style='width:200px' /></td>
+ </tr>
+ <tr>
+ <th><span class='translate'>Network Options:</span></th>
+ <td><label><input type='checkbox' class='vboxCheckbox' id='vboxSettingsGlobalNATNetDHCP' /> <span class='translate vboxEnablerListen'>Supports DHCP</span></label></td>
+ </tr>
+ <tr>
+ <th></th>
+ <td><label><input type='checkbox' class='vboxCheckbox vboxEnablerTrigger' id='vboxSettingsGlobalNATNetIPv6' /> <span class='translate vboxEnablerListen'>Supports IPv6</span></label></td>
+ </tr>
+ <tr>
+ <th></th>
+ <td><label><input type='checkbox' class='vboxCheckbox' id='vboxSettingsGlobalNATNetIPv6Route' /> <span class='translate vboxEnablerListen'>Advertise Default IPv6 Route</span></label></td>
+ </tr>
+ <tr>
+ <th></th>
+ <td><input type='button' class='vboxButton' id='vboxSettingsGlobalNATNetRules' value='Port Forwarding' /></td>
+ </tr>
+ </table>
+ </div>
+</div>
+
+
+
+
+<script type='text/javascript'>
+
+/* Build Host interface Toolbar */
+
+var sButtons = new Array(
+
+ {
+ 'name' : 'addNet',
+ 'label' : 'Add host-only network',
+ 'icon' : 'add_host_iface',
+ 'enabled' : function () { return true; },
+ 'click' : function () {
+
+ var refreshInterfaces = function(){
+ var l = new vboxLoader();
+ l.add('hostOnlyInterfacesGet',function(d){$('#vboxSettingsDialog').data('vboxHostOnlyInterfaces',d.responseData);});
+ l.onLoad = function(){
+ vboxSettingsGlobalNetworkAddAdpaters();
+ vboxVMDataMediator.refreshVMData('host');
+ };
+ l.run();
+ };
+
+ var l = new vboxLoader();
+ l.add('hostOnlyInterfaceCreate',function(d){
+
+ if(d && d.responseData && d.responseData.progress) {
+ vboxProgress({'progress':d.responseData.progress,'persist':d.persist},function(){
+ $('#vboxSettingsGlobalNetList').html('<li><img src="images/spinner.gif" /></li>');
+ setTimeout(refreshInterfaces,2000);
+ },null,trans('Add host-only network','UIGlobalSettingsNetwork'),'',true);
+ }
+
+ });
+
+ l.run();
+
+ }
+ },
+
+ {
+ 'name' : 'delNet',
+ 'label' : 'Remove host-only network',
+ 'icon' : 'remove_host_iface',
+ 'enabled' : function (item) { return ($(item).data('interface')); },
+ 'click' : function () {
+
+ var item = $('#vboxSettingsGlobalNetList').children('li.vboxListItemSelected').first();
+
+ var buttons = {};
+ buttons[trans('OK','QIMessageBox')] = function() {
+
+ var dialog = this;
+ var item = $('#vboxSettingsGlobalNetList').children('li.vboxListItemSelected').first();
+
+ var l = new vboxLoader();
+ l.add('hostOnlyInterfaceRemove',function(d){
+
+ if(d && d.responseData && d.responseData.progress) {
+ vboxProgress({'progress':d.responseData.progress,'persist':d.persist},function(){
+ var l2 = new vboxLoader();
+ l2.add('hostOnlyInterfacesGet',function(d){$('#vboxSettingsDialog').data('vboxHostOnlyInterfaces',d.responseData);});
+ l2.onLoad = function(){
+ vboxSettingsGlobalNetworkAddAdpaters();
+ vboxVMDataMediator.refreshVMData('host');
+ };
+ l2.run();
+ },null,trans('Remove host-only network','UIGlobalSettingsNetwork'),'',true);
+ }
+
+ },{'id':$(item).data('interface').id});
+
+ l.onLoad = function(){$(dialog).empty().remove();};
+ l.run();
+ };
+ vboxConfirm(trans("<p>Deleting this host-only network will remove " +
+ "the host-only interface this network is based on. Do you want to " +
+ "remove the (host-only network) interface <nobr><b>%1</b>?</nobr></p>" +
+ "<p><b>Note:</b> this interface may be in use by one or more " +
+ "virtual network adapters belonging to one of your VMs. " +
+ "After it is removed, these adapters will no longer be usable until " +
+ "you correct their settings by either choosing a different interface " +
+ "name or a different adapter attachment type.</p>",'UIMessageCenter').replace('%1',$(item).data('interface').name),buttons);
+ }
+ },
+ {
+ 'name' : 'editNet',
+ 'label' : 'Edit host-only network',
+ 'icon' : 'guesttools',
+ 'enabled' : function (item) { return ($(item).data('interface')); },
+ 'click' : function () {
+ vboxSettingsGlobalNetEditDialog();
+ }
+ },{
+ name : 'refreshNet',
+ 'label' : 'Refresh',
+ 'language_context': 'UIVMLogViewer',
+ 'icon' : 'refresh',
+ click: function() {
+ var l = new vboxLoader();
+ l.add('hostOnlyInterfacesGet',function(d){$('#vboxSettingsDialog').data('vboxHostOnlyInterfaces',d.responseData);});
+ l.onLoad = function(){
+ vboxSettingsGlobalNetworkAddAdpaters();
+ };
+ l.run();
+ }
+ }
+);
+
+var netToolbar = new vboxToolbarSmall({buttons: sButtons, language_context: 'UIGlobalSettingsNetwork'});
+netToolbar.renderTo('vboxSettingsGlobalNetToolbar');
+
+$('#vboxSettingsGlobalNetList').on('select',function(e,i){
+ netToolbar.update(i);
+});
+
+
+/* Build nat network Toolbar */
+
+var sButtons = new Array(
+
+ {
+ 'name' : 'addNet',
+ 'label' : 'Add NAT network',
+ 'icon' : 'add_host_iface',
+ 'click' : function () {
+
+ // Elect name...
+ var netNameTpl = 'NatNetwork';
+ var number = 1;
+ var netName = netNameTpl + number++;
+
+ while($('#vboxSettingsGlobalNATNetList').find('td:contains("'+netName+'")').length) {
+ netName = netNameTpl + number++;
+ }
+ vboxSettingsGlobalNATNetworksAddNet({'enabled':false,'networkName':netName,'portForwardRules4':[],'portForwardRules6':[]});
+
+
+ }
+ },
+
+ {
+ 'name' : 'delNet',
+ 'label' : 'Remove NAT network',
+ 'icon' : 'remove_host_iface',
+ 'enabled' : function (item) { return (item); },
+ 'click' : function () {
+
+ var item = $('#vboxSettingsGlobalNATNetList').children('tr.vboxListItemSelected').first();
+
+ var buttons = {};
+ buttons[trans('OK','QIMessageBox')] = function() {
+
+ $(item).remove();
+ $('#vboxSettingsGlobalNATNetList').trigger('select', null);
+ $(this).empty().remove();
+ };
+ vboxConfirm(trans("<p>Deleting this host-only network will remove " +
+ "the host-only interface this network is based on. Do you want to " +
+ "remove the (host-only network) interface <nobr><b>%1</b>?</nobr></p>" +
+ "<p><b>Note:</b> this interface may be in use by one or more " +
+ "virtual network adapters belonging to one of your VMs. " +
+ "After it is removed, these adapters will no longer be usable until " +
+ "you correct their settings by either choosing a different interface " +
+ "name or a different adapter attachment type.</p>",'UIMessageCenter').replace('%1',$(item).data('NATNetwork').networkName),buttons);
+ }
+ },
+ {
+ 'name' : 'editNet',
+ 'label' : 'Edit NAT network',
+ 'icon' : 'guesttools',
+ 'enabled' : function (item) { return (item); },
+ 'click' : function () {
+ vboxSettingsGlobalNATNetworkEditDialog();
+ }
+ },{
+ name : 'refreshNet',
+ 'label' : 'Refresh',
+ 'language_context': 'UIVMLogViewer',
+ 'icon' : 'refresh',
+ click: function() {
+ var l = new vboxLoader();
+ l.add('vboxNATNetworksGet',function(d){$('#vboxSettingsDialog').data('vboxNATNetworks',d.responseData);});
+ l.onLoad = function(){
+ vboxSettingsGlobalNATNetworksAdd();
+ };
+ l.run();
+ }
+ }
+);
+
+var natNetToolbar = new vboxToolbarSmall({buttons: sButtons, language_context: 'UIGlobalSettingsNetwork'});
+natNetToolbar.renderTo('vboxSettingsGlobalNATNetToolbar');
+
+$('#vboxSettingsGlobalNATNetList').on('select',function(e,i){
+ natNetToolbar.update(i);
+});
+
+/*
+ *
+ * Function to fill network adapters
+ *
+ */
+function vboxSettingsGlobalNetworkAddAdpater(n) {
+
+ // If the adapter exists, don't add it
+ var exists = false;
+ $('#vboxSettingsGlobalNetList').children('li').each(function(){
+ if($(this).data('interface').id == n.id) {
+ exists = true;
+ return false;
+ }
+ });
+
+ if(exists) return;
+
+ $('<li />').attr({'class':'vboxListItem'}).html($('<div />').text(n.name).html()).hoverClass('vboxHover').data('interface',n).click(function(){
+ $(this).parent().children('li.vboxListItemSelected').removeClass('vboxListItemSelected').addClass('vboxListItem');
+ $(this).addClass('vboxListItemSelected').removeClass('vboxListItem');
+ $('#vboxSettingsGlobalNetList').trigger('select',this);
+ }).appendTo($('#vboxSettingsGlobalNetList'));
+
+}
+
+/*
+ *
+ * Fill network adapters
+ *
+ */
+function vboxSettingsGlobalNetworkAddAdpaters() {
+ $('#vboxSettingsGlobalNetList').children().remove();
+ var nics = $('#vboxSettingsDialog').data('vboxHostOnlyInterfaces').networkInterfaces;
+ for(var i = 0; i < nics.length; i++) {
+ vboxSettingsGlobalNetworkAddAdpater(nics[i]);
+ }
+ $('#vboxSettingsGlobalNetList').trigger('select',null);
+}
+vboxSettingsGlobalNetworkAddAdpaters();
+
+/*
+ *
+ * FIll nat networks
+ */
+function vboxSettingsGlobalNATNetworksAdd() {
+ var nets = $('#vboxSettingsDialog').data('vboxNATNetworks');
+ $('#vboxSettingsGlobalNATNetList').empty();
+ for(var i = 0; i < nets.length; i++) {
+ nets[i].orig_networkName = nets[i].networkName;
+ vboxSettingsGlobalNATNetworksAddNet(nets[i]);
+ }
+ $('#vboxSettingsGlobalNATNetList').trigger('select',null);
+}
+
+function vboxSettingsGlobalNATNetworksAddNet(net) {
+
+ $('<tr />').data({'NATNetwork':net}).hoverClass('vboxHover').addClass('vboxListItem').append(
+ $('<td />').append(
+ $('<input />').attr({'type':'checkbox'}).click(function(){
+ $(this).closest('tr').data('NATNetwork').enabled = this.checked;
+ $(this).closest('tr').data('NATNetwork')._modified = true;
+ }).prop('checked', net.enabled)
+
+ ).click(function(){
+ $(this).parent().parent().children('tr.vboxListItemSelected').removeClass('vboxListItemSelected').addClass('vboxListItem');
+ $(this).parent().addClass('vboxListItemSelected').removeClass('vboxListItem');
+ $('#vboxSettingsGlobalNATNetList').trigger('select',this);
+ })
+ ).append(
+ $('<td />').html($('<div />').html(net.networkName).text()).click(function(){
+ $(this).parent().parent().children('tr.vboxListItemSelected').removeClass('vboxListItemSelected').addClass('vboxListItem');
+ $(this).parent().addClass('vboxListItemSelected').removeClass('vboxListItem');
+ $('#vboxSettingsGlobalNATNetList').trigger('select',this);
+ })
+ ).appendTo($('#vboxSettingsGlobalNATNetList'));
+
+}
+
+vboxSettingsGlobalNATNetworksAdd();
+
+/*
+ *
+ * Edit Network Interface Dialog
+ *
+ */
+vboxInitDisplay('vboxSettingsGlobalNetEditDialog','UIGlobalSettingsNetworkDetails');
+
+var buttons = {};
+buttons[trans('OK','QIMessageBox')] = function(){
+
+ var nic = $('#vboxSettingsGlobalNetList').children('li.vboxListItemSelected').first().data('interface');
+
+ nic.IPAddress = $('#vboxSettingsGlobalNetIPv4').val();
+ nic.networkMask = $('#vboxSettingsGlobalNetIPv4Mask').val();
+ nic.IPV6Address = $('#vboxSettingsGlobalNetIPv6').val();
+ nic.IPV6NetworkMaskPrefixLength = $('#vboxSettingsGlobalNetIPv6Mask').val();
+ nic.dhcpServer = {};
+ nic.dhcpServer.networkName = nic.networkName;
+ nic.dhcpServer.enabled = $('#vboxSettingsGlobalNetDHCPEnabled').prop('checked');
+ nic.dhcpServer.IPAddress = $('#vboxSettingsGlobalNetServerAddress').val();
+ nic.dhcpServer.networkMask = $('#vboxSettingsGlobalNetServerMask').val();
+ nic.dhcpServer.lowerIP = $('#vboxSettingsGlobalNetLower').val();
+ nic.dhcpServer.upperIP = $('#vboxSettingsGlobalNetUpper').val();
+
+ $('#vboxSettingsGlobalNetList').children('li.vboxListItemSelected').first().data('interface',nic);
+
+ $(this).dialog("close");
+};
+buttons[trans('Cancel','QIMessageBox')] = function(){$(this).dialog("close");};
+$('#vboxSettingsGlobalNetEditDialog').dialog({'buttons':buttons,'width':500,'modal':true,'autoOpen':false,'dialogClass':'vboxDialogContent','title':'<img src="images/vbox/nw_16px.png" class="vboxDialogTitleIcon" /> ' +trans('Host-only Network Details','UIGlobalSettingsNetworkDetails')});
+
+
+function vboxSettingsGlobalNetEditDialog() {
+
+ var nic = $('#vboxSettingsGlobalNetList').children('li.vboxListItemSelected').first().data('interface');
+
+ // Set Form Values
+ $('#vboxSettingsGlobalNetIPv4').val(nic.IPAddress);
+ $('#vboxSettingsGlobalNetIPv4Mask').val(nic.networkMask);
+
+ if(nic.IPV6Supported) {
+ $('#vboxSettingsGlobalNetIPv6').prop('disabled',false).val(nic.IPV6Address).closest('tr').find('span').removeClass('vboxDisabled');
+ $('#vboxSettingsGlobalNetIPv6Mask').prop('disabled',false).val(nic.IPV6NetworkMaskPrefixLength).closest('tr').find('span').removeClass('vboxDisabled');
+ } else {
+ $('#vboxSettingsGlobalNetIPv6').prop('disabled',true).val('').closest('tr').find('span').addClass('vboxDisabled');
+ $('#vboxSettingsGlobalNetIPv6Mask').prop('disabled',true).val('').closest('tr').find('span').addClass('vboxDisabled');
+ }
+
+ if(nic.dhcpServer && nic.dhcpServer.networkName) {
+ $('#vboxSettingsGlobalNetServerAddress').val(nic.dhcpServer.IPAddress);
+ $('#vboxSettingsGlobalNetServerMask').val(nic.dhcpServer.networkMask);
+ $('#vboxSettingsGlobalNetLower').val(nic.dhcpServer.lowerIP);
+ $('#vboxSettingsGlobalNetUpper').val(nic.dhcpServer.upperIP);
+ } else {
+ $('#vboxSettingsGlobalNetServerAddress').val('');
+ $('#vboxSettingsGlobalNetServerMask').val('');
+ $('#vboxSettingsGlobalNetLower').val('');
+ $('#vboxSettingsGlobalNetUpper').val('');
+ }
+
+
+ $('#vboxSettingsGlobalNetEdit').tabs('option','active',0);
+ $('#vboxSettingsGlobalNetDHCPEnabled').trigger('click');
+
+ if(nic.dhcpServer && nic.dhcpServer.enabled && !$('#vboxSettingsGlobalNetDHCPEnabled').prop('checked')) {
+ $('#vboxSettingsGlobalNetDHCPEnabled').trigger('click');
+ } else if(nic.dhcpServer && !nic.dhcpServer.enabled && $('#vboxSettingsGlobalNetDHCPEnabled').prop('checked')) {
+ $('#vboxSettingsGlobalNetDHCPEnabled').trigger('click');
+ }
+
+ $('#vboxSettingsGlobalNetEditDialog').dialog('open');
+
+}
+
+/*
+*
+* Edit NAT Network Interface Dialog
+*
+*/
+vboxInitDisplay('vboxSettingsGlobalNATNetworkEditDialog', 'UIGlobalSettingsNetworkDetailsNAT');
+
+var buttons = {};
+buttons[trans('OK','QIMessageBox')] = function(){
+
+ var net = $('#vboxSettingsGlobalNATNetList').children('tr.vboxListItemSelected').first().data('NATNetwork');
+
+ // Get Form Values
+ net.enabled = $('#vboxSettingsGlobalNATNetEnabled').prop('checked');
+ net.networkName = $('#vboxSettingsGlobalNATNetName').val();
+ net.network = $('#vboxSettingsGlobalNATNetNetwork').val();
+ net.needDhcpServer = $('#vboxSettingsGlobalNATNetDHCP').prop('checked');
+ net.IPv6Enabled = $('#vboxSettingsGlobalNATNetIPv6').prop('checked');
+ net.advertiseDefaultIPv6RouteEnabled = $('#vboxSettingsGlobalNATNetIPv6Route').prop('checked');
+ net._modified = true;
+
+ $('#vboxSettingsGlobalNATNetList').children('tr.vboxListItemSelected').first().data('NATNetwork',net).find('input').prop('checked', net.enabled);
+
+ $(this).dialog("close");
+};
+buttons[trans('Cancel','QIMessageBox')] = function(){$(this).dialog("close");};
+$('#vboxSettingsGlobalNATNetworkEditDialog').dialog({'buttons':buttons,'width':500,'modal':true,'autoOpen':false,'dialogClass':'vboxDialogContent','title':'<img src="images/vbox/nw_16px.png" class="vboxDialogTitleIcon" /> ' +trans('Host-only Network Details','UIGlobalSettingsNetworkDetails')});
+$('#vboxSettingsGlobalNATNetIPv6').on('enable',function() {
+ if(this.checked) {
+ $('#vboxSettingsGlobalNATNetIPv6Route').prop('disabled', false).siblings().removeClass('vboxDisabled');
+ } else {
+ $('#vboxSettingsGlobalNATNetIPv6Route').prop('disabled', true).siblings().addClass('vboxDisabled');
+ }
+}).on('click',function(){
+ $(this).trigger('enable');
+});
+
+function vboxSettingsGlobalNATNetworkEditDialog() {
+
+ var net = $('#vboxSettingsGlobalNATNetList').children('tr.vboxListItemSelected').first().data('NATNetwork');
+
+ // Set Form Values
+ $('#vboxSettingsGlobalNATNetEnabled').prop('checked', net.enabled);
+ $('#vboxSettingsGlobalNATNetName').val(net.networkName);
+ $('#vboxSettingsGlobalNATNetNetwork').val(net.network);
+ $('#vboxSettingsGlobalNATNetDHCP').prop('checked', net.needDhcpServer)
+ $('#vboxSettingsGlobalNATNetIPv6').prop('checked', net.IPv6Enabled)
+ $('#vboxSettingsGlobalNATNetIPv6Route').prop('checked', net.advertiseDefaultIPv6RouteEnabled)
+
+ $('#vboxSettingsGlobalNATNetEnabled').triggerHandler('click');
+ $('#vboxSettingsGlobalNATNetIPv6').triggerHandler('click');
+
+ $('#vboxSettingsGlobalNATNetRules').val(trans('Port Forwarding', 'UIGlobalSettingsNetworkDetailsNAT')).off('click').on('click',function(){
+ vboxSettingsGlobalNetworkNatPortForwardingDialog(net, $('#vboxSettingsGlobalNATNetList').children('tr.vboxListItemSelected').first());
+ });
+
+ $('#vboxSettingsGlobalNATNetworkEditDialog').dialog('open');
+
+}
+
+
+function vboxSettingsGlobalNetworkNatPortForwardingDialog(net, row) {
+
+ if($('#vboxSettingsGlobalNetworkNatPortForwardingDialog')[0])
+ $('#vboxSettingsGlobalNetworkNatPortForwardingDialog').empty().remove();
+
+ var l = new vboxLoader();
+ l.addFileToDOM("panes/settingsGlobalNetworkNATPortForwarding.html");
+ l.onLoad = function(){
+
+ vboxSettingsGlobalNetworkNatPortForwardingInit(net.portForwardRules4, false);
+ vboxSettingsGlobalNetworkNatPortForwardingInit(net.portForwardRules6, true);
+
+ var buttons = {};
+ buttons[trans('OK','QIMessageBox')] = function(){
+
+ // wrap ips in []
+ var wrapIp = function(ip) {
+ ip = ip.trim();
+ if(!ip) return '[]';
+ if(ip[0] != '[') $ip = '[' + ip;
+ if(ip[ip.length-1] != ']') ip += ']';
+ return ip;
+ }
+
+ // Get rules
+ var none=0;
+ do {
+ var ruleNum = 4 + (none*2);
+ var rules = $('#vboxSettingsGlobalNetworkNatPortForwardingListIPv'+ruleNum).children('tr');
+ var rulesToPass = new Array();
+ for(var i = 0; i < rules.length; i++) {
+ if($(rules[i]).data('vboxRule')[3] == 0 || $(rules[i]).data('vboxRule')[5] == 0) {
+ vboxAlert(trans("The current port forwarding rules are not valid. " +
+ "None of the host or guest port values may be set to zero.",'UIMessageCenter'));
+ return;
+ }
+
+ rulesToPass[i] = $(rules[i]).data('vboxRule');
+
+ rulesToPass[i][0] = rulesToPass[i][0].replace(':','');
+ rulesToPass[i][2] = wrapIp(rulesToPass[i][2]);
+ rulesToPass[i][4] = wrapIp(rulesToPass[i][4]);
+
+ rulesToPass[i] = rulesToPass[i].join(':');
+ }
+ $('#vboxSettingsGlobalNATNetList').children('tr.vboxListItemSelected').first().data('NATNetwork')['portForwardRules'+ruleNum] = rulesToPass;
+
+ } while(none++ < 1)
+
+ $(this).trigger('close').empty().remove();
+
+
+ };
+ buttons[trans('Cancel','QIMessageBox')] = function(){
+ $(this).trigger('close').empty().remove();
+ };
+
+ vboxInitDisplay($('#vboxSettingsGlobalNetworkNatPortForwardingDialog'), 'UIPortForwardingModel');
+
+ $('#vboxSettingsGlobalNetworkNatPortForwardingDialog').tabs();
+
+ $('#vboxSettingsGlobalNetworkNatPortForwardingDialog').dialog({'closeOnEscape':true,'width':840,'height':400,'buttons':buttons,'modal':true,'autoOpen':true,'dialogClass':'vboxDialogContent','title':'<img src="images/vbox/nw_16px.png" class="vboxDialogTitleIcon" /> ' + trans('Port Forwarding Rules','UIMachineSettingsPortForwardingDlg')}).on("dialogbeforeclose",function(){
+ $(this).parent().find('span:contains("'+trans('Cancel','QIMessageBox')+'")').trigger('click');
+ });
+
+
+ };
+ l.run();
+
+}
+
+/*
+ *
+ * Update Data onSave()
+ *
+ */
+$('#vboxSettingsDialog').on('save',function(){
+
+ $('#vboxSettingsDialog').data('vboxHostOnlyInterfaces').networkInterfaces = new Array();
+
+ $('#vboxSettingsGlobalNetList').children('li').each(function(){
+ $('#vboxSettingsDialog').data('vboxHostOnlyInterfaces').networkInterfaces.push($(this).data('interface'));
+ });
+
+ var nets = [];
+
+ $('#vboxSettingsGlobalNATNetList').children('tr').each(function(){
+ nets.push($(this).data('NATNetwork'));
+ });
+ $('#vboxSettingsDialog').data('vboxNATNetworks',nets);
+
+});
+
+/*
+ * Remove dialogs on close
+ */
+$('#vboxSettingsDialog').on('close',function(){
+ $('#vboxSettingsGlobalNetEditDialog').remove();
+ $('#vboxSettingsGlobalNATNetworkEditDialog').remove();
+});
+
</script> \ No newline at end of file
diff --git a/panes/settingsGlobalUsers.html b/panes/settingsGlobalUsers.html
index 70fad74..65c7b58 100644
--- a/panes/settingsGlobalUsers.html
+++ b/panes/settingsGlobalUsers.html
@@ -1,259 +1,259 @@
-<!--
-
- User list
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: settingsGlobalUsers.html 595 2015-04-17 09:50:36Z imoore76 $
-
- -->
-<div>
-<table style='width: auto; margin-left:auto; margin-right:auto;' class='vboxInvisible'>
- <tr>
- <td colspan='2'><span class='translate'>Users</span>:</td>
- </tr>
- <tr style='vertical-align:top'>
- <td style='width: 400px'>
- <ul id='vboxSettingsUserList' class='vboxBordered vboxList vboxHover' style='width: 400px; margin-top: 0px;'>
- <li>user</li>
- </ul>
- </td>
- <td style='width: 10px' id='vboxSettingsGlobalUsersToolbar'></td>
- </tr>
-</table>
-
-
-<!-- Main Div -->
-</div>
-
-
-<script type='text/javascript'>
-
-/* Build Toolbar */
-
-/*
- * Init Users buttons and toolbar
- */
-
-var sButtons = new Array(
-
- {
- 'name' : 'addUser',
- 'label' : 'Add User',
- 'icon' : 'vm_new',
- 'click' : function () {
-
- var l = new vboxLoader();
- l.addFileToDOM('panes/userEdit.html');
- l.onLoad = function(){
-
- // Set mode
- $('#vboxUserEdit').trigger('setMode','addUser');
-
- var buttons = {};
- buttons[trans('OK','QIMessageBox')] = function() {
- var u = $('#vboxUserEdit').find('input[name=username]').first().val();
- var p1 = $('#vboxUserEdit').find('input[name=npass1]').first().val();
- var p2 = $('#vboxUserEdit').find('input[name=npass2]').first().val();
- var a = $('#vboxUserEdit').find('input[name=admin]').first().prop('checked');
- if(u.length == 0) {
- $(this).remove();
- return;
- }
- if(p1.length == 0 || (p1 != p2)) {
- vboxAlert(trans('The passwords you have entered do not match.','UIUsers'),{'width':'auto'});
- return;
- }
- var dialog = this;
- var chp = new vboxLoader();
- chp.add('addUser',function(d){
- if(d) {
- if(d.success) {
- vboxSettingsGlobalAddUserList({'username':u,'admin':a});
- $(dialog).remove();
- } else {
- vboxAlert(trans('A user with that username already exists.','UIUsers'),{'width':'auto'});
- }
- } else {
- // unknown error
- $(dialog).remove();
- }
- },{'u':u,'p':p1,'a':a});
- chp.run();
- };
- buttons[trans('Cancel','QIMessageBox')] = function(){
- $(this).remove();
- };
- $('#vboxUserEdit').dialog({'closeOnEscape':false,'width':500,'height':220,'buttons':buttons,'modal':true,'autoOpen':true,'dialogClass':'vboxDialogContent','title':'<img src="images/vbox/vm_new_16px.png" class="vboxDialogTitleIcon" /> '+trans('Add User','UIUsers')});
-
- };
- l.run();
- }
- },
-
- {
- 'name' : 'delUser',
- 'label' : 'Remove User',
- 'icon' : 'vm_delete',
- 'noDisabledIcon' : true,
- 'enabled' : function (item) { return (item && $(item).data('username') && $(item).data('username') != $('#vboxPane').data('vboxSession').user); },
- 'click' : function () {
- var buttons = {};
- buttons[trans('OK','QIMessageBox')] = function() {
- var user = $('#vboxSettingsUserList').children('li.vboxListItemSelected').data();
- var l = new vboxLoader();
- l.add('delUser',function(d){
- if(d && d.success) {
- $('#vboxSettingsUserList').children('li.vboxListItemSelected').remove();
- $('#vboxSettingsUserList').trigger('select',null);
- }
- },{'u':user.username});
- l.run();
- $(this).remove();
- };
- var user = $('#vboxSettingsUserList').children('li.vboxListItemSelected').data();
- vboxConfirm(trans('Are you sure you want to remove the user <b>%s</b>? This action cannot be undone.','UIUsers').replace('%s',user.username),buttons);
- }
- },
- {
- 'name' : 'chpwUser',
- 'label' : 'Change Password',
- 'icon' : 'register',
- 'noDisabledIcon' : true,
- 'enabled' : function (item) { return (item && $(item).data('username') && $(item).data('username') == $('#vboxPane').data('vboxSession').user); },
- 'click' : function () {
- var l = new vboxLoader();
- l.addFileToDOM('panes/userEdit.html');
- l.onLoad = function(){
-
- // Set mode
- $('#vboxUserEdit').trigger('setMode','changePassword');
-
- var buttons = {};
- buttons[trans('OK','QIMessageBox')] = function() {
- var o = $('#vboxUserEdit').find('input[name=opass]').first().val();
- var n1 = $('#vboxUserEdit').find('input[name=npass1]').first().val();
- var n2 = $('#vboxUserEdit').find('input[name=npass2]').first().val();
- if(o.length == 0) {
- vboxAlert(trans('The password you have entered is invalid.','UIUsers'),{'width':'auto'});
- return;
- }
- if(n1.length == 0 || (n1 != n2)) {
- vboxAlert(trans('The passwords you have entered do not match.','UIUsers'),{'width':'auto'});
- return;
- }
- var dialog = this;
- var chp = new vboxLoader();
- chp.add('changePassword',function(d){
- if(d) {
- if(d.success) {
- vboxAlert(trans('Password changed.','UIUsers'),{'width':'auto'});
- $(dialog).remove();
- } else {
- vboxAlert(trans('The password you have entered is invalid.','UIUsers'),{'width':'auto'});
- }
- } else {
- // unknown error
- $(dialog).remove();
- }
- },{'old':o,'new':n1});
- chp.run();
- };
- buttons[trans('Cancel','QIMessageBox')] = function(){
- $(this).remove();
- };
- $('#vboxUserEdit').dialog({'closeOnEscape':false,'width':400,'height':200,'buttons':buttons,'modal':true,'autoOpen':true,'dialogClass':'vboxDialogContent','title':'<img src="images/vbox/register_16px.png" class="vboxDialogTitleIcon" /> '+trans('Change Password','UIUsers')});
- };
- l.run();
-
- }
- },
- {
- 'name' : 'editUser',
- 'label' : 'Edit User',
- 'icon' : 'register',
- 'noDisabledIcon' : true,
- 'enabled' : function (item) { return (item && $(item).data('username') && $(item).data('username') != $('#vboxPane').data('vboxSession').user); },
- 'click' : function () {
-
- var l = new vboxLoader();
- l.addFileToDOM('panes/userEdit.html');
- l.onLoad = function(){
-
- // Set mode
- $('#vboxUserEdit').trigger('setMode','editUser');
-
- // Set values
- var user = $('#vboxSettingsUserList').children('li.vboxListItemSelected').data();
- $('#vboxEditUserUsername').html(user.username);
- $('#vboxUserEdit').find('input[name=admin]').first().prop('checked', (user.admin ? true : false));
-
- var buttons = {};
- buttons[trans('OK','QIMessageBox')] = function() {
-
- var p1 = $('#vboxUserEdit').find('input[name=npass1]').first().val();
- var p2 = $('#vboxUserEdit').find('input[name=npass2]').first().val();
- var a = $('#vboxUserEdit').find('input[name=admin]').first().prop('checked');
-
- if(p1.length > 0 && (p1 != p2)) {
- vboxAlert(trans('The passwords you have entered do not match.','UIUsers'),{'width':'auto'});
- return;
- }
- var dialog = this;
- var chp = new vboxLoader();
- chp.add('editUser',function(d){
- if(d && d.success) {
- $('#vboxSettingsUserList').children('li.vboxListItemSelected').data({'admin':a}).html(user.username + (a ? ' ('+trans('Admin User','UIUsers')+')' : ''));
- $(dialog).remove();
- } else {
- // unknown error
- $(dialog).remove();
- }
- },{'u':user.username,'p':p1,'a':a});
- chp.run();
- };
- buttons[trans('Cancel','QIMessageBox')] = function(){
- $(this).remove();
- };
- $('#vboxUserEdit').dialog({'closeOnEscape':false,'width':500,'height':230,'buttons':buttons,'modal':true,'autoOpen':true,'dialogClass':'vboxDialogContent','title':'<img src="images/vbox/register_16px.png" class="vboxDialogTitleIcon" /> '+trans('Edit User','UIUsers')});
-
- };
- l.run();
-
- }
- }
-);
-
-var userToolbar = new vboxToolbarSmall({buttons: sButtons, language_context: 'UIUsers'});
-userToolbar.disabledString = 'dis';
-userToolbar.renderTo('vboxSettingsGlobalUsersToolbar');
-$('#vboxSettingsUserList').on('select', function(e,el){userToolbar.update(el);});
-
-/*
- *
- * Function to fill users
- *
- */
-function vboxSettingsGlobalAddUserList(n) {
-
- $('<li />').attr({'class':'vboxListItem'}).html($('<div />').html(n.username + (n.admin ? ' ('+trans('Admin User','UIUsers')+')' : ''))).hoverClass('vboxHover').data(n).click(function(){
- $(this).parent().children('li.vboxListItemSelected').removeClass('vboxListItemSelected').addClass('vboxListItem');
- $(this).addClass('vboxListItemSelected').removeClass('vboxListItem');
- $('#vboxSettingsUserList').trigger('select',this);
- }).appendTo($('#vboxSettingsUserList'));
-
-}
-
-/*
- *
- * Fill network adapters
- *
- */
-$('#vboxSettingsUserList').children().remove();
-var users = $('#vboxSettingsDialog').data('vboxUsers');
-for(var i in users) {
- vboxSettingsGlobalAddUserList(users[i]);
-}
-$('#vboxSettingsUserList').trigger('select',null);
-
-
+<!--
+
+ User list
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: settingsGlobalUsers.html 595 2015-04-17 09:50:36Z imoore76 $
+
+ -->
+<div>
+<table style='width: auto; margin-left:auto; margin-right:auto;' class='vboxInvisible'>
+ <tr>
+ <td colspan='2'><span class='translate'>Users</span>:</td>
+ </tr>
+ <tr style='vertical-align:top'>
+ <td style='width: 400px'>
+ <ul id='vboxSettingsUserList' class='vboxBordered vboxList vboxHover' style='width: 400px; margin-top: 0px;'>
+ <li>user</li>
+ </ul>
+ </td>
+ <td style='width: 10px' id='vboxSettingsGlobalUsersToolbar'></td>
+ </tr>
+</table>
+
+
+<!-- Main Div -->
+</div>
+
+
+<script type='text/javascript'>
+
+/* Build Toolbar */
+
+/*
+ * Init Users buttons and toolbar
+ */
+
+var sButtons = new Array(
+
+ {
+ 'name' : 'addUser',
+ 'label' : 'Add User',
+ 'icon' : 'vm_new',
+ 'click' : function () {
+
+ var l = new vboxLoader();
+ l.addFileToDOM('panes/userEdit.html');
+ l.onLoad = function(){
+
+ // Set mode
+ $('#vboxUserEdit').trigger('setMode','addUser');
+
+ var buttons = {};
+ buttons[trans('OK','QIMessageBox')] = function() {
+ var u = $('#vboxUserEdit').find('input[name=username]').first().val();
+ var p1 = $('#vboxUserEdit').find('input[name=npass1]').first().val();
+ var p2 = $('#vboxUserEdit').find('input[name=npass2]').first().val();
+ var a = $('#vboxUserEdit').find('input[name=admin]').first().prop('checked');
+ if(u.length == 0) {
+ $(this).remove();
+ return;
+ }
+ if(p1.length == 0 || (p1 != p2)) {
+ vboxAlert(trans('The passwords you have entered do not match.','UIUsers'),{'width':'auto'});
+ return;
+ }
+ var dialog = this;
+ var chp = new vboxLoader();
+ chp.add('addUser',function(d){
+ if(d) {
+ if(d.success) {
+ vboxSettingsGlobalAddUserList({'username':u,'admin':a});
+ $(dialog).remove();
+ } else {
+ vboxAlert(trans('A user with that username already exists.','UIUsers'),{'width':'auto'});
+ }
+ } else {
+ // unknown error
+ $(dialog).remove();
+ }
+ },{'u':u,'p':p1,'a':a});
+ chp.run();
+ };
+ buttons[trans('Cancel','QIMessageBox')] = function(){
+ $(this).remove();
+ };
+ $('#vboxUserEdit').dialog({'closeOnEscape':false,'width':500,'height':220,'buttons':buttons,'modal':true,'autoOpen':true,'dialogClass':'vboxDialogContent','title':'<img src="images/vbox/vm_new_16px.png" class="vboxDialogTitleIcon" /> '+trans('Add User','UIUsers')});
+
+ };
+ l.run();
+ }
+ },
+
+ {
+ 'name' : 'delUser',
+ 'label' : 'Remove User',
+ 'icon' : 'vm_delete',
+ 'noDisabledIcon' : true,
+ 'enabled' : function (item) { return (item && $(item).data('username') && $(item).data('username') != $('#vboxPane').data('vboxSession').user); },
+ 'click' : function () {
+ var buttons = {};
+ buttons[trans('OK','QIMessageBox')] = function() {
+ var user = $('#vboxSettingsUserList').children('li.vboxListItemSelected').data();
+ var l = new vboxLoader();
+ l.add('delUser',function(d){
+ if(d && d.success) {
+ $('#vboxSettingsUserList').children('li.vboxListItemSelected').remove();
+ $('#vboxSettingsUserList').trigger('select',null);
+ }
+ },{'u':user.username});
+ l.run();
+ $(this).remove();
+ };
+ var user = $('#vboxSettingsUserList').children('li.vboxListItemSelected').data();
+ vboxConfirm(trans('Are you sure you want to remove the user <b>%s</b>? This action cannot be undone.','UIUsers').replace('%s',user.username),buttons);
+ }
+ },
+ {
+ 'name' : 'chpwUser',
+ 'label' : 'Change Password',
+ 'icon' : 'register',
+ 'noDisabledIcon' : true,
+ 'enabled' : function (item) { return (item && $(item).data('username') && $(item).data('username') == $('#vboxPane').data('vboxSession').user); },
+ 'click' : function () {
+ var l = new vboxLoader();
+ l.addFileToDOM('panes/userEdit.html');
+ l.onLoad = function(){
+
+ // Set mode
+ $('#vboxUserEdit').trigger('setMode','changePassword');
+
+ var buttons = {};
+ buttons[trans('OK','QIMessageBox')] = function() {
+ var o = $('#vboxUserEdit').find('input[name=opass]').first().val();
+ var n1 = $('#vboxUserEdit').find('input[name=npass1]').first().val();
+ var n2 = $('#vboxUserEdit').find('input[name=npass2]').first().val();
+ if(o.length == 0) {
+ vboxAlert(trans('The password you have entered is invalid.','UIUsers'),{'width':'auto'});
+ return;
+ }
+ if(n1.length == 0 || (n1 != n2)) {
+ vboxAlert(trans('The passwords you have entered do not match.','UIUsers'),{'width':'auto'});
+ return;
+ }
+ var dialog = this;
+ var chp = new vboxLoader();
+ chp.add('changePassword',function(d){
+ if(d) {
+ if(d.success) {
+ vboxAlert(trans('Password changed.','UIUsers'),{'width':'auto'});
+ $(dialog).remove();
+ } else {
+ vboxAlert(trans('The password you have entered is invalid.','UIUsers'),{'width':'auto'});
+ }
+ } else {
+ // unknown error
+ $(dialog).remove();
+ }
+ },{'old':o,'new':n1});
+ chp.run();
+ };
+ buttons[trans('Cancel','QIMessageBox')] = function(){
+ $(this).remove();
+ };
+ $('#vboxUserEdit').dialog({'closeOnEscape':false,'width':400,'height':200,'buttons':buttons,'modal':true,'autoOpen':true,'dialogClass':'vboxDialogContent','title':'<img src="images/vbox/register_16px.png" class="vboxDialogTitleIcon" /> '+trans('Change Password','UIUsers')});
+ };
+ l.run();
+
+ }
+ },
+ {
+ 'name' : 'editUser',
+ 'label' : 'Edit User',
+ 'icon' : 'register',
+ 'noDisabledIcon' : true,
+ 'enabled' : function (item) { return (item && $(item).data('username') && $(item).data('username') != $('#vboxPane').data('vboxSession').user); },
+ 'click' : function () {
+
+ var l = new vboxLoader();
+ l.addFileToDOM('panes/userEdit.html');
+ l.onLoad = function(){
+
+ // Set mode
+ $('#vboxUserEdit').trigger('setMode','editUser');
+
+ // Set values
+ var user = $('#vboxSettingsUserList').children('li.vboxListItemSelected').data();
+ $('#vboxEditUserUsername').html(user.username);
+ $('#vboxUserEdit').find('input[name=admin]').first().prop('checked', (user.admin ? true : false));
+
+ var buttons = {};
+ buttons[trans('OK','QIMessageBox')] = function() {
+
+ var p1 = $('#vboxUserEdit').find('input[name=npass1]').first().val();
+ var p2 = $('#vboxUserEdit').find('input[name=npass2]').first().val();
+ var a = $('#vboxUserEdit').find('input[name=admin]').first().prop('checked');
+
+ if(p1.length > 0 && (p1 != p2)) {
+ vboxAlert(trans('The passwords you have entered do not match.','UIUsers'),{'width':'auto'});
+ return;
+ }
+ var dialog = this;
+ var chp = new vboxLoader();
+ chp.add('editUser',function(d){
+ if(d && d.success) {
+ $('#vboxSettingsUserList').children('li.vboxListItemSelected').data({'admin':a}).html(user.username + (a ? ' ('+trans('Admin User','UIUsers')+')' : ''));
+ $(dialog).remove();
+ } else {
+ // unknown error
+ $(dialog).remove();
+ }
+ },{'u':user.username,'p':p1,'a':a});
+ chp.run();
+ };
+ buttons[trans('Cancel','QIMessageBox')] = function(){
+ $(this).remove();
+ };
+ $('#vboxUserEdit').dialog({'closeOnEscape':false,'width':500,'height':230,'buttons':buttons,'modal':true,'autoOpen':true,'dialogClass':'vboxDialogContent','title':'<img src="images/vbox/register_16px.png" class="vboxDialogTitleIcon" /> '+trans('Edit User','UIUsers')});
+
+ };
+ l.run();
+
+ }
+ }
+);
+
+var userToolbar = new vboxToolbarSmall({buttons: sButtons, language_context: 'UIUsers'});
+userToolbar.disabledString = 'dis';
+userToolbar.renderTo('vboxSettingsGlobalUsersToolbar');
+$('#vboxSettingsUserList').on('select', function(e,el){userToolbar.update(el);});
+
+/*
+ *
+ * Function to fill users
+ *
+ */
+function vboxSettingsGlobalAddUserList(n) {
+
+ $('<li />').attr({'class':'vboxListItem'}).html($('<div />').html(n.username + (n.admin ? ' ('+trans('Admin User','UIUsers')+')' : ''))).hoverClass('vboxHover').data(n).click(function(){
+ $(this).parent().children('li.vboxListItemSelected').removeClass('vboxListItemSelected').addClass('vboxListItem');
+ $(this).addClass('vboxListItemSelected').removeClass('vboxListItem');
+ $('#vboxSettingsUserList').trigger('select',this);
+ }).appendTo($('#vboxSettingsUserList'));
+
+}
+
+/*
+ *
+ * Fill network adapters
+ *
+ */
+$('#vboxSettingsUserList').children().remove();
+var users = $('#vboxSettingsDialog').data('vboxUsers');
+for(var i in users) {
+ vboxSettingsGlobalAddUserList(users[i]);
+}
+$('#vboxSettingsUserList').trigger('select',null);
+
+
</script> \ No newline at end of file
diff --git a/panes/settingsNetwork.html b/panes/settingsNetwork.html
index 526d4f3..a95a6b2 100644
--- a/panes/settingsNetwork.html
+++ b/panes/settingsNetwork.html
@@ -1,529 +1,529 @@
-<!--
-
- VM Network Settings
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: settingsNetwork.html 597 2015-04-20 11:41:28Z imoore76 $
-
--->
-<div id='vboxSettingsTabNetAdapter' title='Adapter' style='display: none'>
-<table class='vboxVertical'>
- <tr>
- <td colspan='2'><label><input name='vboxSettingsNetEnabled' class='vboxCheckbox vboxEnablerCheckbox' type='checkbox' /> <span class='translate'>Enable Network Adapter</span></label></td>
- </tr>
- <tr>
- <th style='min-width: 120px'><span class='translate'>Attached to:</span></th>
- <td style='width: 100%' class='vboxEnablerTrigger'>
- <select name='vboxSettingsNetAttachedTo' onchange='vboxSettingsUpdateNetworkOptions(this);' style='width: 100%'>
- <option value='Null' class='translate'>Not attached</option>
- <option value='NAT' class='translate'>NAT</option>
- <option value='NATNetwork' class='translate'>NAT Network</option>
- <option value='Bridged' class='translate'>Bridged Adapter</option>
- <option value='Internal' class='translate'>Internal Network</option>
- <option value='HostOnly' class='translate'>Host-only Adapter</option>
- <option value='Generic' class='translate'>Generic Driver</option>
- <option value='VDE' class='translate'>VDE Adapter</option>
- </select>
- </td>
- </tr>
- <tr>
- <th class='vboxSettingsNetAdapterNamedLabel'><span class='translate'>Name:</span></th>
- <td>
- <select name='vboxSettingsNetName' class='vboxSettingsNetAdapterNamed' style='width: 100%'>
- <option value=''></option>
-
- </select>
- </td>
- </tr>
-
- <!-- Advanced NAT Settings -->
- <tr class='vboxSettingsAdvancedNat' style='display: none'>
- <th><span class='translate'>NAT Alias Mode:</span></th>
- <td>
- <label><input type='checkbox' class='vboxCheckbox' class='vboxEnablerListen' name='vboxSettingsNetAliasModeProxyOnly' /> <span class='translate vboxEnablerListen'>Proxy Only</span></label><br />
- <label><input type='checkbox' class='vboxCheckbox' class='vboxEnablerListen' name='vboxSettingsNetAliasModeSamePorts' /> <span class='translate vboxEnablerListen'>Same Ports</span></label><br />
- </td>
- </tr>
- <tr class='vboxSettingsAdvancedNat' style='display: none'>
- <th><span class='translate'>Advanced NAT Options</span> :</th>
- <td>
- <label><input type='checkbox' class='vboxCheckbox' class='vboxEnablerListen' name='vboxSettingsNetPassDNSDomain' /> <span class='translate vboxEnablerListen'>Pass DNS Domain</span></label><br />
- <label><input type='checkbox' class='vboxCheckbox' class='vboxEnablerListen' name='vboxSettingsNetDNSProxy' /> <span class='translate vboxEnablerListen'>DNS Proxy</span></label><br />
- <label><input type='checkbox' class='vboxCheckbox' class='vboxEnablerListen' name='vboxSettingsNetUseHostResolver' /> <span class='translate vboxEnablerListen'>Use Host Resolver</span></label><br />
- <span class='translate vboxEnablerListen'>Bind to IP</span> <input type='text' class='vboxTextbox' class='vboxEnablerListen' name='vboxSettingsNetBindIp' size='16'/>
- </td>
- </tr>
-
- <tr>
- <th>
- <input class="netImgAdvanced vboxImgButton" style='background: url(images/rightArrow.png) 3px 2px no-repeat; width: 14px; height: 14px;' type="button" value="" />
- <span class='translate'>Advanced</span></th>
- <td></td>
- </tr>
- <tr class='vboxSettingsNetToggleAdvanced' style='display: none'>
- <th><span class='translate'>Adapter Type:</span></th>
- <td>
- <select name='vboxSettingsNetAdapter' style='width: 100%'>
- </select>
- </td>
- </tr>
- <tr class='vboxSettingsNetToggleAdvanced' style='display: none'>
- <th><span class='translate'>MAC Address:</span></th>
- <td style='white-space: nowrap'><input type='text' class='vboxText' style='width: 200px' name='vboxSettingsNetMAC' size='40' />
- <input class="vboxSettingsNetMacGen vboxImgButton" style='background: url(images/vbox/refresh_16px.png) 1px 1px no-repeat; width: 18px; height: 18px; vertical-align:bottom' type="button" value="" />
- </td>
- </tr>
- <tr class='vboxSettingsNetToggleAdvanced vboxSettingsNetPromiscuousMode' style='display: none'>
- <th class='vboxSettingsNetPromiscuousMode'><span class='translate'>Promiscuous Mode:</span></th>
- <td>
- <select class='vboxSettingsNetPromiscuousMode' name='vboxSettingsNetAdapterPromiscuousMode' style='width: 100%'>
- <option value='Deny'>Deny</option>
- <option value='AllowNetwork'>Allow VMs</option>
- <option value='AllowAll'>Allow All</option>
- </select>
- </td>
- </tr>
- <tr class='vboxSettingsNetToggleAdvanced vboxSettingsNetGenPropsRow' style='display: none'>
- <th><span class='translate vboxRunningEnabled'>Generic Properties:</span></th>
- <td style='white-space: nowrap'>
- <textarea class='vboxRunningEnabled' rows='3' cols='20' name='vboxSettingsNetGenericProps'></textarea>
- </td>
- </tr>
- <tr class='vboxSettingsNetToggleAdvanced' style='display: none'>
- <th></th>
- <td><label><input type='checkbox' class='vboxCheckbox' class='vboxEnablerListen' name='vboxSettingsNetConnected' /> <span class='translate vboxEnablerListen'>Cable Connected</span></label></td>
- </tr>
- <tr class='vboxSettingsNetToggleAdvanced vboxSettingsNetPFButton' style='display: none'>
- <th></th>
- <td><input type='button' class='vboxButton' class='vboxEnablerListen' name='vboxSettingsNetPF' value='Port Forwarding' /></td>
- </tr>
-
-</table>
-</div>
-<script type='text/javascript'>
-
-/* Translations */
-$(document.forms['frmVboxSettings'].vboxSettingsNetAttachedTo).find('option').html(function(i,h){return trans(h,'VBoxGlobal');});
-$(document.forms['frmVboxSettings'].vboxSettingsNetAdapterPromiscuousMode).find('option').html(function(i,h){return trans(h,'VBoxGlobal');});
-$('#vboxSettingsTabNetAdapter').find(".translate").html(function(i,h){return trans($('<div />').html(h).text(),'UIMachineSettingsNetwork');}).removeClass('translate');
-
-/*
- *
- * Setup data for networking options.
- *
- */
-var vboxSettingsNetAdaptersBridged = new Array();
-var vboxSettingsNetAdaptersHostOnly = new Array();
-var vboxSettingsNetNetworks = new Array();
-
-/*
- * Fill Adapter Types
- */
-var nics = $('#vboxSettingsDialog').data('vboxNetworkAdapterTypes');
-for(var i = 1; i < nics.length; i++) { // index 0 is 'Null' and not used
- var opt = new Option(trans(vboxNetworkAdapterType(nics[i]),'VBoxGlobal'),nics[i]);
- document.forms['frmVboxSettings'].vboxSettingsNetAdapter.options[document.forms['frmVboxSettings'].vboxSettingsNetAdapter.options.length] = opt;
-}
-
-
-// Shorthand
-var vboxNetworking = $('#vboxSettingsDialog').data('vboxNetworking');
-vboxNetworking.networkInterfaces = $('#vboxSettingsDialog').data('vboxHostDetails').networkInterfaces;
-
-for(var i = 0; i < vboxNetworking.networkInterfaces.length; i++) {
- if(vboxNetworking.networkInterfaces[i].interfaceType == 'Bridged') {
- vboxSettingsNetAdaptersBridged[vboxSettingsNetAdaptersBridged.length] = vboxNetworking.networkInterfaces[i].name;
- } else if(vboxNetworking.networkInterfaces[i].interfaceType == 'HostOnly') {
- vboxSettingsNetAdaptersHostOnly[vboxSettingsNetAdaptersHostOnly.length] = vboxNetworking.networkInterfaces[i].name;
- } else {
- vboxAlert('Unknown interface type :' + vboxNetworking.networkInterfaces[i].interfaceType);
- }
-}
-
-// Check for sub / virtual interfaces. These will not be reported by VirtualBox
-var vboxGuestNet = $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters;
-for(var i = 0; i < vboxGuestNet.length; i++) {
- if(!vboxGuestNet[i].bridgedInterface || vboxGuestNet[i].bridgedInterface == '') continue;
- if(jQuery.inArray(vboxGuestNet[i].bridgedInterface,vboxSettingsNetAdaptersBridged) < 0) {
- vboxSettingsNetAdaptersBridged[vboxSettingsNetAdaptersBridged.length] = vboxGuestNet[i].bridgedInterface;
- }
-}
-
-
-var vboxSettingsNetTemplate = document.getElementById('vboxSettingsTabNetAdapter');
-var vboxSettingsNetContainer = $(vboxSettingsNetTemplate).parent();
-
-
-/* Network advanced show / hide */
-$('#vboxSettingsTabNetAdapter').find('input.netImgAdvanced').click(function(){
-
- if(!$(this).data('toggleClicked')) {
-
- $(this).data('toggleClicked', true);
- $(this).data('vboxAdvancedEnabled',true);
- $(this).closest('table').find('.vboxSettingsNetToggleAdvanced:not(.vboxForceHide)').css('display','');
- $(this).css('background-image','url(images/downArrow.png)');
-
- } else {
-
- $(this).data('toggleClicked', false);
- $(this).data('vboxAdvancedEnabled',false);
- $(this).closest('table').find('.vboxSettingsNetToggleAdvanced').css('display','none');
- $(this).css('background-image','url(images/rightArrow.png)');
-
- }
-});
-
-/* Mac address generator */
-$('#vboxSettingsTabNetAdapter').find('input.vboxSettingsNetMacGen').click(function(){
-
- var t = $(this).siblings('input').first();
- var oval = $(t).val();
- $(t).val('...').prop('disabled',true);
-
- var l = new vboxLoader();
- l.add('vboxGenerateMacAddress',function(d){
- if(d && d.success) $(t).val(d.responseData);
- else $(t).val(oval);
- $(t).prop('disabled',false);
- });
- l.noLoadingScreen = true;
- l.run();
-});
-
-
-/* Network adapter tab links */
-var ul = $('<ul />');
-$(vboxSettingsNetContainer).append(ul);
-
-for(var i = 0; i < parseInt($('#vboxPane').data('vboxConfig').nicMax); i++) {
-
-
- /* tab */
- $(ul).append($('<li />').html('<a href="#' + vboxSettingsNetTemplate.id + (i + 1) +'"><span>' + trans('Adapter %1','VBoxGlobal').replace('%1',(i + 1)) + '</span></a>'));
-
- /* tab content */
- var newTab = $("#vboxSettingsTabNetAdapter").clone(true);
- newTab.attr({'id':vboxSettingsNetTemplate.id + (i + 1)}).css({'display':'block'}).find('.vboxEnablerTrigger').on('enable',function(){
- $(this).children('select').first().trigger('change');
- });
- newTab.appendTo(vboxSettingsNetContainer);
-
- /* Form elements must be unique */
- $("#vboxSettingsTabNetAdapter" + (i + 1)).find('[name]').each(function() {
- $(this).attr('name',$(this).attr('name') + (i + 1));
- });
-
-}
-
-
-/* Remove Template */
-$("#vboxSettingsTabNetAdapter").empty().remove();
-
-
-/* preload network 'advanced' down arrow image */
-var netDnAdvImg = new Image();
-netDnAdvImg.src = 'images/downArrow.png';
-
-/*
- * Called when network adpater 'attached to' changes
- */
-function vboxSettingsUpdateNetworkOptions(sel) {
-
- var ptable = $(sel).closest('table');
- var th = $(ptable).find('th.vboxSettingsNetAdapterNamedLabel').first();
- var nsel = $(ptable).find('.vboxSettingsNetAdapterNamed').first();
-
- var advEnabled = ptable.find('input.netImgAdvanced').first().data('vboxAdvancedEnabled');
-
- // Promiscuous mode selection
- if(sel.value == 'NAT' || sel.value == 'Null' || sel.value == 'Generic') {
- $(ptable).find('tr.vboxSettingsNetPromiscuousMode').addClass('vboxForceHide').hide();
- } else {
- $(ptable).find('tr.vboxSettingsNetPromiscuousMode').removeClass('vboxForceHide');
- if(advEnabled) $(ptable).find('tr.vboxSettingsNetPromiscuousMode').show();
- }
-
- // Generic properties
- if(sel.value == 'Generic') {
- $(ptable).find('tr.vboxSettingsNetGenPropsRow').removeClass('vboxForceHide');
- if(advEnabled) $(ptable).find('tr.vboxSettingsNetGenPropsRow').show();
- } else {
- $(ptable).find('tr.vboxSettingsNetGenPropsRow').hide().addClass('vboxForceHide');
- }
-
- // Port forward button
- if(sel.value == 'NAT') {
- $(ptable).find('tr.vboxSettingsNetPFButton').removeClass('vboxForceHide');
- if(advEnabled) $(ptable).find('tr.vboxSettingsNetPFButton').show();
- } else {
- $(ptable).find('tr.vboxSettingsNetPFButton').addClass('vboxForceHide').hide();
- }
-
- // Name box
- if(sel.value == 'Null' || sel.value == 'NAT') {
-
- $(th).addClass('vboxDisabled');
-
- $(nsel).children().remove();
- $(nsel).prop('disabled',true);
-
- if(sel.value == 'NAT' && $('#vboxPane').data('vboxConfig').enableAdvancedConfig) ptable.find('tr.vboxSettingsAdvancedNat').css('display','');
- else ptable.find('tr.vboxSettingsAdvancedNat').css('display','none');
-
-
- } else {
-
- ptable.find('tr.vboxSettingsAdvancedNat').css('display','none');
-
- $(th).removeClass('vboxDisabled');
-
- $(nsel).children().remove();
- $(nsel).prop('disabled',false);
-
- // Special case for certian network selects
- if(sel.value == 'Internal' || sel.value == 'VDE' || sel.value=='Generic' || sel.value=='Bridged' || sel.value=='NATNetwork') {
- var isel = $(nsel).clone(false);
- $(nsel).replaceWith(isel);
- nsel = isel;
- }
-
- var defaultSel = $(sel).data('vboxDefault');
-
- switch(sel.value) {
- case 'Bridged':
- src = vboxSettingsNetAdaptersBridged;
- break;
- case 'HostOnly':
- src = vboxSettingsNetAdaptersHostOnly;
- break;
- case 'Internal':
- src = $('#vboxSettingsDialog').data('vboxNetworking').networks;
- break;
- case 'Generic':
- src = $('#vboxSettingsDialog').data('vboxNetworking').genericDrivers;
- break;
- case 'NATNetwork':
- src = $('#vboxSettingsDialog').data('vboxNetworking').natNetworks;
- break;
- case 'VDE':
- src = $('#vboxSettingsDialog').data('vboxNetworking').vdenetworks;
- break;
- default:
- vboxAlert('Unknown network binding type: ' + sel.value);
- }
-
- for(var i = 0; i < src.length; i++) {
- var hSrc = $('<div />').text(src[i]).html();
- $(nsel).append('<option ' + (src[i] == defaultSel ? ' selected ' : '') + ' value="' + hSrc + '">' + hSrc + '</option>');
- }
- }
-
- // Special case for Internal, Generic, and VDE network selects
- if(sel.value == 'Internal' || sel.value == 'VDE' || sel.value == 'Generic' || sel.value == 'Bridged') {
- $(nsel).jec();
- }
-
-}
-
-/* Change settings onShow() when VM is running */
-$('#vboxSettingsDialog').on('dataLoaded',function(){
-
-
- /* Net values */
- var vboxVDEFound = false; // check for VDE attachments
- for(var i = 0; i < parseInt($('#vboxPane').data('vboxConfig').nicMax); i++) {
-
- var a = (i + 1);
-
- // attached to
- $(document.forms['frmVboxSettings'].elements['vboxSettingsNetAttachedTo'+a]).val($('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].attachmentType).trigger('change');
- $(document.forms['frmVboxSettings'].elements['vboxSettingsNetAttachedTo'+a].options[document.forms['frmVboxSettings'].elements['vboxSettingsNetAttachedTo'+a].selectedIndex]).attr('selected','selected');
- $(document.forms['frmVboxSettings'].elements['vboxSettingsNetAttachedTo'+a]).change();
-
- // Device or network name, depending on what 'attached to' is
- var netName = '';
- switch($('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].attachmentType) {
- case 'Bridged':
- netName = $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].bridgedInterface;
- break;
- case 'HostOnly':
- netName = $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].hostOnlyInterface;
- break;
- case 'Internal':
- netName = $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].internalNetwork;
- break;
- case 'Generic':
- netName = $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].genericDriver;
- break;
- case 'NATNetwork':
- netName = $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATNetwork;
- break;
- case 'VDE':
- netName = $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].VDENetwork;
- vboxVDEFound = true;
- break;
- }
-
- // hold default value
- $(document.forms['frmVboxSettings'].elements['vboxSettingsNetAttachedTo'+a]).data('vboxDefault', netName);
-
- document.forms['frmVboxSettings'].elements['vboxSettingsNetName'+a].value = netName;
-
- document.forms['frmVboxSettings'].elements['vboxSettingsNetAdapter'+a].value = $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].adapterType;
- document.forms['frmVboxSettings'].elements['vboxSettingsNetMAC'+a].value = $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].MACAddress;
- document.forms['frmVboxSettings'].elements['vboxSettingsNetConnected'+a].checked = ($('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].cableConnected ? true : false);
- $(document.forms['frmVboxSettings'].elements['vboxSettingsNetAdapterPromiscuousMode'+a]).val($('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].promiscModePolicy);
-
- document.forms['frmVboxSettings'].elements['vboxSettingsNetGenericProps'+a].innerHTML = $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].properties;
-
- // Enabled adapter
- $(document.forms['frmVboxSettings'].elements['vboxSettingsNetEnabled'+a]).prop('checked',$('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].enabled).triggerHandler('click');;
-
-
- $(document.forms['frmVboxSettings'].elements['vboxSettingsNetPF'+a]).unbind('click');
- $(document.forms['frmVboxSettings'].elements['vboxSettingsNetPF'+a]).click(function(){
-
- var nicIndex = (parseInt($(this).attr('name').substr(17))-1);
-
- $.when(vboxPortForwardConfigDialog($('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[nicIndex].redirects))
- .done(function(rules){
- for(var i = 0; i < rules.length; i++) {
- rules[i] = rules[i].join(',');
- }
- $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[nicIndex].redirects = rules;
- });
-
- }).val(trans('Port Forwarding','UIMachineSettingsNetwork'));
-
- // Set Nat values
- if($('#vboxPane').data('vboxConfig').enableAdvancedConfig) {
- document.forms['frmVboxSettings'].elements['vboxSettingsNetAliasModeProxyOnly'+a].checked = (($('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATEngine.aliasMode & 2) ? true : false);
- document.forms['frmVboxSettings'].elements['vboxSettingsNetAliasModeSamePorts'+a].checked = (($('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATEngine.aliasMode & 4) ? true : false);
- document.forms['frmVboxSettings'].elements['vboxSettingsNetPassDNSDomain'+a].checked = ($('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATEngine.DNSPassDomain ? true : false);
- document.forms['frmVboxSettings'].elements['vboxSettingsNetDNSProxy'+a].checked = ($('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATEngine.DNSProxy ? true : false);
- document.forms['frmVboxSettings'].elements['vboxSettingsNetUseHostResolver'+a].checked = ($('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATEngine.DNSUseHostResolver ? true : false);
- $(document.forms['frmVboxSettings'].elements['vboxSettingsNetBindIp'+a]).val($('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATEngine.hostIP);
- }
-
-
- }
- /* Disable VDE selection? */
- if(!vboxVDEFound && !$('#vboxPane').data('vboxConfig').enableVDE) {
- for(var i = 0; i < parseInt($('#vboxPane').data('vboxConfig').nicMax); i++) {
- $(document.forms['frmVboxSettings'].elements['vboxSettingsNetAttachedTo'+(i+1)]).children("[value='VDE']").remove();
- }
- }
-
- if(!$('#vboxSettingsDialog').data('vboxFullEdit')) {
-
- for(var i = 0; i < parseInt($('#vboxPane').data('vboxConfig').nicMax); i++) {
-
- var a = (i + 1);
-
- /* Disable these inputs */
- document.forms['frmVboxSettings'].elements['vboxSettingsNetEnabled'+a].disabled ='disabled';
- document.forms['frmVboxSettings'].elements['vboxSettingsNetAdapter'+a].disabled ='disabled';
- document.forms['frmVboxSettings'].elements['vboxSettingsNetMAC'+a].disabled ='disabled';
- $(document.forms['frmVboxSettings'].elements['vboxSettingsNetMAC'+a]).siblings('input').css('display','none');
-
- /* Disable these labels */
- $(document.forms['frmVboxSettings'].elements['vboxSettingsNetEnabled'+a]).closest('tr').children().addClass('vboxDisabled');
- $(document.forms['frmVboxSettings'].elements['vboxSettingsNetAdapter'+a]).closest('tr').children().addClass('vboxDisabled');
- $(document.forms['frmVboxSettings'].elements['vboxSettingsNetMAC'+a]).closest('tr').children().addClass('vboxDisabled');
-
- }
- // Expand all advanced settings
- $('#vboxSettingsDialog').find('input.netImgAdvanced').each(function(){
- if(!$(this).data('vboxAdvancedEnabled')) $(this).trigger('click');
- });
-
- // Disable mac address generation
- $('#vboxSettingsDialog').find('input.vboxSettingsNetMacGen').prop('disabled',true);
-
- } else {
-
- for(var i = 0; i < parseInt($('#vboxPane').data('vboxConfig').nicMax); i++) {
-
- var a = (i + 1);
-
- /* Enable these inputs */
- document.forms['frmVboxSettings'].elements['vboxSettingsNetEnabled'+a].disabled ='';
- document.forms['frmVboxSettings'].elements['vboxSettingsNetAdapter'+a].disabled ='';
- document.forms['frmVboxSettings'].elements['vboxSettingsNetMAC'+a].disabled ='';
- $(document.forms['frmVboxSettings'].elements['vboxSettingsNetMAC'+a]).siblings('input').css('display','');
-
- /* Enable these labels */
- $(document.forms['frmVboxSettings'].elements['vboxSettingsNetEnabled'+a]).closest('tr').children().removeClass('vboxDisabled');
- $(document.forms['frmVboxSettings'].elements['vboxSettingsNetAdapter'+a]).closest('tr').children().removeClass('vboxDisabled');
- $(document.forms['frmVboxSettings'].elements['vboxSettingsNetMAC'+a]).closest('tr').children().removeClass('vboxDisabled');
-
- }
-
- // Enable mac address generation
- $('#vboxSettingsDialog').find('input.vboxSettingsNetMacGen').prop('disabled',false);
-
- }
-
-/* Change settings onSave() */
-}).on('save',function(){
-
- /* Net */
- for(var i = 0; i < parseInt($('#vboxPane').data('vboxConfig').nicMax); i++) {
-
- var a = (i + 1);
-
- // attached to
- $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].attachmentType = document.forms['frmVboxSettings'].elements['vboxSettingsNetAttachedTo'+a].value;
-
- // Device or network name, depending on what 'attached to' is
- switch($('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].attachmentType) {
- case 'Bridged':
- $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].bridgedInterface = document.forms['frmVboxSettings'].elements['vboxSettingsNetName'+a].value;;
- case 'HostOnly':
- $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].hostOnlyInterface = document.forms['frmVboxSettings'].elements['vboxSettingsNetName'+a].value;;
- break;
- case 'Generic':
- $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].genericDriver = document.forms['frmVboxSettings'].elements['vboxSettingsNetName'+a].value;
- break;
- case 'Internal':
- $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].internalNetwork = document.forms['frmVboxSettings'].elements['vboxSettingsNetName'+a].value;
- break;
- case 'NATNetwork':
- $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATNetwork = document.forms['frmVboxSettings'].elements['vboxSettingsNetName'+a].value;
- break;
- case 'VDE':
- $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].VDENetwork = document.forms['frmVboxSettings'].elements['vboxSettingsNetName'+a].value;
- break;
- }
-
- // Set Nat values
- if($('#vboxPane').data('vboxConfig').enableAdvancedConfig) {
- var aliasMode = $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATEngine.aliasMode & 1;
- if(document.forms['frmVboxSettings'].elements['vboxSettingsNetAliasModeProxyOnly'+a].checked) {
- aliasMode |= 2;
- }
- if(document.forms['frmVboxSettings'].elements['vboxSettingsNetAliasModeSamePorts'+a].checked) {
- aliasMode |= 4;
- }
- $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATEngine.aliasMode = aliasMode;
- $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATEngine.DNSPassDomain = document.forms['frmVboxSettings'].elements['vboxSettingsNetPassDNSDomain'+a].checked;
- $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATEngine.DNSProxy = document.forms['frmVboxSettings'].elements['vboxSettingsNetDNSProxy'+a].checked;
- $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATEngine.DNSUseHostResolver = document.forms['frmVboxSettings'].elements['vboxSettingsNetUseHostResolver'+a].checked;
- $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATEngine.hostIP = $(document.forms['frmVboxSettings'].elements['vboxSettingsNetBindIp'+a]).val();
- }
-
- $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].properties = $(document.forms['frmVboxSettings'].elements['vboxSettingsNetGenericProps'+a]).val();
- $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].promiscModePolicy = $(document.forms['frmVboxSettings'].elements['vboxSettingsNetAdapterPromiscuousMode'+a]).val();
- $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].adapterType = document.forms['frmVboxSettings'].elements['vboxSettingsNetAdapter'+a].value;
- $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].MACAddress = document.forms['frmVboxSettings'].elements['vboxSettingsNetMAC'+a].value;
- $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].cableConnected = document.forms['frmVboxSettings'].elements['vboxSettingsNetConnected'+a].checked;
- $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].enabled = document.forms['frmVboxSettings'].elements['vboxSettingsNetEnabled'+a].checked;
-
- }
-
-});
-
-</script>
-
-
+<!--
+
+ VM Network Settings
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: settingsNetwork.html 597 2015-04-20 11:41:28Z imoore76 $
+
+-->
+<div id='vboxSettingsTabNetAdapter' title='Adapter' style='display: none'>
+<table class='vboxVertical'>
+ <tr>
+ <td colspan='2'><label><input name='vboxSettingsNetEnabled' class='vboxCheckbox vboxEnablerCheckbox' type='checkbox' /> <span class='translate'>Enable Network Adapter</span></label></td>
+ </tr>
+ <tr>
+ <th style='min-width: 120px'><span class='translate'>Attached to:</span></th>
+ <td style='width: 100%' class='vboxEnablerTrigger'>
+ <select name='vboxSettingsNetAttachedTo' onchange='vboxSettingsUpdateNetworkOptions(this);' style='width: 100%'>
+ <option value='Null' class='translate'>Not attached</option>
+ <option value='NAT' class='translate'>NAT</option>
+ <option value='NATNetwork' class='translate'>NAT Network</option>
+ <option value='Bridged' class='translate'>Bridged Adapter</option>
+ <option value='Internal' class='translate'>Internal Network</option>
+ <option value='HostOnly' class='translate'>Host-only Adapter</option>
+ <option value='Generic' class='translate'>Generic Driver</option>
+ <option value='VDE' class='translate'>VDE Adapter</option>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <th class='vboxSettingsNetAdapterNamedLabel'><span class='translate'>Name:</span></th>
+ <td>
+ <select name='vboxSettingsNetName' class='vboxSettingsNetAdapterNamed' style='width: 100%'>
+ <option value=''></option>
+
+ </select>
+ </td>
+ </tr>
+
+ <!-- Advanced NAT Settings -->
+ <tr class='vboxSettingsAdvancedNat' style='display: none'>
+ <th><span class='translate'>NAT Alias Mode:</span></th>
+ <td>
+ <label><input type='checkbox' class='vboxCheckbox' class='vboxEnablerListen' name='vboxSettingsNetAliasModeProxyOnly' /> <span class='translate vboxEnablerListen'>Proxy Only</span></label><br />
+ <label><input type='checkbox' class='vboxCheckbox' class='vboxEnablerListen' name='vboxSettingsNetAliasModeSamePorts' /> <span class='translate vboxEnablerListen'>Same Ports</span></label><br />
+ </td>
+ </tr>
+ <tr class='vboxSettingsAdvancedNat' style='display: none'>
+ <th><span class='translate'>Advanced NAT Options</span> :</th>
+ <td>
+ <label><input type='checkbox' class='vboxCheckbox' class='vboxEnablerListen' name='vboxSettingsNetPassDNSDomain' /> <span class='translate vboxEnablerListen'>Pass DNS Domain</span></label><br />
+ <label><input type='checkbox' class='vboxCheckbox' class='vboxEnablerListen' name='vboxSettingsNetDNSProxy' /> <span class='translate vboxEnablerListen'>DNS Proxy</span></label><br />
+ <label><input type='checkbox' class='vboxCheckbox' class='vboxEnablerListen' name='vboxSettingsNetUseHostResolver' /> <span class='translate vboxEnablerListen'>Use Host Resolver</span></label><br />
+ <span class='translate vboxEnablerListen'>Bind to IP</span> <input type='text' class='vboxTextbox' class='vboxEnablerListen' name='vboxSettingsNetBindIp' size='16'/>
+ </td>
+ </tr>
+
+ <tr>
+ <th>
+ <input class="netImgAdvanced vboxImgButton" style='background: url(images/rightArrow.png) 3px 2px no-repeat; width: 14px; height: 14px;' type="button" value="" />
+ <span class='translate'>Advanced</span></th>
+ <td></td>
+ </tr>
+ <tr class='vboxSettingsNetToggleAdvanced' style='display: none'>
+ <th><span class='translate'>Adapter Type:</span></th>
+ <td>
+ <select name='vboxSettingsNetAdapter' style='width: 100%'>
+ </select>
+ </td>
+ </tr>
+ <tr class='vboxSettingsNetToggleAdvanced' style='display: none'>
+ <th><span class='translate'>MAC Address:</span></th>
+ <td style='white-space: nowrap'><input type='text' class='vboxText' style='width: 200px' name='vboxSettingsNetMAC' size='40' />
+ <input class="vboxSettingsNetMacGen vboxImgButton" style='background: url(images/vbox/refresh_16px.png) 1px 1px no-repeat; width: 18px; height: 18px; vertical-align:bottom' type="button" value="" />
+ </td>
+ </tr>
+ <tr class='vboxSettingsNetToggleAdvanced vboxSettingsNetPromiscuousMode' style='display: none'>
+ <th class='vboxSettingsNetPromiscuousMode'><span class='translate'>Promiscuous Mode:</span></th>
+ <td>
+ <select class='vboxSettingsNetPromiscuousMode' name='vboxSettingsNetAdapterPromiscuousMode' style='width: 100%'>
+ <option value='Deny'>Deny</option>
+ <option value='AllowNetwork'>Allow VMs</option>
+ <option value='AllowAll'>Allow All</option>
+ </select>
+ </td>
+ </tr>
+ <tr class='vboxSettingsNetToggleAdvanced vboxSettingsNetGenPropsRow' style='display: none'>
+ <th><span class='translate vboxRunningEnabled'>Generic Properties:</span></th>
+ <td style='white-space: nowrap'>
+ <textarea class='vboxRunningEnabled' rows='3' cols='20' name='vboxSettingsNetGenericProps'></textarea>
+ </td>
+ </tr>
+ <tr class='vboxSettingsNetToggleAdvanced' style='display: none'>
+ <th></th>
+ <td><label><input type='checkbox' class='vboxCheckbox' class='vboxEnablerListen' name='vboxSettingsNetConnected' /> <span class='translate vboxEnablerListen'>Cable Connected</span></label></td>
+ </tr>
+ <tr class='vboxSettingsNetToggleAdvanced vboxSettingsNetPFButton' style='display: none'>
+ <th></th>
+ <td><input type='button' class='vboxButton' class='vboxEnablerListen' name='vboxSettingsNetPF' value='Port Forwarding' /></td>
+ </tr>
+
+</table>
+</div>
+<script type='text/javascript'>
+
+/* Translations */
+$(document.forms['frmVboxSettings'].vboxSettingsNetAttachedTo).find('option').html(function(i,h){return trans(h,'VBoxGlobal');});
+$(document.forms['frmVboxSettings'].vboxSettingsNetAdapterPromiscuousMode).find('option').html(function(i,h){return trans(h,'VBoxGlobal');});
+$('#vboxSettingsTabNetAdapter').find(".translate").html(function(i,h){return trans($('<div />').html(h).text(),'UIMachineSettingsNetwork');}).removeClass('translate');
+
+/*
+ *
+ * Setup data for networking options.
+ *
+ */
+var vboxSettingsNetAdaptersBridged = new Array();
+var vboxSettingsNetAdaptersHostOnly = new Array();
+var vboxSettingsNetNetworks = new Array();
+
+/*
+ * Fill Adapter Types
+ */
+var nics = $('#vboxSettingsDialog').data('vboxNetworkAdapterTypes');
+for(var i = 1; i < nics.length; i++) { // index 0 is 'Null' and not used
+ var opt = new Option(trans(vboxNetworkAdapterType(nics[i]),'VBoxGlobal'),nics[i]);
+ document.forms['frmVboxSettings'].vboxSettingsNetAdapter.options[document.forms['frmVboxSettings'].vboxSettingsNetAdapter.options.length] = opt;
+}
+
+
+// Shorthand
+var vboxNetworking = $('#vboxSettingsDialog').data('vboxNetworking');
+vboxNetworking.networkInterfaces = $('#vboxSettingsDialog').data('vboxHostDetails').networkInterfaces;
+
+for(var i = 0; i < vboxNetworking.networkInterfaces.length; i++) {
+ if(vboxNetworking.networkInterfaces[i].interfaceType == 'Bridged') {
+ vboxSettingsNetAdaptersBridged[vboxSettingsNetAdaptersBridged.length] = vboxNetworking.networkInterfaces[i].name;
+ } else if(vboxNetworking.networkInterfaces[i].interfaceType == 'HostOnly') {
+ vboxSettingsNetAdaptersHostOnly[vboxSettingsNetAdaptersHostOnly.length] = vboxNetworking.networkInterfaces[i].name;
+ } else {
+ vboxAlert('Unknown interface type :' + vboxNetworking.networkInterfaces[i].interfaceType);
+ }
+}
+
+// Check for sub / virtual interfaces. These will not be reported by VirtualBox
+var vboxGuestNet = $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters;
+for(var i = 0; i < vboxGuestNet.length; i++) {
+ if(!vboxGuestNet[i].bridgedInterface || vboxGuestNet[i].bridgedInterface == '') continue;
+ if(jQuery.inArray(vboxGuestNet[i].bridgedInterface,vboxSettingsNetAdaptersBridged) < 0) {
+ vboxSettingsNetAdaptersBridged[vboxSettingsNetAdaptersBridged.length] = vboxGuestNet[i].bridgedInterface;
+ }
+}
+
+
+var vboxSettingsNetTemplate = document.getElementById('vboxSettingsTabNetAdapter');
+var vboxSettingsNetContainer = $(vboxSettingsNetTemplate).parent();
+
+
+/* Network advanced show / hide */
+$('#vboxSettingsTabNetAdapter').find('input.netImgAdvanced').click(function(){
+
+ if(!$(this).data('toggleClicked')) {
+
+ $(this).data('toggleClicked', true);
+ $(this).data('vboxAdvancedEnabled',true);
+ $(this).closest('table').find('.vboxSettingsNetToggleAdvanced:not(.vboxForceHide)').css('display','');
+ $(this).css('background-image','url(images/downArrow.png)');
+
+ } else {
+
+ $(this).data('toggleClicked', false);
+ $(this).data('vboxAdvancedEnabled',false);
+ $(this).closest('table').find('.vboxSettingsNetToggleAdvanced').css('display','none');
+ $(this).css('background-image','url(images/rightArrow.png)');
+
+ }
+});
+
+/* Mac address generator */
+$('#vboxSettingsTabNetAdapter').find('input.vboxSettingsNetMacGen').click(function(){
+
+ var t = $(this).siblings('input').first();
+ var oval = $(t).val();
+ $(t).val('...').prop('disabled',true);
+
+ var l = new vboxLoader();
+ l.add('vboxGenerateMacAddress',function(d){
+ if(d && d.success) $(t).val(d.responseData);
+ else $(t).val(oval);
+ $(t).prop('disabled',false);
+ });
+ l.noLoadingScreen = true;
+ l.run();
+});
+
+
+/* Network adapter tab links */
+var ul = $('<ul />');
+$(vboxSettingsNetContainer).append(ul);
+
+for(var i = 0; i < parseInt($('#vboxPane').data('vboxConfig').nicMax); i++) {
+
+
+ /* tab */
+ $(ul).append($('<li />').html('<a href="#' + vboxSettingsNetTemplate.id + (i + 1) +'"><span>' + trans('Adapter %1','VBoxGlobal').replace('%1',(i + 1)) + '</span></a>'));
+
+ /* tab content */
+ var newTab = $("#vboxSettingsTabNetAdapter").clone(true);
+ newTab.attr({'id':vboxSettingsNetTemplate.id + (i + 1)}).css({'display':'block'}).find('.vboxEnablerTrigger').on('enable',function(){
+ $(this).children('select').first().trigger('change');
+ });
+ newTab.appendTo(vboxSettingsNetContainer);
+
+ /* Form elements must be unique */
+ $("#vboxSettingsTabNetAdapter" + (i + 1)).find('[name]').each(function() {
+ $(this).attr('name',$(this).attr('name') + (i + 1));
+ });
+
+}
+
+
+/* Remove Template */
+$("#vboxSettingsTabNetAdapter").empty().remove();
+
+
+/* preload network 'advanced' down arrow image */
+var netDnAdvImg = new Image();
+netDnAdvImg.src = 'images/downArrow.png';
+
+/*
+ * Called when network adpater 'attached to' changes
+ */
+function vboxSettingsUpdateNetworkOptions(sel) {
+
+ var ptable = $(sel).closest('table');
+ var th = $(ptable).find('th.vboxSettingsNetAdapterNamedLabel').first();
+ var nsel = $(ptable).find('.vboxSettingsNetAdapterNamed').first();
+
+ var advEnabled = ptable.find('input.netImgAdvanced').first().data('vboxAdvancedEnabled');
+
+ // Promiscuous mode selection
+ if(sel.value == 'NAT' || sel.value == 'Null' || sel.value == 'Generic') {
+ $(ptable).find('tr.vboxSettingsNetPromiscuousMode').addClass('vboxForceHide').hide();
+ } else {
+ $(ptable).find('tr.vboxSettingsNetPromiscuousMode').removeClass('vboxForceHide');
+ if(advEnabled) $(ptable).find('tr.vboxSettingsNetPromiscuousMode').show();
+ }
+
+ // Generic properties
+ if(sel.value == 'Generic') {
+ $(ptable).find('tr.vboxSettingsNetGenPropsRow').removeClass('vboxForceHide');
+ if(advEnabled) $(ptable).find('tr.vboxSettingsNetGenPropsRow').show();
+ } else {
+ $(ptable).find('tr.vboxSettingsNetGenPropsRow').hide().addClass('vboxForceHide');
+ }
+
+ // Port forward button
+ if(sel.value == 'NAT') {
+ $(ptable).find('tr.vboxSettingsNetPFButton').removeClass('vboxForceHide');
+ if(advEnabled) $(ptable).find('tr.vboxSettingsNetPFButton').show();
+ } else {
+ $(ptable).find('tr.vboxSettingsNetPFButton').addClass('vboxForceHide').hide();
+ }
+
+ // Name box
+ if(sel.value == 'Null' || sel.value == 'NAT') {
+
+ $(th).addClass('vboxDisabled');
+
+ $(nsel).children().remove();
+ $(nsel).prop('disabled',true);
+
+ if(sel.value == 'NAT' && $('#vboxPane').data('vboxConfig').enableAdvancedConfig) ptable.find('tr.vboxSettingsAdvancedNat').css('display','');
+ else ptable.find('tr.vboxSettingsAdvancedNat').css('display','none');
+
+
+ } else {
+
+ ptable.find('tr.vboxSettingsAdvancedNat').css('display','none');
+
+ $(th).removeClass('vboxDisabled');
+
+ $(nsel).children().remove();
+ $(nsel).prop('disabled',false);
+
+ // Special case for certian network selects
+ if(sel.value == 'Internal' || sel.value == 'VDE' || sel.value=='Generic' || sel.value=='Bridged' || sel.value=='NATNetwork') {
+ var isel = $(nsel).clone(false);
+ $(nsel).replaceWith(isel);
+ nsel = isel;
+ }
+
+ var defaultSel = $(sel).data('vboxDefault');
+
+ switch(sel.value) {
+ case 'Bridged':
+ src = vboxSettingsNetAdaptersBridged;
+ break;
+ case 'HostOnly':
+ src = vboxSettingsNetAdaptersHostOnly;
+ break;
+ case 'Internal':
+ src = $('#vboxSettingsDialog').data('vboxNetworking').networks;
+ break;
+ case 'Generic':
+ src = $('#vboxSettingsDialog').data('vboxNetworking').genericDrivers;
+ break;
+ case 'NATNetwork':
+ src = $('#vboxSettingsDialog').data('vboxNetworking').natNetworks;
+ break;
+ case 'VDE':
+ src = $('#vboxSettingsDialog').data('vboxNetworking').vdenetworks;
+ break;
+ default:
+ vboxAlert('Unknown network binding type: ' + sel.value);
+ }
+
+ for(var i = 0; i < src.length; i++) {
+ var hSrc = $('<div />').text(src[i]).html();
+ $(nsel).append('<option ' + (src[i] == defaultSel ? ' selected ' : '') + ' value="' + hSrc + '">' + hSrc + '</option>');
+ }
+ }
+
+ // Special case for Internal, Generic, and VDE network selects
+ if(sel.value == 'Internal' || sel.value == 'VDE' || sel.value == 'Generic' || sel.value == 'Bridged') {
+ $(nsel).jec();
+ }
+
+}
+
+/* Change settings onShow() when VM is running */
+$('#vboxSettingsDialog').on('dataLoaded',function(){
+
+
+ /* Net values */
+ var vboxVDEFound = false; // check for VDE attachments
+ for(var i = 0; i < parseInt($('#vboxPane').data('vboxConfig').nicMax); i++) {
+
+ var a = (i + 1);
+
+ // attached to
+ $(document.forms['frmVboxSettings'].elements['vboxSettingsNetAttachedTo'+a]).val($('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].attachmentType).trigger('change');
+ $(document.forms['frmVboxSettings'].elements['vboxSettingsNetAttachedTo'+a].options[document.forms['frmVboxSettings'].elements['vboxSettingsNetAttachedTo'+a].selectedIndex]).attr('selected','selected');
+ $(document.forms['frmVboxSettings'].elements['vboxSettingsNetAttachedTo'+a]).change();
+
+ // Device or network name, depending on what 'attached to' is
+ var netName = '';
+ switch($('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].attachmentType) {
+ case 'Bridged':
+ netName = $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].bridgedInterface;
+ break;
+ case 'HostOnly':
+ netName = $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].hostOnlyInterface;
+ break;
+ case 'Internal':
+ netName = $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].internalNetwork;
+ break;
+ case 'Generic':
+ netName = $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].genericDriver;
+ break;
+ case 'NATNetwork':
+ netName = $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATNetwork;
+ break;
+ case 'VDE':
+ netName = $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].VDENetwork;
+ vboxVDEFound = true;
+ break;
+ }
+
+ // hold default value
+ $(document.forms['frmVboxSettings'].elements['vboxSettingsNetAttachedTo'+a]).data('vboxDefault', netName);
+
+ document.forms['frmVboxSettings'].elements['vboxSettingsNetName'+a].value = netName;
+
+ document.forms['frmVboxSettings'].elements['vboxSettingsNetAdapter'+a].value = $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].adapterType;
+ document.forms['frmVboxSettings'].elements['vboxSettingsNetMAC'+a].value = $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].MACAddress;
+ document.forms['frmVboxSettings'].elements['vboxSettingsNetConnected'+a].checked = ($('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].cableConnected ? true : false);
+ $(document.forms['frmVboxSettings'].elements['vboxSettingsNetAdapterPromiscuousMode'+a]).val($('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].promiscModePolicy);
+
+ document.forms['frmVboxSettings'].elements['vboxSettingsNetGenericProps'+a].innerHTML = $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].properties;
+
+ // Enabled adapter
+ $(document.forms['frmVboxSettings'].elements['vboxSettingsNetEnabled'+a]).prop('checked',$('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].enabled).triggerHandler('click');;
+
+
+ $(document.forms['frmVboxSettings'].elements['vboxSettingsNetPF'+a]).unbind('click');
+ $(document.forms['frmVboxSettings'].elements['vboxSettingsNetPF'+a]).click(function(){
+
+ var nicIndex = (parseInt($(this).attr('name').substr(17))-1);
+
+ $.when(vboxPortForwardConfigDialog($('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[nicIndex].redirects))
+ .done(function(rules){
+ for(var i = 0; i < rules.length; i++) {
+ rules[i] = rules[i].join(',');
+ }
+ $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[nicIndex].redirects = rules;
+ });
+
+ }).val(trans('Port Forwarding','UIMachineSettingsNetwork'));
+
+ // Set Nat values
+ if($('#vboxPane').data('vboxConfig').enableAdvancedConfig) {
+ document.forms['frmVboxSettings'].elements['vboxSettingsNetAliasModeProxyOnly'+a].checked = (($('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATEngine.aliasMode & 2) ? true : false);
+ document.forms['frmVboxSettings'].elements['vboxSettingsNetAliasModeSamePorts'+a].checked = (($('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATEngine.aliasMode & 4) ? true : false);
+ document.forms['frmVboxSettings'].elements['vboxSettingsNetPassDNSDomain'+a].checked = ($('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATEngine.DNSPassDomain ? true : false);
+ document.forms['frmVboxSettings'].elements['vboxSettingsNetDNSProxy'+a].checked = ($('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATEngine.DNSProxy ? true : false);
+ document.forms['frmVboxSettings'].elements['vboxSettingsNetUseHostResolver'+a].checked = ($('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATEngine.DNSUseHostResolver ? true : false);
+ $(document.forms['frmVboxSettings'].elements['vboxSettingsNetBindIp'+a]).val($('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATEngine.hostIP);
+ }
+
+
+ }
+ /* Disable VDE selection? */
+ if(!vboxVDEFound && !$('#vboxPane').data('vboxConfig').enableVDE) {
+ for(var i = 0; i < parseInt($('#vboxPane').data('vboxConfig').nicMax); i++) {
+ $(document.forms['frmVboxSettings'].elements['vboxSettingsNetAttachedTo'+(i+1)]).children("[value='VDE']").remove();
+ }
+ }
+
+ if(!$('#vboxSettingsDialog').data('vboxFullEdit')) {
+
+ for(var i = 0; i < parseInt($('#vboxPane').data('vboxConfig').nicMax); i++) {
+
+ var a = (i + 1);
+
+ /* Disable these inputs */
+ document.forms['frmVboxSettings'].elements['vboxSettingsNetEnabled'+a].disabled ='disabled';
+ document.forms['frmVboxSettings'].elements['vboxSettingsNetAdapter'+a].disabled ='disabled';
+ document.forms['frmVboxSettings'].elements['vboxSettingsNetMAC'+a].disabled ='disabled';
+ $(document.forms['frmVboxSettings'].elements['vboxSettingsNetMAC'+a]).siblings('input').css('display','none');
+
+ /* Disable these labels */
+ $(document.forms['frmVboxSettings'].elements['vboxSettingsNetEnabled'+a]).closest('tr').children().addClass('vboxDisabled');
+ $(document.forms['frmVboxSettings'].elements['vboxSettingsNetAdapter'+a]).closest('tr').children().addClass('vboxDisabled');
+ $(document.forms['frmVboxSettings'].elements['vboxSettingsNetMAC'+a]).closest('tr').children().addClass('vboxDisabled');
+
+ }
+ // Expand all advanced settings
+ $('#vboxSettingsDialog').find('input.netImgAdvanced').each(function(){
+ if(!$(this).data('vboxAdvancedEnabled')) $(this).trigger('click');
+ });
+
+ // Disable mac address generation
+ $('#vboxSettingsDialog').find('input.vboxSettingsNetMacGen').prop('disabled',true);
+
+ } else {
+
+ for(var i = 0; i < parseInt($('#vboxPane').data('vboxConfig').nicMax); i++) {
+
+ var a = (i + 1);
+
+ /* Enable these inputs */
+ document.forms['frmVboxSettings'].elements['vboxSettingsNetEnabled'+a].disabled ='';
+ document.forms['frmVboxSettings'].elements['vboxSettingsNetAdapter'+a].disabled ='';
+ document.forms['frmVboxSettings'].elements['vboxSettingsNetMAC'+a].disabled ='';
+ $(document.forms['frmVboxSettings'].elements['vboxSettingsNetMAC'+a]).siblings('input').css('display','');
+
+ /* Enable these labels */
+ $(document.forms['frmVboxSettings'].elements['vboxSettingsNetEnabled'+a]).closest('tr').children().removeClass('vboxDisabled');
+ $(document.forms['frmVboxSettings'].elements['vboxSettingsNetAdapter'+a]).closest('tr').children().removeClass('vboxDisabled');
+ $(document.forms['frmVboxSettings'].elements['vboxSettingsNetMAC'+a]).closest('tr').children().removeClass('vboxDisabled');
+
+ }
+
+ // Enable mac address generation
+ $('#vboxSettingsDialog').find('input.vboxSettingsNetMacGen').prop('disabled',false);
+
+ }
+
+/* Change settings onSave() */
+}).on('save',function(){
+
+ /* Net */
+ for(var i = 0; i < parseInt($('#vboxPane').data('vboxConfig').nicMax); i++) {
+
+ var a = (i + 1);
+
+ // attached to
+ $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].attachmentType = document.forms['frmVboxSettings'].elements['vboxSettingsNetAttachedTo'+a].value;
+
+ // Device or network name, depending on what 'attached to' is
+ switch($('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].attachmentType) {
+ case 'Bridged':
+ $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].bridgedInterface = document.forms['frmVboxSettings'].elements['vboxSettingsNetName'+a].value;;
+ case 'HostOnly':
+ $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].hostOnlyInterface = document.forms['frmVboxSettings'].elements['vboxSettingsNetName'+a].value;;
+ break;
+ case 'Generic':
+ $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].genericDriver = document.forms['frmVboxSettings'].elements['vboxSettingsNetName'+a].value;
+ break;
+ case 'Internal':
+ $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].internalNetwork = document.forms['frmVboxSettings'].elements['vboxSettingsNetName'+a].value;
+ break;
+ case 'NATNetwork':
+ $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATNetwork = document.forms['frmVboxSettings'].elements['vboxSettingsNetName'+a].value;
+ break;
+ case 'VDE':
+ $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].VDENetwork = document.forms['frmVboxSettings'].elements['vboxSettingsNetName'+a].value;
+ break;
+ }
+
+ // Set Nat values
+ if($('#vboxPane').data('vboxConfig').enableAdvancedConfig) {
+ var aliasMode = $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATEngine.aliasMode & 1;
+ if(document.forms['frmVboxSettings'].elements['vboxSettingsNetAliasModeProxyOnly'+a].checked) {
+ aliasMode |= 2;
+ }
+ if(document.forms['frmVboxSettings'].elements['vboxSettingsNetAliasModeSamePorts'+a].checked) {
+ aliasMode |= 4;
+ }
+ $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATEngine.aliasMode = aliasMode;
+ $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATEngine.DNSPassDomain = document.forms['frmVboxSettings'].elements['vboxSettingsNetPassDNSDomain'+a].checked;
+ $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATEngine.DNSProxy = document.forms['frmVboxSettings'].elements['vboxSettingsNetDNSProxy'+a].checked;
+ $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATEngine.DNSUseHostResolver = document.forms['frmVboxSettings'].elements['vboxSettingsNetUseHostResolver'+a].checked;
+ $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].NATEngine.hostIP = $(document.forms['frmVboxSettings'].elements['vboxSettingsNetBindIp'+a]).val();
+ }
+
+ $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].properties = $(document.forms['frmVboxSettings'].elements['vboxSettingsNetGenericProps'+a]).val();
+ $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].promiscModePolicy = $(document.forms['frmVboxSettings'].elements['vboxSettingsNetAdapterPromiscuousMode'+a]).val();
+ $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].adapterType = document.forms['frmVboxSettings'].elements['vboxSettingsNetAdapter'+a].value;
+ $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].MACAddress = document.forms['frmVboxSettings'].elements['vboxSettingsNetMAC'+a].value;
+ $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].cableConnected = document.forms['frmVboxSettings'].elements['vboxSettingsNetConnected'+a].checked;
+ $('#vboxSettingsDialog').data('vboxMachineData').networkAdapters[i].enabled = document.forms['frmVboxSettings'].elements['vboxSettingsNetEnabled'+a].checked;
+
+ }
+
+});
+
+</script>
+
+
diff --git a/panes/settingsParallelPorts.html b/panes/settingsParallelPorts.html
index 9a132ca..01a41db 100644
--- a/panes/settingsParallelPorts.html
+++ b/panes/settingsParallelPorts.html
@@ -1,192 +1,192 @@
-<!--
- Parallel port settings
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: settingsParallelPorts.html 597 2015-04-20 11:41:28Z imoore76 $
--->
-<div id='vboxSettingsTabParallelPort'>
- <table class='vboxVertical'>
- <tr>
- <td colspan='2'><label><input name='vboxSettingsPPortEnabled' class='vboxCheckbox vboxEnablerCheckbox' type='checkbox' /> <span class='translate'>Enable Parallel Port</span></label></td>
- </tr>
- <tr>
- <th style='min-width: 120px'><span class='translate'>Port Number:</span></th>
- <td class='vboxEnablerTrigger'>
- <select style='width: auto' name='vboxSettingsPPortNumber' onchange='vboxSettingsUpdatePPortOptions(this);'>
- <option value='LPT1'>LPT1</option>
- <option value='LPT2'>LPT2</option>
- <option value='LPT3'>LPT3</option>
- <option value='User-defined' class='translate'>User-defined</option>
- </select>
- <span class='vboxEnablerListen translate'>IRQ:</span> <input type='text' name='vboxSettingsPPortIRQ' size='2' />
- <span class='vboxEnablerListen translate'>I/O Port:</span> <input type='text' name='vboxSettingsPPortIO' size='5' />
- </td>
- </tr>
- <tr>
- <th class='vboxPPortPathLabel'><span class='translate'>Port Path:</span></th>
- <td>
- <input type='text' class='vboxText vboxPPortPathBox' style='width: 100%' name='vboxSettingsPPortPath'/>
- </td>
- </tr>
- </table>
-</div>
-
-<script type='text/javascript'>
-
-/*
- *
- * Setup data for parallel port options
- *
- */
-if($('#vboxPane').data('vboxConfig').enableLPTConfig) {
-
- var vboxSettingsPPortTemplate = document.getElementById('vboxSettingsTabParallelPort');
- var vboxSettingsPPortContainer = $(vboxSettingsPPortTemplate).parent();
-
- /* translated select values */
- for(var i = 0; i < document.forms['frmVboxSettings'].vboxSettingsPPortNumber.options.length; i++) {
- if($(document.forms['frmVboxSettings'].vboxSettingsPPortNumber.options[i]).hasClass('translate'))
- $(document.forms['frmVboxSettings'].vboxSettingsPPortNumber.options[i]).text(trans(document.forms['frmVboxSettings'].vboxSettingsPPortNumber.options[i].text,'VBoxGlobal')).removeClass('translate');
- }
-
- //Translations
- $('#vboxSettingsTabParallelPort').find(".translate").html(function(i,h){return trans($('<div />').html(h).text(),'UIMachineSettingsParallel');}).removeClass('translate');
-
-
-
- /* Parallel Port tab links */
- var ul = $('<ul />');
- $(vboxSettingsPPortContainer).append(ul);
-
- for(var i = 0; i < parseInt($('#vboxPane').data('vboxSystemProperties').parallelPortCount); i++) {
-
-
- /* tab */
- ul.append($('<li />').html('<a href="#' + vboxSettingsPPortTemplate.id + (i + 1) +'"><span>' + trans('Port %1','UIMachineSettingsParallel').replace('%1',i + 1) + '</span></a>'));
-
- /* tab content */
- var newTab = $("#vboxSettingsTabParallelPort").clone(true);
- newTab.attr('id',vboxSettingsPPortTemplate.id + (i + 1));
- newTab.css('display','block');
-
- // Enable / disable trigger
- newTab.find('.vboxEnablerTrigger').on('enable',function(){
- $(this).children('select').trigger('change');
- });
-
- newTab.appendTo(vboxSettingsPPortContainer);
-
- /* Form elements must be unique */
- $("#vboxSettingsTabParallelPort" + (i + 1)).find('[name]').each(function() {
- $(this).attr('name',$(this).attr('name') + (i + 1));
- });
-
- }
-
-
- /* Remove Template */
- $("#vboxSettingsTabParallelPort").empty().remove();
-
-
- //Tell jQuery to set up tabs
- $(vboxSettingsPPortContainer).tabs();
-
-
-
-
-}
-
-/*
- * Called when parallel port options change
- */
-function vboxSettingsUpdatePPortOptions(sel) {
-
- // IRQ and IO text boxes
- if(sel.value == 'User-defined') {
- $(sel).siblings('input').prop('disabled',false);
- $(sel).siblings('span').removeClass('vboxDisabled');
- } else {
- $(sel).siblings('input').prop('disabled',true);
- $(sel).siblings('span').addClass('vboxDisabled');
- for(var i = 0; i < vboxParallelPorts.ports.length; i++) {
- if(vboxParallelPorts.ports[i].name == sel.value) {
- $(sel).siblings('input').first().val(vboxParallelPorts.ports[i].irq);
- $(sel).siblings('input').last().val(vboxParallelPorts.ports[i].port);
- return;
- }
- }
- }
-}
-
-/*
- *
- * Parallel port logic
- *
- */
-if($('#vboxPane').data('vboxConfig').enableLPTConfig) {
-
- $('#vboxSettingsDialog').on('dataLoaded',function(){
-
- /* Port values */
- for(var i = 0; i < parseInt($('#vboxSettingsDialog').data('vboxMachineData').parallelPorts.length); i++) {
-
- var a = (i + 1);
-
- if(a > $('#vboxPane').data('vboxSystemProperties').parallelPortCount) continue;
-
- // Port Number
- var pNum = vboxParallelPorts.getPortName($('#vboxSettingsDialog').data('vboxMachineData').parallelPorts[i].IRQ,$('#vboxSettingsDialog').data('vboxMachineData').parallelPorts[i].IOBase);
- $(document.forms['frmVboxSettings'].elements['vboxSettingsPPortNumber'+a]).val(pNum);
- $(document.forms['frmVboxSettings'].elements['vboxSettingsPPortNumber'+a].options[document.forms['frmVboxSettings'].elements['vboxSettingsPPortNumber'+a].selectedIndex]).attr('selected','selected');
- $(document.forms['frmVboxSettings'].elements['vboxSettingsPPortNumber'+a]).change();
-
- $(document.forms['frmVboxSettings'].elements['vboxSettingsPPortIRQ'+a]).val($('#vboxSettingsDialog').data('vboxMachineData').parallelPorts[i].IRQ);
- $(document.forms['frmVboxSettings'].elements['vboxSettingsPPortIO'+a]).val($('#vboxSettingsDialog').data('vboxMachineData').parallelPorts[i].IOBase);
-
- // Path
- $(document.forms['frmVboxSettings'].elements['vboxSettingsPPortPath'+a]).val($('#vboxSettingsDialog').data('vboxMachineData').parallelPorts[i].path);
-
- // Enabled port
- $(document.forms['frmVboxSettings'].elements['vboxSettingsPPortEnabled'+a]).prop('checked',$('#vboxSettingsDialog').data('vboxMachineData').parallelPorts[i].enabled).triggerHandler('click');
-
- }
-
- if(!$('#vboxSettingsDialog').data('vboxFullEdit')) {
- vboxSettingsPPortContainer.find('input.vboxEnablerCheckbox').triggerHandler('click');
- vboxSettingsPPortContainer.children(':not(ul)').find('span').addClass('disabled');
- vboxSettingsPPortContainer.find('input,select,textarea').prop('disabled',true);
- } else {
- vboxSettingsPPortContainer.find('span').removeClass('disabled');
- vboxSettingsPPortContainer.find('input,select,textarea').prop('disabled',false);
- vboxSettingsPPortContainer.find('input.vboxEnablerCheckbox').triggerHandler('click');
- }
- });
-}
-
-
-/* Change settings onSave() */
-$('#vboxSettingsDialog').on('save',function(){
-
- if(!$('#vboxPane').data('vboxConfig').enableLPTConfig) return;
-
- for(var i = 0; i < parseInt($('#vboxPane').data('vboxSystemProperties').parallelPortCount); i++) {
-
- var a = (i + 1);
-
- // Port IRQ and IO
- $('#vboxSettingsDialog').data('vboxMachineData').parallelPorts[i].IRQ = $(document.forms['frmVboxSettings'].elements['vboxSettingsPPortIRQ'+a]).val();
- $('#vboxSettingsDialog').data('vboxMachineData').parallelPorts[i].IOBase = $(document.forms['frmVboxSettings'].elements['vboxSettingsPPortIO'+a]).val();
-
- // Path
- $('#vboxSettingsDialog').data('vboxMachineData').parallelPorts[i].path = $(document.forms['frmVboxSettings'].elements['vboxSettingsPPortPath'+a]).val();
-
- // Enabled port
- $('#vboxSettingsDialog').data('vboxMachineData').parallelPorts[i].enabled = document.forms['frmVboxSettings'].elements['vboxSettingsPPortEnabled'+a].checked;
-
-
- }
-
-});
-
-
-</script>
+<!--
+ Parallel port settings
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: settingsParallelPorts.html 597 2015-04-20 11:41:28Z imoore76 $
+-->
+<div id='vboxSettingsTabParallelPort'>
+ <table class='vboxVertical'>
+ <tr>
+ <td colspan='2'><label><input name='vboxSettingsPPortEnabled' class='vboxCheckbox vboxEnablerCheckbox' type='checkbox' /> <span class='translate'>Enable Parallel Port</span></label></td>
+ </tr>
+ <tr>
+ <th style='min-width: 120px'><span class='translate'>Port Number:</span></th>
+ <td class='vboxEnablerTrigger'>
+ <select style='width: auto' name='vboxSettingsPPortNumber' onchange='vboxSettingsUpdatePPortOptions(this);'>
+ <option value='LPT1'>LPT1</option>
+ <option value='LPT2'>LPT2</option>
+ <option value='LPT3'>LPT3</option>
+ <option value='User-defined' class='translate'>User-defined</option>
+ </select>
+ <span class='vboxEnablerListen translate'>IRQ:</span> <input type='text' name='vboxSettingsPPortIRQ' size='2' />
+ <span class='vboxEnablerListen translate'>I/O Port:</span> <input type='text' name='vboxSettingsPPortIO' size='5' />
+ </td>
+ </tr>
+ <tr>
+ <th class='vboxPPortPathLabel'><span class='translate'>Port Path:</span></th>
+ <td>
+ <input type='text' class='vboxText vboxPPortPathBox' style='width: 100%' name='vboxSettingsPPortPath'/>
+ </td>
+ </tr>
+ </table>
+</div>
+
+<script type='text/javascript'>
+
+/*
+ *
+ * Setup data for parallel port options
+ *
+ */
+if($('#vboxPane').data('vboxConfig').enableLPTConfig) {
+
+ var vboxSettingsPPortTemplate = document.getElementById('vboxSettingsTabParallelPort');
+ var vboxSettingsPPortContainer = $(vboxSettingsPPortTemplate).parent();
+
+ /* translated select values */
+ for(var i = 0; i < document.forms['frmVboxSettings'].vboxSettingsPPortNumber.options.length; i++) {
+ if($(document.forms['frmVboxSettings'].vboxSettingsPPortNumber.options[i]).hasClass('translate'))
+ $(document.forms['frmVboxSettings'].vboxSettingsPPortNumber.options[i]).text(trans(document.forms['frmVboxSettings'].vboxSettingsPPortNumber.options[i].text,'VBoxGlobal')).removeClass('translate');
+ }
+
+ //Translations
+ $('#vboxSettingsTabParallelPort').find(".translate").html(function(i,h){return trans($('<div />').html(h).text(),'UIMachineSettingsParallel');}).removeClass('translate');
+
+
+
+ /* Parallel Port tab links */
+ var ul = $('<ul />');
+ $(vboxSettingsPPortContainer).append(ul);
+
+ for(var i = 0; i < parseInt($('#vboxPane').data('vboxSystemProperties').parallelPortCount); i++) {
+
+
+ /* tab */
+ ul.append($('<li />').html('<a href="#' + vboxSettingsPPortTemplate.id + (i + 1) +'"><span>' + trans('Port %1','UIMachineSettingsParallel').replace('%1',i + 1) + '</span></a>'));
+
+ /* tab content */
+ var newTab = $("#vboxSettingsTabParallelPort").clone(true);
+ newTab.attr('id',vboxSettingsPPortTemplate.id + (i + 1));
+ newTab.css('display','block');
+
+ // Enable / disable trigger
+ newTab.find('.vboxEnablerTrigger').on('enable',function(){
+ $(this).children('select').trigger('change');
+ });
+
+ newTab.appendTo(vboxSettingsPPortContainer);
+
+ /* Form elements must be unique */
+ $("#vboxSettingsTabParallelPort" + (i + 1)).find('[name]').each(function() {
+ $(this).attr('name',$(this).attr('name') + (i + 1));
+ });
+
+ }
+
+
+ /* Remove Template */
+ $("#vboxSettingsTabParallelPort").empty().remove();
+
+
+ //Tell jQuery to set up tabs
+ $(vboxSettingsPPortContainer).tabs();
+
+
+
+
+}
+
+/*
+ * Called when parallel port options change
+ */
+function vboxSettingsUpdatePPortOptions(sel) {
+
+ // IRQ and IO text boxes
+ if(sel.value == 'User-defined') {
+ $(sel).siblings('input').prop('disabled',false);
+ $(sel).siblings('span').removeClass('vboxDisabled');
+ } else {
+ $(sel).siblings('input').prop('disabled',true);
+ $(sel).siblings('span').addClass('vboxDisabled');
+ for(var i = 0; i < vboxParallelPorts.ports.length; i++) {
+ if(vboxParallelPorts.ports[i].name == sel.value) {
+ $(sel).siblings('input').first().val(vboxParallelPorts.ports[i].irq);
+ $(sel).siblings('input').last().val(vboxParallelPorts.ports[i].port);
+ return;
+ }
+ }
+ }
+}
+
+/*
+ *
+ * Parallel port logic
+ *
+ */
+if($('#vboxPane').data('vboxConfig').enableLPTConfig) {
+
+ $('#vboxSettingsDialog').on('dataLoaded',function(){
+
+ /* Port values */
+ for(var i = 0; i < parseInt($('#vboxSettingsDialog').data('vboxMachineData').parallelPorts.length); i++) {
+
+ var a = (i + 1);
+
+ if(a > $('#vboxPane').data('vboxSystemProperties').parallelPortCount) continue;
+
+ // Port Number
+ var pNum = vboxParallelPorts.getPortName($('#vboxSettingsDialog').data('vboxMachineData').parallelPorts[i].IRQ,$('#vboxSettingsDialog').data('vboxMachineData').parallelPorts[i].IOBase);
+ $(document.forms['frmVboxSettings'].elements['vboxSettingsPPortNumber'+a]).val(pNum);
+ $(document.forms['frmVboxSettings'].elements['vboxSettingsPPortNumber'+a].options[document.forms['frmVboxSettings'].elements['vboxSettingsPPortNumber'+a].selectedIndex]).attr('selected','selected');
+ $(document.forms['frmVboxSettings'].elements['vboxSettingsPPortNumber'+a]).change();
+
+ $(document.forms['frmVboxSettings'].elements['vboxSettingsPPortIRQ'+a]).val($('#vboxSettingsDialog').data('vboxMachineData').parallelPorts[i].IRQ);
+ $(document.forms['frmVboxSettings'].elements['vboxSettingsPPortIO'+a]).val($('#vboxSettingsDialog').data('vboxMachineData').parallelPorts[i].IOBase);
+
+ // Path
+ $(document.forms['frmVboxSettings'].elements['vboxSettingsPPortPath'+a]).val($('#vboxSettingsDialog').data('vboxMachineData').parallelPorts[i].path);
+
+ // Enabled port
+ $(document.forms['frmVboxSettings'].elements['vboxSettingsPPortEnabled'+a]).prop('checked',$('#vboxSettingsDialog').data('vboxMachineData').parallelPorts[i].enabled).triggerHandler('click');
+
+ }
+
+ if(!$('#vboxSettingsDialog').data('vboxFullEdit')) {
+ vboxSettingsPPortContainer.find('input.vboxEnablerCheckbox').triggerHandler('click');
+ vboxSettingsPPortContainer.children(':not(ul)').find('span').addClass('disabled');
+ vboxSettingsPPortContainer.find('input,select,textarea').prop('disabled',true);
+ } else {
+ vboxSettingsPPortContainer.find('span').removeClass('disabled');
+ vboxSettingsPPortContainer.find('input,select,textarea').prop('disabled',false);
+ vboxSettingsPPortContainer.find('input.vboxEnablerCheckbox').triggerHandler('click');
+ }
+ });
+}
+
+
+/* Change settings onSave() */
+$('#vboxSettingsDialog').on('save',function(){
+
+ if(!$('#vboxPane').data('vboxConfig').enableLPTConfig) return;
+
+ for(var i = 0; i < parseInt($('#vboxPane').data('vboxSystemProperties').parallelPortCount); i++) {
+
+ var a = (i + 1);
+
+ // Port IRQ and IO
+ $('#vboxSettingsDialog').data('vboxMachineData').parallelPorts[i].IRQ = $(document.forms['frmVboxSettings'].elements['vboxSettingsPPortIRQ'+a]).val();
+ $('#vboxSettingsDialog').data('vboxMachineData').parallelPorts[i].IOBase = $(document.forms['frmVboxSettings'].elements['vboxSettingsPPortIO'+a]).val();
+
+ // Path
+ $('#vboxSettingsDialog').data('vboxMachineData').parallelPorts[i].path = $(document.forms['frmVboxSettings'].elements['vboxSettingsPPortPath'+a]).val();
+
+ // Enabled port
+ $('#vboxSettingsDialog').data('vboxMachineData').parallelPorts[i].enabled = document.forms['frmVboxSettings'].elements['vboxSettingsPPortEnabled'+a].checked;
+
+
+ }
+
+});
+
+
+</script>
diff --git a/panes/settingsPortForwarding.html b/panes/settingsPortForwarding.html
index 98b79d7..761d9fa 100644
--- a/panes/settingsPortForwarding.html
+++ b/panes/settingsPortForwarding.html
@@ -1,195 +1,195 @@
-<!--
- Port Forwarding Settings
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: settingsPortForwarding.html 595 2015-04-17 09:50:36Z imoore76 $
- -->
-<div id='vboxSettingsPortForwarding' style='height: 100%'>
-<table class='vboxInvisible'>
-<tr style='vertical-align: top'>
-<td style='width: 100%; height: 100%'>
- <div id='vboxSettingsPortForwardingListDiv' class='vboxBordered' style='overflow: auto;'>
- <table class='vboxHorizontal'>
- <thead>
- <tr>
- <th class='translate'>Name</th>
- <th class='translate'>Protocol</th>
- <th class='translate'>Host IP</th>
- <th class='translate'>Host Port</th>
- <th class='translate'>Guest IP</th>
- <th class='translate'>Guest Port</th>
- </tr>
- </thead>
- <tbody id='vboxSettingsPortForwardingList' class='vboxHover'></tbody>
- </table>
- </div>
-</td><td id='vboxSettingsPortForwardingToolbar'></td>
-</tr>
-</table>
-<script type='text/javascript'>
-
-/*
- * Translate
- */
-$('#vboxSettingsPortForwarding').find('.translate').html(function(i,h){return trans(h,'UIPortForwardingModel');}).removeClass('translate');
-
-/*
- * Init port forwarding buttons and toolbar
- */
-
-var sButtons = new Array(
- {
- 'name' : 'insportfwd',
- 'label' : 'Insert new rule',
- 'icon' : 'controller_add',
- 'click' : function () {
- var rname = null;
- var rules = $('#vboxSettingsPortForwardingList').children('tr');
- for(var n = 1; n < 100; n++) {
- rname = trans('Rule %1').replace('%1',n);
- for(var i = 0; i < rules.length; i++) {
- if($(rules[i]).data('vboxRule')[0] == rname) {
- rname = null;
- break;
- }
- }
- if(rname) break;
- }
- vboxSettingsPortForwardingAdd(rname+',1,,,,');
- }
- },
- {
- 'name' : 'delportfwd',
- 'label' : 'Delete selected rule',
- 'icon' : 'controller_remove',
- 'click' : function () {
- $('#vboxSettingsPortForwardingList').children('tr.vboxListItemSelected').first().remove();
- $('#vboxSettingsPortForwardingList').trigger('select');
- },
- 'enabled' : function(item) {return ((item && $(item).data('vboxRule')) ? true : false);}
- }
-);
-var pfToolbar = new vboxToolbarSmall({buttons: sButtons, language_context: 'UIMachineSettingsPortForwardingDlg'});
-pfToolbar.renderTo('vboxSettingsPortForwardingToolbar');
-
-
-$('#vboxSettingsPortForwardingList').on('select',function(e,el){pfToolbar.update(el);});
-$('#vboxSettingsPortForwardingList').trigger('select');
-
-/* Edit rule element */
-function vboxSettingsPortForwardingEdit(td,type) {
- if($(td).children('input').length) return;
- var ex = $(td).parent().data('vboxRule')[$(td).data('vboxPane')];
- var w = $(td).width();
- $(td).html('');
- $('<input />').data('vboxPane',$(td).data('vboxPane')).attr({'class':'vboxText'}).val(ex).blur(function(){
- switch($(this).data('vboxPane')) {
- /* name */
- case 0:
- $(this).val(jQuery.trim($(this).val().replace(',','')));
- if(!$(this).val())
- $(this).val($(this).parent().parent().data('vboxRule')[0]);
- break;
- /* IPs */
- case 2:
- case 4:
- $(this).val($(this).val().replace(/[^0-9\.]/,''));
- break;
- /* ports */
- case 3:
- case 5:
- $(this).val($(this).val().replace(/[^0-9]/,''));
- if(!$(this).val() || $(this).val() < 0) $(this).val('0');
- else if($(this).val() > 65535) $(this).val('65535');
- break;
- }
- $(this).parent().parent().data('vboxRule')[$(this).data('vboxPane')] = $(this).val();
- var ex = $(this).val();
- $(this).replaceWith($('<div />').html(ex).text());
- }).css({'width':(w-8)+'px','padding':'0px','margin':'0px'}).keydown(function(event){
- if(event.keyCode == 13) {
- $(this).trigger('blur');
- return;
- }
- switch($(this).data('vboxPane')) {
- /* name */
- case 0:
- if(event.keyCode == 188) return false; // no commas
- break;
- /* IPs */
- case 2:
- case 4:
- return true;
- break;
- /* ports */
- case 3:
- case 5:
- return (vboxValidateCtrl(event.keyCode) || vboxValidateNum(event.keyCode));
- break;
- }
-
- }).appendTo(td).focus();
-}
-
-/* Edit protocol */
-function vboxSettingsPortForwardingEditProto(td) {
- var ex = $(td).parent().data('vboxRule')[1];
-
- if(ex == 0) val = 1;
- else val = 0;
-
- $(td).parent().data('vboxRule')[1] = val;
-
- $(td).html(val == '1' ? trans('TCP','VBoxGlobal') : trans('UDP','VBoxGlobal'));
-
-}
-/* Add forwarding rule */
-function vboxSettingsPortForwardingAdd(r) {
-
- var rule = r.split(',');
- var tr = $('<tr />').attr({'class':'vboxListItem'});
-
- $('<td />').data('vboxPane',0).html($('<div />').html(rule[0]).text()).click(function(){
- if($(this).parent().hasClass('vboxListItemSelected')) {
- vboxSettingsPortForwardingEdit(this,'name');
- return;
- }
- $(this).parent().addClass('vboxListItemSelected').removeClass('vboxHover').siblings().removeClass('vboxListItemSelected');
- $('#vboxSettingsPortForwardingList').trigger('select',$(this).parent());
- }).addClass('vboxHoverFirst').appendTo(tr);
-
- $('<td />').click(function(){
- if($(this).parent().hasClass('vboxListItemSelected')) {
- vboxSettingsPortForwardingEditProto(this);
- return;
- }
- $(this).parent().addClass('vboxListItemSelected').removeClass('vboxHover').siblings().removeClass('vboxListItemSelected');
- $('#vboxSettingsPortForwardingList').trigger('select',$(this).parent());
- }).addClass('vboxProto vboxHoverMid').html(trans(rule[1] == 1 ? 'TCP' : 'UDP','VBoxGlobal')).appendTo(tr);
-
- for(var i = 2; i < rule.length; i++) {
- $('<td />').data('vboxPane',i).click(function(){
- if($(this).parent().hasClass('vboxListItemSelected')) {
- vboxSettingsPortForwardingEdit(this,'port');
- return;
- }
- $(this).parent().addClass('vboxListItemSelected').removeClass('vboxHover').siblings().removeClass('vboxListItemSelected');
- $('#vboxSettingsPortForwardingList').trigger('select',$(this).parent());
- }).addClass('vboxHover' + (i == (rule.length-1) ? 'Last' : 'Mid'))
- .html($('<div />').html(rule[i]).text()).addClass((i%2 ? 'vboxPort' : 'vboxIP')).appendTo(tr);
- }
- $(tr).data({'vboxRule':rule}).hover(function(){
- if(!$(this).hasClass('vboxListItemSelected'))
- $(this).addClass('vboxHover');
- },function(){
- $(this).removeClass('vboxHover');
- }).appendTo($('#vboxSettingsPortForwardingList'));
-
-}
-function vboxSettingsPortForwardingInit(rules) {
- for(var r = 0; r < rules.length; r++) {
- vboxSettingsPortForwardingAdd(rules[r]);
- }
-}
-</script>
-</div>
+<!--
+ Port Forwarding Settings
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: settingsPortForwarding.html 595 2015-04-17 09:50:36Z imoore76 $
+ -->
+<div id='vboxSettingsPortForwarding' style='height: 100%'>
+<table class='vboxInvisible'>
+<tr style='vertical-align: top'>
+<td style='width: 100%; height: 100%'>
+ <div id='vboxSettingsPortForwardingListDiv' class='vboxBordered' style='overflow: auto;'>
+ <table class='vboxHorizontal'>
+ <thead>
+ <tr>
+ <th class='translate'>Name</th>
+ <th class='translate'>Protocol</th>
+ <th class='translate'>Host IP</th>
+ <th class='translate'>Host Port</th>
+ <th class='translate'>Guest IP</th>
+ <th class='translate'>Guest Port</th>
+ </tr>
+ </thead>
+ <tbody id='vboxSettingsPortForwardingList' class='vboxHover'></tbody>
+ </table>
+ </div>
+</td><td id='vboxSettingsPortForwardingToolbar'></td>
+</tr>
+</table>
+<script type='text/javascript'>
+
+/*
+ * Translate
+ */
+$('#vboxSettingsPortForwarding').find('.translate').html(function(i,h){return trans(h,'UIPortForwardingModel');}).removeClass('translate');
+
+/*
+ * Init port forwarding buttons and toolbar
+ */
+
+var sButtons = new Array(
+ {
+ 'name' : 'insportfwd',
+ 'label' : 'Insert new rule',
+ 'icon' : 'controller_add',
+ 'click' : function () {
+ var rname = null;
+ var rules = $('#vboxSettingsPortForwardingList').children('tr');
+ for(var n = 1; n < 100; n++) {
+ rname = trans('Rule %1').replace('%1',n);
+ for(var i = 0; i < rules.length; i++) {
+ if($(rules[i]).data('vboxRule')[0] == rname) {
+ rname = null;
+ break;
+ }
+ }
+ if(rname) break;
+ }
+ vboxSettingsPortForwardingAdd(rname+',1,,,,');
+ }
+ },
+ {
+ 'name' : 'delportfwd',
+ 'label' : 'Delete selected rule',
+ 'icon' : 'controller_remove',
+ 'click' : function () {
+ $('#vboxSettingsPortForwardingList').children('tr.vboxListItemSelected').first().remove();
+ $('#vboxSettingsPortForwardingList').trigger('select');
+ },
+ 'enabled' : function(item) {return ((item && $(item).data('vboxRule')) ? true : false);}
+ }
+);
+var pfToolbar = new vboxToolbarSmall({buttons: sButtons, language_context: 'UIMachineSettingsPortForwardingDlg'});
+pfToolbar.renderTo('vboxSettingsPortForwardingToolbar');
+
+
+$('#vboxSettingsPortForwardingList').on('select',function(e,el){pfToolbar.update(el);});
+$('#vboxSettingsPortForwardingList').trigger('select');
+
+/* Edit rule element */
+function vboxSettingsPortForwardingEdit(td,type) {
+ if($(td).children('input').length) return;
+ var ex = $(td).parent().data('vboxRule')[$(td).data('vboxPane')];
+ var w = $(td).width();
+ $(td).html('');
+ $('<input />').data('vboxPane',$(td).data('vboxPane')).attr({'class':'vboxText'}).val(ex).blur(function(){
+ switch($(this).data('vboxPane')) {
+ /* name */
+ case 0:
+ $(this).val(jQuery.trim($(this).val().replace(',','')));
+ if(!$(this).val())
+ $(this).val($(this).parent().parent().data('vboxRule')[0]);
+ break;
+ /* IPs */
+ case 2:
+ case 4:
+ $(this).val($(this).val().replace(/[^0-9\.]/,''));
+ break;
+ /* ports */
+ case 3:
+ case 5:
+ $(this).val($(this).val().replace(/[^0-9]/,''));
+ if(!$(this).val() || $(this).val() < 0) $(this).val('0');
+ else if($(this).val() > 65535) $(this).val('65535');
+ break;
+ }
+ $(this).parent().parent().data('vboxRule')[$(this).data('vboxPane')] = $(this).val();
+ var ex = $(this).val();
+ $(this).replaceWith($('<div />').html(ex).text());
+ }).css({'width':(w-8)+'px','padding':'0px','margin':'0px'}).keydown(function(event){
+ if(event.keyCode == 13) {
+ $(this).trigger('blur');
+ return;
+ }
+ switch($(this).data('vboxPane')) {
+ /* name */
+ case 0:
+ if(event.keyCode == 188) return false; // no commas
+ break;
+ /* IPs */
+ case 2:
+ case 4:
+ return true;
+ break;
+ /* ports */
+ case 3:
+ case 5:
+ return (vboxValidateCtrl(event.keyCode) || vboxValidateNum(event.keyCode));
+ break;
+ }
+
+ }).appendTo(td).focus();
+}
+
+/* Edit protocol */
+function vboxSettingsPortForwardingEditProto(td) {
+ var ex = $(td).parent().data('vboxRule')[1];
+
+ if(ex == 0) val = 1;
+ else val = 0;
+
+ $(td).parent().data('vboxRule')[1] = val;
+
+ $(td).html(val == '1' ? trans('TCP','VBoxGlobal') : trans('UDP','VBoxGlobal'));
+
+}
+/* Add forwarding rule */
+function vboxSettingsPortForwardingAdd(r) {
+
+ var rule = r.split(',');
+ var tr = $('<tr />').attr({'class':'vboxListItem'});
+
+ $('<td />').data('vboxPane',0).html($('<div />').html(rule[0]).text()).click(function(){
+ if($(this).parent().hasClass('vboxListItemSelected')) {
+ vboxSettingsPortForwardingEdit(this,'name');
+ return;
+ }
+ $(this).parent().addClass('vboxListItemSelected').removeClass('vboxHover').siblings().removeClass('vboxListItemSelected');
+ $('#vboxSettingsPortForwardingList').trigger('select',$(this).parent());
+ }).addClass('vboxHoverFirst').appendTo(tr);
+
+ $('<td />').click(function(){
+ if($(this).parent().hasClass('vboxListItemSelected')) {
+ vboxSettingsPortForwardingEditProto(this);
+ return;
+ }
+ $(this).parent().addClass('vboxListItemSelected').removeClass('vboxHover').siblings().removeClass('vboxListItemSelected');
+ $('#vboxSettingsPortForwardingList').trigger('select',$(this).parent());
+ }).addClass('vboxProto vboxHoverMid').html(trans(rule[1] == 1 ? 'TCP' : 'UDP','VBoxGlobal')).appendTo(tr);
+
+ for(var i = 2; i < rule.length; i++) {
+ $('<td />').data('vboxPane',i).click(function(){
+ if($(this).parent().hasClass('vboxListItemSelected')) {
+ vboxSettingsPortForwardingEdit(this,'port');
+ return;
+ }
+ $(this).parent().addClass('vboxListItemSelected').removeClass('vboxHover').siblings().removeClass('vboxListItemSelected');
+ $('#vboxSettingsPortForwardingList').trigger('select',$(this).parent());
+ }).addClass('vboxHover' + (i == (rule.length-1) ? 'Last' : 'Mid'))
+ .html($('<div />').html(rule[i]).text()).addClass((i%2 ? 'vboxPort' : 'vboxIP')).appendTo(tr);
+ }
+ $(tr).data({'vboxRule':rule}).hover(function(){
+ if(!$(this).hasClass('vboxListItemSelected'))
+ $(this).addClass('vboxHover');
+ },function(){
+ $(this).removeClass('vboxHover');
+ }).appendTo($('#vboxSettingsPortForwardingList'));
+
+}
+function vboxSettingsPortForwardingInit(rules) {
+ for(var r = 0; r < rules.length; r++) {
+ vboxSettingsPortForwardingAdd(rules[r]);
+ }
+}
+</script>
+</div>
diff --git a/panes/settingsSerialPorts.html b/panes/settingsSerialPorts.html
index b47dab8..e74fbc2 100644
--- a/panes/settingsSerialPorts.html
+++ b/panes/settingsSerialPorts.html
@@ -1,232 +1,232 @@
-<!--
- Serial port settings
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: settingsSerialPorts.html 597 2015-04-20 11:41:28Z imoore76 $
- -->
-<div id='vboxSettingsTabSerialPort' style='display: none'>
-<table class='vboxVertical'>
- <tr>
- <td colspan='2'><label><input name='vboxSettingsSPortEnabled' class='vboxCheckbox vboxEnablerCheckbox' type='checkbox' /> <span class='translate'>Enable Serial Port</span></label></td>
- </tr>
- <tr>
- <th style='min-width: 120px'><span class='translate'>Port Number:</span></th>
- <td class='vboxEnablerTrigger'>
- <select style='width: auto' name='vboxSettingsPortNumber' onchange='vboxSettingsUpdateSPortOptions(this);'>
- <option value='COM1'>COM1</option>
- <option value='COM2'>COM2</option>
- <option value='COM3'>COM3</option>
- <option value='COM4'>COM4</option>
- <option value='User-defined' class='translate'>User-defined</option>
- </select>
- <span class='vboxEnablerListen'><span class='translate'>IRQ:</span></span> <input type='text' name='vboxSettingsSPortIRQ' size='2' />
- <span class='vboxEnablerListen'><span class='translate'>I/O Port:</span></span> <input type='text' name='vboxSettingsSPortIO' size='5' />
- </td>
- </tr>
- <tr>
- <th><span class='translate'>Port Mode:</span></th>
- <td class='vboxEnablerTrigger'>
- <select style='width: auto' name='vboxSettingsPortMode' onchange='vboxSettingsUpdateSPortMode(this);'>
- <option value='Disconnected' >Disconnected</option>
- <option value='HostPipe' >HostPipe</option>
- <option value='HostDevice' >HostDevice</option>
- <option value='RawFile' >RawFile</option>
- </select>
- </td>
- </tr>
- <tr>
- <th></th>
- <td>
- <label><input type='checkbox' class='vboxCheckbox vboxSettingsSPortCreatePipe' name='vboxSettingsSPortCreatePipe' />
- <span class='translate vboxEnablerListen'>Create Pipe</span></label>
- </td>
- </tr>
- <tr>
- <th class='vboxSPortPathLabel'><span class='translate'>Port/File Path:</span></th>
- <td>
- <input type='text' class='vboxText vboxSPortPathBox' style='width: 100%' name='vboxSettingsSPortPath'/>
- </td>
- </tr>
-</table>
-</div>
-
-<script type='text/javascript'>
-
-
-/*
- *
- * Setup data for serial port options
- *
- */
-
-var vboxSettingsSPortTemplate = document.getElementById('vboxSettingsTabSerialPort');
-var vboxSettingsSPortContainer = $(vboxSettingsSPortTemplate).parent();
-
-/* translated select values */
-for(var i = 0; i < document.forms['frmVboxSettings'].vboxSettingsPortNumber.options.length; i++) {
- if($(document.forms['frmVboxSettings'].vboxSettingsPortNumber.options[i]).hasClass('translate'))
- $(document.forms['frmVboxSettings'].vboxSettingsPortNumber.options[i]).text(trans(document.forms['frmVboxSettings'].vboxSettingsPortNumber.options[i].text,'VBoxGlobal')).removeClass('translate');
-}
-for(var i = 0; i < document.forms['frmVboxSettings'].vboxSettingsPortMode.options.length; i++) {
- document.forms['frmVboxSettings'].vboxSettingsPortMode.options[i].text = trans(vboxSerialMode(document.forms['frmVboxSettings'].vboxSettingsPortMode.options[i].text),'VBoxGlobal');
-}
-
-// Translations
-$('#vboxSettingsTabSerialPort').find(".translate").html(function(i,h){return trans($('<div />').html(h).text(),'UIMachineSettingsSerial');}).removeClass('translate');
-
-/* Serial Port tab links */
-var ul = $('<ul />');
-$(vboxSettingsSPortContainer).append(ul);
-
-for(var i = 0; i < parseInt($('#vboxPane').data('vboxSystemProperties').serialPortCount); i++) {
-
-
- /* tab */
- ul.append($('<li />').html('<a href="#' + vboxSettingsSPortTemplate.id + (i + 1) +'"><span>' + trans('Port %1','UIMachineSettingsSerial').replace('%1',i + 1) + '</span></a>'));
-
- /* tab content */
- var newTab = $("#vboxSettingsTabSerialPort").clone(true);
- newTab.attr({'id':vboxSettingsSPortTemplate.id + (i + 1)}).css({'display':'block'}).find('.vboxEnablerTrigger').on('enable',function(){
- $(this).find('select').trigger('change');
- });
-
- newTab.appendTo(vboxSettingsSPortContainer);
-
- /* Form elements must be unique */
- $("#vboxSettingsTabSerialPort" + (i + 1)).find('[name]').each(function() {
- $(this).attr('name',$(this).attr('name') + (i + 1));
- });
-
-}
-
-
-/* Remove Template */
-$("#vboxSettingsTabSerialPort").empty().remove();
-
-
-// Tell jQuery to set up tabs
-$(vboxSettingsSPortContainer).tabs();
-
-/*
- * Called when serial port options change
- */
-function vboxSettingsUpdateSPortOptions(sel) {
-
- // IRQ and IO text boxes
- if(sel.value == 'User-defined') {
- $(sel).siblings('input').prop('disabled',false);
- $(sel).siblings('span').removeClass('vboxDisabled');
- } else {
- $(sel).siblings('input').prop('disabled',true);
- $(sel).siblings('span').addClass('vboxDisabled');
- for(var i = 0; i < vboxSerialPorts.ports.length; i++) {
- if(vboxSerialPorts.ports[i].name == sel.value) {
- $(sel).siblings('input').first().val(vboxSerialPorts.ports[i].irq);
- $(sel).siblings('input').last().val(vboxSerialPorts.ports[i].port);
- return;
- }
- }
- }
-}
-
-/*
- * When serial port mode changes
- */
-function vboxSettingsUpdateSPortMode(sel) {
- var ptable = $(sel).closest('table');
- if(sel.value == 'HostPipe') {
- ptable.find('input.vboxSettingsSPortCreatePipe').prop({'disabled':false}).siblings().removeClass('vboxDisabled');
- } else {
- ptable.find('input.vboxSettingsSPortCreatePipe').prop({'disabled':true}).siblings().addClass('vboxDisabled');
- }
- if(sel.value == 'Disconnected') {
- ptable.find('.vboxSPortPathLabel').addClass('vboxDisabled');
- ptable.find('.vboxSPortPathBox').prop('disabled',true);
- } else {
- ptable.find('.vboxSPortPathLabel').removeClass('vboxDisabled');
- ptable.find('.vboxSPortPathBox').prop('disabled',false);
- }
-}
-
-
-/* When data is loaded */
-$('#vboxSettingsDialog').on('dataLoaded',function(){
-
- /*
- * Serial ports
- *
- */
- for(var i = 0; i < parseInt($('#vboxSettingsDialog').data('vboxMachineData').serialPorts.length); i++) {
-
- var a = (i + 1);
-
- if(a > $('#vboxPane').data('vboxSystemProperties').serialPortCount) continue;
-
- // Port Number
- var pNum = vboxSerialPorts.getPortName($('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].IRQ,$('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].IOBase);
- $(document.forms['frmVboxSettings'].elements['vboxSettingsPortNumber'+a]).val(pNum);
- $(document.forms['frmVboxSettings'].elements['vboxSettingsPortNumber'+a].options[document.forms['frmVboxSettings'].elements['vboxSettingsPortNumber'+a].selectedIndex]).attr('selected','selected');
- $(document.forms['frmVboxSettings'].elements['vboxSettingsPortNumber'+a]).change();
-
- $(document.forms['frmVboxSettings'].elements['vboxSettingsSPortIRQ'+a]).val($('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].IRQ);
- $(document.forms['frmVboxSettings'].elements['vboxSettingsSPortIO'+a]).val($('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].IOBase);
-
- // Port Mode
- $(document.forms['frmVboxSettings'].elements['vboxSettingsPortMode'+a]).val($('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].hostMode);
- $(document.forms['frmVboxSettings'].elements['vboxSettingsPortMode'+a].options[document.forms['frmVboxSettings'].elements['vboxSettingsPortMode'+a].selectedIndex]).attr('selected','selected');
- $(document.forms['frmVboxSettings'].elements['vboxSettingsPortMode'+a]).change();
-
- // Create pipe
- $(document.forms['frmVboxSettings'].elements['vboxSettingsSPortCreatePipe'+a]).prop('checked',($('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].server ? true : false)).triggerHandler('click');
-
- // Path
- $(document.forms['frmVboxSettings'].elements['vboxSettingsSPortPath'+a]).val($('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].path);
-
- // Enabled
- $(document.forms['frmVboxSettings'].elements['vboxSettingsSPortEnabled'+a]).prop('checked',($('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].enabled));
-
- }
-
- if(!$('#vboxSettingsDialog').data('vboxFullEdit')) {
- vboxSettingsSPortContainer.find('input.vboxEnablerCheckbox').triggerHandler('click');
- vboxSettingsSPortContainer.children(':not(ul)').find('span').addClass('disabled');
- vboxSettingsSPortContainer.find('input,select,textarea').prop('disabled',true);
- } else {
- vboxSettingsSPortContainer.find('span').removeClass('disabled');
- vboxSettingsSPortContainer.find('input,select,textarea').prop('disabled',false);
- vboxSettingsSPortContainer.find('input.vboxEnablerCheckbox').triggerHandler('click');
- }
-
-});
-
-/* Change settings onSave() */
-$('#vboxSettingsDialog').on('save',function(){
-
- /* Net */
- for(var i = 0; i < parseInt($('#vboxPane').data('vboxSystemProperties').serialPortCount); i++) {
-
- var a = (i + 1);
-
- // Port IRQ and IO
- $('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].IRQ = $(document.forms['frmVboxSettings'].elements['vboxSettingsSPortIRQ'+a]).val();
- $('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].IOBase = $(document.forms['frmVboxSettings'].elements['vboxSettingsSPortIO'+a]).val();
-
- // Port Mode
- $('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].hostMode = $(document.forms['frmVboxSettings'].elements['vboxSettingsPortMode'+a]).val();
-
- // Create pipe
- $('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].server = document.forms['frmVboxSettings'].elements['vboxSettingsSPortCreatePipe'+a].checked;
-
- // Path
- $('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].path = $(document.forms['frmVboxSettings'].elements['vboxSettingsSPortPath'+a]).val();
-
- // Enabled port
- $('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].enabled = document.forms['frmVboxSettings'].elements['vboxSettingsSPortEnabled'+a].checked;
-
-
- }
-
-});
-
-
+<!--
+ Serial port settings
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: settingsSerialPorts.html 597 2015-04-20 11:41:28Z imoore76 $
+ -->
+<div id='vboxSettingsTabSerialPort' style='display: none'>
+<table class='vboxVertical'>
+ <tr>
+ <td colspan='2'><label><input name='vboxSettingsSPortEnabled' class='vboxCheckbox vboxEnablerCheckbox' type='checkbox' /> <span class='translate'>Enable Serial Port</span></label></td>
+ </tr>
+ <tr>
+ <th style='min-width: 120px'><span class='translate'>Port Number:</span></th>
+ <td class='vboxEnablerTrigger'>
+ <select style='width: auto' name='vboxSettingsPortNumber' onchange='vboxSettingsUpdateSPortOptions(this);'>
+ <option value='COM1'>COM1</option>
+ <option value='COM2'>COM2</option>
+ <option value='COM3'>COM3</option>
+ <option value='COM4'>COM4</option>
+ <option value='User-defined' class='translate'>User-defined</option>
+ </select>
+ <span class='vboxEnablerListen'><span class='translate'>IRQ:</span></span> <input type='text' name='vboxSettingsSPortIRQ' size='2' />
+ <span class='vboxEnablerListen'><span class='translate'>I/O Port:</span></span> <input type='text' name='vboxSettingsSPortIO' size='5' />
+ </td>
+ </tr>
+ <tr>
+ <th><span class='translate'>Port Mode:</span></th>
+ <td class='vboxEnablerTrigger'>
+ <select style='width: auto' name='vboxSettingsPortMode' onchange='vboxSettingsUpdateSPortMode(this);'>
+ <option value='Disconnected' >Disconnected</option>
+ <option value='HostPipe' >HostPipe</option>
+ <option value='HostDevice' >HostDevice</option>
+ <option value='RawFile' >RawFile</option>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <th></th>
+ <td>
+ <label><input type='checkbox' class='vboxCheckbox vboxSettingsSPortCreatePipe' name='vboxSettingsSPortCreatePipe' />
+ <span class='translate vboxEnablerListen'>Create Pipe</span></label>
+ </td>
+ </tr>
+ <tr>
+ <th class='vboxSPortPathLabel'><span class='translate'>Port/File Path:</span></th>
+ <td>
+ <input type='text' class='vboxText vboxSPortPathBox' style='width: 100%' name='vboxSettingsSPortPath'/>
+ </td>
+ </tr>
+</table>
+</div>
+
+<script type='text/javascript'>
+
+
+/*
+ *
+ * Setup data for serial port options
+ *
+ */
+
+var vboxSettingsSPortTemplate = document.getElementById('vboxSettingsTabSerialPort');
+var vboxSettingsSPortContainer = $(vboxSettingsSPortTemplate).parent();
+
+/* translated select values */
+for(var i = 0; i < document.forms['frmVboxSettings'].vboxSettingsPortNumber.options.length; i++) {
+ if($(document.forms['frmVboxSettings'].vboxSettingsPortNumber.options[i]).hasClass('translate'))
+ $(document.forms['frmVboxSettings'].vboxSettingsPortNumber.options[i]).text(trans(document.forms['frmVboxSettings'].vboxSettingsPortNumber.options[i].text,'VBoxGlobal')).removeClass('translate');
+}
+for(var i = 0; i < document.forms['frmVboxSettings'].vboxSettingsPortMode.options.length; i++) {
+ document.forms['frmVboxSettings'].vboxSettingsPortMode.options[i].text = trans(vboxSerialMode(document.forms['frmVboxSettings'].vboxSettingsPortMode.options[i].text),'VBoxGlobal');
+}
+
+// Translations
+$('#vboxSettingsTabSerialPort').find(".translate").html(function(i,h){return trans($('<div />').html(h).text(),'UIMachineSettingsSerial');}).removeClass('translate');
+
+/* Serial Port tab links */
+var ul = $('<ul />');
+$(vboxSettingsSPortContainer).append(ul);
+
+for(var i = 0; i < parseInt($('#vboxPane').data('vboxSystemProperties').serialPortCount); i++) {
+
+
+ /* tab */
+ ul.append($('<li />').html('<a href="#' + vboxSettingsSPortTemplate.id + (i + 1) +'"><span>' + trans('Port %1','UIMachineSettingsSerial').replace('%1',i + 1) + '</span></a>'));
+
+ /* tab content */
+ var newTab = $("#vboxSettingsTabSerialPort").clone(true);
+ newTab.attr({'id':vboxSettingsSPortTemplate.id + (i + 1)}).css({'display':'block'}).find('.vboxEnablerTrigger').on('enable',function(){
+ $(this).find('select').trigger('change');
+ });
+
+ newTab.appendTo(vboxSettingsSPortContainer);
+
+ /* Form elements must be unique */
+ $("#vboxSettingsTabSerialPort" + (i + 1)).find('[name]').each(function() {
+ $(this).attr('name',$(this).attr('name') + (i + 1));
+ });
+
+}
+
+
+/* Remove Template */
+$("#vboxSettingsTabSerialPort").empty().remove();
+
+
+// Tell jQuery to set up tabs
+$(vboxSettingsSPortContainer).tabs();
+
+/*
+ * Called when serial port options change
+ */
+function vboxSettingsUpdateSPortOptions(sel) {
+
+ // IRQ and IO text boxes
+ if(sel.value == 'User-defined') {
+ $(sel).siblings('input').prop('disabled',false);
+ $(sel).siblings('span').removeClass('vboxDisabled');
+ } else {
+ $(sel).siblings('input').prop('disabled',true);
+ $(sel).siblings('span').addClass('vboxDisabled');
+ for(var i = 0; i < vboxSerialPorts.ports.length; i++) {
+ if(vboxSerialPorts.ports[i].name == sel.value) {
+ $(sel).siblings('input').first().val(vboxSerialPorts.ports[i].irq);
+ $(sel).siblings('input').last().val(vboxSerialPorts.ports[i].port);
+ return;
+ }
+ }
+ }
+}
+
+/*
+ * When serial port mode changes
+ */
+function vboxSettingsUpdateSPortMode(sel) {
+ var ptable = $(sel).closest('table');
+ if(sel.value == 'HostPipe') {
+ ptable.find('input.vboxSettingsSPortCreatePipe').prop({'disabled':false}).siblings().removeClass('vboxDisabled');
+ } else {
+ ptable.find('input.vboxSettingsSPortCreatePipe').prop({'disabled':true}).siblings().addClass('vboxDisabled');
+ }
+ if(sel.value == 'Disconnected') {
+ ptable.find('.vboxSPortPathLabel').addClass('vboxDisabled');
+ ptable.find('.vboxSPortPathBox').prop('disabled',true);
+ } else {
+ ptable.find('.vboxSPortPathLabel').removeClass('vboxDisabled');
+ ptable.find('.vboxSPortPathBox').prop('disabled',false);
+ }
+}
+
+
+/* When data is loaded */
+$('#vboxSettingsDialog').on('dataLoaded',function(){
+
+ /*
+ * Serial ports
+ *
+ */
+ for(var i = 0; i < parseInt($('#vboxSettingsDialog').data('vboxMachineData').serialPorts.length); i++) {
+
+ var a = (i + 1);
+
+ if(a > $('#vboxPane').data('vboxSystemProperties').serialPortCount) continue;
+
+ // Port Number
+ var pNum = vboxSerialPorts.getPortName($('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].IRQ,$('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].IOBase);
+ $(document.forms['frmVboxSettings'].elements['vboxSettingsPortNumber'+a]).val(pNum);
+ $(document.forms['frmVboxSettings'].elements['vboxSettingsPortNumber'+a].options[document.forms['frmVboxSettings'].elements['vboxSettingsPortNumber'+a].selectedIndex]).attr('selected','selected');
+ $(document.forms['frmVboxSettings'].elements['vboxSettingsPortNumber'+a]).change();
+
+ $(document.forms['frmVboxSettings'].elements['vboxSettingsSPortIRQ'+a]).val($('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].IRQ);
+ $(document.forms['frmVboxSettings'].elements['vboxSettingsSPortIO'+a]).val($('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].IOBase);
+
+ // Port Mode
+ $(document.forms['frmVboxSettings'].elements['vboxSettingsPortMode'+a]).val($('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].hostMode);
+ $(document.forms['frmVboxSettings'].elements['vboxSettingsPortMode'+a].options[document.forms['frmVboxSettings'].elements['vboxSettingsPortMode'+a].selectedIndex]).attr('selected','selected');
+ $(document.forms['frmVboxSettings'].elements['vboxSettingsPortMode'+a]).change();
+
+ // Create pipe
+ $(document.forms['frmVboxSettings'].elements['vboxSettingsSPortCreatePipe'+a]).prop('checked',($('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].server ? true : false)).triggerHandler('click');
+
+ // Path
+ $(document.forms['frmVboxSettings'].elements['vboxSettingsSPortPath'+a]).val($('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].path);
+
+ // Enabled
+ $(document.forms['frmVboxSettings'].elements['vboxSettingsSPortEnabled'+a]).prop('checked',($('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].enabled));
+
+ }
+
+ if(!$('#vboxSettingsDialog').data('vboxFullEdit')) {
+ vboxSettingsSPortContainer.find('input.vboxEnablerCheckbox').triggerHandler('click');
+ vboxSettingsSPortContainer.children(':not(ul)').find('span').addClass('disabled');
+ vboxSettingsSPortContainer.find('input,select,textarea').prop('disabled',true);
+ } else {
+ vboxSettingsSPortContainer.find('span').removeClass('disabled');
+ vboxSettingsSPortContainer.find('input,select,textarea').prop('disabled',false);
+ vboxSettingsSPortContainer.find('input.vboxEnablerCheckbox').triggerHandler('click');
+ }
+
+});
+
+/* Change settings onSave() */
+$('#vboxSettingsDialog').on('save',function(){
+
+ /* Net */
+ for(var i = 0; i < parseInt($('#vboxPane').data('vboxSystemProperties').serialPortCount); i++) {
+
+ var a = (i + 1);
+
+ // Port IRQ and IO
+ $('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].IRQ = $(document.forms['frmVboxSettings'].elements['vboxSettingsSPortIRQ'+a]).val();
+ $('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].IOBase = $(document.forms['frmVboxSettings'].elements['vboxSettingsSPortIO'+a]).val();
+
+ // Port Mode
+ $('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].hostMode = $(document.forms['frmVboxSettings'].elements['vboxSettingsPortMode'+a]).val();
+
+ // Create pipe
+ $('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].server = document.forms['frmVboxSettings'].elements['vboxSettingsSPortCreatePipe'+a].checked;
+
+ // Path
+ $('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].path = $(document.forms['frmVboxSettings'].elements['vboxSettingsSPortPath'+a]).val();
+
+ // Enabled port
+ $('#vboxSettingsDialog').data('vboxMachineData').serialPorts[i].enabled = document.forms['frmVboxSettings'].elements['vboxSettingsSPortEnabled'+a].checked;
+
+
+ }
+
+});
+
+
</script> \ No newline at end of file
diff --git a/panes/settingsSharedFolders.html b/panes/settingsSharedFolders.html
index b94be01..f1b2362 100644
--- a/panes/settingsSharedFolders.html
+++ b/panes/settingsSharedFolders.html
@@ -1,365 +1,365 @@
-<!--
-
- Shared Folders
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: settingsSharedFolders.html 595 2015-04-17 09:50:36Z imoore76 $
-
--->
-<table style='width: 100%' id='vboxSettingsSharedFoldersTable'>
- <tr style='vertical-align: middle'>
- <td style='width: 100%'>
- <table class='vboxSettingsHeadingLine' style='width:100%;border-spacing:0;border:0px;margin:0px;padding:0px;'><tr style='vertical-align:middle'><td style='white-space: nowrap; width: auto;'><span class='translate'>Folders List</span></td><td style='width: 100%'><hr style='width: 100%;' class='vboxSeparatorLine'/></td></tr></table>
- </td>
- </tr>
- <tr>
- <td style='width: 100%'>
- <table style='width: 100%'>
- <tr>
- <td style='width: 100%'>
- <div style='overflow: auto;' class='vboxBordered' id='vboxSettingsSharedFolders'>
- <table class='vboxHorizontal' id='vboxSettingsSharedFoldersList'>
- <thead>
- <tr id='vboxSettingsSharedFoldersHeading'>
- <th><span class='translate'>Name</span></th>
- <th style='width: 100%; white-space: nowrap;'><span class='translate'>Path</span></th>
- <th><span class='translate'>Auto-Mount</span></th>
- <th><span class='translate'>Access</span></th>
- </tr>
- </thead>
- </table>
- </div>
- </td>
- <td id='vboxSettingsSFButtons'></td>
- </tr>
- </table>
- </td>
- </tr>
-
-</table>
-<script type='text/javascript'>
-
-/*
- * Init Shared Folder buttons and toolbar
- */
-
-var sButtons = new Array(
-
- {
- 'name': 'addshared',
- 'label': 'Add Shared Folder',
- 'icon': 'sf_add',
- 'enabled': function (item) { return true; },
- 'click': function () {
-
- var dialog = vboxSettingsSFEditDialog();
-
- $('#vboxSettingsSFPath').val('');
- $('#vboxSettingsSFName').val('');
- $('#vboxSettingsSFAM').prop('checked',false);
- $('#vboxSettingsSFRO').prop('checked',false);
- $('#vboxSettingsSFPerm').prop('checked',false);
-
- var buttons = { };
- buttons[trans('OK','QIMessageBox')] = function() {
- if($('#vboxSettingsSFName').val() && $('#vboxSettingsSFPath').val()) {
- var f = {'name':$('#vboxSettingsSFName').val(),'hostPath':$('#vboxSettingsSFPath').val(),'autoMount':($('#vboxSettingsSFAM').prop('checked')),'writable':!($('#vboxSettingsSFRO').prop('checked'))};
- if($('#vboxSettingsSFPerm').length) {
- f['type'] = ($('#vboxSettingsSFPerm').prop('checked') ? 'machine' : '');
- } else {
- f['type'] = 'machine';
- }
- var row = vboxSettingsAddSharedFolder(f);
- $(row).children('td').last().trigger('click');
- }
- $(dialog).empty().remove();
- };
- buttons[trans('Cancel','QIMessageBox')] = function() { $(dialog).empty().remove(); };
- $(dialog).dialog({'buttons':buttons,'title':'<img src="images/vbox/sf_16px.png" class="vboxDialogTitleIcon" /> '+trans('Add Share','UIMachineSettingsSFDetails')}).dialog('open');
-
- }
- },
-
- {
- 'name': 'editshared',
- 'label': 'Edit Shared Folder',
- 'icon': 'sf_edit',
- 'enabled': function (item) { return $(item).hasClass('vboxListItemSelected'); },
- 'click': function () {
-
- var dialog = vboxSettingsSFEditDialog();
-
- var def = $('#vboxSettingsSharedFoldersList').find('tr.vboxListItemSelected').first();
- $('#vboxSettingsSFPath').val(($(def).data('hostPath')||''));
- $('#vboxSettingsSFName').val(($(def).data('name')||''));
- $('#vboxSettingsSFAM').prop('checked',($(def).data('autoMount') ? true : false));
- $('#vboxSettingsSFRO').prop('checked',($(def).data('writable') ? false : true));
- $('#vboxSettingsSFPerm').prop('checked',($(def).data('type') == 'machine' ? true : false));
-
- var buttons = { };
- buttons[trans('OK','QIMessageBox')] = function() {
- if($('#vboxSettingsSFName').val() && $('#vboxSettingsSFPath').val()) {
- var item = $('#vboxSettingsSharedFoldersList').find('tr.vboxListItemSelected').first();
- $(item).data({
- 'hostPath' : $('#vboxSettingsSFPath').val(),
- 'name' : $('#vboxSettingsSFName').val(),
- 'autoMount' : ($('#vboxSettingsSFAM').prop('checked')),
- 'writable' : !($('#vboxSettingsSFRO').prop('checked')),
- 'type' : ((!$('#vboxSettingsSFPerm').length || $('#vboxSettingsSFPerm').prop('checked')) ? 'machine' : '')
- }).trigger('refresh');
- }
- $(dialog).empty().remove();
- };
- buttons[trans('Cancel','QIMessageBox')] = function() { $(dialog).empty().remove(); };
- $(dialog).dialog({'buttons':buttons}).dialog('open');
-
- }
- },
-
- {
- 'name' : 'removeshared',
- 'label' : 'Remove Shared Folder',
- 'icon' : 'sf_remove',
- 'enabled' : function (item) { return $(item).hasClass('vboxListItemSelected'); },
- 'click' : function () {
- var item = $('#vboxSettingsSharedFoldersList').find('.vboxListItemSelected').first();
- var target = $(item).next();
- if(!$(target).hasClass('vboxListItemSelected')) target = $(item).prev();
- if(!$(target).hasClass('vboxListItemSelected')) target = $('#vboxSettingsSharedFoldersList').find('.vboxListItem').first();
- $('#vboxSettingsSharedFoldersList').find('tr.vboxListItemSelected').first().remove();
- if(!$(target).children().first().trigger('click').hasClass('vboxListItemSelected')) {
- $('#vboxSettingsSharedFoldersList').trigger('select',null);
- }
- }
- }
-
- );
-
-var sfToolbar = new vboxToolbarSmall({buttons: sButtons,
- language_context: 'UIMachineSettingsSF', renderTo: 'vboxSettingsSFButtons'});
-
-$('#vboxSettingsSharedFoldersList').on('select',function(e,el){sfToolbar.update(el);});
-
-/* Add Shared Folder to list */
-
-function vboxSettingsAddSharedFolder(f, noColor) {
-
- var tr = $('<tr />').attr({'class':'vboxListItem'}).addClass(f.type == 'machine' ? 'vboxSFMachine' : 'vboxSFTransient').on('refresh',function(){
-
- // bind refresh
- $(this).children('td.vboxSettingsSFNameCell').children('span').first().html($('<div/>').text($(this).data('name')).html());
- $(this).children('td.vboxSettingsSFPathCell').html($('<div/>').text($(this).data('hostPath')).html());
- $(this).children('td.vboxSettingsSFAMCell').html($(this).data('autoMount') ? trans('Yes','UIMachineSettingsSF') : '');
- $(this).children('td.vboxSettingsSFROCell').html($(this).data('writable') ? trans('Full','UIMachineSettingsSF') : trans('Read-only','UIMachineSettingsSF'));
-
- // Move from one type to another
- if($(this).data('type') == 'machine' && $(this).hasClass('vboxSFTransient')) {
- $(this).removeClass('vboxSFTransient').addClass('vboxSFMachine').detach().appendTo('#vboxSFMachineBody');
- vboxColorRows($('#vboxSFMachineBody'));
- vboxColorRows($('#vboxSFTransientBody'));
- } else if($(this).data('type') != 'machine' && $(this).hasClass('vboxSFMachine')) {
- $(this).removeClass('vboxSFMachine').addClass('vboxSFTransient').detach().appendTo('#vboxSFTransientBody');
- vboxColorRows($('#vboxSFMachineBody'));
- vboxColorRows($('#vboxSFTransientBody'));
- }
-
-
- }).hoverClass('vboxHover').disableSelection().data(f);
-
- // Name
- $('<td />').attr({'class':'vboxSettingsSFNameCell vboxHoverFirst'}).append($('<img />').attr({'src':'images/vbox/blank.gif','style':'height: 10px; width: 30px;'})).append($('<span />').html($('<div/>').text(f.name).html())).appendTo(tr);
-
- // Path
- $('<td />').attr({'class':'vboxSettingsSFPathCell vboxHoverMid'}).html($('<div/>').text(f.hostPath).html()).appendTo(tr);
-
- // auto-mount?
- $('<td />').attr({'class':'vboxSettingsSFAMCell vboxHoverMid'}).html(f.autoMount ? trans('Yes','UIMachineSettingsSF') : '').appendTo(tr);
-
- // Read only?
- $('<td />').attr({'class':'vboxSettingsSFROCell vboxHoverLast'}).html(f.writable ? trans('Full','UIMachineSettingsSF') : trans('Read-only','UIMachineSettingsSF')).appendTo(tr);
-
-
- $(tr).children().click(function(){
- $('#vboxSettingsSharedFoldersList').find('tr.vboxListItemSelected').removeClass('vboxListItemSelected').addClass('vboxListItem');
- $(this).parent().removeClass('vboxListItem').addClass('vboxListItemSelected');
- $('#vboxSettingsSharedFoldersList').trigger('select',$(this).parent());
-
- }).dblclick(function(e){
- sfToolbar.click('editshared');
- e.preventDefault();
-
- });
-
- if(f.type == 'machine') {
- $('#vboxSFMachineBody').append(tr);
- if(!noColor) vboxColorRows($('#vboxSFMachineBody'));
- } else {
- $('#vboxSFTransientBody').append(tr);
- if(!noColor) vboxColorRows($('#vboxSFTransientBody'));
- }
-
- return tr;
-}
-
-/*
- *
- *
- * Load SF data
- *
- */
-
- $('#vboxSettingsDialog').on('dataLoaded',function(){
-
- /* Shared Folders */
- var sfh = $('#vboxSettingsSharedFoldersList');
- sfh.children('tbody').empty().remove();
-
- /*
- *
- Add 'Machine Folder's
- *
- */
- var tb = $('<tbody />').attr({'id':'vboxSFMachineBody'}).addClass('vboxHover');
- var tr = $('<tr />').attr({'class':'vboxListItemDisabled'}).disableSelection();
- var td = $('<td />').attr({'class':'vboxSettingsSFNameCell'});
- $('<input />').attr({'type':'button','class':'vboxImgButton','style':'background-image: url(images/vbox/arrow_down_10px.png); width: 12px; height: 12px; margin-right: 4px;'}).click(function(){
-
- if(!$(this).data('toggleClicked')) {
-
- $(this).data('toggleClicked', true);
- $(this).css({'background-image':'url(images/vbox/arrow_right_10px.png)'});
- $('#vboxSettingsSharedFoldersList').trigger('select',null);
- $('#vboxSFMachineBody').children('tr.vboxSFMachine').css({'display':'none'}).removeClass('vboxListItemSelected').addClass('vboxListItem');
-
- } else {
-
- $(this).data('toggleClicked', false);
- $(this).css({'background-image':'url(images/vbox/arrow_down_10px.png)'});
- $('#vboxSettingsSharedFoldersList').trigger('select',null);
- $('#vboxSFMachineBody').children('tr.vboxSFMachine').css({'display':''});
- }
-
- }).appendTo(td);
- $(td).append($('<span />').html($('<div/>').text(trans(' Machine Folders','UIMachineSettingsSF')).html())).appendTo(tr);
- $(tb).append($(tr).append($('<td />').attr({'class':'vboxSettingsSFPathCell'})).append($('<td />').attr({'class':'vboxSettingsSFAMCell'})).append($('<td />').attr({'class':'vboxSettingsSFROCell'}))).appendTo(sfh);
-
- /*
- *
- * Add 'Transient Folders' if machine is running
- *
- */
- if(vboxVMStates.isRunning($('#vboxSettingsDialog').data('vboxMachineData')) || vboxVMStates.isSaved($('#vboxSettingsDialog').data('vboxMachineData')) || vboxVMStates.isPaused($('#vboxSettingsDialog').data('vboxMachineData'))) {
-
- var tb = $('<tbody />').attr({'id':'vboxSFTransientBody'}).addClass('vboxHover');
- var tr = $('<tr />').attr({'class':'vboxListItemDisabled'}).disableSelection();
-
- $('<td />').attr({'class':'vboxSettingsSFNameCell'}).append(
- $('<input />').attr({'type':'button','class':'vboxImgButton','style':'background-image: url(images/vbox/arrow_down_10px.png); width: 12px; height: 12px; margin-right: 4px;'}).click(function(){
-
- if(!$(this).data('toggleClicked')) {
-
- $(this).data('toggleClicked', true);
-
- $(this).css({'background-image':'url(images/vbox/arrow_right_10px.png)'});
- $('#vboxSettingsSharedFoldersList').trigger('select',null);
- $('#vboxSFTransientBody').children('tr.vboxSFTransient').css({'display':'none'}).removeClass('vboxListItemSelected').addClass('vboxListItem');
-
- } else {
- $(this).data('toggleClicked', false);
- $(this).css({'background-image':'url(images/vbox/arrow_down_10px.png)'});
- $('#vboxSettingsSharedFoldersList').trigger('select',null);
- $('#vboxSFTransientBody').children('tr.vboxSFTransient').css('display','');
- }
- })).append($('<span />').html($('<div/>').text(trans(' Transient Folders','UIMachineSettingsSF')).html())).appendTo(tr);
-
- $(tr).append($('<td />').attr({'class':'vboxSettingsSFPathCell'})).append($('<td />').attr({'class':'vboxSettingsSFAMCell'})).append($('<td />').attr({'class':'vboxSettingsSFROCell'}));
- $(tb).append(tr).appendTo(sfh);
-
- // add each transient folder
- for(var i = 0; i < $('#vboxSettingsDialog').data('vboxTransientSharedFolders').length; i++) {
- vboxSettingsAddSharedFolder($('#vboxSettingsDialog').data('vboxTransientSharedFolders')[i]);
- }
-
-
- }
-
- // add each machine folder
- for(var i = 0; i < $('#vboxSettingsDialog').data('vboxMachineData').sharedFolders.length; i++) {
- vboxSettingsAddSharedFolder($('#vboxSettingsDialog').data('vboxMachineData').sharedFolders[i]);
- }
-
- $('#vboxSettingsSharedFoldersList').trigger('select',null);
-
-});
-
-/* Update Shared Folder path and name. Callback for folder browser */
-function vboxSFBrowseFolder(btn) {
- vboxFileBrowser($('#vboxSettingsSFPath').val(),function(f) {
- if(!f) return;
- $('#vboxSettingsSFPath').val(f);
- if(!$('#vboxSettingsSFName').val()) {
- f = f.replace(/.*\//,'');
- f = f.replace(/.*\\/,'');
- if(f) $('#vboxSettingsSFName').val(f);
- }
- },true,trans('Folder Path:','UIMachineSettingsSFDetails').replace(':',''));
-}
-/*
- *
- *
- * Shared Folder Properties Screen
- *
- *
- */
-function vboxSettingsSFEditDialog() {
-
- var d = $('<div />').attr({'id':'vboxSettingsSFEdit','class':'vboxNonTabbed vboxDialogContent','style':'display: none;'});
-
- var tbl = $('<table />').attr({'style':'width: 100%','class':'vboxSettingsTable'});
-
- // Path
- $('<tr />').attr({'style':'vertical-align: middle'}).append($('<th />').attr({'style':'white-space: nowrap'}).html(trans('Folder Path:','UIMachineSettingsSFDetails'))).append(
- $('<td />').attr({'style':'white-space: nowrap'}).html('<table style="width: 100%"><tr><td style="width: 100%"><input type="text" class="vboxText" id="vboxSettingsSFPath" style="width: 100%"/></td><td style="width: auto" class="vboxFileFolderInput"><input type="button" class="vboxImgButton" style="background-image: url(images/vbox/select_file_16px.png)" onClick="vboxSFBrowseFolder(this)" /></td></tr></table>')
- ).appendTo(tbl);
-
- // Name
- $('<tr />').append($('<th />').html(trans('Folder Name:','UIMachineSettingsSFDetails'))).append($('<td />').html('<input type="text" class="vboxText" id="vboxSettingsSFName" style="width: 100%" />')).appendTo(tbl);
-
- // Read only
- $('<tr />').append($('<th />')).append($('<td />').html('<label><input type="checkbox" class="vboxCheckbox" id="vboxSettingsSFRO" /> ' + trans('Read-only','UIMachineSettingsSFDetails')+'</label>')).appendTo(tbl);
-
- // Auto mount
- $('<tr />').append($('<th />')).append($('<td />').html('<label><input type="checkbox" class="vboxCheckbox" id="vboxSettingsSFAM" /> ' + trans('Auto-mount','UIMachineSettingsSFDetails')+'</label>')).appendTo(tbl);
-
- // Add "Make Permanent"?
- if(vboxVMStates.isRunning($('#vboxSettingsDialog').data('vboxMachineData')) || vboxVMStates.isSaved($('#vboxSettingsDialog').data('vboxMachineData')) || vboxVMStates.isPaused($('#vboxSettingsDialog').data('vboxMachineData'))) {
-
- $('<tr />').append($('<th />')).append($('<td />').html('<label><input type="checkbox" class="vboxCheckbox" id="vboxSettingsSFPerm" /> ' + trans('Make Permanent','UIMachineSettingsSFDetails')+'</label>')).appendTo(tbl);
- }
-
- $(d).append(tbl).dialog({'width':800,'modal':true,'autoOpen':false,'dialogClass':'vboxDialogContent vboxNonTabbed','title':'<img src="images/vbox/sf_16px.png" class="vboxDialogTitleIcon" /> '+trans('Edit Share','UIMachineSettingsSFDetails')});
-
- return $('#vboxSettingsSFEdit');
-}
-
-
-
-/* Change settings onSave() */
-$('#vboxSettingsDialog').on('save',function(){
-
- $('#vboxSettingsDialog').data('vboxMachineData').sharedFolders = new Array();
-
- var folders = new Array();
- $('#vboxSettingsSharedFoldersList').find('tr').each(function(){
- // Skip headers and such
- if($(this).data('name')) {
- folders[folders.length] = {'name':$(this).data('name'),'hostPath':$(this).data('hostPath'),'autoMount':($(this).data('autoMount') ? true : false),'writable':($(this).data('writable') ? true : false),'type':$(this).data('type')};
- }
- });
- $('#vboxSettingsDialog').data('vboxMachineData').sharedFolders = folders;
-
-});
-
-
-</script>
-
+<!--
+
+ Shared Folders
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: settingsSharedFolders.html 595 2015-04-17 09:50:36Z imoore76 $
+
+-->
+<table style='width: 100%' id='vboxSettingsSharedFoldersTable'>
+ <tr style='vertical-align: middle'>
+ <td style='width: 100%'>
+ <table class='vboxSettingsHeadingLine' style='width:100%;border-spacing:0;border:0px;margin:0px;padding:0px;'><tr style='vertical-align:middle'><td style='white-space: nowrap; width: auto;'><span class='translate'>Folders List</span></td><td style='width: 100%'><hr style='width: 100%;' class='vboxSeparatorLine'/></td></tr></table>
+ </td>
+ </tr>
+ <tr>
+ <td style='width: 100%'>
+ <table style='width: 100%'>
+ <tr>
+ <td style='width: 100%'>
+ <div style='overflow: auto;' class='vboxBordered' id='vboxSettingsSharedFolders'>
+ <table class='vboxHorizontal' id='vboxSettingsSharedFoldersList'>
+ <thead>
+ <tr id='vboxSettingsSharedFoldersHeading'>
+ <th><span class='translate'>Name</span></th>
+ <th style='width: 100%; white-space: nowrap;'><span class='translate'>Path</span></th>
+ <th><span class='translate'>Auto-Mount</span></th>
+ <th><span class='translate'>Access</span></th>
+ </tr>
+ </thead>
+ </table>
+ </div>
+ </td>
+ <td id='vboxSettingsSFButtons'></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+
+</table>
+<script type='text/javascript'>
+
+/*
+ * Init Shared Folder buttons and toolbar
+ */
+
+var sButtons = new Array(
+
+ {
+ 'name': 'addshared',
+ 'label': 'Add Shared Folder',
+ 'icon': 'sf_add',
+ 'enabled': function (item) { return true; },
+ 'click': function () {
+
+ var dialog = vboxSettingsSFEditDialog();
+
+ $('#vboxSettingsSFPath').val('');
+ $('#vboxSettingsSFName').val('');
+ $('#vboxSettingsSFAM').prop('checked',false);
+ $('#vboxSettingsSFRO').prop('checked',false);
+ $('#vboxSettingsSFPerm').prop('checked',false);
+
+ var buttons = { };
+ buttons[trans('OK','QIMessageBox')] = function() {
+ if($('#vboxSettingsSFName').val() && $('#vboxSettingsSFPath').val()) {
+ var f = {'name':$('#vboxSettingsSFName').val(),'hostPath':$('#vboxSettingsSFPath').val(),'autoMount':($('#vboxSettingsSFAM').prop('checked')),'writable':!($('#vboxSettingsSFRO').prop('checked'))};
+ if($('#vboxSettingsSFPerm').length) {
+ f['type'] = ($('#vboxSettingsSFPerm').prop('checked') ? 'machine' : '');
+ } else {
+ f['type'] = 'machine';
+ }
+ var row = vboxSettingsAddSharedFolder(f);
+ $(row).children('td').last().trigger('click');
+ }
+ $(dialog).empty().remove();
+ };
+ buttons[trans('Cancel','QIMessageBox')] = function() { $(dialog).empty().remove(); };
+ $(dialog).dialog({'buttons':buttons,'title':'<img src="images/vbox/sf_16px.png" class="vboxDialogTitleIcon" /> '+trans('Add Share','UIMachineSettingsSFDetails')}).dialog('open');
+
+ }
+ },
+
+ {
+ 'name': 'editshared',
+ 'label': 'Edit Shared Folder',
+ 'icon': 'sf_edit',
+ 'enabled': function (item) { return $(item).hasClass('vboxListItemSelected'); },
+ 'click': function () {
+
+ var dialog = vboxSettingsSFEditDialog();
+
+ var def = $('#vboxSettingsSharedFoldersList').find('tr.vboxListItemSelected').first();
+ $('#vboxSettingsSFPath').val(($(def).data('hostPath')||''));
+ $('#vboxSettingsSFName').val(($(def).data('name')||''));
+ $('#vboxSettingsSFAM').prop('checked',($(def).data('autoMount') ? true : false));
+ $('#vboxSettingsSFRO').prop('checked',($(def).data('writable') ? false : true));
+ $('#vboxSettingsSFPerm').prop('checked',($(def).data('type') == 'machine' ? true : false));
+
+ var buttons = { };
+ buttons[trans('OK','QIMessageBox')] = function() {
+ if($('#vboxSettingsSFName').val() && $('#vboxSettingsSFPath').val()) {
+ var item = $('#vboxSettingsSharedFoldersList').find('tr.vboxListItemSelected').first();
+ $(item).data({
+ 'hostPath' : $('#vboxSettingsSFPath').val(),
+ 'name' : $('#vboxSettingsSFName').val(),
+ 'autoMount' : ($('#vboxSettingsSFAM').prop('checked')),
+ 'writable' : !($('#vboxSettingsSFRO').prop('checked')),
+ 'type' : ((!$('#vboxSettingsSFPerm').length || $('#vboxSettingsSFPerm').prop('checked')) ? 'machine' : '')
+ }).trigger('refresh');
+ }
+ $(dialog).empty().remove();
+ };
+ buttons[trans('Cancel','QIMessageBox')] = function() { $(dialog).empty().remove(); };
+ $(dialog).dialog({'buttons':buttons}).dialog('open');
+
+ }
+ },
+
+ {
+ 'name' : 'removeshared',
+ 'label' : 'Remove Shared Folder',
+ 'icon' : 'sf_remove',
+ 'enabled' : function (item) { return $(item).hasClass('vboxListItemSelected'); },
+ 'click' : function () {
+ var item = $('#vboxSettingsSharedFoldersList').find('.vboxListItemSelected').first();
+ var target = $(item).next();
+ if(!$(target).hasClass('vboxListItemSelected')) target = $(item).prev();
+ if(!$(target).hasClass('vboxListItemSelected')) target = $('#vboxSettingsSharedFoldersList').find('.vboxListItem').first();
+ $('#vboxSettingsSharedFoldersList').find('tr.vboxListItemSelected').first().remove();
+ if(!$(target).children().first().trigger('click').hasClass('vboxListItemSelected')) {
+ $('#vboxSettingsSharedFoldersList').trigger('select',null);
+ }
+ }
+ }
+
+ );
+
+var sfToolbar = new vboxToolbarSmall({buttons: sButtons,
+ language_context: 'UIMachineSettingsSF', renderTo: 'vboxSettingsSFButtons'});
+
+$('#vboxSettingsSharedFoldersList').on('select',function(e,el){sfToolbar.update(el);});
+
+/* Add Shared Folder to list */
+
+function vboxSettingsAddSharedFolder(f, noColor) {
+
+ var tr = $('<tr />').attr({'class':'vboxListItem'}).addClass(f.type == 'machine' ? 'vboxSFMachine' : 'vboxSFTransient').on('refresh',function(){
+
+ // bind refresh
+ $(this).children('td.vboxSettingsSFNameCell').children('span').first().html($('<div/>').text($(this).data('name')).html());
+ $(this).children('td.vboxSettingsSFPathCell').html($('<div/>').text($(this).data('hostPath')).html());
+ $(this).children('td.vboxSettingsSFAMCell').html($(this).data('autoMount') ? trans('Yes','UIMachineSettingsSF') : '');
+ $(this).children('td.vboxSettingsSFROCell').html($(this).data('writable') ? trans('Full','UIMachineSettingsSF') : trans('Read-only','UIMachineSettingsSF'));
+
+ // Move from one type to another
+ if($(this).data('type') == 'machine' && $(this).hasClass('vboxSFTransient')) {
+ $(this).removeClass('vboxSFTransient').addClass('vboxSFMachine').detach().appendTo('#vboxSFMachineBody');
+ vboxColorRows($('#vboxSFMachineBody'));
+ vboxColorRows($('#vboxSFTransientBody'));
+ } else if($(this).data('type') != 'machine' && $(this).hasClass('vboxSFMachine')) {
+ $(this).removeClass('vboxSFMachine').addClass('vboxSFTransient').detach().appendTo('#vboxSFTransientBody');
+ vboxColorRows($('#vboxSFMachineBody'));
+ vboxColorRows($('#vboxSFTransientBody'));
+ }
+
+
+ }).hoverClass('vboxHover').disableSelection().data(f);
+
+ // Name
+ $('<td />').attr({'class':'vboxSettingsSFNameCell vboxHoverFirst'}).append($('<img />').attr({'src':'images/vbox/blank.gif','style':'height: 10px; width: 30px;'})).append($('<span />').html($('<div/>').text(f.name).html())).appendTo(tr);
+
+ // Path
+ $('<td />').attr({'class':'vboxSettingsSFPathCell vboxHoverMid'}).html($('<div/>').text(f.hostPath).html()).appendTo(tr);
+
+ // auto-mount?
+ $('<td />').attr({'class':'vboxSettingsSFAMCell vboxHoverMid'}).html(f.autoMount ? trans('Yes','UIMachineSettingsSF') : '').appendTo(tr);
+
+ // Read only?
+ $('<td />').attr({'class':'vboxSettingsSFROCell vboxHoverLast'}).html(f.writable ? trans('Full','UIMachineSettingsSF') : trans('Read-only','UIMachineSettingsSF')).appendTo(tr);
+
+
+ $(tr).children().click(function(){
+ $('#vboxSettingsSharedFoldersList').find('tr.vboxListItemSelected').removeClass('vboxListItemSelected').addClass('vboxListItem');
+ $(this).parent().removeClass('vboxListItem').addClass('vboxListItemSelected');
+ $('#vboxSettingsSharedFoldersList').trigger('select',$(this).parent());
+
+ }).dblclick(function(e){
+ sfToolbar.click('editshared');
+ e.preventDefault();
+
+ });
+
+ if(f.type == 'machine') {
+ $('#vboxSFMachineBody').append(tr);
+ if(!noColor) vboxColorRows($('#vboxSFMachineBody'));
+ } else {
+ $('#vboxSFTransientBody').append(tr);
+ if(!noColor) vboxColorRows($('#vboxSFTransientBody'));
+ }
+
+ return tr;
+}
+
+/*
+ *
+ *
+ * Load SF data
+ *
+ */
+
+ $('#vboxSettingsDialog').on('dataLoaded',function(){
+
+ /* Shared Folders */
+ var sfh = $('#vboxSettingsSharedFoldersList');
+ sfh.children('tbody').empty().remove();
+
+ /*
+ *
+ Add 'Machine Folder's
+ *
+ */
+ var tb = $('<tbody />').attr({'id':'vboxSFMachineBody'}).addClass('vboxHover');
+ var tr = $('<tr />').attr({'class':'vboxListItemDisabled'}).disableSelection();
+ var td = $('<td />').attr({'class':'vboxSettingsSFNameCell'});
+ $('<input />').attr({'type':'button','class':'vboxImgButton','style':'background-image: url(images/vbox/arrow_down_10px.png); width: 12px; height: 12px; margin-right: 4px;'}).click(function(){
+
+ if(!$(this).data('toggleClicked')) {
+
+ $(this).data('toggleClicked', true);
+ $(this).css({'background-image':'url(images/vbox/arrow_right_10px.png)'});
+ $('#vboxSettingsSharedFoldersList').trigger('select',null);
+ $('#vboxSFMachineBody').children('tr.vboxSFMachine').css({'display':'none'}).removeClass('vboxListItemSelected').addClass('vboxListItem');
+
+ } else {
+
+ $(this).data('toggleClicked', false);
+ $(this).css({'background-image':'url(images/vbox/arrow_down_10px.png)'});
+ $('#vboxSettingsSharedFoldersList').trigger('select',null);
+ $('#vboxSFMachineBody').children('tr.vboxSFMachine').css({'display':''});
+ }
+
+ }).appendTo(td);
+ $(td).append($('<span />').html($('<div/>').text(trans(' Machine Folders','UIMachineSettingsSF')).html())).appendTo(tr);
+ $(tb).append($(tr).append($('<td />').attr({'class':'vboxSettingsSFPathCell'})).append($('<td />').attr({'class':'vboxSettingsSFAMCell'})).append($('<td />').attr({'class':'vboxSettingsSFROCell'}))).appendTo(sfh);
+
+ /*
+ *
+ * Add 'Transient Folders' if machine is running
+ *
+ */
+ if(vboxVMStates.isRunning($('#vboxSettingsDialog').data('vboxMachineData')) || vboxVMStates.isSaved($('#vboxSettingsDialog').data('vboxMachineData')) || vboxVMStates.isPaused($('#vboxSettingsDialog').data('vboxMachineData'))) {
+
+ var tb = $('<tbody />').attr({'id':'vboxSFTransientBody'}).addClass('vboxHover');
+ var tr = $('<tr />').attr({'class':'vboxListItemDisabled'}).disableSelection();
+
+ $('<td />').attr({'class':'vboxSettingsSFNameCell'}).append(
+ $('<input />').attr({'type':'button','class':'vboxImgButton','style':'background-image: url(images/vbox/arrow_down_10px.png); width: 12px; height: 12px; margin-right: 4px;'}).click(function(){
+
+ if(!$(this).data('toggleClicked')) {
+
+ $(this).data('toggleClicked', true);
+
+ $(this).css({'background-image':'url(images/vbox/arrow_right_10px.png)'});
+ $('#vboxSettingsSharedFoldersList').trigger('select',null);
+ $('#vboxSFTransientBody').children('tr.vboxSFTransient').css({'display':'none'}).removeClass('vboxListItemSelected').addClass('vboxListItem');
+
+ } else {
+ $(this).data('toggleClicked', false);
+ $(this).css({'background-image':'url(images/vbox/arrow_down_10px.png)'});
+ $('#vboxSettingsSharedFoldersList').trigger('select',null);
+ $('#vboxSFTransientBody').children('tr.vboxSFTransient').css('display','');
+ }
+ })).append($('<span />').html($('<div/>').text(trans(' Transient Folders','UIMachineSettingsSF')).html())).appendTo(tr);
+
+ $(tr).append($('<td />').attr({'class':'vboxSettingsSFPathCell'})).append($('<td />').attr({'class':'vboxSettingsSFAMCell'})).append($('<td />').attr({'class':'vboxSettingsSFROCell'}));
+ $(tb).append(tr).appendTo(sfh);
+
+ // add each transient folder
+ for(var i = 0; i < $('#vboxSettingsDialog').data('vboxTransientSharedFolders').length; i++) {
+ vboxSettingsAddSharedFolder($('#vboxSettingsDialog').data('vboxTransientSharedFolders')[i]);
+ }
+
+
+ }
+
+ // add each machine folder
+ for(var i = 0; i < $('#vboxSettingsDialog').data('vboxMachineData').sharedFolders.length; i++) {
+ vboxSettingsAddSharedFolder($('#vboxSettingsDialog').data('vboxMachineData').sharedFolders[i]);
+ }
+
+ $('#vboxSettingsSharedFoldersList').trigger('select',null);
+
+});
+
+/* Update Shared Folder path and name. Callback for folder browser */
+function vboxSFBrowseFolder(btn) {
+ vboxFileBrowser($('#vboxSettingsSFPath').val(),function(f) {
+ if(!f) return;
+ $('#vboxSettingsSFPath').val(f);
+ if(!$('#vboxSettingsSFName').val()) {
+ f = f.replace(/.*\//,'');
+ f = f.replace(/.*\\/,'');
+ if(f) $('#vboxSettingsSFName').val(f);
+ }
+ },true,trans('Folder Path:','UIMachineSettingsSFDetails').replace(':',''));
+}
+/*
+ *
+ *
+ * Shared Folder Properties Screen
+ *
+ *
+ */
+function vboxSettingsSFEditDialog() {
+
+ var d = $('<div />').attr({'id':'vboxSettingsSFEdit','class':'vboxNonTabbed vboxDialogContent','style':'display: none;'});
+
+ var tbl = $('<table />').attr({'style':'width: 100%','class':'vboxSettingsTable'});
+
+ // Path
+ $('<tr />').attr({'style':'vertical-align: middle'}).append($('<th />').attr({'style':'white-space: nowrap'}).html(trans('Folder Path:','UIMachineSettingsSFDetails'))).append(
+ $('<td />').attr({'style':'white-space: nowrap'}).html('<table style="width: 100%"><tr><td style="width: 100%"><input type="text" class="vboxText" id="vboxSettingsSFPath" style="width: 100%"/></td><td style="width: auto" class="vboxFileFolderInput"><input type="button" class="vboxImgButton" style="background-image: url(images/vbox/select_file_16px.png)" onClick="vboxSFBrowseFolder(this)" /></td></tr></table>')
+ ).appendTo(tbl);
+
+ // Name
+ $('<tr />').append($('<th />').html(trans('Folder Name:','UIMachineSettingsSFDetails'))).append($('<td />').html('<input type="text" class="vboxText" id="vboxSettingsSFName" style="width: 100%" />')).appendTo(tbl);
+
+ // Read only
+ $('<tr />').append($('<th />')).append($('<td />').html('<label><input type="checkbox" class="vboxCheckbox" id="vboxSettingsSFRO" /> ' + trans('Read-only','UIMachineSettingsSFDetails')+'</label>')).appendTo(tbl);
+
+ // Auto mount
+ $('<tr />').append($('<th />')).append($('<td />').html('<label><input type="checkbox" class="vboxCheckbox" id="vboxSettingsSFAM" /> ' + trans('Auto-mount','UIMachineSettingsSFDetails')+'</label>')).appendTo(tbl);
+
+ // Add "Make Permanent"?
+ if(vboxVMStates.isRunning($('#vboxSettingsDialog').data('vboxMachineData')) || vboxVMStates.isSaved($('#vboxSettingsDialog').data('vboxMachineData')) || vboxVMStates.isPaused($('#vboxSettingsDialog').data('vboxMachineData'))) {
+
+ $('<tr />').append($('<th />')).append($('<td />').html('<label><input type="checkbox" class="vboxCheckbox" id="vboxSettingsSFPerm" /> ' + trans('Make Permanent','UIMachineSettingsSFDetails')+'</label>')).appendTo(tbl);
+ }
+
+ $(d).append(tbl).dialog({'width':800,'modal':true,'autoOpen':false,'dialogClass':'vboxDialogContent vboxNonTabbed','title':'<img src="images/vbox/sf_16px.png" class="vboxDialogTitleIcon" /> '+trans('Edit Share','UIMachineSettingsSFDetails')});
+
+ return $('#vboxSettingsSFEdit');
+}
+
+
+
+/* Change settings onSave() */
+$('#vboxSettingsDialog').on('save',function(){
+
+ $('#vboxSettingsDialog').data('vboxMachineData').sharedFolders = new Array();
+
+ var folders = new Array();
+ $('#vboxSettingsSharedFoldersList').find('tr').each(function(){
+ // Skip headers and such
+ if($(this).data('name')) {
+ folders[folders.length] = {'name':$(this).data('name'),'hostPath':$(this).data('hostPath'),'autoMount':($(this).data('autoMount') ? true : false),'writable':($(this).data('writable') ? true : false),'type':$(this).data('type')};
+ }
+ });
+ $('#vboxSettingsDialog').data('vboxMachineData').sharedFolders = folders;
+
+});
+
+
+</script>
+
diff --git a/panes/settingsStorage.html b/panes/settingsStorage.html
index 5056343..5e1ce54 100644
--- a/panes/settingsStorage.html
+++ b/panes/settingsStorage.html
@@ -1,1705 +1,1705 @@
-<!--
-
- VM Storage Settings
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: settingsStorage.html 599 2015-07-27 10:40:37Z imoore76 $
-
--->
-<table style='width: 100%;' id='vboxSettingsStorageTableWrapper'>
- <tr style='height: 100%'>
- <td width='50%' style='padding: 6px;'>
- <div id='vboxStoragePaneLeft'>
- <table class='vboxSettingsHeadingLine'
- style='width: 100%; border-spacing: 0; border: 0px; margin: 0px; padding: 0px;'>
- <tr style='vertical-align: middle'>
- <td style='white-space: nowrap; width: auto;'><span
- class='translate vboxRunningEnabled'>Storage Tree</span></td>
- <td style='width: 100%'>
- <hr style='width: 100%;' class='vboxSeparatorLine'/>
- </td>
- </tr>
- </table>
-
-
- <!-- Storage Controllers -->
- <div id='vboxSettingsStorageTree' style='height: 290px; outline: none;' class='vboxBordered' tabindex='0'>
- <ul class='vboxHover vboxHoverBorderless'>
- <li>Storage Thingy</li>
- <li>
- <ul>
- <li>Attachment Thingy</li>
- </ul>
- </li>
- </ul>
- </div>
-
- <!-- Controller Toolbar -->
- <div id='vboxSettingsControllersButtons' style='text-align: right'></div>
-
-
- </div>
- </td>
-
- <!-- Resize Bar -->
- <td style='height: 100%; width:3px; padding:0px; margin:0px;'>
- <div style='margin:0px; margin-top: 2px; padding:0px; width: 3px; height: 99%; background:#aaa;' id='vboxStorageResizeBar' ></div>
- </td>
-
- <td width='50%' style='padding: 6px;'>
- <div id='vboxStoragePaneRight'>
- <table class='vboxSettingsHeadingLine'
- style='width: 100%; border-spacing: 0; border: 0px; margin: 0px; padding: 0px;'>
- <tr style='vertical-align: middle'>
- <td style='white-space: nowrap; width: auto;'><span
- class='translate vboxRunningEnabled'>Attributes</span></td>
- <td style='width: 100%; white-space: nowrap;'><hr style='width: 100%;' class='vboxSeparatorLine'/></td>
- </tr>
- </table>
-
-
- <!-- Controller Settings -->
- <div id='vboxSettingsController' style='width: 100%; display: none;'>
- <table style='width: 100%' class='vboxVertical'>
- <tr>
- <th><span class='translate'>Name:</span></th>
- <td style='width: 100%'><input type='text' class='vboxText'
- name='vboxSettingsStorageItemName' style='width: 99%' /></td>
- </tr>
- <tr>
- <th><span class='translate'>Type:</span></th>
- <td><select name='vboxSettingsStorageControllerType'
- style='width: 100%'>
- <option value='ICH6'>ICH6</option>
- </select></td>
- </tr>
- <tr id='vboxSettingsControllerPortCountRow' style='display: none'>
- <th><span class='translate'>Port Count:</span></th>
- <td>
- <select name='vboxSettingsControllerPortCount'>
- </select>
- </td>
- </tr>
- <tr>
- <th></th>
- <td style='width: 100%'>
- <label><input type='checkbox' class='vboxCheckbox'
- name='vboxSettingsStorageHostCache'/> <span class='translate'>Use Host I/O Cache</span></label></td>
- </tr>
- </table>
- </div>
-
- <!-- Attachment Settings -->
- <div id='vboxSettingsStorageAttachment' style='display: none'>
- <table class='vboxVertical'>
- <tr style='vertical-align: middle;'>
- <th><span class='translate vboxRunningEnabled' id='vboxSettingsControllerSlotLabel'>HardDisk</span></th>
- <td style='width: 100%'>
- <table class='vboxInvisible' style='width: 100%'>
- <tr style='vertical-align: middle'>
- <td style='width: 100%'>
- <select name='vboxSettingsControllerSlot' style='width: 100%'></select>
- </td>
- <td>
- <div id='vboxSettingsAddAttachmentsMenuHDDiv' style='display: none'></div>
- <div id='vboxSettingsAddAttachmentsMenuFDDiv' style='display: none'></div>
- <div id='vboxSettingsAddAttachmentsMenuCDDiv' style='display: none'></div>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
- </div>
-
- <!-- Selected Media Info -->
- <div id='vboxSettingsMediaInfo' style='display: none'>
- <table class='vboxSettingsHeadingLine'
- style='width: 100%; border-spacing: 0; border: 0px; margin: 0px; padding: 0px;'>
- <tr style='vertical-align: middle'>
- <td style='white-space: nowrap; width: auto;'><span
- class='translate vboxRunningEnabled'>Information</span></td>
- <td style='width: 100%'>
- <hr style='width: 100%; ' class='vboxSeparatorLine'/>
- </td>
- </tr>
- </table>
-
-
- <!-- HardDisk Media -->
- <div id='vboxSettingsHDInfo'>
- <table class='vboxVertical'>
- <tr>
- <th><span class='translate vboxRunningEnabled'>Type (Format):</span></th>
- <td><span id='vboxSettingsHDtype' class='vboxRunningEnabled'>Image</span></td>
- </tr>
- <tr>
- <th><span class='translate vboxRunningEnabled'>Virtual Size:</span></th>
- <td><span id='vboxSettingsHDvsize' class='vboxRunningEnabled'>30 GB</span></td>
- </tr>
- <tr>
- <th><span class='translate vboxRunningEnabled'>Actual Size:</span></th>
- <td><span id='vboxSettingsHDasize' class='vboxRunningEnabled'>30 GB</span></td>
- </tr>
- <tr>
- <th><span class='translate vboxRunningEnabled'>Details:</span></th>
- <td><span id='vboxSettingsHDDetails' class='vboxRunningEnabled'>Dynamic</span></td>
- </tr>
- <tr>
- <th><span class='translate vboxRunningEnabled'>Location:</span></th>
- <td><span id='vboxSettingsHDlocation' class='vboxRunningEnabled'>/usr/local/blah/etc..</span></td>
- </tr>
- <tr>
- <th><span class='translate vboxRunningEnabled'>Attached to:</span></th>
- <td><span id='vboxSettingsHDattached' class='vboxRunningEnabled'>Some Virtual
- Machine Name</span></td>
- </tr>
- <tr>
- <th><span class='translate vboxRunningEnabled'>Encrypted with key:</span></th>
- <td><span id='vboxSettingsHDEncrypted' class='vboxRunningEnabled'>--</span></td>
- </tr>
- </table>
- </div>
-
- <!-- DVD/CD Media and Floppy -->
- <div id='vboxSettingsImageInfo'>
- <table class='vboxVertical'>
- <tr>
- <th><span class='translate vboxRunningEnabled'>Type:</span></th>
- <td><span id='vboxSettingsImageType' class='vboxRunningEnabled'>Image</span></td>
- </tr>
- <tr>
- <th><span class='translate vboxRunningEnabled'>Size:</span></th>
- <td><span id='vboxSettingsImageSize' class='vboxRunningEnabled'>30 GB</span></td>
- </tr>
- <tr>
- <th><span class='translate vboxRunningEnabled'>Location:</span></th>
- <td><span id='vboxSettingsImageLocation' class='vboxRunningEnabled'>/usr/local/blah/etc..</span></td>
- </tr>
- <tr>
- <th><span class='translate vboxRunningEnabled'>Attached to:</span></th>
- <td><span id='vboxSettingsImageAttached' class='vboxRunningEnabled'>Some Virtual
- Machine Name</span></td>
- </tr>
- </table>
- </div>
-
- </div>
- </div>
- </td>
- </tr>
-</table>
-<script type='text/javascript'>
-
- /*
- *
- * Storage controller helper object
- *
- *
- */
- var vboxSettingsStorageObj = function() {
-
- this.busTypes = vboxStorage.getBusTypes();
-
- this.attachedDirectMedia = {};
- this.attachedIndirectMedia = {};
-
- /* Return slots available on controller, including incl (device currently on slot) */
- this.availableSlots = function(conElm,incl) {
-
- var bus = $(conElm).children('table').first().data('controller').bus;
- var slots = vboxStorage[bus].slots();
-
- var atts = $(conElm).find('table.vboxSettingsStorageAttachment');
-
- for(var i = 0; i < atts.length; i++) {
- slot = $(atts[i]).data('attachment').port+'-'+$(atts[i]).data('attachment').device;
- if(incl && (incl == slot)) continue;
- delete slots[slot];
- }
- return slots;
- };
-
- this.addAttached = function(m) {
- if(!m || !m.id) return;
- var medium = vboxMedia.getMediumById(m.id);
-
- // SafeGuard
- if(!medium) {
- alert('A medium listed as attached to this machine was not found in the media registry. phpVirtualBox will now reload.');
- location.reload(true);
- }
-
- this.attachedDirectMedia[medium.id] = medium;
- if(medium.base) {
- this.attachedIndirectMedia[medium.base] = medium;
- }
- };
-
- this.isAttached = function(m,directOnly) {
- if(!m || !m.id) return false;
- if(this.attachedDirectMedia[m.id]) return this.attachedDirectMedia[m.id];
- if(!directOnly) {
- return (m.base ? this.attachedIndirectMedia[m.base] : null);
- }
- return false;
- };
-
- this.isAttachedDirect = function(m) { return this.attachedDirectMedia[m.id]; };
- this.isAttachedIndirect = function(m) { return (m.base ? this.attachedIndirectMedia[m.base] : null); };
- };
-
- /*
- *
- *
- * Initialization logic
- *
- *
- */
-
- /* Storage Obj */
- var vboxSettingsStorageBusses = new vboxSettingsStorageObj(); // defined below
-
- /* Setup SATA port count */
- var sel = document.forms['frmVboxSettings'].vboxSettingsControllerPortCount;
- for(var i = 1; i <= vboxStorage.SATA.maxPortCount; i++) {
- sel.options[sel.options.length] = new Option(i,i);
- }
- $(sel).change(function(){
- $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().data('controller').portCount = $(this).val();
- });
-
-
-
- /* Pre-load storage images */
-var imgs = new Array();
-for(var i=0;i<vboxSettingsStorageBusses.busTypes.length;i++){
- var imgName = vboxStorage.getBusIconName(vboxSettingsStorageBusses.busTypes[i]);
- imgs[i] = new Array();
- imgs[i][0] = new Image();
- imgs[i][0].src = 'images/vbox/'+imgName+'_expand_16px.png';
- imgs[i][1] = new Image();
- imgs[i][1].src = 'images/vbox/'+imgName+'_collapse_16px.png';
- imgs[i][2] = new Image();
- imgs[i][2].src = 'images/vbox/'+imgName+'_add_16px.png';
- imgs[i][3] = new Image();
- imgs[i][3].src = 'images/vbox/'+imgName+'_add_disabled_16px.png';
-}
-
-var imgs2 = new Array();
-var imgsToLoad = ['fd','hd','cd'];
-for(var i=0;i<imgsToLoad.length;i++){
- imgs2[i] = new Image();
- imgs2[i].src = 'images/vbox/'+imgsToLoad[i]+'_16px.png';
-}
-
-/*
- *
- * Init Storage Controller menus and toolbar
- *
- */
-
- /* Menu for adding controllers */
- var vboxSettingsCMenu = new vboxMenu({id: 'vboxSettingsAddControllerMenu',
- language_context: 'UIMachineSettingsStorage'});
- var vboxSettingsCMenuItems = [];
- var bustypes = vboxStorage.getBusTypes();
- for(var i = 0; i < bustypes.length; i++) {
- var bt = bustypes[i];
- var icon = vboxStorage.getBusIconName(bt);
- vboxSettingsCMenuItems[vboxSettingsCMenuItems.length] = {'name':'add'+bt,'icon':icon+"_add",'label':'Add '+bt+' Controller'};
- }
- vboxSettingsCMenu.addMenu(vboxSettingsCMenuItems);
-
-
- /* Storage tree context menu to add controllers */
- $('#vboxSettingsStorageTree').contextMenu({
- menu: vboxSettingsCMenu.menuId()
- },
- function(action, el, pos) {
-
- var bus = action.substring(3);
- var c = {'bus':bus,'mediumAttachments':[],'controllerType':vboxStorage[bus].types[0],'useHostIOCache':1,
- 'maxPortCount':vboxStorage[bus]['maxPortCount'],'maxDevicesPerPortCount':vboxStorage[bus]['maxDevicesPerPortCount']};
-
-
- vboxSettingsAddController(c, $('#vboxSettingsStorageTree').children('ul').first());
-
- $('#vboxSettingsStorageTree').trigger('itemselect',$('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first());
- }
- );
-
- /* Storage tree tool bar */
- var vboxSettingsStorageButtons = new Array(
- {
- /* Add Attachment Button */
- 'name' : 'addattach',
- 'label' : 'Add Attachment',
- 'icon' : 'attachment_add',
- 'enabled' : function (item) {
-
- if(!$(item).data('controller')) return false;
-
- // Determine how max and how many are used
- if(!($(item).data('controller').maxPortCount && ($(item).parent().find('ul').children('li').length < ($(item).data('controller').maxPortCount * $(item).data('controller').maxDevicesPerPortCount))))
- return false;
-
- // Enable / Disable CD/DVD menu
- var c = $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first();
- if(jQuery.inArray('dvd', vboxStorage[$(c).data('controller').bus].driveTypes) > -1) {
- scToolbar.getButtonElement("addattach").data('busType',$(c).data('controller').bus);
- scToolbar.getButtonElement("addattach").enableContextMenu();
- } else {
- scToolbar.getButtonElement("addattach").disableContextMenu();
- }
- return true;
-
- },
- 'click' : function (item) {
- // Let context menu handle IDE and Sata
- var c = $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first();
- if(vboxStorage[$(c).data('controller').bus].driveTypes.length > 1) {
- return;
- }
- vboxSettingsStorageAddMedium($(c).parent(),($(c).data('controller').bus == 'Floppy' ? 'Floppy' : 'HardDisk'));
- }
- },
-
- {
- /* Remove Attachment Button */
- 'name' : 'removeattach',
- 'label' : 'Remove Attachment',
- 'icon' : 'attachment_remove',
- 'enabled' : function (item) { return (item && $(item).data('attachment')); },
- 'click' : function () {
-
- // Set previous item to last?
- var cur = $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().parent();
-
- if($(cur).hasClass('last')) {
- $(cur).prev().addClass('last');
- }
-
- var next = $(cur).next().find('table.vboxListItem').first();
- if(!$(next).html()) {
- var con = $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().data('controller');
- if(con) next = $('#vboxSettingsController'+con.bus).find('table.vboxListItem').first();
- }
- $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().parent().remove();
- if(!$(next).trigger('click').html()) $('#vboxSettingsStorageTree').trigger('itemselect',null);
- }
- },
-
- {
- /* Add Controller Button */
- 'name' : 'addcontroller',
- 'label' : 'Add Controller',
- 'icon' : 'controller_add',
- 'enabled' : function (item) {
-
- // Draw menu items
- var cons = $('#vboxSettingsStorageTree').find('table.vboxSettingsController');
- var avail = vboxStorage.getBusTypes();
- var used = {};
- for(var i = 0; i < avail.length; i++) {
- used[avail[i]] = false;
- }
-
- for(var i = 0; i < cons.length; i++) {
- used[$(cons[i]).data('controller').bus] = true;
- }
-
- var oneEnabled = false;
- for(var i in used) {
-
- if(used[i]) { // && vboxStorage[i].limitOneInstance) {
- vboxSettingsCMenu.disableItem('add'+i);
- } else {
- vboxSettingsCMenu.enableItem('add'+i);
- oneEnabled = true;
- }
- }
-
- // If at least one item is enabled
- return oneEnabled;
-
-
- },
- 'click' : function (item) { return true; }
- },
-
- {
- /* Remove Controller Button */
- 'name' : 'removecontroller',
- 'label' : 'Remove Controller',
- 'icon' : 'controller_remove',
- 'enabled' : function (item) { if(item && $(item).data('controller')) return true; },
- 'click' : function () {
- var next = $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().parent().next().find('table.vboxListItem').first();
- $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().parent().remove();
- if(!$(next).html()) {next = $('#vboxSettingsStorageTree').find('table.vboxListItem').first();}
- if(!$(next).trigger('click').html()) $('#vboxSettingsStorageTree').trigger('itemselect',null);
- }
- }
-
-
-
- );
-var scToolbar = new vboxToolbarSmall({buttons: vboxSettingsStorageButtons,
- language_context: 'UIMachineSettingsStorage', renderTo: 'vboxSettingsControllersButtons'});
-
-
-/* Add controller button menu initialization */
-scToolbar.getButtonElement("addcontroller").contextMenu({
- menu: vboxSettingsCMenu.menuId(),
- mode:'menu',
- button: 0
- },
- function(action, el, pos) {
-
- var bus = action.substring(3);
- var c = {'bus':bus,'mediumAttachments':[],'controllerType':vboxStorage[bus].types[0],'useHostIOCache':1,
- 'maxPortCount':vboxStorage[bus]['maxPortCount'],'maxDevicesPerPortCount':vboxStorage[bus]['maxDevicesPerPortCount']};
-
- vboxSettingsAddController(c, $('#vboxSettingsStorageTree').children('ul').first());
-
- $('#vboxSettingsStorageTree').trigger('itemselect',$('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first());
- }
- );
-
-/* Menu for adding attachment */
-var mAttachMenu = new vboxMenu({id: 'vboxSettingsAddAttachmentsMenu',
- language_context: 'UIMachineSettingsStorage',
- menuItems: [{name: 'addCD', icon: 'cd_add', label: 'Add Optical Drive'},
- {name: 'addHD', icon: 'hd_add', label: 'Add Hard Disk'}]});
-
-
- /* Add attachment button menu initialization */
-scToolbar.getButtonElement("addattach").contextMenu({
- menu: mAttachMenu.menuId(),
- mode:'menu',
- button: 0
- },
- function(action, el, pos) {
- vboxSettingsStorageAddMedium($('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().parent(),(action == 'addCD' ? 'DVD' : 'HardDisk'));
- }
- );
-
-
-
-$('#vboxSettingsStorageTree').on('itemselect',function(e,el) {scToolbar.update(el); });
-
-
-/* Medium attachment context menu */
-var vboxSettingsMAMenu = new vboxMenu({'name':'vboxSettingsMAMenuL',
- 'menuItems': [vboxSettingsStorageButtons[1]],
- 'language_context': 'UIMachineSettingsStorage'});
-
-/*
- * Medium menu buttons
- */
-var mAttachToolbarHD = new vboxButtonMediaMenu('HardDisk',vboxSettingsControllerAttach);
-mAttachToolbarHD.renderTo('vboxSettingsAddAttachmentsMenuHDDiv');
-
-var mAttachToolbarCD = new vboxButtonMediaMenu('DVD',vboxSettingsControllerAttach);
-mAttachToolbarCD.renderTo('vboxSettingsAddAttachmentsMenuCDDiv');
-
-var mAttachToolbarFD = new vboxButtonMediaMenu('Floppy',vboxSettingsControllerAttach);
-mAttachToolbarFD.renderTo('vboxSettingsAddAttachmentsMenuFDDiv');
-
-/*
- * Controller actions and menus for each bus type
- */
-var vboxStorageBusTypes = vboxStorage.getBusTypes();
-var vboxStorageAttachmentMenus = new Array();
-for(var i = 0; i < vboxStorageBusTypes.length; i++) {
- var btype = vboxStorageBusTypes[i];
- var menuItems = [];
- for(var a = 0; a < vboxStorage[btype].driveTypes.length; a++) {
- switch(vboxStorage[btype].driveTypes[a]) {
- case 'dvd':
- b = {
- 'name' : btype+'addcd',
- 'label' : 'Add Optical Drive',
- 'icon' : 'cd_add',
- 'click' : function () {
- vboxSettingsStorageAddMedium($('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().parent(),'DVD');
- }
- };
- break;
- case 'disk':
- b = {
- 'name' : btype+'adddrive',
- 'label' : 'Add Hard Disk',
- 'icon' : 'hd_add',
- 'click' : function (item) {
- vboxSettingsStorageAddMedium($('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().parent());
- }
- };
- break;
- case 'floppy':
- b = {
- 'name' : btype + 'addfloppy',
- 'label':trans('Add Floppy Drive','UIMachineSettingsStorage'),
- 'icon' : 'fd_add',
- 'click' : function (item) {
- vboxSettingsStorageAddMedium($('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().parent(),'Floppy'); }
- };
- break;
- }
- b['enabled'] = function(a) {
- return ($('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().parent().find('li').length < (vboxStorage[a].maxPortCount * vboxStorage[a].maxDevicesPerPortCount));
- };
- menuItems[menuItems.length] = b;
- }
-
- // Add seperator and "remove controller"
- menuItems[menuItems.length] = $.extend(true, {}, vboxSettingsStorageButtons[3]); // "Remove"
- menuItems[(menuItems.length-1)].separator = true;
- menuItems[(menuItems.length-1)].enabled = null; // always enabled
-
- vboxStorageAttachmentMenus[btype] = new vboxMenu({name: 'vboxSettingsController'+btype+'AttachmentsMenu',
- language_context: 'UIMachineSettingsStorage',
- 'menuItems': menuItems});
-
-}
-
-$('#vboxSettingsStorageTree').on('itemselect',function(e,item){
- for(var i = 0; i < vboxStorageBusTypes.length; i++)
- vboxStorageAttachmentMenus[vboxStorageBusTypes[i]].update(vboxStorageBusTypes[i]);
-});
-/*
- *
- * Form helper functions that listen for form change events
- *
- *
- */
-
-/*
- * Changing the slot changes the object
- */
-document.forms['frmVboxSettings'].vboxSettingsControllerSlot.onchange = function(){
-
- // change port / device
- var pd = this.value.split('-');
- var attachment = $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first();
- $(attachment).data('attachment').port = pd[0];
- $(attachment).data('attachment').device = pd[1];
-
-};
-
-
-
-/*
- *
- * Controller form elements
- *
- */
-
-/* onChange of controller type */
-$(document.forms['frmVboxSettings'].vboxSettingsStorageControllerType).change(function(){
- $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().data('controller').controllerType = $(this).val();
-});
-
-/* change storage controller label on keydown in text box */
-$(document.forms['frmVboxSettings'].vboxSettingsStorageItemName).keyup(function(){
- $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().find('span.vboxSettingsControllerTitle').first().text(this.value);
-});
-
-/* Set storage controller name on blur of textbox */
-$(document.forms['frmVboxSettings'].vboxSettingsStorageItemName).on('blur',function(e){
-
- var bus = $('#vboxSettingsStorageTree').find('.vboxListItemSelected').first();
-
- if(!$(bus).data('controller')) return;
-
- var newName = $(this).val();
-
- // no change?
- if(newName == $(bus).data('controller').name) return true;
-
- if(jQuery.trim($(this).val().toString()).length < 1) {
- $(document.forms['frmVboxSettings'].vboxSettingsStorageItemName).val($(bus).data('controller').name);
-
- } else {
-
- $('#vboxSettingsStorageTree').find('table.vboxSettingsController').each(function(idx,elm) {
- if($(elm).data('controller').name == newName) {
- $(document.forms['frmVboxSettings'].vboxSettingsStorageItemName).val($(bus).data('controller').name);
- conflictFound = true;
- return false;
- }
- });
- }
-
- $(bus).data('controller').name = $(document.forms['frmVboxSettings'].vboxSettingsStorageItemName).val();
- $(bus).find('span.vboxSettingsControllerTitle').first().text($(bus).data('controller').name);
-
-}).keyup(function(){
- $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().find('span.vboxSettingsControllerTitle').text(this.value);
-});
-
-/* Change host cache value onClick of checkbox */
-$(document.forms['frmVboxSettings'].vboxSettingsStorageHostCache).click(function(){
- $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().data('controller').useHostIOCache = this.checked;
-});
-
-
-
-
-/*
- * Update menu items on select and display
- */
-$('#vboxSettingsStorageTree').on('itemselect',function(e,item){
-
- $('#vboxSettingsAddAttachmentsMenuCDDiv').hide();
- $('#vboxSettingsAddAttachmentsMenuHDDiv').hide();
- $('#vboxSettingsAddAttachmentsMenuFDDiv').hide();
-
- // Null selection hides everything
- if(!item) {
- $('#vboxSettingsController').css('display','none');
- $('#vboxSettingsMediaInfo').css('display','none');
- $('#vboxSettingsStorageAttachment').css('display','none');
- // Update label widths
- vboxStorageResizeTreeItemLabels();
- return;
- }
-
- if(!$(item).data('attachment')) {
- // Update label widths
- vboxStorageResizeTreeItemLabels();
- return;
- }
-
- switch($(item).data('attachment').type) {
- case 'HardDisk':
- $('#vboxSettingsAddAttachmentsMenuHDDiv').show();
- break;
- case 'Floppy':
- // Update media menu...
- mAttachToolbarFD.menuUpdateMedia($(item).data('attachment').medium);
- $('#vboxSettingsAddAttachmentsMenuFDDiv').show();
- break;
- default:
- // Update media menu...
- mAttachToolbarCD.menuUpdateMedia($(item).data('attachment').medium);
- $('#vboxSettingsAddAttachmentsMenuCDDiv').show();
- }
-
- // Update label widths
- vboxStorageResizeTreeItemLabels();
-
-
-
-});
-
-
-
-
-/*
- *
- * OnSave and OnShow for dialog
- *
- *
- */
-
-/* Change settings onSave() */
-$('#vboxSettingsDialog').on('save',function(){
-
- $(document.forms['frmVboxSettings'].vboxSettingsStorageItemName).trigger('blur');
-
- $('#vboxSettingsDialog').data('vboxMachineData').storageControllers = new Array();
-
- var storageList = $('#vboxSettingsStorageTree').children('ul').first();
-
- $(storageList).find('table.vboxSettingsController').each(function(i,con){
-
-
- var attachments = new Array();
-
- $(con).parent().find('table.vboxSettingsStorageAttachment').each(function(i,elm) {
-
- var attch = $(elm).data('attachment');
-
- if(attch.medium && attch.medium.id) {
- var med = vboxMedia.getMediumById(attch.medium.id);
- attch.medium = {'id':med.id,'hostDrive':med.hostDrive,'location':med.location};
- }
-
- attachments[attachments.length] = attch;
-
- });
-
- var curCon = $('#vboxSettingsDialog').data('vboxMachineData').storageControllers.length;
-
- $('#vboxSettingsDialog').data('vboxMachineData').storageControllers[curCon] = $(this).data('controller');
- $('#vboxSettingsDialog').data('vboxMachineData').storageControllers[curCon]['mediumAttachments'] = attachments;
-
- });
-
-
-});
-
-/* WHen data is loaded */
-$('#vboxSettingsDialog').on('dataLoaded',function(){
-
- /*
- *
- * Fill form and storage list items
- *
- */
-
- /* Fill List by calling helper functions for each controller */
- var storageList = $('#vboxSettingsStorageTree').children('ul').first();
- $(storageList).children().remove();
-
- var cons = $('#vboxSettingsDialog').data('vboxMachineData').storageControllers;
- for(var a = 0; a < cons.length; a++) {
-
- var attch = cons[a].mediumAttachments;
-
- var conElm = vboxSettingsAddController(cons[a], $(storageList));
-
- for(var b = 0; b < cons[a].mediumAttachments.length; b++) {
- vboxSettingsStorageBusses.addAttached(cons[a].mediumAttachments[b].medium);
- vboxSettingsAddAttachment(cons[a].mediumAttachments[b], conElm);
- }
- }
-
- //Select first item in storage tree list
- $('#vboxSettingsStorageTree').find('table.vboxListItem').first().trigger('click').html();
-
- /* Disable non-editable items when VM is running */
- var p = $('#vboxSettingsStorageTableWrapper');
- if(!$('#vboxSettingsDialog').data('vboxFullEdit')) {
-
- scToolbar.disable();
- $('#vboxSettingsStorageTree').disableContextMenu()
-
- p.find('span:not(.vboxRunningEnabled)').addClass('disabled');
- p.find('input:not(.vboxRunningEnabled),select,textarea').prop('disabled',true);
-
- // Storage tree toolbars
- $('#vboxSettingsStorageTree').find('.vboxControllerAttachmentButton').trigger('disable');
-
- // Hard Disk Media menu button
- $('#vboxSettingsAddAttachmentsMenuHDDiv').trigger('disable');
-
- } else {
-
- $('#vboxSettingsStorageTree').enableContextMenu();
-
- p.find('span:not(.vboxRunningEnabled)').removeClass('disabled');
- p.find('input:not(.vboxRunningEnabled),select,textarea').prop('disabled',false);
-
- // Storage tree toolbars
- $('#vboxSettingsStorageTree').find('.vboxControllerAttachmentButton').trigger('enable');
-
- // Hard Disk Media menu button
- $('#vboxSettingsAddAttachmentsMenuHDDiv').trigger('enable');
-
- // initial toolbar update
- scToolbar.enable();
- scToolbar.update();
-
- }
-
-});
-
-
-/* Respond to UP / Down arrow events */
-$('#vboxSettingsStorageTree').click(function(){$(this).focus();}).keydown(function(e){
-
- var keynum = 0;
-
- if(e.keyCode)
- keynum = e.keyCode;
- else if(e.which)
- keynum = e.which;
-
- switch(keynum) {
-
- // up
- case 38:
-
- var cur = $(this).find('table.vboxListItemSelected').parent();
-
- // Try previous med attachment
- if($(cur).prev('li.vboxSettingsMediumAttachment').children('table.vboxListItem').trigger('click')[0]) {
- return;
- }
-
- // If we're a medium, click our parent controller
- if($(cur).hasClass('vboxSettingsMediumAttachment')) {
- $(cur).parent().parent('li.vboxSettingsController').children('table.vboxListItem').trigger('click');
- return;
- }
-
- // Must be a controller, try previous controller's last medium attachment
- if($(cur).prev().children('ul:not([class~="vboxHidden"])').find('table.vboxListItem:last').trigger('click')[0])
- return;
-
- // No med attachment, try previous controller
- $(cur).prev('li.vboxSettingsController').children('table.vboxListItem').trigger('click');
- break;
-
- // right / expand
- case 39:
- var tbl = $(this).find('table.vboxListItemSelected');
- var con = $(tbl).data('controller');
- if(!con) return;
- $(tbl).find('td.vboxSettingsController' + con.bus).click();
- break;
-
- // left / contract
- case 37:
- var tbl = $(this).find('table.vboxListItemSelected');
- var con = $(tbl).data('controller');
- if(!con) return;
- $(tbl).find('td.vboxSettingsController' + con.bus + 'Expanded').click();
- break;
-
- // down
- case 40:
-
- var cur = $(this).find('table.vboxListItemSelected').parent();
-
- // Try next med attachment
- if($(cur).next('li.vboxSettingsMediumAttachment').children('table.vboxListItem').trigger('click')[0]) {
- return;
- }
-
- // Select first medium of current controller?
- if($(cur).children('ul:not([class~="vboxHidden"])').find('table.vboxListItem:first').trigger('click')[0])
- return;
-
- // Try next controller
- $(cur).closest('li.vboxSettingsController').next('li.vboxSettingsController').children('table.vboxListItem').trigger('click');
-
- break;
- }
-
-}).css('outline','none');;
-
-/*
- *
- * Change media attachment helper function
- *
- */
-function vboxSettingsControllerAttach(m) {
-
- var tbl = $('#vboxSettingsStorageTree').find('table.vboxListItemSelected');
- $(tbl).data('attachment').medium = m;
- $(tbl).parent().tipped({'source':vboxSettingsMediumTip(m),'position':'mouse','delay':1000});
-
- // Re-select attachment to update display info
- vboxSettingsSelectAttachment(tbl);
-
-
-}
-
-
-/*
- *
- * Called when controller is selected helper function
- *
- */
-function vboxSettingsSelectController(tbl) {
-
- // Null selection?
- if(!tbl) {
- $('#vboxSettingsController').css('display','none');
- $('#vboxSettingsMediaInfo').css('display','none');
- $('#vboxSettingsStorageAttachment').css('display','none');
- return;
- }
-
- $(document.forms['frmVboxSettings'].vboxSettingsStorageItemName).trigger('blur');
-
- /* set classes for selected / unselected */
- $('#vboxSettingsStorageTree').find('table[class]').removeClass('vboxListItemSelected').addClass('vboxListItem');
- $(tbl).removeClass('vboxListItem').addClass('vboxListItemSelected');
-
- /* set name text box value */
- document.forms['frmVboxSettings'].vboxSettingsStorageItemName.value = $(tbl).data('controller').name;
-
- /* Set host cache checkbox */
- document.forms['frmVboxSettings'].vboxSettingsStorageHostCache.checked = $(tbl).data('controller').useHostIOCache ? 'checked' : '';
-
- var busType = $(tbl).data('controller').bus;
-
- /* controller type */
- document.forms['frmVboxSettings'].vboxSettingsStorageControllerType.options.length = 0;
- $(document.forms['frmVboxSettings'].vboxSettingsStorageControllerType).children().remove();
- for(var i = 0; i < vboxStorage[busType].types.length; i++) {
- document.forms['frmVboxSettings'].vboxSettingsStorageControllerType.options[i] = new Option(trans(vboxStorageControllerType(vboxStorage[busType].types[i]),'VBoxGlobal'),vboxStorage[busType].types[i]);
- }
-
- /* Set default type */
- document.forms['frmVboxSettings'].vboxSettingsStorageControllerType.value = $(tbl).data('controller').controllerType;
-
- $('#vboxSettingsController').css('display','block');
- $('#vboxSettingsStorageAttachment').css('display','none');
- $('#vboxSettingsMediaInfo').css('display','none');
- $('#vboxSettingsHDInfo').css('display','none');
-
- // Show SATA port count
- if(busType == 'SATA') {
- $(document.forms['frmVboxSettings'].vboxSettingsControllerPortCount).val($(tbl).data('controller').portCount);
- $('#vboxSettingsControllerPortCountRow').css('display','');
- } else {
- $('#vboxSettingsControllerPortCountRow').css('display','none');
- }
-
- /* Enable / disable buttons */
- if($(tbl).parent().find('ul').children('li').length < ($(tbl).data('controller').maxPortCount * $(tbl).data('controller').maxDevicesPerPortCount)) {
-
- if($('#vboxSettingsDialog').data('vboxFullEdit')) {
- $(tbl).find('.vboxToolbarSmall').trigger('enable', [true]);
- }
-
- } else {
- $(tbl).find('.vboxToolbarSmall').trigger('disable');
- }
-
- /* Trigger Event */
- $('#vboxSettingsStorageTree').trigger('itemselect',tbl);
-
-}
-
-
-/*
- * Generate tooltip for medium helper function
- */
-function vboxSettingsMediumTip(m) {
-
- if(!m || !m.id) return trans('Empty','VBoxGlobal');
- if(m.hostDrive) return vboxMedia.getName(m);
-
- // DVD / Floppy images
- if(m.deviceType != 'HardDisk') {
- return '<b>'+m.location+'</b><p>'+trans('Attached to:','UIMachineSettingsStorage')+' '+vboxMedia.attachedTo(m)+'</p>';
- }
-
- var mbase = m;
- if(m.base != m.id) {
- mbase = vboxMedia.getMediumById(m.base);
- }
- var tip = '<b>'+mbase.location+'</b><p>'+trans('Type (Format):','UIMachineSettingsStorage')+' '+vboxMedia.getType(mbase)+' ('+mbase.format+')</p><p>'+trans('Attached to:','UIMachineSettingsStorage')+' '+vboxMedia.attachedTo(mbase)+'</p>';
-
- // Is this a medium that is attached indirectly
- if(vboxSettingsStorageBusses.isAttachedIndirect(m) && m.base != m.id) {
- var p = vboxSettingsStorageBusses.isAttached(m);
- tip += '<hr />'+trans('This base hard disk is indirectly attached using the following differencing hard disk:','VBoxGlobal')+'<br /><b>'+p.location+'</b></p><p>'+trans('Type (Format):','UIMachineSettingsStorage')+' '+vboxMedia.getType(p) + ' (' + p.format + ')'+'</p><p>'+trans('Attached to:','UIMachineSettingsStorage')+' '+vboxMedia.attachedTo(p)+'</p>';
- } else if(m.readOnly) {
- tip += '<hr />'+trans('Attaching this hard disk will be performed indirectly using a newly created differencing hard disk.','VBoxGlobal');
- }
-
- return tip;
-
-}
-
-/*
- *
- * Add disk medium to bus helper function
- *
- */
-function vboxSettingsStorageAddMedium(conElm, type) {
-
- // get controller name
- var controller = $(conElm).find('span.vboxSettingsControllerTitle').first().text();
-
- if(!type) type = 'HardDisk';
-
- // Find first target slot (vboxSettingsStorageBusses created above)
- var slots = vboxSettingsStorageBusses.availableSlots(conElm);
- var slot = null;
- for(var i in slots) {
- if(typeof i == 'function') continue;
- slot = i;
- break;
- }
- if(slot === null) return;
- slot = slot.split('-');
- var port = slot[0];
- var device = slot[1];
-
- // Add new attachment dialog
- ////////////////////////////
- var buttons = {};
-
- var msg = '';
-
- // Hard Disk buttons
- if (type == 'HardDisk') {
-
- buttons[trans('Create new disk','UIMessageCenter')] = function() {
-
- $.when(new vboxWizardNewHDDialog({'path':vboxDirname($('#vboxSettingsDialog').data('vboxMachineData').settingsFilePath)+$('#vboxPane').data('vboxConfig').DSEP,vmName:$('#vboxSettingsDialog').data('vboxMachineData').name}).run())
- .done(function(id){
- if(!id) return;
- mAttachToolbarHD.mediaMenu.menuUpdateRecent();
- vboxSettingsAddAttachment({'controller':controller,'port':port,'device':device,'type':type,'medium':vboxMedia.getMediumById(id),'ignoreFlush':1}, conElm);
- $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().click();
- });
-
- $(this).remove();
-
- };
- buttons[trans('Choose existing disk','UIMessageCenter')] = function() {
- var dlg = $(this);
- vboxMedia.actions.choose(null,'HardDisk',function(med){
- if(med) {
- mAttachToolbarHD.mediaMenu.menuUpdateRecent();
- vboxSettingsAddAttachment({'controller':controller,'port':port,'device':device,'type':type,'medium':med,'ignoreFlush':1}, conElm);
- $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().click();
- }
- $(dlg).remove();
- });
- };
-
- msg = trans('<p>You are about to add a virtual hard disk to controller <b>%1</b>.</p><p>Would you like to create a new, empty file to hold the disk contents or select an existing one?</p>','UIMessageCenter').replace('%1',controller);
-
- // Floppy buttons
- } else if(type == 'Floppy') {
-
- buttons[trans('Choose disk','UIMessageCenter')] = function() {
- var dlg = $(this);
- vboxMedia.actions.choose(null,'Floppy',function(med){
- if(med) {
- mAttachToolbarFD.mediaMenu.menuUpdateRecent();
- vboxSettingsAddAttachment({'controller':controller,'port':port,'device':device,'type':type,'medium':med}, conElm);
- $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().click();
- }
- $(dlg).remove();
- });
-
- };
-
- buttons[trans('Leave empty','UIMessageCenter')] = function() {
- vboxSettingsAddAttachment({'controller':controller,'port':port,'device':device,'type':type,'medium':null}, conElm);
- $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().click();
- $(this).remove();
- };
-
- msg = trans('<p>You are about to add a new floppy drive to controller <b>%1</b>.</p><p>Would you like to choose a virtual floppy disk to put in the drive or to leave it empty for now?</p>','UIMessageCenter').replace('%1',controller);
-
- // CD/DVD buttons
- } else {
-
- buttons[trans('Choose disk','UIMessageCenter')] = function() {
- var dlg = $(this);
- vboxMedia.actions.choose(null,'DVD',function(med){
- if(med) {
- mAttachToolbarCD.mediaMenu.menuUpdateRecent();
- vboxSettingsAddAttachment({'controller':controller,'port':port,'device':device,'type':type,'medium':med}, conElm);
- $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().click();
- }
- $(dlg).remove();
- });
-
- };
-
- buttons[trans('Leave empty','UIMessageCenter')] = function() {
- vboxSettingsAddAttachment({'controller':controller,'port':port,'device':device,'type':type,'medium':null}, conElm);
- $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().click();
- $(this).remove();
- };
-
- msg = trans('<p>You are about to add a new CD/DVD drive to controller <b>%1</b>.</p><p>Would you like to choose a virtual CD/DVD disk to put in the drive or to leave it empty for now?</p>','UIMessageCenter').replace('%1',controller);
-
- }
-
- buttons[trans('Cancel','QIMessageBox')] = function() {
- $(this).remove();
- };
- $('<div />').attr({'id':'vboxSettingsStorageUnavailable','style':'display: none'}).html(
- '<div><img src="images/50px-Question_icon.svg.png" style="float: left; padding: 10px; " />'+msg+'</div>'
- ).dialog({'closeOnEscape':false,'width':600,'height':200,'buttons':buttons,'modal':true,'autoOpen':true,'dialogClass':'vboxDialogContent','title':'<img src="images/vbox/OSE/about_16px.png" class="vboxDialogTitleIcon" /> phpVirtualBox'});
-
-
-}
-
-/*
- *
- * Add controller to list helper function
- *
- */
-
-function vboxSettingsAddController(con,list) {
-
- // Elect name if none exists
- if(!con.name) {
- var count = $(list).children('li.vboxSettingsController'+con.bus).length + 1;
- var name = trans(con.bus,'UIMachineSettingsStorage');
- if(count == 1) {
- con.name = name;
- } else {
-
- var electedName = name + ' ' + count;
- var conflictFound = false;
- do {
- conflictFound = false;
- $(list).children('li.vboxSettingsController'+con.bus).each(function(idx,elm) {
- if($(elm).children('table').first().data('controller').name == electedName) {
- conflictFound = true;
- electedName = name + ' ' + (++count);
- return false;
- }
- });
- con.name = electedName;
-
- } while(conflictFound);
- }
-
- }
- var li = $('<li />').attr({'title':con.name,'class':'vboxSettingsController vboxSettingsController' + con.bus});
-
- var tbl = $('<table />').attr({'class':'vboxListItem vboxSettingsController'}).on('click',function(){
- vboxSettingsSelectController(this);
- });
-
- // filter out any dummy medium attachments
- var mas = new Array();
- for(var i = 0; i < con.mediumAttachments.length; i++) {
- if(con.mediumAttachments[i].controller)
- mas[mas.length] = con.mediumAttachments[i];
- }
- con.mediumAttachments = mas;
-
- // Assign data
- $(tbl).data('controller',con);
-
- var tr = $('<tr />');
-
- var iconName = vboxStorage.getBusIconName(con.bus);
- $('<td />').attr({'class':'vboxSettingsStorageTypeIcon vboxSettingsController' + con.bus + 'Expanded'})
- .css({
- 'background-image':'url(images/vbox/'+iconName+'_collapse_16px.png)'
- }).html('<div style="width:22px" />').click(function(){
-
-
- if(!$(this).data('toggleClicked')) {
-
- $(this).data('toggleClicked', true);
-
- var n = $(this).closest('li');
- $(n).children('ul').addClass('vboxHidden').css('display','none');
- $(this).removeClass('vboxSettingsController'+con.bus+'Expanded').addClass('vboxSettingsController'+con.bus)
- .css({'background-image':'url(images/vbox/'+iconName+'_expand_16px.png)'});
-
- } else {
-
- $(this).data('toggleClicked', false);
- var n = $(this).closest('li');
- $(n).children('ul').removeClass('vboxHidden').css('display','');
- $(this).removeClass('vboxSettingsController'+con.bus).addClass('vboxSettingsController'+con.bus+'Expanded')
- .css({'background-image':'url(images/vbox/'+iconName+'_collapse_16px.png)'})
-
- }
-
- return false;
-
- }).appendTo(tr);
-
- // Controller name
- $(tr).append($('<td />').css({'width':'100%'}).html('<div class="vboxFitToContainer">'+trans('Controller: %1','UIMachineSettingsStorage').replace('%1','<span class="vboxSettingsControllerTitle vboxRunningEnabled">'+$('<div/>').text(con.name).html())+"</span>"+"</div>"));
-
- // Buttons
- $(tr).append($('<td />').attr({'style':'width: 22px;','class':'vboxControllerAttachmentButton'}));
-
- $(tbl).append(tr).appendTo(li);
-
-
- /* Attachments list holder */
- $(li).append($('<ul />').attr({'class':'vboxSettingsControllerAttachments'})).dblclick(function(e){
- $(this).children('table.vboxSettingsController').find('td.vboxSettingsStorageTypeIcon').trigger('click',e);
- }).disableSelection().appendTo(list);
-
- /* Generate Toolbars */
- var dtypes = vboxStorage[con.bus].driveTypes;
- for(var i = 0; i < dtypes.length; i++) {
- var b = null;
- if(dtypes[i] == 'dvd') {
- b = {
- 'name' : con.bus+'addcd',
- 'label' : trans('Add Optical Drive','UIMachineSettingsStorage'),
- 'icon' : 'cd_add',
- 'click' : function () { vboxSettingsStorageAddMedium(li,'DVD'); }
- };
- } else if(dtypes[i] == 'disk') {
- b = {
- 'name' : con.bus+'adddrive',
- 'label' : trans('Add Hard Disk','UIMachineSettingsStorage'),
- 'icon' : 'hd_add',
- 'click' : function (item) { vboxSettingsStorageAddMedium(li); }
- };
-
- } else if(dtypes[i] == 'floppy') {
- b = {'label':trans('Add Floppy Drive','UIMachineSettingsStorage'),
- 'icon' : 'fd_add',
- 'click' : function (item) { vboxSettingsStorageAddMedium(li,'Floppy'); }
- };
- }
- b['enabled'] = function() {
-
- return (li.find('li').length < (vboxStorage[con.bus].maxPortCount * vboxStorage[con.bus].maxDevicesPerPortCount));
- };
-
- var tb = new vboxToolbarSmall({buttons: [b],
- buttonStyle: 'margin:0px;padding:0px;border:0px;background-repeat:no-repeat;background-position:0px 0px;',
- noHover: true,
- renderTo: li.find('td.vboxControllerAttachmentButton')});
- tb.disable();
-
- }
-
- // Only if machine is not running
- if($('#vboxSettingsDialog').data('vboxFullEdit')) {
-
- $(li).contextMenu({menu: vboxStorageAttachmentMenus[con.bus].menuId(),
- menusetup: function() {$(li).children('table').first().trigger('click')}},
- vboxStorageAttachmentMenus[con.bus].menuClickCallback
- );
-
- }
-
- // Return controller element list item
- return li;
-
-}
-
-
-
-
-
-/*
- *
- * Add a medium attachment to a controller helper function
- *
- */
-function vboxSettingsAddAttachment(d,conElm) {
-
-
- var con = (conElm ? conElm : $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().parent());
-
- // Save bus
- d.bus = $(con).find('table.vboxSettingsController').data('controller').bus;
-
- // remove any 'last' classes
- $(con).children('ul').children().removeClass('last');
-
- var li = $('<li />').attr({'class':'last vboxSettingsMediumAttachment'});
-
-
- var tbl = $('<table />').attr({'class':'vboxListItem vboxSettingsStorageAttachment'})
- .data({'attachment':d}).on('click',function(){
- vboxSettingsSelectAttachment(this);
- });
-
- var m = vboxMedia.getMediumById(((d.medium && d.medium.id) ? d.medium.id : null));
-
- var tr = $('<tr />');
-
- // Storage type icon
- $(tr).append($('<td />').attr({'class':'vboxSettingsStorageTypeIcon vboxSettingsMediaType' + d.type,'style':'width:22px'}).html('<img src="images/vbox/blank.gif" style="width:22px" />'));
-
- // Medium name
- $(tr).append($('<td />').css({'width':'100%'}).append($('<div />').attr({'class':'vboxSettingsStorageMediumName vboxFitToContainer'}).html(vboxMedia.getName(vboxMedia.getMediumById((m && m.base ? m.base : (m && m.id ? m.id : null)))))));
-
-
- $(tbl).append(tr).appendTo(li);
-
- // Only if not running
- if($('#vboxSettingsDialog').data('vboxFullEdit')) {
-
- $(li).contextMenu({
- menu: vboxSettingsMAMenu.menuId(),
- menusetup : function(el) {
- vboxSettingsSelectAttachment($(el).find('table.vboxSettingsStorageAttachment'));
- }
- },
- function(action, el, pos) {
- vboxSettingsStorageButtons[1].click();
- }
- );
- }
-
- $(li).tipped({'source':vboxSettingsMediumTip(m),'position':'mouse','delay':1000}).appendTo(con.children('ul'));
-
-
-}
-
-/*
- *
- * Called when selecting a medium attachment
- *
- */
-function vboxSettingsSelectAttachment(tbl) {
-
- // Null selection?
- if(!tbl) {
- $('#vboxSettingsController').css('display','none');
- $('#vboxSettingsMediaInfo').css('display','none');
- $('#vboxSettingsStorageAttachment').css('display','none');
- return;
- }
-
- $(document.forms['frmVboxSettings'].vboxSettingsStorageItemName).trigger('blur');
-
- /* Display Changes */
- if(!$(tbl).hasClass('vboxListItemSelected')) {
- $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').removeClass('vboxListItemSelected').addClass('vboxListItem');
- $(tbl).removeClass('vboxListItem').addClass('vboxListItemSelected');
- }
-
- $('#vboxSettingsController').css('display','none');
- $('#vboxSettingsMediaInfo').css('display','block');
- $('#vboxSettingsStorageAttachment').css('display','block');
-
-
- var ma = $(tbl).data('attachment');
-
- /* Get / Set Medium */
- if(ma.medium && ma.medium.id)
- ma.medium = vboxMedia.getMediumById(ma.medium.id);
-
- (function(){
-
- var sc = $(tbl).closest('li.vboxSettingsController').children('table').first().data('controller');
-
- var tblSA = $('#vboxSettingsStorageAttachment').find('table').first();
- $(tblSA).find('tr.vboxSettingsControllerDeviceOptionRow').empty().remove();
-
- switch(ma.type) {
-
- case 'HardDisk':
- label = 'Hard Disk:';
- break;
- case 'DVD':
- label = 'CD/DVD Drive:';
- break;
- case 'Floppy':
- label = 'Floppy Drive:';
- break;
- }
- var maOptions = vboxStorage.getMAOptions(ma)
- .concat(vboxStorage.getMAOptionsForSC(sc));
- for(var i = 0; i < maOptions.length; i++) {
-
- var opt = maOptions[i];
-
- var cbox = $('<input />').attr('type','checkbox').prop('checked', ma[opt.attrib] ? true : false)
- .on('click', {attrib: opt.attrib}, function(event){
-
- var attachment = $(tbl).data('attachment');
- attachment[event.data.attrib] = this.checked ? true : false;
- $(tbl).data('attachment', attachment);
-
- }).addClass('vboxCheckbox');
-
- $('<tr />').addClass('vboxSettingsControllerDeviceOptionRow')
- .append($('<th />'))
- .append(
- $('<td />')
- .append($('<label />')
- .append(cbox)
- .append($('<span />').css({'margin-left':'4px'}).text(opt.label))
- )
- ).appendTo($(tblSA));
-
-
- }
- })();
- $('#vboxSettingsControllerSlotLabel').html(trans(label,'UIMachineSettingsStorage'));
-
-
- /* Show / Hide HD/Media Info */
- $('#vboxSettingsImageInfo').css('display',(ma.type == 'HardDisk' ? 'none' : 'block'));
- $('#vboxSettingsHDInfo').css('display',(ma.type == 'HardDisk' ? 'block' : 'none'));
-
-
-
- /* Populate slot select box */
- document.forms['frmVboxSettings'].vboxSettingsControllerSlot.options.length = 0;
- $(document.forms['frmVboxSettings'].vboxSettingsControllerSlot).children().remove();
- slots = vboxSettingsStorageBusses.availableSlots($(tbl).parent().parent().parent(), ma.port+'-'+ma.device);
-
- for(var s in slots) {
- var opt = new Option(slots[s], s);
- document.forms['frmVboxSettings'].vboxSettingsControllerSlot.options[document.forms['frmVboxSettings'].vboxSettingsControllerSlot.options.length] = opt;
- }
- document.forms['frmVboxSettings'].vboxSettingsControllerSlot.value = ma.port+'-'+ma.device;
-
- /* Trigger Event */
- $('#vboxSettingsStorageTree').trigger('itemselect',tbl);
-
- var m = ma.medium;
- var name = vboxMedia.getName(m);
-
- // Read-only medium selected
- if(ma.medium && ma.medium.readOnly) {
- $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().find('td').first().addClass('vboxMediumReadOnly');
- } else {
- $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().find('td').first().removeClass('vboxMediumReadOnly');
- }
-
- // Show medium info
- if(m && m.deviceType == 'HardDisk') {
-
- var disp = vboxMedia.getMediumById(m.base);
- name = vboxMedia.getName(disp);
-
- var encSettings = vboxMedia.getEncryptionSettings(disp);
-
- $('#vboxSettingsHDvsize').html(vboxMbytesConvert(disp.logicalSize));
- $('#vboxSettingsHDasize').html(vboxBytesConvert(disp.size));
- $('#vboxSettingsHDDetails').html(vboxMedia.getHardDiskVariant(disp));
- $('#vboxSettingsHDlocation').html(disp.location);
- $('#vboxSettingsHDtype').html(trans(disp.type,'VBoxGlobal') + ' (' + disp.format + ')');
- $('#vboxSettingsHDattached').html(vboxMedia.attachedTo(disp));
- $('#vboxSettingsHDEncrypted').html(encSettings && encSettings.id ? encSettings.id : '--');
-
-
- } else {
-
- $('#vboxSettingsImageType').html(m ? trans((m.hostDrive ? 'Host Drive' : 'Image'),'UIMachineSettingsStorage'): '--');
- $('#vboxSettingsImageSize').html((m && !m.hostDrive ? vboxBytesConvert(m.size):'--'));
- $('#vboxSettingsImageLocation').html((m && !m.hostDrive ? m.location:'--'));
- $('#vboxSettingsImageAttached').html((m && !m.hostDrive ? vboxMedia.attachedTo(m) :'--'));
-
- }
-
- $(tbl).data('attachment').medium = m;
- $(tbl).find('div.vboxSettingsStorageMediumName').first().html($('<div />').text(name).html());
-
-
-}
-
-
-/*
- * Focus storage controller list when showing this pane
- */
-$('#vboxSettingsStorageTableWrapper').on('show',function(){
- $('#vboxSettingsStorageTree').focus();
-});
-
-/*
- *
- *
- * Storage pane resize and draggable resize bar logic
- *
- *
- */
-/*
- * Resize storage pane
- */
-function vboxSettingsStorageResize() {
-
- // Hide storage tree
- $('#vboxSettingsStorageTree').css({'display':'none'});
-
- // Get and set size
- $('#vboxStoragePaneLeft').css({'display':'none'});
- $('#vboxStoragePaneRight').css({'display':'none'});
-
- // Main table height
- $('#vboxSettingsStorageTableWrapper').css({'display':'none'});
- var h = $('#vboxSettingsStorageTableWrapper').css({'display':'none'}).parent().parent().innerHeight()-4;
-
- // IE needs to account for bordering
- if($.browser.msie) h-= 4;
-
- // Set height
- $('#vboxSettingsStorageTableWrapper').css({'display':''}).height(h);
-
- // Pane width
- var bothWidth = ($('#vboxStoragePaneLeft').parent().innerWidth() + $('#vboxStoragePaneRight').parent().innerWidth() - 24) / 2;
- $('#vboxStoragePaneLeft').css({'width':bothWidth+'px','display':''}).parent().css({'width':'auto','padding':'6px'});
- $('#vboxStoragePaneRight').css({'width':bothWidth+'px','display':''}).parent().css({'width':'auto','padding':'6px'});
-
- // Unsnap.. sorry..
- $('#vboxStorageResizeBar').data('vboxSnapped',0);
-
- // Get inner height of storage tree parent - padding
- var h = $('#vboxStoragePaneLeft').parent().innerHeight() - 24;
- // subtract sibling heights
- $('#vboxSettingsStorageTree').siblings().each(function(){
- h -= $(this).outerHeight(true);
- });
-
- $('#vboxSettingsStorageTree').height(h).css({'display':''});
-
- vboxStorageResizeTreeItemLabels();
-
-}
-
-/*
- * Resize controller labels
- */
-function vboxStorageResizeTreeItemLabels() {
-
- $('#vboxSettingsStorageTree div.vboxFitToContainer').each(function(){
- $(this).css({'display':'none'});
- var w = $(this).parent().innerWidth() - 2;
- $(this).css({'width':w+'px','display':''});
- });
-
-
-};
-
-/*
- * Set pane sizes and resize bar
- */
-$('#vboxSettingsStorageTableWrapper').one('show',function(){
-
-
- // Resize everything on dialog resize
- $('#vboxSettingsDialog').on('dialogresizestop',function(){
- vboxSettingsStorageResize();
- });
- $('#vboxSettingsStorageTableWrapper').on('show',function(){
- vboxSettingsStorageResize();
- });
-
- // Hide children to get true size
- $('#vboxStoragePaneLeft').children().css({'display':'none'});
- $('#vboxStoragePaneRight').children().css({'display':'none'});
-
- var h = $('#vboxSettingsStorageTableWrapper').parent().css({'padding':'0px','margin':'0px'}).parent().innerHeight();
-
- // IE needs to account for bordering
- if($.browser.msie) h-= 4;
-
- $('#vboxSettingsStorageTableWrapper').height(h-4);
-
- // Get and set size
- var bothWidth = ($('#vboxStoragePaneLeft').parent().innerWidth() + $('#vboxStoragePaneRight').parent().innerWidth() - 24) / 2;
- $('#vboxStoragePaneLeft').css({'width':bothWidth+'px','overflow':'hidden'}).parent().css({'width':'auto'});
- $('#vboxStoragePaneRight').css({'width':bothWidth+'px','overflow':'hidden'}).parent().css({'width':'auto'});
-
- // Show children again
- $('#vboxStoragePaneLeft').children().css({'display':''});
- $('#vboxStoragePaneRight').children().css({'display':''});
-
- // Re-trigger list selection to show correct info
- if(!$('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().click().hasClass('vboxListItemSelected'))
- $('#vboxSettingsStorageTree').trigger('itemselect',null);
-
- // Don't allow selection of text in storage tree. This looks funny when dragging the resize bar
- $('#vboxSettingsStorageTree').disableSelection();
-
- // Resize
- vboxSettingsStorageResize();
-
- // Draggable resize bar
- $('#vboxStorageResizeBar').draggable({cursor:(jQuery.browser.opera ? 'e-resize' : 'col-resize'),axis:'x',zIndex:99,helper:function(){
-
- return $('<span />'); // dummy element
-
- },scroll:false,'start':function(e,ui){
-
- $('#vboxStorageResizeBar').data('vboxX',e.pageX);
-
- $('#vboxResizeOverlay').remove();
- $('body').disableSelection().css({'cursor':(jQuery.browser.opera ? 'e-resize' : 'col-resize')});
- $('#vboxSettingsDialog').append($('<div />').attr({'id':'vboxResizeOverlay','style':'width:99%;height:99%;border:0px;margin:0px;padding:0px;position:absolute;top:0px;left:0px;cursor:'+(jQuery.browser.opera ? 'e-resize' : 'col-resize')}));
-
-
- },'drag':function(e){
-
- var sStart = $('#vboxStorageResizeBar').data('vboxX');
- var sStop = e.pageX;
- var sWidth = Math.abs(sStop - sStart);
- if(sWidth == 0) return;
-
- var lWidth = parseInt($('#vboxStoragePaneLeft').css('width'));
- var rWidth = parseInt($('#vboxStoragePaneRight').css('width'));
-
- var snapped = $('#vboxStorageResizeBar').data('vboxSnapped');
-
- // Left to right
- if(sStop > sStart) {
-
- // Check for snapping
- if(snapped) {
- if(snapped > sStop || (rWidth - sWidth < 150)) { return; }
- else if(snapped && snapped <= sStop) {
-
- // Unsnap left pane
- $('#vboxStoragePaneRight').parent().css({'width':'auto'});
- $('#vboxStoragePaneLeft').css({'display':''}).parent().css({'padding':'6px'});
- $('#vboxStorageResizeBar').data('vboxSnapped',0);
- lWidth = $('#vboxStorageResizeBar').data('vboxSnappedWidthL');
- rWidth = $('#vboxStorageResizeBar').data('vboxSnappedWidthR');
- sWidth = Math.abs(sStop - snapped);
- }
- }
-
- if(rWidth - sWidth < 150) {
-
- $('#vboxStoragePaneLeft').css({'width':'100%'}).parent().css({'width':'100%'});
- $('#vboxStoragePaneRight').css({'display':'none','width':'10px'}).parent().css({'padding':'0px'});
- $('#vboxStorageResizeBar').data('vboxSnapped',e.pageX);
- $('#vboxStorageResizeBar').data('vboxSnappedWidthL', (lWidth + sWidth));
- $('#vboxStorageResizeBar').data('vboxSnappedWidthR', (rWidth - sWidth));
-
- } else {
- $('#vboxStoragePaneLeft').css({'width':(lWidth + sWidth)+'px','display':''});
- $('#vboxStoragePaneRight').css({'width':(rWidth - sWidth)+'px','display':''});
- }
-
-
- // Right to left
- } else {
-
- // Check for snapping
- if(snapped) {
- if(snapped < sStop || (lWidth - sWidth < 150)) { return; }
- else if(snapped && snapped >= sStop) {
-
- // Unsnap right pane
- $('#vboxStoragePaneLeft').parent().css({'width':'auto'});
- $('#vboxStoragePaneRight').css({'display':''}).parent().css({'width':'100%','padding':'6px'}); // 100% to fix webkit
- $('#vboxStorageResizeBar').data('vboxSnapped',0);
- lWidth = $('#vboxStorageResizeBar').data('vboxSnappedWidthL');
- rWidth = $('#vboxStorageResizeBar').data('vboxSnappedWidthR');
- sWidth = Math.abs(sStop-snapped);
-
- }
- }
-
- if(lWidth - sWidth < 150) {
-
- $('#vboxStoragePaneRight').css({'width':'100%'}).parent().css({'width':'100%'});
- $('#vboxStoragePaneLeft').css({'display':'none','width':'10px'}).parent().css({'padding':'0px'});
- $('#vboxStorageResizeBar').data('vboxSnapped',e.pageX);
- $('#vboxStorageResizeBar').data('vboxSnappedWidthL', (lWidth - sWidth));
- $('#vboxStorageResizeBar').data('vboxSnappedWidthR', (rWidth + sWidth));
-
- } else {
- $('#vboxStoragePaneLeft').css({'width':(lWidth - sWidth)+'px'});
- $('#vboxStoragePaneRight').css({'width':(rWidth + sWidth)+'px'});
- }
- }
-
- $('#vboxStorageResizeBar').data('vboxX',e.pageX);
-
- // resize labels
- vboxStorageResizeTreeItemLabels();
-
-
- },'stop':function(e) {
-
- // resize labels
- vboxStorageResizeTreeItemLabels();
-
- $('body').enableSelection().css({'cursor':'default'});
- $('#vboxResizeOverlay').remove();
- }}).css({'cursor':(jQuery.browser.opera ? 'e-resize' : 'col-resize'),'height':'98%'});
-
-
-});
-
+<!--
+
+ VM Storage Settings
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: settingsStorage.html 599 2015-07-27 10:40:37Z imoore76 $
+
+-->
+<table style='width: 100%;' id='vboxSettingsStorageTableWrapper'>
+ <tr style='height: 100%'>
+ <td width='50%' style='padding: 6px;'>
+ <div id='vboxStoragePaneLeft'>
+ <table class='vboxSettingsHeadingLine'
+ style='width: 100%; border-spacing: 0; border: 0px; margin: 0px; padding: 0px;'>
+ <tr style='vertical-align: middle'>
+ <td style='white-space: nowrap; width: auto;'><span
+ class='translate vboxRunningEnabled'>Storage Tree</span></td>
+ <td style='width: 100%'>
+ <hr style='width: 100%;' class='vboxSeparatorLine'/>
+ </td>
+ </tr>
+ </table>
+
+
+ <!-- Storage Controllers -->
+ <div id='vboxSettingsStorageTree' style='height: 290px; outline: none;' class='vboxBordered' tabindex='0'>
+ <ul class='vboxHover vboxHoverBorderless'>
+ <li>Storage Thingy</li>
+ <li>
+ <ul>
+ <li>Attachment Thingy</li>
+ </ul>
+ </li>
+ </ul>
+ </div>
+
+ <!-- Controller Toolbar -->
+ <div id='vboxSettingsControllersButtons' style='text-align: right'></div>
+
+
+ </div>
+ </td>
+
+ <!-- Resize Bar -->
+ <td style='height: 100%; width:3px; padding:0px; margin:0px;'>
+ <div style='margin:0px; margin-top: 2px; padding:0px; width: 3px; height: 99%; background:#aaa;' id='vboxStorageResizeBar' ></div>
+ </td>
+
+ <td width='50%' style='padding: 6px;'>
+ <div id='vboxStoragePaneRight'>
+ <table class='vboxSettingsHeadingLine'
+ style='width: 100%; border-spacing: 0; border: 0px; margin: 0px; padding: 0px;'>
+ <tr style='vertical-align: middle'>
+ <td style='white-space: nowrap; width: auto;'><span
+ class='translate vboxRunningEnabled'>Attributes</span></td>
+ <td style='width: 100%; white-space: nowrap;'><hr style='width: 100%;' class='vboxSeparatorLine'/></td>
+ </tr>
+ </table>
+
+
+ <!-- Controller Settings -->
+ <div id='vboxSettingsController' style='width: 100%; display: none;'>
+ <table style='width: 100%' class='vboxVertical'>
+ <tr>
+ <th><span class='translate'>Name:</span></th>
+ <td style='width: 100%'><input type='text' class='vboxText'
+ name='vboxSettingsStorageItemName' style='width: 99%' /></td>
+ </tr>
+ <tr>
+ <th><span class='translate'>Type:</span></th>
+ <td><select name='vboxSettingsStorageControllerType'
+ style='width: 100%'>
+ <option value='ICH6'>ICH6</option>
+ </select></td>
+ </tr>
+ <tr id='vboxSettingsControllerPortCountRow' style='display: none'>
+ <th><span class='translate'>Port Count:</span></th>
+ <td>
+ <select name='vboxSettingsControllerPortCount'>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <th></th>
+ <td style='width: 100%'>
+ <label><input type='checkbox' class='vboxCheckbox'
+ name='vboxSettingsStorageHostCache'/> <span class='translate'>Use Host I/O Cache</span></label></td>
+ </tr>
+ </table>
+ </div>
+
+ <!-- Attachment Settings -->
+ <div id='vboxSettingsStorageAttachment' style='display: none'>
+ <table class='vboxVertical'>
+ <tr style='vertical-align: middle;'>
+ <th><span class='translate vboxRunningEnabled' id='vboxSettingsControllerSlotLabel'>HardDisk</span></th>
+ <td style='width: 100%'>
+ <table class='vboxInvisible' style='width: 100%'>
+ <tr style='vertical-align: middle'>
+ <td style='width: 100%'>
+ <select name='vboxSettingsControllerSlot' style='width: 100%'></select>
+ </td>
+ <td>
+ <div id='vboxSettingsAddAttachmentsMenuHDDiv' style='display: none'></div>
+ <div id='vboxSettingsAddAttachmentsMenuFDDiv' style='display: none'></div>
+ <div id='vboxSettingsAddAttachmentsMenuCDDiv' style='display: none'></div>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </div>
+
+ <!-- Selected Media Info -->
+ <div id='vboxSettingsMediaInfo' style='display: none'>
+ <table class='vboxSettingsHeadingLine'
+ style='width: 100%; border-spacing: 0; border: 0px; margin: 0px; padding: 0px;'>
+ <tr style='vertical-align: middle'>
+ <td style='white-space: nowrap; width: auto;'><span
+ class='translate vboxRunningEnabled'>Information</span></td>
+ <td style='width: 100%'>
+ <hr style='width: 100%; ' class='vboxSeparatorLine'/>
+ </td>
+ </tr>
+ </table>
+
+
+ <!-- HardDisk Media -->
+ <div id='vboxSettingsHDInfo'>
+ <table class='vboxVertical'>
+ <tr>
+ <th><span class='translate vboxRunningEnabled'>Type (Format):</span></th>
+ <td><span id='vboxSettingsHDtype' class='vboxRunningEnabled'>Image</span></td>
+ </tr>
+ <tr>
+ <th><span class='translate vboxRunningEnabled'>Virtual Size:</span></th>
+ <td><span id='vboxSettingsHDvsize' class='vboxRunningEnabled'>30 GB</span></td>
+ </tr>
+ <tr>
+ <th><span class='translate vboxRunningEnabled'>Actual Size:</span></th>
+ <td><span id='vboxSettingsHDasize' class='vboxRunningEnabled'>30 GB</span></td>
+ </tr>
+ <tr>
+ <th><span class='translate vboxRunningEnabled'>Details:</span></th>
+ <td><span id='vboxSettingsHDDetails' class='vboxRunningEnabled'>Dynamic</span></td>
+ </tr>
+ <tr>
+ <th><span class='translate vboxRunningEnabled'>Location:</span></th>
+ <td><span id='vboxSettingsHDlocation' class='vboxRunningEnabled'>/usr/local/blah/etc..</span></td>
+ </tr>
+ <tr>
+ <th><span class='translate vboxRunningEnabled'>Attached to:</span></th>
+ <td><span id='vboxSettingsHDattached' class='vboxRunningEnabled'>Some Virtual
+ Machine Name</span></td>
+ </tr>
+ <tr>
+ <th><span class='translate vboxRunningEnabled'>Encrypted with key:</span></th>
+ <td><span id='vboxSettingsHDEncrypted' class='vboxRunningEnabled'>--</span></td>
+ </tr>
+ </table>
+ </div>
+
+ <!-- DVD/CD Media and Floppy -->
+ <div id='vboxSettingsImageInfo'>
+ <table class='vboxVertical'>
+ <tr>
+ <th><span class='translate vboxRunningEnabled'>Type:</span></th>
+ <td><span id='vboxSettingsImageType' class='vboxRunningEnabled'>Image</span></td>
+ </tr>
+ <tr>
+ <th><span class='translate vboxRunningEnabled'>Size:</span></th>
+ <td><span id='vboxSettingsImageSize' class='vboxRunningEnabled'>30 GB</span></td>
+ </tr>
+ <tr>
+ <th><span class='translate vboxRunningEnabled'>Location:</span></th>
+ <td><span id='vboxSettingsImageLocation' class='vboxRunningEnabled'>/usr/local/blah/etc..</span></td>
+ </tr>
+ <tr>
+ <th><span class='translate vboxRunningEnabled'>Attached to:</span></th>
+ <td><span id='vboxSettingsImageAttached' class='vboxRunningEnabled'>Some Virtual
+ Machine Name</span></td>
+ </tr>
+ </table>
+ </div>
+
+ </div>
+ </div>
+ </td>
+ </tr>
+</table>
+<script type='text/javascript'>
+
+ /*
+ *
+ * Storage controller helper object
+ *
+ *
+ */
+ var vboxSettingsStorageObj = function() {
+
+ this.busTypes = vboxStorage.getBusTypes();
+
+ this.attachedDirectMedia = {};
+ this.attachedIndirectMedia = {};
+
+ /* Return slots available on controller, including incl (device currently on slot) */
+ this.availableSlots = function(conElm,incl) {
+
+ var bus = $(conElm).children('table').first().data('controller').bus;
+ var slots = vboxStorage[bus].slots();
+
+ var atts = $(conElm).find('table.vboxSettingsStorageAttachment');
+
+ for(var i = 0; i < atts.length; i++) {
+ slot = $(atts[i]).data('attachment').port+'-'+$(atts[i]).data('attachment').device;
+ if(incl && (incl == slot)) continue;
+ delete slots[slot];
+ }
+ return slots;
+ };
+
+ this.addAttached = function(m) {
+ if(!m || !m.id) return;
+ var medium = vboxMedia.getMediumById(m.id);
+
+ // SafeGuard
+ if(!medium) {
+ alert('A medium listed as attached to this machine was not found in the media registry. phpVirtualBox will now reload.');
+ location.reload(true);
+ }
+
+ this.attachedDirectMedia[medium.id] = medium;
+ if(medium.base) {
+ this.attachedIndirectMedia[medium.base] = medium;
+ }
+ };
+
+ this.isAttached = function(m,directOnly) {
+ if(!m || !m.id) return false;
+ if(this.attachedDirectMedia[m.id]) return this.attachedDirectMedia[m.id];
+ if(!directOnly) {
+ return (m.base ? this.attachedIndirectMedia[m.base] : null);
+ }
+ return false;
+ };
+
+ this.isAttachedDirect = function(m) { return this.attachedDirectMedia[m.id]; };
+ this.isAttachedIndirect = function(m) { return (m.base ? this.attachedIndirectMedia[m.base] : null); };
+ };
+
+ /*
+ *
+ *
+ * Initialization logic
+ *
+ *
+ */
+
+ /* Storage Obj */
+ var vboxSettingsStorageBusses = new vboxSettingsStorageObj(); // defined below
+
+ /* Setup SATA port count */
+ var sel = document.forms['frmVboxSettings'].vboxSettingsControllerPortCount;
+ for(var i = 1; i <= vboxStorage.SATA.maxPortCount; i++) {
+ sel.options[sel.options.length] = new Option(i,i);
+ }
+ $(sel).change(function(){
+ $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().data('controller').portCount = $(this).val();
+ });
+
+
+
+ /* Pre-load storage images */
+var imgs = new Array();
+for(var i=0;i<vboxSettingsStorageBusses.busTypes.length;i++){
+ var imgName = vboxStorage.getBusIconName(vboxSettingsStorageBusses.busTypes[i]);
+ imgs[i] = new Array();
+ imgs[i][0] = new Image();
+ imgs[i][0].src = 'images/vbox/'+imgName+'_expand_16px.png';
+ imgs[i][1] = new Image();
+ imgs[i][1].src = 'images/vbox/'+imgName+'_collapse_16px.png';
+ imgs[i][2] = new Image();
+ imgs[i][2].src = 'images/vbox/'+imgName+'_add_16px.png';
+ imgs[i][3] = new Image();
+ imgs[i][3].src = 'images/vbox/'+imgName+'_add_disabled_16px.png';
+}
+
+var imgs2 = new Array();
+var imgsToLoad = ['fd','hd','cd'];
+for(var i=0;i<imgsToLoad.length;i++){
+ imgs2[i] = new Image();
+ imgs2[i].src = 'images/vbox/'+imgsToLoad[i]+'_16px.png';
+}
+
+/*
+ *
+ * Init Storage Controller menus and toolbar
+ *
+ */
+
+ /* Menu for adding controllers */
+ var vboxSettingsCMenu = new vboxMenu({id: 'vboxSettingsAddControllerMenu',
+ language_context: 'UIMachineSettingsStorage'});
+ var vboxSettingsCMenuItems = [];
+ var bustypes = vboxStorage.getBusTypes();
+ for(var i = 0; i < bustypes.length; i++) {
+ var bt = bustypes[i];
+ var icon = vboxStorage.getBusIconName(bt);
+ vboxSettingsCMenuItems[vboxSettingsCMenuItems.length] = {'name':'add'+bt,'icon':icon+"_add",'label':'Add '+bt+' Controller'};
+ }
+ vboxSettingsCMenu.addMenu(vboxSettingsCMenuItems);
+
+
+ /* Storage tree context menu to add controllers */
+ $('#vboxSettingsStorageTree').contextMenu({
+ menu: vboxSettingsCMenu.menuId()
+ },
+ function(action, el, pos) {
+
+ var bus = action.substring(3);
+ var c = {'bus':bus,'mediumAttachments':[],'controllerType':vboxStorage[bus].types[0],'useHostIOCache':1,
+ 'maxPortCount':vboxStorage[bus]['maxPortCount'],'maxDevicesPerPortCount':vboxStorage[bus]['maxDevicesPerPortCount']};
+
+
+ vboxSettingsAddController(c, $('#vboxSettingsStorageTree').children('ul').first());
+
+ $('#vboxSettingsStorageTree').trigger('itemselect',$('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first());
+ }
+ );
+
+ /* Storage tree tool bar */
+ var vboxSettingsStorageButtons = new Array(
+ {
+ /* Add Attachment Button */
+ 'name' : 'addattach',
+ 'label' : 'Add Attachment',
+ 'icon' : 'attachment_add',
+ 'enabled' : function (item) {
+
+ if(!$(item).data('controller')) return false;
+
+ // Determine how max and how many are used
+ if(!($(item).data('controller').maxPortCount && ($(item).parent().find('ul').children('li').length < ($(item).data('controller').maxPortCount * $(item).data('controller').maxDevicesPerPortCount))))
+ return false;
+
+ // Enable / Disable CD/DVD menu
+ var c = $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first();
+ if(jQuery.inArray('dvd', vboxStorage[$(c).data('controller').bus].driveTypes) > -1) {
+ scToolbar.getButtonElement("addattach").data('busType',$(c).data('controller').bus);
+ scToolbar.getButtonElement("addattach").enableContextMenu();
+ } else {
+ scToolbar.getButtonElement("addattach").disableContextMenu();
+ }
+ return true;
+
+ },
+ 'click' : function (item) {
+ // Let context menu handle IDE and Sata
+ var c = $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first();
+ if(vboxStorage[$(c).data('controller').bus].driveTypes.length > 1) {
+ return;
+ }
+ vboxSettingsStorageAddMedium($(c).parent(),($(c).data('controller').bus == 'Floppy' ? 'Floppy' : 'HardDisk'));
+ }
+ },
+
+ {
+ /* Remove Attachment Button */
+ 'name' : 'removeattach',
+ 'label' : 'Remove Attachment',
+ 'icon' : 'attachment_remove',
+ 'enabled' : function (item) { return (item && $(item).data('attachment')); },
+ 'click' : function () {
+
+ // Set previous item to last?
+ var cur = $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().parent();
+
+ if($(cur).hasClass('last')) {
+ $(cur).prev().addClass('last');
+ }
+
+ var next = $(cur).next().find('table.vboxListItem').first();
+ if(!$(next).html()) {
+ var con = $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().data('controller');
+ if(con) next = $('#vboxSettingsController'+con.bus).find('table.vboxListItem').first();
+ }
+ $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().parent().remove();
+ if(!$(next).trigger('click').html()) $('#vboxSettingsStorageTree').trigger('itemselect',null);
+ }
+ },
+
+ {
+ /* Add Controller Button */
+ 'name' : 'addcontroller',
+ 'label' : 'Add Controller',
+ 'icon' : 'controller_add',
+ 'enabled' : function (item) {
+
+ // Draw menu items
+ var cons = $('#vboxSettingsStorageTree').find('table.vboxSettingsController');
+ var avail = vboxStorage.getBusTypes();
+ var used = {};
+ for(var i = 0; i < avail.length; i++) {
+ used[avail[i]] = false;
+ }
+
+ for(var i = 0; i < cons.length; i++) {
+ used[$(cons[i]).data('controller').bus] = true;
+ }
+
+ var oneEnabled = false;
+ for(var i in used) {
+
+ if(used[i]) { // && vboxStorage[i].limitOneInstance) {
+ vboxSettingsCMenu.disableItem('add'+i);
+ } else {
+ vboxSettingsCMenu.enableItem('add'+i);
+ oneEnabled = true;
+ }
+ }
+
+ // If at least one item is enabled
+ return oneEnabled;
+
+
+ },
+ 'click' : function (item) { return true; }
+ },
+
+ {
+ /* Remove Controller Button */
+ 'name' : 'removecontroller',
+ 'label' : 'Remove Controller',
+ 'icon' : 'controller_remove',
+ 'enabled' : function (item) { if(item && $(item).data('controller')) return true; },
+ 'click' : function () {
+ var next = $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().parent().next().find('table.vboxListItem').first();
+ $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().parent().remove();
+ if(!$(next).html()) {next = $('#vboxSettingsStorageTree').find('table.vboxListItem').first();}
+ if(!$(next).trigger('click').html()) $('#vboxSettingsStorageTree').trigger('itemselect',null);
+ }
+ }
+
+
+
+ );
+var scToolbar = new vboxToolbarSmall({buttons: vboxSettingsStorageButtons,
+ language_context: 'UIMachineSettingsStorage', renderTo: 'vboxSettingsControllersButtons'});
+
+
+/* Add controller button menu initialization */
+scToolbar.getButtonElement("addcontroller").contextMenu({
+ menu: vboxSettingsCMenu.menuId(),
+ mode:'menu',
+ button: 0
+ },
+ function(action, el, pos) {
+
+ var bus = action.substring(3);
+ var c = {'bus':bus,'mediumAttachments':[],'controllerType':vboxStorage[bus].types[0],'useHostIOCache':1,
+ 'maxPortCount':vboxStorage[bus]['maxPortCount'],'maxDevicesPerPortCount':vboxStorage[bus]['maxDevicesPerPortCount']};
+
+ vboxSettingsAddController(c, $('#vboxSettingsStorageTree').children('ul').first());
+
+ $('#vboxSettingsStorageTree').trigger('itemselect',$('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first());
+ }
+ );
+
+/* Menu for adding attachment */
+var mAttachMenu = new vboxMenu({id: 'vboxSettingsAddAttachmentsMenu',
+ language_context: 'UIMachineSettingsStorage',
+ menuItems: [{name: 'addCD', icon: 'cd_add', label: 'Add Optical Drive'},
+ {name: 'addHD', icon: 'hd_add', label: 'Add Hard Disk'}]});
+
+
+ /* Add attachment button menu initialization */
+scToolbar.getButtonElement("addattach").contextMenu({
+ menu: mAttachMenu.menuId(),
+ mode:'menu',
+ button: 0
+ },
+ function(action, el, pos) {
+ vboxSettingsStorageAddMedium($('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().parent(),(action == 'addCD' ? 'DVD' : 'HardDisk'));
+ }
+ );
+
+
+
+$('#vboxSettingsStorageTree').on('itemselect',function(e,el) {scToolbar.update(el); });
+
+
+/* Medium attachment context menu */
+var vboxSettingsMAMenu = new vboxMenu({'name':'vboxSettingsMAMenuL',
+ 'menuItems': [vboxSettingsStorageButtons[1]],
+ 'language_context': 'UIMachineSettingsStorage'});
+
+/*
+ * Medium menu buttons
+ */
+var mAttachToolbarHD = new vboxButtonMediaMenu('HardDisk',vboxSettingsControllerAttach);
+mAttachToolbarHD.renderTo('vboxSettingsAddAttachmentsMenuHDDiv');
+
+var mAttachToolbarCD = new vboxButtonMediaMenu('DVD',vboxSettingsControllerAttach);
+mAttachToolbarCD.renderTo('vboxSettingsAddAttachmentsMenuCDDiv');
+
+var mAttachToolbarFD = new vboxButtonMediaMenu('Floppy',vboxSettingsControllerAttach);
+mAttachToolbarFD.renderTo('vboxSettingsAddAttachmentsMenuFDDiv');
+
+/*
+ * Controller actions and menus for each bus type
+ */
+var vboxStorageBusTypes = vboxStorage.getBusTypes();
+var vboxStorageAttachmentMenus = new Array();
+for(var i = 0; i < vboxStorageBusTypes.length; i++) {
+ var btype = vboxStorageBusTypes[i];
+ var menuItems = [];
+ for(var a = 0; a < vboxStorage[btype].driveTypes.length; a++) {
+ switch(vboxStorage[btype].driveTypes[a]) {
+ case 'dvd':
+ b = {
+ 'name' : btype+'addcd',
+ 'label' : 'Add Optical Drive',
+ 'icon' : 'cd_add',
+ 'click' : function () {
+ vboxSettingsStorageAddMedium($('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().parent(),'DVD');
+ }
+ };
+ break;
+ case 'disk':
+ b = {
+ 'name' : btype+'adddrive',
+ 'label' : 'Add Hard Disk',
+ 'icon' : 'hd_add',
+ 'click' : function (item) {
+ vboxSettingsStorageAddMedium($('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().parent());
+ }
+ };
+ break;
+ case 'floppy':
+ b = {
+ 'name' : btype + 'addfloppy',
+ 'label':trans('Add Floppy Drive','UIMachineSettingsStorage'),
+ 'icon' : 'fd_add',
+ 'click' : function (item) {
+ vboxSettingsStorageAddMedium($('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().parent(),'Floppy'); }
+ };
+ break;
+ }
+ b['enabled'] = function(a) {
+ return ($('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().parent().find('li').length < (vboxStorage[a].maxPortCount * vboxStorage[a].maxDevicesPerPortCount));
+ };
+ menuItems[menuItems.length] = b;
+ }
+
+ // Add seperator and "remove controller"
+ menuItems[menuItems.length] = $.extend(true, {}, vboxSettingsStorageButtons[3]); // "Remove"
+ menuItems[(menuItems.length-1)].separator = true;
+ menuItems[(menuItems.length-1)].enabled = null; // always enabled
+
+ vboxStorageAttachmentMenus[btype] = new vboxMenu({name: 'vboxSettingsController'+btype+'AttachmentsMenu',
+ language_context: 'UIMachineSettingsStorage',
+ 'menuItems': menuItems});
+
+}
+
+$('#vboxSettingsStorageTree').on('itemselect',function(e,item){
+ for(var i = 0; i < vboxStorageBusTypes.length; i++)
+ vboxStorageAttachmentMenus[vboxStorageBusTypes[i]].update(vboxStorageBusTypes[i]);
+});
+/*
+ *
+ * Form helper functions that listen for form change events
+ *
+ *
+ */
+
+/*
+ * Changing the slot changes the object
+ */
+document.forms['frmVboxSettings'].vboxSettingsControllerSlot.onchange = function(){
+
+ // change port / device
+ var pd = this.value.split('-');
+ var attachment = $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first();
+ $(attachment).data('attachment').port = pd[0];
+ $(attachment).data('attachment').device = pd[1];
+
+};
+
+
+
+/*
+ *
+ * Controller form elements
+ *
+ */
+
+/* onChange of controller type */
+$(document.forms['frmVboxSettings'].vboxSettingsStorageControllerType).change(function(){
+ $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().data('controller').controllerType = $(this).val();
+});
+
+/* change storage controller label on keydown in text box */
+$(document.forms['frmVboxSettings'].vboxSettingsStorageItemName).keyup(function(){
+ $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().find('span.vboxSettingsControllerTitle').first().text(this.value);
+});
+
+/* Set storage controller name on blur of textbox */
+$(document.forms['frmVboxSettings'].vboxSettingsStorageItemName).on('blur',function(e){
+
+ var bus = $('#vboxSettingsStorageTree').find('.vboxListItemSelected').first();
+
+ if(!$(bus).data('controller')) return;
+
+ var newName = $(this).val();
+
+ // no change?
+ if(newName == $(bus).data('controller').name) return true;
+
+ if(jQuery.trim($(this).val().toString()).length < 1) {
+ $(document.forms['frmVboxSettings'].vboxSettingsStorageItemName).val($(bus).data('controller').name);
+
+ } else {
+
+ $('#vboxSettingsStorageTree').find('table.vboxSettingsController').each(function(idx,elm) {
+ if($(elm).data('controller').name == newName) {
+ $(document.forms['frmVboxSettings'].vboxSettingsStorageItemName).val($(bus).data('controller').name);
+ conflictFound = true;
+ return false;
+ }
+ });
+ }
+
+ $(bus).data('controller').name = $(document.forms['frmVboxSettings'].vboxSettingsStorageItemName).val();
+ $(bus).find('span.vboxSettingsControllerTitle').first().text($(bus).data('controller').name);
+
+}).keyup(function(){
+ $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().find('span.vboxSettingsControllerTitle').text(this.value);
+});
+
+/* Change host cache value onClick of checkbox */
+$(document.forms['frmVboxSettings'].vboxSettingsStorageHostCache).click(function(){
+ $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().data('controller').useHostIOCache = this.checked;
+});
+
+
+
+
+/*
+ * Update menu items on select and display
+ */
+$('#vboxSettingsStorageTree').on('itemselect',function(e,item){
+
+ $('#vboxSettingsAddAttachmentsMenuCDDiv').hide();
+ $('#vboxSettingsAddAttachmentsMenuHDDiv').hide();
+ $('#vboxSettingsAddAttachmentsMenuFDDiv').hide();
+
+ // Null selection hides everything
+ if(!item) {
+ $('#vboxSettingsController').css('display','none');
+ $('#vboxSettingsMediaInfo').css('display','none');
+ $('#vboxSettingsStorageAttachment').css('display','none');
+ // Update label widths
+ vboxStorageResizeTreeItemLabels();
+ return;
+ }
+
+ if(!$(item).data('attachment')) {
+ // Update label widths
+ vboxStorageResizeTreeItemLabels();
+ return;
+ }
+
+ switch($(item).data('attachment').type) {
+ case 'HardDisk':
+ $('#vboxSettingsAddAttachmentsMenuHDDiv').show();
+ break;
+ case 'Floppy':
+ // Update media menu...
+ mAttachToolbarFD.menuUpdateMedia($(item).data('attachment').medium);
+ $('#vboxSettingsAddAttachmentsMenuFDDiv').show();
+ break;
+ default:
+ // Update media menu...
+ mAttachToolbarCD.menuUpdateMedia($(item).data('attachment').medium);
+ $('#vboxSettingsAddAttachmentsMenuCDDiv').show();
+ }
+
+ // Update label widths
+ vboxStorageResizeTreeItemLabels();
+
+
+
+});
+
+
+
+
+/*
+ *
+ * OnSave and OnShow for dialog
+ *
+ *
+ */
+
+/* Change settings onSave() */
+$('#vboxSettingsDialog').on('save',function(){
+
+ $(document.forms['frmVboxSettings'].vboxSettingsStorageItemName).trigger('blur');
+
+ $('#vboxSettingsDialog').data('vboxMachineData').storageControllers = new Array();
+
+ var storageList = $('#vboxSettingsStorageTree').children('ul').first();
+
+ $(storageList).find('table.vboxSettingsController').each(function(i,con){
+
+
+ var attachments = new Array();
+
+ $(con).parent().find('table.vboxSettingsStorageAttachment').each(function(i,elm) {
+
+ var attch = $(elm).data('attachment');
+
+ if(attch.medium && attch.medium.id) {
+ var med = vboxMedia.getMediumById(attch.medium.id);
+ attch.medium = {'id':med.id,'hostDrive':med.hostDrive,'location':med.location};
+ }
+
+ attachments[attachments.length] = attch;
+
+ });
+
+ var curCon = $('#vboxSettingsDialog').data('vboxMachineData').storageControllers.length;
+
+ $('#vboxSettingsDialog').data('vboxMachineData').storageControllers[curCon] = $(this).data('controller');
+ $('#vboxSettingsDialog').data('vboxMachineData').storageControllers[curCon]['mediumAttachments'] = attachments;
+
+ });
+
+
+});
+
+/* WHen data is loaded */
+$('#vboxSettingsDialog').on('dataLoaded',function(){
+
+ /*
+ *
+ * Fill form and storage list items
+ *
+ */
+
+ /* Fill List by calling helper functions for each controller */
+ var storageList = $('#vboxSettingsStorageTree').children('ul').first();
+ $(storageList).children().remove();
+
+ var cons = $('#vboxSettingsDialog').data('vboxMachineData').storageControllers;
+ for(var a = 0; a < cons.length; a++) {
+
+ var attch = cons[a].mediumAttachments;
+
+ var conElm = vboxSettingsAddController(cons[a], $(storageList));
+
+ for(var b = 0; b < cons[a].mediumAttachments.length; b++) {
+ vboxSettingsStorageBusses.addAttached(cons[a].mediumAttachments[b].medium);
+ vboxSettingsAddAttachment(cons[a].mediumAttachments[b], conElm);
+ }
+ }
+
+ //Select first item in storage tree list
+ $('#vboxSettingsStorageTree').find('table.vboxListItem').first().trigger('click').html();
+
+ /* Disable non-editable items when VM is running */
+ var p = $('#vboxSettingsStorageTableWrapper');
+ if(!$('#vboxSettingsDialog').data('vboxFullEdit')) {
+
+ scToolbar.disable();
+ $('#vboxSettingsStorageTree').disableContextMenu()
+
+ p.find('span:not(.vboxRunningEnabled)').addClass('disabled');
+ p.find('input:not(.vboxRunningEnabled),select,textarea').prop('disabled',true);
+
+ // Storage tree toolbars
+ $('#vboxSettingsStorageTree').find('.vboxControllerAttachmentButton').trigger('disable');
+
+ // Hard Disk Media menu button
+ $('#vboxSettingsAddAttachmentsMenuHDDiv').trigger('disable');
+
+ } else {
+
+ $('#vboxSettingsStorageTree').enableContextMenu();
+
+ p.find('span:not(.vboxRunningEnabled)').removeClass('disabled');
+ p.find('input:not(.vboxRunningEnabled),select,textarea').prop('disabled',false);
+
+ // Storage tree toolbars
+ $('#vboxSettingsStorageTree').find('.vboxControllerAttachmentButton').trigger('enable');
+
+ // Hard Disk Media menu button
+ $('#vboxSettingsAddAttachmentsMenuHDDiv').trigger('enable');
+
+ // initial toolbar update
+ scToolbar.enable();
+ scToolbar.update();
+
+ }
+
+});
+
+
+/* Respond to UP / Down arrow events */
+$('#vboxSettingsStorageTree').click(function(){$(this).focus();}).keydown(function(e){
+
+ var keynum = 0;
+
+ if(e.keyCode)
+ keynum = e.keyCode;
+ else if(e.which)
+ keynum = e.which;
+
+ switch(keynum) {
+
+ // up
+ case 38:
+
+ var cur = $(this).find('table.vboxListItemSelected').parent();
+
+ // Try previous med attachment
+ if($(cur).prev('li.vboxSettingsMediumAttachment').children('table.vboxListItem').trigger('click')[0]) {
+ return;
+ }
+
+ // If we're a medium, click our parent controller
+ if($(cur).hasClass('vboxSettingsMediumAttachment')) {
+ $(cur).parent().parent('li.vboxSettingsController').children('table.vboxListItem').trigger('click');
+ return;
+ }
+
+ // Must be a controller, try previous controller's last medium attachment
+ if($(cur).prev().children('ul:not([class~="vboxHidden"])').find('table.vboxListItem:last').trigger('click')[0])
+ return;
+
+ // No med attachment, try previous controller
+ $(cur).prev('li.vboxSettingsController').children('table.vboxListItem').trigger('click');
+ break;
+
+ // right / expand
+ case 39:
+ var tbl = $(this).find('table.vboxListItemSelected');
+ var con = $(tbl).data('controller');
+ if(!con) return;
+ $(tbl).find('td.vboxSettingsController' + con.bus).click();
+ break;
+
+ // left / contract
+ case 37:
+ var tbl = $(this).find('table.vboxListItemSelected');
+ var con = $(tbl).data('controller');
+ if(!con) return;
+ $(tbl).find('td.vboxSettingsController' + con.bus + 'Expanded').click();
+ break;
+
+ // down
+ case 40:
+
+ var cur = $(this).find('table.vboxListItemSelected').parent();
+
+ // Try next med attachment
+ if($(cur).next('li.vboxSettingsMediumAttachment').children('table.vboxListItem').trigger('click')[0]) {
+ return;
+ }
+
+ // Select first medium of current controller?
+ if($(cur).children('ul:not([class~="vboxHidden"])').find('table.vboxListItem:first').trigger('click')[0])
+ return;
+
+ // Try next controller
+ $(cur).closest('li.vboxSettingsController').next('li.vboxSettingsController').children('table.vboxListItem').trigger('click');
+
+ break;
+ }
+
+}).css('outline','none');;
+
+/*
+ *
+ * Change media attachment helper function
+ *
+ */
+function vboxSettingsControllerAttach(m) {
+
+ var tbl = $('#vboxSettingsStorageTree').find('table.vboxListItemSelected');
+ $(tbl).data('attachment').medium = m;
+ $(tbl).parent().tipped({'source':vboxSettingsMediumTip(m),'position':'mouse','delay':1000});
+
+ // Re-select attachment to update display info
+ vboxSettingsSelectAttachment(tbl);
+
+
+}
+
+
+/*
+ *
+ * Called when controller is selected helper function
+ *
+ */
+function vboxSettingsSelectController(tbl) {
+
+ // Null selection?
+ if(!tbl) {
+ $('#vboxSettingsController').css('display','none');
+ $('#vboxSettingsMediaInfo').css('display','none');
+ $('#vboxSettingsStorageAttachment').css('display','none');
+ return;
+ }
+
+ $(document.forms['frmVboxSettings'].vboxSettingsStorageItemName).trigger('blur');
+
+ /* set classes for selected / unselected */
+ $('#vboxSettingsStorageTree').find('table[class]').removeClass('vboxListItemSelected').addClass('vboxListItem');
+ $(tbl).removeClass('vboxListItem').addClass('vboxListItemSelected');
+
+ /* set name text box value */
+ document.forms['frmVboxSettings'].vboxSettingsStorageItemName.value = $(tbl).data('controller').name;
+
+ /* Set host cache checkbox */
+ document.forms['frmVboxSettings'].vboxSettingsStorageHostCache.checked = $(tbl).data('controller').useHostIOCache ? 'checked' : '';
+
+ var busType = $(tbl).data('controller').bus;
+
+ /* controller type */
+ document.forms['frmVboxSettings'].vboxSettingsStorageControllerType.options.length = 0;
+ $(document.forms['frmVboxSettings'].vboxSettingsStorageControllerType).children().remove();
+ for(var i = 0; i < vboxStorage[busType].types.length; i++) {
+ document.forms['frmVboxSettings'].vboxSettingsStorageControllerType.options[i] = new Option(trans(vboxStorageControllerType(vboxStorage[busType].types[i]),'VBoxGlobal'),vboxStorage[busType].types[i]);
+ }
+
+ /* Set default type */
+ document.forms['frmVboxSettings'].vboxSettingsStorageControllerType.value = $(tbl).data('controller').controllerType;
+
+ $('#vboxSettingsController').css('display','block');
+ $('#vboxSettingsStorageAttachment').css('display','none');
+ $('#vboxSettingsMediaInfo').css('display','none');
+ $('#vboxSettingsHDInfo').css('display','none');
+
+ // Show SATA port count
+ if(busType == 'SATA') {
+ $(document.forms['frmVboxSettings'].vboxSettingsControllerPortCount).val($(tbl).data('controller').portCount);
+ $('#vboxSettingsControllerPortCountRow').css('display','');
+ } else {
+ $('#vboxSettingsControllerPortCountRow').css('display','none');
+ }
+
+ /* Enable / disable buttons */
+ if($(tbl).parent().find('ul').children('li').length < ($(tbl).data('controller').maxPortCount * $(tbl).data('controller').maxDevicesPerPortCount)) {
+
+ if($('#vboxSettingsDialog').data('vboxFullEdit')) {
+ $(tbl).find('.vboxToolbarSmall').trigger('enable', [true]);
+ }
+
+ } else {
+ $(tbl).find('.vboxToolbarSmall').trigger('disable');
+ }
+
+ /* Trigger Event */
+ $('#vboxSettingsStorageTree').trigger('itemselect',tbl);
+
+}
+
+
+/*
+ * Generate tooltip for medium helper function
+ */
+function vboxSettingsMediumTip(m) {
+
+ if(!m || !m.id) return trans('Empty','VBoxGlobal');
+ if(m.hostDrive) return vboxMedia.getName(m);
+
+ // DVD / Floppy images
+ if(m.deviceType != 'HardDisk') {
+ return '<b>'+m.location+'</b><p>'+trans('Attached to:','UIMachineSettingsStorage')+' '+vboxMedia.attachedTo(m)+'</p>';
+ }
+
+ var mbase = m;
+ if(m.base != m.id) {
+ mbase = vboxMedia.getMediumById(m.base);
+ }
+ var tip = '<b>'+mbase.location+'</b><p>'+trans('Type (Format):','UIMachineSettingsStorage')+' '+vboxMedia.getType(mbase)+' ('+mbase.format+')</p><p>'+trans('Attached to:','UIMachineSettingsStorage')+' '+vboxMedia.attachedTo(mbase)+'</p>';
+
+ // Is this a medium that is attached indirectly
+ if(vboxSettingsStorageBusses.isAttachedIndirect(m) && m.base != m.id) {
+ var p = vboxSettingsStorageBusses.isAttached(m);
+ tip += '<hr />'+trans('This base hard disk is indirectly attached using the following differencing hard disk:','VBoxGlobal')+'<br /><b>'+p.location+'</b></p><p>'+trans('Type (Format):','UIMachineSettingsStorage')+' '+vboxMedia.getType(p) + ' (' + p.format + ')'+'</p><p>'+trans('Attached to:','UIMachineSettingsStorage')+' '+vboxMedia.attachedTo(p)+'</p>';
+ } else if(m.readOnly) {
+ tip += '<hr />'+trans('Attaching this hard disk will be performed indirectly using a newly created differencing hard disk.','VBoxGlobal');
+ }
+
+ return tip;
+
+}
+
+/*
+ *
+ * Add disk medium to bus helper function
+ *
+ */
+function vboxSettingsStorageAddMedium(conElm, type) {
+
+ // get controller name
+ var controller = $(conElm).find('span.vboxSettingsControllerTitle').first().text();
+
+ if(!type) type = 'HardDisk';
+
+ // Find first target slot (vboxSettingsStorageBusses created above)
+ var slots = vboxSettingsStorageBusses.availableSlots(conElm);
+ var slot = null;
+ for(var i in slots) {
+ if(typeof i == 'function') continue;
+ slot = i;
+ break;
+ }
+ if(slot === null) return;
+ slot = slot.split('-');
+ var port = slot[0];
+ var device = slot[1];
+
+ // Add new attachment dialog
+ ////////////////////////////
+ var buttons = {};
+
+ var msg = '';
+
+ // Hard Disk buttons
+ if (type == 'HardDisk') {
+
+ buttons[trans('Create new disk','UIMessageCenter')] = function() {
+
+ $.when(new vboxWizardNewHDDialog({'path':vboxDirname($('#vboxSettingsDialog').data('vboxMachineData').settingsFilePath)+$('#vboxPane').data('vboxConfig').DSEP,vmName:$('#vboxSettingsDialog').data('vboxMachineData').name}).run())
+ .done(function(id){
+ if(!id) return;
+ mAttachToolbarHD.mediaMenu.menuUpdateRecent();
+ vboxSettingsAddAttachment({'controller':controller,'port':port,'device':device,'type':type,'medium':vboxMedia.getMediumById(id),'ignoreFlush':1}, conElm);
+ $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().click();
+ });
+
+ $(this).remove();
+
+ };
+ buttons[trans('Choose existing disk','UIMessageCenter')] = function() {
+ var dlg = $(this);
+ vboxMedia.actions.choose(null,'HardDisk',function(med){
+ if(med) {
+ mAttachToolbarHD.mediaMenu.menuUpdateRecent();
+ vboxSettingsAddAttachment({'controller':controller,'port':port,'device':device,'type':type,'medium':med,'ignoreFlush':1}, conElm);
+ $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().click();
+ }
+ $(dlg).remove();
+ });
+ };
+
+ msg = trans('<p>You are about to add a virtual hard disk to controller <b>%1</b>.</p><p>Would you like to create a new, empty file to hold the disk contents or select an existing one?</p>','UIMessageCenter').replace('%1',controller);
+
+ // Floppy buttons
+ } else if(type == 'Floppy') {
+
+ buttons[trans('Choose disk','UIMessageCenter')] = function() {
+ var dlg = $(this);
+ vboxMedia.actions.choose(null,'Floppy',function(med){
+ if(med) {
+ mAttachToolbarFD.mediaMenu.menuUpdateRecent();
+ vboxSettingsAddAttachment({'controller':controller,'port':port,'device':device,'type':type,'medium':med}, conElm);
+ $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().click();
+ }
+ $(dlg).remove();
+ });
+
+ };
+
+ buttons[trans('Leave empty','UIMessageCenter')] = function() {
+ vboxSettingsAddAttachment({'controller':controller,'port':port,'device':device,'type':type,'medium':null}, conElm);
+ $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().click();
+ $(this).remove();
+ };
+
+ msg = trans('<p>You are about to add a new floppy drive to controller <b>%1</b>.</p><p>Would you like to choose a virtual floppy disk to put in the drive or to leave it empty for now?</p>','UIMessageCenter').replace('%1',controller);
+
+ // CD/DVD buttons
+ } else {
+
+ buttons[trans('Choose disk','UIMessageCenter')] = function() {
+ var dlg = $(this);
+ vboxMedia.actions.choose(null,'DVD',function(med){
+ if(med) {
+ mAttachToolbarCD.mediaMenu.menuUpdateRecent();
+ vboxSettingsAddAttachment({'controller':controller,'port':port,'device':device,'type':type,'medium':med}, conElm);
+ $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().click();
+ }
+ $(dlg).remove();
+ });
+
+ };
+
+ buttons[trans('Leave empty','UIMessageCenter')] = function() {
+ vboxSettingsAddAttachment({'controller':controller,'port':port,'device':device,'type':type,'medium':null}, conElm);
+ $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().click();
+ $(this).remove();
+ };
+
+ msg = trans('<p>You are about to add a new CD/DVD drive to controller <b>%1</b>.</p><p>Would you like to choose a virtual CD/DVD disk to put in the drive or to leave it empty for now?</p>','UIMessageCenter').replace('%1',controller);
+
+ }
+
+ buttons[trans('Cancel','QIMessageBox')] = function() {
+ $(this).remove();
+ };
+ $('<div />').attr({'id':'vboxSettingsStorageUnavailable','style':'display: none'}).html(
+ '<div><img src="images/50px-Question_icon.svg.png" style="float: left; padding: 10px; " />'+msg+'</div>'
+ ).dialog({'closeOnEscape':false,'width':600,'height':200,'buttons':buttons,'modal':true,'autoOpen':true,'dialogClass':'vboxDialogContent','title':'<img src="images/vbox/OSE/about_16px.png" class="vboxDialogTitleIcon" /> phpVirtualBox'});
+
+
+}
+
+/*
+ *
+ * Add controller to list helper function
+ *
+ */
+
+function vboxSettingsAddController(con,list) {
+
+ // Elect name if none exists
+ if(!con.name) {
+ var count = $(list).children('li.vboxSettingsController'+con.bus).length + 1;
+ var name = trans(con.bus,'UIMachineSettingsStorage');
+ if(count == 1) {
+ con.name = name;
+ } else {
+
+ var electedName = name + ' ' + count;
+ var conflictFound = false;
+ do {
+ conflictFound = false;
+ $(list).children('li.vboxSettingsController'+con.bus).each(function(idx,elm) {
+ if($(elm).children('table').first().data('controller').name == electedName) {
+ conflictFound = true;
+ electedName = name + ' ' + (++count);
+ return false;
+ }
+ });
+ con.name = electedName;
+
+ } while(conflictFound);
+ }
+
+ }
+ var li = $('<li />').attr({'title':con.name,'class':'vboxSettingsController vboxSettingsController' + con.bus});
+
+ var tbl = $('<table />').attr({'class':'vboxListItem vboxSettingsController'}).on('click',function(){
+ vboxSettingsSelectController(this);
+ });
+
+ // filter out any dummy medium attachments
+ var mas = new Array();
+ for(var i = 0; i < con.mediumAttachments.length; i++) {
+ if(con.mediumAttachments[i].controller)
+ mas[mas.length] = con.mediumAttachments[i];
+ }
+ con.mediumAttachments = mas;
+
+ // Assign data
+ $(tbl).data('controller',con);
+
+ var tr = $('<tr />');
+
+ var iconName = vboxStorage.getBusIconName(con.bus);
+ $('<td />').attr({'class':'vboxSettingsStorageTypeIcon vboxSettingsController' + con.bus + 'Expanded'})
+ .css({
+ 'background-image':'url(images/vbox/'+iconName+'_collapse_16px.png)'
+ }).html('<div style="width:22px" />').click(function(){
+
+
+ if(!$(this).data('toggleClicked')) {
+
+ $(this).data('toggleClicked', true);
+
+ var n = $(this).closest('li');
+ $(n).children('ul').addClass('vboxHidden').css('display','none');
+ $(this).removeClass('vboxSettingsController'+con.bus+'Expanded').addClass('vboxSettingsController'+con.bus)
+ .css({'background-image':'url(images/vbox/'+iconName+'_expand_16px.png)'});
+
+ } else {
+
+ $(this).data('toggleClicked', false);
+ var n = $(this).closest('li');
+ $(n).children('ul').removeClass('vboxHidden').css('display','');
+ $(this).removeClass('vboxSettingsController'+con.bus).addClass('vboxSettingsController'+con.bus+'Expanded')
+ .css({'background-image':'url(images/vbox/'+iconName+'_collapse_16px.png)'})
+
+ }
+
+ return false;
+
+ }).appendTo(tr);
+
+ // Controller name
+ $(tr).append($('<td />').css({'width':'100%'}).html('<div class="vboxFitToContainer">'+trans('Controller: %1','UIMachineSettingsStorage').replace('%1','<span class="vboxSettingsControllerTitle vboxRunningEnabled">'+$('<div/>').text(con.name).html())+"</span>"+"</div>"));
+
+ // Buttons
+ $(tr).append($('<td />').attr({'style':'width: 22px;','class':'vboxControllerAttachmentButton'}));
+
+ $(tbl).append(tr).appendTo(li);
+
+
+ /* Attachments list holder */
+ $(li).append($('<ul />').attr({'class':'vboxSettingsControllerAttachments'})).dblclick(function(e){
+ $(this).children('table.vboxSettingsController').find('td.vboxSettingsStorageTypeIcon').trigger('click',e);
+ }).disableSelection().appendTo(list);
+
+ /* Generate Toolbars */
+ var dtypes = vboxStorage[con.bus].driveTypes;
+ for(var i = 0; i < dtypes.length; i++) {
+ var b = null;
+ if(dtypes[i] == 'dvd') {
+ b = {
+ 'name' : con.bus+'addcd',
+ 'label' : trans('Add Optical Drive','UIMachineSettingsStorage'),
+ 'icon' : 'cd_add',
+ 'click' : function () { vboxSettingsStorageAddMedium(li,'DVD'); }
+ };
+ } else if(dtypes[i] == 'disk') {
+ b = {
+ 'name' : con.bus+'adddrive',
+ 'label' : trans('Add Hard Disk','UIMachineSettingsStorage'),
+ 'icon' : 'hd_add',
+ 'click' : function (item) { vboxSettingsStorageAddMedium(li); }
+ };
+
+ } else if(dtypes[i] == 'floppy') {
+ b = {'label':trans('Add Floppy Drive','UIMachineSettingsStorage'),
+ 'icon' : 'fd_add',
+ 'click' : function (item) { vboxSettingsStorageAddMedium(li,'Floppy'); }
+ };
+ }
+ b['enabled'] = function() {
+
+ return (li.find('li').length < (vboxStorage[con.bus].maxPortCount * vboxStorage[con.bus].maxDevicesPerPortCount));
+ };
+
+ var tb = new vboxToolbarSmall({buttons: [b],
+ buttonStyle: 'margin:0px;padding:0px;border:0px;background-repeat:no-repeat;background-position:0px 0px;',
+ noHover: true,
+ renderTo: li.find('td.vboxControllerAttachmentButton')});
+ tb.disable();
+
+ }
+
+ // Only if machine is not running
+ if($('#vboxSettingsDialog').data('vboxFullEdit')) {
+
+ $(li).contextMenu({menu: vboxStorageAttachmentMenus[con.bus].menuId(),
+ menusetup: function() {$(li).children('table').first().trigger('click')}},
+ vboxStorageAttachmentMenus[con.bus].menuClickCallback
+ );
+
+ }
+
+ // Return controller element list item
+ return li;
+
+}
+
+
+
+
+
+/*
+ *
+ * Add a medium attachment to a controller helper function
+ *
+ */
+function vboxSettingsAddAttachment(d,conElm) {
+
+
+ var con = (conElm ? conElm : $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().parent());
+
+ // Save bus
+ d.bus = $(con).find('table.vboxSettingsController').data('controller').bus;
+
+ // remove any 'last' classes
+ $(con).children('ul').children().removeClass('last');
+
+ var li = $('<li />').attr({'class':'last vboxSettingsMediumAttachment'});
+
+
+ var tbl = $('<table />').attr({'class':'vboxListItem vboxSettingsStorageAttachment'})
+ .data({'attachment':d}).on('click',function(){
+ vboxSettingsSelectAttachment(this);
+ });
+
+ var m = vboxMedia.getMediumById(((d.medium && d.medium.id) ? d.medium.id : null));
+
+ var tr = $('<tr />');
+
+ // Storage type icon
+ $(tr).append($('<td />').attr({'class':'vboxSettingsStorageTypeIcon vboxSettingsMediaType' + d.type,'style':'width:22px'}).html('<img src="images/vbox/blank.gif" style="width:22px" />'));
+
+ // Medium name
+ $(tr).append($('<td />').css({'width':'100%'}).append($('<div />').attr({'class':'vboxSettingsStorageMediumName vboxFitToContainer'}).html(vboxMedia.getName(vboxMedia.getMediumById((m && m.base ? m.base : (m && m.id ? m.id : null)))))));
+
+
+ $(tbl).append(tr).appendTo(li);
+
+ // Only if not running
+ if($('#vboxSettingsDialog').data('vboxFullEdit')) {
+
+ $(li).contextMenu({
+ menu: vboxSettingsMAMenu.menuId(),
+ menusetup : function(el) {
+ vboxSettingsSelectAttachment($(el).find('table.vboxSettingsStorageAttachment'));
+ }
+ },
+ function(action, el, pos) {
+ vboxSettingsStorageButtons[1].click();
+ }
+ );
+ }
+
+ $(li).tipped({'source':vboxSettingsMediumTip(m),'position':'mouse','delay':1000}).appendTo(con.children('ul'));
+
+
+}
+
+/*
+ *
+ * Called when selecting a medium attachment
+ *
+ */
+function vboxSettingsSelectAttachment(tbl) {
+
+ // Null selection?
+ if(!tbl) {
+ $('#vboxSettingsController').css('display','none');
+ $('#vboxSettingsMediaInfo').css('display','none');
+ $('#vboxSettingsStorageAttachment').css('display','none');
+ return;
+ }
+
+ $(document.forms['frmVboxSettings'].vboxSettingsStorageItemName).trigger('blur');
+
+ /* Display Changes */
+ if(!$(tbl).hasClass('vboxListItemSelected')) {
+ $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').removeClass('vboxListItemSelected').addClass('vboxListItem');
+ $(tbl).removeClass('vboxListItem').addClass('vboxListItemSelected');
+ }
+
+ $('#vboxSettingsController').css('display','none');
+ $('#vboxSettingsMediaInfo').css('display','block');
+ $('#vboxSettingsStorageAttachment').css('display','block');
+
+
+ var ma = $(tbl).data('attachment');
+
+ /* Get / Set Medium */
+ if(ma.medium && ma.medium.id)
+ ma.medium = vboxMedia.getMediumById(ma.medium.id);
+
+ (function(){
+
+ var sc = $(tbl).closest('li.vboxSettingsController').children('table').first().data('controller');
+
+ var tblSA = $('#vboxSettingsStorageAttachment').find('table').first();
+ $(tblSA).find('tr.vboxSettingsControllerDeviceOptionRow').empty().remove();
+
+ switch(ma.type) {
+
+ case 'HardDisk':
+ label = 'Hard Disk:';
+ break;
+ case 'DVD':
+ label = 'CD/DVD Drive:';
+ break;
+ case 'Floppy':
+ label = 'Floppy Drive:';
+ break;
+ }
+ var maOptions = vboxStorage.getMAOptions(ma)
+ .concat(vboxStorage.getMAOptionsForSC(sc));
+ for(var i = 0; i < maOptions.length; i++) {
+
+ var opt = maOptions[i];
+
+ var cbox = $('<input />').attr('type','checkbox').prop('checked', ma[opt.attrib] ? true : false)
+ .on('click', {attrib: opt.attrib}, function(event){
+
+ var attachment = $(tbl).data('attachment');
+ attachment[event.data.attrib] = this.checked ? true : false;
+ $(tbl).data('attachment', attachment);
+
+ }).addClass('vboxCheckbox');
+
+ $('<tr />').addClass('vboxSettingsControllerDeviceOptionRow')
+ .append($('<th />'))
+ .append(
+ $('<td />')
+ .append($('<label />')
+ .append(cbox)
+ .append($('<span />').css({'margin-left':'4px'}).text(opt.label))
+ )
+ ).appendTo($(tblSA));
+
+
+ }
+ })();
+ $('#vboxSettingsControllerSlotLabel').html(trans(label,'UIMachineSettingsStorage'));
+
+
+ /* Show / Hide HD/Media Info */
+ $('#vboxSettingsImageInfo').css('display',(ma.type == 'HardDisk' ? 'none' : 'block'));
+ $('#vboxSettingsHDInfo').css('display',(ma.type == 'HardDisk' ? 'block' : 'none'));
+
+
+
+ /* Populate slot select box */
+ document.forms['frmVboxSettings'].vboxSettingsControllerSlot.options.length = 0;
+ $(document.forms['frmVboxSettings'].vboxSettingsControllerSlot).children().remove();
+ slots = vboxSettingsStorageBusses.availableSlots($(tbl).parent().parent().parent(), ma.port+'-'+ma.device);
+
+ for(var s in slots) {
+ var opt = new Option(slots[s], s);
+ document.forms['frmVboxSettings'].vboxSettingsControllerSlot.options[document.forms['frmVboxSettings'].vboxSettingsControllerSlot.options.length] = opt;
+ }
+ document.forms['frmVboxSettings'].vboxSettingsControllerSlot.value = ma.port+'-'+ma.device;
+
+ /* Trigger Event */
+ $('#vboxSettingsStorageTree').trigger('itemselect',tbl);
+
+ var m = ma.medium;
+ var name = vboxMedia.getName(m);
+
+ // Read-only medium selected
+ if(ma.medium && ma.medium.readOnly) {
+ $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().find('td').first().addClass('vboxMediumReadOnly');
+ } else {
+ $('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().find('td').first().removeClass('vboxMediumReadOnly');
+ }
+
+ // Show medium info
+ if(m && m.deviceType == 'HardDisk') {
+
+ var disp = vboxMedia.getMediumById(m.base);
+ name = vboxMedia.getName(disp);
+
+ var encSettings = vboxMedia.getEncryptionSettings(disp);
+
+ $('#vboxSettingsHDvsize').html(vboxMbytesConvert(disp.logicalSize));
+ $('#vboxSettingsHDasize').html(vboxBytesConvert(disp.size));
+ $('#vboxSettingsHDDetails').html(vboxMedia.getHardDiskVariant(disp));
+ $('#vboxSettingsHDlocation').html(disp.location);
+ $('#vboxSettingsHDtype').html(trans(disp.type,'VBoxGlobal') + ' (' + disp.format + ')');
+ $('#vboxSettingsHDattached').html(vboxMedia.attachedTo(disp));
+ $('#vboxSettingsHDEncrypted').html(encSettings && encSettings.id ? encSettings.id : '--');
+
+
+ } else {
+
+ $('#vboxSettingsImageType').html(m ? trans((m.hostDrive ? 'Host Drive' : 'Image'),'UIMachineSettingsStorage'): '--');
+ $('#vboxSettingsImageSize').html((m && !m.hostDrive ? vboxBytesConvert(m.size):'--'));
+ $('#vboxSettingsImageLocation').html((m && !m.hostDrive ? m.location:'--'));
+ $('#vboxSettingsImageAttached').html((m && !m.hostDrive ? vboxMedia.attachedTo(m) :'--'));
+
+ }
+
+ $(tbl).data('attachment').medium = m;
+ $(tbl).find('div.vboxSettingsStorageMediumName').first().html($('<div />').text(name).html());
+
+
+}
+
+
+/*
+ * Focus storage controller list when showing this pane
+ */
+$('#vboxSettingsStorageTableWrapper').on('show',function(){
+ $('#vboxSettingsStorageTree').focus();
+});
+
+/*
+ *
+ *
+ * Storage pane resize and draggable resize bar logic
+ *
+ *
+ */
+/*
+ * Resize storage pane
+ */
+function vboxSettingsStorageResize() {
+
+ // Hide storage tree
+ $('#vboxSettingsStorageTree').css({'display':'none'});
+
+ // Get and set size
+ $('#vboxStoragePaneLeft').css({'display':'none'});
+ $('#vboxStoragePaneRight').css({'display':'none'});
+
+ // Main table height
+ $('#vboxSettingsStorageTableWrapper').css({'display':'none'});
+ var h = $('#vboxSettingsStorageTableWrapper').css({'display':'none'}).parent().parent().innerHeight()-4;
+
+ // IE needs to account for bordering
+ if($.browser.msie) h-= 4;
+
+ // Set height
+ $('#vboxSettingsStorageTableWrapper').css({'display':''}).height(h);
+
+ // Pane width
+ var bothWidth = ($('#vboxStoragePaneLeft').parent().innerWidth() + $('#vboxStoragePaneRight').parent().innerWidth() - 24) / 2;
+ $('#vboxStoragePaneLeft').css({'width':bothWidth+'px','display':''}).parent().css({'width':'auto','padding':'6px'});
+ $('#vboxStoragePaneRight').css({'width':bothWidth+'px','display':''}).parent().css({'width':'auto','padding':'6px'});
+
+ // Unsnap.. sorry..
+ $('#vboxStorageResizeBar').data('vboxSnapped',0);
+
+ // Get inner height of storage tree parent - padding
+ var h = $('#vboxStoragePaneLeft').parent().innerHeight() - 24;
+ // subtract sibling heights
+ $('#vboxSettingsStorageTree').siblings().each(function(){
+ h -= $(this).outerHeight(true);
+ });
+
+ $('#vboxSettingsStorageTree').height(h).css({'display':''});
+
+ vboxStorageResizeTreeItemLabels();
+
+}
+
+/*
+ * Resize controller labels
+ */
+function vboxStorageResizeTreeItemLabels() {
+
+ $('#vboxSettingsStorageTree div.vboxFitToContainer').each(function(){
+ $(this).css({'display':'none'});
+ var w = $(this).parent().innerWidth() - 2;
+ $(this).css({'width':w+'px','display':''});
+ });
+
+
+};
+
+/*
+ * Set pane sizes and resize bar
+ */
+$('#vboxSettingsStorageTableWrapper').one('show',function(){
+
+
+ // Resize everything on dialog resize
+ $('#vboxSettingsDialog').on('dialogresizestop',function(){
+ vboxSettingsStorageResize();
+ });
+ $('#vboxSettingsStorageTableWrapper').on('show',function(){
+ vboxSettingsStorageResize();
+ });
+
+ // Hide children to get true size
+ $('#vboxStoragePaneLeft').children().css({'display':'none'});
+ $('#vboxStoragePaneRight').children().css({'display':'none'});
+
+ var h = $('#vboxSettingsStorageTableWrapper').parent().css({'padding':'0px','margin':'0px'}).parent().innerHeight();
+
+ // IE needs to account for bordering
+ if($.browser.msie) h-= 4;
+
+ $('#vboxSettingsStorageTableWrapper').height(h-4);
+
+ // Get and set size
+ var bothWidth = ($('#vboxStoragePaneLeft').parent().innerWidth() + $('#vboxStoragePaneRight').parent().innerWidth() - 24) / 2;
+ $('#vboxStoragePaneLeft').css({'width':bothWidth+'px','overflow':'hidden'}).parent().css({'width':'auto'});
+ $('#vboxStoragePaneRight').css({'width':bothWidth+'px','overflow':'hidden'}).parent().css({'width':'auto'});
+
+ // Show children again
+ $('#vboxStoragePaneLeft').children().css({'display':''});
+ $('#vboxStoragePaneRight').children().css({'display':''});
+
+ // Re-trigger list selection to show correct info
+ if(!$('#vboxSettingsStorageTree').find('table.vboxListItemSelected').first().click().hasClass('vboxListItemSelected'))
+ $('#vboxSettingsStorageTree').trigger('itemselect',null);
+
+ // Don't allow selection of text in storage tree. This looks funny when dragging the resize bar
+ $('#vboxSettingsStorageTree').disableSelection();
+
+ // Resize
+ vboxSettingsStorageResize();
+
+ // Draggable resize bar
+ $('#vboxStorageResizeBar').draggable({cursor:(jQuery.browser.opera ? 'e-resize' : 'col-resize'),axis:'x',zIndex:99,helper:function(){
+
+ return $('<span />'); // dummy element
+
+ },scroll:false,'start':function(e,ui){
+
+ $('#vboxStorageResizeBar').data('vboxX',e.pageX);
+
+ $('#vboxResizeOverlay').remove();
+ $('body').disableSelection().css({'cursor':(jQuery.browser.opera ? 'e-resize' : 'col-resize')});
+ $('#vboxSettingsDialog').append($('<div />').attr({'id':'vboxResizeOverlay','style':'width:99%;height:99%;border:0px;margin:0px;padding:0px;position:absolute;top:0px;left:0px;cursor:'+(jQuery.browser.opera ? 'e-resize' : 'col-resize')}));
+
+
+ },'drag':function(e){
+
+ var sStart = $('#vboxStorageResizeBar').data('vboxX');
+ var sStop = e.pageX;
+ var sWidth = Math.abs(sStop - sStart);
+ if(sWidth == 0) return;
+
+ var lWidth = parseInt($('#vboxStoragePaneLeft').css('width'));
+ var rWidth = parseInt($('#vboxStoragePaneRight').css('width'));
+
+ var snapped = $('#vboxStorageResizeBar').data('vboxSnapped');
+
+ // Left to right
+ if(sStop > sStart) {
+
+ // Check for snapping
+ if(snapped) {
+ if(snapped > sStop || (rWidth - sWidth < 150)) { return; }
+ else if(snapped && snapped <= sStop) {
+
+ // Unsnap left pane
+ $('#vboxStoragePaneRight').parent().css({'width':'auto'});
+ $('#vboxStoragePaneLeft').css({'display':''}).parent().css({'padding':'6px'});
+ $('#vboxStorageResizeBar').data('vboxSnapped',0);
+ lWidth = $('#vboxStorageResizeBar').data('vboxSnappedWidthL');
+ rWidth = $('#vboxStorageResizeBar').data('vboxSnappedWidthR');
+ sWidth = Math.abs(sStop - snapped);
+ }
+ }
+
+ if(rWidth - sWidth < 150) {
+
+ $('#vboxStoragePaneLeft').css({'width':'100%'}).parent().css({'width':'100%'});
+ $('#vboxStoragePaneRight').css({'display':'none','width':'10px'}).parent().css({'padding':'0px'});
+ $('#vboxStorageResizeBar').data('vboxSnapped',e.pageX);
+ $('#vboxStorageResizeBar').data('vboxSnappedWidthL', (lWidth + sWidth));
+ $('#vboxStorageResizeBar').data('vboxSnappedWidthR', (rWidth - sWidth));
+
+ } else {
+ $('#vboxStoragePaneLeft').css({'width':(lWidth + sWidth)+'px','display':''});
+ $('#vboxStoragePaneRight').css({'width':(rWidth - sWidth)+'px','display':''});
+ }
+
+
+ // Right to left
+ } else {
+
+ // Check for snapping
+ if(snapped) {
+ if(snapped < sStop || (lWidth - sWidth < 150)) { return; }
+ else if(snapped && snapped >= sStop) {
+
+ // Unsnap right pane
+ $('#vboxStoragePaneLeft').parent().css({'width':'auto'});
+ $('#vboxStoragePaneRight').css({'display':''}).parent().css({'width':'100%','padding':'6px'}); // 100% to fix webkit
+ $('#vboxStorageResizeBar').data('vboxSnapped',0);
+ lWidth = $('#vboxStorageResizeBar').data('vboxSnappedWidthL');
+ rWidth = $('#vboxStorageResizeBar').data('vboxSnappedWidthR');
+ sWidth = Math.abs(sStop-snapped);
+
+ }
+ }
+
+ if(lWidth - sWidth < 150) {
+
+ $('#vboxStoragePaneRight').css({'width':'100%'}).parent().css({'width':'100%'});
+ $('#vboxStoragePaneLeft').css({'display':'none','width':'10px'}).parent().css({'padding':'0px'});
+ $('#vboxStorageResizeBar').data('vboxSnapped',e.pageX);
+ $('#vboxStorageResizeBar').data('vboxSnappedWidthL', (lWidth - sWidth));
+ $('#vboxStorageResizeBar').data('vboxSnappedWidthR', (rWidth + sWidth));
+
+ } else {
+ $('#vboxStoragePaneLeft').css({'width':(lWidth - sWidth)+'px'});
+ $('#vboxStoragePaneRight').css({'width':(rWidth + sWidth)+'px'});
+ }
+ }
+
+ $('#vboxStorageResizeBar').data('vboxX',e.pageX);
+
+ // resize labels
+ vboxStorageResizeTreeItemLabels();
+
+
+ },'stop':function(e) {
+
+ // resize labels
+ vboxStorageResizeTreeItemLabels();
+
+ $('body').enableSelection().css({'cursor':'default'});
+ $('#vboxResizeOverlay').remove();
+ }}).css({'cursor':(jQuery.browser.opera ? 'e-resize' : 'col-resize'),'height':'98%'});
+
+
+});
+
</script> \ No newline at end of file
diff --git a/panes/settingsSystem.html b/panes/settingsSystem.html
index 68f8669..cc53863 100644
--- a/panes/settingsSystem.html
+++ b/panes/settingsSystem.html
@@ -1,466 +1,466 @@
-<!--
-
- VM System Settings
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: settingsSystem.html 597 2015-04-20 11:41:28Z imoore76 $
-
--->
-
-<ul>
- <li><a href="#vboxSettingsTabSystemMotherboard"><span class='translate'>Motherboard</span></a></li>
- <li><a href="#vboxSettingsTabSystemProcessor"><span class='translate'>Processor</span></a></li>
- <li><a href="#vboxSettingsTabSystemAcceleration"><span class='translate'>Acceleration</span></a></li>
-</ul>
-
-<!-- Motherboard Tab -->
-<div id='vboxSettingsTabSystemMotherboard' title='Motherboard'>
-<table style='width: 100%'>
- <tr>
- <th style='text-align:right'><span class='translate'>Base Memory:</span></th>
- <td style='width: 100%; white-space: nowrap'>
- <table style='width: 100%'>
- <tr>
- <td style='width: 100%; border: 0px; margin: 0px; padding: 0px;'>
- <div style='margin-top: 4px' id='vboxSettingsSystemMemory' class='slider'><div class='sliderScale'></div></div>
- </td>
- <td><input type='text' class='vboxText sliderValue' name='vboxSettingsSystemMemoryValue' size='5' /> <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 class='vboxSliderMin'>%1 MB</span></td>
- <td style='text-align: right;'><span class='vboxSliderMax'>%1 MB</span></td>
- </tr>
- </table>
- </td>
- <td></td>
- </tr>
- </table>
- </td>
- </tr>
- <tr class='vboxSettingsSystemAdvancedOnly'>
- <th></th>
- <td><label><input type='checkbox' class='vboxCheckbox' name='vboxSettingsSystemPageFusion' /> <span class='translate'>Enable Page Fusion</span></label></td>
- </tr>
- <tr style='vertical-align: top'>
- <th style='text-align:right'><span class='translate'>Boot Order:</span></th>
- <td>
- <table id='vboxVMBootOrder'>
- <tr style='vertical-align: top'>
- <td style='width: auto'>
- <ul class='vboxList vboxHover vboxBordered' id='vboxVMBootOrderList' style='margin: 0px; padding: 2px; white-space: nowrap; width: 200px'>
- <li id='HardDisk'><input type='checkbox' class='vboxCheckbox' name='vboxSettingsBootHardDisk' /> <img src="images/vbox/hd_16px.png" /> <span class='vboxBootOrderDevice'>HardDisk</span></li>
- <li id='DVD'><input type='checkbox' class='vboxCheckbox' name='vboxSettingsBootDVD' /> <img src="images/vbox/cd_16px.png" /> <span class='vboxBootOrderDevice'>DVD</span></li>
- <li id='Floppy'><input type='checkbox' class='vboxCheckbox' name='vboxSettingsBootFloppy' /> <img src="images/vbox/fd_16px.png" /> <span class='vboxBootOrderDevice'>Floppy</span></li>
- <li id='Network'><input type='checkbox' class='vboxCheckbox' name='vboxSettingsBootNetwork' /> <img src="images/vbox/nw_16px.png" /> <span class='vboxBootOrderDevice'>Network</span></li>
- </ul>
- </td>
- <td style='text-align: left; width: 100%'>
- <input disabled='disabled' class="imgMvUp vboxImgButton" style='background: url(images/vbox/list_moveup_disabled_16px.png) 1px 1px no-repeat; width: 18px; height: 18px; vertical-align:bottom' type="button" value="" />
- <br />
- <input disabled='disabled' class="imgMvDn vboxImgButton" style='background: url(images/vbox/list_movedown_disabled_16px.png) 1px 1px no-repeat; width: 18px; height: 18px; vertical-align:bottom' type="button" value="" />
- </td>
- </tr>
- </table>
- </td>
- </tr>
- <tr id='vboxSettingsSystemChipsetRow'>
- <th style='text-align:right'><span class='translate'>Chipset:</span></th>
- <td><select name='vboxSettingsSystemChipset'>
- <option value='PIIX3'>PIIX3</option>
- <option value='ICH9'>ICH9</option>
- </select>
- </td>
- </tr>
- <tr>
- <th style='text-align:right'><span class='translate'>Extended Features:</span></th>
- <td><label><input type='checkbox' class='vboxCheckbox' name='vboxSettingsSystemIOAPIC' /> <span class='translate'>Enable I/O APIC</span></label></td>
- </tr>
- <tr>
- <th></th>
- <td><label><input type='checkbox' class='vboxCheckbox' name='vboxSettingsSystemEFI' /> <span class='translate'>Enable EFI (special OSes only)</span></label></td>
- </tr>
- <tr>
- <th></th>
- <td><label><input type='checkbox' class='vboxCheckbox' name='vboxSettingsSystemRTCUseUTC' /> <span class='translate'>Hardware Clock in UTC Time</span></label></td>
- </tr>
- <tr class='vboxSettingsSystemAdvancedOnly'>
- <th></th>
- <td><label><input type='checkbox' class='vboxCheckbox' name='vboxSettingsSystemDisableHostTimeSync' /> <span class='translate'>Disable host time sync</span></label></td>
- </tr>
- <tr class='vboxSettingsSystemAdvancedOnly'>
- <th></th>
- <td><label><input type='checkbox' class='vboxCheckbox' name='vboxSettingsSystemHPET' /> <span class='translate'>HPET (high precision event timer)</span></label></td>
- </tr>
-
-</table>
-</div>
-
-<!-- Processor Tab -->
-<div id='vboxSettingsTabSystemProcessor' title='Processors'>
-<table style='width: 100%'>
- <tr>
- <th style='text-align:right'><span class='translate'>Processor(s):</span></th>
- <td style='width: 100%; white-space: nowrap'>
- <table style='width: 100%'>
- <tr>
- <td style='width: 100%; border: 0px; margin: 0px; padding: 0px;'>
- <div style='margin-top: 4px' id='vboxSettingsSystemProcessor' class='slider'><div class='sliderScale'></div></div>
- </td>
- <td><input type='text' class='vboxText' name='vboxSettingsSystemProcessorValue' size='2' class='sliderValue' /></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 class='vboxSliderMin'>%1 CPU</span></td>
- <td style='text-align: right;'><span class='vboxSliderMax'>%1 CPUs</span></td>
- </tr>
- </table>
- </td>
- <td></td>
- </tr>
- </table>
-
- </td>
- </tr>
- <tr class='vboxRunningEnabled'>
- <th style='text-align:right'><span class='translate'>Execution Cap:</span></th>
- <td style='width: 100%; white-space: nowrap'>
- <table style='width: 100%'>
- <tr class='vboxRunningEnabled'>
- <td style='width: 100%; border: 0px; margin: 0px; padding: 0px;'>
- <div style='margin-top: 4px' id='vboxSettingsSystemProcessorCap' class='slider'><div class='sliderScale'></div></div>
- </td>
- <td><input type='text' class='vboxText vboxRunningEnabled' name='vboxSettingsSystemProcessorCapValue' size='3' class='sliderValue' /></td>
- </tr>
- <tr style='vertical-align: top;' class='vboxRunningEnabled'>
- <td style='border: 0px; margin: 0px; padding: 0px;'>
- <table style='width: 100%; border: 0px; margin: 0px; padding: 0px;'>
- <tr style='vertical-align: top' class='vboxRunningEnabled'>
- <td style='text-align: left;'><span class='vboxSliderMin' title='Min CPU execution cap in %'>%1%</span></td>
- <td style='text-align: right;'><span class='vboxSliderMax' title='Max CPU execution cap in %'>%1%</span></td>
- </tr>
- </table>
- </td>
- <td></td>
- </tr>
- </table>
-
- </td>
- </tr>
-
- <tr id='vboxSettingsSystemPAERow'>
- <th><span class='translate'>Extended Features:</span></th>
- <td><label><input type='checkbox' class='vboxCheckbox' name='vboxSettingsSystemPAE' /> <span class='translate'>Enable PAE/NX</span></label></td>
- </tr>
-</table>
-</div>
-
-<!-- Acceleration Tab -->
-<div id='vboxSettingsTabSystemAcceleration' title='Acceleration'>
-<table>
- <tr>
- <th class='vboxEnablerIgnore'><span class='translate'>Paravirtualization Interface:</span></th>
- <td><select name='vboxSettingsParavirtInterface' class='vboxEnablerIgnore'>
- <option value='None'>None</option>
- <option value='Default'>Default</option>
- <option value='Legacy'>Legacy</option>
- <option value='Minimal'>Minimal</option>
- <option value='HyperV'>HyperV</option>
- <option value='KVM'>KVM</option>
- </select></td>
- <tr>
- <th style='text-align:right' class='vboxEnablerIgnore vboxSettingsAccelRequired'><span class='translate'>Hardware Virtualization:</span></th>
- <td style='width:100%'><label><input type='checkbox' name='settingsSystemVT' class='vboxEnablerCheckbox vboxSettingsAccelRequired'/>
- <span class='translate vboxSettingsAccelRequired'>Enable VT-x/AMD-V</span></label></td>
- </tr>
- <tr>
- <th></th>
- <td><label><input type='checkbox' name='settingsSystemPaging' class='vboxEnablerListen' /> <span class='translate vboxEnablerListen'>Enable Nested Paging</span></label></td>
- </tr>
- <tr class='vboxSettingsSystemAdvancedOnly'>
- <th></th>
- <td><label><input type='checkbox' name='settingsSystemLargePages' class='vboxEnablerListen'/> <span class='translate vboxEnablerListen'>Enable Large Pages</span></label></td>
- </tr>
- <tr class='vboxSettingsSystemAdvancedOnly'>
- <th></th>
- <td><label><input type='checkbox' name='settingsSystemUnrestrictedExecution' class='vboxEnablerListen'/> <span class='translate vboxEnablerListen'>Enable VT-x unrestricted execution</span></label></td>
- </tr>
- <tr class='vboxSettingsSystemAdvancedOnly'>
- <th></th>
- <td><label><input type='checkbox' name='settingsSystemVPID' class='vboxEnablerListen'/> <span class='translate vboxEnablerListen'>Enable VT-x VPID (Intel only)</span></label></td>
- </tr>
-</table>
-</div>
-
-
-<script type='text/javascript'>
-
-/* Boot order devices */
-$('#vboxVMBootOrder').find("span.vboxBootOrderDevice").html(function(i,h){return trans(vboxDevice(h),'VBoxGlobal');});
-
-/* Chipsets */
-$('#vboxSettingsSystemChipsetRow').find('option').html(function(i,h){return trans(h,'VBoxGlobal');});
-
-/* Paravirtualization providers */
-$(document.forms['frmVboxSettings'].vboxSettingsParavirtInterface).find('option').html(function(i,h){return trans(h,'VBoxGlobal', 'ParavirtProvider');});
-
-$('#vboxSettingsSystemMemory').data('form','frmVboxSettings');
-$('#vboxSettingsSystemProcessor').data('form','frmVboxSettings');
-$('#vboxSettingsSystemProcessorCap').data('form','frmVboxSettings');
-$('#vboxSettingsSystemMemory').slider({'min':parseInt($('#vboxPane').data('vboxSystemProperties').minGuestRAM),'max':parseInt($('#vboxSettingsDialog').data('vboxHostDetails').memorySize)});
-$('#vboxSettingsSystemProcessor').slider({'min':1,'max':$('#vboxSettingsDialog').data('vboxHostDetails').cpus.length});
-$('#vboxSettingsSystemProcessorCap').slider({'min':1,'max':100});
-
-
-/* Disable PAE if it is unsupported */
-if(!$('#vboxSettingsDialog').data('vboxHostDetails').cpuFeatures.PAE) {
- $('#vboxSettingsSystemPAERow span').addClass('disabled');
- document.forms['frmVboxSettings'].vboxSettingsSystemPAE.checked = false;
- document.forms['frmVboxSettings'].vboxSettingsSystemPAE.disabled = true;
-}
-
-/* Set CPUs to 1 and disable if host cpu does not support HWVirtEx */
-if(!$('#vboxSettingsDialog').data('vboxHostDetails').cpuFeatures.HWVirtEx) {
- var pt = $('#vboxSettingsSystemProcessor').slider('value',1).slider('disable').closest('table');
- pt.find('span').addClass('disabled');
- pt.find('input').prop('disabled',true);
-}
-
-/** @def VBOX_WITH_PAGE_SHARING
- * Enables the page sharing code.
- * @remarks This must match GMMR0Init; currently we only support page fusion on
- * all 64-bit hosts except Mac OS X */
-if(!$('#vboxSettingsDialog').data('vboxHostDetails').cpuFeatures['Long Mode (64-bit)'] || $('#vboxSettingsDialog').data('vboxHostDetails').operatingSystem.toLowerCase().search("darwin") >-1) {
- $(document.forms['frmVboxSettings'].vboxSettingsSystemPageFusion).prop({'checked':false,'disabled':true}).siblings().addClass('disabled');
-}
-
-
-/*
- *
- * Ordered lists (Boot order)
- *
- */
-
-$("#vboxVMBootOrder").find("input.imgMvUp").click(function() {
-
- var list = $('#vboxVMBootOrderList').children('li');
-
- for(var i = 0; i < list.length; i++ ) {
- if(list[i].className == 'vboxListItemSelected') {
- if(i == 0) return;
- var mv = $(list[i]).detach();
- $(list[(i-1)]).before(mv);
- i = list.length;
- mv.click();
- }
- }
-
-});
-
-$("#vboxVMBootOrder").find("input.imgMvDn").click(function() {
-
- var list = $('#vboxVMBootOrderList').children('li');
-
- for(var i = 0; i < list.length; i++ ) {
-
- if(list[i].className == 'vboxListItemSelected') {
- if(i == (list.length - 1)) return;
- var mv = $(list[i]).detach();
- $(list[(i+1)]).after(mv);
- i = list.length;
- mv.click();
- }
- }
-
-});
-
-// Preload up / down images
-var a = new Image();
-a.src = "images/vbox/list_movedown_16px.png";
-var b = new Image();
-b.src = "images/vbox/list_moveup_16px.png";
-
-
-/* Update values when data is loaded */
-$('#vboxSettingsDialog').on('dataLoaded',function(){
-
- /* System Default values from VM*/
- $('#vboxSettingsSystemMemory').slider('value', parseInt($('#vboxSettingsDialog').data('vboxMachineData').memorySize));
- document.forms['frmVboxSettings'].vboxSettingsSystemIOAPIC.checked = $('#vboxSettingsDialog').data('vboxMachineData').BIOSSettings.IOAPICEnabled;
- document.forms['frmVboxSettings'].vboxSettingsSystemEFI.checked = ($('#vboxSettingsDialog').data('vboxMachineData').firmwareType == 'EFI');
- document.forms['frmVboxSettings'].vboxSettingsSystemRTCUseUTC.checked = ($('#vboxSettingsDialog').data('vboxMachineData').RTCUseUTC);
- $('#vboxSettingsSystemProcessor').slider('value',parseInt($('#vboxSettingsDialog').data('vboxMachineData').CPUCount));
- $('#vboxSettingsSystemProcessorCap').slider('value',parseInt($('#vboxSettingsDialog').data('vboxMachineData').CPUExecutionCap));
- document.forms['frmVboxSettings'].vboxSettingsSystemPAE.checked = ($('#vboxSettingsDialog').data('vboxMachineData').CpuProperties.PAE);
- document.forms['frmVboxSettings'].settingsSystemVT.checked = ($('#vboxSettingsDialog').data('vboxMachineData').HWVirtExProperties.Enabled);
- document.forms['frmVboxSettings'].settingsSystemPaging.checked = ($('#vboxSettingsDialog').data('vboxMachineData').HWVirtExProperties.NestedPaging);
-
- $(document.forms['frmVboxSettings'].vboxSettingsParavirtInterface).val($('#vboxSettingsDialog').data('vboxMachineData').paravirtProvider);
-
- $(document.forms['frmVboxSettings'].settingsSystemVT).triggerHandler('click');
-
-
- /* Only if acceleration config is enabled */
- if($('#vboxPane').data('vboxConfig').enableAdvancedConfig) {
-
- document.forms['frmVboxSettings'].vboxSettingsSystemHPET.checked = ($('#vboxSettingsDialog').data('vboxMachineData').HPETEnabled);
- document.forms['frmVboxSettings'].vboxSettingsSystemDisableHostTimeSync.checked = ($('#vboxSettingsDialog').data('vboxMachineData').disableHostTimeSync);
- document.forms['frmVboxSettings'].settingsSystemLargePages.checked = ($('#vboxSettingsDialog').data('vboxMachineData').HWVirtExProperties.LargePages);
- document.forms['frmVboxSettings'].settingsSystemUnrestrictedExecution.checked = ($('#vboxSettingsDialog').data('vboxMachineData').HWVirtExProperties.UnrestrictedExecution);
- document.forms['frmVboxSettings'].settingsSystemVPID.checked = ($('#vboxSettingsDialog').data('vboxMachineData').HWVirtExProperties.VPID);
- document.forms['frmVboxSettings'].vboxSettingsSystemPageFusion.checked = ($('#vboxSettingsDialog').data('vboxMachineData').pageFusionEnabled);
-
- $('#vboxSettingsTabSystemMotherboard').find('tr.vboxSettingsSystemAdvancedOnly').css('display','');
- $('#vboxSettingsTabSystemAcceleration').find('tr.vboxSettingsSystemAdvancedOnly').css('display','');
-
-
- /* Else, remove advanced settings */
- } else {
- $('#vboxSettingsTabSystemMotherboard').find('tr.vboxSettingsSystemAdvancedOnly').css('display','none');
- $('#vboxSettingsTabSystemAcceleration').find('tr.vboxSettingsSystemAdvancedOnly').css('display','none');
- }
-
- /* Boot Order */
- var bootItems = {};
- var bootList = $('#vboxVMBootOrderList');
- $(bootList).children('li').each(function(){
- bootItems[$(this).attr('id')] = $(this).detach();
- });
- for(var i in $('#vboxSettingsDialog').data('vboxMachineData').bootOrder) {
- if(!isNaN(i)) {
- $(bootList).append(bootItems[$('#vboxSettingsDialog').data('vboxMachineData').bootOrder[i]]);
- document.forms['frmVboxSettings'].elements['vboxSettingsBoot' + $('#vboxSettingsDialog').data('vboxMachineData').bootOrder[i]].checked = true;
- }
- delete bootItems[$('#vboxSettingsDialog').data('vboxMachineData').bootOrder[i]];
- }
- for(var i in bootItems) {
- if(typeof i == 'function') continue;
- $(bootList).append(bootItems[i]);
- delete bootItems[i];
- }
- $(bootList).children().hoverClass('vboxHover');
-
-
-
- /* Hide Chipset selection if we didn't get one, or VirtualBox version is 4.0.0 A safeguard */
- if(!$('#vboxSettingsDialog').data('vboxMachineData').chipsetType) {
- $('#vboxSettingsSystemChipsetRow').css('display','none');
- } else {
- $('#vboxSettingsSystemChipsetRow').css('display','');
- $(document.forms['frmVboxSettings'].vboxSettingsSystemChipset).val($('#vboxSettingsDialog').data('vboxMachineData').chipsetType);
- }
-
-
- // Full editing not enabled
- var p = $('#vboxSettingsTabSystemMotherboard').parent().children('div');
- var t = $('#vboxVMBootOrder');
-
- if(!$('#vboxSettingsDialog').data('vboxFullEdit')) {
-
- $(p).find('tr:not(.vboxRunningEnabled)').find('span').addClass('disabled');
- $(p).find('tr:not(.vboxRunningEnabled)').find('input,select,textarea').prop('disabled',true);
- $('#vboxSettingsSystemMemory').slider('disable');
- $('#vboxSettingsSystemProcessor').slider('disable');
-
- t.find('input.imgMvUp').css('background-image', 'url(images/vbox/list_moveup_disabled_16px.png)');
- t.find('input.imgMvDn').css('background-image', 'url(images/vbox/list_movedown_disabled_16px.png)');
- t.find('img').each(function(){
- $(this).prop('src',$(this).prop('src').replace('_16','_disabled_16'));
- });
-
- $("#vboxVMBootOrderList").children("li").unbind('click');
-
- } else {
-
- $(p).find('tr:not(.vboxRunningEnabled)').find('span').removeClass('disabled');
- $(p).find('tr:not(.vboxRunningEnabled)').find('input,select,textarea').prop('disabled',false);
- $('#vboxSettingsSystemMemory').slider('enable');
- $('#vboxSettingsSystemProcessor').slider('enable');
-
- t.find('input.imgMvUp').css('background-image', 'url(images/vbox/list_moveup_16px.png)');
- t.find('input.imgMvDn').css('background-image', 'url(images/vbox/list_movedown_16px.png)');
- t.find('img').each(function(){
- $(this).prop('src',$(this).prop('src').replace('_disabled_16','_16'));
- });
-
- $("#vboxVMBootOrderList").children("li").click(function() {
-
- // Update class
- $(this).siblings().prop('className','vboxListItem');
- $(this).prop('className','vboxListItemSelected');
-
- var isFirst = ($(this).parent().children().first().attr('id') == $(this).attr('id'));
- var isLast = ($(this).parent().children().last().attr('id') == $(this).attr('id'));
-
- // update buttons
- $(this).closest("table").find('input.imgMvUp').css('background-image', 'url(images/vbox/list_moveup' + (isFirst ? '_disabled' : '') + '_16px.png)').prop('disabled', isFirst);
- $(this).closest("table").find('input.imgMvDn').css('background-image', 'url(images/vbox/list_movedown' + (isLast ? '_disabled' : '') + '_16px.png)').prop('disabled', isLast);
-
- }).first().trigger('click');
-
- }
-
-});
-
-/* Disable non-editable items when VM is running */
-$('#vboxSettingsDialog').one('show',function(){
-
- // Are virtualExtensions supported by the cpu?
- if(!$('#vboxSettingsDialog').data('vboxHostDetails').cpuFeatures.HWVirtEx && !$('#vboxSettingsDialog').data('vboxMachineData').HWVirtExProperties.Enabled) {
-
- $('#vboxSettingsTabSystemAcceleration').find('input.vboxSettingsAccelRequired').prop('disabled', true);
- $('#vboxSettingsTabSystemAcceleration').find('.vboxSettingsAccelRequired').addClass('vboxDisabled');
- }
-
-
-});
-
-
-/* Change general settings onSave() */
-$('#vboxSettingsDialog').on('save',function(){
-
- $('#vboxSettingsDialog').data('vboxMachineData').memorySize = parseInt(document.forms['frmVboxSettings'].vboxSettingsSystemMemoryValue.value);
- $('#vboxSettingsDialog').data('vboxMachineData').BIOSSettings.IOAPICEnabled = document.forms['frmVboxSettings'].vboxSettingsSystemIOAPIC.checked;
- $('#vboxSettingsDialog').data('vboxMachineData').firmwareType = (document.forms['frmVboxSettings'].vboxSettingsSystemEFI.checked ? 'EFI' : 'BIOS');
- $('#vboxSettingsDialog').data('vboxMachineData').CPUCount = parseInt($('#vboxSettingsSystemProcessor').slider('value'));
- $('#vboxSettingsDialog').data('vboxMachineData').CPUExecutionCap = parseInt($('#vboxSettingsSystemProcessorCap').slider('value'));
- $('#vboxSettingsDialog').data('vboxMachineData').CpuProperties.PAE = document.forms['frmVboxSettings'].vboxSettingsSystemPAE.checked;
- $('#vboxSettingsDialog').data('vboxMachineData').RTCUseUTC = document.forms['frmVboxSettings'].vboxSettingsSystemRTCUseUTC.checked;
-
- /* Only if we had a chipset */
- if($('#vboxSettingsDialog').data('vboxMachineData').chipsetType)
- $('#vboxSettingsDialog').data('vboxMachineData').chipsetType = $(document.forms['frmVboxSettings'].vboxSettingsSystemChipset).val();
-
- if($('#vboxSettingsDialog').data('vboxHostDetails').cpuFeatures.HWVirtEx || $('#vboxSettingsDialog').data('vboxMachineData').HWVirtExProperties.Enabled || $('#vboxPane').data('vboxConfig').enableAdvancedConfig) {
- $('#vboxSettingsDialog').data('vboxMachineData').HWVirtExProperties.Enabled = document.forms['frmVboxSettings'].settingsSystemVT.checked;
- $('#vboxSettingsDialog').data('vboxMachineData').HWVirtExProperties.NestedPaging = $('#vboxSettingsDialog').data('vboxMachineData').HWVirtExProperties.Enabled && document.forms['frmVboxSettings'].settingsSystemPaging.checked;
- }
-
- $('#vboxSettingsDialog').data('vboxMachineData').paravirtProvider = $(document.forms['frmVboxSettings'].vboxSettingsParavirtInterface).val();
-
- /* Only if advanced config is enabled */
- if($('#vboxPane').data('vboxConfig').enableAdvancedConfig) {
- $('#vboxSettingsDialog').data('vboxMachineData').pageFusionEnabled = document.forms['frmVboxSettings'].vboxSettingsSystemPageFusion.checked;
- $('#vboxSettingsDialog').data('vboxMachineData').HPETEnabled = document.forms['frmVboxSettings'].vboxSettingsSystemHPET.checked;
- $('#vboxSettingsDialog').data('vboxMachineData').disableHostTimeSync = document.forms['frmVboxSettings'].vboxSettingsSystemDisableHostTimeSync.checked;
- $('#vboxSettingsDialog').data('vboxMachineData').HWVirtExProperties.LargePages = document.forms['frmVboxSettings'].settingsSystemLargePages.checked;
- $('#vboxSettingsDialog').data('vboxMachineData').HWVirtExProperties.UnrestrictedExecution = ($('#vboxSettingsDialog').data('vboxMachineData').HWVirtExProperties.Enabled && document.forms['frmVboxSettings'].settingsSystemUnrestrictedExecution.checked ? true : false);
- $('#vboxSettingsDialog').data('vboxMachineData').HWVirtExProperties.VPID = $('#vboxSettingsDialog').data('vboxMachineData').HWVirtExProperties.Enabled && document.forms['frmVboxSettings'].settingsSystemVPID.checked;
- }
-
- // Boot order
- $('#vboxSettingsDialog').data('vboxMachineData').bootOrder = new Array();
- $('#vboxVMBootOrderList').find('input').each(function(){
- if(!$(this).prop('checked')) return;
- $('#vboxSettingsDialog').data('vboxMachineData').bootOrder[$('#vboxSettingsDialog').data('vboxMachineData').bootOrder.length] = $(this).attr('name').substring(16);
- });
-
-});
-
-
-
-</script>
+<!--
+
+ VM System Settings
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: settingsSystem.html 597 2015-04-20 11:41:28Z imoore76 $
+
+-->
+
+<ul>
+ <li><a href="#vboxSettingsTabSystemMotherboard"><span class='translate'>Motherboard</span></a></li>
+ <li><a href="#vboxSettingsTabSystemProcessor"><span class='translate'>Processor</span></a></li>
+ <li><a href="#vboxSettingsTabSystemAcceleration"><span class='translate'>Acceleration</span></a></li>
+</ul>
+
+<!-- Motherboard Tab -->
+<div id='vboxSettingsTabSystemMotherboard' title='Motherboard'>
+<table style='width: 100%'>
+ <tr>
+ <th style='text-align:right'><span class='translate'>Base Memory:</span></th>
+ <td style='width: 100%; white-space: nowrap'>
+ <table style='width: 100%'>
+ <tr>
+ <td style='width: 100%; border: 0px; margin: 0px; padding: 0px;'>
+ <div style='margin-top: 4px' id='vboxSettingsSystemMemory' class='slider'><div class='sliderScale'></div></div>
+ </td>
+ <td><input type='text' class='vboxText sliderValue' name='vboxSettingsSystemMemoryValue' size='5' /> <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 class='vboxSliderMin'>%1 MB</span></td>
+ <td style='text-align: right;'><span class='vboxSliderMax'>%1 MB</span></td>
+ </tr>
+ </table>
+ </td>
+ <td></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr class='vboxSettingsSystemAdvancedOnly'>
+ <th></th>
+ <td><label><input type='checkbox' class='vboxCheckbox' name='vboxSettingsSystemPageFusion' /> <span class='translate'>Enable Page Fusion</span></label></td>
+ </tr>
+ <tr style='vertical-align: top'>
+ <th style='text-align:right'><span class='translate'>Boot Order:</span></th>
+ <td>
+ <table id='vboxVMBootOrder'>
+ <tr style='vertical-align: top'>
+ <td style='width: auto'>
+ <ul class='vboxList vboxHover vboxBordered' id='vboxVMBootOrderList' style='margin: 0px; padding: 2px; white-space: nowrap; width: 200px'>
+ <li id='HardDisk'><input type='checkbox' class='vboxCheckbox' name='vboxSettingsBootHardDisk' /> <img src="images/vbox/hd_16px.png" /> <span class='vboxBootOrderDevice'>HardDisk</span></li>
+ <li id='DVD'><input type='checkbox' class='vboxCheckbox' name='vboxSettingsBootDVD' /> <img src="images/vbox/cd_16px.png" /> <span class='vboxBootOrderDevice'>DVD</span></li>
+ <li id='Floppy'><input type='checkbox' class='vboxCheckbox' name='vboxSettingsBootFloppy' /> <img src="images/vbox/fd_16px.png" /> <span class='vboxBootOrderDevice'>Floppy</span></li>
+ <li id='Network'><input type='checkbox' class='vboxCheckbox' name='vboxSettingsBootNetwork' /> <img src="images/vbox/nw_16px.png" /> <span class='vboxBootOrderDevice'>Network</span></li>
+ </ul>
+ </td>
+ <td style='text-align: left; width: 100%'>
+ <input disabled='disabled' class="imgMvUp vboxImgButton" style='background: url(images/vbox/list_moveup_disabled_16px.png) 1px 1px no-repeat; width: 18px; height: 18px; vertical-align:bottom' type="button" value="" />
+ <br />
+ <input disabled='disabled' class="imgMvDn vboxImgButton" style='background: url(images/vbox/list_movedown_disabled_16px.png) 1px 1px no-repeat; width: 18px; height: 18px; vertical-align:bottom' type="button" value="" />
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr id='vboxSettingsSystemChipsetRow'>
+ <th style='text-align:right'><span class='translate'>Chipset:</span></th>
+ <td><select name='vboxSettingsSystemChipset'>
+ <option value='PIIX3'>PIIX3</option>
+ <option value='ICH9'>ICH9</option>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <th style='text-align:right'><span class='translate'>Extended Features:</span></th>
+ <td><label><input type='checkbox' class='vboxCheckbox' name='vboxSettingsSystemIOAPIC' /> <span class='translate'>Enable I/O APIC</span></label></td>
+ </tr>
+ <tr>
+ <th></th>
+ <td><label><input type='checkbox' class='vboxCheckbox' name='vboxSettingsSystemEFI' /> <span class='translate'>Enable EFI (special OSes only)</span></label></td>
+ </tr>
+ <tr>
+ <th></th>
+ <td><label><input type='checkbox' class='vboxCheckbox' name='vboxSettingsSystemRTCUseUTC' /> <span class='translate'>Hardware Clock in UTC Time</span></label></td>
+ </tr>
+ <tr class='vboxSettingsSystemAdvancedOnly'>
+ <th></th>
+ <td><label><input type='checkbox' class='vboxCheckbox' name='vboxSettingsSystemDisableHostTimeSync' /> <span class='translate'>Disable host time sync</span></label></td>
+ </tr>
+ <tr class='vboxSettingsSystemAdvancedOnly'>
+ <th></th>
+ <td><label><input type='checkbox' class='vboxCheckbox' name='vboxSettingsSystemHPET' /> <span class='translate'>HPET (high precision event timer)</span></label></td>
+ </tr>
+
+</table>
+</div>
+
+<!-- Processor Tab -->
+<div id='vboxSettingsTabSystemProcessor' title='Processors'>
+<table style='width: 100%'>
+ <tr>
+ <th style='text-align:right'><span class='translate'>Processor(s):</span></th>
+ <td style='width: 100%; white-space: nowrap'>
+ <table style='width: 100%'>
+ <tr>
+ <td style='width: 100%; border: 0px; margin: 0px; padding: 0px;'>
+ <div style='margin-top: 4px' id='vboxSettingsSystemProcessor' class='slider'><div class='sliderScale'></div></div>
+ </td>
+ <td><input type='text' class='vboxText' name='vboxSettingsSystemProcessorValue' size='2' class='sliderValue' /></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 class='vboxSliderMin'>%1 CPU</span></td>
+ <td style='text-align: right;'><span class='vboxSliderMax'>%1 CPUs</span></td>
+ </tr>
+ </table>
+ </td>
+ <td></td>
+ </tr>
+ </table>
+
+ </td>
+ </tr>
+ <tr class='vboxRunningEnabled'>
+ <th style='text-align:right'><span class='translate'>Execution Cap:</span></th>
+ <td style='width: 100%; white-space: nowrap'>
+ <table style='width: 100%'>
+ <tr class='vboxRunningEnabled'>
+ <td style='width: 100%; border: 0px; margin: 0px; padding: 0px;'>
+ <div style='margin-top: 4px' id='vboxSettingsSystemProcessorCap' class='slider'><div class='sliderScale'></div></div>
+ </td>
+ <td><input type='text' class='vboxText vboxRunningEnabled' name='vboxSettingsSystemProcessorCapValue' size='3' class='sliderValue' /></td>
+ </tr>
+ <tr style='vertical-align: top;' class='vboxRunningEnabled'>
+ <td style='border: 0px; margin: 0px; padding: 0px;'>
+ <table style='width: 100%; border: 0px; margin: 0px; padding: 0px;'>
+ <tr style='vertical-align: top' class='vboxRunningEnabled'>
+ <td style='text-align: left;'><span class='vboxSliderMin' title='Min CPU execution cap in %'>%1%</span></td>
+ <td style='text-align: right;'><span class='vboxSliderMax' title='Max CPU execution cap in %'>%1%</span></td>
+ </tr>
+ </table>
+ </td>
+ <td></td>
+ </tr>
+ </table>
+
+ </td>
+ </tr>
+
+ <tr id='vboxSettingsSystemPAERow'>
+ <th><span class='translate'>Extended Features:</span></th>
+ <td><label><input type='checkbox' class='vboxCheckbox' name='vboxSettingsSystemPAE' /> <span class='translate'>Enable PAE/NX</span></label></td>
+ </tr>
+</table>
+</div>
+
+<!-- Acceleration Tab -->
+<div id='vboxSettingsTabSystemAcceleration' title='Acceleration'>
+<table>
+ <tr>
+ <th class='vboxEnablerIgnore'><span class='translate'>Paravirtualization Interface:</span></th>
+ <td><select name='vboxSettingsParavirtInterface' class='vboxEnablerIgnore'>
+ <option value='None'>None</option>
+ <option value='Default'>Default</option>
+ <option value='Legacy'>Legacy</option>
+ <option value='Minimal'>Minimal</option>
+ <option value='HyperV'>HyperV</option>
+ <option value='KVM'>KVM</option>
+ </select></td>
+ <tr>
+ <th style='text-align:right' class='vboxEnablerIgnore vboxSettingsAccelRequired'><span class='translate'>Hardware Virtualization:</span></th>
+ <td style='width:100%'><label><input type='checkbox' name='settingsSystemVT' class='vboxEnablerCheckbox vboxSettingsAccelRequired'/>
+ <span class='translate vboxSettingsAccelRequired'>Enable VT-x/AMD-V</span></label></td>
+ </tr>
+ <tr>
+ <th></th>
+ <td><label><input type='checkbox' name='settingsSystemPaging' class='vboxEnablerListen' /> <span class='translate vboxEnablerListen'>Enable Nested Paging</span></label></td>
+ </tr>
+ <tr class='vboxSettingsSystemAdvancedOnly'>
+ <th></th>
+ <td><label><input type='checkbox' name='settingsSystemLargePages' class='vboxEnablerListen'/> <span class='translate vboxEnablerListen'>Enable Large Pages</span></label></td>
+ </tr>
+ <tr class='vboxSettingsSystemAdvancedOnly'>
+ <th></th>
+ <td><label><input type='checkbox' name='settingsSystemUnrestrictedExecution' class='vboxEnablerListen'/> <span class='translate vboxEnablerListen'>Enable VT-x unrestricted execution</span></label></td>
+ </tr>
+ <tr class='vboxSettingsSystemAdvancedOnly'>
+ <th></th>
+ <td><label><input type='checkbox' name='settingsSystemVPID' class='vboxEnablerListen'/> <span class='translate vboxEnablerListen'>Enable VT-x VPID (Intel only)</span></label></td>
+ </tr>
+</table>
+</div>
+
+
+<script type='text/javascript'>
+
+/* Boot order devices */
+$('#vboxVMBootOrder').find("span.vboxBootOrderDevice").html(function(i,h){return trans(vboxDevice(h),'VBoxGlobal');});
+
+/* Chipsets */
+$('#vboxSettingsSystemChipsetRow').find('option').html(function(i,h){return trans(h,'VBoxGlobal');});
+
+/* Paravirtualization providers */
+$(document.forms['frmVboxSettings'].vboxSettingsParavirtInterface).find('option').html(function(i,h){return trans(h,'VBoxGlobal', 'ParavirtProvider');});
+
+$('#vboxSettingsSystemMemory').data('form','frmVboxSettings');
+$('#vboxSettingsSystemProcessor').data('form','frmVboxSettings');
+$('#vboxSettingsSystemProcessorCap').data('form','frmVboxSettings');
+$('#vboxSettingsSystemMemory').slider({'min':parseInt($('#vboxPane').data('vboxSystemProperties').minGuestRAM),'max':parseInt($('#vboxSettingsDialog').data('vboxHostDetails').memorySize)});
+$('#vboxSettingsSystemProcessor').slider({'min':1,'max':$('#vboxSettingsDialog').data('vboxHostDetails').cpus.length});
+$('#vboxSettingsSystemProcessorCap').slider({'min':1,'max':100});
+
+
+/* Disable PAE if it is unsupported */
+if(!$('#vboxSettingsDialog').data('vboxHostDetails').cpuFeatures.PAE) {
+ $('#vboxSettingsSystemPAERow span').addClass('disabled');
+ document.forms['frmVboxSettings'].vboxSettingsSystemPAE.checked = false;
+ document.forms['frmVboxSettings'].vboxSettingsSystemPAE.disabled = true;
+}
+
+/* Set CPUs to 1 and disable if host cpu does not support HWVirtEx */
+if(!$('#vboxSettingsDialog').data('vboxHostDetails').cpuFeatures.HWVirtEx) {
+ var pt = $('#vboxSettingsSystemProcessor').slider('value',1).slider('disable').closest('table');
+ pt.find('span').addClass('disabled');
+ pt.find('input').prop('disabled',true);
+}
+
+/** @def VBOX_WITH_PAGE_SHARING
+ * Enables the page sharing code.
+ * @remarks This must match GMMR0Init; currently we only support page fusion on
+ * all 64-bit hosts except Mac OS X */
+if(!$('#vboxSettingsDialog').data('vboxHostDetails').cpuFeatures['Long Mode (64-bit)'] || $('#vboxSettingsDialog').data('vboxHostDetails').operatingSystem.toLowerCase().search("darwin") >-1) {
+ $(document.forms['frmVboxSettings'].vboxSettingsSystemPageFusion).prop({'checked':false,'disabled':true}).siblings().addClass('disabled');
+}
+
+
+/*
+ *
+ * Ordered lists (Boot order)
+ *
+ */
+
+$("#vboxVMBootOrder").find("input.imgMvUp").click(function() {
+
+ var list = $('#vboxVMBootOrderList').children('li');
+
+ for(var i = 0; i < list.length; i++ ) {
+ if(list[i].className == 'vboxListItemSelected') {
+ if(i == 0) return;
+ var mv = $(list[i]).detach();
+ $(list[(i-1)]).before(mv);
+ i = list.length;
+ mv.click();
+ }
+ }
+
+});
+
+$("#vboxVMBootOrder").find("input.imgMvDn").click(function() {
+
+ var list = $('#vboxVMBootOrderList').children('li');
+
+ for(var i = 0; i < list.length; i++ ) {
+
+ if(list[i].className == 'vboxListItemSelected') {
+ if(i == (list.length - 1)) return;
+ var mv = $(list[i]).detach();
+ $(list[(i+1)]).after(mv);
+ i = list.length;
+ mv.click();
+ }
+ }
+
+});
+
+// Preload up / down images
+var a = new Image();
+a.src = "images/vbox/list_movedown_16px.png";
+var b = new Image();
+b.src = "images/vbox/list_moveup_16px.png";
+
+
+/* Update values when data is loaded */
+$('#vboxSettingsDialog').on('dataLoaded',function(){
+
+ /* System Default values from VM*/
+ $('#vboxSettingsSystemMemory').slider('value', parseInt($('#vboxSettingsDialog').data('vboxMachineData').memorySize));
+ document.forms['frmVboxSettings'].vboxSettingsSystemIOAPIC.checked = $('#vboxSettingsDialog').data('vboxMachineData').BIOSSettings.IOAPICEnabled;
+ document.forms['frmVboxSettings'].vboxSettingsSystemEFI.checked = ($('#vboxSettingsDialog').data('vboxMachineData').firmwareType == 'EFI');
+ document.forms['frmVboxSettings'].vboxSettingsSystemRTCUseUTC.checked = ($('#vboxSettingsDialog').data('vboxMachineData').RTCUseUTC);
+ $('#vboxSettingsSystemProcessor').slider('value',parseInt($('#vboxSettingsDialog').data('vboxMachineData').CPUCount));
+ $('#vboxSettingsSystemProcessorCap').slider('value',parseInt($('#vboxSettingsDialog').data('vboxMachineData').CPUExecutionCap));
+ document.forms['frmVboxSettings'].vboxSettingsSystemPAE.checked = ($('#vboxSettingsDialog').data('vboxMachineData').CpuProperties.PAE);
+ document.forms['frmVboxSettings'].settingsSystemVT.checked = ($('#vboxSettingsDialog').data('vboxMachineData').HWVirtExProperties.Enabled);
+ document.forms['frmVboxSettings'].settingsSystemPaging.checked = ($('#vboxSettingsDialog').data('vboxMachineData').HWVirtExProperties.NestedPaging);
+
+ $(document.forms['frmVboxSettings'].vboxSettingsParavirtInterface).val($('#vboxSettingsDialog').data('vboxMachineData').paravirtProvider);
+
+ $(document.forms['frmVboxSettings'].settingsSystemVT).triggerHandler('click');
+
+
+ /* Only if acceleration config is enabled */
+ if($('#vboxPane').data('vboxConfig').enableAdvancedConfig) {
+
+ document.forms['frmVboxSettings'].vboxSettingsSystemHPET.checked = ($('#vboxSettingsDialog').data('vboxMachineData').HPETEnabled);
+ document.forms['frmVboxSettings'].vboxSettingsSystemDisableHostTimeSync.checked = ($('#vboxSettingsDialog').data('vboxMachineData').disableHostTimeSync);
+ document.forms['frmVboxSettings'].settingsSystemLargePages.checked = ($('#vboxSettingsDialog').data('vboxMachineData').HWVirtExProperties.LargePages);
+ document.forms['frmVboxSettings'].settingsSystemUnrestrictedExecution.checked = ($('#vboxSettingsDialog').data('vboxMachineData').HWVirtExProperties.UnrestrictedExecution);
+ document.forms['frmVboxSettings'].settingsSystemVPID.checked = ($('#vboxSettingsDialog').data('vboxMachineData').HWVirtExProperties.VPID);
+ document.forms['frmVboxSettings'].vboxSettingsSystemPageFusion.checked = ($('#vboxSettingsDialog').data('vboxMachineData').pageFusionEnabled);
+
+ $('#vboxSettingsTabSystemMotherboard').find('tr.vboxSettingsSystemAdvancedOnly').css('display','');
+ $('#vboxSettingsTabSystemAcceleration').find('tr.vboxSettingsSystemAdvancedOnly').css('display','');
+
+
+ /* Else, remove advanced settings */
+ } else {
+ $('#vboxSettingsTabSystemMotherboard').find('tr.vboxSettingsSystemAdvancedOnly').css('display','none');
+ $('#vboxSettingsTabSystemAcceleration').find('tr.vboxSettingsSystemAdvancedOnly').css('display','none');
+ }
+
+ /* Boot Order */
+ var bootItems = {};
+ var bootList = $('#vboxVMBootOrderList');
+ $(bootList).children('li').each(function(){
+ bootItems[$(this).attr('id')] = $(this).detach();
+ });
+ for(var i in $('#vboxSettingsDialog').data('vboxMachineData').bootOrder) {
+ if(!isNaN(i)) {
+ $(bootList).append(bootItems[$('#vboxSettingsDialog').data('vboxMachineData').bootOrder[i]]);
+ document.forms['frmVboxSettings'].elements['vboxSettingsBoot' + $('#vboxSettingsDialog').data('vboxMachineData').bootOrder[i]].checked = true;
+ }
+ delete bootItems[$('#vboxSettingsDialog').data('vboxMachineData').bootOrder[i]];
+ }
+ for(var i in bootItems) {
+ if(typeof i == 'function') continue;
+ $(bootList).append(bootItems[i]);
+ delete bootItems[i];
+ }
+ $(bootList).children().hoverClass('vboxHover');
+
+
+
+ /* Hide Chipset selection if we didn't get one, or VirtualBox version is 4.0.0 A safeguard */
+ if(!$('#vboxSettingsDialog').data('vboxMachineData').chipsetType) {
+ $('#vboxSettingsSystemChipsetRow').css('display','none');
+ } else {
+ $('#vboxSettingsSystemChipsetRow').css('display','');
+ $(document.forms['frmVboxSettings'].vboxSettingsSystemChipset).val($('#vboxSettingsDialog').data('vboxMachineData').chipsetType);
+ }
+
+
+ // Full editing not enabled
+ var p = $('#vboxSettingsTabSystemMotherboard').parent().children('div');
+ var t = $('#vboxVMBootOrder');
+
+ if(!$('#vboxSettingsDialog').data('vboxFullEdit')) {
+
+ $(p).find('tr:not(.vboxRunningEnabled)').find('span').addClass('disabled');
+ $(p).find('tr:not(.vboxRunningEnabled)').find('input,select,textarea').prop('disabled',true);
+ $('#vboxSettingsSystemMemory').slider('disable');
+ $('#vboxSettingsSystemProcessor').slider('disable');
+
+ t.find('input.imgMvUp').css('background-image', 'url(images/vbox/list_moveup_disabled_16px.png)');
+ t.find('input.imgMvDn').css('background-image', 'url(images/vbox/list_movedown_disabled_16px.png)');
+ t.find('img').each(function(){
+ $(this).prop('src',$(this).prop('src').replace('_16','_disabled_16'));
+ });
+
+ $("#vboxVMBootOrderList").children("li").unbind('click');
+
+ } else {
+
+ $(p).find('tr:not(.vboxRunningEnabled)').find('span').removeClass('disabled');
+ $(p).find('tr:not(.vboxRunningEnabled)').find('input,select,textarea').prop('disabled',false);
+ $('#vboxSettingsSystemMemory').slider('enable');
+ $('#vboxSettingsSystemProcessor').slider('enable');
+
+ t.find('input.imgMvUp').css('background-image', 'url(images/vbox/list_moveup_16px.png)');
+ t.find('input.imgMvDn').css('background-image', 'url(images/vbox/list_movedown_16px.png)');
+ t.find('img').each(function(){
+ $(this).prop('src',$(this).prop('src').replace('_disabled_16','_16'));
+ });
+
+ $("#vboxVMBootOrderList").children("li").click(function() {
+
+ // Update class
+ $(this).siblings().prop('className','vboxListItem');
+ $(this).prop('className','vboxListItemSelected');
+
+ var isFirst = ($(this).parent().children().first().attr('id') == $(this).attr('id'));
+ var isLast = ($(this).parent().children().last().attr('id') == $(this).attr('id'));
+
+ // update buttons
+ $(this).closest("table").find('input.imgMvUp').css('background-image', 'url(images/vbox/list_moveup' + (isFirst ? '_disabled' : '') + '_16px.png)').prop('disabled', isFirst);
+ $(this).closest("table").find('input.imgMvDn').css('background-image', 'url(images/vbox/list_movedown' + (isLast ? '_disabled' : '') + '_16px.png)').prop('disabled', isLast);
+
+ }).first().trigger('click');
+
+ }
+
+});
+
+/* Disable non-editable items when VM is running */
+$('#vboxSettingsDialog').one('show',function(){
+
+ // Are virtualExtensions supported by the cpu?
+ if(!$('#vboxSettingsDialog').data('vboxHostDetails').cpuFeatures.HWVirtEx && !$('#vboxSettingsDialog').data('vboxMachineData').HWVirtExProperties.Enabled) {
+
+ $('#vboxSettingsTabSystemAcceleration').find('input.vboxSettingsAccelRequired').prop('disabled', true);
+ $('#vboxSettingsTabSystemAcceleration').find('.vboxSettingsAccelRequired').addClass('vboxDisabled');
+ }
+
+
+});
+
+
+/* Change general settings onSave() */
+$('#vboxSettingsDialog').on('save',function(){
+
+ $('#vboxSettingsDialog').data('vboxMachineData').memorySize = parseInt(document.forms['frmVboxSettings'].vboxSettingsSystemMemoryValue.value);
+ $('#vboxSettingsDialog').data('vboxMachineData').BIOSSettings.IOAPICEnabled = document.forms['frmVboxSettings'].vboxSettingsSystemIOAPIC.checked;
+ $('#vboxSettingsDialog').data('vboxMachineData').firmwareType = (document.forms['frmVboxSettings'].vboxSettingsSystemEFI.checked ? 'EFI' : 'BIOS');
+ $('#vboxSettingsDialog').data('vboxMachineData').CPUCount = parseInt($('#vboxSettingsSystemProcessor').slider('value'));
+ $('#vboxSettingsDialog').data('vboxMachineData').CPUExecutionCap = parseInt($('#vboxSettingsSystemProcessorCap').slider('value'));
+ $('#vboxSettingsDialog').data('vboxMachineData').CpuProperties.PAE = document.forms['frmVboxSettings'].vboxSettingsSystemPAE.checked;
+ $('#vboxSettingsDialog').data('vboxMachineData').RTCUseUTC = document.forms['frmVboxSettings'].vboxSettingsSystemRTCUseUTC.checked;
+
+ /* Only if we had a chipset */
+ if($('#vboxSettingsDialog').data('vboxMachineData').chipsetType)
+ $('#vboxSettingsDialog').data('vboxMachineData').chipsetType = $(document.forms['frmVboxSettings'].vboxSettingsSystemChipset).val();
+
+ if($('#vboxSettingsDialog').data('vboxHostDetails').cpuFeatures.HWVirtEx || $('#vboxSettingsDialog').data('vboxMachineData').HWVirtExProperties.Enabled || $('#vboxPane').data('vboxConfig').enableAdvancedConfig) {
+ $('#vboxSettingsDialog').data('vboxMachineData').HWVirtExProperties.Enabled = document.forms['frmVboxSettings'].settingsSystemVT.checked;
+ $('#vboxSettingsDialog').data('vboxMachineData').HWVirtExProperties.NestedPaging = $('#vboxSettingsDialog').data('vboxMachineData').HWVirtExProperties.Enabled && document.forms['frmVboxSettings'].settingsSystemPaging.checked;
+ }
+
+ $('#vboxSettingsDialog').data('vboxMachineData').paravirtProvider = $(document.forms['frmVboxSettings'].vboxSettingsParavirtInterface).val();
+
+ /* Only if advanced config is enabled */
+ if($('#vboxPane').data('vboxConfig').enableAdvancedConfig) {
+ $('#vboxSettingsDialog').data('vboxMachineData').pageFusionEnabled = document.forms['frmVboxSettings'].vboxSettingsSystemPageFusion.checked;
+ $('#vboxSettingsDialog').data('vboxMachineData').HPETEnabled = document.forms['frmVboxSettings'].vboxSettingsSystemHPET.checked;
+ $('#vboxSettingsDialog').data('vboxMachineData').disableHostTimeSync = document.forms['frmVboxSettings'].vboxSettingsSystemDisableHostTimeSync.checked;
+ $('#vboxSettingsDialog').data('vboxMachineData').HWVirtExProperties.LargePages = document.forms['frmVboxSettings'].settingsSystemLargePages.checked;
+ $('#vboxSettingsDialog').data('vboxMachineData').HWVirtExProperties.UnrestrictedExecution = ($('#vboxSettingsDialog').data('vboxMachineData').HWVirtExProperties.Enabled && document.forms['frmVboxSettings'].settingsSystemUnrestrictedExecution.checked ? true : false);
+ $('#vboxSettingsDialog').data('vboxMachineData').HWVirtExProperties.VPID = $('#vboxSettingsDialog').data('vboxMachineData').HWVirtExProperties.Enabled && document.forms['frmVboxSettings'].settingsSystemVPID.checked;
+ }
+
+ // Boot order
+ $('#vboxSettingsDialog').data('vboxMachineData').bootOrder = new Array();
+ $('#vboxVMBootOrderList').find('input').each(function(){
+ if(!$(this).prop('checked')) return;
+ $('#vboxSettingsDialog').data('vboxMachineData').bootOrder[$('#vboxSettingsDialog').data('vboxMachineData').bootOrder.length] = $(this).attr('name').substring(16);
+ });
+
+});
+
+
+
+</script>
diff --git a/panes/settingsUSB.html b/panes/settingsUSB.html
index a00c495..330d461 100644
--- a/panes/settingsUSB.html
+++ b/panes/settingsUSB.html
@@ -1,414 +1,414 @@
-<!--
-
- USB port settings
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: settingsUSB.html 597 2015-04-20 11:41:28Z imoore76 $
-
- -->
-<table id='vboxSettingsUSBTable' style='width: 100%'>
- <tr>
- <td><label><input type='checkbox' class='vboxCheckbox vboxEnablerCheckbox' name='vboxSettingsUSBEnabled' /> <span class='translate'>Enable USB Controller</span></label></td>
- </tr>
- <tr>
- <td style='width: 100%; padding-left: 20px;'><label><input type='radio' class='vboxCheckbox' name='vboxSettingsUSBControllerType' value='OHCI'/> <span class='translate vboxEnablerListen'>USB 1.1 (OHCI) Controller</span></label></td>
- </tr>
- <tr>
- <td style='width: 100%; padding-left: 20px;'><label><input type='radio' class='vboxCheckbox' name='vboxSettingsUSBControllerType' value='EHCI'/> <span class='translate vboxEnablerListen'>USB 2.0 (EHCI) Controller</span></label></td>
- </tr>
- <tr>
- <td style='width: 100%; padding-left: 20px;'><label><input type='radio' class='vboxCheckbox' name='vboxSettingsUSBControllerType' value='XHCI'/> <span class='translate vboxEnablerListen'>USB 3.0 (xHCI) Controller</span></label></td>
- </tr>
- <tr style='vertical-align: middle' class='vboxRunningEnabled'>
- <td style='width: 100%; padding-left: 20px;'>
- <table class='vboxSettingsHeadingLine' style='width:100%;border-spacing:0;border:0px;margin:0px;padding:0px;'><tr style='vertical-align:middle' class='vboxRunningEnabled'><td style='white-space: nowrap; width: auto'><span class='translate vboxEnablerListen'>USB Device Filters</span></td><td style='width: 100%'><hr style='width: 100%;' class='vboxSeparatorLine'/></td></tr></table>
- </td>
- </tr>
- <tr class='vboxRunningEnabled'>
- <td style='width: 100%; padding-left: 20px;'>
- <table style='width: 100%'>
- <tr class='vboxRunningEnabled'>
- <td id='vboxSettingsUSBFilters' style='width: 100%;' class='vboxBordered vboxEnablerListen'>
- <!-- Hidden div for context menu -->
- <div id='vboxSettingsUSBAddDeviceClick' style='display: none' />
- <ul id='vboxSettingsUSBFilterList' class='vboxList vboxHover' style='width: 100%'>
- <li class='vboxListItem'><input type='checkbox' class='vboxCheckbox' />a</li>
- </ul>
- </td>
- <td id='vboxSettingsUSBButtons' class='vboxEnablerListen'></td>
- </tr>
- </table>
- </td>
- </tr>
-
-</table>
-<script type='text/javascript'>
-
-/*
- * USB Buttons and Toolbar
- */
-
-//Translations
- $('#vboxSettingsTabPortsUSB').find(".translate").html(function(i,h){return trans($('<div />').html(h).text(),'UIMachineSettingsUSB');}).removeClass('translate');
-
-
- var sButtons = new Array(
-
- {
- 'name' : 'usbnew',
- 'label' : 'Add Empty Filter',
- 'icon' : 'usb_new',
- 'click' : function () {
- var list = $('#vboxSettingsUSBFilterList');
- var currUsbName = 1;
- for(; currUsbName < 99; currUsbName++) {
- if(!$(list).find('span.vboxSettingsUSBFilterTitle').filter(function(){
- return ($(this).text() == trans('New Filter %1','UIMachineSettingsUSB').replace('%1',currUsbName));
- }).length) break;
- }
-
- vboxSettingsAddUSBFilter({'active':1,'name':trans('New Filter %1','UIMachineSettingsUSB').replace('%1',currUsbName)});
-
- if(!$('#vboxSettingsUSBFilterList').find('.vboxListItemSelected').first().trigger('click').html()) {
- $('#vboxSettingsUSBFilterList').trigger('select',null); }
- }
- },
-
- {
- 'name' : 'usbnewdevice',
- 'label' : 'Add Filter From Device',
- 'icon' : 'usb_add',
- 'click' : function (e) {
-
- // Update menu
- var menu = $("#vboxSettingsUSBAddDevice");
-
- menu.children().remove();
- menu.append($('<li />').html('<span><img src="images/jqueryFileTree/spinner.gif" /></span>').css({'width':'100px','text-align':'center'}));
-
- var l = new vboxLoader();
- l.add('hostGetUSBDevices',function(res){
-
- var hostUSB = res.responseData;
-
- $(menu).children().remove();
- for(var i = 0; i < hostUSB.length; i++) {
-
- var dname = '';
- if(!hostUSB[i].product)
- dname = trans('Unknown device %1:%2','VBoxGlobal').replace('%1',hostUSB[i].vendorId).replace('%2',hostUSB[i].productId);
- else
- dname = hostUSB[i].manufacturer + ' ' + hostUSB[i].product;
- dname += ' [' + hostUSB[i].revision + ']';
-
- $(menu).append($('<li />').append($('<a />').attr({'href':'#usbDev'+i}).html(dname).data({'device':hostUSB[i]})));
- }
-
- // No devices?
- if(hostUSB.length == 0) {
- $(menu).append($('<li />').append($('<a />').attr({'href':'#usbNoop'}).html($('<div />').text(trans('<no devices available>','VBoxUSBMenu')).html()).data({'device':hostUSB[i]})));
- }
- $(menu).trigger('menuLoaded');
-
- vboxPositionToWindow(menu);
-
- },{});
- l.noLoadingScreen = true;
- l.run();
-
- // Trigger mouse up / down on hidden element
-
- var md = jQuery.Event("mousedown");
- var mu = jQuery.Event("mouseup");
- for(var i in e) { (md[i] ? null : md[i] = mu[i] = e[i]); }
- // Fix mouse button for MSIE
- if(jQuery.browser.msie && e.button == 0) md.button = mu.button = 1;
-
-
- $("#vboxSettingsUSBAddDeviceClick").trigger(md).trigger(mu);
- }
- },
-
- {
- 'name' : 'usbedit',
- 'label' : 'Edit Filter',
- 'icon' : 'usb_filter_edit',
- 'enabled' : function (item) { return (item && $(item).data('filter') && $(item).data('filter').name); },
- 'click' : function () {
-
- var d = $('<div />').attr({'id':'vboxSettingsUSBFilterEdit','style':'display: none','class':'vboxNonTabbed vboxDialogContent'});
-
- var tbl = $('<table />').attr({'style':'width: 100%','class':'vboxSettingsTable'});
-
- var vboxSettingsUSBFilterProps = [
- ['Name','name'],['Vendor ID','vendorId'],['Product ID','productId'],
- ['Revision','revision'],['Manufacturer','manufacturer'],['Product','product'],
- ['Serial No.','serialNumber'],['Port','port']];
-
- /* Get Defaults */
- var filter = $('#vboxSettingsUSBFilterList').find('li.vboxListItemSelected').first().data('filter');
-
- for(var i = 0; i < vboxSettingsUSBFilterProps.length; i++) {
-
- var val = (filter[vboxSettingsUSBFilterProps[i][1]]||'');
- $('<tr />').append($('<th />').attr({'style':'white-space: nowrap; width: auto; text-align: right;'}).html(trans(vboxSettingsUSBFilterProps[i][0]+':','UIMachineSettingsUSBFilterDetails'))).append($('<td />').attr({'style':'width: 100%'}).html('<input type="text" class="vboxText" style="width: 100%" id="vboxSettingsUSBF'+vboxSettingsUSBFilterProps[i][1]+'" value="'+$('<div />').text((filter[vboxSettingsUSBFilterProps[i][1]]||'')).html()+'"/>')).appendTo(tbl);
- }
-
- // Generate select box
- var sel = $('<select />').attr({'id':'vboxSettingsUSBFRemote'});
- var opts = [['',trans('Any','UIMachineSettingsUSBFilterDetails')],['yes',trans('Yes','UIMachineSettingsUSBFilterDetails')],['no',trans('No','UIMachineSettingsUSBFilterDetails')]];
- for(var i = 0; i < opts.length; i++) {
- var o = new Option(opts[i][1],opts[i][0],((filter['remote']||'')==opts[i][0]));
- $(sel).prop('options').add(o);
- }
-
- $('<tr />').append($('<th />').attr({'style':'white-space: nowrap; width: auto; text-align: right;'}).html(trans('Remote:','UIMachineSettingsUSBFilterDetails'))).append($('<td />').attr({'style':'width: 100%'}).append(sel)).appendTo(tbl);
-
- $(d).append(tbl).appendTo($('#vboxPane'));
-
- var buttons = { };
- buttons[trans('OK','QIMessageBox')] = function() {
-
- var item = $('#vboxSettingsUSBFilterList').find('.vboxListItemSelected').first();
-
- for(var i = 0; i < vboxSettingsUSBFilterProps.length; i++) {
- $(item).data('filter')[vboxSettingsUSBFilterProps[i][1]] = $('#vboxSettingsUSBF'+(vboxSettingsUSBFilterProps[i][1])).val();
- }
- $(item).data('filter').remote = ($('#vboxSettingsUSBFRemote').val()||'');
- // Change display name
- $(item).find('span.vboxSettingsUSBFilterTitle').first().text($(item).data('filter').name);
- $('#vboxSettingsUSBFilterEdit').remove();
- };
- buttons[trans('Cancel','QIMessageBox')] = function() { $('#vboxSettingsUSBFilterEdit').remove(); };
-
-
- $('#vboxSettingsUSBFilterEdit').dialog({'buttons':buttons,'closeOnEscape':false,'width':400,'modal':true,'autoOpen':true,'dialogClass':'vboxDialogContent vboxNonTabbed','title':'<img src="images/vbox/usb_16px.png" class="vboxDialogTitleIcon" /> '+trans('USB Filter Details','UIMachineSettingsUSBFilterDetails')});
-
- }
- },
-
- {
- 'name' : 'usbremove',
- 'label' : 'Remove Filter',
- 'icon' : 'usb_remove',
- 'enabled' : function (item) { return (item && $(item).data('filter') && $(item).data('filter').name); },
- 'click' : function () {
- var item = $('#vboxSettingsUSBFilterList').find('.vboxListItemSelected').first();
- // determine next target
- var target = $(item).next();
- if(!$(target).length) target = $(item).prev();
- if(!$(target).length) target = null;
- $(item).empty().remove();
-
- if(!$(target).trigger('click').length) {
- $('#vboxSettingsUSBFilterList').trigger('select',null);
- }
- vboxColorRows($('#vboxSettingsUSBFilterList'));
- }
- },
-
- {
- 'name' : 'usbup',
- 'label' : 'Move Filter Up',
- 'icon' : 'usb_moveup',
- 'enabled' : function (item) {
- return (item && $(item).data('filter') && $(item).data('filter').name && $(item).attr('id') != $('#vboxSettingsUSBFilterList').children().first().attr('id'));
- },
- 'click' : function () {
-
- var item = $('#vboxSettingsUSBFilterList').find('.vboxListItemSelected').first();
-
- var prev = $(item).prev();
- if(!$(prev).length) return;
- var mv = $(item).detach();
- $(prev).before(mv);
-
- vboxColorRows($('#vboxSettingsUSBFilterList'));
- $('#vboxSettingsUSBFilterList').find('.vboxListItemSelected').first().trigger('click');
-
- }
- },
-
- {
- 'name' : 'usbdown',
- 'label' : 'Move Filter Down',
- 'icon' : 'usb_movedown',
- 'enabled' : function (item) {
- return (item && $(item).data('filter') && $(item).data('filter').name && $(item).attr('id') != $('#vboxSettingsUSBFilterList').children().last().attr('id'));
- },
- 'click' : function () {
-
- var item = $('#vboxSettingsUSBFilterList').find('.vboxListItemSelected').first();
-
- var next = $(item).next();
- if(!$(next).length) return;
- var mv = $(item).detach();
- $(next).after(mv);
-
- vboxColorRows($('#vboxSettingsUSBFilterList'));
- $('#vboxSettingsUSBFilterList').find('.vboxListItemSelected').first().trigger('click');
- }
- }
-
-
- );
-
-var usbToolbar = new vboxToolbarSmall({buttons: sButtons,
- language_context: 'UIMachineSettingsUSB', renderTo: 'vboxSettingsUSBButtons'});
-
-$('#vboxSettingsUSBFilterList').on('select',function(e,el){usbToolbar.update(el);});
-
-
-
-/* Adds a USB filter to list */
-function vboxSettingsAddUSBFilter(f,noColor) {
-
- var li = $('<li />').data({'filter':f}).attr({'id':'vboxSettingsUSBFilterNumber' + (Math.floor(Math.random()*1000)),'class':'vboxListItem'});
-
- if(document.forms['frmVboxSettings'].vboxSettingsUSBEnabled.checked) {
-
- li.click(function(){
- $(this).parent().children().removeClass('vboxListItemSelected');
- $(this).addClass('vboxListItemSelected');
- $('#vboxSettingsUSBFilterList').trigger('select',this);
- }).dblclick(function(e){
- e.preventDefault();
- usbToolbar.click('usbedit');
- }).hoverClass('vboxHover').disableSelection();
- }
-
- $('<input />').attr({'type':'checkbox'}).prop('checked',(f.active ? true : false)).appendTo(li);
-
- $(li).append(' <span class="vboxSettingsUSBFilterTitle">'+$('<div/>').text(f.name).html()+'</span>').appendTo($('#vboxSettingsUSBFilterList'));
-
-
- if(!noColor) vboxColorRows($('#vboxSettingsUSBFilterList'));
-}
-
-
-/* Menu for adding existing USB device */
-
-var exUsb = new vboxMenu({id: 'vboxSettingsUSBAddDevice', menuItems: []});
-
-/* Add attachment button menu initialization */
-$("#vboxSettingsUSBAddDeviceClick").contextMenu({
- menu: 'vboxSettingsUSBAddDevice',
- button: 0
- },
- function(action, el, pos, menuItem) {
-
- if(action == 'usbNoop') return;
-
- // usb data kept in elm
- var usb = $(menuItem).data('device');
- delete usb.port, usb.version, usb.portVersion;
- usb.name = $(menuItem).html();
- usb.active = 1;
-
- vboxSettingsAddUSBFilter(usb);
-
- $('#vboxSettingsUSBFilterList').trigger('select',$('#vboxSettingsUSBFilterList').find('.vboxListItemSelected').first());
-
- }
-);
-
-
-/*
- * USB data
- */
-$('#vboxSettingsDialog').on('dataLoaded',function(){
-
- // set checkboxes for USB and EHCI
- if($('#vboxSettingsDialog').data('vboxMachineData').USBControllers.length) {
-
- var usbType = 'OHCI';
- var enabled = false;
-
- for(var i = 0; i < $('#vboxSettingsDialog').data('vboxMachineData').USBControllers.length; i++) {
- var listUSBType = $('#vboxSettingsDialog').data('vboxMachineData').USBControllers[i].type;
- if(listUSBType == 'OHCI') {
- enabled = true;
- }
- switch(listUSBType) {
- case 'OHCI':
- if(usbType == 'EHCI')
- break;
- case 'EHCI':
- if(usbType == 'XHCI')
- break;
- default:
- usbType = listUSBType;
- }
- }
- $(document.forms['frmVboxSettings'].vboxSettingsUSBEnabled).prop('checked',enabled).triggerHandler('click');
-
- $(document.forms['frmVboxSettings']).find('input[value="'+usbType+'"]').prop('checked',true);
-
- } else {
- $(document.forms['frmVboxSettings'].vboxSettingsUSBEnabled).prop('checked',false).triggerHandler('click');
- $(document.forms['frmVboxSettings']).find('input[value="OHCI"]').prop('checked',true);
- }
-
- // clear list
- var list = $('#vboxSettingsUSBFilterList');
- $(list).empty().children().remove();
-
- // add filters
- for(var i = 0; i < $('#vboxSettingsDialog').data('vboxMachineData').USBDeviceFilters.length; i++) {
- vboxSettingsAddUSBFilter($('#vboxSettingsDialog').data('vboxMachineData').USBDeviceFilters[i],true);
- }
- vboxColorRows($('#vboxSettingsUSBFilterList'));
-
-
- if(!$('#vboxSettingsUSBFilterList').find('li.vboxListItem').first().trigger('click')) {
- $('#vboxSettingsUSBFilterList').trigger('select',null);
- }
-
- var p = $('#vboxSettingsUSBTable');
- if(!$('#vboxSettingsDialog').data('vboxFullEdit')) {
- $(p).find('tr:not(.vboxRunningEnabled)').find('span').addClass('disabled');
- $(p).find('tr:not(.vboxRunningEnabled)').find('input,select,textarea').prop('disabled',true);
- } else {
- $(p).find('tr:not(.vboxRunningEnabled)').find('span').removeClass('disabled');
- $(p).find('tr:not(.vboxRunningEnabled)').find('input,select,textarea').prop('disabled',false);
- }
-});
-
-
-/* Change settings onSave() */
-$('#vboxSettingsDialog').on('save',function(){
-
- // get checkboxes for USB and EHCI
- var frmEnabled = document.forms['frmVboxSettings'].vboxSettingsUSBEnabled.checked;
-
- var frmType = $(document.forms['frmVboxSettings']).find('input[name="vboxSettingsUSBControllerType"]:checked').val();
-
- $('#vboxSettingsDialog').data('vboxMachineData').USBControllers = new Array();
-
- if(frmEnabled) {
- $('#vboxSettingsDialog').data('vboxMachineData').USBControllers = [{
- 'name': 'OHCI',
- 'type': 'OHCI'
- }];
- }
-
- if(frmType != 'OHCI') {
- $('#vboxSettingsDialog').data('vboxMachineData').USBControllers.push({
- 'name': frmType,
- 'type': frmType
- });
- }
-
- $('#vboxSettingsDialog').data('vboxMachineData').USBDeviceFilters = new Array();
-
- $('#vboxSettingsUSBFilterList').children('li').each(function(){
- $(this).data('filter').active = $(this).children('input:checkbox').first().prop('checked');
- $('#vboxSettingsDialog').data('vboxMachineData').USBDeviceFilters[$('#vboxSettingsDialog').data('vboxMachineData').USBDeviceFilters.length] = $(this).data('filter');
- });
-
-});
-
-
-</script>
-
+<!--
+
+ USB port settings
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: settingsUSB.html 597 2015-04-20 11:41:28Z imoore76 $
+
+ -->
+<table id='vboxSettingsUSBTable' style='width: 100%'>
+ <tr>
+ <td><label><input type='checkbox' class='vboxCheckbox vboxEnablerCheckbox' name='vboxSettingsUSBEnabled' /> <span class='translate'>Enable USB Controller</span></label></td>
+ </tr>
+ <tr>
+ <td style='width: 100%; padding-left: 20px;'><label><input type='radio' class='vboxCheckbox' name='vboxSettingsUSBControllerType' value='OHCI'/> <span class='translate vboxEnablerListen'>USB 1.1 (OHCI) Controller</span></label></td>
+ </tr>
+ <tr>
+ <td style='width: 100%; padding-left: 20px;'><label><input type='radio' class='vboxCheckbox' name='vboxSettingsUSBControllerType' value='EHCI'/> <span class='translate vboxEnablerListen'>USB 2.0 (EHCI) Controller</span></label></td>
+ </tr>
+ <tr>
+ <td style='width: 100%; padding-left: 20px;'><label><input type='radio' class='vboxCheckbox' name='vboxSettingsUSBControllerType' value='XHCI'/> <span class='translate vboxEnablerListen'>USB 3.0 (xHCI) Controller</span></label></td>
+ </tr>
+ <tr style='vertical-align: middle' class='vboxRunningEnabled'>
+ <td style='width: 100%; padding-left: 20px;'>
+ <table class='vboxSettingsHeadingLine' style='width:100%;border-spacing:0;border:0px;margin:0px;padding:0px;'><tr style='vertical-align:middle' class='vboxRunningEnabled'><td style='white-space: nowrap; width: auto'><span class='translate vboxEnablerListen'>USB Device Filters</span></td><td style='width: 100%'><hr style='width: 100%;' class='vboxSeparatorLine'/></td></tr></table>
+ </td>
+ </tr>
+ <tr class='vboxRunningEnabled'>
+ <td style='width: 100%; padding-left: 20px;'>
+ <table style='width: 100%'>
+ <tr class='vboxRunningEnabled'>
+ <td id='vboxSettingsUSBFilters' style='width: 100%;' class='vboxBordered vboxEnablerListen'>
+ <!-- Hidden div for context menu -->
+ <div id='vboxSettingsUSBAddDeviceClick' style='display: none' />
+ <ul id='vboxSettingsUSBFilterList' class='vboxList vboxHover' style='width: 100%'>
+ <li class='vboxListItem'><input type='checkbox' class='vboxCheckbox' />a</li>
+ </ul>
+ </td>
+ <td id='vboxSettingsUSBButtons' class='vboxEnablerListen'></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+
+</table>
+<script type='text/javascript'>
+
+/*
+ * USB Buttons and Toolbar
+ */
+
+//Translations
+ $('#vboxSettingsTabPortsUSB').find(".translate").html(function(i,h){return trans($('<div />').html(h).text(),'UIMachineSettingsUSB');}).removeClass('translate');
+
+
+ var sButtons = new Array(
+
+ {
+ 'name' : 'usbnew',
+ 'label' : 'Add Empty Filter',
+ 'icon' : 'usb_new',
+ 'click' : function () {
+ var list = $('#vboxSettingsUSBFilterList');
+ var currUsbName = 1;
+ for(; currUsbName < 99; currUsbName++) {
+ if(!$(list).find('span.vboxSettingsUSBFilterTitle').filter(function(){
+ return ($(this).text() == trans('New Filter %1','UIMachineSettingsUSB').replace('%1',currUsbName));
+ }).length) break;
+ }
+
+ vboxSettingsAddUSBFilter({'active':1,'name':trans('New Filter %1','UIMachineSettingsUSB').replace('%1',currUsbName)});
+
+ if(!$('#vboxSettingsUSBFilterList').find('.vboxListItemSelected').first().trigger('click').html()) {
+ $('#vboxSettingsUSBFilterList').trigger('select',null); }
+ }
+ },
+
+ {
+ 'name' : 'usbnewdevice',
+ 'label' : 'Add Filter From Device',
+ 'icon' : 'usb_add',
+ 'click' : function (e) {
+
+ // Update menu
+ var menu = $("#vboxSettingsUSBAddDevice");
+
+ menu.children().remove();
+ menu.append($('<li />').html('<span><img src="images/jqueryFileTree/spinner.gif" /></span>').css({'width':'100px','text-align':'center'}));
+
+ var l = new vboxLoader();
+ l.add('hostGetUSBDevices',function(res){
+
+ var hostUSB = res.responseData;
+
+ $(menu).children().remove();
+ for(var i = 0; i < hostUSB.length; i++) {
+
+ var dname = '';
+ if(!hostUSB[i].product)
+ dname = trans('Unknown device %1:%2','VBoxGlobal').replace('%1',hostUSB[i].vendorId).replace('%2',hostUSB[i].productId);
+ else
+ dname = hostUSB[i].manufacturer + ' ' + hostUSB[i].product;
+ dname += ' [' + hostUSB[i].revision + ']';
+
+ $(menu).append($('<li />').append($('<a />').attr({'href':'#usbDev'+i}).html(dname).data({'device':hostUSB[i]})));
+ }
+
+ // No devices?
+ if(hostUSB.length == 0) {
+ $(menu).append($('<li />').append($('<a />').attr({'href':'#usbNoop'}).html($('<div />').text(trans('<no devices available>','VBoxUSBMenu')).html()).data({'device':hostUSB[i]})));
+ }
+ $(menu).trigger('menuLoaded');
+
+ vboxPositionToWindow(menu);
+
+ },{});
+ l.noLoadingScreen = true;
+ l.run();
+
+ // Trigger mouse up / down on hidden element
+
+ var md = jQuery.Event("mousedown");
+ var mu = jQuery.Event("mouseup");
+ for(var i in e) { (md[i] ? null : md[i] = mu[i] = e[i]); }
+ // Fix mouse button for MSIE
+ if(jQuery.browser.msie && e.button == 0) md.button = mu.button = 1;
+
+
+ $("#vboxSettingsUSBAddDeviceClick").trigger(md).trigger(mu);
+ }
+ },
+
+ {
+ 'name' : 'usbedit',
+ 'label' : 'Edit Filter',
+ 'icon' : 'usb_filter_edit',
+ 'enabled' : function (item) { return (item && $(item).data('filter') && $(item).data('filter').name); },
+ 'click' : function () {
+
+ var d = $('<div />').attr({'id':'vboxSettingsUSBFilterEdit','style':'display: none','class':'vboxNonTabbed vboxDialogContent'});
+
+ var tbl = $('<table />').attr({'style':'width: 100%','class':'vboxSettingsTable'});
+
+ var vboxSettingsUSBFilterProps = [
+ ['Name','name'],['Vendor ID','vendorId'],['Product ID','productId'],
+ ['Revision','revision'],['Manufacturer','manufacturer'],['Product','product'],
+ ['Serial No.','serialNumber'],['Port','port']];
+
+ /* Get Defaults */
+ var filter = $('#vboxSettingsUSBFilterList').find('li.vboxListItemSelected').first().data('filter');
+
+ for(var i = 0; i < vboxSettingsUSBFilterProps.length; i++) {
+
+ var val = (filter[vboxSettingsUSBFilterProps[i][1]]||'');
+ $('<tr />').append($('<th />').attr({'style':'white-space: nowrap; width: auto; text-align: right;'}).html(trans(vboxSettingsUSBFilterProps[i][0]+':','UIMachineSettingsUSBFilterDetails'))).append($('<td />').attr({'style':'width: 100%'}).html('<input type="text" class="vboxText" style="width: 100%" id="vboxSettingsUSBF'+vboxSettingsUSBFilterProps[i][1]+'" value="'+$('<div />').text((filter[vboxSettingsUSBFilterProps[i][1]]||'')).html()+'"/>')).appendTo(tbl);
+ }
+
+ // Generate select box
+ var sel = $('<select />').attr({'id':'vboxSettingsUSBFRemote'});
+ var opts = [['',trans('Any','UIMachineSettingsUSBFilterDetails')],['yes',trans('Yes','UIMachineSettingsUSBFilterDetails')],['no',trans('No','UIMachineSettingsUSBFilterDetails')]];
+ for(var i = 0; i < opts.length; i++) {
+ var o = new Option(opts[i][1],opts[i][0],((filter['remote']||'')==opts[i][0]));
+ $(sel).prop('options').add(o);
+ }
+
+ $('<tr />').append($('<th />').attr({'style':'white-space: nowrap; width: auto; text-align: right;'}).html(trans('Remote:','UIMachineSettingsUSBFilterDetails'))).append($('<td />').attr({'style':'width: 100%'}).append(sel)).appendTo(tbl);
+
+ $(d).append(tbl).appendTo($('#vboxPane'));
+
+ var buttons = { };
+ buttons[trans('OK','QIMessageBox')] = function() {
+
+ var item = $('#vboxSettingsUSBFilterList').find('.vboxListItemSelected').first();
+
+ for(var i = 0; i < vboxSettingsUSBFilterProps.length; i++) {
+ $(item).data('filter')[vboxSettingsUSBFilterProps[i][1]] = $('#vboxSettingsUSBF'+(vboxSettingsUSBFilterProps[i][1])).val();
+ }
+ $(item).data('filter').remote = ($('#vboxSettingsUSBFRemote').val()||'');
+ // Change display name
+ $(item).find('span.vboxSettingsUSBFilterTitle').first().text($(item).data('filter').name);
+ $('#vboxSettingsUSBFilterEdit').remove();
+ };
+ buttons[trans('Cancel','QIMessageBox')] = function() { $('#vboxSettingsUSBFilterEdit').remove(); };
+
+
+ $('#vboxSettingsUSBFilterEdit').dialog({'buttons':buttons,'closeOnEscape':false,'width':400,'modal':true,'autoOpen':true,'dialogClass':'vboxDialogContent vboxNonTabbed','title':'<img src="images/vbox/usb_16px.png" class="vboxDialogTitleIcon" /> '+trans('USB Filter Details','UIMachineSettingsUSBFilterDetails')});
+
+ }
+ },
+
+ {
+ 'name' : 'usbremove',
+ 'label' : 'Remove Filter',
+ 'icon' : 'usb_remove',
+ 'enabled' : function (item) { return (item && $(item).data('filter') && $(item).data('filter').name); },
+ 'click' : function () {
+ var item = $('#vboxSettingsUSBFilterList').find('.vboxListItemSelected').first();
+ // determine next target
+ var target = $(item).next();
+ if(!$(target).length) target = $(item).prev();
+ if(!$(target).length) target = null;
+ $(item).empty().remove();
+
+ if(!$(target).trigger('click').length) {
+ $('#vboxSettingsUSBFilterList').trigger('select',null);
+ }
+ vboxColorRows($('#vboxSettingsUSBFilterList'));
+ }
+ },
+
+ {
+ 'name' : 'usbup',
+ 'label' : 'Move Filter Up',
+ 'icon' : 'usb_moveup',
+ 'enabled' : function (item) {
+ return (item && $(item).data('filter') && $(item).data('filter').name && $(item).attr('id') != $('#vboxSettingsUSBFilterList').children().first().attr('id'));
+ },
+ 'click' : function () {
+
+ var item = $('#vboxSettingsUSBFilterList').find('.vboxListItemSelected').first();
+
+ var prev = $(item).prev();
+ if(!$(prev).length) return;
+ var mv = $(item).detach();
+ $(prev).before(mv);
+
+ vboxColorRows($('#vboxSettingsUSBFilterList'));
+ $('#vboxSettingsUSBFilterList').find('.vboxListItemSelected').first().trigger('click');
+
+ }
+ },
+
+ {
+ 'name' : 'usbdown',
+ 'label' : 'Move Filter Down',
+ 'icon' : 'usb_movedown',
+ 'enabled' : function (item) {
+ return (item && $(item).data('filter') && $(item).data('filter').name && $(item).attr('id') != $('#vboxSettingsUSBFilterList').children().last().attr('id'));
+ },
+ 'click' : function () {
+
+ var item = $('#vboxSettingsUSBFilterList').find('.vboxListItemSelected').first();
+
+ var next = $(item).next();
+ if(!$(next).length) return;
+ var mv = $(item).detach();
+ $(next).after(mv);
+
+ vboxColorRows($('#vboxSettingsUSBFilterList'));
+ $('#vboxSettingsUSBFilterList').find('.vboxListItemSelected').first().trigger('click');
+ }
+ }
+
+
+ );
+
+var usbToolbar = new vboxToolbarSmall({buttons: sButtons,
+ language_context: 'UIMachineSettingsUSB', renderTo: 'vboxSettingsUSBButtons'});
+
+$('#vboxSettingsUSBFilterList').on('select',function(e,el){usbToolbar.update(el);});
+
+
+
+/* Adds a USB filter to list */
+function vboxSettingsAddUSBFilter(f,noColor) {
+
+ var li = $('<li />').data({'filter':f}).attr({'id':'vboxSettingsUSBFilterNumber' + (Math.floor(Math.random()*1000)),'class':'vboxListItem'});
+
+ if(document.forms['frmVboxSettings'].vboxSettingsUSBEnabled.checked) {
+
+ li.click(function(){
+ $(this).parent().children().removeClass('vboxListItemSelected');
+ $(this).addClass('vboxListItemSelected');
+ $('#vboxSettingsUSBFilterList').trigger('select',this);
+ }).dblclick(function(e){
+ e.preventDefault();
+ usbToolbar.click('usbedit');
+ }).hoverClass('vboxHover').disableSelection();
+ }
+
+ $('<input />').attr({'type':'checkbox'}).prop('checked',(f.active ? true : false)).appendTo(li);
+
+ $(li).append(' <span class="vboxSettingsUSBFilterTitle">'+$('<div/>').text(f.name).html()+'</span>').appendTo($('#vboxSettingsUSBFilterList'));
+
+
+ if(!noColor) vboxColorRows($('#vboxSettingsUSBFilterList'));
+}
+
+
+/* Menu for adding existing USB device */
+
+var exUsb = new vboxMenu({id: 'vboxSettingsUSBAddDevice', menuItems: []});
+
+/* Add attachment button menu initialization */
+$("#vboxSettingsUSBAddDeviceClick").contextMenu({
+ menu: 'vboxSettingsUSBAddDevice',
+ button: 0
+ },
+ function(action, el, pos, menuItem) {
+
+ if(action == 'usbNoop') return;
+
+ // usb data kept in elm
+ var usb = $(menuItem).data('device');
+ delete usb.port, usb.version, usb.portVersion;
+ usb.name = $(menuItem).html();
+ usb.active = 1;
+
+ vboxSettingsAddUSBFilter(usb);
+
+ $('#vboxSettingsUSBFilterList').trigger('select',$('#vboxSettingsUSBFilterList').find('.vboxListItemSelected').first());
+
+ }
+);
+
+
+/*
+ * USB data
+ */
+$('#vboxSettingsDialog').on('dataLoaded',function(){
+
+ // set checkboxes for USB and EHCI
+ if($('#vboxSettingsDialog').data('vboxMachineData').USBControllers.length) {
+
+ var usbType = 'OHCI';
+ var enabled = false;
+
+ for(var i = 0; i < $('#vboxSettingsDialog').data('vboxMachineData').USBControllers.length; i++) {
+ var listUSBType = $('#vboxSettingsDialog').data('vboxMachineData').USBControllers[i].type;
+ if(listUSBType == 'OHCI') {
+ enabled = true;
+ }
+ switch(listUSBType) {
+ case 'OHCI':
+ if(usbType == 'EHCI')
+ break;
+ case 'EHCI':
+ if(usbType == 'XHCI')
+ break;
+ default:
+ usbType = listUSBType;
+ }
+ }
+ $(document.forms['frmVboxSettings'].vboxSettingsUSBEnabled).prop('checked',enabled).triggerHandler('click');
+
+ $(document.forms['frmVboxSettings']).find('input[value="'+usbType+'"]').prop('checked',true);
+
+ } else {
+ $(document.forms['frmVboxSettings'].vboxSettingsUSBEnabled).prop('checked',false).triggerHandler('click');
+ $(document.forms['frmVboxSettings']).find('input[value="OHCI"]').prop('checked',true);
+ }
+
+ // clear list
+ var list = $('#vboxSettingsUSBFilterList');
+ $(list).empty().children().remove();
+
+ // add filters
+ for(var i = 0; i < $('#vboxSettingsDialog').data('vboxMachineData').USBDeviceFilters.length; i++) {
+ vboxSettingsAddUSBFilter($('#vboxSettingsDialog').data('vboxMachineData').USBDeviceFilters[i],true);
+ }
+ vboxColorRows($('#vboxSettingsUSBFilterList'));
+
+
+ if(!$('#vboxSettingsUSBFilterList').find('li.vboxListItem').first().trigger('click')) {
+ $('#vboxSettingsUSBFilterList').trigger('select',null);
+ }
+
+ var p = $('#vboxSettingsUSBTable');
+ if(!$('#vboxSettingsDialog').data('vboxFullEdit')) {
+ $(p).find('tr:not(.vboxRunningEnabled)').find('span').addClass('disabled');
+ $(p).find('tr:not(.vboxRunningEnabled)').find('input,select,textarea').prop('disabled',true);
+ } else {
+ $(p).find('tr:not(.vboxRunningEnabled)').find('span').removeClass('disabled');
+ $(p).find('tr:not(.vboxRunningEnabled)').find('input,select,textarea').prop('disabled',false);
+ }
+});
+
+
+/* Change settings onSave() */
+$('#vboxSettingsDialog').on('save',function(){
+
+ // get checkboxes for USB and EHCI
+ var frmEnabled = document.forms['frmVboxSettings'].vboxSettingsUSBEnabled.checked;
+
+ var frmType = $(document.forms['frmVboxSettings']).find('input[name="vboxSettingsUSBControllerType"]:checked').val();
+
+ $('#vboxSettingsDialog').data('vboxMachineData').USBControllers = new Array();
+
+ if(frmEnabled) {
+ $('#vboxSettingsDialog').data('vboxMachineData').USBControllers = [{
+ 'name': 'OHCI',
+ 'type': 'OHCI'
+ }];
+ }
+
+ if(frmType != 'OHCI') {
+ $('#vboxSettingsDialog').data('vboxMachineData').USBControllers.push({
+ 'name': frmType,
+ 'type': frmType
+ });
+ }
+
+ $('#vboxSettingsDialog').data('vboxMachineData').USBDeviceFilters = new Array();
+
+ $('#vboxSettingsUSBFilterList').children('li').each(function(){
+ $(this).data('filter').active = $(this).children('input:checkbox').first().prop('checked');
+ $('#vboxSettingsDialog').data('vboxMachineData').USBDeviceFilters[$('#vboxSettingsDialog').data('vboxMachineData').USBDeviceFilters.length] = $(this).data('filter');
+ });
+
+});
+
+
+</script>
+
\ No newline at end of file
diff --git a/panes/tabVMConsole.html b/panes/tabVMConsole.html
index e00cdc3..91788a2 100644
--- a/panes/tabVMConsole.html
+++ b/panes/tabVMConsole.html
@@ -1,41 +1,41 @@
-<!--
-
- VM Console tab
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: tabVMConsole.html 595 2015-04-17 09:50:36Z imoore76 $
-
- -->
-<div id='vboxTabVMConsole' class='vboxTabContent' style='display:none;'>
-</div>
-<script type="text/javascript">
-
-// Load default VRDE tab
-if($('#vboxPane').data('vboxSystemProperties') && $('#vboxPane').data('vboxSystemProperties').defaultVRDEExtPack.indexOf('VNC') > -1) {
- // VNC
- $('#vboxTabVMConsole').load('panes/tabVMConsoleVNC.html');
-} else {
- // RDP
- $('#vboxTabVMConsole').load('panes/tabVMConsoleRDP.html');
-}
-
-// Load new on host change
-$('#vboxPane').on('hostChanged', function() {
-
- $('#vboxTabVMConsole').empty();
-
- // Load default VRDE tab
- if($('#vboxPane').data('vboxSystemProperties') && $('#vboxPane').data('vboxSystemProperties').defaultVRDEExtPack.indexOf('VNC') > -1) {
- // VNC
- $('#vboxTabVMConsole').load('panes/tabVMConsoleVNC.html');
- } else {
- // RDP
- $('#vboxTabVMConsole').load('panes/tabVMConsoleRDP.html');
- }
-
-});
-
-
-</script>
-
-
+<!--
+
+ VM Console tab
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: tabVMConsole.html 595 2015-04-17 09:50:36Z imoore76 $
+
+ -->
+<div id='vboxTabVMConsole' class='vboxTabContent' style='display:none;'>
+</div>
+<script type="text/javascript">
+
+// Load default VRDE tab
+if($('#vboxPane').data('vboxSystemProperties') && $('#vboxPane').data('vboxSystemProperties').defaultVRDEExtPack.indexOf('VNC') > -1) {
+ // VNC
+ $('#vboxTabVMConsole').load('panes/tabVMConsoleVNC.html');
+} else {
+ // RDP
+ $('#vboxTabVMConsole').load('panes/tabVMConsoleRDP.html');
+}
+
+// Load new on host change
+$('#vboxPane').on('hostChanged', function() {
+
+ $('#vboxTabVMConsole').empty();
+
+ // Load default VRDE tab
+ if($('#vboxPane').data('vboxSystemProperties') && $('#vboxPane').data('vboxSystemProperties').defaultVRDEExtPack.indexOf('VNC') > -1) {
+ // VNC
+ $('#vboxTabVMConsole').load('panes/tabVMConsoleVNC.html');
+ } else {
+ // RDP
+ $('#vboxTabVMConsole').load('panes/tabVMConsoleRDP.html');
+ }
+
+});
+
+
+</script>
+
+
diff --git a/panes/tabVMConsoleRDP.html b/panes/tabVMConsoleRDP.html
index c38e66d..ac62f7b 100644
--- a/panes/tabVMConsoleRDP.html
+++ b/panes/tabVMConsoleRDP.html
@@ -1,504 +1,504 @@
-<!--
-
- VM Console tab
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: tabVMConsoleRDP.html 595 2015-04-17 09:50:36Z imoore76 $
-
- -->
- <div id='vboxTabVMUnavailable' style='display: none' class='translate'>Virtual machine is not running or is not configured to accept RDP connections.</div>
- <div id='vboxRDPFormContainer' style='padding-top: 8px; display: none'>
- <form name="vboxRDPForm" id="vboxRDPForm">
- <div class='vboxInvisible' id='vboxRDPConnParams'>
-
- <span id='vboxConsoleLoginInfo'>
- <span class='translate'>User name</span>: <input class='vboxRDPSet' type=text size=20 name=logonUsername value="">
- <span class='translate'>Password</span>: <input class='vboxRDPSet' type=password size=20 name=logonPassword value="">
- </span>
-
- <span class='translate'>Requested desktop size</span>:
- <select id='vboxRDPSize' name='vboxRDPSizeSelect'>
- <option value='800x600'>800x600</option>
- <option value='1024x768'>1024x768</option>
- <option value='1280x1024'>1280x1024</option>
- </select>
-
- </div>
- <p>
- <input name=connectionButton type=button value="Connect" onclick="vboxRDPConnect();" />
- <input type='text' id='vboxConsoleAddr' name='serverAddress' class='vboxRDPSet' value='' />
- <!-- and hardcore web dev guys across the world frown ... //-->
- &nbsp; &nbsp; &nbsp;
- <input name=cadButton id='vboxConsoleCADButton' style='display: none' type=button value="Ctrl-Alt-Del" onClick="vboxRDPsendCAD()" />
- <input id='vboxVRDPDetachBtn' style='display: none' name='detach' type='button' value='Detach' onClick="vboxRDPDetach();" />
- <span id='vboxRDPStatus'></span>
- </p>
- </form>
- </div>
-
- <div id="FlashRDPContainer" style='width: 100%;'>
- <div id="FlashRDP" style='width: 100%;'></div>
- </div>
-
-
-<script type="text/javascript">
-
-var vboxRDPFlashLoaded = false;
-var vboxConsoleDetached = (vboxConsoleDetached || false);
-var vboxRDPFlashListenersAdded = false;
-
-$('#vboxRDPForm').on('submit',function(e){
- e.stopPropagation();
- e.preventDefault();
- return false;
-});
-
-// Custom resolutions
-if($("#vboxPane").data('vboxConfig').consoleResolutions) {
- var res = $("#vboxPane").data('vboxConfig').consoleResolutions;
- // first one must be valid
- if(res[0].split('x').length == 2) {
- document.vboxRDPForm.vboxRDPSizeSelect.options.length = 0;
- $(document.vboxRDPForm.vboxRDPSizeSelect).children().remove();
- for(var i = 0; i < res.length; i++) {
- document.vboxRDPForm.vboxRDPSizeSelect.options[i] = new Option(res[i],res[i]);
- }
- }
-}
-// Translations
-$('#vboxTabVMConsole').find(".translate").html(function(i,h){return trans(h,'VBoxConsoleWgt');}).removeClass('translate');
-$(document.vboxRDPForm.connectionButton).val(trans('Connect','VBoxConsoleWgt'));
-$(document.vboxRDPForm.cadButton).val(trans("Send Ctrl-Alt-Del",'VBoxConsoleWgt'));
-$(document.vboxRDPForm.vboxVRDPDetachBtn).val(trans("Detach",'VBoxConsoleWgt'));
-$("#vboxRDPStatus").html(trans("Loading ...",'UIVMDesktop'));
-if(vboxConsoleDetached) window.status = $("#vboxRDPStatus").text();
-
-// Disable / enable tab on selection list changes
-$('#vboxPane').on('vmSelectionListChanged', function(){
-
- var vm = vboxChooser.getSingleSelected();
-
- // Initially disable tab
- $('#vboxTabVMConsole').parent().trigger('disableTab', ['vboxTabVMConsole']);
-
- if(!vm || !vboxVMStates.isRunning(vm)) {
- $('#vboxRDPFormContainer').css({'display':'none'});
- $('#FlashRDPContainer').css({'visibility':'hidden'});
- $('#vboxTabVMUnavailable').css({'display':'none'});
-
- } else {
-
- // VM is running, get runtime data
- $.when(vboxVMDataMediator.getVMDataCombined(vm.id)).done(function(info) {
-
- if(info.VRDEServerInfo && info.VRDEServerInfo.port > 0 && info.VRDEServer.VRDEExtPack.indexOf("VNC") == -1) {
-
- $('#vboxRDPFormContainer').css({'display':''});
- $('#FlashRDPContainer').css({'visibility':'visible'});
- $('#vboxTabVMUnavailable').css({'display':'none'});
-
- $('#vboxTabVMConsole').parent().trigger('enableTab', ['vboxTabVMConsole']);
- }
-
- });
-
- }
-
-
-// Update on console info change
-}).on('vboxOnVRDEServerInfoChanged',function(e,eventData) {
-
- // Shorthand
- var vmid = eventData.machineId;
- var VRDEServerInfo = eventData.enrichmentData;
-
- var selVM = vboxChooser.getSingleSelected();
- var enabled = (selVM && selVM.id == vmid && vboxVMStates.isRunning(selVM) && VRDEServerInfo && VRDEServerInfo.port > 0);
-
- if(enabled) {
-
- $.when(vboxVMDataMediator.getVMDataCombined(vmid)).done(function(info) {
-
- enabled = (info.VRDEServerInfo && info.VRDEServerInfo.port > 0 && info.VRDEServer.VRDEExtPack.indexOf("VNC") == -1);
-
- if(enabled) {
-
- $('#vboxTabVMConsole').parent().trigger('enableTab', ['vboxTabVMConsole']);
-
- $('#vboxRDPFormContainer').css({'display':''});
- $('#FlashRDPContainer').css({'visibility':'visible'});
- $('#vboxTabVMUnavailable').css({'display':'none'});
-
-
- var chost = vboxGetVRDEHost(selVM);
- chost+=':'+VRDEServerInfo.port;
-
- if($(document.vboxRDPForm.serverAddress).val() != chost) {
-
- // console host changed
- vboxRDPDisconnect();
-
- }
- $(document.vboxRDPForm.serverAddress).val(chost);
- } else {
- $('#vboxTabVMConsole').parent().trigger('disableTab', ['vboxTabVMConsole']);
- }
-
- });
-
- } else {
-
- $('#vboxTabVMConsole').parent().trigger('disableTab', ['vboxTabVMConsole']);
- }
-
-// Update tab on machine state change
-}).on('vboxOnMachineStateChanged', function(e, eventData){
-
- var selVMId = vboxChooser.getSingleSelectedId();
- var enabled = (selVMId == eventData.machineId && vboxVMStates.isRunning({'state':eventData.state}));
-
- $('#vboxTabVMConsole').parent().trigger('disableTab', ['vboxTabVMConsole']);
-
- if(enabled) {
-
- // VM is running, get runtime data
- $.when(vboxVMDataMediator.getVMRuntimeData(eventData.machineId)).done(function(vm) {
-
- if(vm.VRDEServerInfo && vm.VRDEServerInfo.port > 0) {
-
- $('#vboxTabVMConsole').parent().trigger('enableTab', ['vboxTabVMConsole']);
-
- $('#vboxRDPFormContainer').css({'display':''});
- $('#FlashRDPContainer').css({'visibility':'visible'});
- $('#vboxTabVMUnavailable').css({'display':'none'});
-
- }
-
- });
-
- }
-
-// Clean up local data storage when a machine is unregistered
-}).on('vboxMachineRegistered', function(e, eventData) {
-
- if(!eventData.registered) {
- vboxSetLocalDataItem('vbox'+eventData.machineId+'ConsoleSize','',true);
- vboxSetLocalDataItem('vbox'+eventData.machineId+'ConsoleConnected','',true);
- }
-});
-
-/*
- * Populate console info values when this tab is shown
- */
-
-$('#vboxTabVMConsole').on('show',function(){
-
- var vm = vboxChooser.getSingleSelected();
-
- if(!vm || !vboxVMStates.isRunning(vm)) {
- $('#vboxRDPFormContainer').css({'display':'none'});
- $('#FlashRDPContainer').css({'visibility':'hidden'});
- $('#vboxTabVMUnavailable').css({'display':''});
- return;
- }
-
- $('#vboxConsoleLoginInfo').hide();
-
- /* Load runtime data. This will tell us if the VRDE server is actually active */
- /* And details. This will give us info about the VRDEServer configuration */
- $.when(vboxVMDataMediator.getVMRuntimeData(vm.id),vboxVMDataMediator.getVMDetails(vm.id))
- .done(function(runtimeData, detailsData) {
-
- /* Not active */
- if(!(runtimeData.VRDEServerInfo && runtimeData.VRDEServerInfo.port > 0)) {
- $('#vboxTabVMUnavailable').css({'display':''});
- $('#vboxTabVMConsole').parent().trigger('disableTab',['vboxTabVMConsole']);
- return;
- }
-
- // Hide login form if authtype is not set
- if(detailsData.VRDEServer.authType != 'Null') {
- $('#vboxConsoleLoginInfo').show();
- }
- $('#vboxConsoleLoginInfo').data('vboxVRDPauthType',detailsData.VRDEServer.authType);
-
- /* Active */
- $('#vboxRDPFormContainer').css({'display':''});
- $('#FlashRDPContainer').css({'visibility':'visible'});
- $('#vboxTabVMUnavailable').css({'display':'none'});
-
- vboxRDPDisconnect();
- $("#vboxRDPStatus").html('');
- if(vboxConsoleDetached) window.status = $("#vboxRDPStatus").text();
-
- var chost = vboxGetVRDEHost(detailsData);
- chost+=':'+runtimeData.VRDEServerInfo.port;
- $(document.vboxRDPForm.serverAddress).val(chost);
-
- // Set default console size for this VM?
- var cs = vboxGetLocalDataItem('vbox'+detailsData.id+'ConsoleSize');
- if(cs) {
- $(document.vboxRDPForm.vboxRDPSizeSelect).children('[value='+cs+']').first().prop('selected',true);
- }
-
- $('#vboxRDPFormContainer').css({'display':''});
-
- vboxRDPLoad();
- });
-
-});
-
-function vboxRDPLoad() {
-
- var flashvars = {};
- var params = {};
- params.wmode="opaque";
- params.menu="false";
- params.bgcolor="#e9e9e9";
- params.quality="low";
- params.allowScriptAccess="always";
- params.flashId="FlashRDP";
-
- var attributes = {};
- swfobject.embedSWF("rdpweb/RDPClientUI.swf", "FlashRDP", "100", "100", "9.0.0","", flashvars, params, attributes);
-
- var ua = swfobject.ua;
-
- // No flash installed
- if(!ua || ua.pv[0] == '0') {
- $('#vboxRDPFormContainer').css('display','none');
- $("#FlashRDP").css('width','100%').html("The Adobe Flash plugin is not installed.");
- }
-}
-
-function vboxRDPgetFlashProperty(name) {
- var flash = RDPWebClient.getFlashById("FlashRDP");
- try {
- return flash.getProperty(name);
- } catch (e) {
- return '';
- }
-}
-
-/*
- * RDP client event handlers.
- * They will be called when the flash movie is ready and some event occurs.
- * Note: the function name must be the "flash_id" + "event name".
- */
-function RDPWebEventLoaded(flashid) {
-
- vboxRDPFlashLoaded = true;
- $("#vboxRDPStatus").html(trans("Version",'UIVMDesktop') + ": " + vboxRDPgetFlashProperty("version"));
- if(vboxConsoleDetached) window.status = $("#vboxRDPStatus").text();
-
- var flash = RDPWebClient.getFlashById("FlashRDP");
-
- // Apply keyboard layout
- flash.setProperty("keyboardLayout", ($('#vboxPane').data('vboxConfig').consoleKeyboardLayout == 'DE' ? 'de' : 'en'));
-
- // Only do this once
- if(!vboxRDPFlashListenersAdded) {
-
- if (window.addEventListener) {
- window.addEventListener("contextmenu", function(event) { return RDPWebClient._MozillaContextMenu(event); }, true);
- window.addEventListener("mousedown", function(event) { return RDPWebClient._MozillaMouse(event, true); }, true);
- window.addEventListener("mouseup", function(event) { return RDPWebClient._MozillaMouse(event, false); }, true);
- flash.addEventListener("mouseout", function(event) { return RDPWebClient._MozillaMouseOut(event); }, true);
- } else {
- document.oncontextmenu = function() { return RDPWebClient._IEContextMenu(); };
- flash.parentNode.onmousedown = function() { return RDPWebClient._IEMouse(true); };
- flash.parentNode.onmouseup = function() { return RDPWebClient._IEMouse(false); };
- flash.onmouseout=function() {return RDPWebClient._IEMouseOut(); };
- }
-
- vboxRDPFlashListenersAdded = true;
-
- }
-
- // Connect if "detached"
- if(vboxConsoleDetached) {
- $('#vboxTabVMUnavailable').css({'display':'none'});
- $('#vboxRDPFormContainer').css({'display':'none'});
- $('#vboxRDPSize').val($(window.opener.document.getElementById('vboxRDPSize')).val());
- $('#vboxRDPFormContainer').find(".vboxRDPSet").each(function(){
- $(this).val(window.opener.document.forms['vboxRDPForm'][$(this).attr('name')].value);
- });
- $(window).on('resize',function(){
- var flash = RDPWebClient.getFlashById("FlashRDP");
- var wh = [ $(window).width()-2, $(window).height()-2 ];
- $(flash).css({'height':wh[1]+'px','width':wh[0]+'px'});
- $('#FlashRDP').css({'height':wh[1]+'px','width':wh[0]+'px'});
- flash.setProperty("displayWidth", wh[0]);
- flash.setProperty("displayHeight", wh[1]);
- $(flash).css({'display':'none'});
- $(flash).css({'display':'block'});
- });
- vboxRDPConnect();
- } else {
-
- $('#vboxRDPConnParams').show();
- $('#vboxRDPFormContainer').css('display','');
-
- // Did not explicitly disconnect from this VM and has no auth settings so reconnect
- if(vboxGetLocalDataItem('vbox'+vboxChooser.getSingleSelectedId()+'ConsoleConnected') == 'true' && $('#vboxConsoleLoginInfo').data('vboxVRDPauthType') == 'Null') {
- document.vboxRDPForm.connectionButton.click();
- }
- }
-}
-
-function RDPWebEventConnected(flashId) {
- $("#vboxRDPStatus").data('vmConnected',true);
- $("#vboxRDPStatus").html(trans("Connected to %1",'VBoxConsoleWgt').replace('%1',$(document.vboxRDPForm.serverAddress).val()));
- if(vboxConsoleDetached) window.status = $("#vboxRDPStatus").text();
- $('#vboxConsoleCADButton').show();
- $('#vboxVRDPDetachBtn').show();
-}
-
-function RDPWebEventServerRedirect(flashId) {
- $("#vboxRDPStatus").html(trans("Redirection by %1",'VBoxConsoleWgt').replace('%1',vboxRDPgetFlashProperty("serverAddress")));
- if(vboxConsoleDetached) window.status = $("#vboxRDPStatus").text();
-}
-
-function RDPWebEventDisconnected(flashId) {
-
- $("#vboxRDPStatus").data('vmConnected',false);
-
- $('#vboxRDPConnParams').show();
- $('#vboxVRDPDetachBtn').hide();
-
- /* RDP connection has been lost */
- $("#vboxRDPStatus").html(trans("Disconnect reason",'VBoxConsoleWgt')+":\n" + vboxRDPgetFlashProperty("lastError"));
- if(vboxConsoleDetached) {
- alert($("#vboxRDPStatus").text());
- window.close();
- }
- document.vboxRDPForm.connectionButton.value = trans("Connect",'VBoxConsoleWgt');
- document.vboxRDPForm.connectionButton.onclick=function() {
- vboxSetLocalDataItem('vbox'+vboxChooser.getSingleSelectedId()+'ConsoleSize',$('#vboxRDPSize').val(),true);
- vboxSetLocalDataItem('vbox'+vboxChooser.getSingleSelectedId()+'ConsoleConnected','true',true);
- return vboxRDPConnect();
- };
- $('#vboxConsoleAddr').css('display','');
- $('#vboxConsoleCADButton').hide();
-
- $('#vboxRDPFormContainer').css({'display':''});
-}
-
-
-function vboxRDPConnect() {
-
- vboxSetLocalDataItem('vbox'+vboxChooser.getSingleSelectedId()+'ConsoleSize',$('#vboxRDPSize').val(), true);
-
- if (!vboxRDPFlashLoaded) return false;
-
- var flash = RDPWebClient.getFlashById("FlashRDP");
- if (!flash) return;
-
- $('#vboxRDPConnParams').hide();
-
- document.vboxRDPForm.connectionButton.value = trans("Disconnect",'VBoxConsoleWgt');
- document.vboxRDPForm.connectionButton.onclick=function(){
- vboxSetLocalDataItem('vbox'+vboxChooser.getSingleSelectedId()+'ConsoleConnected');
- return vboxRDPDisconnect();
- };
-
- $('#vboxConsoleAddr').css('display','none');
- $('#FlashRDPContainer').css({'visibility':'visible'});
-
-
- var flash = RDPWebClient.getFlashById("FlashRDP");
-
- var wh = null;
- if(vboxConsoleDetached) {
- wh = [ $(document).width()-2, $(document).height()-2 ];
- } else {
- wh = $('#vboxRDPSize').val().split('x');
- }
- $(flash).css({'height':wh[1]+'px','width':wh[0]+'px'});
- flash.setProperty("displayWidth", wh[0]);
- flash.setProperty("displayHeight", wh[1]);
-
- /* Setup the client parameters. */
- $('#vboxRDPFormContainer').find(".vboxRDPSet").each(function(){
- flash.setProperty($(this).attr('name'),$(this).val());
- });
-
- $("#vboxRDPStatus").html(trans("Connecting to %1",'VBoxConsoleWgt').replace('%1',$(document.vboxRDPForm.serverAddress).val()) + "...");
- if(vboxConsoleDetached) window.status = $("#vboxRDPStatus").html();
-
- /* Establish the connection. */
- flash.connect();
-
-}
-
-function vboxRDPDisconnect() {
- var flash = RDPWebClient.getFlashById("FlashRDP");
- if (flash) try { flash.disconnect(); } catch (err) {};
- /* Restore the "Connect" form. And resize flash*/
- document.vboxRDPForm.connectionButton.value = trans("Connect",'VBoxConsoleWgt');
- document.vboxRDPForm.connectionButton.onclick=function() {
- vboxSetLocalDataItem('vbox'+vboxChooser.getSingleSelectedId()+'ConsoleConnected','true',true);
- vboxSetLocalDataItem('vbox'+vboxChooser.getSingleSelectedId()+'ConsoleSize',$('#vboxRDPSize').val(),true);
- vboxRDPConnect();this.blur();
- };
- $('#vboxConsoleCADButton').hide();
- $(flash).css({'height':'100px','width':'100px'});
- $('#vboxConsoleAddr').css('display','');
-
-}
-
-function vboxRDPsendCAD() {
- var flash = RDPWebClient.getFlashById("FlashRDP");
- if (flash) flash.keyboardSendCAD();
-}
-
-function vboxRDPDetach() {
-
- vboxRDPDisconnect();
-
- var vmname = vboxChooser.getSingleSelected().name;
- var wh = $('#vboxRDPSize').val().split('x');
- var newwin = window.open('about:blank','vboxConsoleDetachedWin'+vmname.replace(/[^a-zA-Z0-9]/g,'_'),'toolbar=0,menubar=0,location=0,directories=0,status=true,resize=true,width='+(parseInt(wh[0])+20)+',height='+(parseInt(wh[1])+20)+'');
-
- newwin.document.open();
- newwin.document.write('<html><head><title>'+vmname + ' - ' + trans('Console','UIVMDesktop')+'</title></head><body style="margin: 0px; border: 0px; padding: 0px; overflow: hidden;"><div style="margin: 0px; border: 0px; padding: 0px" id="vboxPane"><img src="images/spinner.gif" /></div></body></html>');
- newwin.document.close();
- newwin.trans = function(t) { return t; };
- var newHead = newwin.document.getElementsByTagName('HEAD')[0];
-
- var headTags = document.getElementsByTagName('HEAD')[0].getElementsByTagName('SCRIPT');
- for(var i = 0; i < headTags.length; i++) {
-
- // Ignore runtime scripts
- if(!$(headTags[i]).attr('src')) continue;
-
- var script = newwin.document.createElement('script');
- script.setAttribute('type','text/javascript');
- script.setAttribute('src',$(headTags[i]).attr('src'));
- newHead.appendChild(script);
- }
- // Load self
- var script = newwin.document.createElement('script');
- script.setAttribute('type','text/javascript');
- script.text = "var vboxConsoleDetached = true;\
- function vboxConsoleCheckLoad() {\
- if(vboxLoader && jQuery) vboxConsoleDetachedOnload();\
- else setTimeout(\"vboxConsoleCheckLoad()\",1000);\
- }\
- function vboxConsoleDetachedOnload(){\
- l = new vboxLoader();\
- l.add('getConfig',function(d){$('#vboxPane').data('vboxConfig',d.responseData);});\
- l.addFile('panes/tabVMConsoleRDP.html',function(d){$('#vboxPane').children().remove();$('#vboxPane').append(d);$('#vboxTabVMConsole').css('display','');vboxRDPLoad();});\
- l.run();};\
- setTimeout(\"vboxConsoleCheckLoad()\",1000);";
- newHead.appendChild(script);
-
-}
-
-</script>
-
-
-<iframe style="height:0px;width:0px;visibility:hidden" src="about:blank">
- this frame prevents back forward cache in Safari
-</iframe>
-
+<!--
+
+ VM Console tab
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: tabVMConsoleRDP.html 595 2015-04-17 09:50:36Z imoore76 $
+
+ -->
+ <div id='vboxTabVMUnavailable' style='display: none' class='translate'>Virtual machine is not running or is not configured to accept RDP connections.</div>
+ <div id='vboxRDPFormContainer' style='padding-top: 8px; display: none'>
+ <form name="vboxRDPForm" id="vboxRDPForm">
+ <div class='vboxInvisible' id='vboxRDPConnParams'>
+
+ <span id='vboxConsoleLoginInfo'>
+ <span class='translate'>User name</span>: <input class='vboxRDPSet' type=text size=20 name=logonUsername value="">
+ <span class='translate'>Password</span>: <input class='vboxRDPSet' type=password size=20 name=logonPassword value="">
+ </span>
+
+ <span class='translate'>Requested desktop size</span>:
+ <select id='vboxRDPSize' name='vboxRDPSizeSelect'>
+ <option value='800x600'>800x600</option>
+ <option value='1024x768'>1024x768</option>
+ <option value='1280x1024'>1280x1024</option>
+ </select>
+
+ </div>
+ <p>
+ <input name=connectionButton type=button value="Connect" onclick="vboxRDPConnect();" />
+ <input type='text' id='vboxConsoleAddr' name='serverAddress' class='vboxRDPSet' value='' />
+ <!-- and hardcore web dev guys across the world frown ... //-->
+ &nbsp; &nbsp; &nbsp;
+ <input name=cadButton id='vboxConsoleCADButton' style='display: none' type=button value="Ctrl-Alt-Del" onClick="vboxRDPsendCAD()" />
+ <input id='vboxVRDPDetachBtn' style='display: none' name='detach' type='button' value='Detach' onClick="vboxRDPDetach();" />
+ <span id='vboxRDPStatus'></span>
+ </p>
+ </form>
+ </div>
+
+ <div id="FlashRDPContainer" style='width: 100%;'>
+ <div id="FlashRDP" style='width: 100%;'></div>
+ </div>
+
+
+<script type="text/javascript">
+
+var vboxRDPFlashLoaded = false;
+var vboxConsoleDetached = (vboxConsoleDetached || false);
+var vboxRDPFlashListenersAdded = false;
+
+$('#vboxRDPForm').on('submit',function(e){
+ e.stopPropagation();
+ e.preventDefault();
+ return false;
+});
+
+// Custom resolutions
+if($("#vboxPane").data('vboxConfig').consoleResolutions) {
+ var res = $("#vboxPane").data('vboxConfig').consoleResolutions;
+ // first one must be valid
+ if(res[0].split('x').length == 2) {
+ document.vboxRDPForm.vboxRDPSizeSelect.options.length = 0;
+ $(document.vboxRDPForm.vboxRDPSizeSelect).children().remove();
+ for(var i = 0; i < res.length; i++) {
+ document.vboxRDPForm.vboxRDPSizeSelect.options[i] = new Option(res[i],res[i]);
+ }
+ }
+}
+// Translations
+$('#vboxTabVMConsole').find(".translate").html(function(i,h){return trans(h,'VBoxConsoleWgt');}).removeClass('translate');
+$(document.vboxRDPForm.connectionButton).val(trans('Connect','VBoxConsoleWgt'));
+$(document.vboxRDPForm.cadButton).val(trans("Send Ctrl-Alt-Del",'VBoxConsoleWgt'));
+$(document.vboxRDPForm.vboxVRDPDetachBtn).val(trans("Detach",'VBoxConsoleWgt'));
+$("#vboxRDPStatus").html(trans("Loading ...",'UIVMDesktop'));
+if(vboxConsoleDetached) window.status = $("#vboxRDPStatus").text();
+
+// Disable / enable tab on selection list changes
+$('#vboxPane').on('vmSelectionListChanged', function(){
+
+ var vm = vboxChooser.getSingleSelected();
+
+ // Initially disable tab
+ $('#vboxTabVMConsole').parent().trigger('disableTab', ['vboxTabVMConsole']);
+
+ if(!vm || !vboxVMStates.isRunning(vm)) {
+ $('#vboxRDPFormContainer').css({'display':'none'});
+ $('#FlashRDPContainer').css({'visibility':'hidden'});
+ $('#vboxTabVMUnavailable').css({'display':'none'});
+
+ } else {
+
+ // VM is running, get runtime data
+ $.when(vboxVMDataMediator.getVMDataCombined(vm.id)).done(function(info) {
+
+ if(info.VRDEServerInfo && info.VRDEServerInfo.port > 0 && info.VRDEServer.VRDEExtPack.indexOf("VNC") == -1) {
+
+ $('#vboxRDPFormContainer').css({'display':''});
+ $('#FlashRDPContainer').css({'visibility':'visible'});
+ $('#vboxTabVMUnavailable').css({'display':'none'});
+
+ $('#vboxTabVMConsole').parent().trigger('enableTab', ['vboxTabVMConsole']);
+ }
+
+ });
+
+ }
+
+
+// Update on console info change
+}).on('vboxOnVRDEServerInfoChanged',function(e,eventData) {
+
+ // Shorthand
+ var vmid = eventData.machineId;
+ var VRDEServerInfo = eventData.enrichmentData;
+
+ var selVM = vboxChooser.getSingleSelected();
+ var enabled = (selVM && selVM.id == vmid && vboxVMStates.isRunning(selVM) && VRDEServerInfo && VRDEServerInfo.port > 0);
+
+ if(enabled) {
+
+ $.when(vboxVMDataMediator.getVMDataCombined(vmid)).done(function(info) {
+
+ enabled = (info.VRDEServerInfo && info.VRDEServerInfo.port > 0 && info.VRDEServer.VRDEExtPack.indexOf("VNC") == -1);
+
+ if(enabled) {
+
+ $('#vboxTabVMConsole').parent().trigger('enableTab', ['vboxTabVMConsole']);
+
+ $('#vboxRDPFormContainer').css({'display':''});
+ $('#FlashRDPContainer').css({'visibility':'visible'});
+ $('#vboxTabVMUnavailable').css({'display':'none'});
+
+
+ var chost = vboxGetVRDEHost(selVM);
+ chost+=':'+VRDEServerInfo.port;
+
+ if($(document.vboxRDPForm.serverAddress).val() != chost) {
+
+ // console host changed
+ vboxRDPDisconnect();
+
+ }
+ $(document.vboxRDPForm.serverAddress).val(chost);
+ } else {
+ $('#vboxTabVMConsole').parent().trigger('disableTab', ['vboxTabVMConsole']);
+ }
+
+ });
+
+ } else {
+
+ $('#vboxTabVMConsole').parent().trigger('disableTab', ['vboxTabVMConsole']);
+ }
+
+// Update tab on machine state change
+}).on('vboxOnMachineStateChanged', function(e, eventData){
+
+ var selVMId = vboxChooser.getSingleSelectedId();
+ var enabled = (selVMId == eventData.machineId && vboxVMStates.isRunning({'state':eventData.state}));
+
+ $('#vboxTabVMConsole').parent().trigger('disableTab', ['vboxTabVMConsole']);
+
+ if(enabled) {
+
+ // VM is running, get runtime data
+ $.when(vboxVMDataMediator.getVMRuntimeData(eventData.machineId)).done(function(vm) {
+
+ if(vm.VRDEServerInfo && vm.VRDEServerInfo.port > 0) {
+
+ $('#vboxTabVMConsole').parent().trigger('enableTab', ['vboxTabVMConsole']);
+
+ $('#vboxRDPFormContainer').css({'display':''});
+ $('#FlashRDPContainer').css({'visibility':'visible'});
+ $('#vboxTabVMUnavailable').css({'display':'none'});
+
+ }
+
+ });
+
+ }
+
+// Clean up local data storage when a machine is unregistered
+}).on('vboxMachineRegistered', function(e, eventData) {
+
+ if(!eventData.registered) {
+ vboxSetLocalDataItem('vbox'+eventData.machineId+'ConsoleSize','',true);
+ vboxSetLocalDataItem('vbox'+eventData.machineId+'ConsoleConnected','',true);
+ }
+});
+
+/*
+ * Populate console info values when this tab is shown
+ */
+
+$('#vboxTabVMConsole').on('show',function(){
+
+ var vm = vboxChooser.getSingleSelected();
+
+ if(!vm || !vboxVMStates.isRunning(vm)) {
+ $('#vboxRDPFormContainer').css({'display':'none'});
+ $('#FlashRDPContainer').css({'visibility':'hidden'});
+ $('#vboxTabVMUnavailable').css({'display':''});
+ return;
+ }
+
+ $('#vboxConsoleLoginInfo').hide();
+
+ /* Load runtime data. This will tell us if the VRDE server is actually active */
+ /* And details. This will give us info about the VRDEServer configuration */
+ $.when(vboxVMDataMediator.getVMRuntimeData(vm.id),vboxVMDataMediator.getVMDetails(vm.id))
+ .done(function(runtimeData, detailsData) {
+
+ /* Not active */
+ if(!(runtimeData.VRDEServerInfo && runtimeData.VRDEServerInfo.port > 0)) {
+ $('#vboxTabVMUnavailable').css({'display':''});
+ $('#vboxTabVMConsole').parent().trigger('disableTab',['vboxTabVMConsole']);
+ return;
+ }
+
+ // Hide login form if authtype is not set
+ if(detailsData.VRDEServer.authType != 'Null') {
+ $('#vboxConsoleLoginInfo').show();
+ }
+ $('#vboxConsoleLoginInfo').data('vboxVRDPauthType',detailsData.VRDEServer.authType);
+
+ /* Active */
+ $('#vboxRDPFormContainer').css({'display':''});
+ $('#FlashRDPContainer').css({'visibility':'visible'});
+ $('#vboxTabVMUnavailable').css({'display':'none'});
+
+ vboxRDPDisconnect();
+ $("#vboxRDPStatus").html('');
+ if(vboxConsoleDetached) window.status = $("#vboxRDPStatus").text();
+
+ var chost = vboxGetVRDEHost(detailsData);
+ chost+=':'+runtimeData.VRDEServerInfo.port;
+ $(document.vboxRDPForm.serverAddress).val(chost);
+
+ // Set default console size for this VM?
+ var cs = vboxGetLocalDataItem('vbox'+detailsData.id+'ConsoleSize');
+ if(cs) {
+ $(document.vboxRDPForm.vboxRDPSizeSelect).children('[value='+cs+']').first().prop('selected',true);
+ }
+
+ $('#vboxRDPFormContainer').css({'display':''});
+
+ vboxRDPLoad();
+ });
+
+});
+
+function vboxRDPLoad() {
+
+ var flashvars = {};
+ var params = {};
+ params.wmode="opaque";
+ params.menu="false";
+ params.bgcolor="#e9e9e9";
+ params.quality="low";
+ params.allowScriptAccess="always";
+ params.flashId="FlashRDP";
+
+ var attributes = {};
+ swfobject.embedSWF("rdpweb/RDPClientUI.swf", "FlashRDP", "100", "100", "9.0.0","", flashvars, params, attributes);
+
+ var ua = swfobject.ua;
+
+ // No flash installed
+ if(!ua || ua.pv[0] == '0') {
+ $('#vboxRDPFormContainer').css('display','none');
+ $("#FlashRDP").css('width','100%').html("The Adobe Flash plugin is not installed.");
+ }
+}
+
+function vboxRDPgetFlashProperty(name) {
+ var flash = RDPWebClient.getFlashById("FlashRDP");
+ try {
+ return flash.getProperty(name);
+ } catch (e) {
+ return '';
+ }
+}
+
+/*
+ * RDP client event handlers.
+ * They will be called when the flash movie is ready and some event occurs.
+ * Note: the function name must be the "flash_id" + "event name".
+ */
+function RDPWebEventLoaded(flashid) {
+
+ vboxRDPFlashLoaded = true;
+ $("#vboxRDPStatus").html(trans("Version",'UIVMDesktop') + ": " + vboxRDPgetFlashProperty("version"));
+ if(vboxConsoleDetached) window.status = $("#vboxRDPStatus").text();
+
+ var flash = RDPWebClient.getFlashById("FlashRDP");
+
+ // Apply keyboard layout
+ flash.setProperty("keyboardLayout", ($('#vboxPane').data('vboxConfig').consoleKeyboardLayout == 'DE' ? 'de' : 'en'));
+
+ // Only do this once
+ if(!vboxRDPFlashListenersAdded) {
+
+ if (window.addEventListener) {
+ window.addEventListener("contextmenu", function(event) { return RDPWebClient._MozillaContextMenu(event); }, true);
+ window.addEventListener("mousedown", function(event) { return RDPWebClient._MozillaMouse(event, true); }, true);
+ window.addEventListener("mouseup", function(event) { return RDPWebClient._MozillaMouse(event, false); }, true);
+ flash.addEventListener("mouseout", function(event) { return RDPWebClient._MozillaMouseOut(event); }, true);
+ } else {
+ document.oncontextmenu = function() { return RDPWebClient._IEContextMenu(); };
+ flash.parentNode.onmousedown = function() { return RDPWebClient._IEMouse(true); };
+ flash.parentNode.onmouseup = function() { return RDPWebClient._IEMouse(false); };
+ flash.onmouseout=function() {return RDPWebClient._IEMouseOut(); };
+ }
+
+ vboxRDPFlashListenersAdded = true;
+
+ }
+
+ // Connect if "detached"
+ if(vboxConsoleDetached) {
+ $('#vboxTabVMUnavailable').css({'display':'none'});
+ $('#vboxRDPFormContainer').css({'display':'none'});
+ $('#vboxRDPSize').val($(window.opener.document.getElementById('vboxRDPSize')).val());
+ $('#vboxRDPFormContainer').find(".vboxRDPSet").each(function(){
+ $(this).val(window.opener.document.forms['vboxRDPForm'][$(this).attr('name')].value);
+ });
+ $(window).on('resize',function(){
+ var flash = RDPWebClient.getFlashById("FlashRDP");
+ var wh = [ $(window).width()-2, $(window).height()-2 ];
+ $(flash).css({'height':wh[1]+'px','width':wh[0]+'px'});
+ $('#FlashRDP').css({'height':wh[1]+'px','width':wh[0]+'px'});
+ flash.setProperty("displayWidth", wh[0]);
+ flash.setProperty("displayHeight", wh[1]);
+ $(flash).css({'display':'none'});
+ $(flash).css({'display':'block'});
+ });
+ vboxRDPConnect();
+ } else {
+
+ $('#vboxRDPConnParams').show();
+ $('#vboxRDPFormContainer').css('display','');
+
+ // Did not explicitly disconnect from this VM and has no auth settings so reconnect
+ if(vboxGetLocalDataItem('vbox'+vboxChooser.getSingleSelectedId()+'ConsoleConnected') == 'true' && $('#vboxConsoleLoginInfo').data('vboxVRDPauthType') == 'Null') {
+ document.vboxRDPForm.connectionButton.click();
+ }
+ }
+}
+
+function RDPWebEventConnected(flashId) {
+ $("#vboxRDPStatus").data('vmConnected',true);
+ $("#vboxRDPStatus").html(trans("Connected to %1",'VBoxConsoleWgt').replace('%1',$(document.vboxRDPForm.serverAddress).val()));
+ if(vboxConsoleDetached) window.status = $("#vboxRDPStatus").text();
+ $('#vboxConsoleCADButton').show();
+ $('#vboxVRDPDetachBtn').show();
+}
+
+function RDPWebEventServerRedirect(flashId) {
+ $("#vboxRDPStatus").html(trans("Redirection by %1",'VBoxConsoleWgt').replace('%1',vboxRDPgetFlashProperty("serverAddress")));
+ if(vboxConsoleDetached) window.status = $("#vboxRDPStatus").text();
+}
+
+function RDPWebEventDisconnected(flashId) {
+
+ $("#vboxRDPStatus").data('vmConnected',false);
+
+ $('#vboxRDPConnParams').show();
+ $('#vboxVRDPDetachBtn').hide();
+
+ /* RDP connection has been lost */
+ $("#vboxRDPStatus").html(trans("Disconnect reason",'VBoxConsoleWgt')+":\n" + vboxRDPgetFlashProperty("lastError"));
+ if(vboxConsoleDetached) {
+ alert($("#vboxRDPStatus").text());
+ window.close();
+ }
+ document.vboxRDPForm.connectionButton.value = trans("Connect",'VBoxConsoleWgt');
+ document.vboxRDPForm.connectionButton.onclick=function() {
+ vboxSetLocalDataItem('vbox'+vboxChooser.getSingleSelectedId()+'ConsoleSize',$('#vboxRDPSize').val(),true);
+ vboxSetLocalDataItem('vbox'+vboxChooser.getSingleSelectedId()+'ConsoleConnected','true',true);
+ return vboxRDPConnect();
+ };
+ $('#vboxConsoleAddr').css('display','');
+ $('#vboxConsoleCADButton').hide();
+
+ $('#vboxRDPFormContainer').css({'display':''});
+}
+
+
+function vboxRDPConnect() {
+
+ vboxSetLocalDataItem('vbox'+vboxChooser.getSingleSelectedId()+'ConsoleSize',$('#vboxRDPSize').val(), true);
+
+ if (!vboxRDPFlashLoaded) return false;
+
+ var flash = RDPWebClient.getFlashById("FlashRDP");
+ if (!flash) return;
+
+ $('#vboxRDPConnParams').hide();
+
+ document.vboxRDPForm.connectionButton.value = trans("Disconnect",'VBoxConsoleWgt');
+ document.vboxRDPForm.connectionButton.onclick=function(){
+ vboxSetLocalDataItem('vbox'+vboxChooser.getSingleSelectedId()+'ConsoleConnected');
+ return vboxRDPDisconnect();
+ };
+
+ $('#vboxConsoleAddr').css('display','none');
+ $('#FlashRDPContainer').css({'visibility':'visible'});
+
+
+ var flash = RDPWebClient.getFlashById("FlashRDP");
+
+ var wh = null;
+ if(vboxConsoleDetached) {
+ wh = [ $(document).width()-2, $(document).height()-2 ];
+ } else {
+ wh = $('#vboxRDPSize').val().split('x');
+ }
+ $(flash).css({'height':wh[1]+'px','width':wh[0]+'px'});
+ flash.setProperty("displayWidth", wh[0]);
+ flash.setProperty("displayHeight", wh[1]);
+
+ /* Setup the client parameters. */
+ $('#vboxRDPFormContainer').find(".vboxRDPSet").each(function(){
+ flash.setProperty($(this).attr('name'),$(this).val());
+ });
+
+ $("#vboxRDPStatus").html(trans("Connecting to %1",'VBoxConsoleWgt').replace('%1',$(document.vboxRDPForm.serverAddress).val()) + "...");
+ if(vboxConsoleDetached) window.status = $("#vboxRDPStatus").html();
+
+ /* Establish the connection. */
+ flash.connect();
+
+}
+
+function vboxRDPDisconnect() {
+ var flash = RDPWebClient.getFlashById("FlashRDP");
+ if (flash) try { flash.disconnect(); } catch (err) {};
+ /* Restore the "Connect" form. And resize flash*/
+ document.vboxRDPForm.connectionButton.value = trans("Connect",'VBoxConsoleWgt');
+ document.vboxRDPForm.connectionButton.onclick=function() {
+ vboxSetLocalDataItem('vbox'+vboxChooser.getSingleSelectedId()+'ConsoleConnected','true',true);
+ vboxSetLocalDataItem('vbox'+vboxChooser.getSingleSelectedId()+'ConsoleSize',$('#vboxRDPSize').val(),true);
+ vboxRDPConnect();this.blur();
+ };
+ $('#vboxConsoleCADButton').hide();
+ $(flash).css({'height':'100px','width':'100px'});
+ $('#vboxConsoleAddr').css('display','');
+
+}
+
+function vboxRDPsendCAD() {
+ var flash = RDPWebClient.getFlashById("FlashRDP");
+ if (flash) flash.keyboardSendCAD();
+}
+
+function vboxRDPDetach() {
+
+ vboxRDPDisconnect();
+
+ var vmname = vboxChooser.getSingleSelected().name;
+ var wh = $('#vboxRDPSize').val().split('x');
+ var newwin = window.open('about:blank','vboxConsoleDetachedWin'+vmname.replace(/[^a-zA-Z0-9]/g,'_'),'toolbar=0,menubar=0,location=0,directories=0,status=true,resize=true,width='+(parseInt(wh[0])+20)+',height='+(parseInt(wh[1])+20)+'');
+
+ newwin.document.open();
+ newwin.document.write('<html><head><title>'+vmname + ' - ' + trans('Console','UIVMDesktop')+'</title></head><body style="margin: 0px; border: 0px; padding: 0px; overflow: hidden;"><div style="margin: 0px; border: 0px; padding: 0px" id="vboxPane"><img src="images/spinner.gif" /></div></body></html>');
+ newwin.document.close();
+ newwin.trans = function(t) { return t; };
+ var newHead = newwin.document.getElementsByTagName('HEAD')[0];
+
+ var headTags = document.getElementsByTagName('HEAD')[0].getElementsByTagName('SCRIPT');
+ for(var i = 0; i < headTags.length; i++) {
+
+ // Ignore runtime scripts
+ if(!$(headTags[i]).attr('src')) continue;
+
+ var script = newwin.document.createElement('script');
+ script.setAttribute('type','text/javascript');
+ script.setAttribute('src',$(headTags[i]).attr('src'));
+ newHead.appendChild(script);
+ }
+ // Load self
+ var script = newwin.document.createElement('script');
+ script.setAttribute('type','text/javascript');
+ script.text = "var vboxConsoleDetached = true;\
+ function vboxConsoleCheckLoad() {\
+ if(vboxLoader && jQuery) vboxConsoleDetachedOnload();\
+ else setTimeout(\"vboxConsoleCheckLoad()\",1000);\
+ }\
+ function vboxConsoleDetachedOnload(){\
+ l = new vboxLoader();\
+ l.add('getConfig',function(d){$('#vboxPane').data('vboxConfig',d.responseData);});\
+ l.addFile('panes/tabVMConsoleRDP.html',function(d){$('#vboxPane').children().remove();$('#vboxPane').append(d);$('#vboxTabVMConsole').css('display','');vboxRDPLoad();});\
+ l.run();};\
+ setTimeout(\"vboxConsoleCheckLoad()\",1000);";
+ newHead.appendChild(script);
+
+}
+
+</script>
+
+
+<iframe style="height:0px;width:0px;visibility:hidden" src="about:blank">
+ this frame prevents back forward cache in Safari
+</iframe>
+
diff --git a/panes/tabVMConsoleVNC.html b/panes/tabVMConsoleVNC.html
index f1c416f..e792c17 100644
--- a/panes/tabVMConsoleVNC.html
+++ b/panes/tabVMConsoleVNC.html
@@ -1,189 +1,189 @@
-<!--
-
- VM Console tab
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: tabVMConsoleVNC.html 595 2015-04-17 09:50:36Z imoore76 $
-
- -->
-<form name="vboxVNCForm" id="vboxVNCForm">
- <span class='translate'>Requested desktop size</span>:
- <select id='vboxVNCSize' name='vboxVNCSizeSelect'>
- <option value='800x600'>800x600</option>
- <option value='1024x768'>1024x768</option>
- <option value='1280x1024'>1280x1024</option>
- </select>
- <input id='vboxVNCDetachBtn' name='detach' type='button' value='Detach' onClick="vboxVNCDetach();" />
-</form>
-<div id='vboxVNCAppletContainer'>
-</div>
-<script type='text/javascript'>
-
-//Custom resolutions
-if($("#vboxPane").data('vboxConfig').consoleResolutions) {
- var res = $("#vboxPane").data('vboxConfig').consoleResolutions;
- // first one must be valid
- if(res[0].split('x').length == 2) {
- document.vboxVNCForm.vboxVNCSizeSelect.options.length = 0;
- $(document.vboxVNCForm.vboxVNCSizeSelect).children().remove();
- for(var i = 0; i < res.length; i++) {
- document.vboxVNCForm.vboxVNCSizeSelect.options[i] = new Option(res[i],res[i]);
- }
- }
- $(document.vboxVNCForm.vboxVNCSizeSelect).on('change',function(){
- var wh = $(this).val().split('x');
- var width = wh[0];
- var height = wh[1];
-
- $('#vboxVNCAppletContainer').children().first().attr({'height':height,'width':width});
-
- vboxSetLocalDataItem('vbox'+vboxChooser.getSingleSelectedId()+'ConsoleSize',$(this).val(),true);
- });
-}
-
-// Translate
-$(document.vboxVNCForm.vboxVNCDetachBtn).val(trans("Detach",'VBoxConsoleWgt'));
-
-//Disable / enable tab on selection list changes
-$('#vboxPane').on('vmSelectionListChanged', function(){
-
- var vm = vboxChooser.getSingleSelected();
-
- // Initially disable tab
- $('#vboxTabVMConsole').parent().trigger('disableTab', ['vboxTabVMConsole']);
-
- if(vm && vboxVMStates.isRunning(vm)) {
-
- // VM is running, get runtime data
- $.when(vboxVMDataMediator.getVMDataCombined(vm.id)).done(function(info) {
-
- if(info.VRDEServerInfo && info.VRDEServerInfo.port > 0) {
-
- $('#vboxTabVMConsole').parent().trigger('enableTab', ['vboxTabVMConsole']);
-
- }
-
- });
-
- }
-
-
-// Update on console info change
-}).on('vboxOnVRDEServerInfoChanged',function(e,eventData) {
-
- // Shorthand
- var vmid = eventData.machineId;
- var VRDEServerInfo = eventData.enrichmentData;
-
- var selVM = vboxChooser.getSingleSelected();
- var enabled = (selVM && selVM.id == vmid && vboxVMStates.isRunning(selVM) && VRDEServerInfo && VRDEServerInfo.port > 0);
-
- if(enabled) {
-
- $.when(vboxVMDataMediator.getVMDataCombined(vmid)).done(function(info) {
-
- enabled = (info.VRDEServerInfo && info.VRDEServerInfo.port > 0);
-
- if(enabled) {
-
- $('#vboxTabVMConsole').parent().trigger('enableTab', ['vboxTabVMConsole']);
-
- var chost = vboxGetVRDEHost(selVM);
- chost+=':'+VRDEServerInfo.port;
-
- } else {
- $('#vboxTabVMConsole').parent().trigger('disableTab', ['vboxTabVMConsole']);
- }
-
- });
-
- } else {
-
- $('#vboxTabVMConsole').parent().trigger('disableTab', ['vboxTabVMConsole']);
- }
-
-// Update tab on machine state change
-}).on('vboxOnMachineStateChanged', function(e, eventData){
-
- var selVMId = vboxChooser.getSingleSelectedId();
- var enabled = (selVMId == eventData.machineId && vboxVMStates.isRunning({'state':eventData.state}));
-
- $('#vboxTabVMConsole').parent().trigger('disableTab', ['vboxTabVMConsole']);
-
- if(enabled) {
-
- // VM is running, get runtime data
- $.when(vboxVMDataMediator.getVMRuntimeData(eventData.machineId)).done(function(vm) {
-
- if(vm.VRDEServerInfo && vm.VRDEServerInfo.port > 0) {
-
- $('#vboxTabVMConsole').parent().trigger('enableTab', ['vboxTabVMConsole']);
-
- }
-
- });
-
- }
-
-// Clean up local data storage when a machine is unregistered
-}).on('vboxMachineRegistered', function(e, eventData) {
-
- if(!eventData.registered) {
- vboxSetLocalDataItem('vbox'+eventData.machineId+'ConsoleSize','',true);
- vboxSetLocalDataItem('vbox'+eventData.machineId+'ConsoleConnected','',true);
- }
-});
-
-/*
- * Populate console info values when this tab is shown
- */
-
-$('#vboxTabVMConsole').on('show',function(){
-
- var vm = vboxChooser.getSingleSelected();
-
- /* Load runtime data. This will tell us if the VRDE server is actually active */
- /* And details. This will give us info about the VRDEServer configuration */
- $.when(vboxVMDataMediator.getVMRuntimeData(vm.id),vboxVMDataMediator.getVMDetails(vm.id))
- .done(function(runtimeData, detailsData) {
-
- /* Not active */
- if(!(runtimeData.VRDEServerInfo && runtimeData.VRDEServerInfo.port > 0)) {
- $('#vboxTabVMConsole').parent().trigger('disableTab',['vboxTabVMConsole']);
- return;
- }
-
- // Set default console size for this VM?
- var cs = vboxGetLocalDataItem('vbox'+detailsData.id+'ConsoleSize');
- if(cs) {
- $(document.vboxVNCForm.vboxVNCSizeSelect).children('[value='+cs+']').first().prop('selected',true);
- }
-
- var wh = $(document.vboxVNCForm.vboxVNCSizeSelect).val().split('x');
- var width = wh[0];
- var height = wh[1];
-
- var chost = vboxGetVRDEHost(runtimeData);
-
- $('#vboxVNCAppletContainer').empty().html('<APPLET CODE="VncViewer.class" ARCHIVE="tightvnc/VncViewer.jar" width="'+width+'" height="'+height+'"><PARAM NAME="PORT" VALUE="'+runtimeData.VRDEServerInfo.port+'"><PARAM NAME="HOST" VALUE="'+chost+'"></APPLET>');
-
- });
-
-});
-
-function vboxVNCDetach() {
-
- var vmname = vboxChooser.getSingleSelected().name;
-
- var wh = $('#vboxVNCSize').val().split('x');
- var newwin = window.open('about:blank','vboxConsoleDetachedWin'+vmname.replace(/[^a-zA-Z0-9]/g,'_'),'toolbar=0,menubar=0,location=0,directories=0,status=true,resize=true,width='+(parseInt(wh[0])+20)+',height='+(parseInt(wh[1])+20)+'');
-
- newwin.document.open();
- newwin.document.write('<html><head><title>'+vmname + ' - ' + trans('Console','UIVMDesktop')+'</title></head><body style="margin: 0px; border: 0px; padding: 0px; overflow: hidden;"><div style="margin: 0px; border: 0px; padding: 0px" id="vboxPane">'+$('#vboxVNCAppletContainer').html()+'</div></body></html>');
- newwin.document.close();
- newwin.trans = function(t) { return t; };
-
-}
-
-
+<!--
+
+ VM Console tab
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: tabVMConsoleVNC.html 595 2015-04-17 09:50:36Z imoore76 $
+
+ -->
+<form name="vboxVNCForm" id="vboxVNCForm">
+ <span class='translate'>Requested desktop size</span>:
+ <select id='vboxVNCSize' name='vboxVNCSizeSelect'>
+ <option value='800x600'>800x600</option>
+ <option value='1024x768'>1024x768</option>
+ <option value='1280x1024'>1280x1024</option>
+ </select>
+ <input id='vboxVNCDetachBtn' name='detach' type='button' value='Detach' onClick="vboxVNCDetach();" />
+</form>
+<div id='vboxVNCAppletContainer'>
+</div>
+<script type='text/javascript'>
+
+//Custom resolutions
+if($("#vboxPane").data('vboxConfig').consoleResolutions) {
+ var res = $("#vboxPane").data('vboxConfig').consoleResolutions;
+ // first one must be valid
+ if(res[0].split('x').length == 2) {
+ document.vboxVNCForm.vboxVNCSizeSelect.options.length = 0;
+ $(document.vboxVNCForm.vboxVNCSizeSelect).children().remove();
+ for(var i = 0; i < res.length; i++) {
+ document.vboxVNCForm.vboxVNCSizeSelect.options[i] = new Option(res[i],res[i]);
+ }
+ }
+ $(document.vboxVNCForm.vboxVNCSizeSelect).on('change',function(){
+ var wh = $(this).val().split('x');
+ var width = wh[0];
+ var height = wh[1];
+
+ $('#vboxVNCAppletContainer').children().first().attr({'height':height,'width':width});
+
+ vboxSetLocalDataItem('vbox'+vboxChooser.getSingleSelectedId()+'ConsoleSize',$(this).val(),true);
+ });
+}
+
+// Translate
+$(document.vboxVNCForm.vboxVNCDetachBtn).val(trans("Detach",'VBoxConsoleWgt'));
+
+//Disable / enable tab on selection list changes
+$('#vboxPane').on('vmSelectionListChanged', function(){
+
+ var vm = vboxChooser.getSingleSelected();
+
+ // Initially disable tab
+ $('#vboxTabVMConsole').parent().trigger('disableTab', ['vboxTabVMConsole']);
+
+ if(vm && vboxVMStates.isRunning(vm)) {
+
+ // VM is running, get runtime data
+ $.when(vboxVMDataMediator.getVMDataCombined(vm.id)).done(function(info) {
+
+ if(info.VRDEServerInfo && info.VRDEServerInfo.port > 0) {
+
+ $('#vboxTabVMConsole').parent().trigger('enableTab', ['vboxTabVMConsole']);
+
+ }
+
+ });
+
+ }
+
+
+// Update on console info change
+}).on('vboxOnVRDEServerInfoChanged',function(e,eventData) {
+
+ // Shorthand
+ var vmid = eventData.machineId;
+ var VRDEServerInfo = eventData.enrichmentData;
+
+ var selVM = vboxChooser.getSingleSelected();
+ var enabled = (selVM && selVM.id == vmid && vboxVMStates.isRunning(selVM) && VRDEServerInfo && VRDEServerInfo.port > 0);
+
+ if(enabled) {
+
+ $.when(vboxVMDataMediator.getVMDataCombined(vmid)).done(function(info) {
+
+ enabled = (info.VRDEServerInfo && info.VRDEServerInfo.port > 0);
+
+ if(enabled) {
+
+ $('#vboxTabVMConsole').parent().trigger('enableTab', ['vboxTabVMConsole']);
+
+ var chost = vboxGetVRDEHost(selVM);
+ chost+=':'+VRDEServerInfo.port;
+
+ } else {
+ $('#vboxTabVMConsole').parent().trigger('disableTab', ['vboxTabVMConsole']);
+ }
+
+ });
+
+ } else {
+
+ $('#vboxTabVMConsole').parent().trigger('disableTab', ['vboxTabVMConsole']);
+ }
+
+// Update tab on machine state change
+}).on('vboxOnMachineStateChanged', function(e, eventData){
+
+ var selVMId = vboxChooser.getSingleSelectedId();
+ var enabled = (selVMId == eventData.machineId && vboxVMStates.isRunning({'state':eventData.state}));
+
+ $('#vboxTabVMConsole').parent().trigger('disableTab', ['vboxTabVMConsole']);
+
+ if(enabled) {
+
+ // VM is running, get runtime data
+ $.when(vboxVMDataMediator.getVMRuntimeData(eventData.machineId)).done(function(vm) {
+
+ if(vm.VRDEServerInfo && vm.VRDEServerInfo.port > 0) {
+
+ $('#vboxTabVMConsole').parent().trigger('enableTab', ['vboxTabVMConsole']);
+
+ }
+
+ });
+
+ }
+
+// Clean up local data storage when a machine is unregistered
+}).on('vboxMachineRegistered', function(e, eventData) {
+
+ if(!eventData.registered) {
+ vboxSetLocalDataItem('vbox'+eventData.machineId+'ConsoleSize','',true);
+ vboxSetLocalDataItem('vbox'+eventData.machineId+'ConsoleConnected','',true);
+ }
+});
+
+/*
+ * Populate console info values when this tab is shown
+ */
+
+$('#vboxTabVMConsole').on('show',function(){
+
+ var vm = vboxChooser.getSingleSelected();
+
+ /* Load runtime data. This will tell us if the VRDE server is actually active */
+ /* And details. This will give us info about the VRDEServer configuration */
+ $.when(vboxVMDataMediator.getVMRuntimeData(vm.id),vboxVMDataMediator.getVMDetails(vm.id))
+ .done(function(runtimeData, detailsData) {
+
+ /* Not active */
+ if(!(runtimeData.VRDEServerInfo && runtimeData.VRDEServerInfo.port > 0)) {
+ $('#vboxTabVMConsole').parent().trigger('disableTab',['vboxTabVMConsole']);
+ return;
+ }
+
+ // Set default console size for this VM?
+ var cs = vboxGetLocalDataItem('vbox'+detailsData.id+'ConsoleSize');
+ if(cs) {
+ $(document.vboxVNCForm.vboxVNCSizeSelect).children('[value='+cs+']').first().prop('selected',true);
+ }
+
+ var wh = $(document.vboxVNCForm.vboxVNCSizeSelect).val().split('x');
+ var width = wh[0];
+ var height = wh[1];
+
+ var chost = vboxGetVRDEHost(runtimeData);
+
+ $('#vboxVNCAppletContainer').empty().html('<APPLET CODE="VncViewer.class" ARCHIVE="tightvnc/VncViewer.jar" width="'+width+'" height="'+height+'"><PARAM NAME="PORT" VALUE="'+runtimeData.VRDEServerInfo.port+'"><PARAM NAME="HOST" VALUE="'+chost+'"></APPLET>');
+
+ });
+
+});
+
+function vboxVNCDetach() {
+
+ var vmname = vboxChooser.getSingleSelected().name;
+
+ var wh = $('#vboxVNCSize').val().split('x');
+ var newwin = window.open('about:blank','vboxConsoleDetachedWin'+vmname.replace(/[^a-zA-Z0-9]/g,'_'),'toolbar=0,menubar=0,location=0,directories=0,status=true,resize=true,width='+(parseInt(wh[0])+20)+',height='+(parseInt(wh[1])+20)+'');
+
+ newwin.document.open();
+ newwin.document.write('<html><head><title>'+vmname + ' - ' + trans('Console','UIVMDesktop')+'</title></head><body style="margin: 0px; border: 0px; padding: 0px; overflow: hidden;"><div style="margin: 0px; border: 0px; padding: 0px" id="vboxPane">'+$('#vboxVNCAppletContainer').html()+'</div></body></html>');
+ newwin.document.close();
+ newwin.trans = function(t) { return t; };
+
+}
+
+
</script> \ No newline at end of file
diff --git a/panes/tabVMDetails.html b/panes/tabVMDetails.html
index 23df5c6..bc3de84 100644
--- a/panes/tabVMDetails.html
+++ b/panes/tabVMDetails.html
@@ -1,752 +1,752 @@
-<!--
-
- VM Details Pane
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: tabVMDetails.html 596 2015-04-19 11:50:53Z imoore76 $
-
- -->
-<div id='vboxTabVMDetails' style='height: 100%; width: 100%; display: none;' class='vboxInvisible'>
-
- <!-- VM Details -->
- <div id='vboxVMDetails' style='height: 100%; width: 100%; display: table; min-height:100px;' class='vboxInvisible'></div>
-
- <!-- Loading... -->
- <div id='vboxDetailsLoading' class='vboxInvisible' style='#position:absolute;#top:50%;display:none;vertical-align:middle;width:100%;height:100%;padding:0px;margin:0px'>
- <div style='#position:relative;#top:-50%;padding:4px;text-align:center;width:100%'>
- <span class='ui-corner-all translate' style='padding:8px;background:#fff;border:2px solid #ddd'>Loading ...</span>
- </div>
- </div>
-
- <!-- Welcome -->
- <div id='vboxDetailsWelcome' style='#position:absolute;#top:50%;display:table-cell;vertical-align:middle;width:50%;height:50%;text-align:center'>
- <div style='#position:relative;#top:-50%;padding:0px;text-align:center;width:100%'>
- <img src='images/vbox/welcome.png' />
- </div>
- </div>
-
-<script type='text/javascript'>
-
-// Translate loading div
-$('#vboxDetailsLoading').find('span.translate').html(trans('Loading ...','UIVMDesktop')).removeClass('translate');
-
-// Last selection list was none
-$('#vboxTabVMDetails').data('vboxLastSelectionList',[]);
-
-// Listen for events
-/////////////////////////////
-$('#vboxPane').on('vmSelectionListChanged',function(){
-
- // No VMs?
- if(!vboxChooser || vboxChooser.selectionMode == vboxSelectionModeNone) {
-
- // Hide all tab children first
- $('#vboxTabVMDetails').css({'display':'table','width':'100%'}).children().hide();
-
- // Display Welcome div
- $('#vboxDetailsWelcome').show().css('display','table-cell');
-
- $('#vboxTabVMDetails').data('showingWelcome', true);
-
- $('#vboxTabVMDetails').data('vboxLastSelectionList',[]);
-
- return;
-
- // Were we showing the welcome screen before?
- } else if($('#vboxTabVMDetails').data('showingWelcome')) {
-
- $('#vboxTabVMDetails').css({'display':''})
- .data({'showingWelcome':false}).children().hide();
- $('#vboxVMDetails').html('').css({'display':''});
-
- }
-
- // We have VMs to load
- if(vboxChooser.selectionMode != vboxSelectionModeNone) {
-
- var targetDiv = $('#vboxVMDetails');
-
- // Loading scren
- if(vboxChooser.selectedVMs.length == 1 && $('#vboxTabVMDetails').css('display') != 'none') {
-
- // Hide all tab children first
- $('#vboxTabVMDetails').css({'display':'table','width':'100%'}).children().hide();
-
- // Display loading div
- $('#vboxDetailsLoading').show().css('display','table-cell');
- }
-
- if(vboxChooser.getSingleSelectedId() == 'host') {
-
- $('#vboxTabVMDetails').data('vboxLastSelectionList',['host']);
-
- targetDiv.children().empty().remove();
-
- $.when(vboxVMDataMediator.getVMDetails('host')).done(function(d) {
-
- // Hide loading screen
- targetDiv.siblings().hide();
- targetDiv.show();
-
-
- __vboxDisplayHostDetailsData(d, targetDiv);
-
- });
-
- return;
- }
-
- // Remove anything that is not a details table
- targetDiv.children(':not(table)').remove();
-
- // Last list of selected vms
- var lastSelectionList = $('#vboxTabVMDetails').data('vboxLastSelectionList');
- $('#vboxTabVMDetails').data('vboxLastSelectionList', vboxChooser.selectedVMs);
-
- // Remove any that aren't in list
- $(lastSelectionList).not(vboxChooser.selectedVMs).each(function(idx,vmid){
- $('#vboxVMDetails .vboxVMDetailsBox-vm-'+vmid).empty().remove();
- });
-
- // Placeholders so vms are listed in order
- for(var i = 0; i < vboxChooser.selectedVMs.length; i++) {
-
- if(jQuery.inArray(vboxChooser.selectedVMs[i], lastSelectionList) > -1) {
- $('#vboxDetailsGeneralTable-'+vboxChooser.selectedVMs[i]).detach().appendTo(targetDiv);
- } else {
- $('<table />').attr({'id':'vboxDetailsGeneralTable-'+vboxChooser.selectedVMs[i],'class':'vboxInvisible vboxVMDetailsBox-vm-'+vboxChooser.selectedVMs[i],'style':'display:none'})
- .appendTo(targetDiv);
- }
-
-
- }
-
- var oneLoaded = false;
- var skipTable = false; // skip drawing multi-section details table
- for(var i = 0; i < vboxChooser.selectedVMs.length; i++) {
-
- // Already drawn and we are showing more than one vm
- if(jQuery.inArray(vboxChooser.selectedVMs[i], lastSelectionList) > -1) {
-
- if(vboxChooser.selectedVMs.length > 1) {
- oneLoaded = true;
- targetDiv.siblings().hide();
- targetDiv.show();
- continue;
- }
- skipTable = true;
- }
-
- $.when(vboxChooser.selectedVMs[i], vboxVMDataMediator.getVMDataCombined(vboxChooser.selectedVMs[i])).done(function(vmid, d) {
-
- // Remove placeholder and don't draw
- // if this vm is no longer selected
- if(!d || !vboxChooser.isVMSelected(vmid)) {
- $('#vboxDetailsGeneralTable-'+vmid).empty().remove();
- return;
- }
-
- // Clear target div if we only have one vm
- if(!oneLoaded) {
- oneLoaded = true;
- targetDiv.siblings().hide();
- targetDiv.show();
- }
-
-
- __vboxDisplayDetailsData(d, (vboxChooser.selectedVMs.length > 1), targetDiv, skipTable);
-
- });
- }
-
-
- }
-
-
-/////////////////////////////////
-//
-// Redraw section logic
-//
-//////////////////////////////////
-}).on('vboxEvents', function(e, eventList) {
-
- // Multiple vms selected
- var multiSelect = (vboxChooser.selectedVMs.length > 1);
-
- // Keep track of details to redraw
- var vmRedrawDetails = {};
- var vmRedrawSections = {};
- var vmTriggerEventSection = {};
-
- // Each event in list
- for(var i = 0; i < eventList.length; i++) {
-
- // Nothing to do if VM is not selected
- if(!eventList[i].machineId || !vboxChooser.isVMSelected(eventList[i].machineId))
- continue;
-
-
-
- switch(eventList[i].eventType) {
-
- // These trigger complete redraws
- case 'OnMachineDataChanged':
- vmRedrawDetails[eventList[i].machineId] = true;
- break;
-
- default:
-
- // already redrawing all vm details
- if(vmRedrawDetails[eventList[i].machineId])
- break;
-
- // Check for specific section redraws or events
- for(var s in vboxVMDetailsSections) {
-
- if(typeof(s) != 'string') continue;
- if(multiSelect && !vboxVMDetailsSections[s].multiSelectDetailsTable) continue;
-
- // Redraw this section?
- if(vboxVMDetailsSections[s].redrawMachineEvents && jQuery.inArray(eventList[i].eventType, vboxVMDetailsSections[s].redrawMachineEvents) > -1) {
-
- if(!vmRedrawSections[eventList[i].machineId])
- vmRedrawSections[eventList[i].machineId] = {};
-
- vmRedrawSections[eventList[i].machineId][s] = true;
-
- // Specific event handler
- } else if(vboxVMDetailsSections[s]['vboxEvent'+eventList[i].eventType]) {
-
- if(!vmTriggerEventSection[eventList[i].machineId])
- vmTriggerEventSection[eventList[i].machineId] = {};
- if(!vmTriggerEventSection[eventList[i].machineId][s])
- vmTriggerEventSection[eventList[i].machineId][s] = [];
-
- vmTriggerEventSection[eventList[i].machineId][s][vmTriggerEventSection[eventList[i].machineId][s].length] = eventList[i];
- }
- }
-
- } // </ switch eventType >
-
-
- } // </ foreach event >
-
-
- // Target for actions
- var targetDiv = $('#vboxVMDetails');
-
-
- // Redraw each details table
- /////////////////////////////////
- for(var vmid in vmRedrawDetails) {
-
- if(typeof(vmid) != 'string') continue;
-
- // Get and show details and runtime data again
- $.when(vboxVMDataMediator.getVMDataCombined(vmid)).done(function(d) {
-
- // Do nothing if VM is no longer selected
- if(!vboxChooser.isVMSelected(d.id)) return;
-
- // if there's only one, we'll have to remove existing data
- if(vboxChooser.selectedVMs.length == 1) {
- targetDiv.children().empty().remove();
- }
- // Special case for host
- if(d.id == 'host') __vboxDisplayHostDetailsData(d, targetDiv);
- else __vboxDisplayDetailsData(d, (vboxChooser.selectedVMs.length > 1), targetDiv);
- });
-
- };
-
- // Redraw each section
- ////////////////////////////
- for(var vmid in vmRedrawSections) {
-
- if(typeof(vmid) != 'string') continue;
- if(vmRedrawDetails[vmid]) continue; // already redrew entire details
-
- // Get and show details and runtime data again
- $.when(vboxVMDataMediator.getVMDataCombined(vmid),vmRedrawSections[vmid]).done(function(d,sections) {
-
- // Do nothing if VM is no longer selected
- if(!vboxChooser.isVMSelected(d.id)) return;
-
- // Redraw each section in list
- for(var s in sections) {
-
- if(typeof(s) != 'string') continue;
-
- $('#vboxDetailsSectionId-'+s+'-'+d.id).replaceWith(
- __vboxCreateDetailsSection(d, s)
- );
-
- if(vboxVMDetailsSections[s].onRender)
- vboxVMDetailsSections[s].onRender(d);
-
- }
- });
-
- }
-
- // Specific event handlers for each section
- for(var vmid in vmTriggerEventSection) {
-
- if(typeof(vmid) != 'string') continue;
- if(vmRedrawDetails[vmid]) continue; // already redrew entire details
-
- // Do nothing if VM is no longer selected
- if(!vboxChooser.isVMSelected(vmid)) return;
-
- for(var s in vmTriggerEventSection[vmid]) {
-
- if(typeof(s) != 'string') continue;
- if(vmRedrawSections[vmid] && vmRedrawSections[vmid][s]) continue; // already redrew this section
-
- // Call each event handler
- for(var i = 0; i < vmTriggerEventSection[vmid][s].length; i++) {
- var event = vmTriggerEventSection[vmid][s][i];
- vboxVMDetailsSections[s]['vboxEvent'+event.eventType](event);
- }
-
-
- }
-
- }
-
-});
-
-// Hide context menus when hiding tab
-$('#vboxTabVMDetails').on('hide',function(){
- $('ul.contextMenu').hide();
-});
-
-
-
-//Base function that returns a table row of machine detail data
-//Called from other functions
-function __vboxDetailRow(name, value, cssClass, html) {
-
- // convert to strings
- if(typeof(value) == 'undefined') value = '';
- name = ''+name;
- value = ''+value;
-
-
- var tr = $('<tr />').attr({'class':'vboxDetailRow'});
- $('<th />').html(name + (value && value.length && name.length ? ':' : ''))
- .attr({'class':'vboxDetailContent ' + cssClass})
- .appendTo(tr);
-
- $('<td />').attr({'class':'vboxDetailsValue'}).html(value).appendTo(tr);
-
- return tr;
-}
-
-//Draw rows to table
-function __vboxDetailAddRows(data, rows, table) {
-
- // Is rows a function?
- if(typeof(rows) == 'function') rows = rows(data);
-
- for(var i = 0; i < rows.length; i++) {
-
- // Check if row has condition
- if(rows[i].condition && !rows[i].condition(data)) continue;
-
- // hold row data
- var rowData = '';
-
- // Check for row attribute
- if(rows[i].attrib) {
- if(!data[rows[i].attrib]) continue;
- rowData = data[rows[i].attrib];
-
- // Check for row callback
- } else if(rows[i].callback) {
- rowData = rows[i].callback(data);
-
- // Static data
- } else {
- rowData = rows[i].data;
- }
-
- if(rows[i].rawRow) {
- $(table).append(rowData);
- } else {
- var title = trans(rows[i].title, rows[i].language_context);
- $(table).append(__vboxDetailRow(
- title,
- rowData,
- 'vboxDetailName ' + (rows[i].indented ? ' vboxDetailNameIndent' : '') + ' ' + (rows[i].cssClass ? rows[i].cssClass : ''),
- rows[i].html));
- }
-
- }
-
-}
-
-// Details section
-////////////////////////////
-function __vboxCreateDetailsSection(data, sectionName, section) {
-
- if(!section)
- section = vboxVMDetailsSections[sectionName];
-
- var links = true;
-
- // No link if VM is not in valid state
- if(!((vboxVMStates.isRunning(data) || vboxVMStates.isPaused(data) || vboxVMStates.isEditable(data)) && !vboxVMStates.isSaved(data))) {
- links = false;
- }
-
- var title = trans(section.title, section.language_context);
- var vboxDetailsTable = $('<table />')
- .attr({'class':'vboxDetailsTable vboxDetailsTableBox'})
- .append($('<thead />')
- .append($('<tr />').attr({'class':'vboxDetailsHead'})
- .append($('<th />').attr({'class':'vboxDetailsSection','colspan':'2'})
- .append($('<div />')
- .append(
- $('<img />').attr({'style':'float:left;margin-right:3px','src':'images/vbox/'+section.icon,'class':'vboxDetailsSectionIcon'})
- ).append(
- $('<span />').css({'float':'left'}).addClass((links ? 'vboxDetailsSectionLink' : '')).click(function(){
- if($(this).hasClass('vboxDetailsSectionLink'))
- vboxVMsettingsDialog(data,section.settingsLink);
- }).html(title)
- ).append(
- $('<span />').addClass('vboxArrowImage')
- .click(function(){ $(this).parent().trigger("dblclick"); })
- )
- )
- ).disableSelection()
- )
- );
-
-
- var tbody = $('<tbody />');
-
- __vboxDetailAddRows(data, section.rows, tbody);
-
-
- // Class added to last row to aid in rounded corners
- if(section.noFooter) {
- tbody.children().last().addClass('vboxTableLastRow');
- } else {
- tbody.append($('<tr />').addClass('vboxTableLastRow').append($('</td >')).append('<td />'));
- }
-
- vboxDetailsTable.append(tbody);
-
- var vboxDetailsSection = $('<div />')
- .attr({'class':'vboxDetailsBorder vboxVMDetailsBox'+sectionName+ ' vboxVMDetailsBox-vm-'+data.id,'id':'vboxDetailsSectionId-'+sectionName+'-'+data.id})
- .dblclick(__vboxDetailsSectionCollapse)
- .hoverClass('vboxHover').disableSelection().data({'sectionName':sectionName});
-
- if(vboxGetLocalDataItem("vboxSectionCollapse"+sectionName)) {
- vboxDetailsSection.addClass('vboxDetailsSectionCollapsed');
- }
-
- if(!vboxGetLocalDataItem("vboxSectionHide"+sectionName)) {
- $(vboxDetailsSection).show();
- } else {
- $(vboxDetailsSection).hide();
- }
-
- /* Context menu for section ? */
- if(section.contextMenu) {
-
- var menu = section.contextMenu();
-
- $(vboxDetailsSection).mouseup({'vmid':data.id},function(e) {
-
- $('ul.contextMenu').hide();
-
- if(e.button == 2) {
-
- $(menu).trigger('beforeshow', e.data.vmid);
-
- vboxPositionEvent(menu, e);
- $(menu).show();
-
- e.preventDefault();
- e.stopPropagation();
-
- return false;
- }
-
- });
-
- $(vboxDetailsSection)
- .on('contextmenu', function() { return false; })
- .on('click',function(e){return e.button!=2;});
-
- }
- return vboxDetailsSection.append(vboxDetailsTable);
-
-}
-
-//Display details data table for VM
-//////////////////////////////////
-function __vboxDisplayDetailsData(data, multiSelect, targetDiv, skipTable) {
-
- // No data? Should never happen
- if(typeof data == 'undefined') return;
-
-
- // Accessibility check
- if(data.state == 'Inaccessible') {
-
-
- var reasonDiv = $('<div />')
- .attr({'class':'vboxVMDetailsBox-vm-'+data.id})
- .html('<div style="width: 50%">'+trans('The selected virtual machine is <i>inaccessible</i>. Please inspect the error message shown below and press the <b>Refresh</b> button if you want to repeat the accessibility check:','UIDetailsPagePrivate')+'</div>');
-
- // Details Table
- $('<table />').attr({'style':'width: 50%','class':'vboxDetailsTable vboxDetailsTableError vboxVMDetailsBox-vm-'+data.id}).append(__vboxDetailRow(trans("VirtualBox - Error",'UIMessageCenter'), data.accessError['text'])).append(__vboxDetailRow(trans('Result Code: ','UIMessageCenter'), data.accessError['resultCode'])).append(__vboxDetailRow(trans("Component: ",'UIMessageCenter'), data.accessError['component'])).appendTo(targetDiv);
-
- var d = $('<div />').attr({'style':'width: 50%; padding: 4px;'});
-
- $('<input />').attr({'type':'button',
- 'value':trans('Refresh','UIVMLogViewer'),
- 'style':'background: url(images/vbox/refresh_16px.png) 2px 2px no-repeat; padding: 2px 2px 2px 18px; border: 1px solid #000; background-color: #eee;'
- }).click({vmid:data.id},function(e){
-
-
- var l = new vboxLoader();
- l.showLoading();
- $.when(vboxVMDataMediator.refreshVMData(e.data.vmid)).always(function(){
- l.removeLoading();
- });
-
-
- }).appendTo(d);
-
- $(reasonDiv).append(d).appendTo(targetDiv);
-
- return;
- }
-
- // Multi-select details table sections
- ////////////////////////////////////////
- if(!skipTable) {
-
- var tbl = $('<table />').attr({'id':'vboxDetailsGeneralTable-'+data.id,'class':'vboxInvisible vboxVMDetailsBox-vm-'+data.id,'style':'width: 100%;'}).append(
-
- $('<tr />').attr({'style':'vertical-align: top'})
-
- .append(
-
- $('<td />').css({'width':'100%'})
- .append(__vboxCreateDetailsSection(data,'general'))
- .append(__vboxCreateDetailsSection(data,'system'))
-
- ).append(
-
- vboxVMDetailsSections['preview'].condition() ?
- $('<td />')
- .append(__vboxCreateDetailsSection(data,'preview')) :
- null
- )
-
- ).data({'vmid':data.id});
-
- // If already exists, replace the table, else append to div
- if($('#vboxDetailsGeneralTable-'+data.id)[0]) {
- $('#vboxDetailsGeneralTable-'+data.id).replaceWith(tbl);
- } else {
- tbl.appendTo(targetDiv);
- }
-
- for(var s in {'general':1,'system':1,'preview':1}) {
- if(vboxVMDetailsSections[s].onRender)
- vboxVMDetailsSections[s].onRender(data);
- }
-
- }
-
- // Other sections
- ///////////////////////////
-
- // Not shown if multiple vms are selected
- if(multiSelect) return;
-
- for(var s in vboxVMDetailsSections) {
-
- if(vboxVMDetailsSections[s].multiSelectDetailsTable) continue;
-
- if(vboxVMDetailsSections[s].condition && !vboxVMDetailsSections[s].condition(data))
- continue;
-
- $(targetDiv).append(__vboxCreateDetailsSection(data, s));
-
- if(vboxVMDetailsSections[s].onRender)
- vboxVMDetailsSections[s].onRender(data);
-
-
- }
-
-}
-
-//Display details data for VirtualBox Host
-/////////////////////////////////////////////
-function __vboxDisplayHostDetailsData(data, targetDiv) {
-
- for(var s in vboxHostDetailsSections) {
-
- if(vboxHostDetailsSections[s].condition && !vboxHostDetailsSections[s].condition(data))
- continue;
-
- $(targetDiv).append(__vboxCreateDetailsSection(data, s, vboxHostDetailsSections[s]));
-
- if(vboxHostDetailsSections[s].onRender)
- vboxHostDetailsSections[s].onRender(data);
-
- }
-
-}
-
-
-//Collapse section used on dblclick of sections
-function __vboxDetailsSectionCollapse(e) {
-
- // Save section name
- var sectionName = $(this).data('sectionName');
-
- vboxSetLocalDataItem('vboxSectionCollapse'+sectionName,
- ($(this).hasClass('vboxDetailsSectionCollapsed') ? '' : '1')
- );
-
- var collapsed = $(this).hasClass('vboxDetailsSectionCollapsed');
-
-
- // IE8 doesn't display this animation
- if(!($.browser.msie && $.browser.version.substring(0,1) < 9)) {
-
- // Get image span of current section only
- var vboxArrowImage = $(this).find('span.vboxArrowImage');
-
- // Only animate the span that is part of this section header
- // All others just get switched
- $.when($('<div />').animate({left:90},
- {
- duration: 300,
- step: function(currentStep) {
-
- if(collapsed) {
- currentStep = (180 - currentStep);
- } else {
- currentStep = currentStep+90;
- }
- vboxArrowImage.css({
- 'transform':'rotate('+currentStep+'deg)',
- '-moz-transform': 'rotate('+currentStep+'deg)',
- '-webkit-transform': 'rotate('+currentStep+'deg)',
- '-o-transform': 'rotate('+currentStep+'deg)',
- '-ms-transform': 'rotate('+currentStep+'deg)'
- });
- },
- queue: true
- })).done(function(){
-
- vboxArrowImage.css({
- 'transform':'',
- '-moz-transform': '',
- '-webkit-transform': '',
- '-o-transform': '',
- '-ms-transform': ''
- });
-
- });
-
- }
-
- $('#vboxVMDetails').find('div.vboxVMDetailsBox'+sectionName)
- .toggleClass('vboxDetailsSectionCollapsed', (($.browser.msie && $.browser.version.substring(0,1) < 9) ? undefined : 300));
-
-
-
- return false;
-
-}
-
-/*
- *
- * Show / Hide boxes menu
- *
- */
-var ul = $('<ul />')
- .attr({'class':'contextMenu contextMenuNoBG','style':'display: none','id':'vboxDetailsShowMenu'})
- .on('contextmenu', function() { return false; });
-
-for(var i in vboxVMDetailsSections) {
-
- if(typeof(i) != 'string') continue;
-
- // Skip if we shouldn't display
- if(vboxVMDetailsSections[i].condition && !vboxVMDetailsSections[i].condition())
- continue;
-
- $('<li />').attr('id','vboxDetailsShowMenuItem'+i).append(
-
- $('<label />').append(
-
- $('<input />')
- .attr({'type':'checkbox','class':'vboxCheckbox','name':i})
- .prop('checked',!vboxGetLocalDataItem("vboxSectionHide"+i))
- .on('click',{'sectionName':i},function(e){
-
- vboxSetLocalDataItem("vboxSectionHide"+$(this).attr('name'),(this.checked ? '' : '1'));
- $('#vboxTabVMDetails .vboxVMDetailsBox'+$(this).attr('name')).css('display',(this.checked ? '' : 'none'));
-
- var sectionName = e.data.sectionName;
-
- // Run section's onShow function
- if(this.checked && vboxVMDetailsSections[sectionName].onShow) {
- vboxVMDetailsSections[sectionName].onShow();
- } else if(!this.checked && vboxVMDetailsSections[sectionName].onHide) {
- vboxVMDetailsSections[sectionName].onHide();
- }
-
- })
-
- ).append(
- $('<span />').html(trans(vboxVMDetailsSections[i].title, vboxVMDetailsSections[i].language_context))
-
- ).disableSelection()
-
- ).appendTo(ul);
-
-
-}
-$('#vboxTabVMDetails').append(ul);
-
-
-/* Menu functionality */
-$("#vboxVMDetails").mouseup( function(e) {
-
- $('ul.contextMenu').hide();
-
- if(e.button == 2 && vboxChooser.getSingleSelectedId() != 'host') {
-
- var menu = $('#vboxDetailsShowMenu');
- vboxPositionEvent(menu, e);
- $(menu).show();
-
- e.preventDefault();
- e.stopPropagation();
-
- return false;
- }
-
-
-}).on('contextmenu', function() { return false; })
- .on('click',function(e){return e.button!=2;});
-
-//Display Welcome div
-$('#vboxTabVMDetails').css({'display':'table','width':'100%'}).children().hide();
-$('#vboxDetailsWelcome').show().css('display','table-cell');
-$('#vboxTabVMDetails').data('showingWelcome', true);
-
-</script>
+<!--
+
+ VM Details Pane
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: tabVMDetails.html 596 2015-04-19 11:50:53Z imoore76 $
+
+ -->
+<div id='vboxTabVMDetails' style='height: 100%; width: 100%; display: none;' class='vboxInvisible'>
+
+ <!-- VM Details -->
+ <div id='vboxVMDetails' style='height: 100%; width: 100%; display: table; min-height:100px;' class='vboxInvisible'></div>
+
+ <!-- Loading... -->
+ <div id='vboxDetailsLoading' class='vboxInvisible' style='#position:absolute;#top:50%;display:none;vertical-align:middle;width:100%;height:100%;padding:0px;margin:0px'>
+ <div style='#position:relative;#top:-50%;padding:4px;text-align:center;width:100%'>
+ <span class='ui-corner-all translate' style='padding:8px;background:#fff;border:2px solid #ddd'>Loading ...</span>
+ </div>
+ </div>
+
+ <!-- Welcome -->
+ <div id='vboxDetailsWelcome' style='#position:absolute;#top:50%;display:table-cell;vertical-align:middle;width:50%;height:50%;text-align:center'>
+ <div style='#position:relative;#top:-50%;padding:0px;text-align:center;width:100%'>
+ <img src='images/vbox/welcome.png' />
+ </div>
+ </div>
+
+<script type='text/javascript'>
+
+// Translate loading div
+$('#vboxDetailsLoading').find('span.translate').html(trans('Loading ...','UIVMDesktop')).removeClass('translate');
+
+// Last selection list was none
+$('#vboxTabVMDetails').data('vboxLastSelectionList',[]);
+
+// Listen for events
+/////////////////////////////
+$('#vboxPane').on('vmSelectionListChanged',function(){
+
+ // No VMs?
+ if(!vboxChooser || vboxChooser.selectionMode == vboxSelectionModeNone) {
+
+ // Hide all tab children first
+ $('#vboxTabVMDetails').css({'display':'table','width':'100%'}).children().hide();
+
+ // Display Welcome div
+ $('#vboxDetailsWelcome').show().css('display','table-cell');
+
+ $('#vboxTabVMDetails').data('showingWelcome', true);
+
+ $('#vboxTabVMDetails').data('vboxLastSelectionList',[]);
+
+ return;
+
+ // Were we showing the welcome screen before?
+ } else if($('#vboxTabVMDetails').data('showingWelcome')) {
+
+ $('#vboxTabVMDetails').css({'display':''})
+ .data({'showingWelcome':false}).children().hide();
+ $('#vboxVMDetails').html('').css({'display':''});
+
+ }
+
+ // We have VMs to load
+ if(vboxChooser.selectionMode != vboxSelectionModeNone) {
+
+ var targetDiv = $('#vboxVMDetails');
+
+ // Loading scren
+ if(vboxChooser.selectedVMs.length == 1 && $('#vboxTabVMDetails').css('display') != 'none') {
+
+ // Hide all tab children first
+ $('#vboxTabVMDetails').css({'display':'table','width':'100%'}).children().hide();
+
+ // Display loading div
+ $('#vboxDetailsLoading').show().css('display','table-cell');
+ }
+
+ if(vboxChooser.getSingleSelectedId() == 'host') {
+
+ $('#vboxTabVMDetails').data('vboxLastSelectionList',['host']);
+
+ targetDiv.children().empty().remove();
+
+ $.when(vboxVMDataMediator.getVMDetails('host')).done(function(d) {
+
+ // Hide loading screen
+ targetDiv.siblings().hide();
+ targetDiv.show();
+
+
+ __vboxDisplayHostDetailsData(d, targetDiv);
+
+ });
+
+ return;
+ }
+
+ // Remove anything that is not a details table
+ targetDiv.children(':not(table)').remove();
+
+ // Last list of selected vms
+ var lastSelectionList = $('#vboxTabVMDetails').data('vboxLastSelectionList');
+ $('#vboxTabVMDetails').data('vboxLastSelectionList', vboxChooser.selectedVMs);
+
+ // Remove any that aren't in list
+ $(lastSelectionList).not(vboxChooser.selectedVMs).each(function(idx,vmid){
+ $('#vboxVMDetails .vboxVMDetailsBox-vm-'+vmid).empty().remove();
+ });
+
+ // Placeholders so vms are listed in order
+ for(var i = 0; i < vboxChooser.selectedVMs.length; i++) {
+
+ if(jQuery.inArray(vboxChooser.selectedVMs[i], lastSelectionList) > -1) {
+ $('#vboxDetailsGeneralTable-'+vboxChooser.selectedVMs[i]).detach().appendTo(targetDiv);
+ } else {
+ $('<table />').attr({'id':'vboxDetailsGeneralTable-'+vboxChooser.selectedVMs[i],'class':'vboxInvisible vboxVMDetailsBox-vm-'+vboxChooser.selectedVMs[i],'style':'display:none'})
+ .appendTo(targetDiv);
+ }
+
+
+ }
+
+ var oneLoaded = false;
+ var skipTable = false; // skip drawing multi-section details table
+ for(var i = 0; i < vboxChooser.selectedVMs.length; i++) {
+
+ // Already drawn and we are showing more than one vm
+ if(jQuery.inArray(vboxChooser.selectedVMs[i], lastSelectionList) > -1) {
+
+ if(vboxChooser.selectedVMs.length > 1) {
+ oneLoaded = true;
+ targetDiv.siblings().hide();
+ targetDiv.show();
+ continue;
+ }
+ skipTable = true;
+ }
+
+ $.when(vboxChooser.selectedVMs[i], vboxVMDataMediator.getVMDataCombined(vboxChooser.selectedVMs[i])).done(function(vmid, d) {
+
+ // Remove placeholder and don't draw
+ // if this vm is no longer selected
+ if(!d || !vboxChooser.isVMSelected(vmid)) {
+ $('#vboxDetailsGeneralTable-'+vmid).empty().remove();
+ return;
+ }
+
+ // Clear target div if we only have one vm
+ if(!oneLoaded) {
+ oneLoaded = true;
+ targetDiv.siblings().hide();
+ targetDiv.show();
+ }
+
+
+ __vboxDisplayDetailsData(d, (vboxChooser.selectedVMs.length > 1), targetDiv, skipTable);
+
+ });
+ }
+
+
+ }
+
+
+/////////////////////////////////
+//
+// Redraw section logic
+//
+//////////////////////////////////
+}).on('vboxEvents', function(e, eventList) {
+
+ // Multiple vms selected
+ var multiSelect = (vboxChooser.selectedVMs.length > 1);
+
+ // Keep track of details to redraw
+ var vmRedrawDetails = {};
+ var vmRedrawSections = {};
+ var vmTriggerEventSection = {};
+
+ // Each event in list
+ for(var i = 0; i < eventList.length; i++) {
+
+ // Nothing to do if VM is not selected
+ if(!eventList[i].machineId || !vboxChooser.isVMSelected(eventList[i].machineId))
+ continue;
+
+
+
+ switch(eventList[i].eventType) {
+
+ // These trigger complete redraws
+ case 'OnMachineDataChanged':
+ vmRedrawDetails[eventList[i].machineId] = true;
+ break;
+
+ default:
+
+ // already redrawing all vm details
+ if(vmRedrawDetails[eventList[i].machineId])
+ break;
+
+ // Check for specific section redraws or events
+ for(var s in vboxVMDetailsSections) {
+
+ if(typeof(s) != 'string') continue;
+ if(multiSelect && !vboxVMDetailsSections[s].multiSelectDetailsTable) continue;
+
+ // Redraw this section?
+ if(vboxVMDetailsSections[s].redrawMachineEvents && jQuery.inArray(eventList[i].eventType, vboxVMDetailsSections[s].redrawMachineEvents) > -1) {
+
+ if(!vmRedrawSections[eventList[i].machineId])
+ vmRedrawSections[eventList[i].machineId] = {};
+
+ vmRedrawSections[eventList[i].machineId][s] = true;
+
+ // Specific event handler
+ } else if(vboxVMDetailsSections[s]['vboxEvent'+eventList[i].eventType]) {
+
+ if(!vmTriggerEventSection[eventList[i].machineId])
+ vmTriggerEventSection[eventList[i].machineId] = {};
+ if(!vmTriggerEventSection[eventList[i].machineId][s])
+ vmTriggerEventSection[eventList[i].machineId][s] = [];
+
+ vmTriggerEventSection[eventList[i].machineId][s][vmTriggerEventSection[eventList[i].machineId][s].length] = eventList[i];
+ }
+ }
+
+ } // </ switch eventType >
+
+
+ } // </ foreach event >
+
+
+ // Target for actions
+ var targetDiv = $('#vboxVMDetails');
+
+
+ // Redraw each details table
+ /////////////////////////////////
+ for(var vmid in vmRedrawDetails) {
+
+ if(typeof(vmid) != 'string') continue;
+
+ // Get and show details and runtime data again
+ $.when(vboxVMDataMediator.getVMDataCombined(vmid)).done(function(d) {
+
+ // Do nothing if VM is no longer selected
+ if(!vboxChooser.isVMSelected(d.id)) return;
+
+ // if there's only one, we'll have to remove existing data
+ if(vboxChooser.selectedVMs.length == 1) {
+ targetDiv.children().empty().remove();
+ }
+ // Special case for host
+ if(d.id == 'host') __vboxDisplayHostDetailsData(d, targetDiv);
+ else __vboxDisplayDetailsData(d, (vboxChooser.selectedVMs.length > 1), targetDiv);
+ });
+
+ };
+
+ // Redraw each section
+ ////////////////////////////
+ for(var vmid in vmRedrawSections) {
+
+ if(typeof(vmid) != 'string') continue;
+ if(vmRedrawDetails[vmid]) continue; // already redrew entire details
+
+ // Get and show details and runtime data again
+ $.when(vboxVMDataMediator.getVMDataCombined(vmid),vmRedrawSections[vmid]).done(function(d,sections) {
+
+ // Do nothing if VM is no longer selected
+ if(!vboxChooser.isVMSelected(d.id)) return;
+
+ // Redraw each section in list
+ for(var s in sections) {
+
+ if(typeof(s) != 'string') continue;
+
+ $('#vboxDetailsSectionId-'+s+'-'+d.id).replaceWith(
+ __vboxCreateDetailsSection(d, s)
+ );
+
+ if(vboxVMDetailsSections[s].onRender)
+ vboxVMDetailsSections[s].onRender(d);
+
+ }
+ });
+
+ }
+
+ // Specific event handlers for each section
+ for(var vmid in vmTriggerEventSection) {
+
+ if(typeof(vmid) != 'string') continue;
+ if(vmRedrawDetails[vmid]) continue; // already redrew entire details
+
+ // Do nothing if VM is no longer selected
+ if(!vboxChooser.isVMSelected(vmid)) return;
+
+ for(var s in vmTriggerEventSection[vmid]) {
+
+ if(typeof(s) != 'string') continue;
+ if(vmRedrawSections[vmid] && vmRedrawSections[vmid][s]) continue; // already redrew this section
+
+ // Call each event handler
+ for(var i = 0; i < vmTriggerEventSection[vmid][s].length; i++) {
+ var event = vmTriggerEventSection[vmid][s][i];
+ vboxVMDetailsSections[s]['vboxEvent'+event.eventType](event);
+ }
+
+
+ }
+
+ }
+
+});
+
+// Hide context menus when hiding tab
+$('#vboxTabVMDetails').on('hide',function(){
+ $('ul.contextMenu').hide();
+});
+
+
+
+//Base function that returns a table row of machine detail data
+//Called from other functions
+function __vboxDetailRow(name, value, cssClass, html) {
+
+ // convert to strings
+ if(typeof(value) == 'undefined') value = '';
+ name = ''+name;
+ value = ''+value;
+
+
+ var tr = $('<tr />').attr({'class':'vboxDetailRow'});
+ $('<th />').html(name + (value && value.length && name.length ? ':' : ''))
+ .attr({'class':'vboxDetailContent ' + cssClass})
+ .appendTo(tr);
+
+ $('<td />').attr({'class':'vboxDetailsValue'}).html(value).appendTo(tr);
+
+ return tr;
+}
+
+//Draw rows to table
+function __vboxDetailAddRows(data, rows, table) {
+
+ // Is rows a function?
+ if(typeof(rows) == 'function') rows = rows(data);
+
+ for(var i = 0; i < rows.length; i++) {
+
+ // Check if row has condition
+ if(rows[i].condition && !rows[i].condition(data)) continue;
+
+ // hold row data
+ var rowData = '';
+
+ // Check for row attribute
+ if(rows[i].attrib) {
+ if(!data[rows[i].attrib]) continue;
+ rowData = data[rows[i].attrib];
+
+ // Check for row callback
+ } else if(rows[i].callback) {
+ rowData = rows[i].callback(data);
+
+ // Static data
+ } else {
+ rowData = rows[i].data;
+ }
+
+ if(rows[i].rawRow) {
+ $(table).append(rowData);
+ } else {
+ var title = trans(rows[i].title, rows[i].language_context);
+ $(table).append(__vboxDetailRow(
+ title,
+ rowData,
+ 'vboxDetailName ' + (rows[i].indented ? ' vboxDetailNameIndent' : '') + ' ' + (rows[i].cssClass ? rows[i].cssClass : ''),
+ rows[i].html));
+ }
+
+ }
+
+}
+
+// Details section
+////////////////////////////
+function __vboxCreateDetailsSection(data, sectionName, section) {
+
+ if(!section)
+ section = vboxVMDetailsSections[sectionName];
+
+ var links = true;
+
+ // No link if VM is not in valid state
+ if(!((vboxVMStates.isRunning(data) || vboxVMStates.isPaused(data) || vboxVMStates.isEditable(data)) && !vboxVMStates.isSaved(data))) {
+ links = false;
+ }
+
+ var title = trans(section.title, section.language_context);
+ var vboxDetailsTable = $('<table />')
+ .attr({'class':'vboxDetailsTable vboxDetailsTableBox'})
+ .append($('<thead />')
+ .append($('<tr />').attr({'class':'vboxDetailsHead'})
+ .append($('<th />').attr({'class':'vboxDetailsSection','colspan':'2'})
+ .append($('<div />')
+ .append(
+ $('<img />').attr({'style':'float:left;margin-right:3px','src':'images/vbox/'+section.icon,'class':'vboxDetailsSectionIcon'})
+ ).append(
+ $('<span />').css({'float':'left'}).addClass((links ? 'vboxDetailsSectionLink' : '')).click(function(){
+ if($(this).hasClass('vboxDetailsSectionLink'))
+ vboxVMsettingsDialog(data,section.settingsLink);
+ }).html(title)
+ ).append(
+ $('<span />').addClass('vboxArrowImage')
+ .click(function(){ $(this).parent().trigger("dblclick"); })
+ )
+ )
+ ).disableSelection()
+ )
+ );
+
+
+ var tbody = $('<tbody />');
+
+ __vboxDetailAddRows(data, section.rows, tbody);
+
+
+ // Class added to last row to aid in rounded corners
+ if(section.noFooter) {
+ tbody.children().last().addClass('vboxTableLastRow');
+ } else {
+ tbody.append($('<tr />').addClass('vboxTableLastRow').append($('</td >')).append('<td />'));
+ }
+
+ vboxDetailsTable.append(tbody);
+
+ var vboxDetailsSection = $('<div />')
+ .attr({'class':'vboxDetailsBorder vboxVMDetailsBox'+sectionName+ ' vboxVMDetailsBox-vm-'+data.id,'id':'vboxDetailsSectionId-'+sectionName+'-'+data.id})
+ .dblclick(__vboxDetailsSectionCollapse)
+ .hoverClass('vboxHover').disableSelection().data({'sectionName':sectionName});
+
+ if(vboxGetLocalDataItem("vboxSectionCollapse"+sectionName)) {
+ vboxDetailsSection.addClass('vboxDetailsSectionCollapsed');
+ }
+
+ if(!vboxGetLocalDataItem("vboxSectionHide"+sectionName)) {
+ $(vboxDetailsSection).show();
+ } else {
+ $(vboxDetailsSection).hide();
+ }
+
+ /* Context menu for section ? */
+ if(section.contextMenu) {
+
+ var menu = section.contextMenu();
+
+ $(vboxDetailsSection).mouseup({'vmid':data.id},function(e) {
+
+ $('ul.contextMenu').hide();
+
+ if(e.button == 2) {
+
+ $(menu).trigger('beforeshow', e.data.vmid);
+
+ vboxPositionEvent(menu, e);
+ $(menu).show();
+
+ e.preventDefault();
+ e.stopPropagation();
+
+ return false;
+ }
+
+ });
+
+ $(vboxDetailsSection)
+ .on('contextmenu', function() { return false; })
+ .on('click',function(e){return e.button!=2;});
+
+ }
+ return vboxDetailsSection.append(vboxDetailsTable);
+
+}
+
+//Display details data table for VM
+//////////////////////////////////
+function __vboxDisplayDetailsData(data, multiSelect, targetDiv, skipTable) {
+
+ // No data? Should never happen
+ if(typeof data == 'undefined') return;
+
+
+ // Accessibility check
+ if(data.state == 'Inaccessible') {
+
+
+ var reasonDiv = $('<div />')
+ .attr({'class':'vboxVMDetailsBox-vm-'+data.id})
+ .html('<div style="width: 50%">'+trans('The selected virtual machine is <i>inaccessible</i>. Please inspect the error message shown below and press the <b>Refresh</b> button if you want to repeat the accessibility check:','UIDetailsPagePrivate')+'</div>');
+
+ // Details Table
+ $('<table />').attr({'style':'width: 50%','class':'vboxDetailsTable vboxDetailsTableError vboxVMDetailsBox-vm-'+data.id}).append(__vboxDetailRow(trans("VirtualBox - Error",'UIMessageCenter'), data.accessError['text'])).append(__vboxDetailRow(trans('Result Code: ','UIMessageCenter'), data.accessError['resultCode'])).append(__vboxDetailRow(trans("Component: ",'UIMessageCenter'), data.accessError['component'])).appendTo(targetDiv);
+
+ var d = $('<div />').attr({'style':'width: 50%; padding: 4px;'});
+
+ $('<input />').attr({'type':'button',
+ 'value':trans('Refresh','UIVMLogViewer'),
+ 'style':'background: url(images/vbox/refresh_16px.png) 2px 2px no-repeat; padding: 2px 2px 2px 18px; border: 1px solid #000; background-color: #eee;'
+ }).click({vmid:data.id},function(e){
+
+
+ var l = new vboxLoader();
+ l.showLoading();
+ $.when(vboxVMDataMediator.refreshVMData(e.data.vmid)).always(function(){
+ l.removeLoading();
+ });
+
+
+ }).appendTo(d);
+
+ $(reasonDiv).append(d).appendTo(targetDiv);
+
+ return;
+ }
+
+ // Multi-select details table sections
+ ////////////////////////////////////////
+ if(!skipTable) {
+
+ var tbl = $('<table />').attr({'id':'vboxDetailsGeneralTable-'+data.id,'class':'vboxInvisible vboxVMDetailsBox-vm-'+data.id,'style':'width: 100%;'}).append(
+
+ $('<tr />').attr({'style':'vertical-align: top'})
+
+ .append(
+
+ $('<td />').css({'width':'100%'})
+ .append(__vboxCreateDetailsSection(data,'general'))
+ .append(__vboxCreateDetailsSection(data,'system'))
+
+ ).append(
+
+ vboxVMDetailsSections['preview'].condition() ?
+ $('<td />')
+ .append(__vboxCreateDetailsSection(data,'preview')) :
+ null
+ )
+
+ ).data({'vmid':data.id});
+
+ // If already exists, replace the table, else append to div
+ if($('#vboxDetailsGeneralTable-'+data.id)[0]) {
+ $('#vboxDetailsGeneralTable-'+data.id).replaceWith(tbl);
+ } else {
+ tbl.appendTo(targetDiv);
+ }
+
+ for(var s in {'general':1,'system':1,'preview':1}) {
+ if(vboxVMDetailsSections[s].onRender)
+ vboxVMDetailsSections[s].onRender(data);
+ }
+
+ }
+
+ // Other sections
+ ///////////////////////////
+
+ // Not shown if multiple vms are selected
+ if(multiSelect) return;
+
+ for(var s in vboxVMDetailsSections) {
+
+ if(vboxVMDetailsSections[s].multiSelectDetailsTable) continue;
+
+ if(vboxVMDetailsSections[s].condition && !vboxVMDetailsSections[s].condition(data))
+ continue;
+
+ $(targetDiv).append(__vboxCreateDetailsSection(data, s));
+
+ if(vboxVMDetailsSections[s].onRender)
+ vboxVMDetailsSections[s].onRender(data);
+
+
+ }
+
+}
+
+//Display details data for VirtualBox Host
+/////////////////////////////////////////////
+function __vboxDisplayHostDetailsData(data, targetDiv) {
+
+ for(var s in vboxHostDetailsSections) {
+
+ if(vboxHostDetailsSections[s].condition && !vboxHostDetailsSections[s].condition(data))
+ continue;
+
+ $(targetDiv).append(__vboxCreateDetailsSection(data, s, vboxHostDetailsSections[s]));
+
+ if(vboxHostDetailsSections[s].onRender)
+ vboxHostDetailsSections[s].onRender(data);
+
+ }
+
+}
+
+
+//Collapse section used on dblclick of sections
+function __vboxDetailsSectionCollapse(e) {
+
+ // Save section name
+ var sectionName = $(this).data('sectionName');
+
+ vboxSetLocalDataItem('vboxSectionCollapse'+sectionName,
+ ($(this).hasClass('vboxDetailsSectionCollapsed') ? '' : '1')
+ );
+
+ var collapsed = $(this).hasClass('vboxDetailsSectionCollapsed');
+
+
+ // IE8 doesn't display this animation
+ if(!($.browser.msie && $.browser.version.substring(0,1) < 9)) {
+
+ // Get image span of current section only
+ var vboxArrowImage = $(this).find('span.vboxArrowImage');
+
+ // Only animate the span that is part of this section header
+ // All others just get switched
+ $.when($('<div />').animate({left:90},
+ {
+ duration: 300,
+ step: function(currentStep) {
+
+ if(collapsed) {
+ currentStep = (180 - currentStep);
+ } else {
+ currentStep = currentStep+90;
+ }
+ vboxArrowImage.css({
+ 'transform':'rotate('+currentStep+'deg)',
+ '-moz-transform': 'rotate('+currentStep+'deg)',
+ '-webkit-transform': 'rotate('+currentStep+'deg)',
+ '-o-transform': 'rotate('+currentStep+'deg)',
+ '-ms-transform': 'rotate('+currentStep+'deg)'
+ });
+ },
+ queue: true
+ })).done(function(){
+
+ vboxArrowImage.css({
+ 'transform':'',
+ '-moz-transform': '',
+ '-webkit-transform': '',
+ '-o-transform': '',
+ '-ms-transform': ''
+ });
+
+ });
+
+ }
+
+ $('#vboxVMDetails').find('div.vboxVMDetailsBox'+sectionName)
+ .toggleClass('vboxDetailsSectionCollapsed', (($.browser.msie && $.browser.version.substring(0,1) < 9) ? undefined : 300));
+
+
+
+ return false;
+
+}
+
+/*
+ *
+ * Show / Hide boxes menu
+ *
+ */
+var ul = $('<ul />')
+ .attr({'class':'contextMenu contextMenuNoBG','style':'display: none','id':'vboxDetailsShowMenu'})
+ .on('contextmenu', function() { return false; });
+
+for(var i in vboxVMDetailsSections) {
+
+ if(typeof(i) != 'string') continue;
+
+ // Skip if we shouldn't display
+ if(vboxVMDetailsSections[i].condition && !vboxVMDetailsSections[i].condition())
+ continue;
+
+ $('<li />').attr('id','vboxDetailsShowMenuItem'+i).append(
+
+ $('<label />').append(
+
+ $('<input />')
+ .attr({'type':'checkbox','class':'vboxCheckbox','name':i})
+ .prop('checked',!vboxGetLocalDataItem("vboxSectionHide"+i))
+ .on('click',{'sectionName':i},function(e){
+
+ vboxSetLocalDataItem("vboxSectionHide"+$(this).attr('name'),(this.checked ? '' : '1'));
+ $('#vboxTabVMDetails .vboxVMDetailsBox'+$(this).attr('name')).css('display',(this.checked ? '' : 'none'));
+
+ var sectionName = e.data.sectionName;
+
+ // Run section's onShow function
+ if(this.checked && vboxVMDetailsSections[sectionName].onShow) {
+ vboxVMDetailsSections[sectionName].onShow();
+ } else if(!this.checked && vboxVMDetailsSections[sectionName].onHide) {
+ vboxVMDetailsSections[sectionName].onHide();
+ }
+
+ })
+
+ ).append(
+ $('<span />').html(trans(vboxVMDetailsSections[i].title, vboxVMDetailsSections[i].language_context))
+
+ ).disableSelection()
+
+ ).appendTo(ul);
+
+
+}
+$('#vboxTabVMDetails').append(ul);
+
+
+/* Menu functionality */
+$("#vboxVMDetails").mouseup( function(e) {
+
+ $('ul.contextMenu').hide();
+
+ if(e.button == 2 && vboxChooser.getSingleSelectedId() != 'host') {
+
+ var menu = $('#vboxDetailsShowMenu');
+ vboxPositionEvent(menu, e);
+ $(menu).show();
+
+ e.preventDefault();
+ e.stopPropagation();
+
+ return false;
+ }
+
+
+}).on('contextmenu', function() { return false; })
+ .on('click',function(e){return e.button!=2;});
+
+//Display Welcome div
+$('#vboxTabVMDetails').css({'display':'table','width':'100%'}).children().hide();
+$('#vboxDetailsWelcome').show().css('display','table-cell');
+$('#vboxTabVMDetails').data('showingWelcome', true);
+
+</script>
</div> \ No newline at end of file
diff --git a/panes/tabVMSnapshots.html b/panes/tabVMSnapshots.html
index f71a042..0bfa6bc 100644
--- a/panes/tabVMSnapshots.html
+++ b/panes/tabVMSnapshots.html
@@ -1,856 +1,919 @@
-<!--
-
- VM Snapshots Pane
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: tabVMSnapshots.html 595 2015-04-17 09:50:36Z imoore76 $
-
- -->
-<div id='vboxTabVMSnapshots' class='vboxInvisible' style='display: none; width:100%;'>
-
- <table class='vboxInvisible' style='height: 99%; width: 99%'>
- <tr style='vertical-align: top; height: 1%'>
- <td><div id='vboxSnapshotToolbar'></div></td>
- </tr>
- <tr style='vertical-align: top;'>
- <td><ul style='min-height: 400px' class='vboxBordered vboxTreeView' id='vboxSnapshotList'></ul></td>
- </tr>
- </table>
-<!--
-
- New Snapshot Dialog
-
- -->
- <div id='vboxSnapshotNew' class='vboxDialogContent' style='display: none;'>
- <table class='vboxVertical'>
- <tr style='vertical-align: top'>
- <th>
- <img id='vboxSnapshotNewImg' src='images/vbox/os_other.png' height='32' width='32' />
- </th>
- <td>
- <div style='height: 100%'>
- <div class='translate'>Snapshot Name</div>
- <input id='vboxSnapshotNewName' style='width: 100%'/>
- <div class='translate'>Snapshot Description</div>
- <textarea rows='10' id='vboxSnapshotNewDesc' style='width: 100%;'></textarea>
- </div>
- </td>
- </tr>
- </table>
- </div>
-
-
-<!--
-
- Snapshot Details Dialog
-
- -->
- <div id='vboxSnapshotDetails' class='vboxDialogContent' style='display: none;'>
- <table class='vboxVertical'>
- <tr>
- <th><span class='translate'>Name:</span></th>
- <td style='width:100%'>
- <input id='vboxSnapshotDetailsName' style='width: 100%'/>
- </td>
- <td rowspan='2' id='vboxSnapshotSS' style='width:1%'></td>
- </tr>
- <tr>
- <th><span class='translate'>Taken:</span></th>
- <td style='width:100%'>
- <span id='vboxSnapshotDetailsTaken'></span>
- </td>
- </tr>
- <tr>
- <th><span class='translate'>Description:</span></th>
- <td colspan='2'>
- <textarea rows='12' id='vboxSnapshotDetailsDesc' name='vboxSnapshotDetailsDescElm'></textarea>
- </td>
- </tr>
- <tr>
- <th><span class='translate'>Details:</span></th>
- <td class='vboxSnapshotDetailsMachine' colspan='2'>
- <div id='vboxSnapshotDetailsVM' style='overflow: auto; height: 100%'></div>
- </td>
- </tr>
- </table>
- </div>
-
-
-
-<script type='text/javascript'>
-
-vboxInitDisplay('vboxSnapshotNew','VBoxTakeSnapshotDlg');
-vboxInitDisplay('vboxSnapshotDetails','VBoxSnapshotDetailsDlg');
-
-var vboxSnapshotButtons = [
-
- {
- 'name' : 'take_snapshot',
- 'label' : 'Take Snapshot...',
- 'language_context': 'UIActionPool',
- 'icon' : 'snapshot_take',
- 'enabled' : function(item) {
-
- if(typeof item == 'string') state = item;
- else if(item && $(item).data('vboxSnapshot')) state = $(item).data('vboxSnapshot').state;
- else return false;
-
- var vm = vboxChooser.getSingleSelected();
- return (item && state == 'current' && jQuery.inArray(vm.state, ['RestoringSnapshot','LiveSnapshotting','DeletingSnapshot']) == -1);
- },
- 'click' : function (callback) {
-
- var vm = vboxChooser.getSingleSelected();
-
- $('#vboxSnapshotNewImg').attr('src',"images/vbox/" + vboxGuestOSTypeIcon(vm.OSTypeId));
-
- var snRegEx = new RegExp('^' + trans('Snapshot %1','VBoxSnapshotsWgt').replace('%1','([0-9]+)') + '$');
-
- // Get max snapshot name
- var snMax = 0;
- var snList = $('#vboxSnapshotList').find('li');
- for(var i = 0; i < snList.length; i++) {
- var snNum = snRegEx.exec($(snList[i]).data('vboxSnapshot').name);
- if(snNum) snMax = Math.max(parseInt(snNum[1]), snMax);
- }
-
- $('#vboxSnapshotNewName').val(trans('Snapshot %1','VBoxSnapshotsWgt').replace('%1',(snMax+1)));
- $('#vboxSnapshotNewDesc').val('');
-
-
- var buttons = {};
- buttons[trans('OK','QIMessageBox')] = function() {
-
- // Get fresh VM state when this is clicked
- var vm = vboxChooser.getSingleSelected();
- if(!vm) return;
-
- // Deferred object that will trigger
- // taking a snapshot on success
- var isPausedOrNotRunning = $.Deferred();
-
- // Take snapshot function when machine is in
- // a valid paused or not running state
- $.when(isPausedOrNotRunning).done(function(paused) {
-
- var l = new vboxLoader('snapshotTake');
- l.add('snapshotTake',function(d){
- if(d && d.responseData && d.responseData.progress) {
- vboxProgress({'progress':d.responseData.progress,'persist':d.persist},function(pres){
-
- // Unpause machine if it was paused
- if(paused) {
- vboxAjaxRequest('machineSetState',{'vm':vm.id,'state':'resume'});
- }
-
- // If progress operation errored, refresh snapshot list
- if(pres && !pres.success)
- $.when(vboxAjaxRequest('machineGetSnapshots',{'vm':vm.id})).done(__vboxTabSnapshotsFill);
-
- // callback passed to click()? else Refresh vm list
- if(typeof callback == 'function') { callback(pres); }
-
- },'progress_snapshot_create_90px.png', trans('Take a snapshot of the current virtual machine state','VBoxSnapshotsWgt'),
- vm.name);
-
- } else {
-
- // Unpause machine if it was paused
- if(paused) {
- vboxAjaxRequest('machineSetState',{'vm':vm.id,'state':'resume'});
- }
-
- if(d && d.error) vboxAlert(d.error);
- $.when(vboxAjaxRequest('machineGetSnapshots',{'vm':vm.id})).done(__vboxTabSnapshotsFill);
- }
- },{'vm':vm.id,'name':$('#vboxSnapshotNewName').val(),'description':$('#vboxSnapshotNewDesc').val()});
- l.run();
-
- }).fail(function(){
-
- $.when(vboxAjaxRequest('machineGetSnapshots',{'vm':vm.id})).done(__vboxTabSnapshotsFill);
-
- });
-
- // Set to paused state if VM is running
- if(vboxVMStates.isRunning(vm)) {
- var pl = new vboxLoader('machineSetStatePaused');
- pl.add('machineSetState', function(d) {
- if(d && d.success) isPausedOrNotRunning.resolve(true);
- else isPausedOrNotRunning.reject();
- },{'vm':vm.id,'state':'pause'});
- pl.run();
- } else {
- isPausedOrNotRunning.resolve();
- }
-
-
- $(this).dialog('close');
-
-
- };
- buttons[trans('Cancel','QIMessageBox')] = function() { $(this).dialog('close'); };
-
- $('#vboxSnapshotNew').dialog({'closeOnEscape':false,'width':'400px','height':'auto','buttons':buttons,'modal':true,'autoOpen':true,'dialogClass':'vboxDialogContent','title':'<img src="images/vbox/snapshot_take_16px.png" class="vboxDialogTitleIcon" height="16" width="16" /> ' + trans('Take Snapshot of Virtual Machine','VBoxTakeSnapshotDlg')});
-
- }
- },
- {
- 'name' : 'discard_cur_state',
- 'label' : 'Restore Snapshot',
- 'icon' : 'snapshot_restore',
- 'enabled' : function(item) {
- var vm = vboxChooser.getSingleSelected();
- return ( item && $(item).data('vboxSnapshot') && $(item).data('vboxSnapshot') && $(item).data('vboxSnapshot').name && $(item).data('vboxSnapshot').state != 'current' && !vboxVMStates.isRunning(vm) && !vboxVMStates.isPaused(vm));
- },
- 'click' : function () {
-
- var vm = vboxChooser.getSingleSelected();
-
- var snapshot = $('#vboxSnapshotList').find('div.vboxListItemSelected').first().parent().data('vboxSnapshot');
-
- var buttons = {};
- var q = '';
-
- // Check if the current state is modified
- if(vm.currentStateModified) {
-
- q = trans("<p>You are about to restore snapshot <nobr><b>%1</b></nobr>.</p>" +
- "<p>You can create a snapshot of the current state of the virtual machine first by checking the box below; " +
- "if you do not do this the current state will be permanently lost. Do you wish to proceed?</p>",'UIMessageCenter');
- q += '<p><label><input type="checkbox" id="vboxRestoreSnapshotCreate" checked /> ' + trans('Create a snapshot of the current machine state','UIMessageCenter') + '</label></p>';
-
- buttons[trans('Restore','UIMessageCenter')] = function() {
-
- var snrestore = function(takeSnapshot){
-
- // Don't do anything if taking a snapshot failed
- if(takeSnapshot && !takeSnapshot.success)
- return;
-
- var l = new vboxLoader();
- l.add('snapshotRestore',function(d){
- if(d && d.responseData && d.responseData.progress) {
- vboxProgress({'progress':d.responseData.progress,'persist':d.persist},function(){
-
- // Let events get picked up. Nothing to do here
-
- },'progress_snapshot_restore_90px.png',trans('Restore Snapshot','VBoxSnapshotsWgt'),
- vm.name);
- } else if(d && d.error) {
- vboxAlert(d.error);
- }
- },{'vm':vm.id,'snapshot':snapshot.id});
-
- l.run();
-
- };
-
- if($('#vboxRestoreSnapshotCreate').prop('checked')) {
- vboxSnapshotButtons[0].click(snrestore);
- } else {
- snrestore();
- }
- $(this).empty().remove();
- };
-
- } else {
-
- q = trans('<p>Are you sure you want to restore snapshot <nobr><b>%1</b></nobr>?</p>','UIMessageCenter');
-
- buttons[trans('Restore','UIMessageCenter')] = function() {
- var l = new vboxLoader();
- l.add('snapshotRestore',function(d){
- if(d && d.responseData && d.responseData.progress) {
- vboxProgress({'progress':d.responseData.progress,'persist':d.persist},function(){
-
- // Let events get picked up. Nothing to do here
-
- },'progress_snapshot_restore_90px.png',trans('Restore Snapshot','VBoxSnapshotsWgt'),
- vm.name);
- } else if(d && d.error) {
- vboxAlert(d.error);
- }
- },{'vm':vm.id,'snapshot':snapshot.id});
- $(this).empty().remove();
-
- l.run();
-
- };
- }
-
- vboxConfirm(q.replace('%1',$('<div />').text(snapshot.name).html()),buttons);
- },
- 'separator' : true
- },
- {
- 'name' : 'delete_snapshot',
- 'label' : 'Delete Snapshot',
- 'icon' : 'snapshot_delete',
- 'enabled' : function(item) {
- return (item && $(item).data('vboxSnapshot') && $(item).data('vboxSnapshot').name && $(item).data('vboxSnapshot').state != 'current' && $(item).data('vboxSnapshot').children.length <= 1);
- },
- 'click' : function () {
- var vm = vboxChooser.getSingleSelected();
- var snapshot = $('#vboxSnapshotList').find('div.vboxListItemSelected').first().parent().data('vboxSnapshot');
- var buttons = {};
- buttons[trans('Delete','UIMessageCenter')] = function() {
- var l = new vboxLoader();
- l.add('snapshotDelete',function(d){
- if(d && d.responseData && d.responseData.progress) {
- vboxProgress({'progress':d.responseData.progress,'persist':d.persist},function(){
-
- // Let events get picked up. Nothing to do here
-
- },'progress_snapshot_discard_90px.png',trans('Delete Snapshot','VBoxSnapshotsWgt'),
- vm.name + ' - ' + snapshot.name);
- }
- },{'vm':vm.id,'snapshot':snapshot.id});
- $(this).empty().remove();
-
- l.run();
- };
- vboxConfirm(trans('<p>Deleting the snapshot will cause the state information saved in it to be lost, and '+
- 'storage data spread over several image files that VirtualBox has created together with the snapshot '+
- 'will be merged into one file. This can be a lengthy process, and the information in the snapshot cannot '+
- 'be recovered.</p></p>Are you sure you want to delete the selected snapshot <b>%1</b>?</p>','UIMessageCenter').replace('%1',$('<div />').text(snapshot.name).html()),buttons);
- }
- },
- {
- 'name' : 'show_snapshot_details',
- 'label' : 'Show Details',
- 'icon' : 'snapshot_show_details',
- 'enabled' : function(item) {
- return (item && $(item).data('vboxSnapshot') && $(item).data('vboxSnapshot').name && $(item).data('vboxSnapshot').state != 'current');
- },
- 'click' : function () {
-
- // Current snapshot
- var snapshot = $('#vboxSnapshotList').find('div.vboxListItemSelected').first().parent().data('vboxSnapshot');
-
- var vm = vboxChooser.getSingleSelected();
-
- var l = new vboxLoader();
- l.add('snapshotGetDetails',function(d){
-
- $('#vboxSnapshotDetailsName').val(d.responseData.name);
- $('#vboxSnapshotDetailsTaken').html(vboxDateTimeString(d.responseData.timeStamp));
- $('#vboxSnapshotDetailsDesc').val(d.responseData.description);
-
- if(d.responseData.online) {
- $('#vboxSnapshotSS').html('<a href="'+ vboxEndpointConfig.screen +'?vm='+vm.id+
- '&snapshot='+d.responseData.id+'&full=1" target="_blank"><img src="'+vboxEndpointConfig.screen+'?vm='+
- vm.id+'&snapshot='+d.responseData.id+'" /></a>').show();
- } else {
- $('#vboxSnapshotSS').empty().hide();
- }
-
- // Display details
- $('#vboxSnapshotDetailsVM').empty();
-
- // Enclosing details Table
- var vboxDetailsTable = $('<table />').attr({'class':'vboxDetailsTable'});
-
- // Set to isSnapshot
- d.responseData.machine._isSnapshot = true;
-
- for(var i in vboxVMDetailsSections) {
-
- section = vboxVMDetailsSections[i];
-
- if(section.noSnapshot) continue;
-
- $('<tr />').attr({'class':'vboxDetailsHead'}).append(
- $('<th />').attr({'class':'vboxDetailsSection','colspan':'2'}).disableSelection()
- .html("<img style='float:left; margin-right: 3px; ' src='images/vbox/" + section.icon + "' height='16' width='16' /> ")
- .append(
- $('<span />').css({'float':'left'}).append(document.createTextNode(trans(section.title, section.language_context) +' '))
- )
- ).appendTo(vboxDetailsTable);
-
- __vboxDetailAddRows(d.responseData.machine, section.rows, vboxDetailsTable);
-
- }
-
- $('#vboxSnapshotDetailsVM').append(vboxDetailsTable);
-
-
- },{'vm':vm.id,'snapshot':snapshot.id});
- l.onLoad = function(){
-
- var buttons = {};
- buttons[trans('OK','QIMessageBox')] = function() {
-
- // Current snapshot
- var snapshot = $('#vboxSnapshotList').find('div.vboxListItemSelected').first().parent().data('vboxSnapshot');
-
- var l = new vboxLoader();
- l.add('snapshotSave',function(d){
-
- // Let events get picked up. Nothing to do here
-
- },{'vm':vm.id,'snapshot':snapshot.id,'name':$('#vboxSnapshotDetailsName').val(),'description':$('#vboxSnapshotDetailsDesc').val()});
- $(this).dialog('close');
- l.run();
-
- };
- buttons[trans('Cancel','QIMessageBox')] = function(){
- $(this).dialog('close');
- };
- $('#vboxSnapshotDetails').dialog({'closeOnEscape':false,'width':'600px','height':'auto','buttons':buttons,'modal':true,'autoOpen':true,'dialogClass':'vboxDialogContent','title':'<img src="images/vbox/snapshot_show_details_16px.png" class="vboxDialogTitleIcon" /> '+trans('Details of %1 (%2)','VBoxSnapshotDetailsDlg').replace('%1',$('<div />').text(snapshot.name).html()).replace('%2',vm.name)});
- };
- l.run();
- }
- },
- {
- 'name' : 'clone',
- 'label' : 'Clone...',
- 'language_context': 'UIActionPool',
- 'icon' : 'vm_clone',
- 'separator' : true,
- 'enabled' : function(item) {
- var vm = vboxChooser.getSingleSelected();
- return (item && $(item).data('vboxSnapshot') && $(item).data('vboxSnapshot').name && !vboxVMStates.isPaused(vm) && !vboxVMStates.isRunning(vm));
- },
- 'click' : function () {
-
- var vm = vboxChooser.getSingleSelected();
-
- // Current snapshot
- var snapshot = $('#vboxSnapshotList').find('div.vboxListItemSelected').first().parent().data('vboxSnapshot');
-
- new vboxWizardCloneVMDialog({'vm':vm,'snapshot':(snapshot.state == 'current' ? undefined : snapshot)}).run();
-
- }
- },
-
-
-
-];
-
-
-/* Append Top Toolbar */
-var vboxSnapshotToolbar = new vboxToolbarSmall({buttons: vboxSnapshotButtons, size: 22, language_context: 'VBoxSnapshotsWgt'});
-// special case for 'clone' button because it is 16px rather than 22px
-vboxSnapshotToolbar.addButtonCSS('clone', {'background-position':'6px 4px'});
-vboxSnapshotToolbar.renderTo('vboxSnapshotToolbar');
-
-vboxInitDisplay('vboxSnapshotToolbar','VBoxSnapshotsWgt');
-
-// Context menu for snapshots
-var vboxSnapshotContextMenu = new vboxMenu({name:'vboxSnapshotContextMenu', language_context: 'VBoxSnapshotsWgt'});
-vboxSnapshotContextMenu.addMenu(vboxSnapshotButtons.slice(-(vboxSnapshotButtons.length-1)));
-
-//Context menu for current state
-var vboxSnapshotContextMenuCurrent = new vboxMenu({name: 'vboxSnapshotContextMenuCurrent', language_context: 'VBoxSnapshotsWgt'});
-vboxSnapshotContextMenuCurrent.addMenu([vboxSnapshotButtons[0],vboxSnapshotButtons[(vboxSnapshotButtons.length-2)]]);
-
-
-/* Toolbar and menu updates*/
-$('#vboxSnapshotList').on('select',function(e,item) {
-
- // Update toolbar
- vboxSnapshotToolbar.update(item);
-
- vboxSnapshotContextMenu.update(item);
- vboxSnapshotContextMenuCurrent.update(item);
-
-});
-
-// Hold timer and date vars
-vboxSnapshotToolbar._timer = null;
-vboxSnapshotToolbar._timeSpans = new Array();
-vboxSnapshotToolbar._timeSpans['days'] = 86400;
-vboxSnapshotToolbar._timeSpans['hours'] = 3600,
-vboxSnapshotToolbar._timeSpans['minutes'] = 60,
-vboxSnapshotToolbar._timeSpans['seconds'] = 1;
-vboxSnapshotToolbar._timeSpans.sort(function(a,b){return (a > b ? -1 : 1);});
-
-
-
-/* Selected VM changed */
-$('#vboxPane').on('vmSelectionListChanged',function(){
-
- $('#vboxTabVMSnapshotsTitle').html(trans('Snapshots','UIVMDesktop'));
-
- var vm = vboxChooser.getSingleSelected();
-
- $('#vboxSnapshotList').trigger('select',null);
-
- // Got vm and it's not host
- if(vm && vm.id != 'host') {
-
- // Enable tab
- $('#vboxTabVMSnapshots').parent().trigger('enableTab', ['vboxTabVMSnapshots']);
-
- $.when(vboxVMDataMediator.getVMDetails(vm.id)).done(function(vm) {
- $('#vboxTabVMSnapshotsTitle').html(trans('Snapshots','UIVMDesktop') + (vm && vm.snapshotCount ? trans(' (%1)','VBoxSnapshotsWgt').replace('%1',vm.snapshotCount):''));
- });
-
- // Unset last vm
- $('#vboxTabVMSnapshots').data('lastVM',0);
-
- // Remove children
- $('#vboxSnapshotList').children().empty().remove();
-
- // Fill snapshots if this tab is being shown
- if($('#vboxTabVMSnapshots').data('vboxShowing')) {
-
- // Keep track of last VM shown
- $('#vboxTabVMSnapshots').data('lastVM',vm.id);
-
- // append spinner
- $('#vboxSnapshotList').append($('<li />').attr({'class':'last'}).html("<div><img src='images/spinner.gif'></div>"));
-
- $.when(vboxAjaxRequest('machineGetSnapshots',{'vm':vm.id})).done(__vboxTabSnapshotsFill);
-
- }
-
- // No single selected VM or it is host
- } else {
- // disable tab
- $('#vboxTabVMConsole').parent().trigger('disableTab', ['vboxTabVMSnapshots']);
- $('#vboxTabVMSnapshots').data('lastVM',0);
- }
-
-/**
- *
- * VBOX event list triggered
- *
- */
-}).on('vboxEvents',function(e,eventList) {
-
- var redrawCurrent = false;
-
- for(var i = 0; i < eventList.length; i++) {
-
- switch(eventList[i].eventType) {
-
- //////////////////////////
- //
- // Snapshot events
- //
- /////////////////////////
- case 'OnSnapshotTaken':
- case 'OnSnapshotDeleted':
- case 'OnSnapshotRestored':
- case 'OnSnapshotChanged':
-
- // Is this vm selected
- if(vboxChooser.getSingleSelectedId() == eventList[i].machineId) {
-
- // Update title
- $('#vboxTabVMSnapshotsTitle').html(trans('Snapshots','UIVMDesktop') +
- (eventList[i].enrichmentData && eventList[i].enrichmentData.snapshotCount ? trans(' (%1)','VBoxSnapshotsWgt').replace('%1',eventList[i].enrichmentData.snapshotCount):''));
-
- // Redraw snapshots if this is shown
- if($('#vboxTabVMSnapshots').data('lastVM') == eventList[i].machineId) {
-
- $('#vboxSnapshotList').children().empty().remove();
-
- // Append spinner
- $('#vboxSnapshotList').append($('<li />').attr({'class':'last'}).html("<div><img src='images/spinner.gif'></div>"));
-
-
- $.when(vboxAjaxRequest('machineGetSnapshots',{'vm':eventList[i].machineId})).done(__vboxTabSnapshotsFill);
-
- return;
-
- }
- }
- break;
-
- /////////////////////////
- //
- // Session or state change
- //
- ////////////////////////
- case 'OnSessionStateChanged':
- case 'OnMachineStateChanged':
- if($('#vboxTabVMSnapshots').data('lastVM') == eventList[i].machineId && vboxChooser.getSingleSelectedId() == eventList[i].machineId) {
- redrawCurrent = true;
- }
- break;
-
- }
-
- }
-
- // Redraw current snapshot
- if(redrawCurrent) {
-
- var vmid = vboxChooser.getSingleSelectedId();
-
- // Get current state and details data
- $.when(vboxVMDataMediator.getVMData(vmid), vboxVMDataMediator.getVMDetails(vmid)).done(function(vm, vmd) {
-
- if($('#vboxTabVMSnapshots').data('lastVM') != vm.id) return;
-
- var selected = $('#vboxTabVMSnapshots').find('li.vboxSnapshotCurrentState').children('div.vboxListItemSelected').length;
- $('#vboxTabVMSnapshots').find('li.vboxSnapshotCurrentState').replaceWith(__vboxTabSnapshotCurrent($.extend(true,{},vm,vmd)));
- if(selected) {
- $('#vboxSnapshotList').trigger('select',
- $('#vboxTabVMSnapshots').find('li.vboxSnapshotCurrentState').children('div.vboxListItem').addClass('vboxListItemSelected').parent());
- }
- });
- }
-
-
-});
-
-// Load snapshots on show
-$('#vboxTabVMSnapshots').on('show',function(e){
-
- $('#vboxTabVMSnapshots').data('vboxShowing', 1);
-
- var vm = vboxChooser.getSingleSelected();
-
- if(vm && vm.id) {
- if($('#vboxTabVMSnapshots').data('lastVM') == vm.id) return;
- $('#vboxTabVMSnapshots').data('lastVM', vm.id);
- } else {
- $('#vboxSnapshotList').children().remove();
- $('#vboxTabVMSnapshots').data('lastVM',0);
- vboxSnapshotToolbar.disable();
- return;
- }
-
-
- // Get snapshots
- // Append spinner
- $('#vboxSnapshotList').append($('<li />').attr({'class':'last'}).html("<div><img src='images/spinner.gif'></div>"));
- $.when(vboxAjaxRequest('machineGetSnapshots',{'vm':vm.id})).done(__vboxTabSnapshotsFill);
-
-
-}).on('hide',function(e) {
- $('#vboxTabVMSnapshots').data('vboxShowing', 0);
-});
-
-/*
- * Fill Snapshots
-*/
-function __vboxTabSnapshotsFill(response) {
-
- var snapshotData = response.responseData;
-
- if(vboxSnapshotToolbar._timer) {
- window.clearTimeout(vboxSnapshotToolbar._timer);
- vboxSnapshotToolbar._timer = null;
- }
-
- if(!snapshotData) return;
-
- // Get current state and details data
- $.when(vboxVMDataMediator.getVMData(response.responseData.vm), vboxVMDataMediator.getVMDetails(response.responseData.vm)).done(function(vm, vmd) {
-
- if($('#vboxTabVMSnapshots').data('lastVM') != vm.id) return;
-
- var list = $('#vboxSnapshotList');
- $(list).children().remove();
-
- var vmc = $.extend(true, {}, vm, vmd);
-
- // Snapshots exist
- if(snapshotData.snapshot && snapshotData.snapshot.name) {
-
- // Traverse snapshots
- $(list).append(__vboxTabSnapshot(snapshotData.snapshot, snapshotData.currentSnapshotId));
-
- // Append current state to last snapshot
- if(snapshotData.currentSnapshotId) {
-
- // Has children
- if($('#'+snapshotData.currentSnapshotId).children('ul').first()[0]) {
- $('#'+snapshotData.currentSnapshotId).children('ul').last().append(__vboxTabSnapshotCurrent(vmc));
- } else {
- $('#'+snapshotData.currentSnapshotId).append($('<ul />').append(__vboxTabSnapshotCurrent(vmc)));
- };
- };
-
- // No snapshots. Append current state to list
- } else {
- $(list).append(__vboxTabSnapshotCurrent(vmc));
- }
-
- // Init vbox tree list
- $('#vboxSnapshotList').vbtree();
-
- vboxSnapshotToolbar.enable();
-
- $('#vboxSnapshotList').trigger('select');
-
- __vboxTabSnapshotTimestamps();
-
- });
-
-}
-
-/* Snapshot list item */
-function __vboxTabSnapshot(s, currentId) {
-
- var li = $('<li />').attr({'id':s.id});
- $(li).data('vboxSnapshot',s);
-
- // Use timestamp
- var t = '';
- if(s.timeStampSplit['seconds'] == 0)
- s.timeStampSplit['seconds'] = 1;
-
- var ago = 0;
- var ts = 'seconds';
- for(var i in s.timeStampSplit) {
- var l = Math.floor(t / s.timeStampSplit[i]);
- if(l > 0) {
- ago = l;
- ts = i;
- break;
- }
- }
-
- switch(ts) {
- case 'days':
- ts = trans('%n day(s)','VBoxGlobal', ago).replace('%n', ago);
- break;
- case 'hours':
- ts = trans('%n hour(s)', 'VBoxGlobal', ago).replace('%n', ago);
- break;
- case 'minutes':
- ts = trans('%n minute(s)', 'VBoxGlobal', ago).replace('%n', ago);
- break;
- case 'seconds':
- ts = trans('%n second(s)', 'VBoxGlobal', ago).replace('%n', ago);
- break;
- }
- ts = trans(' (%1 ago)','VBoxSnapshotsWgt').replace('%1', ts);
-
- $(li).append(' ').append(
-
- $('<div />').attr({'class':'vboxListItem'})
- .html('<img src="images/vbox/snapshot_'+(s.online ? 'online' : 'offline')+'_16px.png" height="16" width="16" /> ' +
- $('<div />').text(s.name).html())
- .append($('<span />').attr({'class':'timestamp'}).data({'vboxTimestamp':s.timeStamp}).text(ts))
-
- // Context menu
- .contextMenu({
- menu: vboxSnapshotContextMenu.menuId(),
- clickthrough: true
- },vboxSnapshotContextMenu.menuClickCallback)
-
- // show details on dblclick
- .dblclick(vboxSnapshotButtons[4].click).disableSelection()
-
- // tool tip
- .tipped({'position':'mouse','delay':1500,'source':'<p><strong>'+$('<div />').text(s.name).html()+'</strong> ('+trans((s.online ? 'online)' : 'offline)'),'VBoxSnapshotsWgt')+'</p>'+
- '<p>'+ vboxDateTimeString(s.timeStamp, trans('Taken at %1','VBoxSnapshotsWgt'), trans('Taken on %1','VBoxSnapshotsWgt'))+'</p>' +
- (s.description ? '<hr />' + $('<div />').text(s.description).html() : '')})
-
- ).addClass(currentId == s.id ? 'vboxSnapshotCurrent' : '').children('div.vboxListItem').first().click(function(){
- $('#vboxSnapshotList').find('div.vboxListItemSelected').first().removeClass('vboxListItemSelected');
- $(this).addClass('vboxListItemSelected');
- $('#vboxSnapshotList').trigger('select',$(this).parent());
- });
-
-
- if(s.children.length) {
- var ul = $('<ul />');
- for(var i = 0; i < s.children.length; i++) {
- $(ul).append(__vboxTabSnapshot(s.children[i], currentId));
- }
- $(li).append(ul);
- }
-
-
-
- return li;
-}
-
-/* Current state list item */
-function __vboxTabSnapshotCurrent(vm) {
-
- return $('<li />').data('vboxSnapshot',{'state':'current','name':trans((vm.currentStateModified ? 'Current State (changed)' : 'Current State'),'VBoxSnapshotsWgt')}).html(' ')
- .addClass('last vboxSnapshotCurrent vboxSnapshotCurrentState')
- .append(
- $('<div />').attr({'class':'vboxListItem'}).html('<img src="images/vbox/'+vboxMachineStateIcon(vm.state)+'" height="16" width="16" /> ' + $('<div />').text(trans((vm.currentStateModified ? 'Current State (changed)' : 'Current State'),'VBoxSnapshotsWgt')).html())
- .contextMenu({
- menu: vboxSnapshotContextMenuCurrent.menuId(),
- clickthrough : true
- },vboxSnapshotContextMenuCurrent.menuClickCallback)
- .click(function(){
- $('#vboxSnapshotList').find('div.vboxListItemSelected').first().removeClass('vboxListItemSelected');
- $(this).addClass('vboxListItemSelected');
- $('#vboxSnapshotList').trigger('select',$(this).parent());
- })
- .tipped({'position':'mouse','delay':1500,'source':'<strong>'+
- trans((vm.currentStateModified ? 'Current State (changed)' : 'Current State'),'VBoxSnapshotsWgt') + '</strong><br />'+
- trans('%1 since %2','VBoxSnapshotsWgt').replace('%1',trans(vboxVMStates.convert(vm.state),'VBoxGlobal'))
- .replace('%2',vboxDateTimeString(vm.lastStateChange))
- + (vm.snapshotCount > 0 ? '<hr />' + (vm.currentStateModified ?
- trans('The current state differs from the state stored in the current snapshot','VBoxSnapshotsWgt')
- : trans('The current state is identical to the state stored in the current snapshot','VBoxSnapshotsWgt'))
- : '')
- })
- );
-
-}
-
-
-/* Update snapshot timestamps */
-function __vboxTabSnapshotTimestamps() {
-
- // Shorthand
- var timeSpans = vboxSnapshotToolbar._timeSpans;
-
- // Keep minimum timestamp
- var minTs = 60;
-
- var currentTime = new Date();
- currentTime = Math.floor(currentTime.getTime() / 1000);
-
- $('#vboxTabVMSnapshots').find('span.timestamp').each(function(){
-
- var sts = parseInt($(this).data('vboxTimestamp'));
- var t = Math.max(currentTime - sts, 1);
-
- minTs = Math.min(minTs,t);
-
- // Check for max age.
- if(Math.floor(t / 86400) > 30) {
- var sdate = new Date(sts * 1000);
- $(this).html(trans(' (%1)','VBoxSnapshotsWgt').replace('%1',sdate.toLocaleString()));
- return;
- }
-
- var ago = 0;
- var ts = 'seconds';
- for(var i in timeSpans) {
- var l = Math.floor(t / timeSpans[i]);
- if(l > 0) {
- ago = l;
- ts = i;
- break;
- }
- }
- switch(ts) {
- case 'days':
- ts = trans('%n day(s)', 'VBoxGlobal', ago).replace('%n', ago);
- break;
- case 'hours':
- ts = trans('%n hour(s)', 'VBoxGlobal', ago).replace('%n', ago);
- break;
- case 'minutes':
- ts = trans('%n minute(s)', 'VBoxGlobal', ago).replace('%n', ago);
- break;
- case 'seconds':
- ts = trans('%n second(s)', 'VBoxGlobal', ago).replace('%n', ago);
- break;
- }
- $(this).html(ts = trans(' (%1 ago)','VBoxSnapshotsWgt').replace('%1', ts));
- });
-
- var timerSet = (minTs >= 60 ? 60 : 10);
- vboxSnapshotToolbar._timer = window.setTimeout(__vboxTabSnapshotTimestamps,(timerSet * 1000));
-}
-
-
-</script>
-</div> \ No newline at end of file
+<!--
+
+ VM Snapshots Pane
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: tabVMSnapshots.html 595 2015-04-17 09:50:36Z imoore76 $
+
+ -->
+<div id='vboxTabVMSnapshots' class='vboxInvisible' style='display: none; width:100%;'>
+
+ <table class='vboxInvisible' style='height: 99%; width: 99%'>
+ <tr style='vertical-align: top; height: 1%'>
+ <td><div id='vboxSnapshotToolbar'></div></td>
+ </tr>
+ <tr style='vertical-align: top;'>
+ <td><ul style='min-height: 400px' class='vboxBordered vboxTreeView' id='vboxSnapshotList'></ul></td>
+ </tr>
+ </table>
+<!--
+
+ New Snapshot Dialog
+
+ -->
+ <div id='vboxSnapshotNew' class='vboxDialogContent' style='display: none;'>
+ <table class='vboxVertical'>
+ <tr style='vertical-align: top'>
+ <th>
+ <img id='vboxSnapshotNewImg' src='images/vbox/os_other.png' height='32' width='32' />
+ </th>
+ <td>
+ <div style='height: 100%'>
+ <div class='translate'>Snapshot Name</div>
+ <input id='vboxSnapshotNewName' style='width: 100%'/>
+ <div class='translate'>Snapshot Description</div>
+ <textarea rows='10' id='vboxSnapshotNewDesc' style='width: 100%;'></textarea>
+ </div>
+ </td>
+ </tr>
+ </table>
+ </div>
+
+
+<!--
+
+ Snapshot Details Dialog
+
+ -->
+ <div id='vboxSnapshotDetails' class='vboxDialogContent' style='display: none;'>
+ <table class='vboxVertical'>
+ <tr>
+ <th><span class='translate'>Name:</span></th>
+ <td style='width:100%'>
+ <input id='vboxSnapshotDetailsName' style='width: 100%'/>
+ </td>
+ <td rowspan='2' id='vboxSnapshotSS' style='width:1%'></td>
+ </tr>
+ <tr>
+ <th><span class='translate'>Taken:</span></th>
+ <td style='width:100%'>
+ <span id='vboxSnapshotDetailsTaken'></span>
+ </td>
+ </tr>
+ <tr>
+ <th><span class='translate'>Description:</span></th>
+ <td colspan='2'>
+ <textarea rows='12' id='vboxSnapshotDetailsDesc' name='vboxSnapshotDetailsDescElm'></textarea>
+ </td>
+ </tr>
+ <tr>
+ <th><span class='translate'>Details:</span></th>
+ <td class='vboxSnapshotDetailsMachine' colspan='2'>
+ <div id='vboxSnapshotDetailsVM' style='overflow: auto; height: 100%'></div>
+ </td>
+ </tr>
+ </table>
+ </div>
+
+
+
+<script type='text/javascript'>
+
+vboxInitDisplay('vboxSnapshotNew','VBoxTakeSnapshotDlg');
+vboxInitDisplay('vboxSnapshotDetails','VBoxSnapshotDetailsDlg');
+
+var vboxSnapshotButtons = [
+
+ {
+ 'name' : 'take_snapshot',
+ 'label' : 'Take Snapshot...',
+ 'language_context': 'UIActionPool',
+ 'icon' : 'snapshot_take',
+ 'enabled' : function(item) {
+
+ if(typeof item == 'string') state = item;
+ else if(item && $(item).data('vboxSnapshot')) state = $(item).data('vboxSnapshot').state;
+ else return false;
+
+ var vm = vboxChooser.getSingleSelected();
+ return (item && state == 'current' && jQuery.inArray(vm.state, ['RestoringSnapshot','LiveSnapshotting','DeletingSnapshot']) == -1);
+ },
+ 'click' : function (callback) {
+
+ var vm = vboxChooser.getSingleSelected();
+
+ $('#vboxSnapshotNewImg').attr('src',"images/vbox/" + vboxGuestOSTypeIcon(vm.OSTypeId));
+
+ var snRegEx = new RegExp('^' + trans('Snapshot %1','VBoxSnapshotsWgt').replace('%1','([0-9]+)') + '$');
+
+ // Get max snapshot name
+ var snMax = 0;
+ var snList = $('#vboxSnapshotList').find('li');
+ for(var i = 0; i < snList.length; i++) {
+ var snNum = snRegEx.exec($(snList[i]).data('vboxSnapshot').name);
+ if(snNum) snMax = Math.max(parseInt(snNum[1]), snMax);
+ }
+
+ $('#vboxSnapshotNewName').val(trans('Snapshot %1','VBoxSnapshotsWgt').replace('%1',(snMax+1)));
+ $('#vboxSnapshotNewName').select();
+ $('#vboxSnapshotNewDesc').val('');
+
+
+ var buttons = {};
+ var OKBtn = buttons[trans('OK','QIMessageBox')] = function() {
+
+ // Get fresh VM state when this is clicked
+ var vm = vboxChooser.getSingleSelected();
+ if(!vm) return;
+
+ // Deferred object that will trigger
+ // taking a snapshot on success
+ var isPausedOrNotRunning = $.Deferred();
+
+ // Take snapshot function when machine is in
+ // a valid paused or not running state
+ $.when(isPausedOrNotRunning).done(function(paused) {
+
+ var l = new vboxLoader('snapshotTake');
+ l.add('snapshotTake',function(d){
+ if(d && d.responseData && d.responseData.progress) {
+ vboxProgress({'progress':d.responseData.progress,'persist':d.persist},function(pres){
+
+ // Unpause machine if it was paused
+ if(paused) {
+ vboxAjaxRequest('machineSetState',{'vm':vm.id,'state':'resume'});
+ }
+
+ // If progress operation errored, refresh snapshot list
+ if(pres && !pres.success)
+ $.when(vboxAjaxRequest('machineGetSnapshots',{'vm':vm.id})).done(__vboxTabSnapshotsFill);
+
+ // callback passed to click()? else Refresh vm list
+ if(typeof callback == 'function') { callback(pres); }
+
+ },'progress_snapshot_create_90px.png', trans('Take a snapshot of the current virtual machine state','VBoxSnapshotsWgt'),
+ vm.name);
+
+ } else {
+
+ // Unpause machine if it was paused
+ if(paused) {
+ vboxAjaxRequest('machineSetState',{'vm':vm.id,'state':'resume'});
+ }
+
+ if(d && d.error) vboxAlert(d.error);
+ $.when(vboxAjaxRequest('machineGetSnapshots',{'vm':vm.id})).done(__vboxTabSnapshotsFill);
+ }
+ },{'vm':vm.id,'name':$('#vboxSnapshotNewName').val(),'description':$('#vboxSnapshotNewDesc').val()});
+ l.run();
+
+ }).fail(function(){
+
+ $.when(vboxAjaxRequest('machineGetSnapshots',{'vm':vm.id})).done(__vboxTabSnapshotsFill);
+
+ });
+
+ // Set to paused state if VM is running
+ if(vboxVMStates.isRunning(vm)) {
+ var pl = new vboxLoader('machineSetStatePaused');
+ pl.add('machineSetState', function(d) {
+ if(d && d.success) isPausedOrNotRunning.resolve(true);
+ else isPausedOrNotRunning.reject();
+ },{'vm':vm.id,'state':'pause'});
+ pl.run();
+ } else {
+ isPausedOrNotRunning.resolve();
+ }
+
+
+ $(this).dialog('close');
+
+
+ };
+ buttons[trans('Cancel','QIMessageBox')] = function() {
+ $(this).dialog('close');
+ if(typeof callback == 'function') { callback({success:false,uicancel:true}); }
+ };
+
+ $('#vboxSnapshotNewName').off('keypress').on('keypress',function(e) { if (e.keyCode == 13) OKBtn.apply($('#vboxSnapshotNew')); });
+
+ $('#vboxSnapshotNew').dialog({'closeOnEscape':false,'width':'400px','height':'auto','buttons':buttons,'modal':true,'autoOpen':true,'dialogClass':'vboxDialogContent','title':'<img src="images/vbox/snapshot_take_16px.png" class="vboxDialogTitleIcon" height="16" width="16" /> ' + trans('Take Snapshot of Virtual Machine','VBoxTakeSnapshotDlg')});
+
+ }
+ },
+ {
+ 'name' : 'discard_cur_state',
+ 'label' : 'Restore Snapshot',
+ 'icon' : 'snapshot_restore',
+ 'enabled' : function(item) {
+ var vm = vboxChooser.getSingleSelected();
+ return ( item && $(item).data('vboxSnapshot') && $(item).data('vboxSnapshot') && $(item).data('vboxSnapshot').name && $(item).data('vboxSnapshot').state != 'current');
+ },
+ 'click' : function () {
+
+ var vm = vboxChooser.getSingleSelected();
+
+ var snapshot = $('#vboxSnapshotList').find('div.vboxListItemSelected').first().parent().data('vboxSnapshot');
+
+ var buttons = {};
+ var q = '';
+
+ // Check if the current state is modified
+ if(vm.currentStateModified) {
+
+ q = trans("<p>You are about to restore snapshot <nobr><b>%1</b></nobr>.</p>" +
+ "<p>You can create a snapshot of the current state of the virtual machine first by checking the box below; " +
+ "if you do not do this the current state will be permanently lost. Do you wish to proceed?</p>",'UIMessageCenter');
+ q += '<p><label><input type="checkbox" id="vboxRestoreSnapshotCreate" checked /> ' + trans('Create a snapshot of the current machine state','UIMessageCenter') + '</label></br>';
+ q += '<label><input type="checkbox" id="vboxRestoreSnapshotAutoStart" '+ (vboxVMStates.isRunning(vm)? 'checked' : '') + ' /> ' + trans('Automatically start the machine after restore','UIMessageCenter') + '</label></p>';
+
+ buttons[trans('Restore','UIMessageCenter')] = function() {
+
+ var self = this;
+ var snautostart = function() {
+ var l = new vboxLoader();
+ l.add('machineSetState',function(d){
+ if(!(d && d.success) && errorMsg) {
+ vboxAlert(errorMsg.replace('%1', vm.name));
+ return;
+ }
+ // check for progress operation
+ if(d && d.responseData && d.responseData.progress) {
+ vboxProgress({'progress':d.responseData.progress,'persist':d.persist},function(d){
+ // Do Nothing
+ },'progress_state_restore_90px.png',trans('Power on virtual machine','VBoxSnapshotsWgt'), vm.name);
+ return;
+ }
+ },{'vm':vm.id,'state':'powerUp'});
+
+ l.run();
+ };
+
+ var snrestore = function(autoStart,takeSnapshot){
+
+ // Don't do anything if taking a snapshot failed
+ if(takeSnapshot && !takeSnapshot.success) {
+ if (takeSnapshot.uicancel)
+ vboxSnapshotButtons[1].click();
+ return;
+ }
+
+ // Power off VM if needed
+ if(vboxVMStates.isRunning(vm) || vboxVMStates.isPaused(vm)) {
+ var l = new vboxLoader();
+ l.add('machineSetState',function(d){
+ if(!(d && d.success) && errorMsg) {
+ vboxAlert(errorMsg.replace('%1', vm.name));
+ return;
+ }
+ // check for progress operation
+ if(d && d.responseData && d.responseData.progress) {
+ vboxProgress({'progress':d.responseData.progress,'persist':d.persist},function(d){
+ if (d && d.responseData && d.responseData.info) {
+ // when poweroff completed
+ if (d.responseData.info.completed) {
+ // schedule snapshot restore immediate after
+ setTimeout(snrestore.bind(self,autoStart,takeSnapshot),0);
+ }
+ }
+ },'progress_poweroff_90px.png',trans('Power off virtual machine','VBoxSnapshotsWgt'), vm.name);
+ }
+ },{'vm':vm.id,'state':'powerDown'});
+
+ l.run();
+ return;
+ }
+
+ var l = new vboxLoader();
+ l.add('snapshotRestore',function(d){
+ if(d && d.responseData && d.responseData.progress) {
+ vboxProgress({'progress':d.responseData.progress,'persist':d.persist},function(d){
+ if (d && d.responseData && d.responseData.info) {
+ // when restore completed and auto start is requested
+ if (d.responseData.info.completed && autoStart) {
+ // schedule start immediately
+ setTimeout(snautostart.bind(self), 0);
+ }
+ }
+ },'progress_snapshot_restore_90px.png',trans('Restore Snapshot','VBoxSnapshotsWgt'),
+ vm.name);
+ } else if(d && d.error) {
+ vboxAlert(d.error);
+ }
+ },{'vm':vm.id,'snapshot':snapshot.id});
+
+ l.run();
+
+ };
+
+ var vmRestoreAutoStart = $('#vboxRestoreSnapshotAutoStart').prop('checked');
+ if($('#vboxRestoreSnapshotCreate').prop('checked')) {
+ vboxSnapshotButtons[0].click(snrestore.bind(self,vmRestoreAutoStart));
+ } else {
+ snrestore(vmRestoreAutoStart);
+ }
+ $(this).empty().remove();
+ };
+
+ } else {
+
+ q = trans('<p>Are you sure you want to restore snapshot <nobr><b>%1</b></nobr>?</p>','UIMessageCenter');
+
+ buttons[trans('Restore','UIMessageCenter')] = function() {
+ var l = new vboxLoader();
+ l.add('snapshotRestore',function(d){
+ if(d && d.responseData && d.responseData.progress) {
+ vboxProgress({'progress':d.responseData.progress,'persist':d.persist},function(){
+
+ // Let events get picked up. Nothing to do here
+
+ },'progress_snapshot_restore_90px.png',trans('Restore Snapshot','VBoxSnapshotsWgt'),
+ vm.name);
+ } else if(d && d.error) {
+ vboxAlert(d.error);
+ }
+ },{'vm':vm.id,'snapshot':snapshot.id});
+ $(this).empty().remove();
+
+ l.run();
+
+ };
+ }
+
+ vboxConfirm(q.replace('%1',$('<div />').text(snapshot.name).html()),buttons);
+ },
+ 'separator' : true
+ },
+ {
+ 'name' : 'delete_snapshot',
+ 'label' : 'Delete Snapshot',
+ 'icon' : 'snapshot_delete',
+ 'enabled' : function(item) {
+ return (item && $(item).data('vboxSnapshot') && $(item).data('vboxSnapshot').name && $(item).data('vboxSnapshot').state != 'current' && $(item).data('vboxSnapshot').children.length <= 1);
+ },
+ 'click' : function () {
+ var vm = vboxChooser.getSingleSelected();
+ var snapshot = $('#vboxSnapshotList').find('div.vboxListItemSelected').first().parent().data('vboxSnapshot');
+ var buttons = {};
+ buttons[trans('Delete','UIMessageCenter')] = function() {
+ var l = new vboxLoader();
+ l.add('snapshotDelete',function(d){
+ if(d && d.responseData && d.responseData.progress) {
+ vboxProgress({'progress':d.responseData.progress,'persist':d.persist},function(){
+
+ // Let events get picked up. Nothing to do here
+
+ },'progress_snapshot_discard_90px.png',trans('Delete Snapshot','VBoxSnapshotsWgt'),
+ vm.name + ' - ' + snapshot.name);
+ }
+ },{'vm':vm.id,'snapshot':snapshot.id});
+ $(this).empty().remove();
+
+ l.run();
+ };
+ vboxConfirm(trans('<p>Deleting the snapshot will cause the state information saved in it to be lost, and '+
+ 'storage data spread over several image files that VirtualBox has created together with the snapshot '+
+ 'will be merged into one file. This can be a lengthy process, and the information in the snapshot cannot '+
+ 'be recovered.</p></p>Are you sure you want to delete the selected snapshot <b>%1</b>?</p>','UIMessageCenter').replace('%1',$('<div />').text(snapshot.name).html()),buttons);
+ }
+ },
+ {
+ 'name' : 'show_snapshot_details',
+ 'label' : 'Show Details',
+ 'icon' : 'snapshot_show_details',
+ 'enabled' : function(item) {
+ return (item && $(item).data('vboxSnapshot') && $(item).data('vboxSnapshot').name && $(item).data('vboxSnapshot').state != 'current');
+ },
+ 'click' : function () {
+
+ // Current snapshot
+ var snapshot = $('#vboxSnapshotList').find('div.vboxListItemSelected').first().parent().data('vboxSnapshot');
+
+ var vm = vboxChooser.getSingleSelected();
+
+ var l = new vboxLoader();
+ l.add('snapshotGetDetails',function(d){
+
+ $('#vboxSnapshotDetailsName').val(d.responseData.name);
+ $('#vboxSnapshotDetailsTaken').html(vboxDateTimeString(d.responseData.timeStamp));
+ $('#vboxSnapshotDetailsDesc').val(d.responseData.description);
+
+ if(d.responseData.online) {
+ $('#vboxSnapshotSS').html('<a href="'+ vboxEndpointConfig.screen +'?vm='+vm.id+
+ '&snapshot='+d.responseData.id+'&full=1" target="_blank"><img src="'+vboxEndpointConfig.screen+'?vm='+
+ vm.id+'&snapshot='+d.responseData.id+'" /></a>').show();
+ } else {
+ $('#vboxSnapshotSS').empty().hide();
+ }
+
+ // Display details
+ $('#vboxSnapshotDetailsVM').empty();
+
+ // Enclosing details Table
+ var vboxDetailsTable = $('<table />').attr({'class':'vboxDetailsTable'});
+
+ // Set to isSnapshot
+ d.responseData.machine._isSnapshot = true;
+
+ for(var i in vboxVMDetailsSections) {
+
+ section = vboxVMDetailsSections[i];
+
+ if(section.noSnapshot) continue;
+
+ $('<tr />').attr({'class':'vboxDetailsHead'}).append(
+ $('<th />').attr({'class':'vboxDetailsSection','colspan':'2'}).disableSelection()
+ .html("<img style='float:left; margin-right: 3px; ' src='images/vbox/" + section.icon + "' height='16' width='16' /> ")
+ .append(
+ $('<span />').css({'float':'left'}).append(document.createTextNode(trans(section.title, section.language_context) +' '))
+ )
+ ).appendTo(vboxDetailsTable);
+
+ __vboxDetailAddRows(d.responseData.machine, section.rows, vboxDetailsTable);
+
+ }
+
+ $('#vboxSnapshotDetailsVM').append(vboxDetailsTable);
+
+
+ },{'vm':vm.id,'snapshot':snapshot.id});
+ l.onLoad = function(){
+
+ var buttons = {};
+ buttons[trans('OK','QIMessageBox')] = function() {
+
+ // Current snapshot
+ var snapshot = $('#vboxSnapshotList').find('div.vboxListItemSelected').first().parent().data('vboxSnapshot');
+
+ var l = new vboxLoader();
+ l.add('snapshotSave',function(d){
+
+ // Let events get picked up. Nothing to do here
+
+ },{'vm':vm.id,'snapshot':snapshot.id,'name':$('#vboxSnapshotDetailsName').val(),'description':$('#vboxSnapshotDetailsDesc').val()});
+ $(this).dialog('close');
+ l.run();
+
+ };
+ buttons[trans('Cancel','QIMessageBox')] = function(){
+ $(this).dialog('close');
+ };
+ $('#vboxSnapshotDetails').dialog({'closeOnEscape':false,'width':'600px','height':'auto','buttons':buttons,'modal':true,'autoOpen':true,'dialogClass':'vboxDialogContent','title':'<img src="images/vbox/snapshot_show_details_16px.png" class="vboxDialogTitleIcon" /> '+trans('Details of %1 (%2)','VBoxSnapshotDetailsDlg').replace('%1',$('<div />').text(snapshot.name).html()).replace('%2',vm.name)});
+ };
+ l.run();
+ }
+ },
+ {
+ 'name' : 'clone',
+ 'label' : 'Clone...',
+ 'language_context': 'UIActionPool',
+ 'icon' : 'vm_clone',
+ 'separator' : true,
+ 'enabled' : function(item) {
+ var vm = vboxChooser.getSingleSelected();
+ return (item && $(item).data('vboxSnapshot') && $(item).data('vboxSnapshot').name && !vboxVMStates.isPaused(vm) && !vboxVMStates.isRunning(vm));
+ },
+ 'click' : function () {
+
+ var vm = vboxChooser.getSingleSelected();
+
+ // Current snapshot
+ var snapshot = $('#vboxSnapshotList').find('div.vboxListItemSelected').first().parent().data('vboxSnapshot');
+
+ new vboxWizardCloneVMDialog({'vm':vm,'snapshot':(snapshot.state == 'current' ? undefined : snapshot)}).run();
+
+ }
+ },
+
+
+
+];
+
+
+/* Append Top Toolbar */
+var vboxSnapshotToolbar = new vboxToolbarSmall({buttons: vboxSnapshotButtons, size: 22, language_context: 'VBoxSnapshotsWgt'});
+// special case for 'clone' button because it is 16px rather than 22px
+vboxSnapshotToolbar.addButtonCSS('clone', {'background-position':'6px 4px'});
+vboxSnapshotToolbar.renderTo('vboxSnapshotToolbar');
+
+vboxInitDisplay('vboxSnapshotToolbar','VBoxSnapshotsWgt');
+
+// Context menu for snapshots
+var vboxSnapshotContextMenu = new vboxMenu({name:'vboxSnapshotContextMenu', language_context: 'VBoxSnapshotsWgt'});
+vboxSnapshotContextMenu.addMenu(vboxSnapshotButtons.slice(-(vboxSnapshotButtons.length-1)));
+
+//Context menu for current state
+var vboxSnapshotContextMenuCurrent = new vboxMenu({name: 'vboxSnapshotContextMenuCurrent', language_context: 'VBoxSnapshotsWgt'});
+vboxSnapshotContextMenuCurrent.addMenu([vboxSnapshotButtons[0],vboxSnapshotButtons[(vboxSnapshotButtons.length-2)]]);
+
+
+/* Toolbar and menu updates*/
+$('#vboxSnapshotList').on('select',function(e,item) {
+
+ // Update toolbar
+ vboxSnapshotToolbar.update(item);
+
+ vboxSnapshotContextMenu.update(item);
+ vboxSnapshotContextMenuCurrent.update(item);
+
+});
+
+// Hold timer and date vars
+vboxSnapshotToolbar._timer = null;
+vboxSnapshotToolbar._timeSpans = new Array();
+vboxSnapshotToolbar._timeSpans['days'] = 86400;
+vboxSnapshotToolbar._timeSpans['hours'] = 3600,
+vboxSnapshotToolbar._timeSpans['minutes'] = 60,
+vboxSnapshotToolbar._timeSpans['seconds'] = 1;
+vboxSnapshotToolbar._timeSpans.sort(function(a,b){return (a > b ? -1 : 1);});
+
+
+
+/* Selected VM changed */
+$('#vboxPane').on('vmSelectionListChanged',function(){
+
+ $('#vboxTabVMSnapshotsTitle').html(trans('Snapshots','UIVMDesktop'));
+
+ var vm = vboxChooser.getSingleSelected();
+
+ $('#vboxSnapshotList').trigger('select',null);
+
+ // Got vm and it's not host
+ if(vm && vm.id != 'host') {
+
+ // Enable tab
+ $('#vboxTabVMSnapshots').parent().trigger('enableTab', ['vboxTabVMSnapshots']);
+
+ $.when(vboxVMDataMediator.getVMDetails(vm.id)).done(function(vm) {
+ $('#vboxTabVMSnapshotsTitle').html(trans('Snapshots','UIVMDesktop') + (vm && vm.snapshotCount ? trans(' (%1)','VBoxSnapshotsWgt').replace('%1',vm.snapshotCount):''));
+ });
+
+ // Unset last vm
+ $('#vboxTabVMSnapshots').data('lastVM',0);
+
+ // Remove children
+ $('#vboxSnapshotList').children().empty().remove();
+
+ // Fill snapshots if this tab is being shown
+ if($('#vboxTabVMSnapshots').data('vboxShowing')) {
+
+ // Keep track of last VM shown
+ $('#vboxTabVMSnapshots').data('lastVM',vm.id);
+
+ // append spinner
+ $('#vboxSnapshotList').append($('<li />').attr({'class':'last'}).html("<div><img src='images/spinner.gif'></div>"));
+
+ $.when(vboxAjaxRequest('machineGetSnapshots',{'vm':vm.id})).done(__vboxTabSnapshotsFill);
+
+ }
+
+ // No single selected VM or it is host
+ } else {
+ // disable tab
+ $('#vboxTabVMSnapshots').parent().trigger('disableTab', ['vboxTabVMSnapshots']);
+ $('#vboxTabVMSnapshots').data('lastVM',0);
+ }
+
+/**
+ *
+ * VBOX event list triggered
+ *
+ */
+}).on('vboxEvents',function(e,eventList) {
+
+ var redrawCurrent = false;
+
+ for(var i = 0; i < eventList.length; i++) {
+
+ switch(eventList[i].eventType) {
+
+ //////////////////////////
+ //
+ // Snapshot events
+ //
+ /////////////////////////
+ case 'OnSnapshotTaken':
+ case 'OnSnapshotDeleted':
+ case 'OnSnapshotRestored':
+ case 'OnSnapshotChanged':
+
+ // Is this vm selected
+ if(vboxChooser.getSingleSelectedId() == eventList[i].machineId) {
+
+ // Update title
+ $('#vboxTabVMSnapshotsTitle').html(trans('Snapshots','UIVMDesktop') +
+ (eventList[i].enrichmentData && eventList[i].enrichmentData.snapshotCount ? trans(' (%1)','VBoxSnapshotsWgt').replace('%1',eventList[i].enrichmentData.snapshotCount):''));
+
+ // Redraw snapshots if this is shown
+ if($('#vboxTabVMSnapshots').data('lastVM') == eventList[i].machineId) {
+
+ $('#vboxSnapshotList').children().empty().remove();
+
+ // Append spinner
+ $('#vboxSnapshotList').append($('<li />').attr({'class':'last'}).html("<div><img src='images/spinner.gif'></div>"));
+
+
+ $.when(vboxAjaxRequest('machineGetSnapshots',{'vm':eventList[i].machineId})).done(__vboxTabSnapshotsFill);
+
+ return;
+
+ }
+ }
+ break;
+
+ /////////////////////////
+ //
+ // Session or state change
+ //
+ ////////////////////////
+ case 'OnSessionStateChanged':
+ case 'OnMachineStateChanged':
+ if($('#vboxTabVMSnapshots').data('lastVM') == eventList[i].machineId && vboxChooser.getSingleSelectedId() == eventList[i].machineId) {
+ redrawCurrent = true;
+ }
+ break;
+
+ }
+
+ }
+
+ // Redraw current snapshot
+ if(redrawCurrent) {
+
+ var vmid = vboxChooser.getSingleSelectedId();
+
+ // Get current state and details data
+ $.when(vboxVMDataMediator.getVMData(vmid), vboxVMDataMediator.getVMDetails(vmid)).done(function(vm, vmd) {
+
+ if($('#vboxTabVMSnapshots').data('lastVM') != vm.id) return;
+
+ var selected = $('#vboxTabVMSnapshots').find('li.vboxSnapshotCurrentState').children('div.vboxListItemSelected').length;
+ $('#vboxTabVMSnapshots').find('li.vboxSnapshotCurrentState').replaceWith(__vboxTabSnapshotCurrent($.extend(true,{},vm,vmd)));
+ if(selected) {
+ $('#vboxSnapshotList').trigger('select',
+ $('#vboxTabVMSnapshots').find('li.vboxSnapshotCurrentState').children('div.vboxListItem').addClass('vboxListItemSelected').parent());
+ }
+ });
+ }
+
+
+});
+
+// Load snapshots on show
+$('#vboxTabVMSnapshots').on('show',function(e){
+
+ $('#vboxTabVMSnapshots').data('vboxShowing', 1);
+
+ var vm = vboxChooser.getSingleSelected();
+
+ if(vm && vm.id) {
+ if($('#vboxTabVMSnapshots').data('lastVM') == vm.id) return;
+ $('#vboxTabVMSnapshots').data('lastVM', vm.id);
+ } else {
+ $('#vboxSnapshotList').children().remove();
+ $('#vboxTabVMSnapshots').data('lastVM',0);
+ vboxSnapshotToolbar.disable();
+ return;
+ }
+
+
+ // Get snapshots
+ // Append spinner
+ $('#vboxSnapshotList').append($('<li />').attr({'class':'last'}).html("<div><img src='images/spinner.gif'></div>"));
+ $.when(vboxAjaxRequest('machineGetSnapshots',{'vm':vm.id})).done(__vboxTabSnapshotsFill);
+
+
+}).on('hide',function(e) {
+ $('#vboxTabVMSnapshots').data('vboxShowing', 0);
+});
+
+/*
+ * Fill Snapshots
+*/
+function __vboxTabSnapshotsFill(response) {
+
+ var snapshotData = response.responseData;
+
+ if(vboxSnapshotToolbar._timer) {
+ window.clearTimeout(vboxSnapshotToolbar._timer);
+ vboxSnapshotToolbar._timer = null;
+ }
+
+ if(!snapshotData) return;
+
+ // Get current state and details data
+ $.when(vboxVMDataMediator.getVMData(response.responseData.vm), vboxVMDataMediator.getVMDetails(response.responseData.vm)).done(function(vm, vmd) {
+
+ if($('#vboxTabVMSnapshots').data('lastVM') != vm.id) return;
+
+ var list = $('#vboxSnapshotList');
+ $(list).children().remove();
+
+ var vmc = $.extend(true, {}, vm, vmd);
+
+ // Snapshots exist
+ if(snapshotData.snapshot && snapshotData.snapshot.name) {
+
+ // Traverse snapshots
+ $(list).append(__vboxTabSnapshot(snapshotData.snapshot, snapshotData.currentSnapshotId));
+
+ // Append current state to last snapshot
+ if(snapshotData.currentSnapshotId) {
+
+ // Has children
+ if($('#'+snapshotData.currentSnapshotId).children('ul').first()[0]) {
+ $('#'+snapshotData.currentSnapshotId).children('ul').last().append(__vboxTabSnapshotCurrent(vmc));
+ } else {
+ $('#'+snapshotData.currentSnapshotId).append($('<ul />').append(__vboxTabSnapshotCurrent(vmc)));
+ };
+ };
+
+ // No snapshots. Append current state to list
+ } else {
+ $(list).append(__vboxTabSnapshotCurrent(vmc));
+ }
+
+ // Init vbox tree list
+ $('#vboxSnapshotList').vbtree();
+
+ vboxSnapshotToolbar.enable();
+
+ var lastListItem = $(list).find('li.vboxSnapshotCurrentState').last();
+ lastListItem.children().addClass('vboxListItemSelected');
+ $('#vboxSnapshotList').trigger('select',lastListItem);
+
+ __vboxTabSnapshotTimestamps();
+
+ });
+
+}
+
+/* Snapshot list item */
+function __vboxTabSnapshot(s, currentId) {
+
+ var li = $('<li />').attr({'id':s.id});
+ $(li).data('vboxSnapshot',s);
+
+ // Use timestamp
+ var t = '';
+ if(s.timeStampSplit['seconds'] == 0)
+ s.timeStampSplit['seconds'] = 1;
+
+ var ago = 0;
+ var ts = 'seconds';
+ for(var i in s.timeStampSplit) {
+ var l = Math.floor(t / s.timeStampSplit[i]);
+ if(l > 0) {
+ ago = l;
+ ts = i;
+ break;
+ }
+ }
+
+ switch(ts) {
+ case 'days':
+ ts = trans('%n day(s)','VBoxGlobal', ago).replace('%n', ago);
+ break;
+ case 'hours':
+ ts = trans('%n hour(s)', 'VBoxGlobal', ago).replace('%n', ago);
+ break;
+ case 'minutes':
+ ts = trans('%n minute(s)', 'VBoxGlobal', ago).replace('%n', ago);
+ break;
+ case 'seconds':
+ ts = trans('%n second(s)', 'VBoxGlobal', ago).replace('%n', ago);
+ break;
+ }
+ ts = trans(' (%1 ago)','VBoxSnapshotsWgt').replace('%1', ts);
+
+ $(li).append(' ').append(
+
+ $('<div />').attr({'class':'vboxListItem'})
+ .html('<img src="images/vbox/snapshot_'+(s.online ? 'online' : 'offline')+'_16px.png" height="16" width="16" /> ' +
+ $('<div />').text(s.name).html())
+ .append($('<span />').attr({'class':'timestamp'}).data({'vboxTimestamp':s.timeStamp}).text(ts))
+
+ // Context menu
+ .contextMenu({
+ menu: vboxSnapshotContextMenu.menuId(),
+ clickthrough: true
+ },vboxSnapshotContextMenu.menuClickCallback)
+
+ // show details on dblclick
+ .dblclick(vboxSnapshotButtons[4].click).disableSelection()
+
+ // tool tip
+ .tipped({'position':'mouse','delay':1500,'source':'<p><strong>'+$('<div />').text(s.name).html()+'</strong> ('+trans((s.online ? 'online)' : 'offline)'),'VBoxSnapshotsWgt')+'</p>'+
+ '<p>'+ vboxDateTimeString(s.timeStamp, trans('Taken at %1','VBoxSnapshotsWgt'), trans('Taken on %1','VBoxSnapshotsWgt'))+'</p>' +
+ (s.description ? '<hr />' + $('<div />').text(s.description).html() : '')})
+
+ ).addClass(currentId == s.id ? 'vboxSnapshotCurrent' : '').children('div.vboxListItem').first().click(function(){
+ $('#vboxSnapshotList').find('div.vboxListItemSelected').first().removeClass('vboxListItemSelected');
+ $(this).addClass('vboxListItemSelected');
+ $('#vboxSnapshotList').trigger('select',$(this).parent());
+ });
+
+
+ if(s.children.length) {
+ var ul = $('<ul />');
+ for(var i = 0; i < s.children.length; i++) {
+ $(ul).append(__vboxTabSnapshot(s.children[i], currentId));
+ }
+ $(li).append(ul);
+ }
+
+
+
+ return li;
+}
+
+/* Current state list item */
+function __vboxTabSnapshotCurrent(vm) {
+
+ return $('<li />').data('vboxSnapshot',{'state':'current','name':trans((vm.currentStateModified ? 'Current State (changed)' : 'Current State'),'VBoxSnapshotsWgt')}).html(' ')
+ .addClass('last vboxSnapshotCurrent vboxSnapshotCurrentState')
+ .append(
+ $('<div />').attr({'class':'vboxListItem'}).html('<img src="images/vbox/'+vboxMachineStateIcon(vm.state)+'" height="16" width="16" /> ' + $('<div />').text(trans((vm.currentStateModified ? 'Current State (changed)' : 'Current State'),'VBoxSnapshotsWgt')).html())
+ .contextMenu({
+ menu: vboxSnapshotContextMenuCurrent.menuId(),
+ clickthrough : true
+ },vboxSnapshotContextMenuCurrent.menuClickCallback)
+ .click(function(){
+ $('#vboxSnapshotList').find('div.vboxListItemSelected').first().removeClass('vboxListItemSelected');
+ $(this).addClass('vboxListItemSelected');
+ $('#vboxSnapshotList').trigger('select',$(this).parent());
+ })
+ .tipped({'position':'mouse','delay':1500,'source':'<strong>'+
+ trans((vm.currentStateModified ? 'Current State (changed)' : 'Current State'),'VBoxSnapshotsWgt') + '</strong><br />'+
+ trans('%1 since %2','VBoxSnapshotsWgt').replace('%1',trans(vboxVMStates.convert(vm.state),'VBoxGlobal'))
+ .replace('%2',vboxDateTimeString(vm.lastStateChange))
+ + (vm.snapshotCount > 0 ? '<hr />' + (vm.currentStateModified ?
+ trans('The current state differs from the state stored in the current snapshot','VBoxSnapshotsWgt')
+ : trans('The current state is identical to the state stored in the current snapshot','VBoxSnapshotsWgt'))
+ : '')
+ })
+ );
+
+}
+
+
+/* Update snapshot timestamps */
+function __vboxTabSnapshotTimestamps() {
+
+ // Shorthand
+ var timeSpans = vboxSnapshotToolbar._timeSpans;
+
+ // Keep minimum timestamp
+ var minTs = 60;
+
+ var currentTime = new Date();
+ currentTime = Math.floor(currentTime.getTime() / 1000);
+
+ $('#vboxTabVMSnapshots').find('span.timestamp').each(function(){
+
+ var sts = parseInt($(this).data('vboxTimestamp'));
+ var t = Math.max(currentTime - sts, 1);
+
+ minTs = Math.min(minTs,t);
+
+ // Check for max age.
+ if(Math.floor(t / 86400) > 30) {
+ var sdate = new Date(sts * 1000);
+ $(this).html(trans(' (%1)','VBoxSnapshotsWgt').replace('%1',sdate.toLocaleString()));
+ return;
+ }
+
+ var ago = 0;
+ var ts = 'seconds';
+ for(var i in timeSpans) {
+ var l = Math.floor(t / timeSpans[i]);
+ if(l > 0) {
+ ago = l;
+ ts = i;
+ break;
+ }
+ }
+ switch(ts) {
+ case 'days':
+ ts = trans('%n day(s)', 'VBoxGlobal', ago).replace('%n', ago);
+ break;
+ case 'hours':
+ ts = trans('%n hour(s)', 'VBoxGlobal', ago).replace('%n', ago);
+ break;
+ case 'minutes':
+ ts = trans('%n minute(s)', 'VBoxGlobal', ago).replace('%n', ago);
+ break;
+ case 'seconds':
+ ts = trans('%n second(s)', 'VBoxGlobal', ago).replace('%n', ago);
+ break;
+ }
+ $(this).html(ts = trans(' (%1 ago)','VBoxSnapshotsWgt').replace('%1', ts));
+ });
+
+ var timerSet = (minTs >= 60 ? 60 : 10);
+ vboxSnapshotToolbar._timer = window.setTimeout(__vboxTabSnapshotTimestamps,(timerSet * 1000));
+}
+
+
+</script>
+</div>
diff --git a/panes/tabs.html b/panes/tabs.html
index 1b72f8a..b1b2142 100644
--- a/panes/tabs.html
+++ b/panes/tabs.html
@@ -1,177 +1,177 @@
-<!--
-
- Main Tabs
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: tabs.html 595 2015-04-17 09:50:36Z imoore76 $
-
- -->
-<div id='tabMainContent' class='vboxInvisible' style='overflow: auto;'></div>
-<script type='text/javascript'>
-
-// Create UL
-$('#vboxTabsList').append($('<ul />').attr({'id':'tablistMain'}));
-
-
-var tabs = [
- // Details
- {
- name:'vboxTabVMDetails',
- content:'tabVMDetails',
- label:'Details',
- icon:'vm_settings'
-
- // Snapshots
- },{
- name:'vboxTabVMSnapshots',
- content:'tabVMSnapshots',
- label:'Snapshots',
- icon:'snapshot_take',
- default_disabled: true
-
- // Console
- },{
- name:'vboxTabVMConsole',
- content:'tabVMConsole',
- label:'Console',
- icon:'vrdp',
- default_disabled: true
- }
-];
-
-
-// Tab object. Defined in this file
-var tabsMain = new vboxTabs('tabMainContent');
-
-// Loader that will load our tab panes
-var tabLoader = new vboxLoader();
-
-// Load each tab and create tab link
-for(var i = 0; i < tabs.length; i++) {
-
- // Tab disabled?
- if($('#vboxPane').data('vboxConfig')['disable' + tabs[i].name.substring(4)])
- continue;
-
- // Tab link
- $('<li />').attr({'class':'ui-corner-all','id':'tabsMain-'+tabs[i].name}).html('<a href="#'+tabs[i].name+'"><span><img src="images/vbox/'+tabs[i].icon+'_16px.png" border="0" /> <span id="'+tabs[i].name+'Title">'+trans(tabs[i].label, 'UIVMDesktop')+'</span></span></a>').appendTo('#tablistMain');
-
- tabLoader.addFileToDOM('panes/'+tabs[i].content+'.html',$('#tabMainContent'));
-
-}
-
-// Once tabs are loaded run this..
-tabLoader.onLoad = function(){
-
- for(var i = 0; i < tabs.length; i++) {
-
- // Tab disabled?
- if($('#vboxPane').data('vboxConfig')['disable' + tabs[i].name.substring(4)])
- continue;
-
- tabsMain.addTab(tabs[i]);
-
- }
-
- // Add "click" functionality to each tab
- $('#tablistMain').children().click(function(){
- if(!$(this).hasClass('vboxDisabled'))
- tabsMain.showTab($(this).children().first().attr('href'));
- return false;
-
- // Mouseover
- }).hover(function(){
- if($(this).hasClass('vboxDisabled')) return false;
- $(this).addClass('vboxHover');
- },function(){
- $(this).removeClass('vboxHover');
- });
-
- // Watch for tabs asking to be enabled / disabled
- $('#tabMainContent').on('enableTab',function(e,tabName) {
- tabsMain.enableTab(tabsMain.getTabByName(tabName));
- }).on('disableTab',function(e,tabName) {
- tabsMain.disableTab(tabsMain.getTabByName(tabName));
- });
-
-
-};
-tabLoader.run();
-
-/*
- * Tabs pane JavaScript code for main tabs. This
- * class listens for a vmlist selection change and tells
- * the tabs to update themselves with new data
- *
- */
-
-function vboxTabs(id) {
-
- var self = this;
- this.ref = null;
- this.vm = null;
- this.tabs = new Array();
- this.tabSelected = null;
- this.id = id;
-
- // Add a tab to list
- this.addTab = function (tab) {
-
- if(!this.tabSelected) {
- this.tabSelected = '#'+tab.name;
- $('#tablistMain').find('a[href=#'+tab.name+']').parent().addClass('selected');
- }
- this.tabs[this.tabs.length] = tab;
-
- // Initially Disable tab
- if(tab.default_disabled) {
- self.disableTab(tab);
- }
- };
-
- // Get a tab by name
- this.getTabByName = function(name) {
- for(var i = 0; i < self.tabs.length; i++) {
- if(self.tabs[i].name == name) return self.tabs[i];
- }
- };
-
- // Show a tab
- this.showTab = function (tab) {
-
- // Do nothing if it is already shown
- if(self.tabSelected == tab) return;
-
- // Hide each tab
- for(var i = 0; i < self.tabs.length; i++) {
- $('#'+self.tabs[i].name).css({'display':'none'}).trigger('hide');
- }
-
- // Show tab
- $(''+tab).css('display','').trigger('show');
- self.tabSelected = tab;
- $('#tablistMain').children().removeClass('selected');
- $('#tablistMain').find('a[href='+tab+']').parent().addClass('selected');
-
-
- };
-
- // Disable a tab
- this.disableTab = function(tab) {
-
- // Was this tab selected?
- if(self.tabSelected == '#'+tab.name)
- self.showTab('#'+self.tabs[0].name);
-
- $('#tabsMain-'+tab.name).addClass('vboxDisabled').find('img').attr('src','images/vbox/'+(tab.disabled_icon ? tab.disabled_icon : tab.icon+'_disabled')+'_16px.png');
- };
-
- // Enable a tab
- this.enableTab = function(tab) {
- $('#tabsMain-'+tab.name).removeClass('vboxDisabled').find('img').attr('src','images/vbox/'+tab.icon+'_16px.png');
- };
-
-}
-
-</script>
-
+<!--
+
+ Main Tabs
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: tabs.html 595 2015-04-17 09:50:36Z imoore76 $
+
+ -->
+<div id='tabMainContent' class='vboxInvisible' style='overflow: auto;'></div>
+<script type='text/javascript'>
+
+// Create UL
+$('#vboxTabsList').append($('<ul />').attr({'id':'tablistMain'}));
+
+
+var tabs = [
+ // Details
+ {
+ name:'vboxTabVMDetails',
+ content:'tabVMDetails',
+ label:'Details',
+ icon:'vm_settings'
+
+ // Snapshots
+ },{
+ name:'vboxTabVMSnapshots',
+ content:'tabVMSnapshots',
+ label:'Snapshots',
+ icon:'snapshot_take',
+ default_disabled: true
+
+ // Console
+ },{
+ name:'vboxTabVMConsole',
+ content:'tabVMConsole',
+ label:'Console',
+ icon:'vrdp',
+ default_disabled: true
+ }
+];
+
+
+// Tab object. Defined in this file
+var tabsMain = new vboxTabs('tabMainContent');
+
+// Loader that will load our tab panes
+var tabLoader = new vboxLoader();
+
+// Load each tab and create tab link
+for(var i = 0; i < tabs.length; i++) {
+
+ // Tab disabled?
+ if($('#vboxPane').data('vboxConfig')['disable' + tabs[i].name.substring(4)])
+ continue;
+
+ // Tab link
+ $('<li />').attr({'class':'ui-corner-all','id':'tabsMain-'+tabs[i].name}).html('<a href="#'+tabs[i].name+'"><span><img src="images/vbox/'+tabs[i].icon+'_16px.png" border="0" /> <span id="'+tabs[i].name+'Title">'+trans(tabs[i].label, 'UIVMDesktop')+'</span></span></a>').appendTo('#tablistMain');
+
+ tabLoader.addFileToDOM('panes/'+tabs[i].content+'.html',$('#tabMainContent'));
+
+}
+
+// Once tabs are loaded run this..
+tabLoader.onLoad = function(){
+
+ for(var i = 0; i < tabs.length; i++) {
+
+ // Tab disabled?
+ if($('#vboxPane').data('vboxConfig')['disable' + tabs[i].name.substring(4)])
+ continue;
+
+ tabsMain.addTab(tabs[i]);
+
+ }
+
+ // Add "click" functionality to each tab
+ $('#tablistMain').children().click(function(){
+ if(!$(this).hasClass('vboxDisabled'))
+ tabsMain.showTab($(this).children().first().attr('href'));
+ return false;
+
+ // Mouseover
+ }).hover(function(){
+ if($(this).hasClass('vboxDisabled')) return false;
+ $(this).addClass('vboxHover');
+ },function(){
+ $(this).removeClass('vboxHover');
+ });
+
+ // Watch for tabs asking to be enabled / disabled
+ $('#tabMainContent').on('enableTab',function(e,tabName) {
+ tabsMain.enableTab(tabsMain.getTabByName(tabName));
+ }).on('disableTab',function(e,tabName) {
+ tabsMain.disableTab(tabsMain.getTabByName(tabName));
+ });
+
+
+};
+tabLoader.run();
+
+/*
+ * Tabs pane JavaScript code for main tabs. This
+ * class listens for a vmlist selection change and tells
+ * the tabs to update themselves with new data
+ *
+ */
+
+function vboxTabs(id) {
+
+ var self = this;
+ this.ref = null;
+ this.vm = null;
+ this.tabs = new Array();
+ this.tabSelected = null;
+ this.id = id;
+
+ // Add a tab to list
+ this.addTab = function (tab) {
+
+ if(!this.tabSelected) {
+ this.tabSelected = '#'+tab.name;
+ $('#tablistMain').find('a[href=#'+tab.name+']').parent().addClass('selected');
+ }
+ this.tabs[this.tabs.length] = tab;
+
+ // Initially Disable tab
+ if(tab.default_disabled) {
+ self.disableTab(tab);
+ }
+ };
+
+ // Get a tab by name
+ this.getTabByName = function(name) {
+ for(var i = 0; i < self.tabs.length; i++) {
+ if(self.tabs[i].name == name) return self.tabs[i];
+ }
+ };
+
+ // Show a tab
+ this.showTab = function (tab) {
+
+ // Do nothing if it is already shown
+ if(self.tabSelected == tab) return;
+
+ // Hide each tab
+ for(var i = 0; i < self.tabs.length; i++) {
+ $('#'+self.tabs[i].name).css({'display':'none'}).trigger('hide');
+ }
+
+ // Show tab
+ $(''+tab).css('display','').trigger('show');
+ self.tabSelected = tab;
+ $('#tablistMain').children().removeClass('selected');
+ $('#tablistMain').find('a[href='+tab+']').parent().addClass('selected');
+
+
+ };
+
+ // Disable a tab
+ this.disableTab = function(tab) {
+
+ // Was this tab selected?
+ if(self.tabSelected == '#'+tab.name)
+ self.showTab('#'+self.tabs[0].name);
+
+ $('#tabsMain-'+tab.name).addClass('vboxDisabled').find('img').attr('src','images/vbox/'+(tab.disabled_icon ? tab.disabled_icon : tab.icon+'_disabled')+'_16px.png');
+ };
+
+ // Enable a tab
+ this.enableTab = function(tab) {
+ $('#tabsMain-'+tab.name).removeClass('vboxDisabled').find('img').attr('src','images/vbox/'+tab.icon+'_16px.png');
+ };
+
+}
+
+</script>
+
diff --git a/panes/toolbar.html b/panes/toolbar.html
index b637c60..c76b347 100644
--- a/panes/toolbar.html
+++ b/panes/toolbar.html
@@ -1,556 +1,556 @@
-<!--
-
- Top (main) phpVirtualBox tool bar
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: toolbar.html 599 2015-07-27 10:40:37Z imoore76 $
-
--->
-<script type='text/javascript'>
-
-/*
- * JS objects for actions that can be performed on a VM
- * from this toolbar
- */
-var tButtons = [
-
- vboxVMActions['new'],
- $.extend({},vboxVMActions['settings'],{click: function(){
- var vm = vboxChooser.getSingleSelected();
- if(!vm || vboxVMStates.isRunning(vm) || vboxVMStates.isPaused(vm)) return;
- vboxVMActions['settings'].click();
-
- }}),
- vboxVMActions['start'],
- {
- name: 'stop',
- icon: 'vm_poweroff',
- label: 'Stop',
- language_context: 'VBoxSelectorWnd',
- enabled: vboxVMActions['stop'].enabled,
- click : function() {return;}
- }
-];
-
-/* Append Top Toolbar */
-var vboxChooserToolbarTop = new vboxToolbar({buttons: tButtons, size: 32,
- language_context: 'UIActionPool', renderTo: 'vboxPaneToolbar'});
-
-/* Stop button menu and actions */
-var stopMenuItems = [
- vboxVMActions['pause'],
- vboxVMActions['reset'],
-];
-for(var i = 0; i < vboxVMActions.stop_actions.length; i++) {
- var n = $.extend({}, vboxVMActions[vboxVMActions.stop_actions[i]]);
- if(i==0) n.separator = true;
- stopMenuItems[stopMenuItems.length] = n;
-}
-stopMenu = new vboxMenu({name: 'stopContextMenu', menuItems: stopMenuItems, language_context: 'UIActionPool'});
-
-vboxChooserToolbarTop.getButtonElement('stop').contextMenu({
- menu: stopMenu.menuId(),
- button: 0,
- mode: 'menu'
- },function(a, el, pos) {
- for(var i in vboxVMActions) {
- if(typeof i == 'string' && vboxVMActions[i].name == a) {
- vboxVMActions[i].click();
- return;
- }
- }
- }
-);
-
-/* 'Settings' menu items / actions */
-var vboxChooserSettingsMenu = {
-
- 'settings' : {
- 'label' : vboxVMActions['settings'].label,
- 'icon' : vboxVMActions['settings'].icon
- },
- 'storage' : {
- 'icon' : 'hd'
- },
- 'USB' : {
- 'label' : 'USB',
- 'icon' : 'usb'
- },
- 'Network' : {
- 'label' : 'Network',
- 'icon' : 'nw'
- },
- 'SharedFolders' : {
- 'label' : 'Shared Folders',
- 'icon' : 'sf'
- },
- 'RemoteDisplay' : {
- 'label' : 'Remote Display',
- 'icon' : 'vrdp',
- 'separator' : true
- },
- 'GuestAdditions' : {
- 'label' : vboxVMActions['guestAdditionsInstall'].label,
- 'icon' : vboxVMActions['guestAdditionsInstall'].icon,
- 'separator' : true
- }
-
-};
-
-
-/* 'Settings' menu */
-var ul = $('<ul />').attr({'class':'contextMenu','style':'display: none','id':'vboxVMSettingsMenu'});
-
-for(var i in vboxChooserSettingsMenu) {
-
- // add name
- vboxChooserSettingsMenu[i].name = i;
- var label = trans(vboxChooserSettingsMenu[i].label, 'UIActionPool');
- var li = $('<li />').html("<span class='vboxMenuItemChecked' /><a href='#" + vboxChooserSettingsMenu[i].name + "' style='background-image: url(images/vbox/" + vboxChooserSettingsMenu[i].icon +"_16px.png);' >"+(label ? label : ' ')+"</a>");
- if(i == 'storage') { $(li).attr({'style':'display:none','id':'vboxVMSettingsToolbarStorageHolder'}); }
- if(i == 'USB') {
- /* 'USB' menu */
- $('<ul />').attr({'class':'vboxSettingsUSBAttachmentsMenu contextMenuNoBG','style':'display: none','id':'vboxVMSettingsUSBMenu'}).data({'callback':'vboxChooserToolbarUSBUpdate'}).appendTo(li);
- }
- if(vboxChooserSettingsMenu[i].separator) $(li).addClass('separator');
- $(ul).append(li);
-
-}
-
-/* Append 'Settings' button Menu */
-$('#vboxPane').append(ul);
-
-
-
-/* 'Settings' button menu initialization */
-vboxChooserToolbarTop.getButtonElement('settings').contextMenu({
- menu: 'vboxVMSettingsMenu',
- button: 0,
- mode: 'menu'
- },
- function(a, el, pos, srcEl) {
-
- var vm = vboxChooser.getSingleSelected();
-
- if(!vm) return;
-
- switch(a) {
-
- case 'Network':
- case 'SharedFolders':
- vboxVMsettingsDialog(vm, a);
- break;
-
- case 'GuestAdditions':
-
- vboxVMActions['guestAdditionsInstall'].click();
- break;
-
- // Don't do anything for dvd, fd, or USB devices main menu item click
- case 'dvdDevices':
- case 'fdDevices':
- case 'USB':
- break;
-
- case 'RemoteDisplay':
- var en = vboxVMDataMediator.getVMRuntimeData(vm.id).VRDEServer.enabled;
- vboxAjaxRequest('consoleVRDEServerSave',{'vm':vm.id,'enabled':(en ? 0 : 1)});
- break;
-
- case 'settings':
- vboxVMActions['settings'].click();
- break;
-
- default:
-
- // Assume it was a storage action
- if(vboxToolbarMediaLast) {
- if(vboxToolbarMediaLast.type == 'DVD') {
- vboxToolbarMediaMenuDVD.menuCallback(a,el,pos);
- } else {
- vboxToolbarMediaMenuFD.menuCallback(a,el,pos);
- }
- }
-
- } // </ switch / case >
-
- }
-);
-
-/*
- * Storage mount menu
- */
-var vboxToolbarMediaLast = null; // Used when context menu item is clicked to determine
- // which medium attachment to act upon.
-function vboxChooserToolbarMediumMount(medium) {
-
- var vmid = vboxChooser.getSingleSelectedId();
-
- var args = {'vm':vmid,'medium':medium,'port':vboxToolbarMediaLast.port,'device':vboxToolbarMediaLast.device,'bus':vboxToolbarMediaLast.bus,'controller':vboxToolbarMediaLast.controller};
-
- // Ajax request to mount medium
- var mount = new vboxLoader('mediumMount');
- mount.add('mediumMount',function(d){
- var l = new vboxLoader('getMedia');
- l.add('vboxGetMedia',function(d){$('#vboxPane').data('vboxMedia',d.responseData);});
- l.run();
- },args);
- mount.run();
-}
-var vboxToolbarMediaMenuDVD = new vboxMediaMenu('DVD',vboxChooserToolbarMediumMount,'');
-var vboxToolbarMediaMenuFD = new vboxMediaMenu('Floppy',vboxChooserToolbarMediumMount,'');
-
-function vboxChooserToolbarStorageUpdate(menu) {
-
- vboxToolbarMediaLast = $(menu).data('storage');
- var medium = null;
- if(vboxToolbarMediaLast && vboxToolbarMediaLast.medium && vboxToolbarMediaLast.medium.id)
- medium = vboxMedia.getMediumById(vboxToolbarMediaLast.medium.id);
-
- if(vboxToolbarMediaLast.type == 'DVD') {
- vboxToolbarMediaMenuDVD.menuUpdateMedia(medium);
- return vboxToolbarMediaMenuDVD.menuElement();
- }
-
- vboxToolbarMediaMenuFD.menuUpdateMedia(medium);
- return vboxToolbarMediaMenuFD.menuElement();
-}
-
-// Update host drives and recent media on host change.
-// Just recreate the menus
-$('#vboxPane').on('hostChanged',function(){
- vboxToolbarMediaMenuDVD = new vboxMediaMenu('DVD',vboxChooserToolbarMediumMount,'');
- vboxToolbarMediaMenuFD = new vboxMediaMenu('Floppy',vboxChooserToolbarMediumMount,'');
-});
-/*
- * Update USB device list
- */
-function vboxChooserToolbarUSBUpdate(menu) {
-
- $(menu).append($('<li />').html('<span><img src="images/jqueryFileTree/spinner.gif" /></span>').css({'width':'100px','text-align':'center'}));
-
- var vm = vboxChooser.getSingleSelected();
-
- var l = new vboxLoader();
-
- l.add('hostGetUSBDevices',function(d){
- $('#vboxPaneToolbar').data('hostUSB',d.responseData);
- },{});
-
- l.add('consoleGetUSBDevices',function(d){
- $('#vboxPaneToolbar').data('guestUSB',d.responseData);
- },{'vm':vm.id});
-
- l.noLoadingScreen = true;
- l.onLoad = function() {
-
- var hostUSB = $('#vboxPaneToolbar').data('hostUSB');
- var guestUSB = $('#vboxPaneToolbar').data('guestUSB');
- $(menu).children().remove();
-
- for(var i = 0; i < hostUSB.length; i++) {
-
- var dname = '';
- if(!hostUSB[i].product) {
- dname = trans('Unknown device %1:%2','UIActionPool').replace('%1',hostUSB[i].vendorId).replace('%2',hostUSB[i].productId);
- } else {
- dname = hostUSB[i].manufacturer + ' ' + hostUSB[i].product;
- }
- dname += ' [' + hostUSB[i].revision + ']';
- var capt = (hostUSB[i].state == 'Captured' && guestUSB[hostUSB[i].id]);
- var avail = (capt || (hostUSB[i].state != 'NotSupported' && hostUSB[i].state != 'Unavailable' && hostUSB[i].state != 'Captured'));
- var cbox = $('<input />').attr({'type':'checkbox','class':'vboxCheckbox'}).prop({'checked':(capt ? true : false),'disabled':(avail ? false : true)}).on('click',function(e){
- e.stopPropagation();
- if($(this).prop('disabled')) return;
-
- var cbox = $(this);
- // Detach
- if($(this).data('capt')) {
- $.when(vboxAjaxRequest('consoleUSBDeviceDetach',{'vm':vm.id,'id':$(this).data('usbDevice')})).done(function(d){
- if(d.success) {
- cbox.prop('checked',false);
- cbox.data('capt',false);
- } else {
- cbox.prop('checked',true);
- }
- });
- // Attach
- } else {
- $.when(vboxAjaxRequest('consoleUSBDeviceAttach',{'vm':vm.id,'id':$(this).data('usbDevice')})).done(function(d){
- if(d.success) {
- cbox.prop('checked',true);
- cbox.data('capt',true);
- } else {
- cbox.prop('checked',false);
- }
- });
- }
- }).data({'usbDevice':hostUSB[i].id,'capt':capt});
-
- $(menu).append($('<li />').append(
- $('<span />').addClass('vboxMenuAcceptClick')
- .click(function(){if(!$(this).parent().hasClass('disabled')){$(this).children('input').click();}return false;})
- .append(cbox).append(' '+dname)).attr({'class':(avail ? '' : 'disabled')}));
- }
-
- // No devices?
- if(hostUSB.length == 0) {
- $(menu).append($('<li />').html('<span>'+$('<div />').text(trans('<no devices available>','VBoxUSBMenu')).html()+'</span>'));
- }
- $(menu).trigger('menuLoaded');
- };
- l.run();
-}
-
-/*
- *
- * Update vboxSettingsMenu items. Called when
- * vboxChooser selection changes $('#vboxPane').onvmSelectionListChanged
- *
- */
-function vboxUpdateSettingsMenu(vm) {
-
- if(vboxVMStates.isRunning(vm) || vboxVMStates.isPaused(vm)) {
- vboxChooserToolbarTop.getButtonElement("settings").enableContextMenu();
- } else {
- vboxChooserToolbarTop.getButtonElement("settings").disableContextMenu();
- return;
- }
- // enable or disable USB
- var usbEnabled = false;
- if(vm['USBControllers'].length) {
- for(var i = 0; i < vm['USBControllers'].length; i++) {
- if(vm['USBControllers'][i].type == 'OHCI') {
- usbEnabled = true;
- break;
- }
- }
- }
- if(usbEnabled) {
- $('ul.vboxSettingsUSBAttachmentsMenu').children().remove();
- $('#vboxVMSettingsMenu').find('a[href=#USB]').closest('li').css('display','');
- } else {
- $('#vboxVMSettingsMenu').find('a[href=#USB]').closest('li').css('display','none');
- }
-
- // Enable or disable network
- var enabledS = false;
- if(vm && vm.networkAdapters && vm.networkAdapters.length) {
- for(var a = 0; a < vm.networkAdapters.length; a++) {
- if(vm.networkAdapters[a].enabled) {
- enabledS = true;
- break;
- }
- }
- }
- if(enabledS) {
- $('#vboxVMSettingsMenu').find('a[href=#Network]').closest('li').css('display','');
- } else {
- $('#vboxVMSettingsMenu').find('a[href=#Network]').closest('li').css('display','none');
- }
-
- // vboxVMSettingsToolbarStorageHolder
- var smenu = $('#vboxVMSettingsToolbarStorageHolder');
- smenu.siblings('li.vboxVMSettingsStorage').remove();
- $('ul.vboxVMSettingsStorage').remove();
- var enabledS = false;
- if(vm && vm.storageControllers && vm.storageControllers.length) {
- var dvdDevices = new Array();
- var fdDevices = new Array();
-
- for(var a = 0; a < vm.storageControllers.length; a++) {
-
- // See if this bus type supports removable media
- if(jQuery.inArray('dvd',vboxStorage[vm['storageControllers'][a].bus].driveTypes) == -1 &&
- jQuery.inArray('floppy',vboxStorage[vm['storageControllers'][a].bus].driveTypes) == -1)
- continue;
-
- var icon = vboxStorage.getBusIconName(vm['storageControllers'][a].bus);
-
- for(var b = 0; b < vm['storageControllers'][a]['mediumAttachments'].length; b++) {
-
- if(vm['storageControllers'][a]['mediumAttachments'][b].type == 'HardDisk') continue;
-
- vm['storageControllers'][a]['mediumAttachments'][b]['controller'] = vm['storageControllers'][a]['name'];
-
- var portName = vboxStorage[vm['storageControllers'][a].bus].slotName(vm['storageControllers'][a]['mediumAttachments'][b].port, vm['storageControllers'][a]['mediumAttachments'][b].device);
- var m = vm['storageControllers'][a]['mediumAttachments'][b].medium;
- m = vboxMedia.getMediumById((m && m.id ? m.id : null));
-
- var mName = vboxMedia.getName(m);
- mName = $('<div />').text(mName).html();
-
-
- var smid = vm.id+'-vboxVMSettingsStorage-'+a+'-'+b;
- $('#'+vm.id+'-vboxVMSettingsStorage-'+a+'-'+b).remove();
-
- var li = $('<li />').attr({'title':mName}).html("<a title='"+mName+"' href='#mount-"+vm['storageControllers'][a].bus+"-"+vm['storageControllers'][a]['mediumAttachments'][b].port+"-"+vm['storageControllers'][a]['mediumAttachments'][b].device+"' style='background-image:url(images/vbox/"+icon+"_16px.png);'>"+vm['storageControllers'][a]['name'] + ' ('+portName + ")</a>").addClass('vboxVMSettingsStorage');
- $(li).append($('<ul />').attr({'id':smid,'style':'display:none'}).data({'callback':'vboxChooserToolbarStorageUpdate','storage':vm['storageControllers'][a]['mediumAttachments'][b]}));
- if(vm['storageControllers'][a]['mediumAttachments'][b].type == 'DVD') {
- dvdDevices[dvdDevices.length] = li;
- } else {
- fdDevices[fdDevices.length] = li;
- }
- enabledS = true;
- }
- }
- if(dvdDevices.length) {
- var ul = null;
- var li = $('<li />').html("<a href='#dvdDevices' style='background-image:url(images/vbox/cd_16px.png);'>"+trans('Optical Drives','UIActionPool')+'</a>').addClass('vboxVMSettingsStorage');
- if(dvdDevices.length == 1) {
- ul = dvdDevices[0].children('ul').first();
- } else {
- ul = $('<ul />').attr({'style':'display:none'}).addClass('vboxVMSettingsStorage');
- for(var i = 0; i < dvdDevices.length; i++) {
- $(ul).append(dvdDevices[i]);
- }
- }
- $(li).append(ul).insertBefore(smenu);
- }
-
- if(fdDevices.length) {
- var ul = null;
- var li = $('<li />').html("<a href='#fdDevices' style='background-image:url(images/vbox/fd_16px.png);'>"+trans('Floppy Devices','UIActionPool')+'</a>').addClass('vboxVMSettingsStorage');
- if(fdDevices.length == 1) {
- ul = fdDevices[0].children('ul').first();
- } else {
- ul = $('<ul />').attr({'style':'display:none'}).addClass('vboxVMSettingsStorage');
- for(var i = 0; i < fdDevices.length; i++) {
- $(ul).append(fdDevices[i]);
- }
- }
- $(li).append(ul).insertBefore(smenu);
- }
-
- }
- if(enabledS) {
- $('#vboxVMSettingsMenu').find('a[href=#Network]').parent().addClass('separator');
- } else {
- $('#vboxVMSettingsMenu').find('a[href=#Network]').parent().removeClass('separator');
- }
-
- // Enable remote display?
- if(vm && vm.VRDEServer) {
- $('#vboxVMSettingsMenu').find('a[href=#RemoteDisplay]').css({'background-image':'url(images/vbox/vrdp' + (vm.VRDEServer.enabled ? '_on' : '') + '_16px.png)'}).parent().removeClass('disabled')
- .addClass((vm.VRDEServer.enabled ? 'vboxMenuItemChecked' : '')).removeClass((vm.VRDEServer.enabled ? '' : 'vboxMenuItemChecked'));
- } else {
- $('#vboxVMSettingsMenu').find('a[href=#RemoteDisplay]').css({'background-image':'url(images/vbox/vrdp_disabled_16px.png)'}).parent().addClass('disabled');
- }
-
-
-}
-
-
-/*
- Bind events...
- */
-
-// Selection list changed
-$('#vboxPane').on('vmSelectionListChanged',function(e) {
-
- vboxChooserToolbarTop.update(vboxChooser);
- vboxUpdateSettingsMenu();
-
- // Check for a single selected VM and
- // update settings menu based on its runtime data
- if(vboxChooser.selectedVMs.length == 1 && (vboxChooser.isSelectedInState('Running') || vboxChooser.isSelectedInState('Paused'))) {
-
- // Get data
- $.when(vboxVMDataMediator.getVMDataCombined(vboxChooser.selectedVMs[0]))
- .done(function(d) {
-
- vboxUpdateSettingsMenu(d);
-
- });
-
- }
-
-// Update menus on these events
-}).on('vboxEvents', function(e, eventList) {
-
- var updateToolbar = false;
- var updateSettingsMenu = false;
- var updateVRDE = false;
-
- for(var i = 0; i < eventList.length && !(updateToolbar && updateSettingsMenu); i++) {
-
- switch(eventList[i].eventType) {
-
- // Machine or session state change
- case 'OnMachineStateChanged':
- case 'OnSessionStateChanged':
- if(vboxChooser.isVMSelected(eventList[i].machineId)) {
- updateToolbar = true;
- }
- if(vboxChooser.getSingleSelectedId() == eventList[i].machineId) {
- updateSettingsMenu = true;
- }
- break;
-
- // Machine or medium data change
- case 'OnMachineDataChanged':
- case 'OnMediumChanged':
- if(vboxChooser.isVMSelected(eventList[i].machineId)) {
- updateToolbar = true;
- updateSettingsMenu = true;
- }
- break;
-
- // VRDE Server
- case 'OnVRDEServerChanged':
- case 'OnVRDEServerInfoChanged':
- if(!updateSettingsMenu && !updateVRDE && vboxChooser.isVMSelected(eventList[i].machineId)) {
- if(eventList[i].enrichmentData && eventList[i].enrichmentData.enabled) {
- updateVRDE = function(){
- $('#vboxVMSettingsMenu').find('a[href=#RemoteDisplay]').css({'background-image':'url(images/vbox/vrdp_on_16px.png)'}).parent().removeClass('disabled')
- .addClass('vboxMenuItemChecked');
- };
- } else {
- updateVRDE = function(){
- $('#vboxVMSettingsMenu').find('a[href=#RemoteDisplay]').css({'background-image':'url(images/vbox/vrdp_16px.png)'}).parent().removeClass('disabled')
- .removeClass('vboxMenuItemChecked');
-
- };
- }
- }
- break;
-
-
- } // </ switch event type >
-
- } // </ for each event >
-
- // Toolbar
- if(updateToolbar) {
- vboxChooserToolbarTop.update(vboxChooser);
- }
-
- // Entire settings menu or just VRDE
- if(updateSettingsMenu) {
-
- // Check for a single selected VM and
- // update settings menu based on its runtime data
- if(vboxChooser.selectedVMs.length == 1 && (vboxChooser.isSelectedInState('Running') || vboxChooser.isSelectedInState('Paused'))) {
-
- // Get data
- $.when(vboxVMDataMediator.getVMDataCombined(vboxChooser.selectedVMs[0]))
- .done(function(d) {
- vboxUpdateSettingsMenu(d);
- });
-
- } else {
- vboxUpdateSettingsMenu();
- }
-
- } else if(updateVRDE) {
-
- updateVRDE();
-
- }
-
-});
-
-$('#vboxVMSettingsMenu').disableContextMenu();
-
-
-</script>
+<!--
+
+ Top (main) phpVirtualBox tool bar
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: toolbar.html 599 2015-07-27 10:40:37Z imoore76 $
+
+-->
+<script type='text/javascript'>
+
+/*
+ * JS objects for actions that can be performed on a VM
+ * from this toolbar
+ */
+var tButtons = [
+
+ vboxVMActions['new'],
+ $.extend({},vboxVMActions['settings'],{click: function(){
+ var vm = vboxChooser.getSingleSelected();
+ if(!vm || vboxVMStates.isRunning(vm) || vboxVMStates.isPaused(vm)) return;
+ vboxVMActions['settings'].click();
+
+ }}),
+ vboxVMActions['start'],
+ {
+ name: 'stop',
+ icon: 'vm_poweroff',
+ label: 'Stop',
+ language_context: 'VBoxSelectorWnd',
+ enabled: vboxVMActions['stop'].enabled,
+ click : function() {return;}
+ }
+];
+
+/* Append Top Toolbar */
+var vboxChooserToolbarTop = new vboxToolbar({buttons: tButtons, size: 32,
+ language_context: 'UIActionPool', renderTo: 'vboxPaneToolbar'});
+
+/* Stop button menu and actions */
+var stopMenuItems = [
+ vboxVMActions['pause'],
+ vboxVMActions['reset'],
+];
+for(var i = 0; i < vboxVMActions.stop_actions.length; i++) {
+ var n = $.extend({}, vboxVMActions[vboxVMActions.stop_actions[i]]);
+ if(i==0) n.separator = true;
+ stopMenuItems[stopMenuItems.length] = n;
+}
+stopMenu = new vboxMenu({name: 'stopContextMenu', menuItems: stopMenuItems, language_context: 'UIActionPool'});
+
+vboxChooserToolbarTop.getButtonElement('stop').contextMenu({
+ menu: stopMenu.menuId(),
+ button: 0,
+ mode: 'menu'
+ },function(a, el, pos) {
+ for(var i in vboxVMActions) {
+ if(typeof i == 'string' && vboxVMActions[i].name == a) {
+ vboxVMActions[i].click();
+ return;
+ }
+ }
+ }
+);
+
+/* 'Settings' menu items / actions */
+var vboxChooserSettingsMenu = {
+
+ 'settings' : {
+ 'label' : vboxVMActions['settings'].label,
+ 'icon' : vboxVMActions['settings'].icon
+ },
+ 'storage' : {
+ 'icon' : 'hd'
+ },
+ 'USB' : {
+ 'label' : 'USB',
+ 'icon' : 'usb'
+ },
+ 'Network' : {
+ 'label' : 'Network',
+ 'icon' : 'nw'
+ },
+ 'SharedFolders' : {
+ 'label' : 'Shared Folders',
+ 'icon' : 'sf'
+ },
+ 'RemoteDisplay' : {
+ 'label' : 'Remote Display',
+ 'icon' : 'vrdp',
+ 'separator' : true
+ },
+ 'GuestAdditions' : {
+ 'label' : vboxVMActions['guestAdditionsInstall'].label,
+ 'icon' : vboxVMActions['guestAdditionsInstall'].icon,
+ 'separator' : true
+ }
+
+};
+
+
+/* 'Settings' menu */
+var ul = $('<ul />').attr({'class':'contextMenu','style':'display: none','id':'vboxVMSettingsMenu'});
+
+for(var i in vboxChooserSettingsMenu) {
+
+ // add name
+ vboxChooserSettingsMenu[i].name = i;
+ var label = trans(vboxChooserSettingsMenu[i].label, 'UIActionPool');
+ var li = $('<li />').html("<span class='vboxMenuItemChecked' /><a href='#" + vboxChooserSettingsMenu[i].name + "' style='background-image: url(images/vbox/" + vboxChooserSettingsMenu[i].icon +"_16px.png);' >"+(label ? label : ' ')+"</a>");
+ if(i == 'storage') { $(li).attr({'style':'display:none','id':'vboxVMSettingsToolbarStorageHolder'}); }
+ if(i == 'USB') {
+ /* 'USB' menu */
+ $('<ul />').attr({'class':'vboxSettingsUSBAttachmentsMenu contextMenuNoBG','style':'display: none','id':'vboxVMSettingsUSBMenu'}).data({'callback':'vboxChooserToolbarUSBUpdate'}).appendTo(li);
+ }
+ if(vboxChooserSettingsMenu[i].separator) $(li).addClass('separator');
+ $(ul).append(li);
+
+}
+
+/* Append 'Settings' button Menu */
+$('#vboxPane').append(ul);
+
+
+
+/* 'Settings' button menu initialization */
+vboxChooserToolbarTop.getButtonElement('settings').contextMenu({
+ menu: 'vboxVMSettingsMenu',
+ button: 0,
+ mode: 'menu'
+ },
+ function(a, el, pos, srcEl) {
+
+ var vm = vboxChooser.getSingleSelected();
+
+ if(!vm) return;
+
+ switch(a) {
+
+ case 'Network':
+ case 'SharedFolders':
+ vboxVMsettingsDialog(vm, a);
+ break;
+
+ case 'GuestAdditions':
+
+ vboxVMActions['guestAdditionsInstall'].click();
+ break;
+
+ // Don't do anything for dvd, fd, or USB devices main menu item click
+ case 'dvdDevices':
+ case 'fdDevices':
+ case 'USB':
+ break;
+
+ case 'RemoteDisplay':
+ var en = vboxVMDataMediator.getVMRuntimeData(vm.id).VRDEServer.enabled;
+ vboxAjaxRequest('consoleVRDEServerSave',{'vm':vm.id,'enabled':(en ? 0 : 1)});
+ break;
+
+ case 'settings':
+ vboxVMActions['settings'].click();
+ break;
+
+ default:
+
+ // Assume it was a storage action
+ if(vboxToolbarMediaLast) {
+ if(vboxToolbarMediaLast.type == 'DVD') {
+ vboxToolbarMediaMenuDVD.menuCallback(a,el,pos);
+ } else {
+ vboxToolbarMediaMenuFD.menuCallback(a,el,pos);
+ }
+ }
+
+ } // </ switch / case >
+
+ }
+);
+
+/*
+ * Storage mount menu
+ */
+var vboxToolbarMediaLast = null; // Used when context menu item is clicked to determine
+ // which medium attachment to act upon.
+function vboxChooserToolbarMediumMount(medium) {
+
+ var vmid = vboxChooser.getSingleSelectedId();
+
+ var args = {'vm':vmid,'medium':medium,'port':vboxToolbarMediaLast.port,'device':vboxToolbarMediaLast.device,'bus':vboxToolbarMediaLast.bus,'controller':vboxToolbarMediaLast.controller};
+
+ // Ajax request to mount medium
+ var mount = new vboxLoader('mediumMount');
+ mount.add('mediumMount',function(d){
+ var l = new vboxLoader('getMedia');
+ l.add('vboxGetMedia',function(d){$('#vboxPane').data('vboxMedia',d.responseData);});
+ l.run();
+ },args);
+ mount.run();
+}
+var vboxToolbarMediaMenuDVD = new vboxMediaMenu('DVD',vboxChooserToolbarMediumMount,'');
+var vboxToolbarMediaMenuFD = new vboxMediaMenu('Floppy',vboxChooserToolbarMediumMount,'');
+
+function vboxChooserToolbarStorageUpdate(menu) {
+
+ vboxToolbarMediaLast = $(menu).data('storage');
+ var medium = null;
+ if(vboxToolbarMediaLast && vboxToolbarMediaLast.medium && vboxToolbarMediaLast.medium.id)
+ medium = vboxMedia.getMediumById(vboxToolbarMediaLast.medium.id);
+
+ if(vboxToolbarMediaLast.type == 'DVD') {
+ vboxToolbarMediaMenuDVD.menuUpdateMedia(medium);
+ return vboxToolbarMediaMenuDVD.menuElement();
+ }
+
+ vboxToolbarMediaMenuFD.menuUpdateMedia(medium);
+ return vboxToolbarMediaMenuFD.menuElement();
+}
+
+// Update host drives and recent media on host change.
+// Just recreate the menus
+$('#vboxPane').on('hostChanged',function(){
+ vboxToolbarMediaMenuDVD = new vboxMediaMenu('DVD',vboxChooserToolbarMediumMount,'');
+ vboxToolbarMediaMenuFD = new vboxMediaMenu('Floppy',vboxChooserToolbarMediumMount,'');
+});
+/*
+ * Update USB device list
+ */
+function vboxChooserToolbarUSBUpdate(menu) {
+
+ $(menu).append($('<li />').html('<span><img src="images/jqueryFileTree/spinner.gif" /></span>').css({'width':'100px','text-align':'center'}));
+
+ var vm = vboxChooser.getSingleSelected();
+
+ var l = new vboxLoader();
+
+ l.add('hostGetUSBDevices',function(d){
+ $('#vboxPaneToolbar').data('hostUSB',d.responseData);
+ },{});
+
+ l.add('consoleGetUSBDevices',function(d){
+ $('#vboxPaneToolbar').data('guestUSB',d.responseData);
+ },{'vm':vm.id});
+
+ l.noLoadingScreen = true;
+ l.onLoad = function() {
+
+ var hostUSB = $('#vboxPaneToolbar').data('hostUSB');
+ var guestUSB = $('#vboxPaneToolbar').data('guestUSB');
+ $(menu).children().remove();
+
+ for(var i = 0; i < hostUSB.length; i++) {
+
+ var dname = '';
+ if(!hostUSB[i].product) {
+ dname = trans('Unknown device %1:%2','UIActionPool').replace('%1',hostUSB[i].vendorId).replace('%2',hostUSB[i].productId);
+ } else {
+ dname = hostUSB[i].manufacturer + ' ' + hostUSB[i].product;
+ }
+ dname += ' [' + hostUSB[i].revision + ']';
+ var capt = (hostUSB[i].state == 'Captured' && guestUSB[hostUSB[i].id]);
+ var avail = (capt || (hostUSB[i].state != 'NotSupported' && hostUSB[i].state != 'Unavailable' && hostUSB[i].state != 'Captured'));
+ var cbox = $('<input />').attr({'type':'checkbox','class':'vboxCheckbox'}).prop({'checked':(capt ? true : false),'disabled':(avail ? false : true)}).on('click',function(e){
+ e.stopPropagation();
+ if($(this).prop('disabled')) return;
+
+ var cbox = $(this);
+ // Detach
+ if($(this).data('capt')) {
+ $.when(vboxAjaxRequest('consoleUSBDeviceDetach',{'vm':vm.id,'id':$(this).data('usbDevice')})).done(function(d){
+ if(d.success) {
+ cbox.prop('checked',false);
+ cbox.data('capt',false);
+ } else {
+ cbox.prop('checked',true);
+ }
+ });
+ // Attach
+ } else {
+ $.when(vboxAjaxRequest('consoleUSBDeviceAttach',{'vm':vm.id,'id':$(this).data('usbDevice')})).done(function(d){
+ if(d.success) {
+ cbox.prop('checked',true);
+ cbox.data('capt',true);
+ } else {
+ cbox.prop('checked',false);
+ }
+ });
+ }
+ }).data({'usbDevice':hostUSB[i].id,'capt':capt});
+
+ $(menu).append($('<li />').append(
+ $('<span />').addClass('vboxMenuAcceptClick')
+ .click(function(){if(!$(this).parent().hasClass('disabled')){$(this).children('input').click();}return false;})
+ .append(cbox).append(' '+dname)).attr({'class':(avail ? '' : 'disabled')}));
+ }
+
+ // No devices?
+ if(hostUSB.length == 0) {
+ $(menu).append($('<li />').html('<span>'+$('<div />').text(trans('<no devices available>','VBoxUSBMenu')).html()+'</span>'));
+ }
+ $(menu).trigger('menuLoaded');
+ };
+ l.run();
+}
+
+/*
+ *
+ * Update vboxSettingsMenu items. Called when
+ * vboxChooser selection changes $('#vboxPane').onvmSelectionListChanged
+ *
+ */
+function vboxUpdateSettingsMenu(vm) {
+
+ if(vboxVMStates.isRunning(vm) || vboxVMStates.isPaused(vm)) {
+ vboxChooserToolbarTop.getButtonElement("settings").enableContextMenu();
+ } else {
+ vboxChooserToolbarTop.getButtonElement("settings").disableContextMenu();
+ return;
+ }
+ // enable or disable USB
+ var usbEnabled = false;
+ if(vm['USBControllers'].length) {
+ for(var i = 0; i < vm['USBControllers'].length; i++) {
+ if(vm['USBControllers'][i].type == 'OHCI') {
+ usbEnabled = true;
+ break;
+ }
+ }
+ }
+ if(usbEnabled) {
+ $('ul.vboxSettingsUSBAttachmentsMenu').children().remove();
+ $('#vboxVMSettingsMenu').find('a[href=#USB]').closest('li').css('display','');
+ } else {
+ $('#vboxVMSettingsMenu').find('a[href=#USB]').closest('li').css('display','none');
+ }
+
+ // Enable or disable network
+ var enabledS = false;
+ if(vm && vm.networkAdapters && vm.networkAdapters.length) {
+ for(var a = 0; a < vm.networkAdapters.length; a++) {
+ if(vm.networkAdapters[a].enabled) {
+ enabledS = true;
+ break;
+ }
+ }
+ }
+ if(enabledS) {
+ $('#vboxVMSettingsMenu').find('a[href=#Network]').closest('li').css('display','');
+ } else {
+ $('#vboxVMSettingsMenu').find('a[href=#Network]').closest('li').css('display','none');
+ }
+
+ // vboxVMSettingsToolbarStorageHolder
+ var smenu = $('#vboxVMSettingsToolbarStorageHolder');
+ smenu.siblings('li.vboxVMSettingsStorage').remove();
+ $('ul.vboxVMSettingsStorage').remove();
+ var enabledS = false;
+ if(vm && vm.storageControllers && vm.storageControllers.length) {
+ var dvdDevices = new Array();
+ var fdDevices = new Array();
+
+ for(var a = 0; a < vm.storageControllers.length; a++) {
+
+ // See if this bus type supports removable media
+ if(jQuery.inArray('dvd',vboxStorage[vm['storageControllers'][a].bus].driveTypes) == -1 &&
+ jQuery.inArray('floppy',vboxStorage[vm['storageControllers'][a].bus].driveTypes) == -1)
+ continue;
+
+ var icon = vboxStorage.getBusIconName(vm['storageControllers'][a].bus);
+
+ for(var b = 0; b < vm['storageControllers'][a]['mediumAttachments'].length; b++) {
+
+ if(vm['storageControllers'][a]['mediumAttachments'][b].type == 'HardDisk') continue;
+
+ vm['storageControllers'][a]['mediumAttachments'][b]['controller'] = vm['storageControllers'][a]['name'];
+
+ var portName = vboxStorage[vm['storageControllers'][a].bus].slotName(vm['storageControllers'][a]['mediumAttachments'][b].port, vm['storageControllers'][a]['mediumAttachments'][b].device);
+ var m = vm['storageControllers'][a]['mediumAttachments'][b].medium;
+ m = vboxMedia.getMediumById((m && m.id ? m.id : null));
+
+ var mName = vboxMedia.getName(m);
+ mName = $('<div />').text(mName).html();
+
+
+ var smid = vm.id+'-vboxVMSettingsStorage-'+a+'-'+b;
+ $('#'+vm.id+'-vboxVMSettingsStorage-'+a+'-'+b).remove();
+
+ var li = $('<li />').attr({'title':mName}).html("<a title='"+mName+"' href='#mount-"+vm['storageControllers'][a].bus+"-"+vm['storageControllers'][a]['mediumAttachments'][b].port+"-"+vm['storageControllers'][a]['mediumAttachments'][b].device+"' style='background-image:url(images/vbox/"+icon+"_16px.png);'>"+vm['storageControllers'][a]['name'] + ' ('+portName + ")</a>").addClass('vboxVMSettingsStorage');
+ $(li).append($('<ul />').attr({'id':smid,'style':'display:none'}).data({'callback':'vboxChooserToolbarStorageUpdate','storage':vm['storageControllers'][a]['mediumAttachments'][b]}));
+ if(vm['storageControllers'][a]['mediumAttachments'][b].type == 'DVD') {
+ dvdDevices[dvdDevices.length] = li;
+ } else {
+ fdDevices[fdDevices.length] = li;
+ }
+ enabledS = true;
+ }
+ }
+ if(dvdDevices.length) {
+ var ul = null;
+ var li = $('<li />').html("<a href='#dvdDevices' style='background-image:url(images/vbox/cd_16px.png);'>"+trans('Optical Drives','UIActionPool')+'</a>').addClass('vboxVMSettingsStorage');
+ if(dvdDevices.length == 1) {
+ ul = dvdDevices[0].children('ul').first();
+ } else {
+ ul = $('<ul />').attr({'style':'display:none'}).addClass('vboxVMSettingsStorage');
+ for(var i = 0; i < dvdDevices.length; i++) {
+ $(ul).append(dvdDevices[i]);
+ }
+ }
+ $(li).append(ul).insertBefore(smenu);
+ }
+
+ if(fdDevices.length) {
+ var ul = null;
+ var li = $('<li />').html("<a href='#fdDevices' style='background-image:url(images/vbox/fd_16px.png);'>"+trans('Floppy Devices','UIActionPool')+'</a>').addClass('vboxVMSettingsStorage');
+ if(fdDevices.length == 1) {
+ ul = fdDevices[0].children('ul').first();
+ } else {
+ ul = $('<ul />').attr({'style':'display:none'}).addClass('vboxVMSettingsStorage');
+ for(var i = 0; i < fdDevices.length; i++) {
+ $(ul).append(fdDevices[i]);
+ }
+ }
+ $(li).append(ul).insertBefore(smenu);
+ }
+
+ }
+ if(enabledS) {
+ $('#vboxVMSettingsMenu').find('a[href=#Network]').parent().addClass('separator');
+ } else {
+ $('#vboxVMSettingsMenu').find('a[href=#Network]').parent().removeClass('separator');
+ }
+
+ // Enable remote display?
+ if(vm && vm.VRDEServer) {
+ $('#vboxVMSettingsMenu').find('a[href=#RemoteDisplay]').css({'background-image':'url(images/vbox/vrdp' + (vm.VRDEServer.enabled ? '_on' : '') + '_16px.png)'}).parent().removeClass('disabled')
+ .addClass((vm.VRDEServer.enabled ? 'vboxMenuItemChecked' : '')).removeClass((vm.VRDEServer.enabled ? '' : 'vboxMenuItemChecked'));
+ } else {
+ $('#vboxVMSettingsMenu').find('a[href=#RemoteDisplay]').css({'background-image':'url(images/vbox/vrdp_disabled_16px.png)'}).parent().addClass('disabled');
+ }
+
+
+}
+
+
+/*
+ Bind events...
+ */
+
+// Selection list changed
+$('#vboxPane').on('vmSelectionListChanged',function(e) {
+
+ vboxChooserToolbarTop.update(vboxChooser);
+ vboxUpdateSettingsMenu();
+
+ // Check for a single selected VM and
+ // update settings menu based on its runtime data
+ if(vboxChooser.selectedVMs.length == 1 && (vboxChooser.isSelectedInState('Running') || vboxChooser.isSelectedInState('Paused'))) {
+
+ // Get data
+ $.when(vboxVMDataMediator.getVMDataCombined(vboxChooser.selectedVMs[0]))
+ .done(function(d) {
+
+ vboxUpdateSettingsMenu(d);
+
+ });
+
+ }
+
+// Update menus on these events
+}).on('vboxEvents', function(e, eventList) {
+
+ var updateToolbar = false;
+ var updateSettingsMenu = false;
+ var updateVRDE = false;
+
+ for(var i = 0; i < eventList.length && !(updateToolbar && updateSettingsMenu); i++) {
+
+ switch(eventList[i].eventType) {
+
+ // Machine or session state change
+ case 'OnMachineStateChanged':
+ case 'OnSessionStateChanged':
+ if(vboxChooser.isVMSelected(eventList[i].machineId)) {
+ updateToolbar = true;
+ }
+ if(vboxChooser.getSingleSelectedId() == eventList[i].machineId) {
+ updateSettingsMenu = true;
+ }
+ break;
+
+ // Machine or medium data change
+ case 'OnMachineDataChanged':
+ case 'OnMediumChanged':
+ if(vboxChooser.isVMSelected(eventList[i].machineId)) {
+ updateToolbar = true;
+ updateSettingsMenu = true;
+ }
+ break;
+
+ // VRDE Server
+ case 'OnVRDEServerChanged':
+ case 'OnVRDEServerInfoChanged':
+ if(!updateSettingsMenu && !updateVRDE && vboxChooser.isVMSelected(eventList[i].machineId)) {
+ if(eventList[i].enrichmentData && eventList[i].enrichmentData.enabled) {
+ updateVRDE = function(){
+ $('#vboxVMSettingsMenu').find('a[href=#RemoteDisplay]').css({'background-image':'url(images/vbox/vrdp_on_16px.png)'}).parent().removeClass('disabled')
+ .addClass('vboxMenuItemChecked');
+ };
+ } else {
+ updateVRDE = function(){
+ $('#vboxVMSettingsMenu').find('a[href=#RemoteDisplay]').css({'background-image':'url(images/vbox/vrdp_16px.png)'}).parent().removeClass('disabled')
+ .removeClass('vboxMenuItemChecked');
+
+ };
+ }
+ }
+ break;
+
+
+ } // </ switch event type >
+
+ } // </ for each event >
+
+ // Toolbar
+ if(updateToolbar) {
+ vboxChooserToolbarTop.update(vboxChooser);
+ }
+
+ // Entire settings menu or just VRDE
+ if(updateSettingsMenu) {
+
+ // Check for a single selected VM and
+ // update settings menu based on its runtime data
+ if(vboxChooser.selectedVMs.length == 1 && (vboxChooser.isSelectedInState('Running') || vboxChooser.isSelectedInState('Paused'))) {
+
+ // Get data
+ $.when(vboxVMDataMediator.getVMDataCombined(vboxChooser.selectedVMs[0]))
+ .done(function(d) {
+ vboxUpdateSettingsMenu(d);
+ });
+
+ } else {
+ vboxUpdateSettingsMenu();
+ }
+
+ } else if(updateVRDE) {
+
+ updateVRDE();
+
+ }
+
+});
+
+$('#vboxVMSettingsMenu').disableContextMenu();
+
+
+</script>
diff --git a/panes/topmenu.html b/panes/topmenu.html
index 7042455..98563ce 100644
--- a/panes/topmenu.html
+++ b/panes/topmenu.html
@@ -1,287 +1,287 @@
-<!--
-
- Main / Top menu
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: topmenu.html 595 2015-04-17 09:50:36Z imoore76 $
-
- -->
-<span></span>
-<script type='text/javascript'>
-/*
- *
- * Main menu at top of interface
- *
- *
- */
-
-// Top menu
-var vboxTopMenuBar = new vboxMenuBar({name: 'vboxTop', language_context: 'UIActionPool'});
-
-var menu = {
- 'name':'vboxTopFile',
- 'label': 'File',
- 'menu':[
- {
- 'name':'fileVMM',
- 'label':'Virtual Media Manager...',
- 'icon':'diskimage',
- 'click':function(){vboxVMMDialog();}
- },
- {
- 'name':'fileImport',
- 'label':'Import Appliance...',
- 'icon':'import',
- 'click':function(){
-
- new vboxWizardImportApplianceDialog().run();
- },
- 'separator': true
- },
- {
- 'name':'fileExport',
- 'label':'Export Appliance...',
- 'icon':'export',
- 'click':function(){new vboxWizardExportApplianceDialog().run();}
- },
- {
- 'name':'filePrefs',
- 'label':'Preferences...',
- 'icon':'global_settings',
- 'click':function(){vboxGlobalPrefsDialog();},
- 'separator':true
- }
- ]
-};
-
-if($('#vboxPane').data('vboxSession').user) {
- if ( $('#vboxPane').data('vboxConfig').authCapabilities.canChangePassword )
- menu['menu'][menu['menu'].length] = {
- 'name' : 'fileChangePW',
- 'label' : 'Change Password',
- 'language_context': 'UIUsers',
- 'icon' : 'register',
- 'click': function() {
- var l = new vboxLoader();
- l.addFileToDOM('panes/userEdit.html');
- l.onLoad = function(){
-
- // Set mode
- $('#vboxUserEdit').trigger('setMode','changePassword');
-
- var buttons = {};
- buttons[trans('OK','QIMessageBox')] = function() {
- var o = $('#vboxUserEdit').find('input[name=opass]').first().val();
- var n1 = $('#vboxUserEdit').find('input[name=npass1]').first().val();
- var n2 = $('#vboxUserEdit').find('input[name=npass2]').first().val();
- if(o.length == 0) {
- vboxAlert(trans('The password you have entered is invalid.','UIUsers'),{'width':'auto'});
- return;
- }
- if(n1.length == 0 || (n1 != n2)) {
- vboxAlert(trans('The passwords you have entered do not match.','UIUsers'),{'width':'auto'});
- return;
- }
- var dialog = this;
- var chp = new vboxLoader();
- chp.add('changePassword',function(d){
- if(d) {
- if(d.success) {
- vboxAlert(trans('Password changed.','UIUsers'),{'width':'auto'});
- $(dialog).remove();
- } else {
- vboxAlert(trans('The password you have entered is invalid.','UIUsers'),{'width':'auto'});
- }
- } else {
- // unknown error
- $(dialog).remove();
- }
- },{'old':o,'new':n1});
- chp.run();
- };
- buttons[trans('Cancel','QIMessageBox')] = function(){
- $(this).remove();
- };
- $('#vboxUserEdit').dialog({'closeOnEscape':false,'width':400,'height':200,'buttons':buttons,'modal':true,'autoOpen':true,'dialogClass':'vboxDialogContent','title':'<img src="images/vbox/register_16px.png" class="vboxDialogTitleIcon" /> '+trans('Change Password','UIUsers')});
- };
- l.run();
- },
- 'separator':true
- };
-
- if ( $('#vboxPane').data('vboxConfig').authCapabilities.canLogout )
- {
- menu['menu'][menu['menu'].length] = {
- 'name' : 'fileLogout',
- // Pre-translated title to append username
- 'label' : trans('Log out - %1','VBoxSelectorWnd').replace('%1',$('#vboxPane').data('vboxSession').user),
- 'icon' : 'exit',
- 'click': function() {
-
- // Show loading screen
- var lm = new vboxLoader();
- lm.showLoading();
-
- // Expire data mediator data
- vboxVMDataMediator.expireAll();
-
- // Unsubscribe from events
- $.when(vboxEventListener.stop()).done(function() {
-
- // remove loading screen
- lm.removeLoading();
-
- var l = new vboxLoader();
- l.noLoadingScreen = true;
- l.add('logout',function(r){
- if ( typeof(r.responseData.url) == 'string' )
- {
- window.location = r.responseData.url;
- }
- else
- {
- location.reload(true);
- }
- });
- l.onLoad = function(loader){
- loader.hideRoot = false;
- };
- l.hideRoot = true;
- l.run();
- });
- }
- };
- }
- else
- {
- menu['menu'][menu['menu'].length] = {
- 'name' : 'fileLogout',
- 'label' : trans('Logged in as %1','VBoxSelectorWnd').replace('%1',$('#vboxPane').data('vboxSession').user),
- 'icon' : 'exit',
- 'click': function() {
- return false;
- }
- };
- }
-
-}
-
-vboxTopMenuBar.addMenu(menu);
-
-//VM List Context menu for each VM
-var sChildren = [];
-for(var i = 0; i < vboxVMActions.stop_actions.length; i++) {
- sChildren[sChildren.length] = vboxVMActions[vboxVMActions.stop_actions[i]];
-}
-
-
-vboxTopMenuBar.addMenu({
- 'name': 'vboxTopMachine',
- 'label': 'Machine',
- 'enabled' : function(chooser) {
- return (!chooser || (chooser.selectionMode != vboxSelectionModeSingleGroup));
- },
- 'menu':[
- vboxVMActions['new'],
- vboxVMActions['add'],
- vboxVMActions['settings'],
- vboxVMActions['clone'],
- vboxVMActions['remove'],
- vboxVMActions['group'],
- $.extend({},vboxVMActions['start'],{'separator':true}),
- vboxVMActions['pause'],
- vboxVMActions['reset'],
- $.extend({},vboxVMActions['stop'],{'children':sChildren}),
- $.extend({},vboxVMActions['discard'],{'separator':true}),
- vboxVMActions['logs'],
- vboxVMActions['refresh'],
- ]
-});
-
-
-vboxTopMenuBar.addMenu({
- 'name':'vboxTopGroup',
- 'label':'Group',
- 'enabled' : function(chooser) {
- return (chooser && (chooser.selectionMode == vboxSelectionModeSingleGroup));
- },
- 'menu':[
- vboxVMGroupActions['newmachine'],
- vboxVMGroupActions['addmachine'],
- $.extend({}, vboxVMGroupActions['rename'], {separator:true}),
- vboxVMGroupActions['ungroup'],
- $.extend({},vboxVMActions['start'],{'name':'start','separator' : true}),
- vboxVMActions['pause'],
- vboxVMActions['reset'],
- $.extend({},vboxVMActions['stop'],{'children':sChildren}),
- $.extend({},vboxVMActions['discard'],{'separator' : true}),
- vboxVMActions['refresh'],
- $.extend({}, vboxVMGroupActions['sort'], {separator:true})
- ]
-});
-
-vboxTopMenuBar.addMenu({
- 'name':'vboxTopHelp',
- 'label': 'Help',
- 'language_context': 'UIHelpButton',
- 'menu':[
- {
- 'name':'helpvbox',
- 'label':'VirtualBox User Manual',
- 'icon':'site',
- 'click':function(){
- window.open('http://www.virtualbox.org/manual/','manual');
- }
- },
-
- {
- 'name':'helpAbout',
- 'label':'About',
- 'icon':'help',
- 'click':function(){
-
- $('#vboxPane').append($('<div />').attr({'id':'vboxAbout','class':'vboxDialogContent','style':'display: none; width: 500px;'}));
-
- var l = new vboxLoader();
- l.addFileToDOM('panes/about.html',$('#vboxAbout'));
- l.onLoad = function() {
- var buttons = {};
- buttons[trans('Close','UIVMLogViewer')] = function() { $(this).empty().remove(); };
-
- $('#vboxAbout').dialog({'closeOnEscape':false,'width':500,'height':'auto','buttons':buttons,'modal':true,'autoOpen':true,'dialogClass':'vboxDialogContent','title':'<img src="images/vbox/help_16px.png" class="vboxDialogTitleIcon" /> phpVirtualBox'});
- };
- l.run();
- }
- }
-
- ]
-});
-
-vboxTopMenuBar.renderTo('vboxMenu');
-
-$('#vboxPane').on('vmSelectionListChanged vmGroupDefsSaving vmGroupDefsSaved',function(e){
- vboxTopMenuBar.update(vboxChooser);
-
-}).on('vboxEvents', function(e, eventList) {
-
- var updateMenuBar = false;
- for(var i = 0; i < eventList.length && !updateMenuBar; i++) {
-
- switch(eventList[i].eventType) {
- case 'OnMachineStateChanged':
- case 'OnSessionStateChanged':
- if(vboxChooser.isVMSelected(eventList[i].machineId)) {
- updateMenuBar = true;
- }
- break;
- }
- }
-
- if(updateMenuBar) {
- vboxTopMenuBar.update(vboxChooser);
- }
-
-});
-
-
+<!--
+
+ Main / Top menu
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: topmenu.html 595 2015-04-17 09:50:36Z imoore76 $
+
+ -->
+<span></span>
+<script type='text/javascript'>
+/*
+ *
+ * Main menu at top of interface
+ *
+ *
+ */
+
+// Top menu
+var vboxTopMenuBar = new vboxMenuBar({name: 'vboxTop', language_context: 'UIActionPool'});
+
+var menu = {
+ 'name':'vboxTopFile',
+ 'label': 'File',
+ 'menu':[
+ {
+ 'name':'fileVMM',
+ 'label':'Virtual Media Manager...',
+ 'icon':'diskimage',
+ 'click':function(){vboxVMMDialog();}
+ },
+ {
+ 'name':'fileImport',
+ 'label':'Import Appliance...',
+ 'icon':'import',
+ 'click':function(){
+
+ new vboxWizardImportApplianceDialog().run();
+ },
+ 'separator': true
+ },
+ {
+ 'name':'fileExport',
+ 'label':'Export Appliance...',
+ 'icon':'export',
+ 'click':function(){new vboxWizardExportApplianceDialog().run();}
+ },
+ {
+ 'name':'filePrefs',
+ 'label':'Preferences...',
+ 'icon':'global_settings',
+ 'click':function(){vboxGlobalPrefsDialog();},
+ 'separator':true
+ }
+ ]
+};
+
+if($('#vboxPane').data('vboxSession').user) {
+ if ( $('#vboxPane').data('vboxConfig').authCapabilities.canChangePassword )
+ menu['menu'][menu['menu'].length] = {
+ 'name' : 'fileChangePW',
+ 'label' : 'Change Password',
+ 'language_context': 'UIUsers',
+ 'icon' : 'register',
+ 'click': function() {
+ var l = new vboxLoader();
+ l.addFileToDOM('panes/userEdit.html');
+ l.onLoad = function(){
+
+ // Set mode
+ $('#vboxUserEdit').trigger('setMode','changePassword');
+
+ var buttons = {};
+ buttons[trans('OK','QIMessageBox')] = function() {
+ var o = $('#vboxUserEdit').find('input[name=opass]').first().val();
+ var n1 = $('#vboxUserEdit').find('input[name=npass1]').first().val();
+ var n2 = $('#vboxUserEdit').find('input[name=npass2]').first().val();
+ if(o.length == 0) {
+ vboxAlert(trans('The password you have entered is invalid.','UIUsers'),{'width':'auto'});
+ return;
+ }
+ if(n1.length == 0 || (n1 != n2)) {
+ vboxAlert(trans('The passwords you have entered do not match.','UIUsers'),{'width':'auto'});
+ return;
+ }
+ var dialog = this;
+ var chp = new vboxLoader();
+ chp.add('changePassword',function(d){
+ if(d) {
+ if(d.success) {
+ vboxAlert(trans('Password changed.','UIUsers'),{'width':'auto'});
+ $(dialog).remove();
+ } else {
+ vboxAlert(trans('The password you have entered is invalid.','UIUsers'),{'width':'auto'});
+ }
+ } else {
+ // unknown error
+ $(dialog).remove();
+ }
+ },{'old':o,'new':n1});
+ chp.run();
+ };
+ buttons[trans('Cancel','QIMessageBox')] = function(){
+ $(this).remove();
+ };
+ $('#vboxUserEdit').dialog({'closeOnEscape':false,'width':400,'height':200,'buttons':buttons,'modal':true,'autoOpen':true,'dialogClass':'vboxDialogContent','title':'<img src="images/vbox/register_16px.png" class="vboxDialogTitleIcon" /> '+trans('Change Password','UIUsers')});
+ };
+ l.run();
+ },
+ 'separator':true
+ };
+
+ if ( $('#vboxPane').data('vboxConfig').authCapabilities.canLogout )
+ {
+ menu['menu'][menu['menu'].length] = {
+ 'name' : 'fileLogout',
+ // Pre-translated title to append username
+ 'label' : trans('Log out - %1','VBoxSelectorWnd').replace('%1',$('#vboxPane').data('vboxSession').user),
+ 'icon' : 'exit',
+ 'click': function() {
+
+ // Show loading screen
+ var lm = new vboxLoader();
+ lm.showLoading();
+
+ // Expire data mediator data
+ vboxVMDataMediator.expireAll();
+
+ // Unsubscribe from events
+ $.when(vboxEventListener.stop()).done(function() {
+
+ // remove loading screen
+ lm.removeLoading();
+
+ var l = new vboxLoader();
+ l.noLoadingScreen = true;
+ l.add('logout',function(r){
+ if ( typeof(r.responseData.url) == 'string' )
+ {
+ window.location = r.responseData.url;
+ }
+ else
+ {
+ location.reload(true);
+ }
+ });
+ l.onLoad = function(loader){
+ loader.hideRoot = false;
+ };
+ l.hideRoot = true;
+ l.run();
+ });
+ }
+ };
+ }
+ else
+ {
+ menu['menu'][menu['menu'].length] = {
+ 'name' : 'fileLogout',
+ 'label' : trans('Logged in as %1','VBoxSelectorWnd').replace('%1',$('#vboxPane').data('vboxSession').user),
+ 'icon' : 'exit',
+ 'click': function() {
+ return false;
+ }
+ };
+ }
+
+}
+
+vboxTopMenuBar.addMenu(menu);
+
+//VM List Context menu for each VM
+var sChildren = [];
+for(var i = 0; i < vboxVMActions.stop_actions.length; i++) {
+ sChildren[sChildren.length] = vboxVMActions[vboxVMActions.stop_actions[i]];
+}
+
+
+vboxTopMenuBar.addMenu({
+ 'name': 'vboxTopMachine',
+ 'label': 'Machine',
+ 'enabled' : function(chooser) {
+ return (!chooser || (chooser.selectionMode != vboxSelectionModeSingleGroup));
+ },
+ 'menu':[
+ vboxVMActions['new'],
+ vboxVMActions['add'],
+ vboxVMActions['settings'],
+ vboxVMActions['clone'],
+ vboxVMActions['remove'],
+ vboxVMActions['group'],
+ $.extend({},vboxVMActions['start'],{'separator':true}),
+ vboxVMActions['pause'],
+ vboxVMActions['reset'],
+ $.extend({},vboxVMActions['stop'],{'children':sChildren}),
+ $.extend({},vboxVMActions['discard'],{'separator':true}),
+ vboxVMActions['logs'],
+ vboxVMActions['refresh'],
+ ]
+});
+
+
+vboxTopMenuBar.addMenu({
+ 'name':'vboxTopGroup',
+ 'label':'Group',
+ 'enabled' : function(chooser) {
+ return (chooser && (chooser.selectionMode == vboxSelectionModeSingleGroup));
+ },
+ 'menu':[
+ vboxVMGroupActions['newmachine'],
+ vboxVMGroupActions['addmachine'],
+ $.extend({}, vboxVMGroupActions['rename'], {separator:true}),
+ vboxVMGroupActions['ungroup'],
+ $.extend({},vboxVMActions['start'],{'name':'start','separator' : true}),
+ vboxVMActions['pause'],
+ vboxVMActions['reset'],
+ $.extend({},vboxVMActions['stop'],{'children':sChildren}),
+ $.extend({},vboxVMActions['discard'],{'separator' : true}),
+ vboxVMActions['refresh'],
+ $.extend({}, vboxVMGroupActions['sort'], {separator:true})
+ ]
+});
+
+vboxTopMenuBar.addMenu({
+ 'name':'vboxTopHelp',
+ 'label': 'Help',
+ 'language_context': 'UIHelpButton',
+ 'menu':[
+ {
+ 'name':'helpvbox',
+ 'label':'VirtualBox User Manual',
+ 'icon':'site',
+ 'click':function(){
+ window.open('http://www.virtualbox.org/manual/','manual');
+ }
+ },
+
+ {
+ 'name':'helpAbout',
+ 'label':'About',
+ 'icon':'help',
+ 'click':function(){
+
+ $('#vboxPane').append($('<div />').attr({'id':'vboxAbout','class':'vboxDialogContent','style':'display: none; width: 500px;'}));
+
+ var l = new vboxLoader();
+ l.addFileToDOM('panes/about.html',$('#vboxAbout'));
+ l.onLoad = function() {
+ var buttons = {};
+ buttons[trans('Close','UIVMLogViewer')] = function() { $(this).empty().remove(); };
+
+ $('#vboxAbout').dialog({'closeOnEscape':false,'width':500,'height':'auto','buttons':buttons,'modal':true,'autoOpen':true,'dialogClass':'vboxDialogContent','title':'<img src="images/vbox/help_16px.png" class="vboxDialogTitleIcon" /> phpVirtualBox'});
+ };
+ l.run();
+ }
+ }
+
+ ]
+});
+
+vboxTopMenuBar.renderTo('vboxMenu');
+
+$('#vboxPane').on('vmSelectionListChanged vmGroupDefsSaving vmGroupDefsSaved',function(e){
+ vboxTopMenuBar.update(vboxChooser);
+
+}).on('vboxEvents', function(e, eventList) {
+
+ var updateMenuBar = false;
+ for(var i = 0; i < eventList.length && !updateMenuBar; i++) {
+
+ switch(eventList[i].eventType) {
+ case 'OnMachineStateChanged':
+ case 'OnSessionStateChanged':
+ if(vboxChooser.isVMSelected(eventList[i].machineId)) {
+ updateMenuBar = true;
+ }
+ break;
+ }
+ }
+
+ if(updateMenuBar) {
+ vboxTopMenuBar.update(vboxChooser);
+ }
+
+});
+
+
</script> \ No newline at end of file
diff --git a/panes/userEdit.html b/panes/userEdit.html
index da8af45..bab3ea8 100644
--- a/panes/userEdit.html
+++ b/panes/userEdit.html
@@ -1,64 +1,64 @@
-<!--
-
- User edit dialog
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: userEdit.html 595 2015-04-17 09:50:36Z imoore76 $
--->
-<div id='vboxUserEdit'>
-<form>
-<table class='vboxVertical'>
-<tr class='addUser'>
- <th><span class='translate'>Username</span>:</th>
- <td><input type='text' name='username' class='vboxText' /></td>
-</tr>
-<tr class='editUser'>
- <th><span class='translate'>Username</span>:</th>
- <td><span id='vboxEditUserUsername'></span></td>
-</tr>
-
-<tr class='addUser editUser'>
- <th><span class='translate'>Admin User</span>:</th>
- <td><label><input type='checkbox' name='admin' class='vboxCheckbox' /> <span class='translate'>Can administer users</span></label></td>
-</tr>
-<tr class='changePassword'>
- <th><span class='translate'>Old Password</span>:</th>
- <td><input type='password' name='opass' class='vboxText' /></td>
-</tr>
-<tr class='editUser'>
- <td colspan='2' style='text-align: center; border-top: 1px solid #000'><span style='font-weight: bold' class='translate'>Change Password</span></td>
-</tr>
-<tr class='changePassword addUser editUser'>
- <th><span class='translate'>New Password</span>:</th>
- <td><input type='password' name='npass1' class='vboxText' /></td>
-</tr>
-<tr class='changePassword addUser editUser'>
- <th><span class='translate'>Retype</span>:</th>
- <td><input type='password' name='npass2' class='vboxText' /></td>
-</tr>
-<tr id='vboxUserBtnRow' style='display:none;padding:0px;margin:0px;border:0px'>
- <th style='padding:0px;margin:0px;border:0px'></th>
- <td style='padding:0px;margin:0px;border:0px'><input type='submit' value='' style='border:0px;margin:0px;display:inline;background:#fff;text:#fff;padding:0px;height:1px;' /></td>
-</tr>
-
-</table>
-</form>
-</div>
-<script type='text/javascript'>
-
-$('#vboxUserEdit').find(".translate").html(function(i,h){return trans(h,'UIUsers');}).removeClass('translate');
-
-$('#vboxUserEdit').on('setMode',function(e,mode) {
- $('#vboxUserEdit').find('table').first().find('tr:not(.'+mode+')').css('display','none');
-});
-
-if($.browser.msie || $.browser.webkit) $('#vboxUserBtnRow').css({'display':''});
-
-$('#vboxUserEdit form').on("submit",function(e) {
- $('#vboxUserEdit').parent().find('span:contains("'+trans('OK','QIMessageBox')+'")').trigger('click');
- e.stopPropagation();
- e.preventDefault();
- return false;
-});
-
-</script>
+<!--
+
+ User edit dialog
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: userEdit.html 595 2015-04-17 09:50:36Z imoore76 $
+-->
+<div id='vboxUserEdit'>
+<form>
+<table class='vboxVertical'>
+<tr class='addUser'>
+ <th><span class='translate'>Username</span>:</th>
+ <td><input type='text' name='username' class='vboxText' /></td>
+</tr>
+<tr class='editUser'>
+ <th><span class='translate'>Username</span>:</th>
+ <td><span id='vboxEditUserUsername'></span></td>
+</tr>
+
+<tr class='addUser editUser'>
+ <th><span class='translate'>Admin User</span>:</th>
+ <td><label><input type='checkbox' name='admin' class='vboxCheckbox' /> <span class='translate'>Can administer users</span></label></td>
+</tr>
+<tr class='changePassword'>
+ <th><span class='translate'>Old Password</span>:</th>
+ <td><input type='password' name='opass' class='vboxText' /></td>
+</tr>
+<tr class='editUser'>
+ <td colspan='2' style='text-align: center; border-top: 1px solid #000'><span style='font-weight: bold' class='translate'>Change Password</span></td>
+</tr>
+<tr class='changePassword addUser editUser'>
+ <th><span class='translate'>New Password</span>:</th>
+ <td><input type='password' name='npass1' class='vboxText' /></td>
+</tr>
+<tr class='changePassword addUser editUser'>
+ <th><span class='translate'>Retype</span>:</th>
+ <td><input type='password' name='npass2' class='vboxText' /></td>
+</tr>
+<tr id='vboxUserBtnRow' style='display:none;padding:0px;margin:0px;border:0px'>
+ <th style='padding:0px;margin:0px;border:0px'></th>
+ <td style='padding:0px;margin:0px;border:0px'><input type='submit' value='' style='border:0px;margin:0px;display:inline;background:#fff;text:#fff;padding:0px;height:1px;' /></td>
+</tr>
+
+</table>
+</form>
+</div>
+<script type='text/javascript'>
+
+$('#vboxUserEdit').find(".translate").html(function(i,h){return trans(h,'UIUsers');}).removeClass('translate');
+
+$('#vboxUserEdit').on('setMode',function(e,mode) {
+ $('#vboxUserEdit').find('table').first().find('tr:not(.'+mode+')').css('display','none');
+});
+
+if($.browser.msie || $.browser.webkit) $('#vboxUserBtnRow').css({'display':''});
+
+$('#vboxUserEdit form').on("submit",function(e) {
+ $('#vboxUserEdit').parent().find('span:contains("'+trans('OK','QIMessageBox')+'")').trigger('click');
+ e.stopPropagation();
+ e.preventDefault();
+ return false;
+});
+
+</script>
diff --git a/panes/vmlogs.html b/panes/vmlogs.html
index e4c7f7b..d575717 100644
--- a/panes/vmlogs.html
+++ b/panes/vmlogs.html
@@ -1,105 +1,105 @@
-<!--
-
- VM Log dialog
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: vmlogs.html 595 2015-04-17 09:50:36Z imoore76 $
--->
-<table id='vboxVMLogContainer' class='vboxInvisible' style='width:100%;height:100%'>
- <tr style='vertical-align:bottom'>
- <td style='height: 1%;' id='vboxVMLogsTabsList'></td>
- </tr>
- <tr id='vboxVMLogsTabsRow' style='vertical-align:top'>
- <td id='vboxVMLogTabsContainer'></td>
- </tr>
-</table>
-<script type='text/javascript'>
-
-function vboxShowLogsInit(vm) {
-
- $('#vboxVMLogsTabsList').empty();
- $('#vboxVMLogTabsContainer').empty();
-
- $('<div />').attr({'id':'vboxVMLogTabs','style':'margin: 0px; padding: 0px;'}).appendTo($('#vboxVMLogTabsContainer'));
-
- var logs = $('#vboxVMLogsDialog').data('logs');
-
- if(!logs || !logs.length) {
- $('#vboxVMLogTabs').html(trans('<p>No log files found. Press the <b>Refresh</b> button to rescan the log folder <nobr><b>%1</b></nobr>.</p>','UIVMLogViewer').replace('%1',$('#vboxVMLogsDialog').data('logpath')));
- return;
- }
-
- // Pattern for regexp replacement
- var preg = new RegExp('.*'+$('#vboxPane').data('vboxConfig').DSEP.replace('\\','\\\\'));
-
- var ul = $('<ul />').attr({'id':'vboxVMLogsUL'});
- for(var i = 0; i < logs.length; i++) {
-
- // Replace path with just file name
- logs[i] = logs[i].replace(preg,'');
-
- // Tab link
- $('<li />').html('<a href="#vboxVMLog'+i+'"><span>'+logs[i]+'</span></a>').appendTo(ul);
-
- // Tab content
- $('<div />').css({'padding':'4px','margin':'0px'}).attr({'id':'vboxVMLog'+i,'class':'vboxVMLog vboxDialogContent'}).data('logIndex',i).one('show',function(){
-
- $(this).html('<img src="images/spinner.gif" />');
-
- $.when({'logIndex':$(this).data('logIndex')}, vboxAjaxRequest('machineGetLogFile',{'vm':vm.id,'log':$(this).data('logIndex')})).done(function(x,d){
-
- // -8 for padding set above + parent's padding
- var pHeight = $('#vboxVMLogTabs').innerHeight() - 10;
-
- var frm = $('<form />');
- $(frm).height(pHeight);
- $('<textarea />').attr({'id':'vboxLogText'+x.logIndex,'spellcheck':'false','wrap':'off','readonly':'true'}).height(pHeight).val(d.responseData).appendTo(frm);
- $('#vboxVMLog'+x.logIndex).html('').append(frm);
- $('#vboxLogText'+x.logIndex).attr('scrollTop',$('#vboxLogText'+x.logIndex).attr('scrollHeight'));
-
- });
-
-
-
- }).appendTo($('#vboxVMLogTabs'));
-
-
- }
- $('#vboxVMLogTabs').prepend(ul);
-
- $('#vboxVMLogTabs').tabs({'activate':function(e,i){
- $('#vboxVMLogTabs').children('div:eq('+$('#vboxVMLogTabs').tabs('option','active')+')').trigger('show');
- }});
-
- // Move tabs to table
- $('#vboxVMLogsUL').css({'border-bottom':'0px','margin-bottom':'0px','padding-bottom':'0px'}).detach().appendTo($('#vboxVMLogsTabsList').addClass($('#vboxVMLogTabs').css({'border-top':'0px','margin-top':'0px','padding-top':'0px'}).removeClass('ui-corner-all').attr('class')));
-
- // Set height
- $('#vboxVMLogTabs').css({'display':'none'});
-
- // -6 to account for padding and leave a small buffer
- $('#vboxVMLogTabs').css({'padding':'0px 2px 2px 2px','margin':'0px','display':''}).height($('#vboxVMLogTabsContainer').css({'padding':'0px','margin':'0px'}).innerHeight()-6);
-
- // Resize dialog resizes these elemtns
- $('#vboxVMLogContainer').parent().on("dialogresizestop",function(e){
-
- // Set height
- $('#vboxVMLogTabs').css({'display':'none'});
-
- var pHeight = $('#vboxVMLogTabsContainer').innerHeight();
-
- // -4 to account for padding
- // -12 to account for vboxVMLogTabs 2px padding and pane's 4px padding (8 + 4)
- $('#vboxVMLogTabs').css({'display':''}).height(pHeight-4).find('form').height(pHeight-12).find('textarea').height(pHeight-12);
-
-
-
- });
-
- $('#vboxVMLogTabs').children('div:eq(0)').trigger('show');
-
-
-
-
-}
-</script>
+<!--
+
+ VM Log dialog
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: vmlogs.html 595 2015-04-17 09:50:36Z imoore76 $
+-->
+<table id='vboxVMLogContainer' class='vboxInvisible' style='width:100%;height:100%'>
+ <tr style='vertical-align:bottom'>
+ <td style='height: 1%;' id='vboxVMLogsTabsList'></td>
+ </tr>
+ <tr id='vboxVMLogsTabsRow' style='vertical-align:top'>
+ <td id='vboxVMLogTabsContainer'></td>
+ </tr>
+</table>
+<script type='text/javascript'>
+
+function vboxShowLogsInit(vm) {
+
+ $('#vboxVMLogsTabsList').empty();
+ $('#vboxVMLogTabsContainer').empty();
+
+ $('<div />').attr({'id':'vboxVMLogTabs','style':'margin: 0px; padding: 0px;'}).appendTo($('#vboxVMLogTabsContainer'));
+
+ var logs = $('#vboxVMLogsDialog').data('logs');
+
+ if(!logs || !logs.length) {
+ $('#vboxVMLogTabs').html(trans('<p>No log files found. Press the <b>Refresh</b> button to rescan the log folder <nobr><b>%1</b></nobr>.</p>','UIVMLogViewer').replace('%1',$('#vboxVMLogsDialog').data('logpath')));
+ return;
+ }
+
+ // Pattern for regexp replacement
+ var preg = new RegExp('.*'+$('#vboxPane').data('vboxConfig').DSEP.replace('\\','\\\\'));
+
+ var ul = $('<ul />').attr({'id':'vboxVMLogsUL'});
+ for(var i = 0; i < logs.length; i++) {
+
+ // Replace path with just file name
+ logs[i] = logs[i].replace(preg,'');
+
+ // Tab link
+ $('<li />').html('<a href="#vboxVMLog'+i+'"><span>'+logs[i]+'</span></a>').appendTo(ul);
+
+ // Tab content
+ $('<div />').css({'padding':'4px','margin':'0px'}).attr({'id':'vboxVMLog'+i,'class':'vboxVMLog vboxDialogContent'}).data('logIndex',i).one('show',function(){
+
+ $(this).html('<img src="images/spinner.gif" />');
+
+ $.when({'logIndex':$(this).data('logIndex')}, vboxAjaxRequest('machineGetLogFile',{'vm':vm.id,'log':$(this).data('logIndex')})).done(function(x,d){
+
+ // -8 for padding set above + parent's padding
+ var pHeight = $('#vboxVMLogTabs').innerHeight() - 10;
+
+ var frm = $('<form />');
+ $(frm).height(pHeight);
+ $('<textarea />').attr({'id':'vboxLogText'+x.logIndex,'spellcheck':'false','wrap':'off','readonly':'true'}).height(pHeight).val(d.responseData).appendTo(frm);
+ $('#vboxVMLog'+x.logIndex).html('').append(frm);
+ $('#vboxLogText'+x.logIndex).attr('scrollTop',$('#vboxLogText'+x.logIndex).attr('scrollHeight'));
+
+ });
+
+
+
+ }).appendTo($('#vboxVMLogTabs'));
+
+
+ }
+ $('#vboxVMLogTabs').prepend(ul);
+
+ $('#vboxVMLogTabs').tabs({'activate':function(e,i){
+ $('#vboxVMLogTabs').children('div:eq('+$('#vboxVMLogTabs').tabs('option','active')+')').trigger('show');
+ }});
+
+ // Move tabs to table
+ $('#vboxVMLogsUL').css({'border-bottom':'0px','margin-bottom':'0px','padding-bottom':'0px'}).detach().appendTo($('#vboxVMLogsTabsList').addClass($('#vboxVMLogTabs').css({'border-top':'0px','margin-top':'0px','padding-top':'0px'}).removeClass('ui-corner-all').attr('class')));
+
+ // Set height
+ $('#vboxVMLogTabs').css({'display':'none'});
+
+ // -6 to account for padding and leave a small buffer
+ $('#vboxVMLogTabs').css({'padding':'0px 2px 2px 2px','margin':'0px','display':''}).height($('#vboxVMLogTabsContainer').css({'padding':'0px','margin':'0px'}).innerHeight()-6);
+
+ // Resize dialog resizes these elemtns
+ $('#vboxVMLogContainer').parent().on("dialogresizestop",function(e){
+
+ // Set height
+ $('#vboxVMLogTabs').css({'display':'none'});
+
+ var pHeight = $('#vboxVMLogTabsContainer').innerHeight();
+
+ // -4 to account for padding
+ // -12 to account for vboxVMLogTabs 2px padding and pane's 4px padding (8 + 4)
+ $('#vboxVMLogTabs').css({'display':''}).height(pHeight-4).find('form').height(pHeight-12).find('textarea').height(pHeight-12);
+
+
+
+ });
+
+ $('#vboxVMLogTabs').children('div:eq(0)').trigger('show');
+
+
+
+
+}
+</script>
diff --git a/panes/vmm.html b/panes/vmm.html
index f3c2043..0c7f135 100644
--- a/panes/vmm.html
+++ b/panes/vmm.html
@@ -1,1132 +1,1132 @@
-<!--
-
- Virtual Media Manager
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: vmm.html 595 2015-04-17 09:50:36Z imoore76 $
-
- -->
-<table id='vboxVirtualMediaManager' style='height: 100%; border:0px;margin:0px;padding:0px;width:100%;border-spacing:0px;border-width:0px;'>
-
- <!-- Top menu -->
- <tr><td style='height:1%;padding:0px;margin:0px;border:0px;'><div id='vboxMMMenu' style='margin:0px;'></div></td></tr>
-
- <!-- Toolbar Created by JavaScript below -->
- <tr><td style='height:1%;padding:0px;margin:0px;border:0px;'><div id='vboxMMToolbar' style='padding:0px; margin:0px;' class='vboxToolbarGrad'></div></td></tr>
-
- <!-- Tab Placeholder -->
- <tr style='vertical-align: top;'><td id='vboxVMMContainerTopCell' style='height:1%;padding:0px;margin:0px;border:0px;'><div id='vboxVMMContainerTop' style='border:0px;margin-bottom:0px;padding-bottom:0px;'></div></td></tr>
-
- <!-- Tabs for Media -->
- <tr style='vertical-align: top;'>
- <td style='padding:0px;margin:0px;border:0px;' id='vboxVMMContainer'>
-
- <div id='vboxVMMTabs'>
-
- <ul id='vboxVMMTabList'>
- <li><a href="#vmmDisks"><span><img id='vmmDisksIcon' style="height:16px;width:16px;vertical-align: middle" src="images/vbox/hd_16px.png" border="0" /> <span class='translate'>Hard disks</span></span></a></li>
- <li><a href="#vmmCDs"><span><img id='vmmCDsIcon' style="height:16px;width:16px;vertical-align: middle" src="images/vbox/cd_16px.png" border="0" /> <span class='translate'>Optical disks</span></span></a></li>
- <li><a href="#vmmFloppys"><span><img id='vmmFloppysIcon' style="height:16px;width:16px;vertical-align: middle" src="images/vbox/fd_16px.png" border="0" /> <span class='translate'>Floppy disks</span></span></a></li>
- </ul>
-
- <!--
-
- HARD DISKS
-
- -->
- <div id='vmmDisks'>
- <div class='vboxBordered vboxVMMList'>
- <div class='vmmTableHead'>
- <table style='border-spacing: 0px; border: 0px; width:100%;' class='vboxHorizontal vboxListTable vboxVMMList'>
- <thead>
- <tr>
- <th style='width: 100%;'><span class='translate'>Name</span></th>
- <th style='width: auto'><span class='translate'>Virtual Size</span></th>
- <th style='width: auto'><span class='translate'>Actual Size</span></th>
- <th style='width: auto;padding:0px;margin:0px;'><img src="images/vbox/blank.gif" style="height:1px;width:1px" /></th>
- </tr>
- </thead>
- </table>
- </div>
- <div class='vmmTableBody'>
- <table class='vboxHorizontal vboxListTable vboxVMMList' tabindex='1'>
- <tbody id='vboxVMMHDList' class='vboxHover'>
- <tr>
- <td>Item 1</td>
- <td>Item 2</td>
- <td>Item 3</td>
- </tr>
- <tr>
- <td>Item 1</td>
- <td>Item 2</td>
- <td>Item 3</td>
- </tr>
- </tbody>
- </table>
- </div>
- </div>
- <div class='vboxVMMMediumInfo'>
- <table>
- <tr>
- <th><span class='translate'>Type:</span></th>
- <td><input id='vmmMediumType' type='text' style='width:100%;border:0px solid transparent;background:transparent;' value='' readonly spellcheck='false' /></td>
- </tr>
- <tr>
- <th><span class='translate'>Location:</span></th>
- <td><input class='vmmMediumLocation' type='text' style='width:100%;border:0px solid transparent;background:transparent;' value='' readonly spellcheck='false' /></td>
- </tr>
- <tr>
- <th><span class='translate'>Format:</span></th>
- <td><input class='vmmMediumFormat' type='text' style='width:100%;border:0px solid transparent;background:transparent;' value='' readonly spellcheck='false'/></td>
- </tr>
- <tr>
- <th><span class='translate'>Storage details:</span></th>
- <td><input class='vmmMediumHDDetails' type='text' style='width:100%;border:0px solid transparent;background:transparent;' value='' readonly spellcheck='false'/></td>
- </tr>
- <tr>
- <th><span class='translate'>Attached to:</span></th>
- <td><input class='vmmMediumAttachedTo' type='text' style='width:100%;border:0px solid transparent;background:transparent;' value='' readonly spellcheck='false'/></td>
- </tr>
- <tr>
- <th><span class='translate'>UUID:</span></th>
- <td><input class='vmmMediumUUID' type='text' style='width:100%;border:0px solid transparent;background:transparent;' value='' readonly spellcheck='false'/></td>
- </tr>
- <tr class='vmmAccessErr'>
- <td colspan='2'></td>
- </tr>
- </table>
- </div>
- </div>
-
-
-
- <!--
-
- CD / DVD IMAGES
-
- -->
- <div id='vmmCDs'>
- <div class='vboxVMMList vboxBordered'>
- <div class='vmmTableHead'>
- <table style='width: 100%; border-spacing: 0px; border: 0px;' class='vboxHorizontal vboxListTable vboxVMMList'>
- <thead>
- <tr>
- <th style='width: 100%'><span class='translate'>Name</span></th>
- <th style='width: auto'><span class='translate'>Size</span></th>
- <th style='width: auto;padding:0px;margin:0px;'><img src="images/vbox/blank.gif" style="height:1px;width:1px" /></th>
- </tr>
- </thead>
- </table>
- </div>
- <div class='vmmTableBody'>
- <table style='width: 100%; border-spacing: 0px; border: 0px;' class='vboxHorizontal vboxListTable vboxVMMList' tabindex='1'>
- <tbody id='vboxVMMCDList' class='vboxHover'>
- <tr>
- <td>Item 1</td>
- <td>Item 3</td>
- </tr>
- <tr>
- <td>Item 1</td>
- <td>Item 3</td>
- </tr>
- </tbody>
- </table>
- </div>
- </div>
- <div class='vboxVMMMediumInfo'>
- <table>
- <tr>
- <th><span class='translate'>Location:</span></th>
- <td><input class='vmmMediumLocation' type='text' style='width:100%;border:0px solid transparent;background:transparent;' value='' readonly spellcheck='false' /></td>
- </tr>
- <tr>
- <th><span class='translate'>Attached to:</span></th>
- <td><input class='vmmMediumAttachedTo' type='text' style='width:100%;border:0px solid transparent;background:transparent;' value='' readonly spellcheck='false'/></td>
- </tr>
- <tr>
- <th><span class='translate'>UUID:</span></th>
- <td><input class='vmmMediumUUID' type='text' style='width:100%;border:0px solid transparent;background:transparent;' value='' readonly spellcheck='false'/></td>
- </tr>
- <tr class='vmmAccessErr'>
- <td colspan='2'></td>
- </tr>
- </table>
- </div>
- </div>
-
-
-
-
- <!--
-
- FLOPPY IMAGES
-
- -->
- <div id='vmmFloppys'>
- <div class='vboxVMMList vboxBordered'>
- <div class='vmmTableHead'>
- <table style='width: 100%; border-spacing: 0px; border: 0px;' class='vboxHorizontal vboxListTable vboxVMMList'>
- <thead>
- <tr>
- <th style='width: 100%'><span class='translate'>Name</span></th>
- <th style='width: auto'><span class='translate'>Size</span></th>
- <th style='width: auto;padding:0px;margin:0px;'><img src="images/vbox/blank.gif" style="height:1px;width:1px" /></th>
- </tr>
- </thead>
- </table>
- </div>
- <div class='vmmTableBody'>
- <table style='width: 100%; border-spacing: 0px; border: 0px;' class='vboxHorizontal vboxListTable vboxVMMList' tabindex='1'>
- <tbody id='vboxVMMFDList' class='vboxHover'>
- <tr>
- <td>Item 1</td>
- <td>Item 2</td>
- </tr>
- </tbody>
- </table>
- </div>
- </div>
- <div class='vboxVMMMediumInfo'>
- <table>
- <tr>
- <th><span class='translate'>Location:</span></th>
- <td><input class='vmmMediumLocation' type='text' style='width:100%;border:0px solid transparent;background:transparent;' value='' readonly spellcheck='false'/></td>
- </tr>
- <tr>
- <th><span class='translate'>Attached to:</span></th>
- <td><input class='vmmMediumAttachedTo' type='text' style='width:100%;border:0px solid transparent;background:transparent;' value='' readonly spellcheck='false'/></td>
- </tr>
- <tr>
- <th><span class='translate'>UUID:</span></th>
- <td><input class='vmmMediumUUID' type='text' style='width:100%;border:0px solid transparent;background:transparent;' value='' readonly spellcheck='false'/></td>
- </tr>
- <tr class='vmmAccessErr'>
- <td colspan='2'></td>
- </tr>
- </table>
- </div>
- </div>
- </div></td>
- </tr>
-</table>
-<script type='text/javascript'>
-
-/*
- * Translate
- */
-
-// These are translated under a different context for some reason
-$('#vboxVMMTabList').find(".translate").html(function(i,h){return trans(h,'UIMediumManager');}).removeClass('translate');
-
-$("#vboxVMMTabs").find(".translate").html(function(i,h){return trans(h,'VBoxMediaManagerDlg');}).removeClass('translate');
-
-/*
- * Keypress events
- */
-$('div.vmmTableBody table').click(function(){$(this).focus();}).keydown(function(e){
-
- var keynum = 0;
-
- if(e.keyCode)
- keynum = e.keyCode;
- else if(e.which)
- keynum = e.which;
-
- switch(keynum) {
-
- // up
- case 38:
- $(this).find('tr.vboxListItemSelected').prevAll('tr:not([class~="vboxHidden"]):first').children().first().click();
- break;
-
- // right / expand
- case 39:
- $(this).find('tr.vboxListItemSelected.collapsed').find('input').click();
- break;
-
- // left / contract
- case 37:
- $(this).find('tr.vboxListItemSelected:not(.collapsed)').find('input').click();
- break;
-
- // down
- case 40:
- $(this).find('tr.vboxListItemSelected').nextAll('tr:not([class~="vboxHidden"]):first').children().first().click();
- break;
-
- }
-
- return false;
-
-}).css('outline','none');
-
-/*
- * Setup Tabs
- */
-$("#vboxVMMTabs").tabs().on("tabsactivate",function(ev,ui){
-
- // Resize table
- vboxVMMSizeTable(ui.newPanel);
-
- // Medium selection
- if(!$(ui.newPanel).find('tbody').children('tr.vboxListItemSelected').first().children().first().click().length) {
- $('#vboxVirtualMediaManager').trigger('mediumselect',[null]);
- }
-});
-
-/*
- * Toolbar Buttons
- */
-var vmmButtons = new Array(
-
- {
- /*
- * Create new HardDisk
- */
- 'name' : 'vmmnew',
- 'label' : 'New',
- 'icon' : 'hd_new',
- 'enabled' : function (item) { return(!$("#vboxVMMTabs").tabs('option','active')); },
- 'click' : function () {
- $.when(new vboxWizardNewHDDialog({'path':$('#vboxVirtualMediaManager').data('vmPath')}).run()).done(function(id){
- vboxVMMFillMedia(id);
- });
- }
- },
-
- {
- /*
- * Add existing medium to virtualbox
- */
- 'name' : 'vmmadd',
- 'label' : 'Add',
- 'icon' : 'hd_add',
- 'click' : function () {
- var type = '';
- switch($("#vboxVMMTabs").tabs('option','active')) {
- case 1: type = 'DVD'; break;
- case 2: type = 'Floppy'; break;
- default: type = 'HardDisk'; break;
- }
-
- vboxMedia.actions.choose(null,type,function(ret){
- vboxVMMFillMedia((ret && ret.id ? ret.id : null));
- });
-
- }
- },
- {
- /*
- * Add iSCSI medium to virtualbox
- */
- 'name' : 'vmmaddiscsi',
- 'label' : 'Add iSCSI',
- 'icon' : 'hd_add',
- 'enabled' : function (item) { return(!$("#vboxVMMTabs").tabs('option','active')); },
- 'click' : function () {
-
-
- var d = $('<div />').attr({'id':'vboxVMMAddMediumImageDialog'});
-
- var buttons = {};
- buttons[trans('OK','QIMessageBox')] = function() {
-
- var frm = document.forms.vboxISCSIForm;
- var server = $(frm.vboxISCSIServer).val();
- var port = $(frm.vboxISCSIPort).val();
- var intnet = frm.vboxISCSIIntnet.checked;
- var target = $(frm.vboxISCSITarget).val();
- var lun = $(frm.vboxISCSILun).val();
- var enclun = frm.vboxISCSILunEnc.checked;
- var user = $(frm.vboxISCSIUser).val();
- var pass = $(frm.vboxISCSIPass).val();
-
- if(server && target) {
- if(!lun) lun = '0';
- var l = new vboxLoader('addiscsi');
- l.add('mediumAddISCSI',function(ret){
- if(ret && ret.responseData && ret.responseData.id) {
- var nl = new vboxLoader('getMedia');
- nl.add('vboxGetMedia',function(dat){$('#vboxPane').data('vboxMedia',dat.responseData);});
- nl.onLoad = function() {
- vboxVMMFillMedia(ret.responseData.id);
- };
- nl.run();
- }
- },{'server':server,'port':port,'intnet':intnet,'target':target,'lun':lun,'enclun':enclun,'targetUser':user,'targetPass':pass});
- l.run();
- }
-
- $(this).empty().remove();
-
- };
- buttons[trans('Cancel','QIMessageBox')] = function() { $(this).empty().remove(); };
-
- var l = new vboxLoader();
- l.addFileToDOM("panes/vmmISCSI.html",$(d));
- l.onLoad = function() {
- $(d).dialog({'width':400,'height':350,'buttons':buttons,'modal':true,'autoOpen':true,'dialogClass':'vboxDialogContent','title':trans('Add iSCSI')});
- };
- l.run();
-
-
- }
- },
- {
- /*
- * Copy Medium
- */
- 'name' : 'vmmcopy',
- 'label' : 'Copy...',
- 'icon' : 'vdm_add',
- 'separator' : $('#vboxPane').data('vboxConfig').enableAdvancedConfig,
- 'enabled' : function (item) {
- if(!item) return false;
- if($("#vboxVMMTabs").tabs('option','active')) return false;
- if(!$(item).data('medium')) return false;
- var m = vboxMedia.getMediumById($(item).data('medium'));
- return (!m || !m.parent);
-
- },
- 'click' : function () {
- var elm = null;
- switch($("#vboxVMMTabs").tabs('option','active')) {
- case 1:
- elm = $('#vboxVMMCDList');
- break;
- case 2:
- elm = $('#vboxVMMFDList');
- break;
- default:
- elm = $('#vboxVMMHDList');
- break;
- }
- $.when(new vboxWizardCopyHDDialog({'medium':$(elm).find('tr.vboxListItemSelected').first().data('medium')}).run()).done(function(id){
- vboxVMMFillMedia(id);
- });
- }
- },
- {
- /*
- * Modify Medium
- */
- 'name' : 'vmmmodify',
- 'label' : 'Modify...',
- 'icon' : 'vdm_new',
- 'enabled' : function (item) {
- if(!item) return false;
- if($("#vboxVMMTabs").tabs('option','active')) return false;
- var m = vboxMedia.getMediumById($(item).data('medium'));
- return (m && !m.parent);
-
- },
- 'click' : function () {
-
- var d = $('<div />').attr({'id':'vboxVMMModifyDialog'});
-
- var med = $('#vboxVMMHDList').find('tr.vboxListItemSelected').first();
- med = vboxMedia.getMediumById(med.data('medium'));
-
- var buttons = {};
- buttons[trans('OK','QIMessageBox')] = function() {
-
- var mtype = document.forms.vboxVMMModifyForm.vmmMType;
- for(var i = 0; i < mtype.length; i++) {
- if(mtype[i].checked) {
- mtype = mtype[i].value;
- break;
- }
- }
-
- $.when(vboxAjaxRequest('mediumSetType',{'medium':med.location,'type':mtype})).done(function(ret){
-
- if(ret && ret.success) {
- var l = new vboxLoader();
- l.add('vboxGetMedia',function(data){$('#vboxPane').data('vboxMedia',data.responseData);});
- l.onLoad = function() {
- if($('#vboxVirtualMediaManager').data('hideDiff')) {
- var d = vboxMedia.getMediumById(med.id);
- if(d.readOnly) $('#vboxVMMMediaTitle-'+d.id).addClass('vboxMediumReadOnly');
- else $('#vboxVMMMediaTitle-'+d.id).removeClass('vboxMediumReadOnly');
- }
- $('#vmmMediumType').val(trans(mtype,'VBoxGlobal'));
- };
- l.run();
- $('#vboxVMMModifyDialog').empty().remove();
- }
- });
-
- };
- buttons[trans('Cancel','QIMessageBox')] = function() { $(this).empty().remove(); };
-
- var l = new vboxLoader();
- l.addFileToDOM("panes/vmmModify.html",$(d));
- l.onLoad = function() {
-
- var msg = trans('<p>You are about to change the settings of the disk image file <b>%1</b>.</p><p>Please choose one of the following modes and press <b>%2</b> to proceed or <b>%3</b> otherwise.</p>','UIMediumTypeChangeDialog');
- var title = trans('Modify medium attributes','UIMediumTypeChangeDialog');
-
- msg = msg.replace('%1',med.location).replace('%2',trans('OK','QIMessageBox')).replace('%3',trans('Cancel','QIMessageBox'));
-
- $(d).dialog({'width':400,'height':370,'buttons':buttons,'modal':true,'autoOpen':true,'dialogClass':'vboxDialogContent','title':'<img src="images/vbox/diskimage_16px.png" /> '+title});
-
- // Translations
- $('#vboxVMMModifyInstructions').html(msg);
-
- $('#vboxVMMModify').find(".translate").html(function(i,h){return trans(h,'UIMediumTypeChangeDialog');}).removeClass('translate');
-
- $('#vboxVMMModify').find('table.vboxOptions').find('span').html(function(i,h){return trans(h,'VBoxGlobal', 'MediumType');});
-
- // Set correct option
- $('#vboxVMMModify').find('input').prop('checked',false);
- $('#vboxVMMModify').find('input[value='+med.type+']').prop('checked',true);
-
-
- };
- l.run();
-
- }
- },
-
- {
- /*
- * Remove a medium
- */
- 'name' : 'vmmremove',
- 'label' : 'Remove',
- 'icon' : 'hd_remove',
- 'enabled' : function (item) {
- if(!item || item.target) return false;
- var m = vboxMedia.getMediumById($(item).data('medium'));
- return (m && m.attachedTo.length == 0 && m.children.length == 0);
- },
- 'click' : function () {
- var mtype = null;
- var elm = null;
- switch($("#vboxVMMTabs").tabs('option','active')) {
- case 1:
- elm = $('#vboxVMMCDList');
- mtype = 'CD/DVD image';
- break;
- case 2:
- elm = $('#vboxVMMFDList');
- mtype = 'floppy image';
- break;
- default:
- elm = $('#vboxVMMHDList');
- mtype = 'hard disk';
- break;
- }
- var m = vboxMedia.getMediumById($(elm).find('tr.vboxListItemSelected').first().data('medium'));
-
- var buttons = {};
- var q = '';
-
- // If we are removing a hard disk and configured to allow deletions
- if(m.deviceType == 'HardDisk' && $('#vboxPane').data('vboxConfig').deleteOnRemove && m.format != 'iSCSI') {
-
-
- q = trans('<p>Do you want to delete the storage unit of the virtual hard disk <nobr><b>%1</b></nobr>?'+
- '</p><p>If you select <b>Delete</b> then the specified storage unit will be permanently deleted. '+
- 'This operation <b>cannot be undone</b>.</p><p>If you select <b>Keep</b> then the hard disk will '+
- 'be only removed from the list of known hard disks, but the storage unit will be left untouched '+
- 'which makes it possible to add this hard disk to the list later again.</p>','UIMessageCenter').replace('%1',m.location);
-
- buttons[trans('Delete','UIMessageCenter')] = function(){
- $.when(vboxAjaxRequest('mediumRemove',{'medium':m.location,'type':m.deviceType,'delete':1})).done(function(ret){
- if(ret && ret.responseData && ret.responseData.progress) {
- vboxProgress(ret.responseData,function(){
- var l = new vboxLoader();
- l.add('vboxGetMedia',function(d){$('#vboxPane').data('vboxMedia',d.responseData);});
- l.onLoad = function() {vboxVMMFillMedia(); };
- l.run();
- },'progress_media_delete_90px.png',trans('Delete','UIMessageCenter'),
- vboxBasename(m.location));
- }
- });
- $(this).empty().remove();
- };
-
- buttons[trans('Keep','UIMessageCenter')] = function(){
- $.when(vboxAjaxRequest('mediumRemove',{'medium':m.location,'type':m.deviceType})).done(function(ret){
- var l = new vboxLoader();
- l.add('vboxGetMedia',function(d){$('#vboxPane').data('vboxMedia',d.responseData);});
- l.onLoad = function() {vboxVMMFillMedia(); };
- l.run();
- });
- $(this).empty().remove();
- };
-
- } else {
-
- q = trans('<p>Are you sure you want to remove the %1 <nobr><b>%2</b></nobr> from the list of known media?</p>','UIMessageCenter').replace('%1',trans(mtype,'UIMessageCenter')).replace('%2',m.location);
- q+= trans('<p>Note that the storage unit of this medium will not be deleted and that it will be possible to use it later again.</p>','UIMessageCenter');
-
- buttons[trans('Remove','UIMessageCenter')] = function(){
- var b = this;
- $.when(vboxAjaxRequest('mediumRemove',{'medium':m.location,'type':m.deviceType})).done(function(ret){
- var l = new vboxLoader();
- l.add('vboxGetMedia',function(d){$('#vboxPane').data('vboxMedia',d.responseData);});
- l.onLoad = function() {vboxVMMFillMedia(); };
- $(b).empty().remove();
- l.run();
- });
- };
-
- }
- vboxConfirm(q,buttons);
- }
- },
-
- {
- /*
- * Release a medium from all attachments
- */
- 'name' : 'vmmrelease',
- 'label' : 'Release',
- 'icon' : 'hd_release',
- 'enabled' : function (item) {
- if(!item || item.target) return false;
- var m = vboxMedia.getMediumById($(item).data('medium'));
- return (m && m.attachedTo.length > 0 && m.children.length == 0 && m.hasSnapshots == 0);
- },
- 'click' : function () {
- var elm = null;
- var mtype = null;
- switch($("#vboxVMMTabs").tabs('option','active')) {
- case 1:
- elm = $('#vboxVMMCDList');
- mtype = 'CD/DVD image';
- break;
- case 2:
- elm = $('#vboxVMMFDList');
- mtype = 'floppy image';
- break;
- default:
- elm = $('#vboxVMMHDList');
- mtype = 'hard disk';
- break;
- }
-
-
- var m = vboxMedia.getMediumById($(elm).find('tr.vboxListItemSelected').first().data('medium'));
- var q = trans('<p>Are you sure you want to release the disk image file <nobr><b>%1</b></nobr>?</p><p>This will detach it from the following virtual machine(s): <b>%2</b>.</p>','UIMessageCenter');
- q = q.replace('%1',m.location);
-
- var buttons = {};
- buttons[trans('Release','UIMessageCenter')] = function(){
- var b = this;
- $.when(vboxAjaxRequest('mediumRelease',{'medium':m.location,'type':m.deviceType})).done(function(ret){
-
- var l = new vboxLoader();
- l.add('vboxGetMedia',function(d){$('#vboxPane').data('vboxMedia',d.responseData);});
- l.onLoad = function(){
- vboxVMMFillMedia(m.id);
- };
- $(b).empty().remove();
- l.run();
- });
- };
-
- if(m.attachedTo.length) {
- var machines = new Array();
- for(var i = 0; i < m.attachedTo.length; i++) {
- machines[machines.length] = m.attachedTo[i].machine;
- }
- q = q.replace('%2','<b>'+machines.join('</b>, <b>') + '</b>');
- };
-
-
- vboxConfirm(q,buttons);
- }
- },
-
- {
- 'name' : 'vmmrefresh',
- 'label' : 'Refresh',
- 'icon' : 'refresh',
- 'click' : function () {
-
- // Force a refresh of media
- var l = new vboxLoader();
- l.add('vboxGetMedia',function(d){$('#vboxPane').data('vboxMedia',d.responseData);});
- l.onLoad = function() {vboxVMMFillMedia(); };
- l.run();
-
- }
- }
-
-
-);
-
-// Check for advanced config
-if(!$('#vboxPane').data('vboxConfig').enableAdvancedConfig) {
- vmmButtons.shift();
- vmmButtons.shift();
- vmmButtons.shift();
-}
-
-/* Toolbar */
-var vmmToolbar = new vboxToolbar({buttons: vmmButtons,
- language_context: 'VBoxMediaManagerDlg',
- renderTo: 'vboxMMToolbar'});
-
-/* Actions Menu */
-var vmmMenu = new vboxMenuBar({name: 'vboxMMMenu', language_context: 'VBoxMediaManagerDlg'});
-vmmMenu.addMenu({
- 'name':'vboxMMactions',
- 'label':'Actions',
- 'menu': vmmButtons
-});
-vmmMenu.renderTo('vboxMMMenu');
-
-/* Context menu for media */
-var vmmCMButtons;
-
-// Check for advanced config. We don't want these in our context menu
-if($('#vboxPane').data('vboxConfig').enableAdvancedConfig) {
- vmmCMButtons = vmmButtons.slice(3,-1);
-} else {
- vmmCMButtons = vmmButtons.slice(0,-1);
-}
-var vmmCMenu = new vboxMenu({name: 'vboxVMMMediaContextMenu', menuItems: vmmCMButtons,
- language_context: 'VBoxMediaManagerDlg'});
-
-
-/**
- * Displays medium info
- * @param {HTMLElement} med selected medium row
- */
-function vboxVMMMediaInfo(med) {
-
- var m = (med ? vboxMedia.getMediumById($(med).data('medium')) : null);
-
- $('#vboxVirtualMediaManager').find('.vmmMediumLocation').val((m && m.location ? m.location : '--'));
- $('#vboxVirtualMediaManager').find('.vmmMediumFormat').val(m ? m.format.toUpperCase() : '--');
- $('#vboxVirtualMediaManager').find('.vmmMediumHDDetails').val(m ? vboxMedia.getHardDiskVariant(m) : '--');
- $('#vmmMediumType').val(m ? trans(m.type,'VBoxGlobal') : '--');
-
- if(m && m.parent) {
- $('#vmmMediumType').val(trans('Differencing','VBoxGlobal'));
- }
-
- // Attached To val
- var attch = null;
- var attchElm = $('#vboxVirtualMediaManager').find('.vmmMediumAttachedTo');
- attchElm.css({'font-style':''});
- if(m) {
- attch = vboxMedia.attachedTo(m,true);
- if(!attch) {
- attch = trans('Not Attached','UIGDetails','details (storage)');
- attchElm.css({'font-style':'italic'});
- }
- attchElm.val(attch);
- } else {
- attchElm.val('--');
- }
-
- // UUID
- $('#vboxVirtualMediaManager').find('.vmmMediumUUID').val(m ? m.id : '--');
-
- if(m && m.state == 'Inaccessible' && m.lastAccessError) {
- $('#vboxVirtualMediaManager').find('tr.vmmAccessErr').css({'display':''}).children().html(m.lastAccessError);
- } else {
- $('#vboxVirtualMediaManager').find('tr.vmmAccessErr').css({'display':'none'}).children().html('');
- }
-}
-
-// Update items on mediumselect
-$('#vboxVirtualMediaManager').on('mediumselect',function(e,m){
- vmmToolbar.update(m);
- vboxVMMMediaInfo(m);
- vmmMenu.update(m);
- vmmCMenu.update(m);
-});
-
-/*
- * Add medium to a table
- */
-function vboxVMMAddMedium(d,depth,hideDiff,topLevelParent) {
-
- var tr = $('<tr />').data({'medium':d.id,'mediumname':d.name,'mediumsize':d.size,'mediumlogicalSize':d.logicalSize})
- .attr({'id':'vboxVMMMedium'+(d.id),'class':'vboxListItem collapsed','title':d.id})
- .hover(function(){
- if(!$(this).hasClass('vboxListItemSelected'))
- $(this).addClass('vboxHover');
- },function(){
- $(this).removeClass('vboxHover');
- }
- )
- .addClass('vboxVMMTopLevel'+(topLevelParent ? topLevelParent : '0')+' vboxVMMChildOf'+(d.parent ? d.parent : '0') +' vboxVMMChildDepth'+depth)
- .contextMenu({
- menu: vmmCMenu.menuId(),
- menusetup : function(el) {
- if(!$(el).hasClass('vboxListItemSelected')) $(el).children().first().trigger('click');
- }
- },vmmCMenu.menuClickCallback);
-
-
- if(d.children && d.children.length && !hideDiff) $(tr).addClass('vboxVMMParent');
- if(d.parent) $(tr).addClass('vboxHidden').attr('style','display: none');
-
- /* Expand / collapse button and/or spacers */
- var td = $('<td />').addClass('vboxHoverFirst');
-
- // Add spacer image to pad for depth
- if(depth) {
- for(var i = 0; i < depth; i++) {
- $('<img />').attr({'class':'vboxVMMSpacer','src':'images/vbox/blank.gif'}).appendTo(td);
- }
- }
-
- // Show / hide children button
- if(d.children && d.children.length && !hideDiff) {
-
- $('<input />').attr({'type':'button','class':'vboxImgButton vboxVMMMediaExpand','style':'background-image: url(images/vbox/arrow_right_10px.png)'}).click(function(){
-
- if(!$(this).data('toggleClicked')) {
-
- $(this).data('toggleClicked', true);
- $(this).css({'background-image':'url(images/vbox/arrow_down_10px.png)'});
- $(this).closest('tr').toggleClass('collapsed').trigger('showChildren',true);
-
- } else {
- $(this).data('toggleClicked', false);
- $(this).css({'background-image':'url(images/vbox/arrow_right_10px.png)'});
- $(this).closest('tr').toggleClass('collapsed').trigger('hideChildren',true);
- }
-
- return false;
-
- }).appendTo(td);
-
- } else if(depth) {
- $('<img />').attr({'class':'vboxVMMSpacer','src':'images/vbox/blank.gif'}).appendTo(td);
- }
-
- // Title div
- var span = $('<span />').attr({'id':'vboxVMMMediaTitle-'+d.id}).html($('<div />').html(d.name).text());
-
- // Add read-only or inaccessible class?
- if(d.state == 'Inaccessible') {
- $(span).addClass('vboxMediumInaccessible');
- } else if(hideDiff !== undefined && d.readOnly) {
- $(span).addClass('vboxMediumReadOnly');
- }
-
- $(td).append(span).appendTo(tr);
-
- // Set target list
- //////////////////////
- var target = '';
- switch(d.deviceType) {
- case 'HardDisk':
- // Logical size column
- $('<td />').addClass('vboxHoverMid').append($('<span />').html(vboxMbytesConvert(d.logicalSize))).appendTo(tr);
- target = '#vboxVMMHDList';
- break;
- case 'DVD':
- target = '#vboxVMMCDList';
- break;
- case 'Floppy':
- target = '#vboxVMMFDList';
- break;
- }
-
- // Size column
- $('<td />').addClass('vboxHoverLast').append($('<div />').html(vboxBytesConvert(d.size))).appendTo(tr);
-
- /* Show / hide children of this medium */
- $(tr).on('showChildren',function(e,first){
-
- var thisid = $(this).data('medium');
- var trTarget = this;
-
- if($(this).hasClass('collapsed') || !$(this).hasClass('vboxVMMParent')) return;
-
- $(trTarget).siblings('tr.vboxVMMChildOf'+thisid).show().removeClass('vboxHidden').trigger('showChildren',false);
-
- // Only set by original button click
- if(first) { vboxColorRows($('#vboxVMMHDList')); vboxVMMTableHeaderSetup($('#vmmDisks')); }
-
- }).on('hideChildren',function(e,first){
-
- if(!$(this).hasClass('vboxVMMParent')) return;
-
- $(this).siblings('tr.vboxVMMChildOf'+$(this).data('medium')).hide().addClass('vboxHidden').trigger('hideChildren',false);
-
- // Only set by original button click
- if(first) { vboxColorRows($('#vboxVMMHDList')); vboxVMMTableHeaderSetup($('#vmmDisks'));}
-
-
- }).children().click(function(){
- $(this).parent().removeClass('vboxListItem vboxHover').addClass('vboxListItemSelected')
- .siblings().removeClass('vboxListItemSelected').addClass('vboxListItem');
- $('#vboxVirtualMediaManager').trigger('mediumselect',[$(this).parent()]);
- });
-
- $(target).append(tr);
-
- if(d.children && d.children.length) {
- if(depth) depth++;
- else depth = 1;
- for(var i = 0; i < d.children.length; i++) {
- vboxVMMAddMedium(d.children[i],depth,hideDiff,(topLevelParent ? topLevelParent : d.id));
- }
- }
-}
-
-/* Fill medium tables and info with Medium info */
-function vboxVMMFillMedia(sel) {
-
- // Remove stub items
- $('#vboxVMMHDList').children().remove();
- $('#vboxVMMCDList').children().remove();
- $('#vboxVMMFDList').children().remove();
-
- // Set icons
- $('#vmmDisksIcon').attr('src','images/vbox/hd_16px.png');
- $('#vmmCDsIcon').attr('src','images/vbox/cd_16px.png');
- $('#vmmFloppysIcon').attr('src','images/vbox/fd_16px.png');
-
- var media = $('#vboxPane').data('vboxMedia').sort(function(a,b) {
- return strnatcasecmp(a.name,b.name);
- });
-
- var hideDiff = $('#vboxVirtualMediaManager').data('hideDiff');
-
- for(var i in media) {
- vboxVMMAddMedium(media[i],0,hideDiff,media[i].parent);
- if(media[i].state == 'Inaccessible') {
- var elm = null;
- switch(media[i].deviceType) {
- case 'HardDisk':
- elm = $('#vmmDisksIcon');
- break;
- case 'DVD':
- elm = $('#vmmCDsIcon');
- break;
- default:
- elm = $('#vmmFloppysIcon');
- }
- elm.attr('src','images/vbox/state_aborted_16px.png');
- }
-
- }
-
- vboxVMMTableHeaderSetup($('#vmmDisks'));
- vboxVMMTableHeaderSetup($('#vmmCDs'));
- vboxVMMTableHeaderSetup($('#vmmFloppys'));
-
- // Select medium?
- if(sel) {
-
- $('#vboxVMMMedium'+sel).children().first().click();
-
- } else {
- $('#vboxVirtualMediaManager').trigger('mediumselect',null);
- }
- vboxVMMTableSort($('#vboxVMMHDList'));
- vboxVMMTableSort($('#vboxVMMFDList'));
- vboxVMMTableSort($('#vboxVMMCDList'));
-
-
-}
-
-/*
- *
- * Sort table according to selected items
- *
- */
-function vboxVMMTableSort(t) {
-
- // Get Selected Heading and sort order
- ////////////////////////////////////////
- var ths = $(t).closest('div').siblings('div.vmmTableHead').find('thead').find('th');
- var cthIndex = 0;
- var sortOrder = null;
- for(var i = 0; i < ths.length; i++) {
- if($(ths[i]).data('sorted')) {
- cthIndex = i;
- sortOrder = $(ths[i]).data('sorted');
- break;
- }
- }
- ths =null;
-
- // Sort table
- ///////////////////////
- $(t).each(function(){
-
- // Sort function (vboxVMMChildOf0 are top-level)
- var rows = $(this).find('tr.vboxVMMChildOf0').get();
- switch(cthIndex) {
- // Name
- case 0:
- rows.sort(function(a,b){
- return strnatcasecmp($(a).data('mediumname'),$(b).data('mediumname'));
- });
- break;
- // size or logical size
- default:
-
- // HD has an extra column for logical size
-
- // size
- var sortOpt = ($("#vboxVMMTabs").tabs('option','active') ? '' : 'HD');
- if(sortOpt == 'HD' && cthIndex == 2 || (sortOpt != 'HD')) {
- rows.sort(function(a,b){
- if($(a).data('mediumsize') == $(b).data('mediumsize')) return 0;
- return (parseInt($(a).data('mediumsize')) > parseInt($(b).data('mediumsize')) ? 1 : -1);
- });
- // logical size
- } else {
- rows.sort(function(a,b){
- if($(a).data('mediumlogicalSize') == $(b).data('mediumlogicalSize')) return 0;
- return (parseInt($(a).data('mediumlogicalSize')) > parseInt($(b).data('mediumlogicalSize')) ? 1 : -1);
- });
- }
- break;
- }
- // reverse?
- if(sortOrder == 'asc') rows.reverse();
-
- // Append rows and children
- var target = $(this);
- $(rows).each(function(){
- // top-level (parent) medium
- $(this).detach().appendTo($(target));
- // Children
- $(target).find('tr.vboxVMMTopLevel'+($(this).data('medium'))).detach().appendTo($(target));
- });
- vboxColorRows(target);
- });
-
-}
-/*
- *
- * Resizing and setup
- *
- */
-
-function vboxVMMSizeTable(elm) {
-
- // Hide table body
- var TB = $(elm).find('div.vmmTableBody');
-
- TB.css({'display':'none'});
-
- // Get height
- var cH = $(elm).parent().innerHeight() - $(elm).outerHeight(true);
-
- // Apply to difference in height to table body
- TB.height(cH-4).css({'display':'','overflow':'auto'});
-
- // Set table head width
- vboxVMMTableHeaderSetup(elm);
-
-}
-/* Setup tables */
-function vboxVMMTableHeaderSetup(elm) {
-
- // Set column width
-
- // Get each column width
- var hCols = $(elm).find('div.vmmTableHead').find('tr:eq(0)').children();
- var tCols = $(elm).find('div.vmmTableBody').find('tbody tr:eq(0)').children();
- for(var i = 0; i < tCols.length; i++) {
- $(hCols[i]).width($(tCols[i]).width());
- }
-
-}
-
-
-/* Init virtual media manager */
-function vboxVMMInit(hideDiff,vmPath) {
-
- // SEVERE hack-fooery ensues..
- /////////////////////////////////
- $('#vboxVirtualMediaManager').parent().on( "dialogresizestart",function(e){
-
- $('#vboxVMMTabs').css({'height':'auto'});
- $('#vboxVMMContainer').css({'height':'auto'});
-
- }).on("dialogresizestop",function(e){
-
- $('#vmmDisks .vmmTableBody').css({'display':'none'});
- $('#vmmCDs .vmmTableBody').css({'display':'none'});
- $('#vmmFloppys .vmmTableBody').css({'display':'none'});
-
- $('#vboxVMMContainer').height($('#vboxVMMContainer').height());
- $('#vboxVMMTabs').height($('#vboxVMMContainer').innerHeight());
-
- vboxVMMSizeTable($('#vmmDisks'));
- vboxVMMSizeTable($('#vmmCDs'));
- vboxVMMSizeTable($('#vmmFloppys'));
- });
-
- $('#vboxVMMTabList').css({'border-bottom':'0px','margin-bottom':'0px','padding-bottom':'0px'}).detach().appendTo($('#vboxVMMContainerTop').attr({'class':$('#vboxVMMTabs').css({'border-top':'0px','margin-top':'0px','padding-top':'0px'}).removeClass('ui-corner-all').attr('class')}));
-
- $('#vboxVMMContainer').height($('#vboxVMMContainer').height()).css({'padding':'0px','margin':'0px'});
- $('#vboxVMMTabs').height($('#vboxVMMContainer').innerHeight()).css({'padding-top':'0px','padding-bottom':'0px','margin-top':'0px','margin-bottom':'0px'});
-
- // Resize disks table body
- vboxVMMSizeTable($('#vmmDisks'));
-
- // Save options for later
- $('#vboxVirtualMediaManager').data('hideDiff', hideDiff);
- $('#vboxVirtualMediaManager').data('vmPath', vmPath);
-
- // Column sorting
- ////////////////////////////
- $("#vboxVirtualMediaManager div.vmmTableHead thead th").each(function(thIndex){
-
- // Skip last column header. It is just kept for spacing
- if($(this).children('img').length) return true;
-
- $(this).hover(function(){
- $(this).children('img').css({'visibility':'visible'});
- },function(){
- if($(this).data('sorted')) return;
- $(this).children('img').css({'visibility':'hidden'});
-
- }).addClass('vboxVMMSortImgFaded').append(' ').append($('<img />').attr({'src':'images/upArrow.png','style':'visibility:hidden;cursor:pointer'}).click(function(e,sortDefault){
-
- var p = $(this).parent();
-
- // Get current sort order and set accordingly
- //////////////////////////////////////////////
- switch(p.data('sorted')) {
- case 'asc':
- $(this).attr({'src':'images/upArrow.png'}).css({'visibility':'visible'});
- p.data('sorted','desc');
- break;
- case 'desc':
- $(this).attr({'src':'images/downArrow.png'}).css({'visibility':'visible'});
- p.data('sorted','asc');
- break;
- default:
- p.data({'sorted':'desc'}).removeClass('vboxVMMSortImgFaded').siblings().data({'sorted':null}).addClass('vboxVMMSortImgFaded').children('img').attr({'src':'images/upArrow.png'}).css({'visibility':'hidden'});
- break;
- }
-
- vboxVMMTableSort($(p).closest('div').siblings('div.vmmTableBody').find('tbody').first());
-
- }));
-
- // Default is sort by name
- if($(this).index() == 0) {
- $(this).data({'sorted':'desc'}).removeClass('vboxVMMSortImgFaded').children('img').css({'visibility':'visible'});
- }
-
-
- });
-
- vboxVMMFillMedia();
-
-}
-
-
-</script>
-
-
+<!--
+
+ Virtual Media Manager
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: vmm.html 595 2015-04-17 09:50:36Z imoore76 $
+
+ -->
+<table id='vboxVirtualMediaManager' style='height: 100%; border:0px;margin:0px;padding:0px;width:100%;border-spacing:0px;border-width:0px;'>
+
+ <!-- Top menu -->
+ <tr><td style='height:1%;padding:0px;margin:0px;border:0px;'><div id='vboxMMMenu' style='margin:0px;'></div></td></tr>
+
+ <!-- Toolbar Created by JavaScript below -->
+ <tr><td style='height:1%;padding:0px;margin:0px;border:0px;'><div id='vboxMMToolbar' style='padding:0px; margin:0px;' class='vboxToolbarGrad'></div></td></tr>
+
+ <!-- Tab Placeholder -->
+ <tr style='vertical-align: top;'><td id='vboxVMMContainerTopCell' style='height:1%;padding:0px;margin:0px;border:0px;'><div id='vboxVMMContainerTop' style='border:0px;margin-bottom:0px;padding-bottom:0px;'></div></td></tr>
+
+ <!-- Tabs for Media -->
+ <tr style='vertical-align: top;'>
+ <td style='padding:0px;margin:0px;border:0px;' id='vboxVMMContainer'>
+
+ <div id='vboxVMMTabs'>
+
+ <ul id='vboxVMMTabList'>
+ <li><a href="#vmmDisks"><span><img id='vmmDisksIcon' style="height:16px;width:16px;vertical-align: middle" src="images/vbox/hd_16px.png" border="0" /> <span class='translate'>Hard disks</span></span></a></li>
+ <li><a href="#vmmCDs"><span><img id='vmmCDsIcon' style="height:16px;width:16px;vertical-align: middle" src="images/vbox/cd_16px.png" border="0" /> <span class='translate'>Optical disks</span></span></a></li>
+ <li><a href="#vmmFloppys"><span><img id='vmmFloppysIcon' style="height:16px;width:16px;vertical-align: middle" src="images/vbox/fd_16px.png" border="0" /> <span class='translate'>Floppy disks</span></span></a></li>
+ </ul>
+
+ <!--
+
+ HARD DISKS
+
+ -->
+ <div id='vmmDisks'>
+ <div class='vboxBordered vboxVMMList'>
+ <div class='vmmTableHead'>
+ <table style='border-spacing: 0px; border: 0px; width:100%;' class='vboxHorizontal vboxListTable vboxVMMList'>
+ <thead>
+ <tr>
+ <th style='width: 100%;'><span class='translate'>Name</span></th>
+ <th style='width: auto'><span class='translate'>Virtual Size</span></th>
+ <th style='width: auto'><span class='translate'>Actual Size</span></th>
+ <th style='width: auto;padding:0px;margin:0px;'><img src="images/vbox/blank.gif" style="height:1px;width:1px" /></th>
+ </tr>
+ </thead>
+ </table>
+ </div>
+ <div class='vmmTableBody'>
+ <table class='vboxHorizontal vboxListTable vboxVMMList' tabindex='1'>
+ <tbody id='vboxVMMHDList' class='vboxHover'>
+ <tr>
+ <td>Item 1</td>
+ <td>Item 2</td>
+ <td>Item 3</td>
+ </tr>
+ <tr>
+ <td>Item 1</td>
+ <td>Item 2</td>
+ <td>Item 3</td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+ </div>
+ <div class='vboxVMMMediumInfo'>
+ <table>
+ <tr>
+ <th><span class='translate'>Type:</span></th>
+ <td><input id='vmmMediumType' type='text' style='width:100%;border:0px solid transparent;background:transparent;' value='' readonly spellcheck='false' /></td>
+ </tr>
+ <tr>
+ <th><span class='translate'>Location:</span></th>
+ <td><input class='vmmMediumLocation' type='text' style='width:100%;border:0px solid transparent;background:transparent;' value='' readonly spellcheck='false' /></td>
+ </tr>
+ <tr>
+ <th><span class='translate'>Format:</span></th>
+ <td><input class='vmmMediumFormat' type='text' style='width:100%;border:0px solid transparent;background:transparent;' value='' readonly spellcheck='false'/></td>
+ </tr>
+ <tr>
+ <th><span class='translate'>Storage details:</span></th>
+ <td><input class='vmmMediumHDDetails' type='text' style='width:100%;border:0px solid transparent;background:transparent;' value='' readonly spellcheck='false'/></td>
+ </tr>
+ <tr>
+ <th><span class='translate'>Attached to:</span></th>
+ <td><input class='vmmMediumAttachedTo' type='text' style='width:100%;border:0px solid transparent;background:transparent;' value='' readonly spellcheck='false'/></td>
+ </tr>
+ <tr>
+ <th><span class='translate'>UUID:</span></th>
+ <td><input class='vmmMediumUUID' type='text' style='width:100%;border:0px solid transparent;background:transparent;' value='' readonly spellcheck='false'/></td>
+ </tr>
+ <tr class='vmmAccessErr'>
+ <td colspan='2'></td>
+ </tr>
+ </table>
+ </div>
+ </div>
+
+
+
+ <!--
+
+ CD / DVD IMAGES
+
+ -->
+ <div id='vmmCDs'>
+ <div class='vboxVMMList vboxBordered'>
+ <div class='vmmTableHead'>
+ <table style='width: 100%; border-spacing: 0px; border: 0px;' class='vboxHorizontal vboxListTable vboxVMMList'>
+ <thead>
+ <tr>
+ <th style='width: 100%'><span class='translate'>Name</span></th>
+ <th style='width: auto'><span class='translate'>Size</span></th>
+ <th style='width: auto;padding:0px;margin:0px;'><img src="images/vbox/blank.gif" style="height:1px;width:1px" /></th>
+ </tr>
+ </thead>
+ </table>
+ </div>
+ <div class='vmmTableBody'>
+ <table style='width: 100%; border-spacing: 0px; border: 0px;' class='vboxHorizontal vboxListTable vboxVMMList' tabindex='1'>
+ <tbody id='vboxVMMCDList' class='vboxHover'>
+ <tr>
+ <td>Item 1</td>
+ <td>Item 3</td>
+ </tr>
+ <tr>
+ <td>Item 1</td>
+ <td>Item 3</td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+ </div>
+ <div class='vboxVMMMediumInfo'>
+ <table>
+ <tr>
+ <th><span class='translate'>Location:</span></th>
+ <td><input class='vmmMediumLocation' type='text' style='width:100%;border:0px solid transparent;background:transparent;' value='' readonly spellcheck='false' /></td>
+ </tr>
+ <tr>
+ <th><span class='translate'>Attached to:</span></th>
+ <td><input class='vmmMediumAttachedTo' type='text' style='width:100%;border:0px solid transparent;background:transparent;' value='' readonly spellcheck='false'/></td>
+ </tr>
+ <tr>
+ <th><span class='translate'>UUID:</span></th>
+ <td><input class='vmmMediumUUID' type='text' style='width:100%;border:0px solid transparent;background:transparent;' value='' readonly spellcheck='false'/></td>
+ </tr>
+ <tr class='vmmAccessErr'>
+ <td colspan='2'></td>
+ </tr>
+ </table>
+ </div>
+ </div>
+
+
+
+
+ <!--
+
+ FLOPPY IMAGES
+
+ -->
+ <div id='vmmFloppys'>
+ <div class='vboxVMMList vboxBordered'>
+ <div class='vmmTableHead'>
+ <table style='width: 100%; border-spacing: 0px; border: 0px;' class='vboxHorizontal vboxListTable vboxVMMList'>
+ <thead>
+ <tr>
+ <th style='width: 100%'><span class='translate'>Name</span></th>
+ <th style='width: auto'><span class='translate'>Size</span></th>
+ <th style='width: auto;padding:0px;margin:0px;'><img src="images/vbox/blank.gif" style="height:1px;width:1px" /></th>
+ </tr>
+ </thead>
+ </table>
+ </div>
+ <div class='vmmTableBody'>
+ <table style='width: 100%; border-spacing: 0px; border: 0px;' class='vboxHorizontal vboxListTable vboxVMMList' tabindex='1'>
+ <tbody id='vboxVMMFDList' class='vboxHover'>
+ <tr>
+ <td>Item 1</td>
+ <td>Item 2</td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+ </div>
+ <div class='vboxVMMMediumInfo'>
+ <table>
+ <tr>
+ <th><span class='translate'>Location:</span></th>
+ <td><input class='vmmMediumLocation' type='text' style='width:100%;border:0px solid transparent;background:transparent;' value='' readonly spellcheck='false'/></td>
+ </tr>
+ <tr>
+ <th><span class='translate'>Attached to:</span></th>
+ <td><input class='vmmMediumAttachedTo' type='text' style='width:100%;border:0px solid transparent;background:transparent;' value='' readonly spellcheck='false'/></td>
+ </tr>
+ <tr>
+ <th><span class='translate'>UUID:</span></th>
+ <td><input class='vmmMediumUUID' type='text' style='width:100%;border:0px solid transparent;background:transparent;' value='' readonly spellcheck='false'/></td>
+ </tr>
+ <tr class='vmmAccessErr'>
+ <td colspan='2'></td>
+ </tr>
+ </table>
+ </div>
+ </div>
+ </div></td>
+ </tr>
+</table>
+<script type='text/javascript'>
+
+/*
+ * Translate
+ */
+
+// These are translated under a different context for some reason
+$('#vboxVMMTabList').find(".translate").html(function(i,h){return trans(h,'UIMediumManager');}).removeClass('translate');
+
+$("#vboxVMMTabs").find(".translate").html(function(i,h){return trans(h,'VBoxMediaManagerDlg');}).removeClass('translate');
+
+/*
+ * Keypress events
+ */
+$('div.vmmTableBody table').click(function(){$(this).focus();}).keydown(function(e){
+
+ var keynum = 0;
+
+ if(e.keyCode)
+ keynum = e.keyCode;
+ else if(e.which)
+ keynum = e.which;
+
+ switch(keynum) {
+
+ // up
+ case 38:
+ $(this).find('tr.vboxListItemSelected').prevAll('tr:not([class~="vboxHidden"]):first').children().first().click();
+ break;
+
+ // right / expand
+ case 39:
+ $(this).find('tr.vboxListItemSelected.collapsed').find('input').click();
+ break;
+
+ // left / contract
+ case 37:
+ $(this).find('tr.vboxListItemSelected:not(.collapsed)').find('input').click();
+ break;
+
+ // down
+ case 40:
+ $(this).find('tr.vboxListItemSelected').nextAll('tr:not([class~="vboxHidden"]):first').children().first().click();
+ break;
+
+ }
+
+ return false;
+
+}).css('outline','none');
+
+/*
+ * Setup Tabs
+ */
+$("#vboxVMMTabs").tabs().on("tabsactivate",function(ev,ui){
+
+ // Resize table
+ vboxVMMSizeTable(ui.newPanel);
+
+ // Medium selection
+ if(!$(ui.newPanel).find('tbody').children('tr.vboxListItemSelected').first().children().first().click().length) {
+ $('#vboxVirtualMediaManager').trigger('mediumselect',[null]);
+ }
+});
+
+/*
+ * Toolbar Buttons
+ */
+var vmmButtons = new Array(
+
+ {
+ /*
+ * Create new HardDisk
+ */
+ 'name' : 'vmmnew',
+ 'label' : 'New',
+ 'icon' : 'hd_new',
+ 'enabled' : function (item) { return(!$("#vboxVMMTabs").tabs('option','active')); },
+ 'click' : function () {
+ $.when(new vboxWizardNewHDDialog({'path':$('#vboxVirtualMediaManager').data('vmPath')}).run()).done(function(id){
+ vboxVMMFillMedia(id);
+ });
+ }
+ },
+
+ {
+ /*
+ * Add existing medium to virtualbox
+ */
+ 'name' : 'vmmadd',
+ 'label' : 'Add',
+ 'icon' : 'hd_add',
+ 'click' : function () {
+ var type = '';
+ switch($("#vboxVMMTabs").tabs('option','active')) {
+ case 1: type = 'DVD'; break;
+ case 2: type = 'Floppy'; break;
+ default: type = 'HardDisk'; break;
+ }
+
+ vboxMedia.actions.choose(null,type,function(ret){
+ vboxVMMFillMedia((ret && ret.id ? ret.id : null));
+ });
+
+ }
+ },
+ {
+ /*
+ * Add iSCSI medium to virtualbox
+ */
+ 'name' : 'vmmaddiscsi',
+ 'label' : 'Add iSCSI',
+ 'icon' : 'hd_add',
+ 'enabled' : function (item) { return(!$("#vboxVMMTabs").tabs('option','active')); },
+ 'click' : function () {
+
+
+ var d = $('<div />').attr({'id':'vboxVMMAddMediumImageDialog'});
+
+ var buttons = {};
+ buttons[trans('OK','QIMessageBox')] = function() {
+
+ var frm = document.forms.vboxISCSIForm;
+ var server = $(frm.vboxISCSIServer).val();
+ var port = $(frm.vboxISCSIPort).val();
+ var intnet = frm.vboxISCSIIntnet.checked;
+ var target = $(frm.vboxISCSITarget).val();
+ var lun = $(frm.vboxISCSILun).val();
+ var enclun = frm.vboxISCSILunEnc.checked;
+ var user = $(frm.vboxISCSIUser).val();
+ var pass = $(frm.vboxISCSIPass).val();
+
+ if(server && target) {
+ if(!lun) lun = '0';
+ var l = new vboxLoader('addiscsi');
+ l.add('mediumAddISCSI',function(ret){
+ if(ret && ret.responseData && ret.responseData.id) {
+ var nl = new vboxLoader('getMedia');
+ nl.add('vboxGetMedia',function(dat){$('#vboxPane').data('vboxMedia',dat.responseData);});
+ nl.onLoad = function() {
+ vboxVMMFillMedia(ret.responseData.id);
+ };
+ nl.run();
+ }
+ },{'server':server,'port':port,'intnet':intnet,'target':target,'lun':lun,'enclun':enclun,'targetUser':user,'targetPass':pass});
+ l.run();
+ }
+
+ $(this).empty().remove();
+
+ };
+ buttons[trans('Cancel','QIMessageBox')] = function() { $(this).empty().remove(); };
+
+ var l = new vboxLoader();
+ l.addFileToDOM("panes/vmmISCSI.html",$(d));
+ l.onLoad = function() {
+ $(d).dialog({'width':400,'height':350,'buttons':buttons,'modal':true,'autoOpen':true,'dialogClass':'vboxDialogContent','title':trans('Add iSCSI')});
+ };
+ l.run();
+
+
+ }
+ },
+ {
+ /*
+ * Copy Medium
+ */
+ 'name' : 'vmmcopy',
+ 'label' : 'Copy...',
+ 'icon' : 'vdm_add',
+ 'separator' : $('#vboxPane').data('vboxConfig').enableAdvancedConfig,
+ 'enabled' : function (item) {
+ if(!item) return false;
+ if($("#vboxVMMTabs").tabs('option','active')) return false;
+ if(!$(item).data('medium')) return false;
+ var m = vboxMedia.getMediumById($(item).data('medium'));
+ return (!m || !m.parent);
+
+ },
+ 'click' : function () {
+ var elm = null;
+ switch($("#vboxVMMTabs").tabs('option','active')) {
+ case 1:
+ elm = $('#vboxVMMCDList');
+ break;
+ case 2:
+ elm = $('#vboxVMMFDList');
+ break;
+ default:
+ elm = $('#vboxVMMHDList');
+ break;
+ }
+ $.when(new vboxWizardCopyHDDialog({'medium':$(elm).find('tr.vboxListItemSelected').first().data('medium')}).run()).done(function(id){
+ vboxVMMFillMedia(id);
+ });
+ }
+ },
+ {
+ /*
+ * Modify Medium
+ */
+ 'name' : 'vmmmodify',
+ 'label' : 'Modify...',
+ 'icon' : 'vdm_new',
+ 'enabled' : function (item) {
+ if(!item) return false;
+ if($("#vboxVMMTabs").tabs('option','active')) return false;
+ var m = vboxMedia.getMediumById($(item).data('medium'));
+ return (m && !m.parent);
+
+ },
+ 'click' : function () {
+
+ var d = $('<div />').attr({'id':'vboxVMMModifyDialog'});
+
+ var med = $('#vboxVMMHDList').find('tr.vboxListItemSelected').first();
+ med = vboxMedia.getMediumById(med.data('medium'));
+
+ var buttons = {};
+ buttons[trans('OK','QIMessageBox')] = function() {
+
+ var mtype = document.forms.vboxVMMModifyForm.vmmMType;
+ for(var i = 0; i < mtype.length; i++) {
+ if(mtype[i].checked) {
+ mtype = mtype[i].value;
+ break;
+ }
+ }
+
+ $.when(vboxAjaxRequest('mediumSetType',{'medium':med.location,'type':mtype})).done(function(ret){
+
+ if(ret && ret.success) {
+ var l = new vboxLoader();
+ l.add('vboxGetMedia',function(data){$('#vboxPane').data('vboxMedia',data.responseData);});
+ l.onLoad = function() {
+ if($('#vboxVirtualMediaManager').data('hideDiff')) {
+ var d = vboxMedia.getMediumById(med.id);
+ if(d.readOnly) $('#vboxVMMMediaTitle-'+d.id).addClass('vboxMediumReadOnly');
+ else $('#vboxVMMMediaTitle-'+d.id).removeClass('vboxMediumReadOnly');
+ }
+ $('#vmmMediumType').val(trans(mtype,'VBoxGlobal'));
+ };
+ l.run();
+ $('#vboxVMMModifyDialog').empty().remove();
+ }
+ });
+
+ };
+ buttons[trans('Cancel','QIMessageBox')] = function() { $(this).empty().remove(); };
+
+ var l = new vboxLoader();
+ l.addFileToDOM("panes/vmmModify.html",$(d));
+ l.onLoad = function() {
+
+ var msg = trans('<p>You are about to change the settings of the disk image file <b>%1</b>.</p><p>Please choose one of the following modes and press <b>%2</b> to proceed or <b>%3</b> otherwise.</p>','UIMediumTypeChangeDialog');
+ var title = trans('Modify medium attributes','UIMediumTypeChangeDialog');
+
+ msg = msg.replace('%1',med.location).replace('%2',trans('OK','QIMessageBox')).replace('%3',trans('Cancel','QIMessageBox'));
+
+ $(d).dialog({'width':400,'height':370,'buttons':buttons,'modal':true,'autoOpen':true,'dialogClass':'vboxDialogContent','title':'<img src="images/vbox/diskimage_16px.png" /> '+title});
+
+ // Translations
+ $('#vboxVMMModifyInstructions').html(msg);
+
+ $('#vboxVMMModify').find(".translate").html(function(i,h){return trans(h,'UIMediumTypeChangeDialog');}).removeClass('translate');
+
+ $('#vboxVMMModify').find('table.vboxOptions').find('span').html(function(i,h){return trans(h,'VBoxGlobal', 'MediumType');});
+
+ // Set correct option
+ $('#vboxVMMModify').find('input').prop('checked',false);
+ $('#vboxVMMModify').find('input[value='+med.type+']').prop('checked',true);
+
+
+ };
+ l.run();
+
+ }
+ },
+
+ {
+ /*
+ * Remove a medium
+ */
+ 'name' : 'vmmremove',
+ 'label' : 'Remove',
+ 'icon' : 'hd_remove',
+ 'enabled' : function (item) {
+ if(!item || item.target) return false;
+ var m = vboxMedia.getMediumById($(item).data('medium'));
+ return (m && m.attachedTo.length == 0 && m.children.length == 0);
+ },
+ 'click' : function () {
+ var mtype = null;
+ var elm = null;
+ switch($("#vboxVMMTabs").tabs('option','active')) {
+ case 1:
+ elm = $('#vboxVMMCDList');
+ mtype = 'CD/DVD image';
+ break;
+ case 2:
+ elm = $('#vboxVMMFDList');
+ mtype = 'floppy image';
+ break;
+ default:
+ elm = $('#vboxVMMHDList');
+ mtype = 'hard disk';
+ break;
+ }
+ var m = vboxMedia.getMediumById($(elm).find('tr.vboxListItemSelected').first().data('medium'));
+
+ var buttons = {};
+ var q = '';
+
+ // If we are removing a hard disk and configured to allow deletions
+ if(m.deviceType == 'HardDisk' && $('#vboxPane').data('vboxConfig').deleteOnRemove && m.format != 'iSCSI') {
+
+
+ q = trans('<p>Do you want to delete the storage unit of the virtual hard disk <nobr><b>%1</b></nobr>?'+
+ '</p><p>If you select <b>Delete</b> then the specified storage unit will be permanently deleted. '+
+ 'This operation <b>cannot be undone</b>.</p><p>If you select <b>Keep</b> then the hard disk will '+
+ 'be only removed from the list of known hard disks, but the storage unit will be left untouched '+
+ 'which makes it possible to add this hard disk to the list later again.</p>','UIMessageCenter').replace('%1',m.location);
+
+ buttons[trans('Delete','UIMessageCenter')] = function(){
+ $.when(vboxAjaxRequest('mediumRemove',{'medium':m.location,'type':m.deviceType,'delete':1})).done(function(ret){
+ if(ret && ret.responseData && ret.responseData.progress) {
+ vboxProgress(ret.responseData,function(){
+ var l = new vboxLoader();
+ l.add('vboxGetMedia',function(d){$('#vboxPane').data('vboxMedia',d.responseData);});
+ l.onLoad = function() {vboxVMMFillMedia(); };
+ l.run();
+ },'progress_media_delete_90px.png',trans('Delete','UIMessageCenter'),
+ vboxBasename(m.location));
+ }
+ });
+ $(this).empty().remove();
+ };
+
+ buttons[trans('Keep','UIMessageCenter')] = function(){
+ $.when(vboxAjaxRequest('mediumRemove',{'medium':m.location,'type':m.deviceType})).done(function(ret){
+ var l = new vboxLoader();
+ l.add('vboxGetMedia',function(d){$('#vboxPane').data('vboxMedia',d.responseData);});
+ l.onLoad = function() {vboxVMMFillMedia(); };
+ l.run();
+ });
+ $(this).empty().remove();
+ };
+
+ } else {
+
+ q = trans('<p>Are you sure you want to remove the %1 <nobr><b>%2</b></nobr> from the list of known media?</p>','UIMessageCenter').replace('%1',trans(mtype,'UIMessageCenter')).replace('%2',m.location);
+ q+= trans('<p>Note that the storage unit of this medium will not be deleted and that it will be possible to use it later again.</p>','UIMessageCenter');
+
+ buttons[trans('Remove','UIMessageCenter')] = function(){
+ var b = this;
+ $.when(vboxAjaxRequest('mediumRemove',{'medium':m.location,'type':m.deviceType})).done(function(ret){
+ var l = new vboxLoader();
+ l.add('vboxGetMedia',function(d){$('#vboxPane').data('vboxMedia',d.responseData);});
+ l.onLoad = function() {vboxVMMFillMedia(); };
+ $(b).empty().remove();
+ l.run();
+ });
+ };
+
+ }
+ vboxConfirm(q,buttons);
+ }
+ },
+
+ {
+ /*
+ * Release a medium from all attachments
+ */
+ 'name' : 'vmmrelease',
+ 'label' : 'Release',
+ 'icon' : 'hd_release',
+ 'enabled' : function (item) {
+ if(!item || item.target) return false;
+ var m = vboxMedia.getMediumById($(item).data('medium'));
+ return (m && m.attachedTo.length > 0 && m.children.length == 0 && m.hasSnapshots == 0);
+ },
+ 'click' : function () {
+ var elm = null;
+ var mtype = null;
+ switch($("#vboxVMMTabs").tabs('option','active')) {
+ case 1:
+ elm = $('#vboxVMMCDList');
+ mtype = 'CD/DVD image';
+ break;
+ case 2:
+ elm = $('#vboxVMMFDList');
+ mtype = 'floppy image';
+ break;
+ default:
+ elm = $('#vboxVMMHDList');
+ mtype = 'hard disk';
+ break;
+ }
+
+
+ var m = vboxMedia.getMediumById($(elm).find('tr.vboxListItemSelected').first().data('medium'));
+ var q = trans('<p>Are you sure you want to release the disk image file <nobr><b>%1</b></nobr>?</p><p>This will detach it from the following virtual machine(s): <b>%2</b>.</p>','UIMessageCenter');
+ q = q.replace('%1',m.location);
+
+ var buttons = {};
+ buttons[trans('Release','UIMessageCenter')] = function(){
+ var b = this;
+ $.when(vboxAjaxRequest('mediumRelease',{'medium':m.location,'type':m.deviceType})).done(function(ret){
+
+ var l = new vboxLoader();
+ l.add('vboxGetMedia',function(d){$('#vboxPane').data('vboxMedia',d.responseData);});
+ l.onLoad = function(){
+ vboxVMMFillMedia(m.id);
+ };
+ $(b).empty().remove();
+ l.run();
+ });
+ };
+
+ if(m.attachedTo.length) {
+ var machines = new Array();
+ for(var i = 0; i < m.attachedTo.length; i++) {
+ machines[machines.length] = m.attachedTo[i].machine;
+ }
+ q = q.replace('%2','<b>'+machines.join('</b>, <b>') + '</b>');
+ };
+
+
+ vboxConfirm(q,buttons);
+ }
+ },
+
+ {
+ 'name' : 'vmmrefresh',
+ 'label' : 'Refresh',
+ 'icon' : 'refresh',
+ 'click' : function () {
+
+ // Force a refresh of media
+ var l = new vboxLoader();
+ l.add('vboxGetMedia',function(d){$('#vboxPane').data('vboxMedia',d.responseData);});
+ l.onLoad = function() {vboxVMMFillMedia(); };
+ l.run();
+
+ }
+ }
+
+
+);
+
+// Check for advanced config
+if(!$('#vboxPane').data('vboxConfig').enableAdvancedConfig) {
+ vmmButtons.shift();
+ vmmButtons.shift();
+ vmmButtons.shift();
+}
+
+/* Toolbar */
+var vmmToolbar = new vboxToolbar({buttons: vmmButtons,
+ language_context: 'VBoxMediaManagerDlg',
+ renderTo: 'vboxMMToolbar'});
+
+/* Actions Menu */
+var vmmMenu = new vboxMenuBar({name: 'vboxMMMenu', language_context: 'VBoxMediaManagerDlg'});
+vmmMenu.addMenu({
+ 'name':'vboxMMactions',
+ 'label':'Actions',
+ 'menu': vmmButtons
+});
+vmmMenu.renderTo('vboxMMMenu');
+
+/* Context menu for media */
+var vmmCMButtons;
+
+// Check for advanced config. We don't want these in our context menu
+if($('#vboxPane').data('vboxConfig').enableAdvancedConfig) {
+ vmmCMButtons = vmmButtons.slice(3,-1);
+} else {
+ vmmCMButtons = vmmButtons.slice(0,-1);
+}
+var vmmCMenu = new vboxMenu({name: 'vboxVMMMediaContextMenu', menuItems: vmmCMButtons,
+ language_context: 'VBoxMediaManagerDlg'});
+
+
+/**
+ * Displays medium info
+ * @param {HTMLElement} med selected medium row
+ */
+function vboxVMMMediaInfo(med) {
+
+ var m = (med ? vboxMedia.getMediumById($(med).data('medium')) : null);
+
+ $('#vboxVirtualMediaManager').find('.vmmMediumLocation').val((m && m.location ? m.location : '--'));
+ $('#vboxVirtualMediaManager').find('.vmmMediumFormat').val(m ? m.format.toUpperCase() : '--');
+ $('#vboxVirtualMediaManager').find('.vmmMediumHDDetails').val(m ? vboxMedia.getHardDiskVariant(m) : '--');
+ $('#vmmMediumType').val(m ? trans(m.type,'VBoxGlobal') : '--');
+
+ if(m && m.parent) {
+ $('#vmmMediumType').val(trans('Differencing','VBoxGlobal'));
+ }
+
+ // Attached To val
+ var attch = null;
+ var attchElm = $('#vboxVirtualMediaManager').find('.vmmMediumAttachedTo');
+ attchElm.css({'font-style':''});
+ if(m) {
+ attch = vboxMedia.attachedTo(m,true);
+ if(!attch) {
+ attch = trans('Not Attached','UIGDetails','details (storage)');
+ attchElm.css({'font-style':'italic'});
+ }
+ attchElm.val(attch);
+ } else {
+ attchElm.val('--');
+ }
+
+ // UUID
+ $('#vboxVirtualMediaManager').find('.vmmMediumUUID').val(m ? m.id : '--');
+
+ if(m && m.state == 'Inaccessible' && m.lastAccessError) {
+ $('#vboxVirtualMediaManager').find('tr.vmmAccessErr').css({'display':''}).children().html(m.lastAccessError);
+ } else {
+ $('#vboxVirtualMediaManager').find('tr.vmmAccessErr').css({'display':'none'}).children().html('');
+ }
+}
+
+// Update items on mediumselect
+$('#vboxVirtualMediaManager').on('mediumselect',function(e,m){
+ vmmToolbar.update(m);
+ vboxVMMMediaInfo(m);
+ vmmMenu.update(m);
+ vmmCMenu.update(m);
+});
+
+/*
+ * Add medium to a table
+ */
+function vboxVMMAddMedium(d,depth,hideDiff,topLevelParent) {
+
+ var tr = $('<tr />').data({'medium':d.id,'mediumname':d.name,'mediumsize':d.size,'mediumlogicalSize':d.logicalSize})
+ .attr({'id':'vboxVMMMedium'+(d.id),'class':'vboxListItem collapsed','title':d.id})
+ .hover(function(){
+ if(!$(this).hasClass('vboxListItemSelected'))
+ $(this).addClass('vboxHover');
+ },function(){
+ $(this).removeClass('vboxHover');
+ }
+ )
+ .addClass('vboxVMMTopLevel'+(topLevelParent ? topLevelParent : '0')+' vboxVMMChildOf'+(d.parent ? d.parent : '0') +' vboxVMMChildDepth'+depth)
+ .contextMenu({
+ menu: vmmCMenu.menuId(),
+ menusetup : function(el) {
+ if(!$(el).hasClass('vboxListItemSelected')) $(el).children().first().trigger('click');
+ }
+ },vmmCMenu.menuClickCallback);
+
+
+ if(d.children && d.children.length && !hideDiff) $(tr).addClass('vboxVMMParent');
+ if(d.parent) $(tr).addClass('vboxHidden').attr('style','display: none');
+
+ /* Expand / collapse button and/or spacers */
+ var td = $('<td />').addClass('vboxHoverFirst');
+
+ // Add spacer image to pad for depth
+ if(depth) {
+ for(var i = 0; i < depth; i++) {
+ $('<img />').attr({'class':'vboxVMMSpacer','src':'images/vbox/blank.gif'}).appendTo(td);
+ }
+ }
+
+ // Show / hide children button
+ if(d.children && d.children.length && !hideDiff) {
+
+ $('<input />').attr({'type':'button','class':'vboxImgButton vboxVMMMediaExpand','style':'background-image: url(images/vbox/arrow_right_10px.png)'}).click(function(){
+
+ if(!$(this).data('toggleClicked')) {
+
+ $(this).data('toggleClicked', true);
+ $(this).css({'background-image':'url(images/vbox/arrow_down_10px.png)'});
+ $(this).closest('tr').toggleClass('collapsed').trigger('showChildren',true);
+
+ } else {
+ $(this).data('toggleClicked', false);
+ $(this).css({'background-image':'url(images/vbox/arrow_right_10px.png)'});
+ $(this).closest('tr').toggleClass('collapsed').trigger('hideChildren',true);
+ }
+
+ return false;
+
+ }).appendTo(td);
+
+ } else if(depth) {
+ $('<img />').attr({'class':'vboxVMMSpacer','src':'images/vbox/blank.gif'}).appendTo(td);
+ }
+
+ // Title div
+ var span = $('<span />').attr({'id':'vboxVMMMediaTitle-'+d.id}).html($('<div />').html(d.name).text());
+
+ // Add read-only or inaccessible class?
+ if(d.state == 'Inaccessible') {
+ $(span).addClass('vboxMediumInaccessible');
+ } else if(hideDiff !== undefined && d.readOnly) {
+ $(span).addClass('vboxMediumReadOnly');
+ }
+
+ $(td).append(span).appendTo(tr);
+
+ // Set target list
+ //////////////////////
+ var target = '';
+ switch(d.deviceType) {
+ case 'HardDisk':
+ // Logical size column
+ $('<td />').addClass('vboxHoverMid').append($('<span />').html(vboxMbytesConvert(d.logicalSize))).appendTo(tr);
+ target = '#vboxVMMHDList';
+ break;
+ case 'DVD':
+ target = '#vboxVMMCDList';
+ break;
+ case 'Floppy':
+ target = '#vboxVMMFDList';
+ break;
+ }
+
+ // Size column
+ $('<td />').addClass('vboxHoverLast').append($('<div />').html(vboxBytesConvert(d.size))).appendTo(tr);
+
+ /* Show / hide children of this medium */
+ $(tr).on('showChildren',function(e,first){
+
+ var thisid = $(this).data('medium');
+ var trTarget = this;
+
+ if($(this).hasClass('collapsed') || !$(this).hasClass('vboxVMMParent')) return;
+
+ $(trTarget).siblings('tr.vboxVMMChildOf'+thisid).show().removeClass('vboxHidden').trigger('showChildren',false);
+
+ // Only set by original button click
+ if(first) { vboxColorRows($('#vboxVMMHDList')); vboxVMMTableHeaderSetup($('#vmmDisks')); }
+
+ }).on('hideChildren',function(e,first){
+
+ if(!$(this).hasClass('vboxVMMParent')) return;
+
+ $(this).siblings('tr.vboxVMMChildOf'+$(this).data('medium')).hide().addClass('vboxHidden').trigger('hideChildren',false);
+
+ // Only set by original button click
+ if(first) { vboxColorRows($('#vboxVMMHDList')); vboxVMMTableHeaderSetup($('#vmmDisks'));}
+
+
+ }).children().click(function(){
+ $(this).parent().removeClass('vboxListItem vboxHover').addClass('vboxListItemSelected')
+ .siblings().removeClass('vboxListItemSelected').addClass('vboxListItem');
+ $('#vboxVirtualMediaManager').trigger('mediumselect',[$(this).parent()]);
+ });
+
+ $(target).append(tr);
+
+ if(d.children && d.children.length) {
+ if(depth) depth++;
+ else depth = 1;
+ for(var i = 0; i < d.children.length; i++) {
+ vboxVMMAddMedium(d.children[i],depth,hideDiff,(topLevelParent ? topLevelParent : d.id));
+ }
+ }
+}
+
+/* Fill medium tables and info with Medium info */
+function vboxVMMFillMedia(sel) {
+
+ // Remove stub items
+ $('#vboxVMMHDList').children().remove();
+ $('#vboxVMMCDList').children().remove();
+ $('#vboxVMMFDList').children().remove();
+
+ // Set icons
+ $('#vmmDisksIcon').attr('src','images/vbox/hd_16px.png');
+ $('#vmmCDsIcon').attr('src','images/vbox/cd_16px.png');
+ $('#vmmFloppysIcon').attr('src','images/vbox/fd_16px.png');
+
+ var media = $('#vboxPane').data('vboxMedia').sort(function(a,b) {
+ return strnatcasecmp(a.name,b.name);
+ });
+
+ var hideDiff = $('#vboxVirtualMediaManager').data('hideDiff');
+
+ for(var i in media) {
+ vboxVMMAddMedium(media[i],0,hideDiff,media[i].parent);
+ if(media[i].state == 'Inaccessible') {
+ var elm = null;
+ switch(media[i].deviceType) {
+ case 'HardDisk':
+ elm = $('#vmmDisksIcon');
+ break;
+ case 'DVD':
+ elm = $('#vmmCDsIcon');
+ break;
+ default:
+ elm = $('#vmmFloppysIcon');
+ }
+ elm.attr('src','images/vbox/state_aborted_16px.png');
+ }
+
+ }
+
+ vboxVMMTableHeaderSetup($('#vmmDisks'));
+ vboxVMMTableHeaderSetup($('#vmmCDs'));
+ vboxVMMTableHeaderSetup($('#vmmFloppys'));
+
+ // Select medium?
+ if(sel) {
+
+ $('#vboxVMMMedium'+sel).children().first().click();
+
+ } else {
+ $('#vboxVirtualMediaManager').trigger('mediumselect',null);
+ }
+ vboxVMMTableSort($('#vboxVMMHDList'));
+ vboxVMMTableSort($('#vboxVMMFDList'));
+ vboxVMMTableSort($('#vboxVMMCDList'));
+
+
+}
+
+/*
+ *
+ * Sort table according to selected items
+ *
+ */
+function vboxVMMTableSort(t) {
+
+ // Get Selected Heading and sort order
+ ////////////////////////////////////////
+ var ths = $(t).closest('div').siblings('div.vmmTableHead').find('thead').find('th');
+ var cthIndex = 0;
+ var sortOrder = null;
+ for(var i = 0; i < ths.length; i++) {
+ if($(ths[i]).data('sorted')) {
+ cthIndex = i;
+ sortOrder = $(ths[i]).data('sorted');
+ break;
+ }
+ }
+ ths =null;
+
+ // Sort table
+ ///////////////////////
+ $(t).each(function(){
+
+ // Sort function (vboxVMMChildOf0 are top-level)
+ var rows = $(this).find('tr.vboxVMMChildOf0').get();
+ switch(cthIndex) {
+ // Name
+ case 0:
+ rows.sort(function(a,b){
+ return strnatcasecmp($(a).data('mediumname'),$(b).data('mediumname'));
+ });
+ break;
+ // size or logical size
+ default:
+
+ // HD has an extra column for logical size
+
+ // size
+ var sortOpt = ($("#vboxVMMTabs").tabs('option','active') ? '' : 'HD');
+ if(sortOpt == 'HD' && cthIndex == 2 || (sortOpt != 'HD')) {
+ rows.sort(function(a,b){
+ if($(a).data('mediumsize') == $(b).data('mediumsize')) return 0;
+ return (parseInt($(a).data('mediumsize')) > parseInt($(b).data('mediumsize')) ? 1 : -1);
+ });
+ // logical size
+ } else {
+ rows.sort(function(a,b){
+ if($(a).data('mediumlogicalSize') == $(b).data('mediumlogicalSize')) return 0;
+ return (parseInt($(a).data('mediumlogicalSize')) > parseInt($(b).data('mediumlogicalSize')) ? 1 : -1);
+ });
+ }
+ break;
+ }
+ // reverse?
+ if(sortOrder == 'asc') rows.reverse();
+
+ // Append rows and children
+ var target = $(this);
+ $(rows).each(function(){
+ // top-level (parent) medium
+ $(this).detach().appendTo($(target));
+ // Children
+ $(target).find('tr.vboxVMMTopLevel'+($(this).data('medium'))).detach().appendTo($(target));
+ });
+ vboxColorRows(target);
+ });
+
+}
+/*
+ *
+ * Resizing and setup
+ *
+ */
+
+function vboxVMMSizeTable(elm) {
+
+ // Hide table body
+ var TB = $(elm).find('div.vmmTableBody');
+
+ TB.css({'display':'none'});
+
+ // Get height
+ var cH = $(elm).parent().innerHeight() - $(elm).outerHeight(true);
+
+ // Apply to difference in height to table body
+ TB.height(cH-4).css({'display':'','overflow':'auto'});
+
+ // Set table head width
+ vboxVMMTableHeaderSetup(elm);
+
+}
+/* Setup tables */
+function vboxVMMTableHeaderSetup(elm) {
+
+ // Set column width
+
+ // Get each column width
+ var hCols = $(elm).find('div.vmmTableHead').find('tr:eq(0)').children();
+ var tCols = $(elm).find('div.vmmTableBody').find('tbody tr:eq(0)').children();
+ for(var i = 0; i < tCols.length; i++) {
+ $(hCols[i]).width($(tCols[i]).width());
+ }
+
+}
+
+
+/* Init virtual media manager */
+function vboxVMMInit(hideDiff,vmPath) {
+
+ // SEVERE hack-fooery ensues..
+ /////////////////////////////////
+ $('#vboxVirtualMediaManager').parent().on( "dialogresizestart",function(e){
+
+ $('#vboxVMMTabs').css({'height':'auto'});
+ $('#vboxVMMContainer').css({'height':'auto'});
+
+ }).on("dialogresizestop",function(e){
+
+ $('#vmmDisks .vmmTableBody').css({'display':'none'});
+ $('#vmmCDs .vmmTableBody').css({'display':'none'});
+ $('#vmmFloppys .vmmTableBody').css({'display':'none'});
+
+ $('#vboxVMMContainer').height($('#vboxVMMContainer').height());
+ $('#vboxVMMTabs').height($('#vboxVMMContainer').innerHeight());
+
+ vboxVMMSizeTable($('#vmmDisks'));
+ vboxVMMSizeTable($('#vmmCDs'));
+ vboxVMMSizeTable($('#vmmFloppys'));
+ });
+
+ $('#vboxVMMTabList').css({'border-bottom':'0px','margin-bottom':'0px','padding-bottom':'0px'}).detach().appendTo($('#vboxVMMContainerTop').attr({'class':$('#vboxVMMTabs').css({'border-top':'0px','margin-top':'0px','padding-top':'0px'}).removeClass('ui-corner-all').attr('class')}));
+
+ $('#vboxVMMContainer').height($('#vboxVMMContainer').height()).css({'padding':'0px','margin':'0px'});
+ $('#vboxVMMTabs').height($('#vboxVMMContainer').innerHeight()).css({'padding-top':'0px','padding-bottom':'0px','margin-top':'0px','margin-bottom':'0px'});
+
+ // Resize disks table body
+ vboxVMMSizeTable($('#vmmDisks'));
+
+ // Save options for later
+ $('#vboxVirtualMediaManager').data('hideDiff', hideDiff);
+ $('#vboxVirtualMediaManager').data('vmPath', vmPath);
+
+ // Column sorting
+ ////////////////////////////
+ $("#vboxVirtualMediaManager div.vmmTableHead thead th").each(function(thIndex){
+
+ // Skip last column header. It is just kept for spacing
+ if($(this).children('img').length) return true;
+
+ $(this).hover(function(){
+ $(this).children('img').css({'visibility':'visible'});
+ },function(){
+ if($(this).data('sorted')) return;
+ $(this).children('img').css({'visibility':'hidden'});
+
+ }).addClass('vboxVMMSortImgFaded').append(' ').append($('<img />').attr({'src':'images/upArrow.png','style':'visibility:hidden;cursor:pointer'}).click(function(e,sortDefault){
+
+ var p = $(this).parent();
+
+ // Get current sort order and set accordingly
+ //////////////////////////////////////////////
+ switch(p.data('sorted')) {
+ case 'asc':
+ $(this).attr({'src':'images/upArrow.png'}).css({'visibility':'visible'});
+ p.data('sorted','desc');
+ break;
+ case 'desc':
+ $(this).attr({'src':'images/downArrow.png'}).css({'visibility':'visible'});
+ p.data('sorted','asc');
+ break;
+ default:
+ p.data({'sorted':'desc'}).removeClass('vboxVMMSortImgFaded').siblings().data({'sorted':null}).addClass('vboxVMMSortImgFaded').children('img').attr({'src':'images/upArrow.png'}).css({'visibility':'hidden'});
+ break;
+ }
+
+ vboxVMMTableSort($(p).closest('div').siblings('div.vmmTableBody').find('tbody').first());
+
+ }));
+
+ // Default is sort by name
+ if($(this).index() == 0) {
+ $(this).data({'sorted':'desc'}).removeClass('vboxVMMSortImgFaded').children('img').css({'visibility':'visible'});
+ }
+
+
+ });
+
+ vboxVMMFillMedia();
+
+}
+
+
+</script>
+
+
diff --git a/panes/vmmISCSI.html b/panes/vmmISCSI.html
index d259fef..c7fe86d 100644
--- a/panes/vmmISCSI.html
+++ b/panes/vmmISCSI.html
@@ -1,51 +1,51 @@
-<!--
- Add iSCSI disk dialog
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: vmmISCSI.html 595 2015-04-17 09:50:36Z imoore76 $
-
- -->
-<div id='vboxISCSI'>
- <form name='vboxISCSIForm' style='width:100%;'>
- <table class='vboxVertical' style='width: 100%;'>
- <tr>
- <th><span class='translate'>Server</span>:</th>
- <td><input type='text' name='vboxISCSIServer' class='vboxText' /></td>
- </tr>
- <tr>
- <th><span class='translate'>Port</span>:</th>
- <td><input type='text' name='vboxISCSIPort' class='vboxText' /></td>
- </tr>
- <tr>
- <th></th>
- <td><label><input type='checkbox' name='vboxISCSIIntnet' class='vboxCheckbox' /> <span class='translate'>Internal Networking</span></label></td>
- </tr>
- <tr>
- <th><span class='translate'>Target</span>:</th>
- <td><input type='text' name='vboxISCSITarget' class='vboxText' /></td>
- </tr>
- <tr>
- <th><span class='translate'>LUN</span>:</th>
- <td><input type='text' name='vboxISCSILun' class='vboxText' value="0" /></td>
- </tr>
- <tr>
- <th></th>
- <td><label><input type='checkbox' name='vboxISCSILunEnc' class='vboxCheckbox' /> <span class='translate'>Encoded</span></label></td>
- </tr>
- <tr>
- <th><span class='translate'>Username</span>:</th>
- <td><input type='text' name='vboxISCSIUser' class='vboxText' /></td>
- </tr>
- <tr>
- <th><span class='translate'>Password</span>:</th>
- <td><input type='password' name='vboxISCSIPass' class='vboxText' /></td>
- </tr>
- </table>
- </form>
-</div>
-<script type='text/javascript'>
-
-// Translations
-$('#vboxISCSI').find(".translate").html(function(i,h){return trans(h,'vboxISCSI');}).removeClass('translate');
-
+<!--
+ Add iSCSI disk dialog
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: vmmISCSI.html 595 2015-04-17 09:50:36Z imoore76 $
+
+ -->
+<div id='vboxISCSI'>
+ <form name='vboxISCSIForm' style='width:100%;'>
+ <table class='vboxVertical' style='width: 100%;'>
+ <tr>
+ <th><span class='translate'>Server</span>:</th>
+ <td><input type='text' name='vboxISCSIServer' class='vboxText' /></td>
+ </tr>
+ <tr>
+ <th><span class='translate'>Port</span>:</th>
+ <td><input type='text' name='vboxISCSIPort' class='vboxText' /></td>
+ </tr>
+ <tr>
+ <th></th>
+ <td><label><input type='checkbox' name='vboxISCSIIntnet' class='vboxCheckbox' /> <span class='translate'>Internal Networking</span></label></td>
+ </tr>
+ <tr>
+ <th><span class='translate'>Target</span>:</th>
+ <td><input type='text' name='vboxISCSITarget' class='vboxText' /></td>
+ </tr>
+ <tr>
+ <th><span class='translate'>LUN</span>:</th>
+ <td><input type='text' name='vboxISCSILun' class='vboxText' value="0" /></td>
+ </tr>
+ <tr>
+ <th></th>
+ <td><label><input type='checkbox' name='vboxISCSILunEnc' class='vboxCheckbox' /> <span class='translate'>Encoded</span></label></td>
+ </tr>
+ <tr>
+ <th><span class='translate'>Username</span>:</th>
+ <td><input type='text' name='vboxISCSIUser' class='vboxText' /></td>
+ </tr>
+ <tr>
+ <th><span class='translate'>Password</span>:</th>
+ <td><input type='password' name='vboxISCSIPass' class='vboxText' /></td>
+ </tr>
+ </table>
+ </form>
+</div>
+<script type='text/javascript'>
+
+// Translations
+$('#vboxISCSI').find(".translate").html(function(i,h){return trans(h,'vboxISCSI');}).removeClass('translate');
+
</script> \ No newline at end of file
diff --git a/panes/vmmModify.html b/panes/vmmModify.html
index cad0a33..f94b326 100644
--- a/panes/vmmModify.html
+++ b/panes/vmmModify.html
@@ -1,34 +1,34 @@
-<!--
- Modify Medium dialog
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: vmmModify.html 595 2015-04-17 09:50:36Z imoore76 $
-
- -->
-<div id='vboxVMMModify'>
-
- <div id='vboxVMMModifyInstructions'></div>
-
- <span class='vboxTableLabel translate'>Choose medium type:</span>
- <div class='vboxBordered'>
- <form name='vboxVMMModifyForm' style='width:100%;'>
- <table class='vboxOptions' style='margin-top: 6px;'>
- <tr>
- <td><label><input type='radio' class='vboxRadio' name='vmmMType' value='Normal' id='vbRadioNormal'/> <span>Normal</span></label></td>
- </tr>
- <tr >
- <td><label><input type='radio' class='vboxRadio' name='vmmMType' value='Immutable' id='vbRadioImmutable'/> <span>Immutable</span></label></td>
- </tr>
- <tr >
- <td><label><input type='radio' class='vboxRadio' name='vmmMType' value='Writethrough' id='vbRadioWritethrough'/> <span>Writethrough</span></label></td>
- </tr>
- <tr >
- <td><label><input type='radio' class='vboxRadio' name='vmmMType' value='Shareable' id='vbRadioShareable'/> <span>Shareable</span></label></td>
- </tr>
- <tr >
- <td><label><input type='radio' class='vboxRadio' name='vmmMType' value='MultiAttach' id='vbRadioMultiAttach'/> <span>Multi-attach</span></label></td>
- </tr>
- </table>
- </form>
- </div>
-</div>
+<!--
+ Modify Medium dialog
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: vmmModify.html 595 2015-04-17 09:50:36Z imoore76 $
+
+ -->
+<div id='vboxVMMModify'>
+
+ <div id='vboxVMMModifyInstructions'></div>
+
+ <span class='vboxTableLabel translate'>Choose medium type:</span>
+ <div class='vboxBordered'>
+ <form name='vboxVMMModifyForm' style='width:100%;'>
+ <table class='vboxOptions' style='margin-top: 6px;'>
+ <tr>
+ <td><label><input type='radio' class='vboxRadio' name='vmmMType' value='Normal' id='vbRadioNormal'/> <span>Normal</span></label></td>
+ </tr>
+ <tr >
+ <td><label><input type='radio' class='vboxRadio' name='vmmMType' value='Immutable' id='vbRadioImmutable'/> <span>Immutable</span></label></td>
+ </tr>
+ <tr >
+ <td><label><input type='radio' class='vboxRadio' name='vmmMType' value='Writethrough' id='vbRadioWritethrough'/> <span>Writethrough</span></label></td>
+ </tr>
+ <tr >
+ <td><label><input type='radio' class='vboxRadio' name='vmmMType' value='Shareable' id='vbRadioShareable'/> <span>Shareable</span></label></td>
+ </tr>
+ <tr >
+ <td><label><input type='radio' class='vboxRadio' name='vmmMType' value='MultiAttach' id='vbRadioMultiAttach'/> <span>Multi-attach</span></label></td>
+ </tr>
+ </table>
+ </form>
+ </div>
+</div>
diff --git a/panes/wizardCloneVM.html b/panes/wizardCloneVM.html
index a7e67f1..ea613f7 100644
--- a/panes/wizardCloneVM.html
+++ b/panes/wizardCloneVM.html
@@ -1,125 +1,128 @@
-<!--
-
- Panes for clone virtual machine wizard. Logic in vboxWizard()
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: wizardCloneVM.html 595 2015-04-17 09:50:36Z imoore76 $
-
- -->
-<!-- Step 1 -->
-<div id='wizardCloneVMStep1' title='New machine name' style='display: none'>
-
- <span id='vboxWizCloneMessage1'></span>
-
- <div class='vboxOptions' style='padding: 6px'>
- <input type='text' class='vboxText' name='machineCloneName' style='width: 95%' />
-
- <p><label><input type='checkbox' class='vboxCheckbox' name='vboxCloneReinitNetwork' />
- <span class='translate'>Reinitialize the MAC address of all network cards</span></label>
- </p>
- </div>
-
-</div>
-
-
-<!-- Step 2 -->
-<div id='wizardCloneVMStep2' title='Clone type' style='display: none'>
-
- <span class='translate'>&lt;p&gt;Please choose the type of clone you wish to create.&lt;/p&gt;&lt;p&gt;If you choose &lt;b&gt;Full clone&lt;/b&gt;, an exact copy (including all virtual hard disk files) of the original virtual machine will be created.&lt;/p&gt;&lt;p&gt;If you choose &lt;b&gt;Linked clone&lt;/b&gt;, a new machine will be created, but the virtual hard disk files will be tied to the virtual hard disk files of original machine and you will not be able to move the new virtual machine to a different computer without moving the original as well.&lt;/p&gt;</span>
-
- <span class='translate' id='vboxCloneVMNewSnap'>&lt;p&gt;If you create a &lt;b&gt;Linked clone&lt;/b&gt; then a new snapshot will be created in the original virtual machine as part of the cloning process.&lt;/p&gt;</span>
-
- <div class='vboxOptions'>
- <table>
- <tr style='vertical-align: bottom;'>
- <td><label><input type='radio' class='vboxRadio' checked='checked' name='vboxCloneType' value='Full' onclick='vboxCloneVMUpdateSteps(this.value)' /> <span class='translate'>Full Clone</span></label></td>
- </tr>
- <tr style='vertical-align: bottom;'>
- <td><label><input type='radio' class='vboxRadio' name='vboxCloneType' value='Linked' onclick='vboxCloneVMUpdateSteps(this.value)' /> <span class='translate'>Linked Clone</span></label></td>
- </tr>
- </table>
- </div>
-</div>
-
-<!-- Step 3 -->
-<div id='wizardCloneVMStep3' title='Snapshots' style='display: none'>
-
- <span class='translate'>&lt;p&gt;Please choose which parts of the snapshot tree should be cloned with the machine.&lt;/p&gt;</span>
-
- <p><span class='translate'>&lt;p&gt;If you choose &lt;b&gt;Current machine state&lt;/b&gt;, the new machine will reflect the current state of the original machine and will have no snapshots.&lt;/p&gt;</span>
- <span class='translate' id='wizardCloneVMCurrentAll' style='display: none;'>&lt;p&gt;If you choose &lt;b&gt;Current snapshot tree branch&lt;/b&gt;, the new machine will reflect the current state of the original machine and will have matching snapshots for all snapshots in the tree branch starting at the current state in the original machine.&lt;/p&gt;</span>
- <span class='translate'>&lt;p&gt;If you choose &lt;b&gt;Everything&lt;/b&gt;, the new machine will reflect the current state of the original machine and will have matching snapshots for all snapshots in the original machine.&lt;/p&gt;</span>
- </p>
-
- <div class='vboxOptions'>
- <table>
- <tr style='vertical-align: bottom;'>
- <td><label><input type='radio' class='vboxRadio' checked='checked' name='vmState' value='MachineState' /> <span class='translate'>Current machine state</span></label></td>
- </tr>
- <tr style='vertical-align: bottom; display:none;' id='vboxCloneCurrentAll'>
- <td><label><input type='radio' class='vboxRadio' name='vmState' value='MachineAndChildStates' /> <span class='translate'>Current snapshot tree branch</span></label></td>
- </tr>
- <tr style='vertical-align: bottom;'>
- <td><label><input type='radio' class='vboxRadio' name='vmState' value='AllStates' /> <span class='translate'>Everything</span></label></td>
- </tr>
- </table>
- </div>
-</div>
-
-
-
-<script type='text/javascript'>
-
-$('#wizardCloneVMStep1').on('show',function(e,wiz){
-
- // Already initialized?
- if($('#wizardCloneVMStep1').data('init') || !wiz.args) return;
-
- $('#wizardCloneVMStep1').data('init',1);
-
- // Hold wizard
- $('#wizardCloneVMStep1').data('wiz',wiz);
-
- // Hold wizard original steps
- $('#wizardCloneVMStep1').data('wizSteps',wiz.steps);
-
- // Hide "new snapshot" message if we're cloning a snapshot
- if(wiz.args && wiz.args.snapshot)
- $('#vboxCloneVMNewSnap').hide();
-
- $('#vboxWizCloneMessage1').html(trans('<p>Please choose a name for the new virtual machine. The new machine will be a clone of the machine <b>%1</b>.</p>','UIWizardCloneVM').replace('%1',wiz.args.vm.name));
-
-
- if((wiz.args.snapshot && wiz.args.snapshot.children && wiz.args.snapshot.children.length)) {
- $('#wizardCloneVMCurrentAll').show();
- $('#vboxCloneCurrentAll').show();
- }
-
- $(document.forms['frmwizardCloneVM'].elements.machineCloneName).focus();
- document.forms['frmwizardCloneVM'].elements.machineCloneName.value = trans('%1 Clone','UIWizardCloneVMPage1').replace('%1',wiz.args.vm.name);
-});
-
-/* When going to step2, make sure a name is entered */
-$('#wizardCloneVMStep2').on('show',function(e,wiz){
-
- document.forms['frmwizardCloneVM'].elements.machineCloneName.value = jQuery.trim(document.forms['frmwizardCloneVM'].elements.machineCloneName.value);
-
- if(!document.forms['frmwizardCloneVM'].elements.machineCloneName.value) {
- // Go back
- wiz.displayStep(1);
- }
-
-
-
-});
-
-function vboxCloneVMUpdateSteps(cval) {
-
- if(cval == 'Linked') {
- $('#wizardCloneVMStep1').data('wiz').setLast();
- } else if($('#wizardCloneVMStep1').data('wizSteps') != $('#wizardCloneVMStep1').data('wiz').steps) {
- $('#wizardCloneVMStep1').data('wiz').unsetLast();
- }
-}
-
-</script>
+<!--
+
+ Panes for clone virtual machine wizard. Logic in vboxWizard()
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: wizardCloneVM.html 595 2015-04-17 09:50:36Z imoore76 $
+
+ -->
+<!-- Step 1 -->
+<div id='wizardCloneVMStep1' title='New machine name' style='display: none'>
+
+ <span id='vboxWizCloneMessage1'></span>
+
+ <div class='vboxOptions' style='padding: 6px'>
+ <input type='text' class='vboxText' name='machineCloneName' style='width: 95%' />
+
+ <p><label><input type='checkbox' class='vboxCheckbox' name='vboxCloneReinitNetwork' checked='checked' />
+ <span class='translate'>Reinitialize the MAC address of all network cards</span></label>
+ </p>
+ </div>
+
+</div>
+
+
+<!-- Step 2 -->
+<div id='wizardCloneVMStep2' title='Clone type' style='display: none'>
+
+ <span class='translate'>&lt;p&gt;Please choose the type of clone you wish to create.&lt;/p&gt;&lt;p&gt;If you choose &lt;b&gt;Full clone&lt;/b&gt;, an exact copy (including all virtual hard disk files) of the original virtual machine will be created.&lt;/p&gt;&lt;p&gt;If you choose &lt;b&gt;Linked clone&lt;/b&gt;, a new machine will be created, but the virtual hard disk files will be tied to the virtual hard disk files of original machine and you will not be able to move the new virtual machine to a different computer without moving the original as well.&lt;/p&gt;</span>
+
+ <span class='translate' id='vboxCloneVMNewSnap'>&lt;p&gt;If you create a &lt;b&gt;Linked clone&lt;/b&gt; then a new snapshot will be created in the original virtual machine as part of the cloning process.&lt;/p&gt;</span>
+
+ <div class='vboxOptions'>
+ <table>
+ <tr style='vertical-align: bottom;'>
+ <td><label><input type='radio' class='vboxRadio' name='vboxCloneType' value='Full' onclick='vboxCloneVMUpdateSteps(this.value)' /> <span class='translate'>Full Clone</span></label></td>
+ </tr>
+ <tr style='vertical-align: bottom;'>
+ <td><label><input type='radio' class='vboxRadio' checked='checked' name='vboxCloneType' value='Linked' onclick='vboxCloneVMUpdateSteps(this.value)' /> <span class='translate'>Linked Clone</span></label></td>
+ </tr>
+ </table>
+ </div>
+</div>
+
+<!-- Step 3 -->
+<div id='wizardCloneVMStep3' title='Snapshots' style='display: none'>
+
+ <span class='translate'>&lt;p&gt;Please choose which parts of the snapshot tree should be cloned with the machine.&lt;/p&gt;</span>
+
+ <p><span class='translate'>&lt;p&gt;If you choose &lt;b&gt;Current machine state&lt;/b&gt;, the new machine will reflect the current state of the original machine and will have no snapshots.&lt;/p&gt;</span>
+ <span class='translate' id='wizardCloneVMCurrentAll' style='display: none;'>&lt;p&gt;If you choose &lt;b&gt;Current snapshot tree branch&lt;/b&gt;, the new machine will reflect the current state of the original machine and will have matching snapshots for all snapshots in the tree branch starting at the current state in the original machine.&lt;/p&gt;</span>
+ <span class='translate'>&lt;p&gt;If you choose &lt;b&gt;Everything&lt;/b&gt;, the new machine will reflect the current state of the original machine and will have matching snapshots for all snapshots in the original machine.&lt;/p&gt;</span>
+ </p>
+
+ <div class='vboxOptions'>
+ <table>
+ <tr style='vertical-align: bottom;'>
+ <td><label><input type='radio' class='vboxRadio' checked='checked' name='vmState' value='MachineState' /> <span class='translate'>Current machine state</span></label></td>
+ </tr>
+ <tr style='vertical-align: bottom; display:none;' id='vboxCloneCurrentAll'>
+ <td><label><input type='radio' class='vboxRadio' name='vmState' value='MachineAndChildStates' /> <span class='translate'>Current snapshot tree branch</span></label></td>
+ </tr>
+ <tr style='vertical-align: bottom;'>
+ <td><label><input type='radio' class='vboxRadio' name='vmState' value='AllStates' /> <span class='translate'>Everything</span></label></td>
+ </tr>
+ </table>
+ </div>
+</div>
+
+
+
+<script type='text/javascript'>
+
+$('#wizardCloneVMStep1').on('show',function(e,wiz){
+
+ // Already initialized?
+ if($('#wizardCloneVMStep1').data('init') || !wiz.args) return;
+
+ $('#wizardCloneVMStep1').data('init',1);
+
+ // Hold wizard
+ $('#wizardCloneVMStep1').data('wiz',wiz);
+
+ // Hold wizard original steps
+ $('#wizardCloneVMStep1').data('wizSteps',wiz.steps);
+
+ // Hide "new snapshot" message if we're cloning a snapshot
+ if(wiz.args && wiz.args.snapshot)
+ $('#vboxCloneVMNewSnap').hide();
+
+ $('#vboxWizCloneMessage1').html(trans('<p>Please choose a name for the new virtual machine. The new machine will be a clone of the machine <b>%1</b>.</p>','UIWizardCloneVM').replace('%1',wiz.args.vm.name));
+
+
+ if((wiz.args.snapshot && wiz.args.snapshot.children && wiz.args.snapshot.children.length)) {
+ $('#wizardCloneVMCurrentAll').show();
+ $('#vboxCloneCurrentAll').show();
+ }
+
+ $(document.forms['frmwizardCloneVM'].elements.machineCloneName).focus();
+ document.forms['frmwizardCloneVM'].elements.machineCloneName.value = trans('%1 Clone','UIWizardCloneVMPage1').replace('%1',wiz.args.vm.name);
+
+ var inputBox = $('#wizardCloneVMStep1').find('input.vboxText').select();
+ setTimeout(inputBox.focus.bind(inputBox),10);
+});
+
+/* When going to step2, make sure a name is entered */
+$('#wizardCloneVMStep2').on('show',function(e,wiz){
+
+ document.forms['frmwizardCloneVM'].elements.machineCloneName.value = jQuery.trim(document.forms['frmwizardCloneVM'].elements.machineCloneName.value);
+
+ if(!document.forms['frmwizardCloneVM'].elements.machineCloneName.value) {
+ // Go back
+ wiz.displayStep(1);
+ }
+
+
+
+});
+
+function vboxCloneVMUpdateSteps(cval) {
+
+ if(cval == 'Linked') {
+ $('#wizardCloneVMStep1').data('wiz').setLast();
+ } else if($('#wizardCloneVMStep1').data('wizSteps') != $('#wizardCloneVMStep1').data('wiz').steps) {
+ $('#wizardCloneVMStep1').data('wiz').unsetLast();
+ }
+}
+
+</script>
diff --git a/panes/wizardCloneVMAdvanced.html b/panes/wizardCloneVMAdvanced.html
index 5eb11bd..508d2b3 100644
--- a/panes/wizardCloneVMAdvanced.html
+++ b/panes/wizardCloneVMAdvanced.html
@@ -1,97 +1,100 @@
-<!--
-
- Advanced panes for clone virtual machine wizard. Logic in vboxWizard()
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: wizardCloneVMAdvanced.html 595 2015-04-17 09:50:36Z imoore76 $
-
- -->
-<!-- Step 1 -->
-<div id='wizardCloneVMStep1' style='display: none'>
-
- <span class='vboxTableLabel translate'>New machine name</span>
- <div class='vboxOptions' style='padding: 6px; padding-top: 8px;'>
- <input type='text' class='vboxText' name='machineCloneName' style='width: 95%' />
- </div>
-
- <table class='vboxInvisible' style='border: 0px solid transparent; border-spacing: 4px;'>
- <tr style='vertical-align: top'>
- <td>
- <span class='vboxTableLabel translate'>Clone type</span>
- <div class='vboxOptions'>
- <table style='margin-top: 8px'>
- <tr style='vertical-align: bottom;'>
- <td><label><input type='radio' class='vboxRadio' checked='checked' name='vboxCloneType' value='Full' onclick='vboxCloneVMUpdateSteps(this.value)' /> <span class='translate'>Full Clone</span></label></td>
- </tr>
- <tr style='vertical-align: bottom;'>
- <td><label><input type='radio' class='vboxRadio' name='vboxCloneType' value='Linked' onclick='vboxCloneVMUpdateSteps(this.value)' /> <span class='translate'>Linked Clone</span></label></td>
- </tr>
- </table>
- </div>
- </td>
- <td>
- <span class='vboxTableLabel translate'>Snapshots</span>
- <div class='vboxOptions'>
- <table style='margin-top: 8px' class='vboxWizardCloneVMSnapshotOpts'>
- <tr style='vertical-align: bottom;'>
- <td><label><input type='radio' class='vboxRadio' checked='checked' name='vmState' value='MachineState' /> <span class='translate'>Current machine state</span></label></td>
- </tr>
- <tr style='vertical-align: bottom; display:none;' id='vboxCloneCurrentAll'>
- <td><label><input type='radio' class='vboxRadio' name='vmState' value='MachineAndChildStates' /> <span class='translate'>Current snapshot tree branch</span></label></td>
- </tr>
- <tr style='vertical-align: bottom;'>
- <td><label><input type='radio' class='vboxRadio' name='vmState' value='AllStates' /> <span class='translate'>Everything</span></label></td>
- </tr>
- </table>
- </div>
- </td>
- </tr>
- </table>
-
- <p><label><input type='checkbox' class='vboxCheckbox' name='vboxCloneReinitNetwork' />
- <span class='translate'>Reinitialize the MAC address of all network cards</span></label>
- </p>
-</div>
-
-
-<script type='text/javascript'>
-
-$('#wizardCloneVMStep1').on('show',function(e,wiz){
-
- // Already initialized?
- if($('#wizardCloneVMStep1').data('init') || !wiz.args) return;
-
- $('#wizardCloneVMStep1').data('init',1);
-
- // Hold wizard
- $('#wizardCloneVMStep1').data('wiz',wiz);
-
- // Hold wizard original steps
- $('#wizardCloneVMStep1').data('wizSteps',wiz.steps);
-
- // Hide "new snapshot" message if we're cloning a snapshot
- if(wiz.args && wiz.args.snapshot)
- $('#vboxCloneVMNewSnap').hide();
-
-
- if((wiz.args.snapshot && wiz.args.snapshot.children && wiz.args.snapshot.children.length)) {
- $('#wizardCloneVMCurrentAll').show();
- $('#vboxCloneCurrentAll').show();
- }
-
- $(document.forms['frmwizardCloneVM'].elements.machineCloneName).focus();
-
- document.forms['frmwizardCloneVM'].elements.machineCloneName.value = trans('%1 Clone','UIWizardCloneVMPage1').replace('%1',wiz.args.vm.name);
-});
-
-
-function vboxCloneVMUpdateSteps(cval) {
-
- if(cval == 'Linked') {
- $('#wizardCloneVMStep1').find('table.vboxWizardCloneVMSnapshotOpts').find('tr').addClass('disabled').find('input').prop('disabled', true);
- } else {
- $('#wizardCloneVMStep1').find('table.vboxWizardCloneVMSnapshotOpts').find('tr').removeClass('disabled').find('input').prop('disabled', false);
- }
-}
-
-</script>
+<!--
+
+ Advanced panes for clone virtual machine wizard. Logic in vboxWizard()
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: wizardCloneVMAdvanced.html 595 2015-04-17 09:50:36Z imoore76 $
+
+ -->
+<!-- Step 1 -->
+<div id='wizardCloneVMStep1' style='display: none'>
+
+ <span class='vboxTableLabel translate'>New machine name</span>
+ <div class='vboxOptions' style='padding: 6px; padding-top: 8px;'>
+ <input type='text' class='vboxText' name='machineCloneName' style='width: 95%' />
+ </div>
+
+ <table class='vboxInvisible' style='border: 0px solid transparent; border-spacing: 4px;'>
+ <tr style='vertical-align: top'>
+ <td>
+ <span class='vboxTableLabel translate'>Clone type</span>
+ <div class='vboxOptions'>
+ <table style='margin-top: 8px'>
+ <tr style='vertical-align: bottom;'>
+ <td><label><input type='radio' class='vboxRadio' name='vboxCloneType' value='Full' onclick='vboxCloneVMUpdateSteps(this.value)' /> <span class='translate'>Full Clone</span></label></td>
+ </tr>
+ <tr style='vertical-align: bottom;'>
+ <td><label><input type='radio' class='vboxRadio' checked='checked' name='vboxCloneType' value='Linked' onclick='vboxCloneVMUpdateSteps(this.value)' /> <span class='translate'>Linked Clone</span></label></td>
+ </tr>
+ </table>
+ </div>
+ </td>
+ <td>
+ <span class='vboxTableLabel translate'>Snapshots</span>
+ <div class='vboxOptions'>
+ <table style='margin-top: 8px' class='vboxWizardCloneVMSnapshotOpts'>
+ <tr style='vertical-align: bottom;'>
+ <td><label><input type='radio' class='vboxRadio' checked='checked' name='vmState' value='MachineState' /> <span class='translate'>Current machine state</span></label></td>
+ </tr>
+ <tr style='vertical-align: bottom; display:none;' id='vboxCloneCurrentAll'>
+ <td><label><input type='radio' class='vboxRadio' name='vmState' value='MachineAndChildStates' /> <span class='translate'>Current snapshot tree branch</span></label></td>
+ </tr>
+ <tr style='vertical-align: bottom;'>
+ <td><label><input type='radio' class='vboxRadio' name='vmState' value='AllStates' /> <span class='translate'>Everything</span></label></td>
+ </tr>
+ </table>
+ </div>
+ </td>
+ </tr>
+ </table>
+
+ <p><label><input type='checkbox' class='vboxCheckbox' name='vboxCloneReinitNetwork' checked='checked' />
+ <span class='translate'>Reinitialize the MAC address of all network cards</span></label>
+ </p>
+</div>
+
+
+<script type='text/javascript'>
+
+$('#wizardCloneVMStep1').on('show',function(e,wiz){
+
+ // Already initialized?
+ if($('#wizardCloneVMStep1').data('init') || !wiz.args) return;
+
+ $('#wizardCloneVMStep1').data('init',1);
+
+ // Hold wizard
+ $('#wizardCloneVMStep1').data('wiz',wiz);
+
+ // Hold wizard original steps
+ $('#wizardCloneVMStep1').data('wizSteps',wiz.steps);
+
+ // Hide "new snapshot" message if we're cloning a snapshot
+ if(wiz.args && wiz.args.snapshot)
+ $('#vboxCloneVMNewSnap').hide();
+
+
+ if((wiz.args.snapshot && wiz.args.snapshot.children && wiz.args.snapshot.children.length)) {
+ $('#wizardCloneVMCurrentAll').show();
+ $('#vboxCloneCurrentAll').show();
+ }
+
+ $(document.forms['frmwizardCloneVM'].elements.machineCloneName).focus();
+
+ document.forms['frmwizardCloneVM'].elements.machineCloneName.value = trans('%1 Clone','UIWizardCloneVMPage1').replace('%1',wiz.args.vm.name);
+
+ var inputBox = $('#wizardCloneVMStep1').find('input.vboxText').select();
+ setTimeout(inputBox.focus.bind(inputBox),10);
+});
+
+
+function vboxCloneVMUpdateSteps(cval) {
+
+ if(cval == 'Linked') {
+ $('#wizardCloneVMStep1').find('table.vboxWizardCloneVMSnapshotOpts').find('tr').addClass('disabled').find('input').prop('disabled', true);
+ } else {
+ $('#wizardCloneVMStep1').find('table.vboxWizardCloneVMSnapshotOpts').find('tr').removeClass('disabled').find('input').prop('disabled', false);
+ }
+}
+
+</script>
diff --git a/panes/wizardCopyHD.html b/panes/wizardCopyHD.html
index 657a2d3..e19d0fb 100644
--- a/panes/wizardCopyHD.html
+++ b/panes/wizardCopyHD.html
@@ -1,245 +1,245 @@
-<!--
-
- Panes for copy hard disk wizard. Logic in vboxWizard()
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: wizardCopyHD.html 595 2015-04-17 09:50:36Z imoore76 $
-
- -->
-<!-- Step 1 -->
-<div id='wizardCopyHDStep1' title='Hard disk to copy' style='display: none'>
-
- <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>
-
- <div class='vboxOptions'>
- <table class='vboxOptions'>
- <tr style='vertical-align: top;'>
- <td><select id="copyHDDiskSelectId" name="copyHDDiskSelect" onchange='wizardCopyHDUpdateName(this)'></select></td>
- <td style='width:1%' id='newVMDiskVMM'></td>
- </tr>
- </table>
- </div>
-</div>
-
-
-<!-- Step 2 -->
-<div id='wizardCopyHDStep2' title='Hard disk file type' style='display: none'>
-
- <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>
-
- <div class='vboxOptions'>
- <table class='vboxOptions'>
- <tr style='vertical-align: top;'>
- <td><label><input type='radio' class='vboxRadio' checked='checked' name='copyHDFileType' value='vdi' /> <span class='translate'>VDI (VirtualBox Disk Image)</span></label></td>
- </tr>
- <tr style='vertical-align: top;'>
- <td><label><input type='radio' class='vboxRadio' name='copyHDFileType' value='vmdk' /> <span class='translate'>VMDK (Virtual Machine Disk)</span></label></td>
- </tr>
- <tr style='vertical-align: top;'>
- <td><label><input type='radio' class='vboxRadio' name='copyHDFileType' value='vhd' /> <span class='translate'>VHD (Virtual Hard Disk)</span></label></td>
- </tr>
-
- </table>
- </div>
-
-</div>
-
-
-<!-- Step 3 -->
-<div id='wizardCopyHDStep3' title='Storage on physical hard disk' style='display: none'>
-
- <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>
-
- <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>
-
- <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>
-
- <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>
-
- <div class='vboxOptions'>
- <table class='vboxOptions'>
- <tr style='vertical-align: top;' class='vboxCreateDynamic'>
- <td><label><input type='radio' class='vboxRadio' checked='checked' name='newHardDiskType' value='dynamic' /> <span class='translate'>Dynamically allocated</span></label></td>
- </tr>
- <tr style='vertical-align: top;' class='vboxCreateFixed'>
- <td><label><input type='radio' class='vboxRadio' name='newHardDiskType' value='fixed' /> <span class='translate'>Fixed size</span></label></td>
- </tr>
- <tr style='vertical-align: top;' class='vboxCreateSplit2G'>
- <td><label><input type='checkbox' class='vboxCheckbox' name='newHardDiskSplit' /> <span class='translate'>Split into files of less than 2GB</span></label></td>
- </tr>
- </table>
- </div>
-</div>
-
-<!-- Step 4 -->
-<div id='wizardCopyHDStep4' title='New hard disk to create' style='display: none'>
-
- <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>
-
- <div class='vboxOptions'>
- <table class='vboxOptions'>
- <tr>
- <td style='width: 100%; white-space: nowrap'>
- <input type='text' class='vboxText' name='wizardCopyHDLocation' style='width: 100%'/>
- </td>
- <td style='width: 1%;' id='newVMDiskVMMDest'></td>
- </tr>
- </table>
- </div>
-
-</div>
-
-<script type='text/javascript'>
-
-
-// Fill HD type options
-var vboxHDTypesTbl = $('#wizardCopyHDStep2').find('table.vboxOptions').first();
-vboxHDTypesTbl.children().remove();
-var vboxHDTypes = $('#vboxPane').data('vboxSystemProperties').mediumFormats;
-for(var i = 0; i < vboxHDTypes.length; i++) {
- if(jQuery.inArray('CreateFixed',vboxHDTypes[i].capabilities) < 0 && jQuery.inArray('CreateDynamic',vboxHDTypes[i].capabilities) < 0) continue;
- if(jQuery.inArray('HardDisk',vboxHDTypes[i].deviceTypes) > -1) {
- 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>");
- vboxHDTypesTbl.find('tr').last().data('vboxFormat', vboxHDTypes[i]);
- }
-}
-// Select default HD format and place it at the top
-vboxHDTypesTbl.find('input[value='+$('#vboxPane').data('vboxSystemProperties').defaultHardDiskFormat+']').prop('checked',true).closest('tr').detach().prependTo(vboxHDTypesTbl);
-
-
-/* Choose virtual hard disk button */
-new vboxToolbarSingle({button: {
- 'name' : 'mselecthdbtn',
- 'label' : 'Choose a virtual hard disk file to copy...',
- 'language_context': 'UIWizardCloneVD',
- 'icon' : 'select_file',
- 'click' : function () {
- vboxMedia.actions.choose(null,'HardDisk',function(med){
- if(med) copyHDFillDisks(med.base);
- });
- }
-}}).renderTo('newVMDiskVMM');
-
-/* Choose location of new file button */
-new vboxToolbarSingle({button: {
- 'name' : 'mselecthdbtn',
- 'label' : 'Choose a location for new virtual hard disk file...',
- 'language_context': 'UIWizardNewVD',
- 'icon' : 'select_file',
- 'click' : function () {
- wizardCopyHDBrowseLocation();
- }
-}}).renderTo('newVMDiskVMMDest');
-
-
-/* Set up disk selection box */
-function copyHDFillDisks(sel) {
-
- document.forms['frmwizardCopyHD'].copyHDDiskSelect.options.length = 0;
- $(document.forms['frmwizardCopyHD'].copyHDDiskSelect).children().remove();
-
- var s = vboxMedia.mediaForAttachmentType('HardDisk');
-
- // Sort media
- s.sort(function(a,b){return strnatcasecmp(a.name,b.name);});
-
- var mediumSelects = [];
- for(var i = 0; i < s.length; i++) {
- document.forms['frmwizardCopyHD'].copyHDDiskSelect.options[i] = new Option(vboxMedia.mediumPrint(s[i]),s[i].id);
- if(s[i].readOnly && s[i].deviceType == 'HardDisk') $(document.forms['frmwizardCopyHD'].copyHDDiskSelect.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) {
- $(document.forms['frmwizardCopyHD'].copyHDDiskSelect).val(sel);
- }
-
- $(document.forms['frmwizardCopyHD'].copyHDDiskSelect).mediumselect({'type':'HardDisk','showdiff':false,'media':mediumSelects});
-
-}
-copyHDFillDisks();
-
-/* Browse for new disk location */
-function wizardCopyHDBrowseLocation() {
-
- // Get current location
- var loc = document.forms['frmwizardCopyHD'].elements.wizardCopyHDLocation.value;
- if(loc.indexOf(':') > 0) {
- // windows
- loc = loc.replace(/.*\\/,'');
- } else if(loc.indexOf('/') != -1) {
- // *nix
- loc = loc.replace(/.*\//,'');
- } else {
- // no path set, use src location
- loc = vboxDirname(vboxMedia.getMediumById($(document.forms['frmwizardCopyHD'].copyHDDiskSelect).val()).location);
- }
-
- vboxFileBrowser(loc,function(f){
- if(!f) return;
- // get file name
- file = document.forms['frmwizardCopyHD'].elements.wizardCopyHDLocation.value;
- document.forms['frmwizardCopyHD'].elements.wizardCopyHDLocation.value = f+$('#vboxPane').data('vboxConfig').DSEP+file;
- },true);
-
-}
-
-/* Update new HD name */
-function wizardCopyHDUpdateName(sel) {
- var n = $(sel).val();
- var m = vboxMedia.getMediumById(n);
- if(!m) return;
- document.forms['frmwizardCopyHD'].elements.wizardCopyHDLocation.value = trans('%1_copy','UIWizardNewVD').replace('%1',m.name.replace(/\.[^\.]+?$/,''));
-}
-
- /* Suggested Data exists */
-$('#wizardCopyHDStep1').on('show',function(e,wiz){
-
- // Already initialized?
- if($('#wizardCopyHDStep1').data('init')) return;
-
- if(wiz && wiz.suggested && wiz.suggested.medium)
- $(document.forms['frmwizardCopyHD'].copyHDDiskSelect).mediumselect({'selectMedium':wiz.suggested.medium});
-
-
- $('#wizardCopyHDStep1').data('init',true);
-
-});
-
-$('#wizardCopyHDStep2').on('show',function(e,wiz){
- wiz._lastStep = 2;
-});
-$('#wizardCopyHDStep4').on('show',function(e,wiz){
- wiz._lastStep = 4;
-});
-
-/* WHen showing step 3, show / hide split option */
-$('#wizardCopyHDStep3').on('show',function(e,wiz){
-
- var caps = new Array();
- for(var i = 0; i < document.forms['frmwizardCopyHD'].copyHDFileType.length; i++) {
- if(document.forms['frmwizardCopyHD'].copyHDFileType[i].checked) {
- caps = $(document.forms['frmwizardCopyHD'].copyHDFileType[i]).closest('tr').data('vboxFormat').capabilities;
- break;
- }
- }
-
- var capOpts = ['CreateFixed','CreateDynamic','CreateSplit2G'];
- for(var i = 0; i < capOpts.length; i++) {
- if(jQuery.inArray(capOpts[i],caps) < 0) {
- $('#wizardCopyHDStep3').find('.vbox'+capOpts[i]).hide();
- } else {
- $('#wizardCopyHDStep3').find('.vbox'+capOpts[i]).show();
- }
- }
-
- // Select first visible option
- $('#wizardCopyHDStep3').find('tr:visible').first().find('input').prop('checked',true);
-
- if($('#wizardCopyHDStep3').find('tr:visible').length == 1) {
- if(wiz._lastStep == 2) wiz.displayStep(4);
- else if(wiz._lastStep == 4) wiz.displayStep(2);
- }
-});
-
-
-</script>
+<!--
+
+ Panes for copy hard disk wizard. Logic in vboxWizard()
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: wizardCopyHD.html 595 2015-04-17 09:50:36Z imoore76 $
+
+ -->
+<!-- Step 1 -->
+<div id='wizardCopyHDStep1' title='Hard disk to copy' style='display: none'>
+
+ <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>
+
+ <div class='vboxOptions'>
+ <table class='vboxOptions'>
+ <tr style='vertical-align: top;'>
+ <td><select id="copyHDDiskSelectId" name="copyHDDiskSelect" onchange='wizardCopyHDUpdateName(this)'></select></td>
+ <td style='width:1%' id='newVMDiskVMM'></td>
+ </tr>
+ </table>
+ </div>
+</div>
+
+
+<!-- Step 2 -->
+<div id='wizardCopyHDStep2' title='Hard disk file type' style='display: none'>
+
+ <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>
+
+ <div class='vboxOptions'>
+ <table class='vboxOptions'>
+ <tr style='vertical-align: top;'>
+ <td><label><input type='radio' class='vboxRadio' checked='checked' name='copyHDFileType' value='vdi' /> <span class='translate'>VDI (VirtualBox Disk Image)</span></label></td>
+ </tr>
+ <tr style='vertical-align: top;'>
+ <td><label><input type='radio' class='vboxRadio' name='copyHDFileType' value='vmdk' /> <span class='translate'>VMDK (Virtual Machine Disk)</span></label></td>
+ </tr>
+ <tr style='vertical-align: top;'>
+ <td><label><input type='radio' class='vboxRadio' name='copyHDFileType' value='vhd' /> <span class='translate'>VHD (Virtual Hard Disk)</span></label></td>
+ </tr>
+
+ </table>
+ </div>
+
+</div>
+
+
+<!-- Step 3 -->
+<div id='wizardCopyHDStep3' title='Storage on physical hard disk' style='display: none'>
+
+ <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>
+
+ <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>
+
+ <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>
+
+ <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>
+
+ <div class='vboxOptions'>
+ <table class='vboxOptions'>
+ <tr style='vertical-align: top;' class='vboxCreateDynamic'>
+ <td><label><input type='radio' class='vboxRadio' checked='checked' name='newHardDiskType' value='dynamic' /> <span class='translate'>Dynamically allocated</span></label></td>
+ </tr>
+ <tr style='vertical-align: top;' class='vboxCreateFixed'>
+ <td><label><input type='radio' class='vboxRadio' name='newHardDiskType' value='fixed' /> <span class='translate'>Fixed size</span></label></td>
+ </tr>
+ <tr style='vertical-align: top;' class='vboxCreateSplit2G'>
+ <td><label><input type='checkbox' class='vboxCheckbox' name='newHardDiskSplit' /> <span class='translate'>Split into files of less than 2GB</span></label></td>
+ </tr>
+ </table>
+ </div>
+</div>
+
+<!-- Step 4 -->
+<div id='wizardCopyHDStep4' title='New hard disk to create' style='display: none'>
+
+ <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>
+
+ <div class='vboxOptions'>
+ <table class='vboxOptions'>
+ <tr>
+ <td style='width: 100%; white-space: nowrap'>
+ <input type='text' class='vboxText' name='wizardCopyHDLocation' style='width: 100%'/>
+ </td>
+ <td style='width: 1%;' id='newVMDiskVMMDest'></td>
+ </tr>
+ </table>
+ </div>
+
+</div>
+
+<script type='text/javascript'>
+
+
+// Fill HD type options
+var vboxHDTypesTbl = $('#wizardCopyHDStep2').find('table.vboxOptions').first();
+vboxHDTypesTbl.children().remove();
+var vboxHDTypes = $('#vboxPane').data('vboxSystemProperties').mediumFormats;
+for(var i = 0; i < vboxHDTypes.length; i++) {
+ if(jQuery.inArray('CreateFixed',vboxHDTypes[i].capabilities) < 0 && jQuery.inArray('CreateDynamic',vboxHDTypes[i].capabilities) < 0) continue;
+ if(jQuery.inArray('HardDisk',vboxHDTypes[i].deviceTypes) > -1) {
+ 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>");
+ vboxHDTypesTbl.find('tr').last().data('vboxFormat', vboxHDTypes[i]);
+ }
+}
+// Select default HD format and place it at the top
+vboxHDTypesTbl.find('input[value='+$('#vboxPane').data('vboxSystemProperties').defaultHardDiskFormat+']').prop('checked',true).closest('tr').detach().prependTo(vboxHDTypesTbl);
+
+
+/* Choose virtual hard disk button */
+new vboxToolbarSingle({button: {
+ 'name' : 'mselecthdbtn',
+ 'label' : 'Choose a virtual hard disk file to copy...',
+ 'language_context': 'UIWizardCloneVD',
+ 'icon' : 'select_file',
+ 'click' : function () {
+ vboxMedia.actions.choose(null,'HardDisk',function(med){
+ if(med) copyHDFillDisks(med.base);
+ });
+ }
+}}).renderTo('newVMDiskVMM');
+
+/* Choose location of new file button */
+new vboxToolbarSingle({button: {
+ 'name' : 'mselecthdbtn',
+ 'label' : 'Choose a location for new virtual hard disk file...',
+ 'language_context': 'UIWizardNewVD',
+ 'icon' : 'select_file',
+ 'click' : function () {
+ wizardCopyHDBrowseLocation();
+ }
+}}).renderTo('newVMDiskVMMDest');
+
+
+/* Set up disk selection box */
+function copyHDFillDisks(sel) {
+
+ document.forms['frmwizardCopyHD'].copyHDDiskSelect.options.length = 0;
+ $(document.forms['frmwizardCopyHD'].copyHDDiskSelect).children().remove();
+
+ var s = vboxMedia.mediaForAttachmentType('HardDisk');
+
+ // Sort media
+ s.sort(function(a,b){return strnatcasecmp(a.name,b.name);});
+
+ var mediumSelects = [];
+ for(var i = 0; i < s.length; i++) {
+ document.forms['frmwizardCopyHD'].copyHDDiskSelect.options[i] = new Option(vboxMedia.mediumPrint(s[i]),s[i].id);
+ if(s[i].readOnly && s[i].deviceType == 'HardDisk') $(document.forms['frmwizardCopyHD'].copyHDDiskSelect.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) {
+ $(document.forms['frmwizardCopyHD'].copyHDDiskSelect).val(sel);
+ }
+
+ $(document.forms['frmwizardCopyHD'].copyHDDiskSelect).mediumselect({'type':'HardDisk','showdiff':false,'media':mediumSelects});
+
+}
+copyHDFillDisks();
+
+/* Browse for new disk location */
+function wizardCopyHDBrowseLocation() {
+
+ // Get current location
+ var loc = document.forms['frmwizardCopyHD'].elements.wizardCopyHDLocation.value;
+ if(loc.indexOf(':') > 0) {
+ // windows
+ loc = loc.replace(/.*\\/,'');
+ } else if(loc.indexOf('/') != -1) {
+ // *nix
+ loc = loc.replace(/.*\//,'');
+ } else {
+ // no path set, use src location
+ loc = vboxDirname(vboxMedia.getMediumById($(document.forms['frmwizardCopyHD'].copyHDDiskSelect).val()).location);
+ }
+
+ vboxFileBrowser(loc,function(f){
+ if(!f) return;
+ // get file name
+ file = document.forms['frmwizardCopyHD'].elements.wizardCopyHDLocation.value;
+ document.forms['frmwizardCopyHD'].elements.wizardCopyHDLocation.value = f+$('#vboxPane').data('vboxConfig').DSEP+file;
+ },true);
+
+}
+
+/* Update new HD name */
+function wizardCopyHDUpdateName(sel) {
+ var n = $(sel).val();
+ var m = vboxMedia.getMediumById(n);
+ if(!m) return;
+ document.forms['frmwizardCopyHD'].elements.wizardCopyHDLocation.value = trans('%1_copy','UIWizardNewVD').replace('%1',m.name.replace(/\.[^\.]+?$/,''));
+}
+
+ /* Suggested Data exists */
+$('#wizardCopyHDStep1').on('show',function(e,wiz){
+
+ // Already initialized?
+ if($('#wizardCopyHDStep1').data('init')) return;
+
+ if(wiz && wiz.suggested && wiz.suggested.medium)
+ $(document.forms['frmwizardCopyHD'].copyHDDiskSelect).mediumselect({'selectMedium':wiz.suggested.medium});
+
+
+ $('#wizardCopyHDStep1').data('init',true);
+
+});
+
+$('#wizardCopyHDStep2').on('show',function(e,wiz){
+ wiz._lastStep = 2;
+});
+$('#wizardCopyHDStep4').on('show',function(e,wiz){
+ wiz._lastStep = 4;
+});
+
+/* WHen showing step 3, show / hide split option */
+$('#wizardCopyHDStep3').on('show',function(e,wiz){
+
+ var caps = new Array();
+ for(var i = 0; i < document.forms['frmwizardCopyHD'].copyHDFileType.length; i++) {
+ if(document.forms['frmwizardCopyHD'].copyHDFileType[i].checked) {
+ caps = $(document.forms['frmwizardCopyHD'].copyHDFileType[i]).closest('tr').data('vboxFormat').capabilities;
+ break;
+ }
+ }
+
+ var capOpts = ['CreateFixed','CreateDynamic','CreateSplit2G'];
+ for(var i = 0; i < capOpts.length; i++) {
+ if(jQuery.inArray(capOpts[i],caps) < 0) {
+ $('#wizardCopyHDStep3').find('.vbox'+capOpts[i]).hide();
+ } else {
+ $('#wizardCopyHDStep3').find('.vbox'+capOpts[i]).show();
+ }
+ }
+
+ // Select first visible option
+ $('#wizardCopyHDStep3').find('tr:visible').first().find('input').prop('checked',true);
+
+ if($('#wizardCopyHDStep3').find('tr:visible').length == 1) {
+ if(wiz._lastStep == 2) wiz.displayStep(4);
+ else if(wiz._lastStep == 4) wiz.displayStep(2);
+ }
+});
+
+
+</script>
diff --git a/panes/wizardCopyHDAdvanced.html b/panes/wizardCopyHDAdvanced.html
index d2b2b7d..4310140 100644
--- a/panes/wizardCopyHDAdvanced.html
+++ b/panes/wizardCopyHDAdvanced.html
@@ -1,217 +1,217 @@
-<!--
-
- Advanced panes for copy hard disk wizard. Logic in vboxWizard()
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: wizardCopyHDAdvanced.html 595 2015-04-17 09:50:36Z imoore76 $
-
- -->
-<!-- Step 1 -->
-<div id='wizardCopyHDStep1' style='display: none'>
-
- <span class='vboxTableLabel translate'>Hard disk to copy</span>
- <div class='vboxOptions'>
- <table class='vboxOptions'>
- <tr style='vertical-align: top;'>
- <td><select id="copyHDDiskSelectId" name="copyHDDiskSelect" onchange='wizardCopyHDUpdateName(this)'></select></td>
- <td style='width:1%' id='newVMDiskVMM'></td>
- </tr>
- </table>
- </div>
-
- <span class='vboxTableLabel translate'>New hard disk to create</span>
- <div class='vboxOptions'>
- <table class='vboxOptions'>
- <tr>
- <td style='width: 100%; white-space: nowrap'>
- <input type='text' class='vboxText' name='wizardCopyHDLocation' style='width: 100%'/>
- </td>
- <td style='width: 1%;' id='newVMDiskVMMDest'></td>
- </tr>
- </table>
- </div>
-
- <table class='vboxInvisible' style='border: 0px solid transparent; border-spacing: 4px;'>
- <tr style='vertical-align: top'>
- <td>
- <span class='vboxTableLabel translate'>Hard disk file type</span>
- <div class='vboxOptions'>
- <table class='vboxOptions vboxNewHDWizardFileTypes'>
- <tr style='vertical-align: top;'>
- <td><label><input type='radio' class='vboxRadio' checked='checked' name='newHardDiskFileType' value='vdi' /> <span class='translate'>VDI (VirtualBox Disk Image)</span></label></td>
- </tr>
- <tr style='vertical-align: top;'>
- <td><label><input type='radio' class='vboxRadio' name='newHardDiskFileType' value='vmdk' /> <span class='translate'>VMDK (Virtual Machine Disk)</span></label></td>
- </tr>
- <tr style='vertical-align: top;'>
- <td><label><input type='radio' class='vboxRadio' name='newHardDiskFileType' value='vhd' /> <span class='translate'>VHD (Virtual Hard Disk)</span></label></td>
- </tr>
- </table>
- </div>
- </td>
- <td>
- <span class='vboxTableLabel translate'>Storage on physical hard disk</span>
- <div class='vboxOptions'>
- <table class='vboxOptions vboxCopyHDWizHDOpts'>
- <tr style='vertical-align: top;' class='vboxCreateDynamic'>
- <td><label><input type='radio' class='vboxRadio' checked='checked' name='newHardDiskType' value='dynamic' /> <span class='translate'>Dynamically allocated</span></label></td>
- </tr>
- <tr style='vertical-align: top;' class='vboxCreateFixed'>
- <td><label><input type='radio' class='vboxRadio' name='newHardDiskType' value='fixed' /> <span class='translate'>Fixed size</span></label></td>
- </tr>
- <tr style='vertical-align: top;' class='vboxCreateSplit2G'>
- <td><label><input type='checkbox' class='vboxCheckbox' name='newHardDiskSplit' disabled/> <span class='translate'>Split into files of less than 2GB</span></label></td>
- </tr>
- </table>
- </div>
- </td>
- </tr>
- </table>
-
-</div>
-
-<script type='text/javascript'>
-
-
-// Fill HD type options
-var vboxHDTypesTbl = $('#wizardCopyHDStep1').find('table.vboxNewHDWizardFileTypes').first();
-vboxHDTypesTbl.children().remove();
-var vboxHDTypes = $('#vboxPane').data('vboxSystemProperties').mediumFormats;
-for(var i = 0; i < vboxHDTypes.length; i++) {
- if(jQuery.inArray('CreateFixed',vboxHDTypes[i].capabilities) < 0 && jQuery.inArray('CreateDynamic',vboxHDTypes[i].capabilities) < 0) continue;
- if(jQuery.inArray('HardDisk',vboxHDTypes[i].deviceTypes) > -1) {
- vboxHDTypesTbl.append("<tr style='vertical-align: top;'><td><label><input type='radio' onclick='wizardCopyHDUpdateOptions()' class='vboxRadio' name='copyHDFileType' value='"+vboxHDTypes[i].id+"' /> "+vboxMedia.getFormat({'format':vboxHDTypes[i].name})+"</label></td></tr>");
- vboxHDTypesTbl.find('tr').last().data('vboxFormat', vboxHDTypes[i]);
- }
-}
-// Select default HD format and place it at the top
-vboxHDTypesTbl.find('input[value='+$('#vboxPane').data('vboxSystemProperties').defaultHardDiskFormat+']').prop('checked',true).closest('tr').detach().prependTo(vboxHDTypesTbl);
-
-/* Choose virtual hard drive button */
-new vboxToolbarSingle({button: {
- 'name' : 'mselecthdbtn',
- 'label' : 'Choose a virtual hard drive file to copy...',
- 'language_context': 'UIWizardCloneVD',
- 'icon' : 'select_file',
- 'click' : function () {
- vboxMedia.actions.choose(null,'HardDisk',function(med){
- if(med) copyHDFillDisks(med.base);
- });
- }
-}}).renderTo('newVMDiskVMM');
-
-/* Choose location of new file button */
-new vboxToolbarSingle({button: {
- 'name' : 'mselecthdbtn',
- 'label' : 'Choose a location for new virtual hard drive file...',
- 'language_context': 'UIWizardNewVD',
- 'icon' : 'select_file',
- 'click' : function () {
- wizardCopyHDBrowseLocation();
- }
-}}).renderTo('newVMDiskVMMDest');
-
-
-/* Set up disk selection box */
-function copyHDFillDisks(sel) {
-
- document.forms['frmwizardCopyHD'].copyHDDiskSelect.options.length = 0;
- $(document.forms['frmwizardCopyHD'].copyHDDiskSelect).children().remove();
-
- var s = vboxMedia.mediaForAttachmentType('HardDisk');
-
- // Sort media
- s.sort(function(a,b){return strnatcasecmp(a.name,b.name);});
-
- var mediumSelects = [];
- for(var i = 0; i < s.length; i++) {
- document.forms['frmwizardCopyHD'].copyHDDiskSelect.options[i] = new Option(vboxMedia.mediumPrint(s[i]),s[i].id);
- if(s[i].readOnly && s[i].deviceType == 'HardDisk') $(document.forms['frmwizardCopyHD'].copyHDDiskSelect.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) {
- $(document.forms['frmwizardCopyHD'].copyHDDiskSelect).val(sel);
- }
-
- $(document.forms['frmwizardCopyHD'].copyHDDiskSelect).mediumselect({'type':'HardDisk','showdiff':false,'media':mediumSelects});
-
-}
-copyHDFillDisks();
-
-/* Browse for new disk location */
-function wizardCopyHDBrowseLocation() {
-
- // Get current location
- var loc = document.forms['frmwizardCopyHD'].elements.wizardCopyHDLocation.value;
- if(loc.indexOf(':') > 0) {
- // windows
- loc = loc.replace(/.*\\/,'');
- } else if(loc.indexOf('/') != -1) {
- // *nix
- loc = loc.replace(/.*\//,'');
- } else {
- // no path set, use src location
- loc = vboxDirname(vboxMedia.getMediumById($(document.forms['frmwizardCopyHD'].copyHDDiskSelect).val()).location);
- }
-
- vboxFileBrowser(loc,function(f){
- if(!f) return;
- // get file name
- file = document.forms['frmwizardCopyHD'].elements.wizardCopyHDLocation.value;
- document.forms['frmwizardCopyHD'].elements.wizardCopyHDLocation.value = f+$('#vboxPane').data('vboxConfig').DSEP+file;
- },true);
-
-}
-
-/* Update new HD name */
-function wizardCopyHDUpdateName(sel) {
- var n = $(sel).val();
- var m = vboxMedia.getMediumById(n);
- if(!m) return;
- document.forms['frmwizardCopyHD'].elements.wizardCopyHDLocation.value = trans('%1_copy','UIWizardNewVD').replace('%1',m.name.replace(/\.[^\.]+?$/,''));
-}
-
- /* Suggested Data exists */
-$('#wizardCopyHDStep1').on('show',function(e,wiz){
-
- // Already initialized?
- if($('#wizardCopyHDStep1').data('init')) return;
-
- if(wiz && wiz.suggested && wiz.suggested.medium)
- $(document.forms['frmwizardCopyHD'].copyHDDiskSelect).mediumselect({'selectMedium':wiz.suggested.medium});
-
-
- $('#wizardCopyHDStep1').data('init',true);
-
-});
-
-/* Show / hide split option */
-function wizardCopyHDUpdateOptions() {
-
- var caps = new Array();
- for(var i = 0; i < document.forms['frmwizardCopyHD'].copyHDFileType.length; i++) {
- if(document.forms['frmwizardCopyHD'].copyHDFileType[i].checked) {
- caps = $(document.forms['frmwizardCopyHD'].copyHDFileType[i]).closest('tr').data('vboxFormat').capabilities;
- break;
- }
- }
-
- var capOpts = ['CreateFixed','CreateDynamic','CreateSplit2G'];
- for(var i = 0; i < capOpts.length; i++) {
- if(jQuery.inArray(capOpts[i],caps) < 0) {
- $('#wizardCopyHDStep1').find('tr.vbox'+capOpts[i]).addClass('disabled').find('input').prop({'disabled':true,'checked':false});
- } else {
- $('#wizardCopyHDStep1').find('tr.vbox'+capOpts[i]).removeClass('disabled').find('input').prop('disabled',false);
- }
- }
-
- // Make sure one is selected
- if(!$('#wizardCopyHDStep1').find('.vboxCopyHDWizHDOpts').find(':checked')[0]) {
- $('#wizardCopyHDStep1').find('.vboxCopyHDWizHDOpts').find('input:not(:disabled)').first().prop('checked', true);
- }
-
-}
-wizardCopyHDUpdateOptions();
-
-
-</script>
+<!--
+
+ Advanced panes for copy hard disk wizard. Logic in vboxWizard()
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: wizardCopyHDAdvanced.html 595 2015-04-17 09:50:36Z imoore76 $
+
+ -->
+<!-- Step 1 -->
+<div id='wizardCopyHDStep1' style='display: none'>
+
+ <span class='vboxTableLabel translate'>Hard disk to copy</span>
+ <div class='vboxOptions'>
+ <table class='vboxOptions'>
+ <tr style='vertical-align: top;'>
+ <td><select id="copyHDDiskSelectId" name="copyHDDiskSelect" onchange='wizardCopyHDUpdateName(this)'></select></td>
+ <td style='width:1%' id='newVMDiskVMM'></td>
+ </tr>
+ </table>
+ </div>
+
+ <span class='vboxTableLabel translate'>New hard disk to create</span>
+ <div class='vboxOptions'>
+ <table class='vboxOptions'>
+ <tr>
+ <td style='width: 100%; white-space: nowrap'>
+ <input type='text' class='vboxText' name='wizardCopyHDLocation' style='width: 100%'/>
+ </td>
+ <td style='width: 1%;' id='newVMDiskVMMDest'></td>
+ </tr>
+ </table>
+ </div>
+
+ <table class='vboxInvisible' style='border: 0px solid transparent; border-spacing: 4px;'>
+ <tr style='vertical-align: top'>
+ <td>
+ <span class='vboxTableLabel translate'>Hard disk file type</span>
+ <div class='vboxOptions'>
+ <table class='vboxOptions vboxNewHDWizardFileTypes'>
+ <tr style='vertical-align: top;'>
+ <td><label><input type='radio' class='vboxRadio' checked='checked' name='newHardDiskFileType' value='vdi' /> <span class='translate'>VDI (VirtualBox Disk Image)</span></label></td>
+ </tr>
+ <tr style='vertical-align: top;'>
+ <td><label><input type='radio' class='vboxRadio' name='newHardDiskFileType' value='vmdk' /> <span class='translate'>VMDK (Virtual Machine Disk)</span></label></td>
+ </tr>
+ <tr style='vertical-align: top;'>
+ <td><label><input type='radio' class='vboxRadio' name='newHardDiskFileType' value='vhd' /> <span class='translate'>VHD (Virtual Hard Disk)</span></label></td>
+ </tr>
+ </table>
+ </div>
+ </td>
+ <td>
+ <span class='vboxTableLabel translate'>Storage on physical hard disk</span>
+ <div class='vboxOptions'>
+ <table class='vboxOptions vboxCopyHDWizHDOpts'>
+ <tr style='vertical-align: top;' class='vboxCreateDynamic'>
+ <td><label><input type='radio' class='vboxRadio' checked='checked' name='newHardDiskType' value='dynamic' /> <span class='translate'>Dynamically allocated</span></label></td>
+ </tr>
+ <tr style='vertical-align: top;' class='vboxCreateFixed'>
+ <td><label><input type='radio' class='vboxRadio' name='newHardDiskType' value='fixed' /> <span class='translate'>Fixed size</span></label></td>
+ </tr>
+ <tr style='vertical-align: top;' class='vboxCreateSplit2G'>
+ <td><label><input type='checkbox' class='vboxCheckbox' name='newHardDiskSplit' disabled/> <span class='translate'>Split into files of less than 2GB</span></label></td>
+ </tr>
+ </table>
+ </div>
+ </td>
+ </tr>
+ </table>
+
+</div>
+
+<script type='text/javascript'>
+
+
+// Fill HD type options
+var vboxHDTypesTbl = $('#wizardCopyHDStep1').find('table.vboxNewHDWizardFileTypes').first();
+vboxHDTypesTbl.children().remove();
+var vboxHDTypes = $('#vboxPane').data('vboxSystemProperties').mediumFormats;
+for(var i = 0; i < vboxHDTypes.length; i++) {
+ if(jQuery.inArray('CreateFixed',vboxHDTypes[i].capabilities) < 0 && jQuery.inArray('CreateDynamic',vboxHDTypes[i].capabilities) < 0) continue;
+ if(jQuery.inArray('HardDisk',vboxHDTypes[i].deviceTypes) > -1) {
+ vboxHDTypesTbl.append("<tr style='vertical-align: top;'><td><label><input type='radio' onclick='wizardCopyHDUpdateOptions()' class='vboxRadio' name='copyHDFileType' value='"+vboxHDTypes[i].id+"' /> "+vboxMedia.getFormat({'format':vboxHDTypes[i].name})+"</label></td></tr>");
+ vboxHDTypesTbl.find('tr').last().data('vboxFormat', vboxHDTypes[i]);
+ }
+}
+// Select default HD format and place it at the top
+vboxHDTypesTbl.find('input[value='+$('#vboxPane').data('vboxSystemProperties').defaultHardDiskFormat+']').prop('checked',true).closest('tr').detach().prependTo(vboxHDTypesTbl);
+
+/* Choose virtual hard drive button */
+new vboxToolbarSingle({button: {
+ 'name' : 'mselecthdbtn',
+ 'label' : 'Choose a virtual hard drive file to copy...',
+ 'language_context': 'UIWizardCloneVD',
+ 'icon' : 'select_file',
+ 'click' : function () {
+ vboxMedia.actions.choose(null,'HardDisk',function(med){
+ if(med) copyHDFillDisks(med.base);
+ });
+ }
+}}).renderTo('newVMDiskVMM');
+
+/* Choose location of new file button */
+new vboxToolbarSingle({button: {
+ 'name' : 'mselecthdbtn',
+ 'label' : 'Choose a location for new virtual hard drive file...',
+ 'language_context': 'UIWizardNewVD',
+ 'icon' : 'select_file',
+ 'click' : function () {
+ wizardCopyHDBrowseLocation();
+ }
+}}).renderTo('newVMDiskVMMDest');
+
+
+/* Set up disk selection box */
+function copyHDFillDisks(sel) {
+
+ document.forms['frmwizardCopyHD'].copyHDDiskSelect.options.length = 0;
+ $(document.forms['frmwizardCopyHD'].copyHDDiskSelect).children().remove();
+
+ var s = vboxMedia.mediaForAttachmentType('HardDisk');
+
+ // Sort media
+ s.sort(function(a,b){return strnatcasecmp(a.name,b.name);});
+
+ var mediumSelects = [];
+ for(var i = 0; i < s.length; i++) {
+ document.forms['frmwizardCopyHD'].copyHDDiskSelect.options[i] = new Option(vboxMedia.mediumPrint(s[i]),s[i].id);
+ if(s[i].readOnly && s[i].deviceType == 'HardDisk') $(document.forms['frmwizardCopyHD'].copyHDDiskSelect.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) {
+ $(document.forms['frmwizardCopyHD'].copyHDDiskSelect).val(sel);
+ }
+
+ $(document.forms['frmwizardCopyHD'].copyHDDiskSelect).mediumselect({'type':'HardDisk','showdiff':false,'media':mediumSelects});
+
+}
+copyHDFillDisks();
+
+/* Browse for new disk location */
+function wizardCopyHDBrowseLocation() {
+
+ // Get current location
+ var loc = document.forms['frmwizardCopyHD'].elements.wizardCopyHDLocation.value;
+ if(loc.indexOf(':') > 0) {
+ // windows
+ loc = loc.replace(/.*\\/,'');
+ } else if(loc.indexOf('/') != -1) {
+ // *nix
+ loc = loc.replace(/.*\//,'');
+ } else {
+ // no path set, use src location
+ loc = vboxDirname(vboxMedia.getMediumById($(document.forms['frmwizardCopyHD'].copyHDDiskSelect).val()).location);
+ }
+
+ vboxFileBrowser(loc,function(f){
+ if(!f) return;
+ // get file name
+ file = document.forms['frmwizardCopyHD'].elements.wizardCopyHDLocation.value;
+ document.forms['frmwizardCopyHD'].elements.wizardCopyHDLocation.value = f+$('#vboxPane').data('vboxConfig').DSEP+file;
+ },true);
+
+}
+
+/* Update new HD name */
+function wizardCopyHDUpdateName(sel) {
+ var n = $(sel).val();
+ var m = vboxMedia.getMediumById(n);
+ if(!m) return;
+ document.forms['frmwizardCopyHD'].elements.wizardCopyHDLocation.value = trans('%1_copy','UIWizardNewVD').replace('%1',m.name.replace(/\.[^\.]+?$/,''));
+}
+
+ /* Suggested Data exists */
+$('#wizardCopyHDStep1').on('show',function(e,wiz){
+
+ // Already initialized?
+ if($('#wizardCopyHDStep1').data('init')) return;
+
+ if(wiz && wiz.suggested && wiz.suggested.medium)
+ $(document.forms['frmwizardCopyHD'].copyHDDiskSelect).mediumselect({'selectMedium':wiz.suggested.medium});
+
+
+ $('#wizardCopyHDStep1').data('init',true);
+
+});
+
+/* Show / hide split option */
+function wizardCopyHDUpdateOptions() {
+
+ var caps = new Array();
+ for(var i = 0; i < document.forms['frmwizardCopyHD'].copyHDFileType.length; i++) {
+ if(document.forms['frmwizardCopyHD'].copyHDFileType[i].checked) {
+ caps = $(document.forms['frmwizardCopyHD'].copyHDFileType[i]).closest('tr').data('vboxFormat').capabilities;
+ break;
+ }
+ }
+
+ var capOpts = ['CreateFixed','CreateDynamic','CreateSplit2G'];
+ for(var i = 0; i < capOpts.length; i++) {
+ if(jQuery.inArray(capOpts[i],caps) < 0) {
+ $('#wizardCopyHDStep1').find('tr.vbox'+capOpts[i]).addClass('disabled').find('input').prop({'disabled':true,'checked':false});
+ } else {
+ $('#wizardCopyHDStep1').find('tr.vbox'+capOpts[i]).removeClass('disabled').find('input').prop('disabled',false);
+ }
+ }
+
+ // Make sure one is selected
+ if(!$('#wizardCopyHDStep1').find('.vboxCopyHDWizHDOpts').find(':checked')[0]) {
+ $('#wizardCopyHDStep1').find('.vboxCopyHDWizHDOpts').find('input:not(:disabled)').first().prop('checked', true);
+ }
+
+}
+wizardCopyHDUpdateOptions();
+
+
+</script>
diff --git a/panes/wizardExportAppliance.html b/panes/wizardExportAppliance.html
index ea2bcf0..4bbcd9a 100644
--- a/panes/wizardExportAppliance.html
+++ b/panes/wizardExportAppliance.html
@@ -1,340 +1,340 @@
-<!--
-
- Export appliance wizard panes. Logic in vboxWizard() class
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: wizardExportAppliance.html 595 2015-04-17 09:50:36Z imoore76 $
-
- -->
-<!-- Step 1 -->
-<div id='wizardExportApplianceStep1' title='Virtual machines to export' style='display: none'>
-
- <span class='translate'>&lt;p&gt;Please select the virtual machines that should be added to the appliance. You can select more than one. Please note that these machines have to be turned off before they can be exported.&lt;/p&gt;</span>
-
- <div id='vboxExportAppVMListContainer' style='overflow:auto;padding:0px;margin:0px;' class='vboxBordered'>
- <ul style='width: 100%;margin:0px;' id='vboxExportAppVMList' class='vboxList'>
- <li><img src='images/spinner.gif' /></li>
- </ul>
- </div>
-</div>
-
-
-<!-- Step 2 -->
-<div id='wizardExportApplianceStep2' title='Appliance Export Settings' style='display: none; width: 100%;'>
-<!--
- Just here for translation skipping
- -->
-</div>
-
-<!-- Step 3 -->
-<div id='wizardExportApplianceStep3' title='Appliance settings' style='display: none; width: 100%;'>
-
- <span class='translatep3'>&lt;p&gt;Please choose a filename to export the OVF/OVA to.&lt;/p&gt;&lt;p&gt;If you use an &lt;i&gt;ova&lt;/i&gt; extension, then all the files will be combined into one Open Virtualization Format Archive.&lt;/p&gt;&lt;p&gt;If you use an &lt;i&gt;ovf&lt;/i&gt; extension, several files will be written separately.&lt;/p&gt;&lt;p&gt;Other extensions are not allowed.&lt;/p&gt;</span>
-
- <div class='vboxOptions'>
- <table style='width: 100%;' class='vboxOptions'>
- <tr>
- <th width='1%'><span class='translate'>File:</span></th>
- <td class='vboxFileFolderInput'>
- <input type='text' class='vboxText' name='wizardExportApplianceLocation' />
- <input type="button" class="vboxImgButton" style="background-image: url(images/vbox/select_file_16px.png)" onClick="wizardExportApplianceBrowseLocation()" />
- </td>
- </tr>
- <tr>
- <th width='1%'><span class='translate'>Format:</span></th>
- <td>
- <select name='wizardExportApplianceFormat'>
- <option value="ovf-0.9">OVF 0.9</option>
- <option value="ovf-1.0" selected>OVF 1.0</option>
- <option value="ovf-2.0">OVF 2.0</option>
- </select>
- </td>
- </tr>
- <tr>
- <td colspan='2'>
- <label><input type='checkbox' class='vboxCheckbox' name='wizardExportApplianceManifest'/>
- <span class='translate'>Write Manifest file</span></label>
- </td>
- </tr>
- </table>
-
- </div>
-</div>
-
-<!-- Step 4 -->
-<div id='wizardExportApplianceStep4' title='Appliance settings' style='display: none; width: 100%;'>
-
- <div class='translate' style='margin-bottom:8px; width: 100%'>This is the descriptive information which will be added to the virtual appliance. You can change it by double clicking on individual lines.</div>
-
- <div class='vboxBordered' id='vboxExportPropsContainer' style='overflow: auto' style='width: 100%'>
- <table class='vboxHorizontal' style='width: 100%;'>
- <tbody id='vboxExportProps'>
- </tbody>
- </table>
- </div>
-</div>
-
-
-<script type='text/javascript'>
-
-// On keypress, mark this as changed
-$(document.forms['frmwizardExportAppliance'].elements.wizardExportApplianceLocation).on('keyup',function(){
- $(this).data('vboxChanged', true);
-});
-
-// Translate step 3
-$('#wizardExportApplianceStep3').find('.translatep3').html(function(i,h){
- return trans($('<span />').html(h).text(),'UIWizardExportAppPageBasic3');
-}).removeClass('translatep3');
-
-// Add format options
-$(document.forms['frmwizardExportAppliance'].wizardExportApplianceFormat).find('option').html(function(i,h){return trans(h,'UIWizardExportApp');});
-
-
-var l = new vboxLoader();
-l.add('vboxGetExportableMachines',function(d){$('#wizardExportApplianceStep1').data('vms',d.responseData);});
-l.onLoad = function() {
- var vms = $('#wizardExportApplianceStep1').data('vms');
- var vmlist = $('#vboxExportAppVMList');
- $(vmlist).children().remove();
- vms.sort(function(a,b){return strnatcasecmp(a.name,b.name);});
- for(var i in vms) {
- var li = $('<li />').data({'vm':vms[i]});
- if(vboxVMStates.isRunning(vms[i]) || vboxVMStates.isPaused(vms[i])) {
- $(li).addClass('vboxDisabled disabled');
- } else {
- $(li).click(function(){$(this).toggleClass('vboxListItemSelected');}).addClass('vboxListItem');
- if(vboxChooser.isVMSelected(vms[i].id))
- $(li).addClass('vboxListItemSelected');
- }
- $(li).html("<img style='width: 16px; height: 16px;' src='images/vbox/" + vboxGuestOSTypeIcon(vms[i].OSTypeId) + "' /> " + vms[i].name)
- .data('vboxVMName', vms[i].name);
- $(vmlist).append(li);
- }
- vboxColorRows(vmlist);
-};
-l.run();
-
-
-function wizardExportApplianceStepResizeList() {
-
- // Resize list
- $('#vboxExportAppVMListContainer').hide();
- var h = $('#wizardExportApplianceStep1').parent().innerHeight() - $('#wizardExportApplianceTitle').outerHeight(true);
-
- $('#vboxExportAppVMListContainer').siblings().each(function(){
- h -= $(this).outerHeight(true);
- });
- h-=20;
- $('#vboxExportAppVMListContainer').height(h).show();
-
- // Resize properties
- $('#vboxExportPropsContainer').hide();
- var h = $('#wizardExportApplianceStep3').parent().innerHeight() - $('#wizardExportApplianceTitle').outerHeight(true);
-
- $('#vboxExportPropsContainer').siblings().each(function(){
- h -= $(this).outerHeight(true);
- });
- $('#vboxExportPropsContainer').width($('#vboxExportPropsContainer').parent().innerWidth()).height(h-4).show();
-
-}
-
-$('#wizardExportApplianceStep1').on('show',function(e,wiz){
-
- wizardExportApplianceStepResizeList();
-
- // Keep track of where we were
- $('#wizardExportApplianceStep2').data('fromStep',1);
-
-});
-
-$('#wizardExportApplianceDialog').on('dialogresizestop',wizardExportApplianceStepResizeList);
-
-/*
- *
- * VM Properties to edit / export
- *
- */
-var vboxApplianceProps = {
- 'name' : {'label':'Name','icon':'name'},
- 'product' : {'label':'Product','icon':'description'},
- 'product-url' : {'label':'Product-URL','icon':'description'},
- 'vendor' : {'label':'Vendor','icon':'description'},
- 'vendor-url' : {'label':'Vendor-URL','icon':'description'},
- 'version' : {'label':'Version','icon':'description'},
- 'description' : {'label':'Description','icon':'description','textarea':true},
- 'license' : {'label':'License','icon':'description','textarea':true}
-};
-
-/* Browse for export location */
-function wizardExportApplianceBrowseLocation() {
-
- var dsepRegEx = $('#vboxPane').data('vboxConfig').DSEP;
- if(dsepRegEx == '\\') dsepRegEx += '\\';
-
- // Get current location
- var loc = document.forms['frmwizardExportAppliance'].elements.wizardExportApplianceLocation.value;
- if(loc.indexOf($('#vboxPane').data('vboxConfig').DSEP) > -1) {
- var r = new RegExp(dsepRegEx+'([^'+dsepRegEx+']*)?$');
- loc = loc.replace(r,'');
- } else {
- // no path set
- loc = vboxDirname($('#vboxPane').data('vboxConfig').version.settingsFilePath) + $('#vboxPane').data('vboxConfig').DSEP;
- }
- vboxFileBrowser(loc,function(f){
- if(!f) return;
- // get file name
- var r = new RegExp('.*'+dsepRegEx);
- file = $(document.forms['frmwizardExportAppliance'].elements.wizardExportApplianceLocation).val().replace(r,'');
- document.forms['frmwizardExportAppliance'].elements.wizardExportApplianceLocation.value = f+($('#vboxPane').data('vboxConfig').DSEP)+file;
- $(document.forms['frmwizardExportAppliance'].elements.wizardExportApplianceLocation).data('vboxChanged', true);
- },true,trans('Select a file to export into','UIWizardExportAppPage3'));
-
-}
-
-/* Skip step 2 */
-$('#wizardExportApplianceStep2').on('show',function(e,wiz){
- if($('#wizardExportApplianceStep2').data('fromStep') == 3)
- wiz.displayStep(1);
- else
- wiz.displayStep(3);
-});
-
-/* When going to step3, determine default OVF name */
-$('#wizardExportApplianceStep3').on('show',function(e,wiz){
-
- // Keep track of where we were
- $('#wizardExportApplianceStep2').data('fromStep',3);
-
- var vmSel = $('#vboxExportAppVMList').children('li.vboxListItemSelected');
-
- /* When going to step3, make sure vms are selected */
- if(!vmSel.length) {
- $('#vboxExportAppVMListContainer').addClass('vboxRequired');
- wiz.displayStep(1);
- return;
- };
-
- $('#vboxExportAppVMListContainer').removeClass('vboxRequired');
-
- if($(document.forms['frmwizardExportAppliance'].elements.wizardExportApplianceLocation).data('vboxChanged'))
- return;
-
- var name = '';
- if(vmSel.length == 1) {
- name = jQuery.trim($(vmSel[0]).data('vboxVMName'));
- }
-
- if(!name) name = 'Appliance';
-
- name = vboxDirname($('#vboxPane').data('vboxConfig').version.settingsFilePath) + $('#vboxPane').data('vboxConfig').DSEP + name + '.ova';
- $(document.forms['frmwizardExportAppliance'].elements.wizardExportApplianceLocation).val(name);
-});
-
-$('#wizardExportApplianceStep4').on('show',function(e,wiz){
-
- var vms = $('#vboxExportAppVMList').children('li');
-
- var tbl = $('#vboxExportProps');
-
- for(var i = 0; i < vms.length; i++) {
-
- var vmid = $(vms[i]).data('vm').id;
-
- // Selected ?
- if($(vms[i]).hasClass('vboxListItemSelected')) {
- if($('#vboxAppliance-'+vmid).attr('id')) continue;
- } else {
- $(tbl).children('tr.vboxAppliance-'+vmid).remove();
- continue;
- }
-
- // VM header row
- var trparent = $('<tr />').attr({'id':'vboxAppliance-'+vmid}).addClass('vboxAppliance-'+vmid + ' vboxTableParent');
- var td = $('<td />').attr({'colspan':'2','class':'vboxApplianceHeader'}).append(
- $('<div />').css({'font-weight':'bold','padding-left':'6px'}).append(
- $('<input />').attr({'type':'button','class':'vboxImgButton','style':'background-image: url(images/downArrow.png); margin:0px;margin-right:4px;padding:0px;vspace:0px;hspace:0px;width: 12px; height: 12px;'}).click(function(){
-
- if(!$(this).data('toggleClicked')) {
-
- $(this).data('toggleClicked', true);
-
- $(this).css({'background-image':'url(images/rightArrow.png)'});
- var tr = $(this).closest('tr');
- $(tr).siblings('tr.vboxChildOf'+$(tr).data('vboxOrder')).hide();
- } else {
-
- $(this).data('toggleClicked', false);
-
- $(this).css({'background-image':'url(images/downArrow.png)'});
- var tr = $(this).closest('tr');
- $(tr).siblings('tr.vboxChildOf'+$(tr).data('vboxOrder')).show();
- }
- })
- ).append(
- //trans('Virtual System X').replace('%s',(i+1))
- $('<div />').text($(vms[i]).data('vm').name).html()
- )
- ).disableSelection();
- $(trparent).append(td).data({'vm':$(vms[i]).data('vm'),'vboxOrder':i}).appendTo(tbl);
-
- // VM properties
- for(var p in vboxApplianceProps) {
-
- var tr = $('<tr />').attr({'class':'vboxAppliance-'+vmid+' vboxChildOf' + i}).data({'vmprop':p});
-
- $('<td />').css({'padding-left':'18px','white-space':'nowrap','width':'1%'}).html('<img src="images/vbox/'+vboxApplianceProps[p].icon+'_16px.png" /> ' + trans(vboxApplianceProps[p].label,'UIApplianceEditorWidget')).appendTo(tr);
-
- $('<td />').attr({'class':'vboxHideOverflow vboxAppProp'+p}).css({'width':'100%','padding-left':'10px','padding-right':'2px'}).html('<div>'+$('<div />').text(($(trparent).data('vm')[p]||'')).html()+'</div>').dblclick((vboxApplianceProps[p].textarea ? vboxExportAppliancePropEditArea : vboxExportAppliancePropEdit )).appendTo(tr);
-
- $(tbl).append(tr);
- }
- }
- vboxColorRows(tbl,false,'vboxTableParent');
-
- wizardExportApplianceStepResizeList();
-
-});
-
-
-/* Edit property that has a text area */
-function vboxExportAppliancePropEditArea(evt,elm) {
-
- vboxExportAppliancePropEditDialog(evt.target, $('<span />').html($(evt.target).html()).text());
-
-}
-/* Edit property dialog */
-function vboxExportAppliancePropEditDialog(elm, defaults) {
-
- var d = $('<div />').css({'display':'none'});
- var frm = $('<form />').attr({'onSubmit':'return false;'}).css({'margin':'0px','border':'0px','padding':'0px','width':'100%','height':'100%'});
- $('<textarea />').attr({'id':'vboxExportAppliancePropTextarea'}).css({'height':'99%','width':'99%'}).val(defaults).appendTo(frm);
- $(d).append(frm);
-
- var buttons = {};
- buttons[trans('OK','QIMessageBox')] = function(){
- var d = vboxDivOverflowHidden(elm);
- $(d).html($('<div />').text($('#vboxExportAppliancePropTextarea').val()).html());
- $(elm).html('').append(d);
- $(this).empty().remove();
- };
- buttons[trans('Cancel','QIMessageBox')] = function(){
- $(this).empty().remove();
- };
- $(d).dialog({'height':300,'width':300,'closeOnEscape':false,'modal':true,'resizable':true,'dialogClass':'vboxDialogContent','draggable':true,'buttons':buttons,'title':$(elm).parent().siblings().first().html()});
-
-}
-/* Edit property that has a text box */
-function vboxExportAppliancePropEdit(evt,elm) {
- var input = $('<input />').attr({'type':'text','class':'vboxText'}).css({'width':($(this).innerWidth()-12)+'px','margin':'0px'}).val($('<div />').html($(this).children().first().html()).text()).blur(function(){
- var v = $(this).val();
- var p = $(this).parent();
- var d = vboxDivOverflowHidden(p);
- $(this).remove();
- $(d).html($('<div />').text(v).html());
- $(p).html('').append(d);
- }).keydown(function(e){if(e.keyCode == 13) $(this).trigger('blur');});
- $(this).html('').append(input).children().first().focus();
-}
-
-</script>
+<!--
+
+ Export appliance wizard panes. Logic in vboxWizard() class
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: wizardExportAppliance.html 595 2015-04-17 09:50:36Z imoore76 $
+
+ -->
+<!-- Step 1 -->
+<div id='wizardExportApplianceStep1' title='Virtual machines to export' style='display: none'>
+
+ <span class='translate'>&lt;p&gt;Please select the virtual machines that should be added to the appliance. You can select more than one. Please note that these machines have to be turned off before they can be exported.&lt;/p&gt;</span>
+
+ <div id='vboxExportAppVMListContainer' style='overflow:auto;padding:0px;margin:0px;' class='vboxBordered'>
+ <ul style='width: 100%;margin:0px;' id='vboxExportAppVMList' class='vboxList'>
+ <li><img src='images/spinner.gif' /></li>
+ </ul>
+ </div>
+</div>
+
+
+<!-- Step 2 -->
+<div id='wizardExportApplianceStep2' title='Appliance Export Settings' style='display: none; width: 100%;'>
+<!--
+ Just here for translation skipping
+ -->
+</div>
+
+<!-- Step 3 -->
+<div id='wizardExportApplianceStep3' title='Appliance settings' style='display: none; width: 100%;'>
+
+ <span class='translatep3'>&lt;p&gt;Please choose a filename to export the OVF/OVA to.&lt;/p&gt;&lt;p&gt;If you use an &lt;i&gt;ova&lt;/i&gt; extension, then all the files will be combined into one Open Virtualization Format Archive.&lt;/p&gt;&lt;p&gt;If you use an &lt;i&gt;ovf&lt;/i&gt; extension, several files will be written separately.&lt;/p&gt;&lt;p&gt;Other extensions are not allowed.&lt;/p&gt;</span>
+
+ <div class='vboxOptions'>
+ <table style='width: 100%;' class='vboxOptions'>
+ <tr>
+ <th width='1%'><span class='translate'>File:</span></th>
+ <td class='vboxFileFolderInput'>
+ <input type='text' class='vboxText' name='wizardExportApplianceLocation' />
+ <input type="button" class="vboxImgButton" style="background-image: url(images/vbox/select_file_16px.png)" onClick="wizardExportApplianceBrowseLocation()" />
+ </td>
+ </tr>
+ <tr>
+ <th width='1%'><span class='translate'>Format:</span></th>
+ <td>
+ <select name='wizardExportApplianceFormat'>
+ <option value="ovf-0.9">OVF 0.9</option>
+ <option value="ovf-1.0" selected>OVF 1.0</option>
+ <option value="ovf-2.0">OVF 2.0</option>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td colspan='2'>
+ <label><input type='checkbox' class='vboxCheckbox' name='wizardExportApplianceManifest'/>
+ <span class='translate'>Write Manifest file</span></label>
+ </td>
+ </tr>
+ </table>
+
+ </div>
+</div>
+
+<!-- Step 4 -->
+<div id='wizardExportApplianceStep4' title='Appliance settings' style='display: none; width: 100%;'>
+
+ <div class='translate' style='margin-bottom:8px; width: 100%'>This is the descriptive information which will be added to the virtual appliance. You can change it by double clicking on individual lines.</div>
+
+ <div class='vboxBordered' id='vboxExportPropsContainer' style='overflow: auto' style='width: 100%'>
+ <table class='vboxHorizontal' style='width: 100%;'>
+ <tbody id='vboxExportProps'>
+ </tbody>
+ </table>
+ </div>
+</div>
+
+
+<script type='text/javascript'>
+
+// On keypress, mark this as changed
+$(document.forms['frmwizardExportAppliance'].elements.wizardExportApplianceLocation).on('keyup',function(){
+ $(this).data('vboxChanged', true);
+});
+
+// Translate step 3
+$('#wizardExportApplianceStep3').find('.translatep3').html(function(i,h){
+ return trans($('<span />').html(h).text(),'UIWizardExportAppPageBasic3');
+}).removeClass('translatep3');
+
+// Add format options
+$(document.forms['frmwizardExportAppliance'].wizardExportApplianceFormat).find('option').html(function(i,h){return trans(h,'UIWizardExportApp');});
+
+
+var l = new vboxLoader();
+l.add('vboxGetExportableMachines',function(d){$('#wizardExportApplianceStep1').data('vms',d.responseData);});
+l.onLoad = function() {
+ var vms = $('#wizardExportApplianceStep1').data('vms');
+ var vmlist = $('#vboxExportAppVMList');
+ $(vmlist).children().remove();
+ vms.sort(function(a,b){return strnatcasecmp(a.name,b.name);});
+ for(var i in vms) {
+ var li = $('<li />').data({'vm':vms[i]});
+ if(vboxVMStates.isRunning(vms[i]) || vboxVMStates.isPaused(vms[i])) {
+ $(li).addClass('vboxDisabled disabled');
+ } else {
+ $(li).click(function(){$(this).toggleClass('vboxListItemSelected');}).addClass('vboxListItem');
+ if(vboxChooser.isVMSelected(vms[i].id))
+ $(li).addClass('vboxListItemSelected');
+ }
+ $(li).html("<img style='width: 16px; height: 16px;' src='images/vbox/" + vboxGuestOSTypeIcon(vms[i].OSTypeId) + "' /> " + vms[i].name)
+ .data('vboxVMName', vms[i].name);
+ $(vmlist).append(li);
+ }
+ vboxColorRows(vmlist);
+};
+l.run();
+
+
+function wizardExportApplianceStepResizeList() {
+
+ // Resize list
+ $('#vboxExportAppVMListContainer').hide();
+ var h = $('#wizardExportApplianceStep1').parent().innerHeight() - $('#wizardExportApplianceTitle').outerHeight(true);
+
+ $('#vboxExportAppVMListContainer').siblings().each(function(){
+ h -= $(this).outerHeight(true);
+ });
+ h-=20;
+ $('#vboxExportAppVMListContainer').height(h).show();
+
+ // Resize properties
+ $('#vboxExportPropsContainer').hide();
+ var h = $('#wizardExportApplianceStep3').parent().innerHeight() - $('#wizardExportApplianceTitle').outerHeight(true);
+
+ $('#vboxExportPropsContainer').siblings().each(function(){
+ h -= $(this).outerHeight(true);
+ });
+ $('#vboxExportPropsContainer').width($('#vboxExportPropsContainer').parent().innerWidth()).height(h-4).show();
+
+}
+
+$('#wizardExportApplianceStep1').on('show',function(e,wiz){
+
+ wizardExportApplianceStepResizeList();
+
+ // Keep track of where we were
+ $('#wizardExportApplianceStep2').data('fromStep',1);
+
+});
+
+$('#wizardExportApplianceDialog').on('dialogresizestop',wizardExportApplianceStepResizeList);
+
+/*
+ *
+ * VM Properties to edit / export
+ *
+ */
+var vboxApplianceProps = {
+ 'name' : {'label':'Name','icon':'name'},
+ 'product' : {'label':'Product','icon':'description'},
+ 'product-url' : {'label':'Product-URL','icon':'description'},
+ 'vendor' : {'label':'Vendor','icon':'description'},
+ 'vendor-url' : {'label':'Vendor-URL','icon':'description'},
+ 'version' : {'label':'Version','icon':'description'},
+ 'description' : {'label':'Description','icon':'description','textarea':true},
+ 'license' : {'label':'License','icon':'description','textarea':true}
+};
+
+/* Browse for export location */
+function wizardExportApplianceBrowseLocation() {
+
+ var dsepRegEx = $('#vboxPane').data('vboxConfig').DSEP;
+ if(dsepRegEx == '\\') dsepRegEx += '\\';
+
+ // Get current location
+ var loc = document.forms['frmwizardExportAppliance'].elements.wizardExportApplianceLocation.value;
+ if(loc.indexOf($('#vboxPane').data('vboxConfig').DSEP) > -1) {
+ var r = new RegExp(dsepRegEx+'([^'+dsepRegEx+']*)?$');
+ loc = loc.replace(r,'');
+ } else {
+ // no path set
+ loc = vboxDirname($('#vboxPane').data('vboxConfig').version.settingsFilePath) + $('#vboxPane').data('vboxConfig').DSEP;
+ }
+ vboxFileBrowser(loc,function(f){
+ if(!f) return;
+ // get file name
+ var r = new RegExp('.*'+dsepRegEx);
+ file = $(document.forms['frmwizardExportAppliance'].elements.wizardExportApplianceLocation).val().replace(r,'');
+ document.forms['frmwizardExportAppliance'].elements.wizardExportApplianceLocation.value = f+($('#vboxPane').data('vboxConfig').DSEP)+file;
+ $(document.forms['frmwizardExportAppliance'].elements.wizardExportApplianceLocation).data('vboxChanged', true);
+ },true,trans('Select a file to export into','UIWizardExportAppPage3'));
+
+}
+
+/* Skip step 2 */
+$('#wizardExportApplianceStep2').on('show',function(e,wiz){
+ if($('#wizardExportApplianceStep2').data('fromStep') == 3)
+ wiz.displayStep(1);
+ else
+ wiz.displayStep(3);
+});
+
+/* When going to step3, determine default OVF name */
+$('#wizardExportApplianceStep3').on('show',function(e,wiz){
+
+ // Keep track of where we were
+ $('#wizardExportApplianceStep2').data('fromStep',3);
+
+ var vmSel = $('#vboxExportAppVMList').children('li.vboxListItemSelected');
+
+ /* When going to step3, make sure vms are selected */
+ if(!vmSel.length) {
+ $('#vboxExportAppVMListContainer').addClass('vboxRequired');
+ wiz.displayStep(1);
+ return;
+ };
+
+ $('#vboxExportAppVMListContainer').removeClass('vboxRequired');
+
+ if($(document.forms['frmwizardExportAppliance'].elements.wizardExportApplianceLocation).data('vboxChanged'))
+ return;
+
+ var name = '';
+ if(vmSel.length == 1) {
+ name = jQuery.trim($(vmSel[0]).data('vboxVMName'));
+ }
+
+ if(!name) name = 'Appliance';
+
+ name = vboxDirname($('#vboxPane').data('vboxConfig').version.settingsFilePath) + $('#vboxPane').data('vboxConfig').DSEP + name + '.ova';
+ $(document.forms['frmwizardExportAppliance'].elements.wizardExportApplianceLocation).val(name);
+});
+
+$('#wizardExportApplianceStep4').on('show',function(e,wiz){
+
+ var vms = $('#vboxExportAppVMList').children('li');
+
+ var tbl = $('#vboxExportProps');
+
+ for(var i = 0; i < vms.length; i++) {
+
+ var vmid = $(vms[i]).data('vm').id;
+
+ // Selected ?
+ if($(vms[i]).hasClass('vboxListItemSelected')) {
+ if($('#vboxAppliance-'+vmid).attr('id')) continue;
+ } else {
+ $(tbl).children('tr.vboxAppliance-'+vmid).remove();
+ continue;
+ }
+
+ // VM header row
+ var trparent = $('<tr />').attr({'id':'vboxAppliance-'+vmid}).addClass('vboxAppliance-'+vmid + ' vboxTableParent');
+ var td = $('<td />').attr({'colspan':'2','class':'vboxApplianceHeader'}).append(
+ $('<div />').css({'font-weight':'bold','padding-left':'6px'}).append(
+ $('<input />').attr({'type':'button','class':'vboxImgButton','style':'background-image: url(images/downArrow.png); margin:0px;margin-right:4px;padding:0px;vspace:0px;hspace:0px;width: 12px; height: 12px;'}).click(function(){
+
+ if(!$(this).data('toggleClicked')) {
+
+ $(this).data('toggleClicked', true);
+
+ $(this).css({'background-image':'url(images/rightArrow.png)'});
+ var tr = $(this).closest('tr');
+ $(tr).siblings('tr.vboxChildOf'+$(tr).data('vboxOrder')).hide();
+ } else {
+
+ $(this).data('toggleClicked', false);
+
+ $(this).css({'background-image':'url(images/downArrow.png)'});
+ var tr = $(this).closest('tr');
+ $(tr).siblings('tr.vboxChildOf'+$(tr).data('vboxOrder')).show();
+ }
+ })
+ ).append(
+ //trans('Virtual System X').replace('%s',(i+1))
+ $('<div />').text($(vms[i]).data('vm').name).html()
+ )
+ ).disableSelection();
+ $(trparent).append(td).data({'vm':$(vms[i]).data('vm'),'vboxOrder':i}).appendTo(tbl);
+
+ // VM properties
+ for(var p in vboxApplianceProps) {
+
+ var tr = $('<tr />').attr({'class':'vboxAppliance-'+vmid+' vboxChildOf' + i}).data({'vmprop':p});
+
+ $('<td />').css({'padding-left':'18px','white-space':'nowrap','width':'1%'}).html('<img src="images/vbox/'+vboxApplianceProps[p].icon+'_16px.png" /> ' + trans(vboxApplianceProps[p].label,'UIApplianceEditorWidget')).appendTo(tr);
+
+ $('<td />').attr({'class':'vboxHideOverflow vboxAppProp'+p}).css({'width':'100%','padding-left':'10px','padding-right':'2px'}).html('<div>'+$('<div />').text(($(trparent).data('vm')[p]||'')).html()+'</div>').dblclick((vboxApplianceProps[p].textarea ? vboxExportAppliancePropEditArea : vboxExportAppliancePropEdit )).appendTo(tr);
+
+ $(tbl).append(tr);
+ }
+ }
+ vboxColorRows(tbl,false,'vboxTableParent');
+
+ wizardExportApplianceStepResizeList();
+
+});
+
+
+/* Edit property that has a text area */
+function vboxExportAppliancePropEditArea(evt,elm) {
+
+ vboxExportAppliancePropEditDialog(evt.target, $('<span />').html($(evt.target).html()).text());
+
+}
+/* Edit property dialog */
+function vboxExportAppliancePropEditDialog(elm, defaults) {
+
+ var d = $('<div />').css({'display':'none'});
+ var frm = $('<form />').attr({'onSubmit':'return false;'}).css({'margin':'0px','border':'0px','padding':'0px','width':'100%','height':'100%'});
+ $('<textarea />').attr({'id':'vboxExportAppliancePropTextarea'}).css({'height':'99%','width':'99%'}).val(defaults).appendTo(frm);
+ $(d).append(frm);
+
+ var buttons = {};
+ buttons[trans('OK','QIMessageBox')] = function(){
+ var d = vboxDivOverflowHidden(elm);
+ $(d).html($('<div />').text($('#vboxExportAppliancePropTextarea').val()).html());
+ $(elm).html('').append(d);
+ $(this).empty().remove();
+ };
+ buttons[trans('Cancel','QIMessageBox')] = function(){
+ $(this).empty().remove();
+ };
+ $(d).dialog({'height':300,'width':300,'closeOnEscape':false,'modal':true,'resizable':true,'dialogClass':'vboxDialogContent','draggable':true,'buttons':buttons,'title':$(elm).parent().siblings().first().html()});
+
+}
+/* Edit property that has a text box */
+function vboxExportAppliancePropEdit(evt,elm) {
+ var input = $('<input />').attr({'type':'text','class':'vboxText'}).css({'width':($(this).innerWidth()-12)+'px','margin':'0px'}).val($('<div />').html($(this).children().first().html()).text()).blur(function(){
+ var v = $(this).val();
+ var p = $(this).parent();
+ var d = vboxDivOverflowHidden(p);
+ $(this).remove();
+ $(d).html($('<div />').text(v).html());
+ $(p).html('').append(d);
+ }).keydown(function(e){if(e.keyCode == 13) $(this).trigger('blur');});
+ $(this).html('').append(input).children().first().focus();
+}
+
+</script>
diff --git a/panes/wizardExportApplianceAdvanced.html b/panes/wizardExportApplianceAdvanced.html
index 5eec268..4a19f3e 100644
--- a/panes/wizardExportApplianceAdvanced.html
+++ b/panes/wizardExportApplianceAdvanced.html
@@ -1,320 +1,320 @@
-<!--
-
- Advanced export appliance wizard panes. Logic in vboxWizard() class
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: wizardExportApplianceAdvanced.html 595 2015-04-17 09:50:36Z imoore76 $
-
- -->
-<!-- Step 1 -->
-<div id='wizardExportApplianceStep1' style='display: none;'>
-
- <table class='vboxInvisible' style='border: 0px solid transparent; border-spacing: 4px; height: 100%;'>
- <tr style='vertical-align: top'>
- <td style='width: 50%'>
-
- <span class='translate vboxTableLabel'>Virtual machines to export</span>
- <hr style='width: 100%; margin: 0px; margin-bottom: 6px; display: block' class='vboxSeparatorLine'/>
-
- <div id='vboxExportAppVMListContainer' style='overflow:auto;padding:0px;margin:0px;' class='vboxBordered'>
- <ul style='width: 100%;margin:0px;' id='vboxExportAppVMList' class='vboxList'>
- <li><img src='images/spinner.gif' /></li>
- </ul>
- </div>
- </td>
- <td>
- <span class='translate vboxTableLabel'>Appliance settings</span>
- <hr style='width: 100%; margin: 0px; margin-bottom: 6px; display: block' class='vboxSeparatorLine'/>
-
- <div class='vboxBordered' id='vboxExportPropsContainer' style='overflow: auto' style='width: 100%'>
- <table class='vboxHorizontal' style='width: 100%; font-size: 0.9em'>
- <tbody id='vboxExportProps'>
- </tbody>
- </table>
- </div>
-
- </td>
- </tr>
-
- <tr style='vertical-align: top; height: 1%;'>
- <td colspan='2'>
-
- <table style='width: 100%;' class='vboxOptions'>
- <tr>
- <th width='1%'><span class='translate'>File:</span></th>
- <td class='vboxFileFolderInput'>
- <input type='text' class='vboxText' name='wizardExportApplianceLocation' />
- <input type="button" class="vboxImgButton" style="background-image: url(images/vbox/select_file_16px.png)" onClick="wizardExportApplianceBrowseLocation()" />
- </td>
- </tr>
- <tr>
- <th width='1%'><span class='translate'>Format:</span></th>
- <td>
- <select name='wizardExportApplianceFormat'>
- <option value="ovf-0.9">OVF 0.9</option>
- <option value="ovf-1.0" selected>OVF 1.0</option>
- <option value="ovf-2.0">OVF 2.0</option>
- </select>
- </td>
- </tr>
- <tr>
- <td colspan='2'>
- <label><input type='checkbox' class='vboxCheckbox' name='wizardExportApplianceManifest'/>
- <span class='translate'>Write Manifest file</span></label>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
-</div>
-
-
-<script type='text/javascript'>
-
-//Add format options
-$(document.forms['frmwizardExportAppliance'].wizardExportApplianceFormat).find('option').html(function(i,h){return trans(h,'UIWizardExportApp');});
-
-
-// Load list of exportable machines
-var l = new vboxLoader();
-l.add('vboxGetExportableMachines',function(d){$('#wizardExportApplianceStep1').data('vms',d.responseData);});
-l.onLoad = function() {
- var vms = $('#wizardExportApplianceStep1').data('vms');
- var vmlist = $('#vboxExportAppVMList');
- $(vmlist).children().remove();
- vms.sort(function(a,b){return strnatcasecmp(a.name,b.name);});
- for(var i in vms) {
- var li = $('<li />').data({'vm':vms[i]});
- if(vboxVMStates.isPaused(vms[i]) || vboxVMStates.isRunning(vms[i])) {
- $(li).addClass('vboxDisabled disabled');
- } else {
-
- /* Exportable appliance clicked */
- $(li).click(function(){
-
- $(this).toggleClass('vboxListItemSelected');
-
- vboxWizardExportApplianceUpdateList();
- vboxWizardExportApplianceOVFName();
-
-
- }).addClass('vboxListItem');
-
- if(vboxChooser.isVMSelected(vms[i].id))
- $(li).addClass('vboxListItemSelected');
-
- }
- $(li).html("<img style='width: 16px; height: 16px;' src='images/vbox/" + vboxGuestOSTypeIcon(vms[i].OSTypeId) + "' /> " + vms[i].name);
- $(vmlist).append(li);
- }
- vboxColorRows(vmlist);
- vboxWizardExportApplianceUpdateList();
- vboxWizardExportApplianceOVFName();
-
-};
-l.run();
-
-// Resize panes function
-function wizardExportApplianceStepResizeList() {
-
- $('#wizardExportApplianceStep1').hide();
- $('#vboxExportAppVMListContainer').hide();
- $('#vboxExportPropsContainer').hide();
-
- $('#wizardExportApplianceStep1').css({'height':($('#wizardExportApplianceStep1').parent().height()-8)+'px'}).show();
- $('#vboxExportAppVMListContainer').css({'height':($('#vboxExportAppVMListContainer').parent().height()-16)+'px'}).show();
- $('#vboxExportPropsContainer').css({'height':$('#vboxExportAppVMListContainer').css('height'),
- 'width':$('#vboxExportAppVMListContainer').parent().width()}).show();
-
-}
-
-// Resize panes when wizard is resized
-$('#wizardExportApplianceDialog').on('dialogresizestop',wizardExportApplianceStepResizeList);
-//Resize panes after this div is shown
-$('#wizardExportApplianceStep1').on('show', wizardExportApplianceStepResizeList);
-
-
-/*
- *
- * VM Properties to edit / export
- *
- */
-var vboxApplianceProps = {
- 'name' : {'label':'Name','icon':'name'},
- 'product' : {'label':'Product','icon':'description'},
- 'product-url' : {'label':'Product-URL','icon':'description'},
- 'vendor' : {'label':'Vendor','icon':'description'},
- 'vendor-url' : {'label':'Vendor-URL','icon':'description'},
- 'version' : {'label':'Version','icon':'description'},
- 'description' : {'label':'Description','icon':'description','textarea':true},
- 'license' : {'label':'License','icon':'description','textarea':true}
-};
-
-/* Browse for export location */
-function wizardExportApplianceBrowseLocation() {
-
- var dsepRegEx = $('#vboxPane').data('vboxConfig').DSEP;
- if(dsepRegEx == '\\') dsepRegEx += '\\';
-
- // Get current location
- var loc = document.forms['frmwizardExportAppliance'].elements.wizardExportApplianceLocation.value;
- if(loc.indexOf($('#vboxPane').data('vboxConfig').DSEP) > -1) {
- var r = new RegExp(dsepRegEx+'([^'+dsepRegEx+']*)?$');
- loc = loc.replace(r,'');
- } else {
- // no path set
- loc = vboxDirname($('#vboxPane').data('vboxConfig').version.settingsFilePath) + $('#vboxPane').data('vboxConfig').DSEP;
- }
- vboxFileBrowser(loc,function(f){
- if(!f) return;
- // get file name
- var r = new RegExp('.*'+dsepRegEx);
- file = $(document.forms['frmwizardExportAppliance'].elements.wizardExportApplianceLocation).val().replace(r,'');
- document.forms['frmwizardExportAppliance'].elements.wizardExportApplianceLocation.value = f+($('#vboxPane').data('vboxConfig').DSEP)+file;
- },true,trans('Select a file to export into','UIWizardExportAppPage3'));
-
-}
-
-/* Determine default OVF name */
-function vboxWizardExportApplianceOVFName() {
-
- // Keep track of where we were
- var vmSel = $('#vboxExportAppVMList').children('li.vboxListItemSelected');
-
- /* When going to step3, make sure vms are selected */
- if(!vmSel.length) {
- $('#vboxExportAppVMListContainer').addClass('vboxRequired');
- return;
- }
- $('#vboxExportAppVMListContainer').removeClass('vboxRequired');
-
-
- if(jQuery.trim($(document.forms['frmwizardExportAppliance'].elements.wizardExportApplianceLocation).val()) && $(document.forms['frmwizardExportAppliance'].elements.wizardExportApplianceLocation).data('userChanged'))
- return;
-
- $(document.forms['frmwizardExportAppliance'].elements.wizardExportApplianceLocation).data('userChanged', false);
-
- var name = '';
- if(vmSel.length > 1) {
- name = 'Appliance';
- } else {
- name = jQuery.trim($(vmSel[0]).text());
- }
-
- // If there is already a folder chosen, don't change it
- if(jQuery.trim($(document.forms['frmwizardExportAppliance'].elements.wizardExportApplianceLocation).val())) {
- name = vboxDirname(jQuery.trim($(document.forms['frmwizardExportAppliance'].elements.wizardExportApplianceLocation).val())) + $('#vboxPane').data('vboxConfig').DSEP + name + '.ova';
- } else {
- name = vboxDirname($('#vboxPane').data('vboxConfig').version.settingsFilePath) + $('#vboxPane').data('vboxConfig').DSEP + name + '.ova';
- }
-
- $(document.forms['frmwizardExportAppliance'].elements.wizardExportApplianceLocation).val(name);
-
-};
-
-function vboxWizardExportApplianceUpdateList() {
-
- var vms = $('#vboxExportAppVMList').children('li');
-
- var tbl = $('#vboxExportProps');
-
- for(var i = 0; i < vms.length; i++) {
-
- var vmid = $(vms[i]).data('vm').id;
-
- // Selected ?
- if($(vms[i]).hasClass('vboxListItemSelected')) {
- if($('#vboxAppliance-'+vmid).attr('id')) continue;
- } else {
- $(tbl).children('tr.vboxAppliance-'+vmid).remove();
- continue;
- }
-
- // VM header row
- var trparent = $('<tr />').attr({'id':'vboxAppliance-'+vmid}).addClass('vboxAppliance-'+vmid + ' vboxTableParent');
- var td = $('<td />').attr({'colspan':'2','class':'vboxApplianceHeader'}).append(
- $('<div />').css({'font-weight':'bold','padding-left':'6px'}).append(
- $('<input />').attr({'type':'button','class':'vboxImgButton','style':'background-image: url(images/downArrow.png); margin:0px;margin-right:4px;padding:0px;vspace:0px;hspace:0px;width: 12px; height: 12px;'}).click(function(){
-
- if(!$(this).data('toggleClicked')) {
-
- $(this).data('toggleClicked', true);
-
- $(this).css({'background-image':'url(images/rightArrow.png)'});
- var tr = $(this).closest('tr');
- $(tr).siblings('tr.vboxChildOf'+$(tr).data('vboxOrder')).hide();
- } else {
-
- $(this).data('toggleClicked', false);
-
- $(this).css({'background-image':'url(images/downArrow.png)'});
- var tr = $(this).closest('tr');
- $(tr).siblings('tr.vboxChildOf'+$(tr).data('vboxOrder')).show();
- }
- })
- ).append(
- //trans('Virtual System X').replace('%s',(i+1))
- $('<div />').text($(vms[i]).data('vm').name).html()
- )
- ).disableSelection();
- $(trparent).append(td).data({'vm':$(vms[i]).data('vm'),'vboxOrder':i}).appendTo(tbl);
-
- // VM properties
- for(var p in vboxApplianceProps) {
-
- var tr = $('<tr />').attr({'class':'vboxAppliance-'+vmid+' vboxChildOf' + i}).data({'vmprop':p});
-
- $('<td />').css({'padding-left':'18px','white-space':'nowrap','width':'1%'}).html('<img src="images/vbox/'+vboxApplianceProps[p].icon+'_16px.png" /> ' + trans(vboxApplianceProps[p].label,'UIApplianceEditorWidget')).appendTo(tr);
-
- $('<td />').attr({'class':'vboxHideOverflow vboxAppProp'+p}).css({'width':'100%','padding-left':'10px','padding-right':'2px'}).html('<div>'+$('<div />').text(($(trparent).data('vm')[p]||'')).html()+'</div>').dblclick((vboxApplianceProps[p].textarea ? vboxExportAppliancePropEditArea : vboxExportAppliancePropEdit )).appendTo(tr);
-
- $(tbl).append(tr);
- }
- }
- vboxColorRows(tbl,false,'vboxTableParent');
-
-
-};
-
-
-/* Edit property that has a text area */
-function vboxExportAppliancePropEditArea(evt,elm) {
- vboxExportAppliancePropEditDialog(evt.target, $('<span />').html($(evt.target).html()).text());
-}
-
-/* Edit property dialog */
-function vboxExportAppliancePropEditDialog(elm, defaults) {
-
- var d = $('<div />').css({'display':'none'});
- var frm = $('<form />').attr({'onSubmit':'return false;'}).css({'margin':'0px','border':'0px','padding':'0px','width':'100%','height':'100%'});
- $('<textarea />').attr({'id':'vboxExportAppliancePropTextarea'}).css({'height':'99%','width':'99%'}).val(defaults).appendTo(frm);
- $(d).append(frm);
-
- var buttons = {};
- buttons[trans('OK','QIMessageBox')] = function(){
- var d = vboxDivOverflowHidden(elm);
- $(d).html($('<div />').text($('#vboxExportAppliancePropTextarea').val()).html());
- $(elm).html('').append(d);
- $(this).empty().remove();
- };
- buttons[trans('Cancel','QIMessageBox')] = function(){
- $(this).empty().remove();
- };
- $(d).dialog({'height':300,'width':300,'closeOnEscape':false,'modal':true,'resizable':true,'dialogClass':'vboxDialogContent','draggable':true,'buttons':buttons,'title':$(elm).parent().siblings().first().html()});
-
-}
-/* Edit property that has a text box */
-function vboxExportAppliancePropEdit(evt,elm) {
- var input = $('<input />').attr({'type':'text','class':'vboxText'}).css({'width':($(this).innerWidth()-12)+'px','margin':'0px'}).val($('<div />').html($(this).children().first().html()).text()).blur(function(){
- var v = $(this).val();
- var p = $(this).parent();
- var d = vboxDivOverflowHidden(p);
- $(this).remove();
- $(d).html($('<div />').text(v).html());
- $(p).html('').append(d);
- }).keydown(function(e){if(e.keyCode == 13) $(this).trigger('blur');});
- $(this).html('').append(input).children().first().focus();
-}
-
-</script>
+<!--
+
+ Advanced export appliance wizard panes. Logic in vboxWizard() class
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: wizardExportApplianceAdvanced.html 595 2015-04-17 09:50:36Z imoore76 $
+
+ -->
+<!-- Step 1 -->
+<div id='wizardExportApplianceStep1' style='display: none;'>
+
+ <table class='vboxInvisible' style='border: 0px solid transparent; border-spacing: 4px; height: 100%;'>
+ <tr style='vertical-align: top'>
+ <td style='width: 50%'>
+
+ <span class='translate vboxTableLabel'>Virtual machines to export</span>
+ <hr style='width: 100%; margin: 0px; margin-bottom: 6px; display: block' class='vboxSeparatorLine'/>
+
+ <div id='vboxExportAppVMListContainer' style='overflow:auto;padding:0px;margin:0px;' class='vboxBordered'>
+ <ul style='width: 100%;margin:0px;' id='vboxExportAppVMList' class='vboxList'>
+ <li><img src='images/spinner.gif' /></li>
+ </ul>
+ </div>
+ </td>
+ <td>
+ <span class='translate vboxTableLabel'>Appliance settings</span>
+ <hr style='width: 100%; margin: 0px; margin-bottom: 6px; display: block' class='vboxSeparatorLine'/>
+
+ <div class='vboxBordered' id='vboxExportPropsContainer' style='overflow: auto' style='width: 100%'>
+ <table class='vboxHorizontal' style='width: 100%; font-size: 0.9em'>
+ <tbody id='vboxExportProps'>
+ </tbody>
+ </table>
+ </div>
+
+ </td>
+ </tr>
+
+ <tr style='vertical-align: top; height: 1%;'>
+ <td colspan='2'>
+
+ <table style='width: 100%;' class='vboxOptions'>
+ <tr>
+ <th width='1%'><span class='translate'>File:</span></th>
+ <td class='vboxFileFolderInput'>
+ <input type='text' class='vboxText' name='wizardExportApplianceLocation' />
+ <input type="button" class="vboxImgButton" style="background-image: url(images/vbox/select_file_16px.png)" onClick="wizardExportApplianceBrowseLocation()" />
+ </td>
+ </tr>
+ <tr>
+ <th width='1%'><span class='translate'>Format:</span></th>
+ <td>
+ <select name='wizardExportApplianceFormat'>
+ <option value="ovf-0.9">OVF 0.9</option>
+ <option value="ovf-1.0" selected>OVF 1.0</option>
+ <option value="ovf-2.0">OVF 2.0</option>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td colspan='2'>
+ <label><input type='checkbox' class='vboxCheckbox' name='wizardExportApplianceManifest'/>
+ <span class='translate'>Write Manifest file</span></label>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+</div>
+
+
+<script type='text/javascript'>
+
+//Add format options
+$(document.forms['frmwizardExportAppliance'].wizardExportApplianceFormat).find('option').html(function(i,h){return trans(h,'UIWizardExportApp');});
+
+
+// Load list of exportable machines
+var l = new vboxLoader();
+l.add('vboxGetExportableMachines',function(d){$('#wizardExportApplianceStep1').data('vms',d.responseData);});
+l.onLoad = function() {
+ var vms = $('#wizardExportApplianceStep1').data('vms');
+ var vmlist = $('#vboxExportAppVMList');
+ $(vmlist).children().remove();
+ vms.sort(function(a,b){return strnatcasecmp(a.name,b.name);});
+ for(var i in vms) {
+ var li = $('<li />').data({'vm':vms[i]});
+ if(vboxVMStates.isPaused(vms[i]) || vboxVMStates.isRunning(vms[i])) {
+ $(li).addClass('vboxDisabled disabled');
+ } else {
+
+ /* Exportable appliance clicked */
+ $(li).click(function(){
+
+ $(this).toggleClass('vboxListItemSelected');
+
+ vboxWizardExportApplianceUpdateList();
+ vboxWizardExportApplianceOVFName();
+
+
+ }).addClass('vboxListItem');
+
+ if(vboxChooser.isVMSelected(vms[i].id))
+ $(li).addClass('vboxListItemSelected');
+
+ }
+ $(li).html("<img style='width: 16px; height: 16px;' src='images/vbox/" + vboxGuestOSTypeIcon(vms[i].OSTypeId) + "' /> " + vms[i].name);
+ $(vmlist).append(li);
+ }
+ vboxColorRows(vmlist);
+ vboxWizardExportApplianceUpdateList();
+ vboxWizardExportApplianceOVFName();
+
+};
+l.run();
+
+// Resize panes function
+function wizardExportApplianceStepResizeList() {
+
+ $('#wizardExportApplianceStep1').hide();
+ $('#vboxExportAppVMListContainer').hide();
+ $('#vboxExportPropsContainer').hide();
+
+ $('#wizardExportApplianceStep1').css({'height':($('#wizardExportApplianceStep1').parent().height()-8)+'px'}).show();
+ $('#vboxExportAppVMListContainer').css({'height':($('#vboxExportAppVMListContainer').parent().height()-16)+'px'}).show();
+ $('#vboxExportPropsContainer').css({'height':$('#vboxExportAppVMListContainer').css('height'),
+ 'width':$('#vboxExportAppVMListContainer').parent().width()}).show();
+
+}
+
+// Resize panes when wizard is resized
+$('#wizardExportApplianceDialog').on('dialogresizestop',wizardExportApplianceStepResizeList);
+//Resize panes after this div is shown
+$('#wizardExportApplianceStep1').on('show', wizardExportApplianceStepResizeList);
+
+
+/*
+ *
+ * VM Properties to edit / export
+ *
+ */
+var vboxApplianceProps = {
+ 'name' : {'label':'Name','icon':'name'},
+ 'product' : {'label':'Product','icon':'description'},
+ 'product-url' : {'label':'Product-URL','icon':'description'},
+ 'vendor' : {'label':'Vendor','icon':'description'},
+ 'vendor-url' : {'label':'Vendor-URL','icon':'description'},
+ 'version' : {'label':'Version','icon':'description'},
+ 'description' : {'label':'Description','icon':'description','textarea':true},
+ 'license' : {'label':'License','icon':'description','textarea':true}
+};
+
+/* Browse for export location */
+function wizardExportApplianceBrowseLocation() {
+
+ var dsepRegEx = $('#vboxPane').data('vboxConfig').DSEP;
+ if(dsepRegEx == '\\') dsepRegEx += '\\';
+
+ // Get current location
+ var loc = document.forms['frmwizardExportAppliance'].elements.wizardExportApplianceLocation.value;
+ if(loc.indexOf($('#vboxPane').data('vboxConfig').DSEP) > -1) {
+ var r = new RegExp(dsepRegEx+'([^'+dsepRegEx+']*)?$');
+ loc = loc.replace(r,'');
+ } else {
+ // no path set
+ loc = vboxDirname($('#vboxPane').data('vboxConfig').version.settingsFilePath) + $('#vboxPane').data('vboxConfig').DSEP;
+ }
+ vboxFileBrowser(loc,function(f){
+ if(!f) return;
+ // get file name
+ var r = new RegExp('.*'+dsepRegEx);
+ file = $(document.forms['frmwizardExportAppliance'].elements.wizardExportApplianceLocation).val().replace(r,'');
+ document.forms['frmwizardExportAppliance'].elements.wizardExportApplianceLocation.value = f+($('#vboxPane').data('vboxConfig').DSEP)+file;
+ },true,trans('Select a file to export into','UIWizardExportAppPage3'));
+
+}
+
+/* Determine default OVF name */
+function vboxWizardExportApplianceOVFName() {
+
+ // Keep track of where we were
+ var vmSel = $('#vboxExportAppVMList').children('li.vboxListItemSelected');
+
+ /* When going to step3, make sure vms are selected */
+ if(!vmSel.length) {
+ $('#vboxExportAppVMListContainer').addClass('vboxRequired');
+ return;
+ }
+ $('#vboxExportAppVMListContainer').removeClass('vboxRequired');
+
+
+ if(jQuery.trim($(document.forms['frmwizardExportAppliance'].elements.wizardExportApplianceLocation).val()) && $(document.forms['frmwizardExportAppliance'].elements.wizardExportApplianceLocation).data('userChanged'))
+ return;
+
+ $(document.forms['frmwizardExportAppliance'].elements.wizardExportApplianceLocation).data('userChanged', false);
+
+ var name = '';
+ if(vmSel.length > 1) {
+ name = 'Appliance';
+ } else {
+ name = jQuery.trim($(vmSel[0]).text());
+ }
+
+ // If there is already a folder chosen, don't change it
+ if(jQuery.trim($(document.forms['frmwizardExportAppliance'].elements.wizardExportApplianceLocation).val())) {
+ name = vboxDirname(jQuery.trim($(document.forms['frmwizardExportAppliance'].elements.wizardExportApplianceLocation).val())) + $('#vboxPane').data('vboxConfig').DSEP + name + '.ova';
+ } else {
+ name = vboxDirname($('#vboxPane').data('vboxConfig').version.settingsFilePath) + $('#vboxPane').data('vboxConfig').DSEP + name + '.ova';
+ }
+
+ $(document.forms['frmwizardExportAppliance'].elements.wizardExportApplianceLocation).val(name);
+
+};
+
+function vboxWizardExportApplianceUpdateList() {
+
+ var vms = $('#vboxExportAppVMList').children('li');
+
+ var tbl = $('#vboxExportProps');
+
+ for(var i = 0; i < vms.length; i++) {
+
+ var vmid = $(vms[i]).data('vm').id;
+
+ // Selected ?
+ if($(vms[i]).hasClass('vboxListItemSelected')) {
+ if($('#vboxAppliance-'+vmid).attr('id')) continue;
+ } else {
+ $(tbl).children('tr.vboxAppliance-'+vmid).remove();
+ continue;
+ }
+
+ // VM header row
+ var trparent = $('<tr />').attr({'id':'vboxAppliance-'+vmid}).addClass('vboxAppliance-'+vmid + ' vboxTableParent');
+ var td = $('<td />').attr({'colspan':'2','class':'vboxApplianceHeader'}).append(
+ $('<div />').css({'font-weight':'bold','padding-left':'6px'}).append(
+ $('<input />').attr({'type':'button','class':'vboxImgButton','style':'background-image: url(images/downArrow.png); margin:0px;margin-right:4px;padding:0px;vspace:0px;hspace:0px;width: 12px; height: 12px;'}).click(function(){
+
+ if(!$(this).data('toggleClicked')) {
+
+ $(this).data('toggleClicked', true);
+
+ $(this).css({'background-image':'url(images/rightArrow.png)'});
+ var tr = $(this).closest('tr');
+ $(tr).siblings('tr.vboxChildOf'+$(tr).data('vboxOrder')).hide();
+ } else {
+
+ $(this).data('toggleClicked', false);
+
+ $(this).css({'background-image':'url(images/downArrow.png)'});
+ var tr = $(this).closest('tr');
+ $(tr).siblings('tr.vboxChildOf'+$(tr).data('vboxOrder')).show();
+ }
+ })
+ ).append(
+ //trans('Virtual System X').replace('%s',(i+1))
+ $('<div />').text($(vms[i]).data('vm').name).html()
+ )
+ ).disableSelection();
+ $(trparent).append(td).data({'vm':$(vms[i]).data('vm'),'vboxOrder':i}).appendTo(tbl);
+
+ // VM properties
+ for(var p in vboxApplianceProps) {
+
+ var tr = $('<tr />').attr({'class':'vboxAppliance-'+vmid+' vboxChildOf' + i}).data({'vmprop':p});
+
+ $('<td />').css({'padding-left':'18px','white-space':'nowrap','width':'1%'}).html('<img src="images/vbox/'+vboxApplianceProps[p].icon+'_16px.png" /> ' + trans(vboxApplianceProps[p].label,'UIApplianceEditorWidget')).appendTo(tr);
+
+ $('<td />').attr({'class':'vboxHideOverflow vboxAppProp'+p}).css({'width':'100%','padding-left':'10px','padding-right':'2px'}).html('<div>'+$('<div />').text(($(trparent).data('vm')[p]||'')).html()+'</div>').dblclick((vboxApplianceProps[p].textarea ? vboxExportAppliancePropEditArea : vboxExportAppliancePropEdit )).appendTo(tr);
+
+ $(tbl).append(tr);
+ }
+ }
+ vboxColorRows(tbl,false,'vboxTableParent');
+
+
+};
+
+
+/* Edit property that has a text area */
+function vboxExportAppliancePropEditArea(evt,elm) {
+ vboxExportAppliancePropEditDialog(evt.target, $('<span />').html($(evt.target).html()).text());
+}
+
+/* Edit property dialog */
+function vboxExportAppliancePropEditDialog(elm, defaults) {
+
+ var d = $('<div />').css({'display':'none'});
+ var frm = $('<form />').attr({'onSubmit':'return false;'}).css({'margin':'0px','border':'0px','padding':'0px','width':'100%','height':'100%'});
+ $('<textarea />').attr({'id':'vboxExportAppliancePropTextarea'}).css({'height':'99%','width':'99%'}).val(defaults).appendTo(frm);
+ $(d).append(frm);
+
+ var buttons = {};
+ buttons[trans('OK','QIMessageBox')] = function(){
+ var d = vboxDivOverflowHidden(elm);
+ $(d).html($('<div />').text($('#vboxExportAppliancePropTextarea').val()).html());
+ $(elm).html('').append(d);
+ $(this).empty().remove();
+ };
+ buttons[trans('Cancel','QIMessageBox')] = function(){
+ $(this).empty().remove();
+ };
+ $(d).dialog({'height':300,'width':300,'closeOnEscape':false,'modal':true,'resizable':true,'dialogClass':'vboxDialogContent','draggable':true,'buttons':buttons,'title':$(elm).parent().siblings().first().html()});
+
+}
+/* Edit property that has a text box */
+function vboxExportAppliancePropEdit(evt,elm) {
+ var input = $('<input />').attr({'type':'text','class':'vboxText'}).css({'width':($(this).innerWidth()-12)+'px','margin':'0px'}).val($('<div />').html($(this).children().first().html()).text()).blur(function(){
+ var v = $(this).val();
+ var p = $(this).parent();
+ var d = vboxDivOverflowHidden(p);
+ $(this).remove();
+ $(d).html($('<div />').text(v).html());
+ $(p).html('').append(d);
+ }).keydown(function(e){if(e.keyCode == 13) $(this).trigger('blur');});
+ $(this).html('').append(input).children().first().focus();
+}
+
+</script>
diff --git a/panes/wizardFirstRun.html b/panes/wizardFirstRun.html
index b2c6bac..d6f8365 100644
--- a/panes/wizardFirstRun.html
+++ b/panes/wizardFirstRun.html
@@ -1,78 +1,78 @@
-<!--
-
- Panes for "First Run" wizard. Logic in vboxWizard()
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: wizardFirstRun.html 595 2015-04-17 09:50:36Z imoore76 $
-
- -->
-<!-- Step 1 -->
-<div id='wizardFirstRunStep1' title='Select start-up disk' style='display: none'>
-
- <span class='translate' id='wizardFirstRunStepWHD'>&lt;p&gt;Please select a virtual optical disk file or a physical optical drive containing a disk to start your new virtual machine from.&lt;/p&gt;&lt;p&gt;The disk should be suitable for starting a computer from and should contain the operating system you wish to install on the virtual machine if you want to do that now. The disk will be ejected from the virtual drive automatically next time you switch the virtual machine off, but you can also do this yourself if needed using the Devices menu.&lt;/p&gt;</span>
- <span class='translate' id='wizardFirstRunStepNoHD'>&lt;p&gt;Please select a virtual optical disk file or a physical optical drive containing a disk to start your new virtual machine from.&lt;/p&gt;&lt;p&gt;The disk should be suitable for starting a computer from. As this virtual machine has no hard drive you will not be able to install an operating system on it at the moment.&lt;/p&gt;</span>
-
- <table class='vboxInvisible'>
- <tr style='vertical-align: middle'><td>
- <select id='wizardFirstRunMedia'>
- </select>
- </td>
- <td style='width:1%' id='wizardFirstRunChoose'></td></tr>
- </table>
-</div>
-
-<script type='text/javascript'>
-
-$('#wizardFirstRunStep1').on('show',function(e,wiz){
-
- var hdFound = false;
- for(var i = 0; i < wiz.args.storageControllers.length; i++) {
- for(var a = 0; a < wiz.args.storageControllers[i].mediumAttachments.length; a++) {
- if(wiz.args.storageControllers[i].mediumAttachments[a].type == "HardDisk" &&
- wiz.args.storageControllers[i].mediumAttachments[a].medium != null) {
- hdFound = true;
- break;
- }
- }
- }
-
- $('#wizardFirstRunStepWHD').css({'display':(hdFound ? '' : 'none')});
- $('#wizardFirstRunStepNoHD').css({'display':(hdFound ? 'none' : '')});
-
- function wizardFirstRunFillMedia(sel) {
-
- var cds = vboxMedia.mediaForAttachmentType('DVD');
-
- $('#wizardFirstRunMedia')[0].options = [];
-
- for(var i = 0; i < cds.length; i++) {
- $('#wizardFirstRunMedia')[0].options[i] = new Option(vboxMedia.getName(cds[i]), cds[i].id, (sel && sel == cds[i].id), (sel && sel == cds[i].id));
- }
-
- }
-
- wizardFirstRunFillMedia();
-
- var wizardFirstRunBar = new vboxToolbarSingle({button: {
- /* Add Attachment Button */
- 'name' : 'mselecthdbtnd',
- 'label' : 'Choose a virtual optical disk file...',
- 'language_context': 'UIWizardFirstRun',
- 'icon' : 'select_file',
- 'click' : function () {
- vboxMedia.actions.choose(null,'DVD',function(med){
- if(!med) return;
- wizardFirstRunFillMedia(med.id);
- });
- }
- }});
- wizardFirstRunBar.renderTo('wizardFirstRunChoose');
-
- $('#wizardFirstRunMedia').hide();
- var w = $('#wizardFirstRunMedia').parent().innerWidth();
- $('#wizardFirstRunMedia').css({'width':w+'px'}).show();
-
-
-});
-
-</script>
+<!--
+
+ Panes for "First Run" wizard. Logic in vboxWizard()
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: wizardFirstRun.html 595 2015-04-17 09:50:36Z imoore76 $
+
+ -->
+<!-- Step 1 -->
+<div id='wizardFirstRunStep1' title='Select start-up disk' style='display: none'>
+
+ <span class='translate' id='wizardFirstRunStepWHD'>&lt;p&gt;Please select a virtual optical disk file or a physical optical drive containing a disk to start your new virtual machine from.&lt;/p&gt;&lt;p&gt;The disk should be suitable for starting a computer from and should contain the operating system you wish to install on the virtual machine if you want to do that now. The disk will be ejected from the virtual drive automatically next time you switch the virtual machine off, but you can also do this yourself if needed using the Devices menu.&lt;/p&gt;</span>
+ <span class='translate' id='wizardFirstRunStepNoHD'>&lt;p&gt;Please select a virtual optical disk file or a physical optical drive containing a disk to start your new virtual machine from.&lt;/p&gt;&lt;p&gt;The disk should be suitable for starting a computer from. As this virtual machine has no hard drive you will not be able to install an operating system on it at the moment.&lt;/p&gt;</span>
+
+ <table class='vboxInvisible'>
+ <tr style='vertical-align: middle'><td>
+ <select id='wizardFirstRunMedia'>
+ </select>
+ </td>
+ <td style='width:1%' id='wizardFirstRunChoose'></td></tr>
+ </table>
+</div>
+
+<script type='text/javascript'>
+
+$('#wizardFirstRunStep1').on('show',function(e,wiz){
+
+ var hdFound = false;
+ for(var i = 0; i < wiz.args.storageControllers.length; i++) {
+ for(var a = 0; a < wiz.args.storageControllers[i].mediumAttachments.length; a++) {
+ if(wiz.args.storageControllers[i].mediumAttachments[a].type == "HardDisk" &&
+ wiz.args.storageControllers[i].mediumAttachments[a].medium != null) {
+ hdFound = true;
+ break;
+ }
+ }
+ }
+
+ $('#wizardFirstRunStepWHD').css({'display':(hdFound ? '' : 'none')});
+ $('#wizardFirstRunStepNoHD').css({'display':(hdFound ? 'none' : '')});
+
+ function wizardFirstRunFillMedia(sel) {
+
+ var cds = vboxMedia.mediaForAttachmentType('DVD');
+
+ $('#wizardFirstRunMedia')[0].options = [];
+
+ for(var i = 0; i < cds.length; i++) {
+ $('#wizardFirstRunMedia')[0].options[i] = new Option(vboxMedia.getName(cds[i]), cds[i].id, (sel && sel == cds[i].id), (sel && sel == cds[i].id));
+ }
+
+ }
+
+ wizardFirstRunFillMedia();
+
+ var wizardFirstRunBar = new vboxToolbarSingle({button: {
+ /* Add Attachment Button */
+ 'name' : 'mselecthdbtnd',
+ 'label' : 'Choose a virtual optical disk file...',
+ 'language_context': 'UIWizardFirstRun',
+ 'icon' : 'select_file',
+ 'click' : function () {
+ vboxMedia.actions.choose(null,'DVD',function(med){
+ if(!med) return;
+ wizardFirstRunFillMedia(med.id);
+ });
+ }
+ }});
+ wizardFirstRunBar.renderTo('wizardFirstRunChoose');
+
+ $('#wizardFirstRunMedia').hide();
+ var w = $('#wizardFirstRunMedia').parent().innerWidth();
+ $('#wizardFirstRunMedia').css({'width':w+'px'}).show();
+
+
+});
+
+</script>
diff --git a/panes/wizardImportAppliance.html b/panes/wizardImportAppliance.html
index 9112a8c..b9f3563 100644
--- a/panes/wizardImportAppliance.html
+++ b/panes/wizardImportAppliance.html
@@ -1,552 +1,552 @@
-<!--
-
- Panes for import appliance wizard. Logic in vboxWizard() class
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: wizardImportAppliance.html 595 2015-04-17 09:50:36Z imoore76 $
-
- -->
-<!-- Step 1 -->
-<div id='wizardImportApplianceStep1' title='Appliance to import' style='display: none'>
-
- <span class='translate'>&lt;p&gt;VirtualBox currently supports importing appliances saved in the Open Virtualization Format (OVF). To continue, select the file to import below.&lt;/p&gt;</span>
-
- <div class='vboxOptions'>
- <table style='width: 100%;' class='vboxOptions'>
- <tr>
- <td style='width: 100%; white-space: nowrap' class='vboxFileFolderInput'>
- <input type='text' class='vboxText' name='wizardImportApplianceLocation' style='width: 100%'/>
- </td>
- <td style='width:1%' id='wizardImportApplianceLocationButton'></td>
- </tr>
- </table>
- </div>
-
-</div>
-
-
-<!-- Step 2 -->
-<div id='wizardImportApplianceStep2' title='Appliance settings' style='display: none; width: 100%;'>
-
- <div class='translate' style='margin-bottom:8px;'>These are the virtual machines contained in the appliance and the suggested settings of the imported VirtualBox machines. You can change many of the properties shown by double-clicking on the items and disable others using the check boxes below.</div>
-
- <div class='vboxBordered' id='vboxImportPropsContainer' style='overflow: auto;'>
- <table style='width: 100%;' class='vboxHorizontal'>
- <!--
- <thead>
- <tr>
- <th style='text-align: left; width: 1%; padding-left: 10px' class='translate'>Description</th>
- <th style='text-align: left; padding-left: 10px;' class='translate'>Configuration</th>
- </tr>
- </thead>
- -->
- <tbody id='vboxImportProps'>
- </tbody>
- </table>
- </div>
- <div style='margin:2px;margin-top:4px;padding:0px;'><label><input type='checkbox' class='vboxCheckbox' name='vboxImportReinitNetwork' />
- <span class='translateglob'>Reinitialize the MAC address of all network cards</span></label>
- </div>
-
-</div>
-<script type='text/javascript'>
-
-/* Draw button */
-new vboxToolbarSingle({button: {
- 'name' : 'mselecthdbtn',
- 'label' : 'Choose a virtual appliance file to import...',
- 'language_context': 'UIWizardImportApp',
- 'icon' : 'select_file',
- 'click' : function () {
- wizardImportApplianceBrowseLocation()
- }
-}}).renderTo('wizardImportApplianceLocationButton');
-
-$('#wizardImportApplianceStep2').find('span.translateglob').html(function(i,h){
- return trans(h,'UIApplianceEditorWidget');
-});
-
-/*
- *
- * VM Properties to edit / import
- *
- */
-var vboxApplianceImportProps = {
- 'Name' : {'label':'Name','icon':'name','edit':'text'},
- 'Description' : {'label':'Description','icon':'description','edit':'textarea'},
- 'OS' : {'label':'Guest OS Type','icon':'os_type','edit':function(elm){
- var input = $('<input />').attr({'type':'button','class':'vboxbutton'}).css({'width':($(elm).innerWidth()-12)+'px','margin':'0px'}).val($(elm).find('span.vboxApplianceOSTitle').html());
- $(elm).children().hide();
- $(elm).append(input);
- $(elm).children('input:button').first().contextMenu({
- menu: 'vboxOSTypesMenu',
- button: 0,
- mode: 'menu',
- inSpeed : -1,
- outSpeed : -1
- },
- function(a, el, pos, srcEl) {
- $(elm).find('span.vboxApplianceOSTitle').html(vboxSettingsOSTypesObj[a]['description']);
- $(elm).find('img.vboxApplianceOSIcon').attr('src','images/vbox/'+vboxGuestOSTypeIcon(a));
- $(elm).closest('td').data('descValue',a);
- $('#vboxImportProps').trigger('selectProp');
- }).focus();
- $('#vboxImportProps').one('selectProp',function(){
- $(elm).children('input:button').first().hide().siblings().show();
- $(elm).children('input:button').first().remove();
- });
-
- },'display':function(val){
- return $('<span />').append('<img class="vboxApplianceOSIcon" src="images/vbox/'+vboxGuestOSTypeIcon(val)+'" style="height: 16px; width: 16px; float: left; margin-top: 2px; margin-right: 4px; " /> <span class="vboxApplianceOSTitle">' + vboxSettingsOSTypesObj[val].description +'</span>').disableSelection().on('selectstart',function(e){e.preventDefault();return false;});
- }},
- 'CPU' : {'label':'CPU','icon':'cpu','edit':'text','postEdit':function(val,old){
- val = parseInt(val);
- if(isNaN(val)) return old;
- return Math.min($('#vboxPane').data('vboxSystemProperties').maxGuestCPUCount,Math.max($('#vboxPane').data('vboxSystemProperties').minGuestCPUCount,val));
- }},
- 'Memory' : {'label':'RAM','icon':'ram','edit':'text','display':function(val){
- return Math.max(parseInt(val),0) + ' ' + trans('MB','VBoxGlobal');
- },'postEdit':function(val,old) {
- val = parseInt(val);
- if(isNaN(val)) return old;
- return Math.min($('#vboxPane').data('vboxSystemProperties').maxGuestRAM,Math.max($('#vboxPane').data('vboxSystemProperties').minGuestRAM,val));
- }},
- 'SoundCard' : {'label':'Sound Card','icon':'sound','checkbox':true,'edit':'options','display':function(val){
- return trans(vboxAudioController($('#vboxPane').data('vboxAudioControllerTypes')[val]),'VBoxGlobal');
- }},
- 'CDROM' : {'label':'DVD','icon':'cd','checkbox':true,'edit':'checkbox'},
- 'USBController' : {'label':'USB Controller','icon':'usb','checkbox':true},
- 'NetworkAdapter' : {'label':'Network Adapter','icon':'nw','checkbox':true,'edit':'options','option_offset':-1,'display':function(val){
- return trans(vboxNetworkAdapterType($('#vboxPane').data('vboxNetworkAdapterTypes')[val]),'VBoxGlobal');
- }},
- 'Floppy' : {'label':'Floppy','icon':'floppy','checkbox':true},
- 'HardDiskControllerIDE' : {'label':'Storage Controller (IDE)','icon':'ide','edit':''},
- 'HardDiskControllerSATA' : {'label':'Storage Controller (SATA)','icon':'sata','edit':null},
- 'HardDiskControllerSAS' : {'label':'Storage Controller (SAS)','icon':'scsi','edit':null},
- 'HardDiskControllerSCSI' : {'label':'Storage Controller (SCSI)','icon':'scsi','edit':null},
- 'HardDiskImage' : {'label':'Virtual Disk Image','icon':'hd','edit':'text'}
-};
-
-/*
- *
- * Add Property Options
- *
- */
-// Storage controllers
-var stTypes = vboxStorage.getBusTypes();
-for(var i = 0; i < stTypes.length; i++) {
-
- if(!vboxApplianceImportProps['HardDiskController'+stTypes[i]]) continue;
-
- // Translate value
- vboxApplianceImportProps['HardDiskController'+stTypes[i]]['display'] = function(val){return trans(vboxStorageControllerType(val),'VBoxGlobal');};
-
- var ctypes = vboxStorage[stTypes[i]].types;
- if(ctypes.length < 2) continue;
-
- var opts = {};
- for(var a = 0; a < ctypes.length; a++) {
- opts[ctypes[a]] = trans(vboxStorageControllerType(ctypes[a]),'VBoxGlobal');
- }
- vboxApplianceImportProps['HardDiskController'+stTypes[i]]['edit'] = 'options';
- vboxApplianceImportProps['HardDiskController'+stTypes[i]]['options'] = opts;
-}
-
-vboxApplianceImportProps['NetworkAdapter']['options'] = [];
-vboxApplianceImportProps['SoundCard']['options'] = [];
-
-// Network adapters
-var cs = $('#vboxPane').data('vboxNetworkAdapterTypes');
-for(var i = 1; i < cs.length; i++) {
- vboxApplianceImportProps['NetworkAdapter']['options'][(i-1)] = trans(vboxNetworkAdapterType(cs[i]),'VBoxGlobal');
-}
-// Sound cards
-var cs = $('#vboxPane').data('vboxAudioControllerTypes');
-for(var i = 0; i < cs.length; i++) {
- vboxApplianceImportProps['SoundCard']['options'][i] = trans(vboxAudioController(cs[i]),'VBoxGlobal');
-}
-
-
-// OS Types
-/////////////////////////
-$('ul.vboxOSTypesMenuList').remove();
-
-// shorthand
-var vboxOSTypes = $('#vboxPane').data('vboxOSTypes');
-var vboxSettingsOSTypes = {};
-var vboxSettingsOSTypesObj = {};
-
-for(var i in vboxOSTypes) {
-
- // Skip unsupported OS Types
- if(!vboxOSTypes[i].supported) continue;
-
- // create array of os family types
- if(!vboxSettingsOSTypes[vboxOSTypes[i].familyId]) {
- vboxSettingsOSTypes[vboxOSTypes[i].familyId] = {'id':vboxOSTypes[i].familyId,'description':vboxOSTypes[i].familyDescription,'osTypes':[]};
- }
-
- vboxSettingsOSTypes[vboxOSTypes[i].familyId].osTypes[vboxSettingsOSTypes[vboxOSTypes[i].familyId].osTypes.length] = {'id':vboxOSTypes[i].id,'description':vboxOSTypes[i].description };
-
- vboxSettingsOSTypesObj[vboxOSTypes[i].id] = vboxOSTypes[i];
-
- // Preload icons
- vboxOSTypes[i].icon = new Image();
- vboxOSTypes[i].icon.src = "images/vbox/" + vboxGuestOSTypeIcon(vboxOSTypes[i].id);
-
-}
-
-var ul = $('<ul />').attr({'id':'vboxOSTypesMenu','class':'contextMenu contextMenuNoBG vboxOSTypesMenuList'});
-for(var i in vboxSettingsOSTypes) {
- var li = $('<li />').html('<a href="#null-'+i+'">'+vboxSettingsOSTypes[i].description+'</a>');
- var ul2 = $('<ul />').addClass('vboxOSTypesMenuList');
- for(var a in vboxSettingsOSTypes[i]['osTypes']) {
- $('<li />').html('<a href="#'+vboxSettingsOSTypes[i]['osTypes'][a]['id']+'"><img style="height: 16px; width:16px; margin-left: -22px; margin-top: 2px; float: left; " src="images/vbox/'+vboxGuestOSTypeIcon(vboxSettingsOSTypes[i]['osTypes'][a]['id'])+'" /> '+vboxSettingsOSTypes[i]['osTypes'][a]['description']+"</a>").appendTo(ul2);
- }
- $(li).append(ul2).appendTo(ul);
-}
-$('#vboxPane').append(ul);
-
-
-
-/* Browse for import location */
-function wizardImportApplianceBrowseLocation() {
-
- var dsepRegEx = $('#vboxPane').data('vboxConfig').DSEP;
- if(dsepRegEx == '\\') dsepRegEx += '\\';
-
- var loc = $('#vboxPane').data('vboxSystemProperties').defaultMachineFolder;
-
- vboxFileBrowser(loc,function(f){
- if(!f) return;
- document.forms['frmwizardImportAppliance'].elements.wizardImportApplianceLocation.value = f;
- },false,trans('Select an appliance to import','UIWizardImportApp'),'images/vbox/os_type_16px.png');
-
-}
-
-/* When going to step2, make sure a file is selected and
- * appliance file was parsed
- */
-$('#wizardImportApplianceStep2').on('show',function(e,wiz){
-
- if(!$(document.forms['frmwizardImportAppliance'].elements.wizardImportApplianceLocation).val()) {
- $(document.forms['frmwizardImportAppliance'].elements.wizardImportApplianceLocation).addClass('vboxRequired');
- wiz.displayStep(1);
- return;
- }
- $(document.forms['frmwizardImportAppliance'].elements.wizardImportApplianceLocation).removeClass('vboxRequired').focus();
-
- wizardImportAppResize();
-
- // Remove any existing VMs from Back / Forward wizard navigation
- $('#vboxImportProps').children().remove();
-
- /* Parse appliance file */
- var l = new vboxLoader();
- l.add('applianceReadInterpret',function(d){
- if(d && d.responseData && d.responseData.descriptions && d.responseData.descriptions.length) { wizardImportApplianceParsed(d.responseData); }
- else if(!d) { vboxAlert(trans('Unkown Error')); wiz.displayStep(1);}
- else { wiz.displayStep(1); } // no data. assume error was displayed
- },{'file':$(document.forms['frmwizardImportAppliance'].elements.wizardImportApplianceLocation).val()});
- l.run();
-
-});
-
-
-function wizardImportAppResize(){
- // Resize properties
- $('#vboxImportPropsContainer').hide();
- var h = $('#wizardImportApplianceStep2').parent().innerHeight() - $('#wizardImportApplianceTitle').outerHeight(true);
-
- $('#vboxImportPropsContainer').siblings().each(function(){
- h -= $(this).outerHeight(true);
- });
- $('#vboxImportPropsContainer').width($('#vboxImportPropsContainer').parent().innerWidth()).height(h-4).show();
-
-}
-$('#wizardImportApplianceDialog').on('dialogresizestop',wizardImportAppResize);
-
-/* After appliance file is parsed */
-function wizardImportApplianceParsed(d) {
-
- // Remove any existing data
- $('#vboxImportProps').children().remove();
-
- var tbl = $('#vboxImportProps');
- if(!d) d = {'descriptions':$(tbl).data('descriptions')};
- else $(tbl).data('descriptions',d.descriptions);
-
-
- for(var vm = 0; vm < d.descriptions.length; vm++) {
-
- var tr = $('<tr />').data({'vmDesc':d.descriptions[vm]}).attr({'class':'vboxApplianceHeaderRow'});
- var td = $('<td />').attr({'colspan':'2','class':'vboxApplianceHeader'});
- $('<input />').data({'vboxOrder':vm}).attr({'type':'button','class':'vboxImgButton','style':'background-image: url(images/downArrow.png); width: 12px; height: 12px; margin-right: 4px;'}).click(function(){
-
- if(!$(this).data('toggleClicked')) {
- $(this).data('toggleClicked', true);
- $(this).css({'background-image':'url(images/rightArrow.png)'});
- $(this).parent().parent().parent().children('tr.vboxChildOf'+$(this).data('vboxOrder')).css('display','none');
- } else {
- $(this).data('toggleClicked', false);
- $(this).css({'background-image':'url(images/downArrow.png)'});
- $(this).parent().parent().parent().children('tr.vboxChildOf'+$(this).data('vboxOrder')).css('display','');
- }
- }).appendTo(td);
- $(td).append(trans('Virtual System %1','UIApplianceEditorWidget').replace('%1',(vm+1))).appendTo(tr);
- $(tbl).append(tr);
-
- // Hard Disks are handled differently
- var hds = [];
-
- for(var i = 0; i < d.descriptions[vm][0].length; i++) {
-
- var desc = vboxApplianceImportProps[d.descriptions[vm][0][i]];
- if(desc == undefined) continue;
-
- var tr = $('<tr />').data({'descType':d.descriptions[vm][0][i],'descOrder':i}).addClass('vboxChildOf'+vm, ' vboxListItem').attr({'id':'vboxVM-'+vm+'-item-'+i}).click(function(){
- $('#vboxImportProps').find('input').trigger('blur');
- if($(this).hasClass('vboxListItemSelected')) return;
- $(this).siblings('tr.vboxListItemSelected').removeClass('vboxListItemSelected');
- $(this).addClass('vboxListItemSelected');
- $(this).parent().trigger('selectProp',this);
- });
-
- $('<td />').css({'white-space':'nowrap','width':'1%'}).attr({'class':'vbox'+d.descriptions[vm][0][i]}).html('<img src="images/vbox/blank.gif" class="vboxSpacer" style="height:2px;"/><img src="images/vbox/'+desc.icon+'_16px.png" style="height: 16px; width: 16px;"/> ' + trans(desc.label,'UIApplianceEditorWidget')).appendTo(tr);
-
- var td = $('<td />').attr({'class':'vboxHideOverflow'}).css({'padding-left':'10px'});
- if(desc.checkbox) {
- $('<input />').attr({'type':'checkbox','class':'vboxCheckbox'}).prop('checked',true).css({'margin-right':'5px'}).click(function(){
- $(this).closest('tr').data('propdisabled',!(this.checked));
- if(this.checked) {
- $(this).siblings().removeClass('vboxDisabled');
- } else {
- $(this).siblings().addClass('vboxDisabled');
- }
- }).appendTo(td);
- }
- var sp = $('<span />').css({'display':'inline-block'}).attr({'class':'vboxImportAppProp'});
- if(desc.display) {
- $(sp).html(desc.display(d.descriptions[vm][3][i]));
- } else {
- $(sp).text(d.descriptions[vm][3][i]);
- }
-
- $(td).data({'descValue':d.descriptions[vm][3][i]}).append(sp).dblclick(function(){
-
- // Edit property function
- var desc = vboxApplianceImportProps[$(this).parent().data('descType')];
-
- // Check for checkbox
- if(desc.checkbox && !$(this).children('input:checkbox').first().prop('checked')) return;
-
- switch(desc.edit) {
- case 'options':
- vboxImportAppliancePropEditOptions(this,desc);
- break;
- case 'text':
- vboxImportAppliancePropEdit(this,desc);
- break;
- case 'textarea':
- vboxImportAppliancePropEditArea(this,desc);
- break;
- default:
- if(typeof desc.edit == 'function') desc.edit(this,desc);
- }
- }).disableSelection().appendTo(tr);
-
- // Hard Disks are handled differently
- if(d.descriptions[vm][0][i] == 'HardDiskImage') {
- var place = d.descriptions[vm][4][i].split(';');
- var con = parseInt(place[0].replace(/.*=/,''));
- var dev = parseInt(place[1].replace(/.*=/,''));
- hds[hds.length] = {'element':tr,'controller':con,'device':dev};
- } else {
- $(tbl).append(tr);
- }
-
- } // </ foreach description item >
-
- // Attach hard disks
- hds.sort(function(a,b){
- if(a.device == b.device) return 0;
- return (a.device < b.device ? 1 : -1); // Yes. Reverse order.
- });
- for(var i = 0; i < hds.length; i++) {
- $('#vboxVM-'+vm+'-item-'+hds[i].controller).after(hds[i].element);
- }
-
- } // </ foreach vm >
-
- vboxColorRows(tbl,false,'vboxApplianceHeaderRow');
-
-
-
- $('#vboxImportProps').disableSelection();
-
- // Check for import warnings
- if(d.warnings && d.warnings.length) {
-
- var div = $('<div />');
- $(div).append(trans('Warnings:','UIApplianceEditorWidget'));
-
- var ul = $('<ul />');
-
- for(var i = 0; i < d.warnings.length; i++) {
- $('<li />').html(d.warnings[i]).appendTo(ul);
- }
- $(div).append(ul);
- var buttons = {};
- buttons[trans('OK','QIMessageBox')] = function(){$(this).empty().remove();};
- $(div).dialog({'height':300,'width':300,'closeOnEscape':false,'modal':true,'resizable':true,'draggable':true,'buttons':buttons,'title':trans('Warnings:')});
-
- }
-
-
-};
-
-
-
-/*
- *
- * Edit property that has options
- *
- */
-function vboxImportAppliancePropEditOptions(elm,desc) {
-
- var s = $('<select />').attr({'id':'vboxImportAppSelect'}).css({'width':'100%'}).change(function(){
- $(this).parent().data('descValue',$(this).val());
- var txt = this.options[this.selectedIndex].text;
-
- $(this).siblings('span.vboxImportAppProp').text(txt);
-
- });
- var val = $(elm).data('descValue');
- if(desc.option_offset) {
- val = parseInt(val) + parseInt(desc.option_offset);
- val = ''+val;
- }
- selOpt = 0;
- var a = 0;
- for(var i in desc.options) {
- $(s).prop('options').add(new Option(desc.options[i],i,(i == val),(i == val)));
- if(i==val) selOpt = a;
- a++;
- }
- $(s).attr('selectedIndex',selOpt);
- $(elm).children().hide();
- $(elm).append(s);
- $('#vboxImportProps').one('selectProp',function(){
- $('#vboxImportAppSelect').hide().siblings().show();
- $('#vboxImportAppSelect').remove();
- });
-
-}
-
-
-
-/*
- *
- * Edit property that has a text area
- *
- */
-function vboxImportAppliancePropEditArea(elm) {
-
- $(elm).children().hide();
-
- $('<input />').attr({'type':'button','class':'vboxbutton'}).css({'width':($(elm).innerWidth()-12)+'px','margin':'0px'}).val(trans('Edit text','VBoxTextEditor')).click(function(){
- vboxImportAppliancePropEditDialog(elm);
- $('#vboxImportProps').trigger('selectProp');
- }).appendTo(elm);
-
- $(elm).children('input:button').first().focus();
- $('#vboxImportProps').one('selectProp',function(){
- $(elm).children('input:button').first().hide().siblings().show();
- $(elm).children('input:button').first().remove();
- });
-}
-
-/*
- *
- * Edit property dialog
- *
- */
-function vboxImportAppliancePropEditDialog(td) {
-
- var d = $('<div />').css({'display':'none'});
- var frm = $('<form />').attr({'onSubmit':'return false;'}).css({'margin':'0px','border':'0px','padding':'0px','width':'100%','height':'100%'});
-
- $('<textarea />').attr({'id':'vboxImportAppliancePropTextarea'}).css({'height':'99%','width':'99%'}).val($(td).data('descValue')).appendTo(frm);
-
- $(d).append(frm);
-
- var buttons = {};
- buttons[trans('OK','QIMessageBox')] = function(){
- $(td).data('descValue',$('#vboxImportAppliancePropTextarea').val());
- $(td).children('span.vboxImportAppProp').html($('<div />').text($('#vboxImportAppliancePropTextarea').val()).html());
- $(this).empty().remove();
- };
- buttons[trans('Cancel','QIMessageBox')] = function(){$(this).empty().remove();};
- $(d).dialog({'height':300,'width':300,'closeOnEscape':false,'modal':true,'resizable':true,'dialogClass':'vboxDialogContent','draggable':true,'buttons':buttons,'title':$(td).prev().html()});
-
-}
-
-/*
- *
- * Edit property that has a text box
- *
- */
-function vboxImportAppliancePropEdit(elm,desc) {
- $(elm).children().hide();
- $('<input />').attr({'type':'text','class':'vboxText'}).css({'width':($(elm).innerWidth()-12)+'px','margin':'0px'}).val($(elm).data('descValue')).blur(function(){
-
- var tbox = this;
-
- var val = (desc.postEdit ? desc.postEdit($(tbox).val(),$(tbox).parent().data('descValue')) : $(tbox).val());
- if(val != $(tbox).parent().data('descValue')) {
- $(tbox).parent().data('descValue',val);
- if(desc.display) {
- $(tbox).siblings('span.vboxImportAppProp').html(desc.display(val));
- } else {
- $(tbox).siblings('span.vboxImportAppProp').text(val);
- }
- $(tbox).parent().data('edited', true);
-
- // Special case for name
- if(desc.label == 'Name') {
-
- // Get ChildOf class
- var r = /(vboxChildOf\d+)/;
- var coClass = r.exec($(tbox).closest('tr').attr('class'));
- coClass = coClass[1];
-
- // Get unedited disk rows
- var diskRows = new Array();
- $.each($(tbox).parent().closest('tr').siblings('.'+coClass), function(i,e){
- if(!$(e).data('edited') && $(e).data('descType') == 'HardDiskImage') {
- diskRows[diskRows.length] = e;
- }
- });
-
- if(diskRows.length) {
- var mfd = new vboxLoader();
- mfd.add('vboxGetComposedMachineFilename',function(d){
- var mfolder = vboxDirname(d.responseData) + $("#vboxPane").data('vboxConfig').DSEP;
- for(var i = 0; i < diskRows.length; i++) {
- var tdc = $(diskRows[i]).children().eq(1);
- var dname = vboxBasename($(tdc).data('descValue'));
- $(tdc).data({'descValue':mfolder + dname}).find('span.vboxImportAppProp').text(mfolder + dname);
- }
- },{'name':val,'group':''});
- mfd.run();
- }
- }
- }
- $(tbox).hide();
- $(tbox).siblings().show();
- $(tbox).remove();
- }).keydown(function(e){if(e.keyCode == 13) $(this).trigger('blur');}).appendTo(elm);
- $(elm).children('input:text').first().focus();
-}
-
-</script>
+<!--
+
+ Panes for import appliance wizard. Logic in vboxWizard() class
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: wizardImportAppliance.html 595 2015-04-17 09:50:36Z imoore76 $
+
+ -->
+<!-- Step 1 -->
+<div id='wizardImportApplianceStep1' title='Appliance to import' style='display: none'>
+
+ <span class='translate'>&lt;p&gt;VirtualBox currently supports importing appliances saved in the Open Virtualization Format (OVF). To continue, select the file to import below.&lt;/p&gt;</span>
+
+ <div class='vboxOptions'>
+ <table style='width: 100%;' class='vboxOptions'>
+ <tr>
+ <td style='width: 100%; white-space: nowrap' class='vboxFileFolderInput'>
+ <input type='text' class='vboxText' name='wizardImportApplianceLocation' style='width: 100%'/>
+ </td>
+ <td style='width:1%' id='wizardImportApplianceLocationButton'></td>
+ </tr>
+ </table>
+ </div>
+
+</div>
+
+
+<!-- Step 2 -->
+<div id='wizardImportApplianceStep2' title='Appliance settings' style='display: none; width: 100%;'>
+
+ <div class='translate' style='margin-bottom:8px;'>These are the virtual machines contained in the appliance and the suggested settings of the imported VirtualBox machines. You can change many of the properties shown by double-clicking on the items and disable others using the check boxes below.</div>
+
+ <div class='vboxBordered' id='vboxImportPropsContainer' style='overflow: auto;'>
+ <table style='width: 100%;' class='vboxHorizontal'>
+ <!--
+ <thead>
+ <tr>
+ <th style='text-align: left; width: 1%; padding-left: 10px' class='translate'>Description</th>
+ <th style='text-align: left; padding-left: 10px;' class='translate'>Configuration</th>
+ </tr>
+ </thead>
+ -->
+ <tbody id='vboxImportProps'>
+ </tbody>
+ </table>
+ </div>
+ <div style='margin:2px;margin-top:4px;padding:0px;'><label><input type='checkbox' class='vboxCheckbox' name='vboxImportReinitNetwork' />
+ <span class='translateglob'>Reinitialize the MAC address of all network cards</span></label>
+ </div>
+
+</div>
+<script type='text/javascript'>
+
+/* Draw button */
+new vboxToolbarSingle({button: {
+ 'name' : 'mselecthdbtn',
+ 'label' : 'Choose a virtual appliance file to import...',
+ 'language_context': 'UIWizardImportApp',
+ 'icon' : 'select_file',
+ 'click' : function () {
+ wizardImportApplianceBrowseLocation()
+ }
+}}).renderTo('wizardImportApplianceLocationButton');
+
+$('#wizardImportApplianceStep2').find('span.translateglob').html(function(i,h){
+ return trans(h,'UIApplianceEditorWidget');
+});
+
+/*
+ *
+ * VM Properties to edit / import
+ *
+ */
+var vboxApplianceImportProps = {
+ 'Name' : {'label':'Name','icon':'name','edit':'text'},
+ 'Description' : {'label':'Description','icon':'description','edit':'textarea'},
+ 'OS' : {'label':'Guest OS Type','icon':'os_type','edit':function(elm){
+ var input = $('<input />').attr({'type':'button','class':'vboxbutton'}).css({'width':($(elm).innerWidth()-12)+'px','margin':'0px'}).val($(elm).find('span.vboxApplianceOSTitle').html());
+ $(elm).children().hide();
+ $(elm).append(input);
+ $(elm).children('input:button').first().contextMenu({
+ menu: 'vboxOSTypesMenu',
+ button: 0,
+ mode: 'menu',
+ inSpeed : -1,
+ outSpeed : -1
+ },
+ function(a, el, pos, srcEl) {
+ $(elm).find('span.vboxApplianceOSTitle').html(vboxSettingsOSTypesObj[a]['description']);
+ $(elm).find('img.vboxApplianceOSIcon').attr('src','images/vbox/'+vboxGuestOSTypeIcon(a));
+ $(elm).closest('td').data('descValue',a);
+ $('#vboxImportProps').trigger('selectProp');
+ }).focus();
+ $('#vboxImportProps').one('selectProp',function(){
+ $(elm).children('input:button').first().hide().siblings().show();
+ $(elm).children('input:button').first().remove();
+ });
+
+ },'display':function(val){
+ return $('<span />').append('<img class="vboxApplianceOSIcon" src="images/vbox/'+vboxGuestOSTypeIcon(val)+'" style="height: 16px; width: 16px; float: left; margin-top: 2px; margin-right: 4px; " /> <span class="vboxApplianceOSTitle">' + vboxSettingsOSTypesObj[val].description +'</span>').disableSelection().on('selectstart',function(e){e.preventDefault();return false;});
+ }},
+ 'CPU' : {'label':'CPU','icon':'cpu','edit':'text','postEdit':function(val,old){
+ val = parseInt(val);
+ if(isNaN(val)) return old;
+ return Math.min($('#vboxPane').data('vboxSystemProperties').maxGuestCPUCount,Math.max($('#vboxPane').data('vboxSystemProperties').minGuestCPUCount,val));
+ }},
+ 'Memory' : {'label':'RAM','icon':'ram','edit':'text','display':function(val){
+ return Math.max(parseInt(val),0) + ' ' + trans('MB','VBoxGlobal');
+ },'postEdit':function(val,old) {
+ val = parseInt(val);
+ if(isNaN(val)) return old;
+ return Math.min($('#vboxPane').data('vboxSystemProperties').maxGuestRAM,Math.max($('#vboxPane').data('vboxSystemProperties').minGuestRAM,val));
+ }},
+ 'SoundCard' : {'label':'Sound Card','icon':'sound','checkbox':true,'edit':'options','display':function(val){
+ return trans(vboxAudioController($('#vboxPane').data('vboxAudioControllerTypes')[val]),'VBoxGlobal');
+ }},
+ 'CDROM' : {'label':'DVD','icon':'cd','checkbox':true,'edit':'checkbox'},
+ 'USBController' : {'label':'USB Controller','icon':'usb','checkbox':true},
+ 'NetworkAdapter' : {'label':'Network Adapter','icon':'nw','checkbox':true,'edit':'options','option_offset':-1,'display':function(val){
+ return trans(vboxNetworkAdapterType($('#vboxPane').data('vboxNetworkAdapterTypes')[val]),'VBoxGlobal');
+ }},
+ 'Floppy' : {'label':'Floppy','icon':'floppy','checkbox':true},
+ 'HardDiskControllerIDE' : {'label':'Storage Controller (IDE)','icon':'ide','edit':''},
+ 'HardDiskControllerSATA' : {'label':'Storage Controller (SATA)','icon':'sata','edit':null},
+ 'HardDiskControllerSAS' : {'label':'Storage Controller (SAS)','icon':'scsi','edit':null},
+ 'HardDiskControllerSCSI' : {'label':'Storage Controller (SCSI)','icon':'scsi','edit':null},
+ 'HardDiskImage' : {'label':'Virtual Disk Image','icon':'hd','edit':'text'}
+};
+
+/*
+ *
+ * Add Property Options
+ *
+ */
+// Storage controllers
+var stTypes = vboxStorage.getBusTypes();
+for(var i = 0; i < stTypes.length; i++) {
+
+ if(!vboxApplianceImportProps['HardDiskController'+stTypes[i]]) continue;
+
+ // Translate value
+ vboxApplianceImportProps['HardDiskController'+stTypes[i]]['display'] = function(val){return trans(vboxStorageControllerType(val),'VBoxGlobal');};
+
+ var ctypes = vboxStorage[stTypes[i]].types;
+ if(ctypes.length < 2) continue;
+
+ var opts = {};
+ for(var a = 0; a < ctypes.length; a++) {
+ opts[ctypes[a]] = trans(vboxStorageControllerType(ctypes[a]),'VBoxGlobal');
+ }
+ vboxApplianceImportProps['HardDiskController'+stTypes[i]]['edit'] = 'options';
+ vboxApplianceImportProps['HardDiskController'+stTypes[i]]['options'] = opts;
+}
+
+vboxApplianceImportProps['NetworkAdapter']['options'] = [];
+vboxApplianceImportProps['SoundCard']['options'] = [];
+
+// Network adapters
+var cs = $('#vboxPane').data('vboxNetworkAdapterTypes');
+for(var i = 1; i < cs.length; i++) {
+ vboxApplianceImportProps['NetworkAdapter']['options'][(i-1)] = trans(vboxNetworkAdapterType(cs[i]),'VBoxGlobal');
+}
+// Sound cards
+var cs = $('#vboxPane').data('vboxAudioControllerTypes');
+for(var i = 0; i < cs.length; i++) {
+ vboxApplianceImportProps['SoundCard']['options'][i] = trans(vboxAudioController(cs[i]),'VBoxGlobal');
+}
+
+
+// OS Types
+/////////////////////////
+$('ul.vboxOSTypesMenuList').remove();
+
+// shorthand
+var vboxOSTypes = $('#vboxPane').data('vboxOSTypes');
+var vboxSettingsOSTypes = {};
+var vboxSettingsOSTypesObj = {};
+
+for(var i in vboxOSTypes) {
+
+ // Skip unsupported OS Types
+ if(!vboxOSTypes[i].supported) continue;
+
+ // create array of os family types
+ if(!vboxSettingsOSTypes[vboxOSTypes[i].familyId]) {
+ vboxSettingsOSTypes[vboxOSTypes[i].familyId] = {'id':vboxOSTypes[i].familyId,'description':vboxOSTypes[i].familyDescription,'osTypes':[]};
+ }
+
+ vboxSettingsOSTypes[vboxOSTypes[i].familyId].osTypes[vboxSettingsOSTypes[vboxOSTypes[i].familyId].osTypes.length] = {'id':vboxOSTypes[i].id,'description':vboxOSTypes[i].description };
+
+ vboxSettingsOSTypesObj[vboxOSTypes[i].id] = vboxOSTypes[i];
+
+ // Preload icons
+ vboxOSTypes[i].icon = new Image();
+ vboxOSTypes[i].icon.src = "images/vbox/" + vboxGuestOSTypeIcon(vboxOSTypes[i].id);
+
+}
+
+var ul = $('<ul />').attr({'id':'vboxOSTypesMenu','class':'contextMenu contextMenuNoBG vboxOSTypesMenuList'});
+for(var i in vboxSettingsOSTypes) {
+ var li = $('<li />').html('<a href="#null-'+i+'">'+vboxSettingsOSTypes[i].description+'</a>');
+ var ul2 = $('<ul />').addClass('vboxOSTypesMenuList');
+ for(var a in vboxSettingsOSTypes[i]['osTypes']) {
+ $('<li />').html('<a href="#'+vboxSettingsOSTypes[i]['osTypes'][a]['id']+'"><img style="height: 16px; width:16px; margin-left: -22px; margin-top: 2px; float: left; " src="images/vbox/'+vboxGuestOSTypeIcon(vboxSettingsOSTypes[i]['osTypes'][a]['id'])+'" /> '+vboxSettingsOSTypes[i]['osTypes'][a]['description']+"</a>").appendTo(ul2);
+ }
+ $(li).append(ul2).appendTo(ul);
+}
+$('#vboxPane').append(ul);
+
+
+
+/* Browse for import location */
+function wizardImportApplianceBrowseLocation() {
+
+ var dsepRegEx = $('#vboxPane').data('vboxConfig').DSEP;
+ if(dsepRegEx == '\\') dsepRegEx += '\\';
+
+ var loc = $('#vboxPane').data('vboxSystemProperties').defaultMachineFolder;
+
+ vboxFileBrowser(loc,function(f){
+ if(!f) return;
+ document.forms['frmwizardImportAppliance'].elements.wizardImportApplianceLocation.value = f;
+ },false,trans('Select an appliance to import','UIWizardImportApp'),'images/vbox/os_type_16px.png');
+
+}
+
+/* When going to step2, make sure a file is selected and
+ * appliance file was parsed
+ */
+$('#wizardImportApplianceStep2').on('show',function(e,wiz){
+
+ if(!$(document.forms['frmwizardImportAppliance'].elements.wizardImportApplianceLocation).val()) {
+ $(document.forms['frmwizardImportAppliance'].elements.wizardImportApplianceLocation).addClass('vboxRequired');
+ wiz.displayStep(1);
+ return;
+ }
+ $(document.forms['frmwizardImportAppliance'].elements.wizardImportApplianceLocation).removeClass('vboxRequired').focus();
+
+ wizardImportAppResize();
+
+ // Remove any existing VMs from Back / Forward wizard navigation
+ $('#vboxImportProps').children().remove();
+
+ /* Parse appliance file */
+ var l = new vboxLoader();
+ l.add('applianceReadInterpret',function(d){
+ if(d && d.responseData && d.responseData.descriptions && d.responseData.descriptions.length) { wizardImportApplianceParsed(d.responseData); }
+ else if(!d) { vboxAlert(trans('Unkown Error')); wiz.displayStep(1);}
+ else { wiz.displayStep(1); } // no data. assume error was displayed
+ },{'file':$(document.forms['frmwizardImportAppliance'].elements.wizardImportApplianceLocation).val()});
+ l.run();
+
+});
+
+
+function wizardImportAppResize(){
+ // Resize properties
+ $('#vboxImportPropsContainer').hide();
+ var h = $('#wizardImportApplianceStep2').parent().innerHeight() - $('#wizardImportApplianceTitle').outerHeight(true);
+
+ $('#vboxImportPropsContainer').siblings().each(function(){
+ h -= $(this).outerHeight(true);
+ });
+ $('#vboxImportPropsContainer').width($('#vboxImportPropsContainer').parent().innerWidth()).height(h-4).show();
+
+}
+$('#wizardImportApplianceDialog').on('dialogresizestop',wizardImportAppResize);
+
+/* After appliance file is parsed */
+function wizardImportApplianceParsed(d) {
+
+ // Remove any existing data
+ $('#vboxImportProps').children().remove();
+
+ var tbl = $('#vboxImportProps');
+ if(!d) d = {'descriptions':$(tbl).data('descriptions')};
+ else $(tbl).data('descriptions',d.descriptions);
+
+
+ for(var vm = 0; vm < d.descriptions.length; vm++) {
+
+ var tr = $('<tr />').data({'vmDesc':d.descriptions[vm]}).attr({'class':'vboxApplianceHeaderRow'});
+ var td = $('<td />').attr({'colspan':'2','class':'vboxApplianceHeader'});
+ $('<input />').data({'vboxOrder':vm}).attr({'type':'button','class':'vboxImgButton','style':'background-image: url(images/downArrow.png); width: 12px; height: 12px; margin-right: 4px;'}).click(function(){
+
+ if(!$(this).data('toggleClicked')) {
+ $(this).data('toggleClicked', true);
+ $(this).css({'background-image':'url(images/rightArrow.png)'});
+ $(this).parent().parent().parent().children('tr.vboxChildOf'+$(this).data('vboxOrder')).css('display','none');
+ } else {
+ $(this).data('toggleClicked', false);
+ $(this).css({'background-image':'url(images/downArrow.png)'});
+ $(this).parent().parent().parent().children('tr.vboxChildOf'+$(this).data('vboxOrder')).css('display','');
+ }
+ }).appendTo(td);
+ $(td).append(trans('Virtual System %1','UIApplianceEditorWidget').replace('%1',(vm+1))).appendTo(tr);
+ $(tbl).append(tr);
+
+ // Hard Disks are handled differently
+ var hds = [];
+
+ for(var i = 0; i < d.descriptions[vm][0].length; i++) {
+
+ var desc = vboxApplianceImportProps[d.descriptions[vm][0][i]];
+ if(desc == undefined) continue;
+
+ var tr = $('<tr />').data({'descType':d.descriptions[vm][0][i],'descOrder':i}).addClass('vboxChildOf'+vm, ' vboxListItem').attr({'id':'vboxVM-'+vm+'-item-'+i}).click(function(){
+ $('#vboxImportProps').find('input').trigger('blur');
+ if($(this).hasClass('vboxListItemSelected')) return;
+ $(this).siblings('tr.vboxListItemSelected').removeClass('vboxListItemSelected');
+ $(this).addClass('vboxListItemSelected');
+ $(this).parent().trigger('selectProp',this);
+ });
+
+ $('<td />').css({'white-space':'nowrap','width':'1%'}).attr({'class':'vbox'+d.descriptions[vm][0][i]}).html('<img src="images/vbox/blank.gif" class="vboxSpacer" style="height:2px;"/><img src="images/vbox/'+desc.icon+'_16px.png" style="height: 16px; width: 16px;"/> ' + trans(desc.label,'UIApplianceEditorWidget')).appendTo(tr);
+
+ var td = $('<td />').attr({'class':'vboxHideOverflow'}).css({'padding-left':'10px'});
+ if(desc.checkbox) {
+ $('<input />').attr({'type':'checkbox','class':'vboxCheckbox'}).prop('checked',true).css({'margin-right':'5px'}).click(function(){
+ $(this).closest('tr').data('propdisabled',!(this.checked));
+ if(this.checked) {
+ $(this).siblings().removeClass('vboxDisabled');
+ } else {
+ $(this).siblings().addClass('vboxDisabled');
+ }
+ }).appendTo(td);
+ }
+ var sp = $('<span />').css({'display':'inline-block'}).attr({'class':'vboxImportAppProp'});
+ if(desc.display) {
+ $(sp).html(desc.display(d.descriptions[vm][3][i]));
+ } else {
+ $(sp).text(d.descriptions[vm][3][i]);
+ }
+
+ $(td).data({'descValue':d.descriptions[vm][3][i]}).append(sp).dblclick(function(){
+
+ // Edit property function
+ var desc = vboxApplianceImportProps[$(this).parent().data('descType')];
+
+ // Check for checkbox
+ if(desc.checkbox && !$(this).children('input:checkbox').first().prop('checked')) return;
+
+ switch(desc.edit) {
+ case 'options':
+ vboxImportAppliancePropEditOptions(this,desc);
+ break;
+ case 'text':
+ vboxImportAppliancePropEdit(this,desc);
+ break;
+ case 'textarea':
+ vboxImportAppliancePropEditArea(this,desc);
+ break;
+ default:
+ if(typeof desc.edit == 'function') desc.edit(this,desc);
+ }
+ }).disableSelection().appendTo(tr);
+
+ // Hard Disks are handled differently
+ if(d.descriptions[vm][0][i] == 'HardDiskImage') {
+ var place = d.descriptions[vm][4][i].split(';');
+ var con = parseInt(place[0].replace(/.*=/,''));
+ var dev = parseInt(place[1].replace(/.*=/,''));
+ hds[hds.length] = {'element':tr,'controller':con,'device':dev};
+ } else {
+ $(tbl).append(tr);
+ }
+
+ } // </ foreach description item >
+
+ // Attach hard disks
+ hds.sort(function(a,b){
+ if(a.device == b.device) return 0;
+ return (a.device < b.device ? 1 : -1); // Yes. Reverse order.
+ });
+ for(var i = 0; i < hds.length; i++) {
+ $('#vboxVM-'+vm+'-item-'+hds[i].controller).after(hds[i].element);
+ }
+
+ } // </ foreach vm >
+
+ vboxColorRows(tbl,false,'vboxApplianceHeaderRow');
+
+
+
+ $('#vboxImportProps').disableSelection();
+
+ // Check for import warnings
+ if(d.warnings && d.warnings.length) {
+
+ var div = $('<div />');
+ $(div).append(trans('Warnings:','UIApplianceEditorWidget'));
+
+ var ul = $('<ul />');
+
+ for(var i = 0; i < d.warnings.length; i++) {
+ $('<li />').html(d.warnings[i]).appendTo(ul);
+ }
+ $(div).append(ul);
+ var buttons = {};
+ buttons[trans('OK','QIMessageBox')] = function(){$(this).empty().remove();};
+ $(div).dialog({'height':300,'width':300,'closeOnEscape':false,'modal':true,'resizable':true,'draggable':true,'buttons':buttons,'title':trans('Warnings:')});
+
+ }
+
+
+};
+
+
+
+/*
+ *
+ * Edit property that has options
+ *
+ */
+function vboxImportAppliancePropEditOptions(elm,desc) {
+
+ var s = $('<select />').attr({'id':'vboxImportAppSelect'}).css({'width':'100%'}).change(function(){
+ $(this).parent().data('descValue',$(this).val());
+ var txt = this.options[this.selectedIndex].text;
+
+ $(this).siblings('span.vboxImportAppProp').text(txt);
+
+ });
+ var val = $(elm).data('descValue');
+ if(desc.option_offset) {
+ val = parseInt(val) + parseInt(desc.option_offset);
+ val = ''+val;
+ }
+ selOpt = 0;
+ var a = 0;
+ for(var i in desc.options) {
+ $(s).prop('options').add(new Option(desc.options[i],i,(i == val),(i == val)));
+ if(i==val) selOpt = a;
+ a++;
+ }
+ $(s).attr('selectedIndex',selOpt);
+ $(elm).children().hide();
+ $(elm).append(s);
+ $('#vboxImportProps').one('selectProp',function(){
+ $('#vboxImportAppSelect').hide().siblings().show();
+ $('#vboxImportAppSelect').remove();
+ });
+
+}
+
+
+
+/*
+ *
+ * Edit property that has a text area
+ *
+ */
+function vboxImportAppliancePropEditArea(elm) {
+
+ $(elm).children().hide();
+
+ $('<input />').attr({'type':'button','class':'vboxbutton'}).css({'width':($(elm).innerWidth()-12)+'px','margin':'0px'}).val(trans('Edit text','VBoxTextEditor')).click(function(){
+ vboxImportAppliancePropEditDialog(elm);
+ $('#vboxImportProps').trigger('selectProp');
+ }).appendTo(elm);
+
+ $(elm).children('input:button').first().focus();
+ $('#vboxImportProps').one('selectProp',function(){
+ $(elm).children('input:button').first().hide().siblings().show();
+ $(elm).children('input:button').first().remove();
+ });
+}
+
+/*
+ *
+ * Edit property dialog
+ *
+ */
+function vboxImportAppliancePropEditDialog(td) {
+
+ var d = $('<div />').css({'display':'none'});
+ var frm = $('<form />').attr({'onSubmit':'return false;'}).css({'margin':'0px','border':'0px','padding':'0px','width':'100%','height':'100%'});
+
+ $('<textarea />').attr({'id':'vboxImportAppliancePropTextarea'}).css({'height':'99%','width':'99%'}).val($(td).data('descValue')).appendTo(frm);
+
+ $(d).append(frm);
+
+ var buttons = {};
+ buttons[trans('OK','QIMessageBox')] = function(){
+ $(td).data('descValue',$('#vboxImportAppliancePropTextarea').val());
+ $(td).children('span.vboxImportAppProp').html($('<div />').text($('#vboxImportAppliancePropTextarea').val()).html());
+ $(this).empty().remove();
+ };
+ buttons[trans('Cancel','QIMessageBox')] = function(){$(this).empty().remove();};
+ $(d).dialog({'height':300,'width':300,'closeOnEscape':false,'modal':true,'resizable':true,'dialogClass':'vboxDialogContent','draggable':true,'buttons':buttons,'title':$(td).prev().html()});
+
+}
+
+/*
+ *
+ * Edit property that has a text box
+ *
+ */
+function vboxImportAppliancePropEdit(elm,desc) {
+ $(elm).children().hide();
+ $('<input />').attr({'type':'text','class':'vboxText'}).css({'width':($(elm).innerWidth()-12)+'px','margin':'0px'}).val($(elm).data('descValue')).blur(function(){
+
+ var tbox = this;
+
+ var val = (desc.postEdit ? desc.postEdit($(tbox).val(),$(tbox).parent().data('descValue')) : $(tbox).val());
+ if(val != $(tbox).parent().data('descValue')) {
+ $(tbox).parent().data('descValue',val);
+ if(desc.display) {
+ $(tbox).siblings('span.vboxImportAppProp').html(desc.display(val));
+ } else {
+ $(tbox).siblings('span.vboxImportAppProp').text(val);
+ }
+ $(tbox).parent().data('edited', true);
+
+ // Special case for name
+ if(desc.label == 'Name') {
+
+ // Get ChildOf class
+ var r = /(vboxChildOf\d+)/;
+ var coClass = r.exec($(tbox).closest('tr').attr('class'));
+ coClass = coClass[1];
+
+ // Get unedited disk rows
+ var diskRows = new Array();
+ $.each($(tbox).parent().closest('tr').siblings('.'+coClass), function(i,e){
+ if(!$(e).data('edited') && $(e).data('descType') == 'HardDiskImage') {
+ diskRows[diskRows.length] = e;
+ }
+ });
+
+ if(diskRows.length) {
+ var mfd = new vboxLoader();
+ mfd.add('vboxGetComposedMachineFilename',function(d){
+ var mfolder = vboxDirname(d.responseData) + $("#vboxPane").data('vboxConfig').DSEP;
+ for(var i = 0; i < diskRows.length; i++) {
+ var tdc = $(diskRows[i]).children().eq(1);
+ var dname = vboxBasename($(tdc).data('descValue'));
+ $(tdc).data({'descValue':mfolder + dname}).find('span.vboxImportAppProp').text(mfolder + dname);
+ }
+ },{'name':val,'group':''});
+ mfd.run();
+ }
+ }
+ }
+ $(tbox).hide();
+ $(tbox).siblings().show();
+ $(tbox).remove();
+ }).keydown(function(e){if(e.keyCode == 13) $(this).trigger('blur');}).appendTo(elm);
+ $(elm).children('input:text').first().focus();
+}
+
+</script>
diff --git a/panes/wizardImportApplianceAdvanced.html b/panes/wizardImportApplianceAdvanced.html
index 8ff832f..74df797 100644
--- a/panes/wizardImportApplianceAdvanced.html
+++ b/panes/wizardImportApplianceAdvanced.html
@@ -1,536 +1,536 @@
-<!--
-
- Advanced panes for import appliance wizard. Logic in vboxWizard() class
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: wizardImportApplianceAdvanced.html 595 2015-04-17 09:50:36Z imoore76 $
-
- -->
-<!-- Step 1 -->
-<div id='wizardImportApplianceStep1' style='display: none'>
-
- <table class='vboxInvisible' style='border: 0px solid transparent; border-spacing: 4px; height: 100%;'>
- <tr style='vertical-align: top'>
- <td style='height: 1%'>
-
- <span class='translate vboxTableLabel'>Appliance to import</span>
- <hr style='width: 100%; margin: 0px; margin-bottom: 6px; display: block' class='vboxSeparatorLine'/>
-
- <input type="button" id='vboxWizardImportApplianceButton' value='Open appliance...' onClick="wizardImportApplianceBrowseLocation()" />
- <input type='hidden' name='wizardImportApplianceLocation' />
- <span id='vboxWizardImportApplianceFilename'> </span>
- </td>
- <tr style='vertical-align: top'>
- <td>
- <div class='vboxBordered' id='vboxImportPropsContainer' style='overflow: auto;'>
- <table style='width: 100%;' class='vboxHorizontal'>
- <!--
- <thead>
- <tr>
- <th style='text-align: left; width: 1%; padding-left: 10px' class='translate'>Description</th>
- <th style='text-align: left; padding-left: 10px;' class='translate'>Configuration</th>
- </tr>
- </thead>
- -->
- <tbody id='vboxImportProps' style='font-size: 0.9em;'>
- </tbody>
- </table>
- </div>
- </td>
- </tr>
- <tr style='vertical-align: top'>
- <td style='height: 1%'>
- <div style='margin:2px;margin-top:4px;padding:0px;'><label><input type='checkbox' class='vboxCheckbox' name='vboxImportReinitNetwork' />
- <span class='translateglob'>Reinitialize the MAC address of all network cards</span></label>
- </div>
- </td>
- </tr>
- </table>
-
-</div>
-
-
-<script type='text/javascript'>
-
-// Translations
-$('#wizardImportApplianceStep1').find('span.translateglob').html(function(i,h){
- return trans(h,'UIApplianceEditorWidget');
-});
-
-$('#vboxWizardImportApplianceButton').val(trans('Choose a virtual appliance file to import...','UIWizardImportApp'));
-
-/*
- *
- * VM Properties to edit / import
- *
- */
-var vboxApplianceImportProps = {
- 'Name' : {'label':'Name','icon':'name','edit':'text'},
- 'Description' : {'label':'Description','icon':'description','edit':'textarea'},
- 'OS' : {'label':'Guest OS Type','icon':'os_type','edit':function(elm){
- var input = $('<input />').attr({'type':'button','class':'vboxbutton'}).css({'width':($(elm).innerWidth()-12)+'px','margin':'0px'}).val($(elm).find('span.vboxApplianceOSTitle').html());
- $(elm).children().hide();
- $(elm).append(input);
- $(elm).children('input:button').first().contextMenu({
- menu: 'vboxOSTypesMenu',
- button: 0,
- mode: 'menu',
- inSpeed : -1,
- outSpeed : -1
- },
- function(a, el, pos, srcEl) {
- $(elm).find('span.vboxApplianceOSTitle').html(vboxSettingsOSTypesObj[a]['description']);
- $(elm).find('img.vboxApplianceOSIcon').attr('src','images/vbox/'+vboxGuestOSTypeIcon(a));
- $(elm).closest('td').data('descValue',a);
- $('#vboxImportProps').trigger('selectProp');
- }).focus();
- $('#vboxImportProps').one('selectProp',function(){
- $(elm).children('input:button').first().hide().siblings().show();
- $(elm).children('input:button').first().remove();
- });
-
- },'display':function(val){
- return $('<span />').append('<img class="vboxApplianceOSIcon" src="images/vbox/'+vboxGuestOSTypeIcon(val)+'" style="height: 16px; width: 16px; float: left; margin-top: 2px; margin-right: 4px; " /> <span class="vboxApplianceOSTitle">' + vboxSettingsOSTypesObj[val].description +'</span>').disableSelection().on('selectstart',function(e){e.preventDefault();return false;});
- }},
- 'CPU' : {'label':'CPU','icon':'cpu','edit':'text','postEdit':function(val,old){
- val = parseInt(val);
- if(isNaN(val)) return old;
- return Math.min($('#vboxPane').data('vboxSystemProperties').maxGuestCPUCount,Math.max($('#vboxPane').data('vboxSystemProperties').minGuestCPUCount,val));
- }},
- 'Memory' : {'label':'RAM','icon':'ram','edit':'text','display':function(val){
- return Math.max(parseInt(val),0) + ' ' + trans('MB','VBoxGlobal');
- },'postEdit':function(val,old) {
- val = parseInt(val);
- if(isNaN(val)) return old;
- return Math.min($('#vboxPane').data('vboxSystemProperties').maxGuestRAM,Math.max($('#vboxPane').data('vboxSystemProperties').minGuestRAM,val));
- }},
- 'SoundCard' : {'label':'Sound Card','icon':'sound','checkbox':true,'edit':'options','display':function(val){
- return trans(vboxAudioController($('#vboxPane').data('vboxAudioControllerTypes')[val]),'VBoxGlobal');
- }},
- 'CDROM' : {'label':'DVD','icon':'cd','checkbox':true,'edit':'checkbox'},
- 'USBController' : {'label':'USB Controller','icon':'usb','checkbox':true},
- 'NetworkAdapter' : {'label':'Network Adapter','icon':'nw','checkbox':true,'edit':'options','option_offset':-1,'display':function(val){
- return trans(vboxNetworkAdapterType($('#vboxPane').data('vboxNetworkAdapterTypes')[val]),'VBoxGlobal');
- }},
- 'Floppy' : {'label':'Floppy','icon':'floppy','checkbox':true},
- 'HardDiskControllerIDE' : {'label':'Storage Controller (IDE)','icon':'ide','edit':''},
- 'HardDiskControllerSATA' : {'label':'Storage Controller (SATA)','icon':'sata','edit':null},
- 'HardDiskControllerSAS' : {'label':'Storage Controller (SAS)','icon':'scsi','edit':null},
- 'HardDiskControllerSCSI' : {'label':'Storage Controller (SCSI)','icon':'scsi','edit':null},
- 'HardDiskImage' : {'label':'Virtual Disk Image','icon':'hd','edit':'text'}
-};
-
-/*
- *
- * Add Property Options
- *
- */
-// Storage controllers
-var stTypes = vboxStorage.getBusTypes();
-for(var i = 0; i < stTypes.length; i++) {
-
- if(!vboxApplianceImportProps['HardDiskController'+stTypes[i]]) continue;
-
- // Translate value
- vboxApplianceImportProps['HardDiskController'+stTypes[i]]['display'] = function(val){return trans(vboxStorageControllerType(val),'VBoxGlobal');};
-
- var ctypes = vboxStorage[stTypes[i]].types;
- if(ctypes.length < 2) continue;
-
- var opts = {};
- for(var a = 0; a < ctypes.length; a++) {
- opts[ctypes[a]] = trans(vboxStorageControllerType(ctypes[a]),'VBoxGlobal');
- }
- vboxApplianceImportProps['HardDiskController'+stTypes[i]]['edit'] = 'options';
- vboxApplianceImportProps['HardDiskController'+stTypes[i]]['options'] = opts;
-}
-
-vboxApplianceImportProps['NetworkAdapter']['options'] = [];
-vboxApplianceImportProps['SoundCard']['options'] = [];
-
-// Network adapters
-var cs = $('#vboxPane').data('vboxNetworkAdapterTypes');
-for(var i = 1; i < cs.length; i++) {
- vboxApplianceImportProps['NetworkAdapter']['options'][(i-1)] = trans(vboxNetworkAdapterType(cs[i]),'VBoxGlobal');
-}
-// Sound cards
-var cs = $('#vboxPane').data('vboxAudioControllerTypes');
-for(var i = 0; i < cs.length; i++) {
- vboxApplianceImportProps['SoundCard']['options'][i] = trans(vboxAudioController(cs[i]),'VBoxGlobal');
-}
-
-
-// OS Types
-/////////////////////////
-$('ul.vboxOSTypesMenuList').remove();
-
-// shorthand
-var vboxOSTypes = $('#vboxPane').data('vboxOSTypes');
-var vboxSettingsOSTypes = {};
-var vboxSettingsOSTypesObj = {};
-
-for(var i in vboxOSTypes) {
-
- // Skip unsupported OS Types
- if(!vboxOSTypes[i].supported) continue;
-
- // create array of os family types
- if(!vboxSettingsOSTypes[vboxOSTypes[i].familyId]) {
- vboxSettingsOSTypes[vboxOSTypes[i].familyId] = {'id':vboxOSTypes[i].familyId,'description':vboxOSTypes[i].familyDescription,'osTypes':[]};
- }
-
- vboxSettingsOSTypes[vboxOSTypes[i].familyId].osTypes[vboxSettingsOSTypes[vboxOSTypes[i].familyId].osTypes.length] = {'id':vboxOSTypes[i].id,'description':vboxOSTypes[i].description };
-
- vboxSettingsOSTypesObj[vboxOSTypes[i].id] = vboxOSTypes[i];
-
- // Preload icons
- vboxOSTypes[i].icon = new Image();
- vboxOSTypes[i].icon.src = "images/vbox/" + vboxGuestOSTypeIcon(vboxOSTypes[i].id);
-
-}
-
-var ul = $('<ul />').attr({'id':'vboxOSTypesMenu','class':'contextMenu contextMenuNoBG vboxOSTypesMenuList'});
-for(var i in vboxSettingsOSTypes) {
- var li = $('<li />').html('<a href="#null-'+i+'">'+vboxSettingsOSTypes[i].description+'</a>');
- var ul2 = $('<ul />').addClass('vboxOSTypesMenuList');
- for(var a in vboxSettingsOSTypes[i]['osTypes']) {
- $('<li />').html('<a href="#'+vboxSettingsOSTypes[i]['osTypes'][a]['id']+'"><img style="height: 16px; width:16px; margin-left: -22px; margin-top: 2px; float: left; " src="images/vbox/'+vboxGuestOSTypeIcon(vboxSettingsOSTypes[i]['osTypes'][a]['id'])+'" /> '+vboxSettingsOSTypes[i]['osTypes'][a]['description']+"</a>").appendTo(ul2);
- }
- $(li).append(ul2).appendTo(ul);
-}
-$('#vboxPane').append(ul);
-
-
-
-/* Browse for import location */
-function wizardImportApplianceBrowseLocation() {
-
- var dsepRegEx = $('#vboxPane').data('vboxConfig').DSEP;
- if(dsepRegEx == '\\') dsepRegEx += '\\';
-
- var loc = $('#vboxPane').data('vboxSystemProperties').defaultMachineFolder;
-
- vboxFileBrowser(loc,function(f){
-
- if(!f) return;
-
- document.forms['frmwizardImportAppliance'].elements.wizardImportApplianceLocation.value = f;
- $('#vboxWizardImportApplianceFilename').html(f);
-
- // Remove any existing VMs from Back / Forward wizard navigation
- $('#vboxImportProps').children().remove();
-
- /* Parse appliance file */
- var l = new vboxLoader();
- l.add('applianceReadInterpret',function(d){
- if(d && d.responseData && d.responseData.descriptions && d.responseData.descriptions.length) { wizardImportApplianceParsed(d.responseData); }
- else {
- if(!d) { vboxAlert(trans('Unkown Error')); }
- document.forms['frmwizardImportAppliance'].elements.wizardImportApplianceLocation.value = '';
- $('#vboxWizardImportApplianceFilename').html('');
- } // no data. assume error was displayed
- },{'file':$(document.forms['frmwizardImportAppliance'].elements.wizardImportApplianceLocation).val()});
- l.run();
-
- },false,trans('Select an appliance to import','UIWizardImportApp'),'images/vbox/os_type_16px.png');
-
-}
-
-
-function wizardImportAppResize(){
-
- // Resize properties
- $('#wizardImportApplianceStep1').hide();
- $('#wizardImportApplianceStep1').css({'height':($('#wizardImportApplianceStep1').parent().height()-8)+'px'}).show();
- $('#vboxImportPropsContainer').hide();
- $('#vboxImportPropsContainer').css({'height':($('#vboxImportPropsContainer').parent().height()-2)+'px'}).show();
-
-}
-$('#wizardImportApplianceDialog').on('dialogresizestop',wizardImportAppResize);
-$('#wizardImportApplianceStep1').on('show',wizardImportAppResize);
-
-/* After appliance file is parsed */
-function wizardImportApplianceParsed(d) {
-
- // Remove any existing data
- $('#vboxImportProps').children().remove();
-
- var tbl = $('#vboxImportProps');
- if(!d) d = {'descriptions':$(tbl).data('descriptions')};
- else $(tbl).data('descriptions',d.descriptions);
-
- // No descriptions.. nothing to do..
- if(!$(tbl).data('descriptions')) return;
-
- for(var vm = 0; vm < d.descriptions.length; vm++) {
-
- var tr = $('<tr />').data({'vmDesc':d.descriptions[vm]}).attr({'class':'vboxApplianceHeaderRow'});
- var td = $('<td />').attr({'colspan':'2','class':'vboxApplianceHeader'});
- $('<input />').data({'vboxOrder':vm}).attr({'type':'button','class':'vboxImgButton','style':'background-image: url(images/downArrow.png); width: 12px; height: 12px; margin-right: 4px;'}).click(function(){
- if(!$(this).data('toggleClicked')) {
- $(this).data('toggleClicked', true);
- $(this).css({'background-image':'url(images/rightArrow.png)'});
- $(this).parent().parent().parent().children('tr.vboxChildOf'+$(this).data('vboxOrder')).css('display','none');
- } else {
- $(this).data('toggleClicked', false);
- $(this).css({'background-image':'url(images/downArrow.png)'});
- $(this).parent().parent().parent().children('tr.vboxChildOf'+$(this).data('vboxOrder')).css('display','');
- }
- }).appendTo(td);
- $(td).append(trans('Virtual System %1','UIApplianceEditorWidget').replace('%1',(vm+1))).appendTo(tr);
- $(tbl).append(tr);
-
- // Hard Disks are handled differently
- var hds = [];
-
- for(var i = 0; i < d.descriptions[vm][0].length; i++) {
-
- var desc = vboxApplianceImportProps[d.descriptions[vm][0][i]];
- if(desc == undefined) continue;
-
- var tr = $('<tr />').data({'descType':d.descriptions[vm][0][i],'descOrder':i}).addClass('vboxChildOf'+vm, ' vboxListItem').attr({'id':'vboxVM-'+vm+'-item-'+i}).click(function(){
- $('#vboxImportProps').find('input').trigger('blur');
- if($(this).hasClass('vboxListItemSelected')) return;
- $(this).siblings('tr.vboxListItemSelected').removeClass('vboxListItemSelected');
- $(this).addClass('vboxListItemSelected');
- $(this).parent().trigger('selectProp',this);
- });
-
- $('<td />').css({'white-space':'nowrap','width':'1%'}).attr({'class':'vbox'+d.descriptions[vm][0][i]}).html('<img src="images/vbox/blank.gif" class="vboxSpacer" style="height:2px;"/><img src="images/vbox/'+desc.icon+'_16px.png" style="height: 16px; width: 16px;"/> ' + trans(desc.label,'UIApplianceEditorWidget')).appendTo(tr);
-
- var td = $('<td />').attr({'class':'vboxHideOverflow'}).css({'padding-left':'10px'});
- if(desc.checkbox) {
- $('<input />').attr({'type':'checkbox','class':'vboxCheckbox'}).prop('checked',true).css({'margin-right':'5px'}).click(function(){
- $(this).closest('tr').data('propdisabled',!(this.checked));
- if(this.checked) {
- $(this).siblings().removeClass('vboxDisabled');
- } else {
- $(this).siblings().addClass('vboxDisabled');
- }
- }).appendTo(td);
- }
- var sp = $('<span />').css({'display':'inline-block'}).attr({'class':'vboxImportAppProp'});
- if(desc.display) {
- $(sp).html(desc.display(d.descriptions[vm][3][i]));
- } else {
- $(sp).text(d.descriptions[vm][3][i]);
- }
-
- $(td).data({'descValue':d.descriptions[vm][3][i]}).append(sp).dblclick(function(){
-
- // Edit property function
- var desc = vboxApplianceImportProps[$(this).parent().data('descType')];
-
- // Check for checkbox
- if(desc.checkbox && !$(this).children('input:checkbox').first().prop('checked')) return;
-
- switch(desc.edit) {
- case 'options':
- vboxImportAppliancePropEditOptions(this,desc);
- break;
- case 'text':
- vboxImportAppliancePropEdit(this,desc);
- break;
- case 'textarea':
- vboxImportAppliancePropEditArea(this,desc);
- break;
- default:
- if(typeof desc.edit == 'function') desc.edit(this,desc);
- }
- }).disableSelection().appendTo(tr);
-
- // Hard Disks are handled differently
- if(d.descriptions[vm][0][i] == 'HardDiskImage') {
- var place = d.descriptions[vm][4][i].split(';');
- var con = parseInt(place[0].replace(/.*=/,''));
- var dev = parseInt(place[1].replace(/.*=/,''));
- hds[hds.length] = {'element':tr,'controller':con,'device':dev};
- } else {
- $(tbl).append(tr);
- }
-
- } // </ foreach description item >
-
- // Attach hard disks
- hds.sort(function(a,b){
- if(a.device == b.device) return 0;
- return (a.device < b.device ? 1 : -1); // Yes. Reverse order.
- });
- for(var i = 0; i < hds.length; i++) {
- $('#vboxVM-'+vm+'-item-'+hds[i].controller).after(hds[i].element);
- }
-
- } // </ foreach vm >
-
- vboxColorRows(tbl,false,'vboxApplianceHeaderRow');
-
-
-
- $('#vboxImportProps').disableSelection();
-
- // Check for import warnings
- if(d.warnings && d.warnings.length) {
-
- var div = $('<div />');
- $(div).append(trans('Warnings:','UIApplianceEditorWidget'));
-
- var ul = $('<ul />');
-
- for(var i = 0; i < d.warnings.length; i++) {
- $('<li />').html(d.warnings[i]).appendTo(ul);
- }
- $(div).append(ul);
- var buttons = {};
- buttons[trans('OK','QIMessageBox')] = function(){$(this).empty().remove();};
- $(div).dialog({'height':300,'width':300,'closeOnEscape':false,'modal':true,'resizable':true,'draggable':true,'buttons':buttons,'title':trans('Warnings:')});
-
- }
-
-
-};
-
-
-
-/*
- *
- * Edit property that has options
- *
- */
-function vboxImportAppliancePropEditOptions(elm,desc) {
-
- var s = $('<select />').attr({'id':'vboxImportAppSelect'}).css({'width':'100%'}).change(function(){
- $(this).parent().data('descValue',$(this).val());
- var txt = this.options[this.selectedIndex].text;
-
- $(this).siblings('span.vboxImportAppProp').text(txt);
-
- });
- var val = $(elm).data('descValue');
- if(desc.option_offset) {
- val = parseInt(val) + parseInt(desc.option_offset);
- val = ''+val;
- }
- selOpt = 0;
- var a = 0;
- for(var i in desc.options) {
- $(s).prop('options').add(new Option(desc.options[i],i,(i == val),(i == val)));
- if(i==val) selOpt = a;
- a++;
- }
- $(s).attr('selectedIndex',selOpt);
- $(elm).children().hide();
- $(elm).append(s);
- $('#vboxImportProps').one('selectProp',function(){
- $('#vboxImportAppSelect').hide().siblings().show();
- $('#vboxImportAppSelect').remove();
- });
-
-}
-
-
-
-/*
- *
- * Edit property that has a text area
- *
- */
-function vboxImportAppliancePropEditArea(elm) {
-
- $(elm).children().hide();
-
- $('<input />').attr({'type':'button','class':'vboxbutton'}).css({'width':($(elm).innerWidth()-12)+'px','margin':'0px'}).val(trans('Edit text','VBoxTextEditor')).click(function(){
- vboxImportAppliancePropEditDialog(elm);
- $('#vboxImportProps').trigger('selectProp');
- }).appendTo(elm);
-
- $(elm).children('input:button').first().focus();
- $('#vboxImportProps').one('selectProp',function(){
- $(elm).children('input:button').first().hide().siblings().show();
- $(elm).children('input:button').first().remove();
- });
-}
-
-/*
- *
- * Edit property dialog
- *
- */
-function vboxImportAppliancePropEditDialog(td) {
-
- var d = $('<div />').css({'display':'none'});
- var frm = $('<form />').attr({'onSubmit':'return false;'}).css({'margin':'0px','border':'0px','padding':'0px','width':'100%','height':'100%'});
-
- $('<textarea />').attr({'id':'vboxImportAppliancePropTextarea'}).css({'height':'99%','width':'99%'}).val($(td).data('descValue')).appendTo(frm);
-
- $(d).append(frm);
-
- var buttons = {};
- buttons[trans('OK','QIMessageBox')] = function(){
- $(td).data('descValue',$('#vboxImportAppliancePropTextarea').val());
- $(td).children('span.vboxImportAppProp').html($('<div />').text($('#vboxImportAppliancePropTextarea').val()).html());
- $(this).empty().remove();
- };
- buttons[trans('Cancel','QIMessageBox')] = function(){$(this).empty().remove();};
- $(d).dialog({'height':300,'width':300,'closeOnEscape':false,'modal':true,'resizable':true,'dialogClass':'vboxDialogContent','draggable':true,'buttons':buttons,'title':$(td).prev().html()});
-
-}
-
-/*
- *
- * Edit property that has a text box
- *
- */
-function vboxImportAppliancePropEdit(elm,desc) {
- $(elm).children().hide();
- $('<input />').attr({'type':'text','class':'vboxText'}).css({'width':($(elm).innerWidth()-12)+'px','margin':'0px'}).val($(elm).data('descValue')).blur(function(){
-
- var tbox = this;
-
- var val = (desc.postEdit ? desc.postEdit($(tbox).val(),$(tbox).parent().data('descValue')) : $(tbox).val());
- if(val != $(tbox).parent().data('descValue')) {
- $(tbox).parent().data('descValue',val);
- if(desc.display) {
- $(tbox).siblings('span.vboxImportAppProp').html(desc.display(val));
- } else {
- $(tbox).siblings('span.vboxImportAppProp').text(val);
- }
- $(tbox).parent().data('edited', true);
-
- // Special case for name
- if(desc.label == 'Name') {
-
- // Get ChildOf class
- var r = /(vboxChildOf\d+)/;
- var coClass = r.exec($(tbox).closest('tr').attr('class'));
- coClass = coClass[1];
-
- // Get unedited disk rows
- var diskRows = new Array();
- $.each($(tbox).parent().closest('tr').siblings('.'+coClass), function(i,e){
- if(!$(e).data('edited') && $(e).data('descType') == 'HardDiskImage') {
- diskRows[diskRows.length] = e;
- }
- });
-
- if(diskRows.length) {
- var mfd = new vboxLoader();
- mfd.add('vboxGetComposedMachineFilename',function(d){
- var mfolder = vboxDirname(d.responseData) + $("#vboxPane").data('vboxConfig').DSEP;
- for(var i = 0; i < diskRows.length; i++) {
- var tdc = $(diskRows[i]).children().eq(1);
- var dname = vboxBasename($(tdc).data('descValue'));
- $(tdc).data({'descValue':mfolder + dname}).find('span.vboxImportAppProp').text(mfolder + dname);
- }
- },{'name':val,'group':''});
- mfd.run();
- }
- }
- }
- $(tbox).hide();
- $(tbox).siblings().show();
- $(tbox).remove();
- }).keydown(function(e){if(e.keyCode == 13) $(this).trigger('blur');}).appendTo(elm);
- $(elm).children('input:text').first().focus();
-}
-
-</script>
+<!--
+
+ Advanced panes for import appliance wizard. Logic in vboxWizard() class
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: wizardImportApplianceAdvanced.html 595 2015-04-17 09:50:36Z imoore76 $
+
+ -->
+<!-- Step 1 -->
+<div id='wizardImportApplianceStep1' style='display: none'>
+
+ <table class='vboxInvisible' style='border: 0px solid transparent; border-spacing: 4px; height: 100%;'>
+ <tr style='vertical-align: top'>
+ <td style='height: 1%'>
+
+ <span class='translate vboxTableLabel'>Appliance to import</span>
+ <hr style='width: 100%; margin: 0px; margin-bottom: 6px; display: block' class='vboxSeparatorLine'/>
+
+ <input type="button" id='vboxWizardImportApplianceButton' value='Open appliance...' onClick="wizardImportApplianceBrowseLocation()" />
+ <input type='hidden' name='wizardImportApplianceLocation' />
+ <span id='vboxWizardImportApplianceFilename'> </span>
+ </td>
+ <tr style='vertical-align: top'>
+ <td>
+ <div class='vboxBordered' id='vboxImportPropsContainer' style='overflow: auto;'>
+ <table style='width: 100%;' class='vboxHorizontal'>
+ <!--
+ <thead>
+ <tr>
+ <th style='text-align: left; width: 1%; padding-left: 10px' class='translate'>Description</th>
+ <th style='text-align: left; padding-left: 10px;' class='translate'>Configuration</th>
+ </tr>
+ </thead>
+ -->
+ <tbody id='vboxImportProps' style='font-size: 0.9em;'>
+ </tbody>
+ </table>
+ </div>
+ </td>
+ </tr>
+ <tr style='vertical-align: top'>
+ <td style='height: 1%'>
+ <div style='margin:2px;margin-top:4px;padding:0px;'><label><input type='checkbox' class='vboxCheckbox' name='vboxImportReinitNetwork' />
+ <span class='translateglob'>Reinitialize the MAC address of all network cards</span></label>
+ </div>
+ </td>
+ </tr>
+ </table>
+
+</div>
+
+
+<script type='text/javascript'>
+
+// Translations
+$('#wizardImportApplianceStep1').find('span.translateglob').html(function(i,h){
+ return trans(h,'UIApplianceEditorWidget');
+});
+
+$('#vboxWizardImportApplianceButton').val(trans('Choose a virtual appliance file to import...','UIWizardImportApp'));
+
+/*
+ *
+ * VM Properties to edit / import
+ *
+ */
+var vboxApplianceImportProps = {
+ 'Name' : {'label':'Name','icon':'name','edit':'text'},
+ 'Description' : {'label':'Description','icon':'description','edit':'textarea'},
+ 'OS' : {'label':'Guest OS Type','icon':'os_type','edit':function(elm){
+ var input = $('<input />').attr({'type':'button','class':'vboxbutton'}).css({'width':($(elm).innerWidth()-12)+'px','margin':'0px'}).val($(elm).find('span.vboxApplianceOSTitle').html());
+ $(elm).children().hide();
+ $(elm).append(input);
+ $(elm).children('input:button').first().contextMenu({
+ menu: 'vboxOSTypesMenu',
+ button: 0,
+ mode: 'menu',
+ inSpeed : -1,
+ outSpeed : -1
+ },
+ function(a, el, pos, srcEl) {
+ $(elm).find('span.vboxApplianceOSTitle').html(vboxSettingsOSTypesObj[a]['description']);
+ $(elm).find('img.vboxApplianceOSIcon').attr('src','images/vbox/'+vboxGuestOSTypeIcon(a));
+ $(elm).closest('td').data('descValue',a);
+ $('#vboxImportProps').trigger('selectProp');
+ }).focus();
+ $('#vboxImportProps').one('selectProp',function(){
+ $(elm).children('input:button').first().hide().siblings().show();
+ $(elm).children('input:button').first().remove();
+ });
+
+ },'display':function(val){
+ return $('<span />').append('<img class="vboxApplianceOSIcon" src="images/vbox/'+vboxGuestOSTypeIcon(val)+'" style="height: 16px; width: 16px; float: left; margin-top: 2px; margin-right: 4px; " /> <span class="vboxApplianceOSTitle">' + vboxSettingsOSTypesObj[val].description +'</span>').disableSelection().on('selectstart',function(e){e.preventDefault();return false;});
+ }},
+ 'CPU' : {'label':'CPU','icon':'cpu','edit':'text','postEdit':function(val,old){
+ val = parseInt(val);
+ if(isNaN(val)) return old;
+ return Math.min($('#vboxPane').data('vboxSystemProperties').maxGuestCPUCount,Math.max($('#vboxPane').data('vboxSystemProperties').minGuestCPUCount,val));
+ }},
+ 'Memory' : {'label':'RAM','icon':'ram','edit':'text','display':function(val){
+ return Math.max(parseInt(val),0) + ' ' + trans('MB','VBoxGlobal');
+ },'postEdit':function(val,old) {
+ val = parseInt(val);
+ if(isNaN(val)) return old;
+ return Math.min($('#vboxPane').data('vboxSystemProperties').maxGuestRAM,Math.max($('#vboxPane').data('vboxSystemProperties').minGuestRAM,val));
+ }},
+ 'SoundCard' : {'label':'Sound Card','icon':'sound','checkbox':true,'edit':'options','display':function(val){
+ return trans(vboxAudioController($('#vboxPane').data('vboxAudioControllerTypes')[val]),'VBoxGlobal');
+ }},
+ 'CDROM' : {'label':'DVD','icon':'cd','checkbox':true,'edit':'checkbox'},
+ 'USBController' : {'label':'USB Controller','icon':'usb','checkbox':true},
+ 'NetworkAdapter' : {'label':'Network Adapter','icon':'nw','checkbox':true,'edit':'options','option_offset':-1,'display':function(val){
+ return trans(vboxNetworkAdapterType($('#vboxPane').data('vboxNetworkAdapterTypes')[val]),'VBoxGlobal');
+ }},
+ 'Floppy' : {'label':'Floppy','icon':'floppy','checkbox':true},
+ 'HardDiskControllerIDE' : {'label':'Storage Controller (IDE)','icon':'ide','edit':''},
+ 'HardDiskControllerSATA' : {'label':'Storage Controller (SATA)','icon':'sata','edit':null},
+ 'HardDiskControllerSAS' : {'label':'Storage Controller (SAS)','icon':'scsi','edit':null},
+ 'HardDiskControllerSCSI' : {'label':'Storage Controller (SCSI)','icon':'scsi','edit':null},
+ 'HardDiskImage' : {'label':'Virtual Disk Image','icon':'hd','edit':'text'}
+};
+
+/*
+ *
+ * Add Property Options
+ *
+ */
+// Storage controllers
+var stTypes = vboxStorage.getBusTypes();
+for(var i = 0; i < stTypes.length; i++) {
+
+ if(!vboxApplianceImportProps['HardDiskController'+stTypes[i]]) continue;
+
+ // Translate value
+ vboxApplianceImportProps['HardDiskController'+stTypes[i]]['display'] = function(val){return trans(vboxStorageControllerType(val),'VBoxGlobal');};
+
+ var ctypes = vboxStorage[stTypes[i]].types;
+ if(ctypes.length < 2) continue;
+
+ var opts = {};
+ for(var a = 0; a < ctypes.length; a++) {
+ opts[ctypes[a]] = trans(vboxStorageControllerType(ctypes[a]),'VBoxGlobal');
+ }
+ vboxApplianceImportProps['HardDiskController'+stTypes[i]]['edit'] = 'options';
+ vboxApplianceImportProps['HardDiskController'+stTypes[i]]['options'] = opts;
+}
+
+vboxApplianceImportProps['NetworkAdapter']['options'] = [];
+vboxApplianceImportProps['SoundCard']['options'] = [];
+
+// Network adapters
+var cs = $('#vboxPane').data('vboxNetworkAdapterTypes');
+for(var i = 1; i < cs.length; i++) {
+ vboxApplianceImportProps['NetworkAdapter']['options'][(i-1)] = trans(vboxNetworkAdapterType(cs[i]),'VBoxGlobal');
+}
+// Sound cards
+var cs = $('#vboxPane').data('vboxAudioControllerTypes');
+for(var i = 0; i < cs.length; i++) {
+ vboxApplianceImportProps['SoundCard']['options'][i] = trans(vboxAudioController(cs[i]),'VBoxGlobal');
+}
+
+
+// OS Types
+/////////////////////////
+$('ul.vboxOSTypesMenuList').remove();
+
+// shorthand
+var vboxOSTypes = $('#vboxPane').data('vboxOSTypes');
+var vboxSettingsOSTypes = {};
+var vboxSettingsOSTypesObj = {};
+
+for(var i in vboxOSTypes) {
+
+ // Skip unsupported OS Types
+ if(!vboxOSTypes[i].supported) continue;
+
+ // create array of os family types
+ if(!vboxSettingsOSTypes[vboxOSTypes[i].familyId]) {
+ vboxSettingsOSTypes[vboxOSTypes[i].familyId] = {'id':vboxOSTypes[i].familyId,'description':vboxOSTypes[i].familyDescription,'osTypes':[]};
+ }
+
+ vboxSettingsOSTypes[vboxOSTypes[i].familyId].osTypes[vboxSettingsOSTypes[vboxOSTypes[i].familyId].osTypes.length] = {'id':vboxOSTypes[i].id,'description':vboxOSTypes[i].description };
+
+ vboxSettingsOSTypesObj[vboxOSTypes[i].id] = vboxOSTypes[i];
+
+ // Preload icons
+ vboxOSTypes[i].icon = new Image();
+ vboxOSTypes[i].icon.src = "images/vbox/" + vboxGuestOSTypeIcon(vboxOSTypes[i].id);
+
+}
+
+var ul = $('<ul />').attr({'id':'vboxOSTypesMenu','class':'contextMenu contextMenuNoBG vboxOSTypesMenuList'});
+for(var i in vboxSettingsOSTypes) {
+ var li = $('<li />').html('<a href="#null-'+i+'">'+vboxSettingsOSTypes[i].description+'</a>');
+ var ul2 = $('<ul />').addClass('vboxOSTypesMenuList');
+ for(var a in vboxSettingsOSTypes[i]['osTypes']) {
+ $('<li />').html('<a href="#'+vboxSettingsOSTypes[i]['osTypes'][a]['id']+'"><img style="height: 16px; width:16px; margin-left: -22px; margin-top: 2px; float: left; " src="images/vbox/'+vboxGuestOSTypeIcon(vboxSettingsOSTypes[i]['osTypes'][a]['id'])+'" /> '+vboxSettingsOSTypes[i]['osTypes'][a]['description']+"</a>").appendTo(ul2);
+ }
+ $(li).append(ul2).appendTo(ul);
+}
+$('#vboxPane').append(ul);
+
+
+
+/* Browse for import location */
+function wizardImportApplianceBrowseLocation() {
+
+ var dsepRegEx = $('#vboxPane').data('vboxConfig').DSEP;
+ if(dsepRegEx == '\\') dsepRegEx += '\\';
+
+ var loc = $('#vboxPane').data('vboxSystemProperties').defaultMachineFolder;
+
+ vboxFileBrowser(loc,function(f){
+
+ if(!f) return;
+
+ document.forms['frmwizardImportAppliance'].elements.wizardImportApplianceLocation.value = f;
+ $('#vboxWizardImportApplianceFilename').html(f);
+
+ // Remove any existing VMs from Back / Forward wizard navigation
+ $('#vboxImportProps').children().remove();
+
+ /* Parse appliance file */
+ var l = new vboxLoader();
+ l.add('applianceReadInterpret',function(d){
+ if(d && d.responseData && d.responseData.descriptions && d.responseData.descriptions.length) { wizardImportApplianceParsed(d.responseData); }
+ else {
+ if(!d) { vboxAlert(trans('Unkown Error')); }
+ document.forms['frmwizardImportAppliance'].elements.wizardImportApplianceLocation.value = '';
+ $('#vboxWizardImportApplianceFilename').html('');
+ } // no data. assume error was displayed
+ },{'file':$(document.forms['frmwizardImportAppliance'].elements.wizardImportApplianceLocation).val()});
+ l.run();
+
+ },false,trans('Select an appliance to import','UIWizardImportApp'),'images/vbox/os_type_16px.png');
+
+}
+
+
+function wizardImportAppResize(){
+
+ // Resize properties
+ $('#wizardImportApplianceStep1').hide();
+ $('#wizardImportApplianceStep1').css({'height':($('#wizardImportApplianceStep1').parent().height()-8)+'px'}).show();
+ $('#vboxImportPropsContainer').hide();
+ $('#vboxImportPropsContainer').css({'height':($('#vboxImportPropsContainer').parent().height()-2)+'px'}).show();
+
+}
+$('#wizardImportApplianceDialog').on('dialogresizestop',wizardImportAppResize);
+$('#wizardImportApplianceStep1').on('show',wizardImportAppResize);
+
+/* After appliance file is parsed */
+function wizardImportApplianceParsed(d) {
+
+ // Remove any existing data
+ $('#vboxImportProps').children().remove();
+
+ var tbl = $('#vboxImportProps');
+ if(!d) d = {'descriptions':$(tbl).data('descriptions')};
+ else $(tbl).data('descriptions',d.descriptions);
+
+ // No descriptions.. nothing to do..
+ if(!$(tbl).data('descriptions')) return;
+
+ for(var vm = 0; vm < d.descriptions.length; vm++) {
+
+ var tr = $('<tr />').data({'vmDesc':d.descriptions[vm]}).attr({'class':'vboxApplianceHeaderRow'});
+ var td = $('<td />').attr({'colspan':'2','class':'vboxApplianceHeader'});
+ $('<input />').data({'vboxOrder':vm}).attr({'type':'button','class':'vboxImgButton','style':'background-image: url(images/downArrow.png); width: 12px; height: 12px; margin-right: 4px;'}).click(function(){
+ if(!$(this).data('toggleClicked')) {
+ $(this).data('toggleClicked', true);
+ $(this).css({'background-image':'url(images/rightArrow.png)'});
+ $(this).parent().parent().parent().children('tr.vboxChildOf'+$(this).data('vboxOrder')).css('display','none');
+ } else {
+ $(this).data('toggleClicked', false);
+ $(this).css({'background-image':'url(images/downArrow.png)'});
+ $(this).parent().parent().parent().children('tr.vboxChildOf'+$(this).data('vboxOrder')).css('display','');
+ }
+ }).appendTo(td);
+ $(td).append(trans('Virtual System %1','UIApplianceEditorWidget').replace('%1',(vm+1))).appendTo(tr);
+ $(tbl).append(tr);
+
+ // Hard Disks are handled differently
+ var hds = [];
+
+ for(var i = 0; i < d.descriptions[vm][0].length; i++) {
+
+ var desc = vboxApplianceImportProps[d.descriptions[vm][0][i]];
+ if(desc == undefined) continue;
+
+ var tr = $('<tr />').data({'descType':d.descriptions[vm][0][i],'descOrder':i}).addClass('vboxChildOf'+vm, ' vboxListItem').attr({'id':'vboxVM-'+vm+'-item-'+i}).click(function(){
+ $('#vboxImportProps').find('input').trigger('blur');
+ if($(this).hasClass('vboxListItemSelected')) return;
+ $(this).siblings('tr.vboxListItemSelected').removeClass('vboxListItemSelected');
+ $(this).addClass('vboxListItemSelected');
+ $(this).parent().trigger('selectProp',this);
+ });
+
+ $('<td />').css({'white-space':'nowrap','width':'1%'}).attr({'class':'vbox'+d.descriptions[vm][0][i]}).html('<img src="images/vbox/blank.gif" class="vboxSpacer" style="height:2px;"/><img src="images/vbox/'+desc.icon+'_16px.png" style="height: 16px; width: 16px;"/> ' + trans(desc.label,'UIApplianceEditorWidget')).appendTo(tr);
+
+ var td = $('<td />').attr({'class':'vboxHideOverflow'}).css({'padding-left':'10px'});
+ if(desc.checkbox) {
+ $('<input />').attr({'type':'checkbox','class':'vboxCheckbox'}).prop('checked',true).css({'margin-right':'5px'}).click(function(){
+ $(this).closest('tr').data('propdisabled',!(this.checked));
+ if(this.checked) {
+ $(this).siblings().removeClass('vboxDisabled');
+ } else {
+ $(this).siblings().addClass('vboxDisabled');
+ }
+ }).appendTo(td);
+ }
+ var sp = $('<span />').css({'display':'inline-block'}).attr({'class':'vboxImportAppProp'});
+ if(desc.display) {
+ $(sp).html(desc.display(d.descriptions[vm][3][i]));
+ } else {
+ $(sp).text(d.descriptions[vm][3][i]);
+ }
+
+ $(td).data({'descValue':d.descriptions[vm][3][i]}).append(sp).dblclick(function(){
+
+ // Edit property function
+ var desc = vboxApplianceImportProps[$(this).parent().data('descType')];
+
+ // Check for checkbox
+ if(desc.checkbox && !$(this).children('input:checkbox').first().prop('checked')) return;
+
+ switch(desc.edit) {
+ case 'options':
+ vboxImportAppliancePropEditOptions(this,desc);
+ break;
+ case 'text':
+ vboxImportAppliancePropEdit(this,desc);
+ break;
+ case 'textarea':
+ vboxImportAppliancePropEditArea(this,desc);
+ break;
+ default:
+ if(typeof desc.edit == 'function') desc.edit(this,desc);
+ }
+ }).disableSelection().appendTo(tr);
+
+ // Hard Disks are handled differently
+ if(d.descriptions[vm][0][i] == 'HardDiskImage') {
+ var place = d.descriptions[vm][4][i].split(';');
+ var con = parseInt(place[0].replace(/.*=/,''));
+ var dev = parseInt(place[1].replace(/.*=/,''));
+ hds[hds.length] = {'element':tr,'controller':con,'device':dev};
+ } else {
+ $(tbl).append(tr);
+ }
+
+ } // </ foreach description item >
+
+ // Attach hard disks
+ hds.sort(function(a,b){
+ if(a.device == b.device) return 0;
+ return (a.device < b.device ? 1 : -1); // Yes. Reverse order.
+ });
+ for(var i = 0; i < hds.length; i++) {
+ $('#vboxVM-'+vm+'-item-'+hds[i].controller).after(hds[i].element);
+ }
+
+ } // </ foreach vm >
+
+ vboxColorRows(tbl,false,'vboxApplianceHeaderRow');
+
+
+
+ $('#vboxImportProps').disableSelection();
+
+ // Check for import warnings
+ if(d.warnings && d.warnings.length) {
+
+ var div = $('<div />');
+ $(div).append(trans('Warnings:','UIApplianceEditorWidget'));
+
+ var ul = $('<ul />');
+
+ for(var i = 0; i < d.warnings.length; i++) {
+ $('<li />').html(d.warnings[i]).appendTo(ul);
+ }
+ $(div).append(ul);
+ var buttons = {};
+ buttons[trans('OK','QIMessageBox')] = function(){$(this).empty().remove();};
+ $(div).dialog({'height':300,'width':300,'closeOnEscape':false,'modal':true,'resizable':true,'draggable':true,'buttons':buttons,'title':trans('Warnings:')});
+
+ }
+
+
+};
+
+
+
+/*
+ *
+ * Edit property that has options
+ *
+ */
+function vboxImportAppliancePropEditOptions(elm,desc) {
+
+ var s = $('<select />').attr({'id':'vboxImportAppSelect'}).css({'width':'100%'}).change(function(){
+ $(this).parent().data('descValue',$(this).val());
+ var txt = this.options[this.selectedIndex].text;
+
+ $(this).siblings('span.vboxImportAppProp').text(txt);
+
+ });
+ var val = $(elm).data('descValue');
+ if(desc.option_offset) {
+ val = parseInt(val) + parseInt(desc.option_offset);
+ val = ''+val;
+ }
+ selOpt = 0;
+ var a = 0;
+ for(var i in desc.options) {
+ $(s).prop('options').add(new Option(desc.options[i],i,(i == val),(i == val)));
+ if(i==val) selOpt = a;
+ a++;
+ }
+ $(s).attr('selectedIndex',selOpt);
+ $(elm).children().hide();
+ $(elm).append(s);
+ $('#vboxImportProps').one('selectProp',function(){
+ $('#vboxImportAppSelect').hide().siblings().show();
+ $('#vboxImportAppSelect').remove();
+ });
+
+}
+
+
+
+/*
+ *
+ * Edit property that has a text area
+ *
+ */
+function vboxImportAppliancePropEditArea(elm) {
+
+ $(elm).children().hide();
+
+ $('<input />').attr({'type':'button','class':'vboxbutton'}).css({'width':($(elm).innerWidth()-12)+'px','margin':'0px'}).val(trans('Edit text','VBoxTextEditor')).click(function(){
+ vboxImportAppliancePropEditDialog(elm);
+ $('#vboxImportProps').trigger('selectProp');
+ }).appendTo(elm);
+
+ $(elm).children('input:button').first().focus();
+ $('#vboxImportProps').one('selectProp',function(){
+ $(elm).children('input:button').first().hide().siblings().show();
+ $(elm).children('input:button').first().remove();
+ });
+}
+
+/*
+ *
+ * Edit property dialog
+ *
+ */
+function vboxImportAppliancePropEditDialog(td) {
+
+ var d = $('<div />').css({'display':'none'});
+ var frm = $('<form />').attr({'onSubmit':'return false;'}).css({'margin':'0px','border':'0px','padding':'0px','width':'100%','height':'100%'});
+
+ $('<textarea />').attr({'id':'vboxImportAppliancePropTextarea'}).css({'height':'99%','width':'99%'}).val($(td).data('descValue')).appendTo(frm);
+
+ $(d).append(frm);
+
+ var buttons = {};
+ buttons[trans('OK','QIMessageBox')] = function(){
+ $(td).data('descValue',$('#vboxImportAppliancePropTextarea').val());
+ $(td).children('span.vboxImportAppProp').html($('<div />').text($('#vboxImportAppliancePropTextarea').val()).html());
+ $(this).empty().remove();
+ };
+ buttons[trans('Cancel','QIMessageBox')] = function(){$(this).empty().remove();};
+ $(d).dialog({'height':300,'width':300,'closeOnEscape':false,'modal':true,'resizable':true,'dialogClass':'vboxDialogContent','draggable':true,'buttons':buttons,'title':$(td).prev().html()});
+
+}
+
+/*
+ *
+ * Edit property that has a text box
+ *
+ */
+function vboxImportAppliancePropEdit(elm,desc) {
+ $(elm).children().hide();
+ $('<input />').attr({'type':'text','class':'vboxText'}).css({'width':($(elm).innerWidth()-12)+'px','margin':'0px'}).val($(elm).data('descValue')).blur(function(){
+
+ var tbox = this;
+
+ var val = (desc.postEdit ? desc.postEdit($(tbox).val(),$(tbox).parent().data('descValue')) : $(tbox).val());
+ if(val != $(tbox).parent().data('descValue')) {
+ $(tbox).parent().data('descValue',val);
+ if(desc.display) {
+ $(tbox).siblings('span.vboxImportAppProp').html(desc.display(val));
+ } else {
+ $(tbox).siblings('span.vboxImportAppProp').text(val);
+ }
+ $(tbox).parent().data('edited', true);
+
+ // Special case for name
+ if(desc.label == 'Name') {
+
+ // Get ChildOf class
+ var r = /(vboxChildOf\d+)/;
+ var coClass = r.exec($(tbox).closest('tr').attr('class'));
+ coClass = coClass[1];
+
+ // Get unedited disk rows
+ var diskRows = new Array();
+ $.each($(tbox).parent().closest('tr').siblings('.'+coClass), function(i,e){
+ if(!$(e).data('edited') && $(e).data('descType') == 'HardDiskImage') {
+ diskRows[diskRows.length] = e;
+ }
+ });
+
+ if(diskRows.length) {
+ var mfd = new vboxLoader();
+ mfd.add('vboxGetComposedMachineFilename',function(d){
+ var mfolder = vboxDirname(d.responseData) + $("#vboxPane").data('vboxConfig').DSEP;
+ for(var i = 0; i < diskRows.length; i++) {
+ var tdc = $(diskRows[i]).children().eq(1);
+ var dname = vboxBasename($(tdc).data('descValue'));
+ $(tdc).data({'descValue':mfolder + dname}).find('span.vboxImportAppProp').text(mfolder + dname);
+ }
+ },{'name':val,'group':''});
+ mfd.run();
+ }
+ }
+ }
+ $(tbox).hide();
+ $(tbox).siblings().show();
+ $(tbox).remove();
+ }).keydown(function(e){if(e.keyCode == 13) $(this).trigger('blur');}).appendTo(elm);
+ $(elm).children('input:text').first().focus();
+}
+
+</script>
diff --git a/panes/wizardNewVM.html b/panes/wizardNewVM.html
index 3fe1641..0e711d0 100644
--- a/panes/wizardNewVM.html
+++ b/panes/wizardNewVM.html
@@ -1,343 +1,343 @@
-<!--
-
- Panes for new virtual machine wizard. Logic in vboxWizard()
- Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
-
- $Id: wizardNewVM.html 595 2015-04-17 09:50:36Z imoore76 $
-
- -->
-
-<!-- Step 1 -->
-<div id='wizardNewVMStep1' title='Name and operating system' style='display: none'>
-
- <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>
-
- <div class='vboxOptions'>
- <table class='vboxOptions' 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>
-</div>
-
-
-<!-- Step 2 -->
-<div id='wizardNewVMStep2' title='Memory size' style='display: none'>
- <span id='newVMSizeLabel'></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>
-
-</div>
-
-<!-- Step 3 -->
-<div id='wizardNewVMStep3' title='Hard disk' style='display: none'>
-
- <span id='newVMHDSizeLabel'></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.vboxOptions').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;
- $('#wizardNewVMStep3').find('.vboxMediumSelect').trigger('disable');
- } else {
- wizardNewVMToolbar.enable();
- document.forms['frmwizardNewVM'].newVMDiskSelect.disabled = (document.forms['frmwizardNewVM'].newVMDiskSelect.options.length > 0 ? false : true);
- $('#wizardNewVMStep3').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 = 0;
- for(var i = 0; i < s.length; i++) {
- document.forms['frmwizardNewVM'].newVMDiskSelect.options[i] = new Option(vboxMedia.mediumPrint(s[i]),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) {
- document.forms['frmwizardNewVM'].newVMDiskSelect.selectedIndex = selectedIndex;
- }
-
- $(document.forms['frmwizardNewVM'].newVMDiskSelect).mediumselect({'type':'HardDisk','showdiff':false,'media':mediumSelects});
-}
-
-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("<p>Select the amount of memory (RAM) in megabytes "+
- "to be allocated to the virtual machine.</p>"+
- "<p>The recommended memory size is <b>%1</b> MB.</p>",'UIWizardNewVM').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>",'UIWizardNewVM').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
- */
-
-$('#wizardNewVMStep1').on('show',function(e,wiz){
- $(document.forms['frmwizardNewVM'].newVMName).focus();
-});
-
-/* When going to step2, make sure a name is entered */
-$('#wizardNewVMStep2').on('show',function(e,wiz){
-
- document.forms['frmwizardNewVM'].newVMName.value = jQuery.trim(document.forms['frmwizardNewVM'].newVMName.value);
-
- if(!document.forms['frmwizardNewVM'].newVMName.value) {
- $(document.forms['frmwizardNewVM'].newVMName).addClass('vboxRequired');
- // Go back
- wiz.displayStep(1);
- return;
- }
-
- var l = new vboxLoader();
- l.add('vboxGetComposedMachineFilename',function(d){
-
- loc = vboxDirname(d.responseData);
-
- var fe = new vboxLoader();
- fe.add('fileExists',function(d){
- fileExists = d.responseData;
- },{'file':loc});
- fe.onLoad = function() {
- if(fileExists) {
- 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)));
- // Go back
- wiz.displayStep(1);
-
- return;
- }
- $(document.forms['frmwizardNewVM'].newVMName).removeClass('vboxRequired');
-
- // 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');
- }
-
- };
- fe.run();
-
-
- },{'name':document.forms['frmwizardNewVM'].newVMName.value, 'group':wiz.vmgroup});
-
- l.run();
-
-});
-
-/* 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);
-});
-
-
-
-</script>
+<!--
+
+ Panes for new virtual machine wizard. Logic in vboxWizard()
+ Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
+
+ $Id: wizardNewVM.html 595 2015-04-17 09:50:36Z imoore76 $
+
+ -->
+
+<!-- Step 1 -->
+<div id='wizardNewVMStep1' title='Name and operating system' style='display: none'>
+
+ <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>
+
+ <div class='vboxOptions'>
+ <table class='vboxOptions' 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>
+</div>
+
+
+<!-- Step 2 -->
+<div id='wizardNewVMStep2' title='Memory size' style='display: none'>
+ <span id='newVMSizeLabel'></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>
+
+</div>
+
+<!-- Step 3 -->
+<div id='wizardNewVMStep3' title='Hard disk' style='display: none'>
+
+ <span id='newVMHDSizeLabel'></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.vboxOptions').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;
+ $('#wizardNewVMStep3').find('.vboxMediumSelect').trigger('disable');
+ } else {
+ wizardNewVMToolbar.enable();
+ document.forms['frmwizardNewVM'].newVMDiskSelect.disabled = (document.forms['frmwizardNewVM'].newVMDiskSelect.options.length > 0 ? false : true);
+ $('#wizardNewVMStep3').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 = 0;
+ for(var i = 0; i < s.length; i++) {
+ document.forms['frmwizardNewVM'].newVMDiskSelect.options[i] = new Option(vboxMedia.mediumPrint(s[i]),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) {
+ document.forms['frmwizardNewVM'].newVMDiskSelect.selectedIndex = selectedIndex;
+ }
+
+ $(document.forms['frmwizardNewVM'].newVMDiskSelect).mediumselect({'type':'HardDisk','showdiff':false,'media':mediumSelects});
+}
+
+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("<p>Select the amount of memory (RAM) in megabytes "+
+ "to be allocated to the virtual machine.</p>"+
+ "<p>The recommended memory size is <b>%1</b> MB.</p>",'UIWizardNewVM').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>",'UIWizardNewVM').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
+ */
+
+$('#wizardNewVMStep1').on('show',function(e,wiz){
+ $(document.forms['frmwizardNewVM'].newVMName).focus();
+});
+
+/* When going to step2, make sure a name is entered */
+$('#wizardNewVMStep2').on('show',function(e,wiz){
+
+ document.forms['frmwizardNewVM'].newVMName.value = jQuery.trim(document.forms['frmwizardNewVM'].newVMName.value);
+
+ if(!document.forms['frmwizardNewVM'].newVMName.value) {
+ $(document.forms['frmwizardNewVM'].newVMName).addClass('vboxRequired');
+ // Go back
+ wiz.displayStep(1);
+ return;
+ }
+
+ var l = new vboxLoader();
+ l.add('vboxGetComposedMachineFilename',function(d){
+
+ loc = vboxDirname(d.responseData);
+
+ var fe = new vboxLoader();
+ fe.add('fileExists',function(d){
+ fileExists = d.responseData;
+ },{'file':loc});
+ fe.onLoad = function() {
+ if(fileExists) {
+ 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)));
+ // Go back
+ wiz.displayStep(1);
+
+ return;
+ }
+ $(document.forms['frmwizardNewVM'].newVMName).removeClass('vboxRequired');
+
+ // 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');
+ }
+
+ };
+ fe.run();
+
+
+ },{'name':document.forms['frmwizardNewVM'].newVMName.value, 'group':wiz.vmgroup});
+
+ l.run();
+
+});
+
+/* 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);
+});
+
+
+
+</script>
diff --git a/panes/wizardNewVMAdvanced.html b/panes/wizardNewVMAdvanced.html
index 5c7a3c1..3b92917 100644
--- a/panes/wizardNewVMAdvanced.html
+++ b/panes/wizardNewVMAdvanced.html
@@ -1,276 +1,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>
+<!--
+
+ 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>