@@ -351,29 +351,35 @@ function filterResults() {
351351 download . style . display = 'block' ;
352352 board_count ++ ;
353353 // exact tag match re-order
354- let searched = downloadsSearch . searchTerm . toLowerCase ( ) ;
355- let tags = download . getAttribute ( "data-tags" ) . split ( "," ) ;
356- if ( tags . indexOf ( searched ) >= 0 ) {
354+ if ( downloadsSearch . searchTerm !== null && downloadsSearch . searchTerm !== undefined ) {
355+ let searched = downloadsSearch . searchTerm . toLowerCase ( ) ;
356+ let tags = download . getAttribute ( "data-tags" ) . split ( "," ) ;
357+ if ( searched !== "" && tags . indexOf ( searched ) >= 0 ) {
357358 let parent = download . parentElement ;
358359 parent . removeChild ( download ) ;
359360 parent . prepend ( download ) ;
360-
361+ }
361362 }
362363 }
363364 } ) ;
364365 document . getElementById ( "board_count" ) . innerHTML = board_count ;
365366}
366367
367368function handleSortResults ( event ) {
368- let searched = downloadsSearch . searchTerm . toLowerCase ( ) ;
369+ let searched ;
370+ if ( downloadsSearch . searchTerm !== null && downloadsSearch . searchTerm !== undefined ) {
371+ searched = downloadsSearch . searchTerm . toLowerCase ( ) ;
372+ }
369373 var sortType = event . target . value ;
370374 setURL ( 'sort-by' , sortType ) ;
371375 var downloads = document . querySelector ( '.downloads-section' ) ;
372376 Array . prototype . slice . call ( downloads . children )
373377 . map ( function ( download ) { return downloads . removeChild ( download ) ; } )
374378 . sort ( function ( a , b ) {
375379 // exact tag match re-order
376- if ( a . dataset . tags . split ( "," ) . indexOf ( searched ) >= 0 ) {
380+ if ( searched !== undefined && searched !== "" &&
381+ a . dataset . tags . split ( "," ) . indexOf ( searched ) >= 0 ) {
382+
377383 return - 2 ;
378384 }
379385 switch ( sortType ) {
0 commit comments