extras.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. $(document).ready(function(){
  2. var uninstalling_module_dataloss = $('#dialog').attr('data-uninstalling_module_dataloss');
  3. var are_you_sure = $('#dialog').attr('data-are_you_sure');
  4. var remove_files_for = $('#dialog').attr('data-remove_files_for');
  5. var confirm = $('#dialog').attr('data-confirm');
  6. var cancel = $('#dialog').attr('data-cancel');
  7. $('.install').click(function(){
  8. var addpost = {};
  9. var folder = $(this).attr('data-module-folder');
  10. addpost[ 'm' ] = 'modulemanager';
  11. addpost[ 'p' ] = 'add';
  12. addpost[ 'module' ] = folder;
  13. $('#loading.'+folder).html('<img style="height:10px;" src="images/loading.gif" />');
  14. $.ajax({
  15. type: "GET",
  16. url: "home.php",
  17. data: addpost,
  18. complete: function(){
  19. document.location.reload();
  20. }
  21. });
  22. });
  23. $('.uninstall').click(function(){
  24. var addpost = {};
  25. var folder = $(this).attr('data-module-folder');
  26. var id = $(this).attr('data-module-id');
  27. addpost[ 'm' ] = 'modulemanager';
  28. addpost[ 'p' ] = 'del';
  29. addpost[ 'id' ] = id;
  30. addpost[ 'module' ] = folder;
  31. $( "#dialog" ).attr('title', are_you_sure+'?').html('<p>'+uninstalling_module_dataloss+'</p>');
  32. $( "#dialog" ).dialog({
  33. resizable: false,
  34. height:150,
  35. modal: true,
  36. buttons:
  37. [{ text: confirm, click: function(){
  38. $( this ).dialog( "close" );
  39. $('#loading.'+folder).html('<img style="height:10px;" src="images/loading.gif" />');
  40. $.ajax({
  41. type: "GET",
  42. url: "home.php",
  43. data: addpost,
  44. complete: function(){
  45. document.location.reload();
  46. }
  47. });
  48. }
  49. },{ text: cancel, click: function(){
  50. $( this ).dialog( "close" );
  51. }
  52. }]
  53. });
  54. });
  55. $('.remove').click(function(){
  56. var addpost = {};
  57. var folder = $(this).attr('data-module-folder');
  58. var mode = $(this).attr('data-remove-mode');
  59. addpost[ 'remove' ] = mode;
  60. addpost[ 'folder' ] = folder;
  61. $( "#dialog" ).attr('title', are_you_sure+'?').html('<p>'+remove_files_for+' '+folder+'?</p>');
  62. $( "#dialog" ).dialog({
  63. resizable: false,
  64. height:150,
  65. modal: true,
  66. buttons:
  67. [{ text: confirm, click: function(){
  68. $( this ).dialog( "close" );
  69. $('#loading.'+folder).html('<img style="height:10px;" src="images/loading.gif" />');
  70. $.ajax({
  71. type: "POST",
  72. url: "home.php?m=extras&type=cleared",
  73. data: addpost,
  74. complete: function(){
  75. document.location.reload();
  76. }
  77. });
  78. }
  79. },{ text: cancel, click: function(){
  80. $( this ).dialog( "close" );
  81. }
  82. }]
  83. });
  84. });
  85. $('button[name=update]').click(function(){
  86. $('#updateButton').html('<img style="height:20px;" src="images/loading.gif" />');
  87. var addpost = {};
  88. addpost.theme = [];
  89. addpost.module = [];
  90. addpost.update = '';
  91. var name = '';
  92. var value = '';
  93. $('input[type=checkbox]:checked').each(function(){
  94. name = $(this).attr('name');
  95. value = $(this).attr('value');
  96. if(name == 'theme')
  97. {
  98. addpost.theme.push(value);
  99. }
  100. if(name == 'module')
  101. {
  102. addpost.module.push(value);
  103. }
  104. return addpost;
  105. });
  106. var mirror = $('#mirror').val();
  107. if(typeof mirror != "undefined")
  108. {
  109. addpost.mirror = mirror;
  110. }
  111. $.ajax({
  112. type: "POST",
  113. url: "home.php?m=extras&type=cleared",
  114. data: addpost,
  115. success: function(data){
  116. var message = data.replace(/(<([^>]+)>)/ig,"");
  117. message = message.trim();
  118. if(message != '')
  119. {
  120. alert(message);
  121. }
  122. },
  123. complete: function(){
  124. document.location.reload();
  125. }
  126. });
  127. });
  128. });