@@ -15,14 +15,12 @@ const ajax = (endpoint, callback, data = null) => {
1515 request . send ( data ) ;
1616}
1717
18- const query_params = ( ... args ) => {
18+ const query_params = ( params ) => {
1919 const url = new URL ( location . href ) ;
2020 const search_params = new URLSearchParams ( url . search ) ;
2121
22- if ( args . length === 2 && typeof args [ 0 ] === 'string' ) {
23- search_params . set ( args [ 0 ] , String ( args [ 1 ] ) ) ;
24- } else if ( args . length === 1 && typeof args [ 0 ] === 'object' ) {
25- Object . entries ( args [ 0 ] ) . forEach ( ( [ key , value ] ) => {
22+ if ( typeof params === 'object' ) {
23+ Object . entries ( params ) . forEach ( ( [ key , value ] ) => {
2624 if ( value === null ) {
2725 search_params . delete ( key ) ;
2826 } else {
@@ -40,7 +38,7 @@ const select_and_redirect = (id, param) => {
4038
4139 if ( select ) {
4240 select . addEventListener ( 'change' , e => {
43- query_params ( param , e . target . value ) ;
41+ query_params ( { [ param ] : e . target . value } ) ;
4442 } ) ;
4543 }
4644}
@@ -182,7 +180,7 @@ const search_form = document.getElementById('search_form');
182180if ( search_form ) {
183181 const submit_search = document . getElementById ( 'submit_search' ) ;
184182 submit_search . addEventListener ( 'click' , ( ) => {
185- query_params ( 's' , document . getElementById ( 'search_key' ) . value )
183+ query_params ( { p : null , s : document . getElementById ( 'search_key' ) . value } ) ;
186184 } ) ;
187185
188186 const search_key = document . getElementById ( 'search_key' ) ;
0 commit comments