оптимизировал поиск по инструментам
This commit is contained in:
+14
-4
@@ -1350,10 +1350,20 @@ function renderToolkitCards(tabId, tools, categoriesMap, filterText = '', catego
|
||||
|
||||
// Фильтр по поисковому запросу
|
||||
if (filterText) {
|
||||
const searchLower = filterText.toLowerCase();
|
||||
const titleMatch = tool.title.toLowerCase().includes(searchLower);
|
||||
const descriptionMatch = tool.description.toLowerCase().includes(searchLower);
|
||||
if (!titleMatch && !descriptionMatch) {
|
||||
const normalize = s => s.toLowerCase().replace(/ё/g, 'е');
|
||||
|
||||
const searchWords = normalize(filterText)
|
||||
.split(/\s+/)
|
||||
.filter(Boolean);
|
||||
|
||||
const title = normalize(tool.title);
|
||||
const description = normalize(tool.description);
|
||||
|
||||
const matches =
|
||||
searchWords.every(word => title.includes(word)) ||
|
||||
searchWords.every(word => description.includes(word));
|
||||
|
||||
if (!matches) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user