Skip to content

Commit

Permalink
Merge pull request #1538 from FoamyGuy/search_exact_tags
Browse files Browse the repository at this point in the history
exact match tags search
  • Loading branch information
dhalbert authored Nov 19, 2024
2 parents 5981326 + a646a2e commit f8d24c1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions _board/raspberry_pi_pico2.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ board_url:
board_image: "raspberry_pi_pico2.jpg"
date_added: 2024-08-08
family: raspberrypi
tags:
- pico 2
features:
- Breadboard-Friendly
- Castellated Pads
Expand Down
14 changes: 14 additions & 0 deletions assets/javascript/downloads.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,18 +350,32 @@ function filterResults() {
} else {
download.style.display = 'block';
board_count++;
// exact tag match re-order
let searched = downloadsSearch.searchTerm.toLowerCase();
let tags = download.getAttribute("data-tags").split(",");
if (tags.indexOf(searched) >= 0 ){
let parent = download.parentElement;
parent.removeChild(download);
parent.prepend(download);

}
}
});
document.getElementById("board_count").innerHTML = board_count;
}

function handleSortResults(event) {
let searched = downloadsSearch.searchTerm.toLowerCase();
var sortType = event.target.value;
setURL('sort-by', sortType);
var downloads = document.querySelector('.downloads-section');
Array.prototype.slice.call(downloads.children)
.map(function (download) { return downloads.removeChild(download); })
.sort(function (a, b) {
// exact tag match re-order
if (a.dataset.tags.split(",").indexOf(searched) >= 0){
return -2;
}
switch(sortType) {
case 'alpha-asc':
return a.dataset.name.localeCompare(b.dataset.name);
Expand Down

0 comments on commit f8d24c1

Please sign in to comment.