ui.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. ui.js
  3. */
  4. function cjax(object){
  5. let csrf_token = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
  6. $.ajax({
  7. url: object.url,
  8. type: object.type || 'POST',
  9. data: object.data || {},
  10. headers: {
  11. 'X-CSRF-Token': csrf_token
  12. },
  13. success: object.success,
  14. error: object.error
  15. });
  16. }
  17. // Add cjax as a jQuery method
  18. $.cjax = cjax;
  19. function switchMassStorageToRemote(){
  20. $.cjax({
  21. url: '/aux/switchusbremote',
  22. type: 'GET',
  23. success: function(response) {
  24. //alert('Mass Storage switched to Remote successfully.');
  25. },
  26. error: function(xhr, status, error) {
  27. alert('Error switching Mass Storage to Remote: ' + error);
  28. }
  29. });
  30. }
  31. function switchMassStorageToKvm(){
  32. $.cjax({
  33. url: '/aux/switchusbkvm',
  34. type: 'GET',
  35. success: function(response) {
  36. //alert('Mass Storage switched to KVM successfully.');
  37. },
  38. error: function(xhr, status, error) {
  39. alert('Error switching Mass Storage to KVM: ' + error);
  40. }
  41. });
  42. }