improve search
This commit is contained in:
@@ -261,7 +261,7 @@ const sortedTags = Object.entries(tagFrequency)
|
||||
}
|
||||
|
||||
function filterTools() {
|
||||
const searchTerm = elements.searchInput.value.toLowerCase();
|
||||
const searchTerm = elements.searchInput.value.trim();
|
||||
const selectedDomain = elements.domainSelect.value;
|
||||
const includeProprietary = elements.proprietaryCheckbox.checked;
|
||||
|
||||
@@ -270,26 +270,31 @@ const sortedTags = Object.entries(tagFrequency)
|
||||
const phases = tool.phases || [];
|
||||
const tags = tool.tags || [];
|
||||
|
||||
// Search filter (keep existing logic)
|
||||
if (searchTerm && !(
|
||||
tool.name.toLowerCase().includes(searchTerm) ||
|
||||
tool.description.toLowerCase().includes(searchTerm) ||
|
||||
tags.some(tag => tag.toLowerCase().includes(searchTerm))
|
||||
tool.name.toLowerCase().includes(searchTerm.toLowerCase()) ||
|
||||
tool.description.toLowerCase().includes(searchTerm.toLowerCase()) ||
|
||||
tags.some(tag => tag.toLowerCase().includes(searchTerm.toLowerCase()))
|
||||
)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Domain filter
|
||||
if (selectedDomain && !domains.includes(selectedDomain)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Phase filter
|
||||
if (selectedPhase && !phases.includes(selectedPhase)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Proprietary filter
|
||||
if (!includeProprietary && !isMethod(tool) && tool.type !== 'concept' && tool.license === 'Proprietary') {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Tag filter
|
||||
if (selectedTags.size > 0 && !Array.from(selectedTags).every(tag => tags.includes(tag))) {
|
||||
return false;
|
||||
}
|
||||
@@ -297,9 +302,14 @@ const sortedTags = Object.entries(tagFrequency)
|
||||
return true;
|
||||
});
|
||||
|
||||
// Apply search prioritization if there's a search term
|
||||
const finalResults = searchTerm && window.prioritizeSearchResults
|
||||
? window.prioritizeSearchResults(filtered, searchTerm)
|
||||
: filtered;
|
||||
|
||||
updateMatrixHighlighting();
|
||||
|
||||
window.dispatchEvent(new CustomEvent('toolsFiltered', { detail: filtered }));
|
||||
window.dispatchEvent(new CustomEvent('toolsFiltered', { detail: finalResults }));
|
||||
}
|
||||
|
||||
function handleTagClick(tagItem) {
|
||||
|
||||
Reference in New Issue
Block a user