common.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. $(function()
  2. {
  3. $('[data-toggle="popover"]').popover();
  4. if(config.currentMethod == 'create') $('#parent').change();
  5. $('#parent').change(function()
  6. {
  7. if(config.currentMethod == 'create'){
  8. var hostID = $('#parent').val();
  9. var link = createLink('zanode', 'ajaxGetImages', 'hostID=' + hostID);
  10. $.get(link, function(data)
  11. {
  12. $('#template').html('').append(data);
  13. $('#image').chosen().trigger("chosen:updated");
  14. $('#image').change();
  15. });
  16. }
  17. });
  18. if(typeof(hostID) != "undefined" && hostID) $('#parent').change();
  19. $(document).on("change", '#image', function()
  20. {
  21. var image = $('#image').val();
  22. var link = createLink('zanode', 'ajaxGetImage', 'image=' + image);
  23. $.get(link, function(data)
  24. {
  25. data = JSON.parse(data);
  26. $('#osName').val(data.osName);
  27. if(data.memory != 0)
  28. {
  29. $('#memory').val(data.memory);
  30. }
  31. if(data.memory != 0)
  32. {
  33. $('#diskSize').val(data.disk);
  34. }
  35. });
  36. });
  37. if(typeof image == 'undefined' || !image) $('#os').change();
  38. })