@@ -351,29 +351,35 @@ function filterResults() {
351
351
download . style . display = 'block' ;
352
352
board_count ++ ;
353
353
// 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 ) {
357
358
let parent = download . parentElement ;
358
359
parent . removeChild ( download ) ;
359
360
parent . prepend ( download ) ;
360
-
361
+ }
361
362
}
362
363
}
363
364
} ) ;
364
365
document . getElementById ( "board_count" ) . innerHTML = board_count ;
365
366
}
366
367
367
368
function 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
+ }
369
373
var sortType = event . target . value ;
370
374
setURL ( 'sort-by' , sortType ) ;
371
375
var downloads = document . querySelector ( '.downloads-section' ) ;
372
376
Array . prototype . slice . call ( downloads . children )
373
377
. map ( function ( download ) { return downloads . removeChild ( download ) ; } )
374
378
. sort ( function ( a , b ) {
375
379
// 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
+
377
383
return - 2 ;
378
384
}
379
385
switch ( sortType ) {
0 commit comments