選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

guestNetAdapters.html 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <!--
  2. Shows guest networking adapters. This requires that Guest Additions be
  3. installed in the Guest VM
  4. Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
  5. $Id: guestNetAdapters.html 595 2015-04-17 09:50:36Z imoore76 $
  6. -->
  7. <div id='vboxGuestNetAdapters'>
  8. </div>
  9. <!-- Used as a Template -->
  10. <div id='vboxGuestNetAdapterTemplate' class='vboxDialogContent vboxTabContent' style='display: none'>
  11. <table class="vboxVertical">
  12. <tr>
  13. <th><span class='translate'>IPv4 Address</span>:</th>
  14. <td><span title='/V4/IP'></span></td>
  15. </tr>
  16. <tr>
  17. <th><span class='translate'>IPv4 Network Mask</span>:</th>
  18. <td><span title='/V4/Netmask'></span></td>
  19. </tr>
  20. <tr class='vboxIPv6' style='display: none'>
  21. <th><span class='translate'>IPv6 Address</span>:</th>
  22. <td><span title='/V6/Ip'></span></td>
  23. </tr>
  24. <tr class='vboxIPv6' style='display: none'>
  25. <th><span class='translate'>IPv6 Network Mask Length</span>:</th>
  26. <td><span title='/V6/Netmask'></span></td>
  27. </tr>
  28. <tr>
  29. <th><span class='vboxGuestMac'>MAC Address:</span></th>
  30. <td><span title='/MAC'></span></td>
  31. </tr>
  32. </table>
  33. </div>
  34. <script type='text/javascript'>
  35. /* Translate */
  36. // Mac is special
  37. $('#vboxGuestNetAdapterTemplate').find('span.vboxGuestMac').html(trans('Mac Address:','UIMachineSettingsNetwork'));
  38. $('#vboxGuestNetAdapterTemplate').find(".translate").html(function(i,h){return trans(h,'UIGlobalSettingsNetwork');}).removeClass('translate');
  39. /*
  40. * Get data and pass to init function
  41. */
  42. function vboxVMNetAdaptersInit(vm) {
  43. // Add spinner and remove tab list if it exists
  44. $('#vboxGuestNetAdapterList').remove();
  45. $('#vboxGuestNetAdapters').prepend("<div class='vboxTabLoading'><img src='images/spinner.gif'></div>");
  46. var pattern = '/VirtualBox/GuestInfo/Net/*';
  47. $.when(vboxAjaxRequest('machineEnumerateGuestProperties',{'vm':vm,'pattern':pattern})).done(function(d){
  48. vboxVMNetAdaptersDisplay(d.responseData);
  49. });
  50. }
  51. function vboxVMNetAdaptersDisplay(d) {
  52. // Create hash / assoc array / mapping
  53. var data = {};
  54. for(var a = 0; a < d[0].length; a++) {
  55. data[d[0][a].replace('/VirtualBox/GuestInfo/Net/','')] = d[1][a];
  56. }
  57. // Remove spinner
  58. $('#vboxGuestNetAdapters').children().first().remove();
  59. // Append tab list
  60. var adl = $('<div />').attr({'id':'vboxGuestNetAdapterList','class':'vboxTabbed'});
  61. // Check for data
  62. if(!data['Count'] || data['Count'] < 1) {
  63. $(adl).html(trans('Unable to retrieve guest properties. Make sure the virtual machine is running and has the VirtualBox Guest Additions installed.','phpVirtualBox'));
  64. $('#vboxGuestNetAdapters').prepend(adl);
  65. return;
  66. }
  67. // Create list
  68. var ul = $('<ul />');
  69. // Each net adapter
  70. for(var i = 0; i < data['Count']; i++) {
  71. // Tab link
  72. $(ul).append($('<li />').html('<a href="#vboxGuestNetAdapter' + (i + 1) +'"><span>' + trans('Adapter %1','VBoxGlobal').replace('%1',(i + 1)) + '</span></a>'));
  73. // Tab content
  74. var tmpl = $("#vboxGuestNetAdapterTemplate").clone(true);
  75. tmpl.find('span[title]').each(function(){
  76. $(this).html(data[i+$(this).attr('title')]);
  77. });
  78. $(tmpl).attr('id','vboxGuestNetAdapter'+(i+1)).css({'display':''}).appendTo(adl);
  79. }
  80. // Tab links UL
  81. $(adl).prepend(ul);
  82. // prepend tabs
  83. $("#vboxGuestNetAdapters").prepend(adl);
  84. // Init display
  85. vboxInitDisplay('vboxGuestNetAdapters');
  86. }
  87. </script>