Vyhledávání nezávislé na diakritice

This commit is contained in:
Emil Miler 2022-04-19 18:09:50 +02:00
parent 0f408e2cb9
commit 3f54c2b90a

View File

@ -22,7 +22,7 @@ input.oninput = function() { filter_name(input.value) };
let articles = document.getElementsByTagName("article");
function filter_name(str) {
str = str.toLowerCase();
str = str.toLowerCase().normalize("NFD").replace(/\p{Diacritic}/gu, "");
if (str.length==0) {
for (let i=0; i<articles.length; i++) {
@ -30,7 +30,7 @@ function filter_name(str) {
}
} else {
for (let i=0; i<articles.length; i++) {
let name = articles[i].getElementsByTagName("h3")[0].innerHTML.toLowerCase();
let name = articles[i].getElementsByClassName("title")[0].innerHTML.toLowerCase().normalize("NFD").replace(/\p{Diacritic}/gu, "");
if (!name.includes(str)) {
articles[i].style.display = "none";
} else {