common.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Copyright (C) 2021 Echedey López Romero <elr@disroot.org>
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. function ResetDays() {
  18. let Days = document.getElementById('day');
  19. Days.value = '';
  20. }
  21. function LimitDays() {
  22. let Month = document.getElementById('month').value;
  23. let Days = document.getElementById('day');
  24. if (Month !== '') {
  25. let Limit;
  26. switch (Month) {
  27. case 'January':
  28. case 'March':
  29. case 'May':
  30. case 'July':
  31. case 'August':
  32. case 'October':
  33. case 'December':
  34. Limit = 31;
  35. break;
  36. case 'April':
  37. case 'June':
  38. case 'September':
  39. case 'November':
  40. Limit = 30;
  41. break;
  42. case 'February':
  43. Limit = 29;
  44. break;
  45. }
  46. for (Pos = 0; Pos < Days.length; Pos++) {
  47. let Option = Days[Pos];
  48. if (Option.value <= Limit) {
  49. Option.removeAttribute('style');
  50. } else {
  51. Option.style.display = 'none';
  52. }
  53. }
  54. if (Days.value > Limit) {
  55. Days.value = '';
  56. }
  57. } else {
  58. for (Pos = 0; Pos < Days.length; Pos++) {
  59. let Option = Days[Pos];
  60. Option.removeAttribute('style');
  61. }
  62. }
  63. }
  64. function AddOnChangeMonth() {
  65. let Month = document.getElementById('month');
  66. Month.setAttribute('onchange', 'LimitDays(); ResetDays();');
  67. }
  68. function Restart() {
  69. let Operators = document.getElementsByTagName('select');
  70. for (let Pos = 0; Pos < Operators.length; Pos++) {
  71. for (let Option = 0; Option < Operators[Pos].length; Option++) {
  72. Operators[Pos][Option].removeAttribute('selected');
  73. }
  74. Operators[Pos][0].setAttribute('selected', '');
  75. }
  76. let Result = document.getElementById('result');
  77. Result.innerHTML = '<span class="d-block text-center">--</span>\n';
  78. }