ニジカもんすたぁ!! トップ・ページ https://nizika.monster
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

script.js 1.8 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. class
  2. Script
  3. {
  4. static
  5. main ()
  6. {
  7. const dateOptions = {dateFormat: 'yy-mm-dd',
  8. firstDay: 6};
  9. $ ('#filter-date-start').datepicker (dateOptions);
  10. $ ('#filter-date-end').datepicker (dateOptions);
  11. const url = new URL (window.location.href);
  12. const orderAsc = document.getElementById ('order-asc');
  13. const filterKeyword = document.getElementById ('filter-keyword');
  14. const btnFilter = document.getElementById ('btn-filter');
  15. const filter = (
  16. function (e)
  17. {
  18. let dateStart = $ ('#filter-date-start').val ();
  19. let dateEnd = $ ('#filter-date-end').val ();
  20. if ((dateStart !== '')
  21. && (dateEnd !== '')
  22. && (dateStart > dateEnd))
  23. [dateStart, dateEnd] = [dateEnd, dateStart];
  24. url.searchParams.delete ('p');
  25. url.searchParams.delete ('asc');
  26. url.searchParams.append ('asc', orderAsc.checked ? '1' : '0');
  27. url.searchParams.delete ('q');
  28. url.searchParams.append ('q', filterKeyword.value);
  29. url.searchParams.delete ('start');
  30. url.searchParams.delete ('end');
  31. if (dateStart !== '')
  32. url.searchParams.append ('start', dateStart);
  33. if (dateEnd !== '')
  34. url.searchParams.append ('end', dateEnd);
  35. window.location.href = url;
  36. });
  37. filterKeyword.addEventListener ('keydown',
  38. function (e)
  39. {
  40. if (e.key === 'Enter')
  41. filter (e);
  42. });
  43. btnFilter.addEventListener ('click', filter);
  44. }
  45. static
  46. jumpTo (page)
  47. {
  48. const url = new URL (window.location.href);
  49. url.searchParams.delete ('p');
  50. url.searchParams.append ('p', page);
  51. window.location.href = url;
  52. }
  53. }
  54. Script.main ();