mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-19 15:26:59 +00:00
Integration search filter improvements (#16067)
* Integration search filter improvements * Handle more cases, fix capitalization
This commit is contained in:
parent
da1063a456
commit
77ffab25f1
@ -118,8 +118,17 @@ allComponents.pop(); // remove placeholder element at the end
|
||||
|
||||
function init() {
|
||||
// do the lowerCase transformation once
|
||||
for (i = 0; i < (allComponents.length); i++) {
|
||||
allComponents[i].titleLC = allComponents[i].title.toLowerCase();
|
||||
for (i = 0; i < allComponents.length; i++) {
|
||||
title = allComponents[i].title.toLowerCase();
|
||||
domain = allComponents[i].domain;
|
||||
title_normalized = title
|
||||
.normalize("NFD")
|
||||
.replace(/[\u0300-\u036f]/g, "");
|
||||
title_dedashed = title.replace(/[-_]/g, " ");
|
||||
title_normalized_dedashed = title_normalized.replace(/[-_]/g, " ");
|
||||
|
||||
allComponents[i].titleLC = title;
|
||||
allComponents[i].search = `${title} ${title_normalized} ${title_dedashed} ${title_normalized_dedashed} ${domain}`;
|
||||
}
|
||||
|
||||
// sort the components alphabetically
|
||||
@ -175,8 +184,10 @@ allComponents.pop(); // remove placeholder element at the end
|
||||
// search through title and category
|
||||
search = decodeURIComponent(hash).substring(8).toLowerCase();
|
||||
filter = function (comp) {
|
||||
return (comp.titleLC.indexOf(search) !== -1) ||
|
||||
(comp.cat.find(c => c.includes("#")) != undefined);
|
||||
return (
|
||||
comp.search.indexOf(search) !== -1 ||
|
||||
comp.cat.find((c) => c.includes("#")) != undefined
|
||||
);
|
||||
};
|
||||
|
||||
} else if (hash === '#featured' || hash === '') {
|
||||
|
Loading…
x
Reference in New Issue
Block a user