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