admin.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /**
  2. * Main Javascript file
  3. *
  4. * @author Open Mind
  5. * @date 04/12/2018
  6. * @time 16:00
  7. */
  8. var fetchHeaders = {
  9. 'Accept': 'text/html',
  10. 'Content-Type': 'text/html',
  11. 'X-Requested-With': 'XMLHttpRequest',
  12. 'Cache-Control': 'no-cache',
  13. 'Pragma': 'no-cache',
  14. 'Expires': '0'
  15. };
  16. /* usefull if a blinking text is need, like in MaxMara project, you need to place this code in html:
  17. *
  18. * <nav class="navbar navbar-collapse p-0">
  19. * <span class="navbar-text blink" style="color: red" id="statusbartext"></span>
  20. * </nav>
  21. */
  22. function SetStatusBarText(msg) {
  23. $('#statusbartext').text(msg);
  24. setTimeout(() => {
  25. $('#statusbartext').text('');
  26. }, 60000);
  27. }
  28. /*
  29. function refreshNotificationArea() {
  30. fetch(`${BASEURL}/api.system.getserverstatus`, {headers: fetchHeaders})
  31. .then(resp => {
  32. if (resp.status === 200)
  33. return resp.json();
  34. else
  35. return Promise.reject("getserverstatus: error");
  36. })
  37. .then(data => {
  38. NotificationBuilder(data.notify);
  39. })
  40. .catch(err => {
  41. console.log(err);
  42. });
  43. }
  44. */
  45. function SetupConfirmationDialog() {
  46. $('.requestconfirm').on('click', function (ev) {
  47. let confirmText = $(this).data('confirmtext');
  48. if (!confirm(confirmText))
  49. ev.preventDefault();
  50. });
  51. }
  52. function SetupSubmitFormDisabler() {
  53. $('body').on('submit', 'form', function () {
  54. $('form input,form select').prop('disabled', false);
  55. setTimeout(function () {
  56. $('form input,form select').prop('disabled', true);
  57. }, 500);
  58. });
  59. }
  60. $(function () {
  61. SetupConfirmationDialog();
  62. SetupSubmitFormDisabler();
  63. });