help.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. $('#create').ajaxForm({
  2. dataType: 'json',
  3. success: function(data)
  4. {
  5. $.each(data, function(i, val)
  6. {
  7. if(i == 'e')
  8. bootbox.dialog('<h3 class="red">Ошибка</h3>'+val,
  9. [{
  10. "label" : "OK",
  11. "class" : "btn-small btn-primary",
  12. }]
  13. );
  14. if(i == 's')
  15. location.href=home+'help/section/dialog/id/'+val;
  16. });
  17. return false;
  18. }
  19. });
  20. $('#reply').ajaxForm({
  21. dataType: 'json',
  22. success: function(data)
  23. {
  24. $.each(data, function(i, val)
  25. {
  26. if(i == 'e')
  27. bootbox.dialog('<h3 class="red">Ошибка</h3>'+val,
  28. [{
  29. "label" : "OK",
  30. "class" : "btn-small btn-primary",
  31. }]
  32. );
  33. if(i == 'с')
  34. {
  35. bootbox.dialog('<h3 class="blue">Внимание</h3>'+val,
  36. [{
  37. "label" : "OK",
  38. "class" : "btn-small btn-primary",
  39. }]
  40. );
  41. location.reload();
  42. }
  43. if(i == 'i')
  44. {
  45. bootbox.dialog('<h3 class="blue">Внимание</h3>'+val,
  46. [{
  47. "label" : "OK",
  48. "class" : "btn-small btn-primary",
  49. }]
  50. );
  51. dialog_update(false);
  52. }
  53. if(i == 's')
  54. {
  55. $('#text').val('');
  56. $('#text').html('');
  57. document.getElementById("text").removeAttribute("style");
  58. dialog_update(false);
  59. }
  60. });
  61. return false;
  62. }
  63. });
  64. function help_open(id)
  65. {
  66. $.getJSON(home+'help/section/close/action/open/id/'+id,
  67. function(data)
  68. {
  69. $.each(data, function(i, val)
  70. {
  71. if(i == 'e')
  72. bootbox.dialog('<h3 class="red">Ошибка</h3>'+val,
  73. [{
  74. "label" : "OK",
  75. "class" : "btn-small btn-primary",
  76. }]
  77. );
  78. if(i == 's')
  79. location.href=home+'help/section/dialog/id/'+id;
  80. });
  81. });
  82. }
  83. function help_msg_del(id, msg)
  84. {
  85. $.getJSON(home+'help/section/dialog/action/remove/id/'+id+'/msg/'+msg,
  86. function(data)
  87. {
  88. $.each(data, function(i, val)
  89. {
  90. if(i == 'e')
  91. bootbox.dialog('<h3 class="red">Ошибка</h3>'+val,
  92. [{
  93. "label" : "OK",
  94. "class" : "btn-small btn-primary",
  95. }]
  96. );
  97. if(i == 's')
  98. dialog_update(false);
  99. });
  100. });
  101. return false;
  102. }
  103. function help_close(id)
  104. {
  105. $.getJSON(home+'help/section/open/action/close/id/'+id,
  106. function(data)
  107. {
  108. $.each(data, function(i, val)
  109. {
  110. if(i == 'e')
  111. bootbox.dialog('<h3 class="red">Ошибка</h3>'+val,
  112. [{
  113. "label" : "OK",
  114. "class" : "btn-small btn-primary",
  115. }]
  116. );
  117. if(i == 's')
  118. location.reload();
  119. });
  120. });
  121. }
  122. function help_readers()
  123. {
  124. $.get(home+'help/section/dialog/action/read/id/'+help,
  125. function(readers)
  126. {
  127. setTimeout(function() {help_readers()}, 9000);
  128. });
  129. }
  130. function help_writers(now)
  131. {
  132. write = '';
  133. if($('#text').val() != '')
  134. write = '/write/1';
  135. $.get(home+'help/section/dialog/action/write/id/'+help+write,
  136. function(writers)
  137. {
  138. if(!now)
  139. setTimeout(function() {help_writers(false)}, 9000);
  140. });
  141. }
  142. function dialog_update(go)
  143. {
  144. if(go)
  145. {
  146. spoilers = $('.spoiler_main');
  147. update = true;
  148. for(var i = 0; i < spoilers.length; i++)
  149. {
  150. if(spoilers[i].style.display == 'block')
  151. {
  152. setTimeout(function() {dialog_update(true)}, 15000);
  153. return false;
  154. }
  155. }
  156. }
  157. $.getJSON(home+'help/section/dialog/id/'+help+'/ajax',
  158. function(data)
  159. {
  160. $.each(data, function(i, val)
  161. {
  162. if(i == 'dialog')
  163. {
  164. $('#dialog').html(val);
  165. $('.spoiler').click(function(){
  166. $(this).parent().children('div.spoiler_main').toggle(0);
  167. });
  168. }
  169. if(i == 'status')
  170. $('#help_status').html(val);
  171. });
  172. if(go)
  173. setTimeout(function() {dialog_update(true)}, 15000);
  174. });
  175. }
  176. // Переустановка сервера (подтверждение)
  177. function help_delete(id)
  178. {
  179. bootbox.dialog('<h3 class="red">Внимание</h3> Вы уверены, что хотите удалить этот вопрос?',
  180. [{
  181. "label" : "Подтвердить",
  182. "class" : "btn-small btn-primary",
  183. callback: function() {help_delete_go(id)}
  184. },{
  185. "label" : "Отмена",
  186. "class" : "btn-small btn-primary",
  187. }]
  188. );
  189. }
  190. function help_delete_go(id)
  191. {
  192. $.getJSON(home+'help/section/open/action/delete/id/'+id,
  193. function(data)
  194. {
  195. $.each(data, function(i, val)
  196. {
  197. if(i == 'e')
  198. bootbox.dialog('<h3 class="red">Ошибка</h3>'+val,
  199. [{
  200. "label" : "OK",
  201. "class" : "btn-small btn-primary",
  202. }]
  203. );
  204. if(i == 's')
  205. location.reload();
  206. });
  207. });
  208. }