class Script { static main () { $ ('#filter-date-start').datepicker (); $ ('#filter-date-end').datepicker (); const url = new URL (window.location.href); const orderAsc = document.getElementById ('order-asc'); const filterKeyword = document.getElementById ('filter-keyword'); const btnFilter = document.getElementById ('btn-filter'); const filter = ( function (e) { url.searchParams.delete ('p'); url.searchParams.delete ('asc'); url.searchParams.append ('asc', orderAsc.checked ? '1' : '0'); url.searchParams.delete ('q'); url.searchParams.append ('q', filterKeyword.value); window.location.href = url; }); filterKeyword.addEventListener ('keydown', function (e) { if (e.key === 'Enter') filter (e); }); btnFilter.addEventListener ('click', filter); } static jumpTo (page) { const url = new URL (window.location.href); url.searchParams.delete ('p'); url.searchParams.append ('p', page); window.location.href = url; } } Script.main ();