File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ board_url:
1010board_image : " raspberry_pi_pico2.jpg"
1111date_added : 2024-08-08
1212family : raspberrypi
13+ tags :
14+ - pico 2
1315features :
1416 - Breadboard-Friendly
1517 - Castellated Pads
Original file line number Diff line number Diff line change @@ -350,18 +350,32 @@ function filterResults() {
350350 } else {
351351 download . style . display = 'block' ;
352352 board_count ++ ;
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 ) {
357+ let parent = download . parentElement ;
358+ parent . removeChild ( download ) ;
359+ parent . prepend ( download ) ;
360+
361+ }
353362 }
354363 } ) ;
355364 document . getElementById ( "board_count" ) . innerHTML = board_count ;
356365}
357366
358367function handleSortResults ( event ) {
368+ let searched = downloadsSearch . searchTerm . toLowerCase ( ) ;
359369 var sortType = event . target . value ;
360370 setURL ( 'sort-by' , sortType ) ;
361371 var downloads = document . querySelector ( '.downloads-section' ) ;
362372 Array . prototype . slice . call ( downloads . children )
363373 . map ( function ( download ) { return downloads . removeChild ( download ) ; } )
364374 . sort ( function ( a , b ) {
375+ // exact tag match re-order
376+ if ( a . dataset . tags . split ( "," ) . indexOf ( searched ) >= 0 ) {
377+ return - 2 ;
378+ }
365379 switch ( sortType ) {
366380 case 'alpha-asc' :
367381 return a . dataset . name . localeCompare ( b . dataset . name ) ;
You can’t perform that action at this time.
0 commit comments