ニジカもんすたぁ!! トップ・ページ 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.0 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. class
  2. Script
  3. {
  4. static
  5. main ()
  6. {
  7. const url = new URL (window.location.href);
  8. const orderAsc = document.getElementById ('order-asc');
  9. const filterKeyword = document.getElementById ('filter-keyword');
  10. const btnFilter = document.getElementById ('btn-filter');
  11. const filter = (
  12. function (e)
  13. {
  14. url.searchParams.delete ('p');
  15. url.searchParams.delete ('asc');
  16. url.searchParams.append ('asc', orderAsc.checked ? '1' : '0');
  17. url.searchParams.delete ('q');
  18. url.searchParams.append ('q', filterKeyword.value);
  19. window.location.href = url;
  20. });
  21. filterKeyword.addEventListener ('keydown',
  22. function (e)
  23. {
  24. if (e.key === 'Enter')
  25. filter (e);
  26. });
  27. btnFilter.addEventListener ('click', filter);
  28. }
  29. static
  30. jumpTo (page)
  31. {
  32. const url = new URL (window.location.href);
  33. url.searchParams.delete ('p');
  34. url.searchParams.append ('p', page);
  35. window.location.href = url;
  36. }
  37. }
  38. Script.main ();