Skip to content

Commit f8d24c1

Browse files
authored
Merge pull request #1538 from FoamyGuy/search_exact_tags
exact match tags search
2 parents 5981326 + a646a2e commit f8d24c1

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

_board/raspberry_pi_pico2.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ board_url:
1010
board_image: "raspberry_pi_pico2.jpg"
1111
date_added: 2024-08-08
1212
family: raspberrypi
13+
tags:
14+
- pico 2
1315
features:
1416
- Breadboard-Friendly
1517
- Castellated Pads

assets/javascript/downloads.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff 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

358367
function 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);

0 commit comments

Comments
 (0)