From b067fccf9cbc5732cbb658b77c4658f436c6fbc5 Mon Sep 17 00:00:00 2001 From: Atmos4 Date: Mon, 8 Apr 2024 12:16:25 +0200 Subject: [PATCH] 193: normalize accents in user list search --- assets/js/section-search.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/assets/js/section-search.js b/assets/js/section-search.js index 9cae78d5..17e2ae67 100644 --- a/assets/js/section-search.js +++ b/assets/js/section-search.js @@ -1,14 +1,21 @@ +function normalize(input) { + return input + .toUpperCase() + .normalize("NFD") + .replace(/[\u0300-\u036f\s]/gu, ""); +} + function searchSection(inputId, sectionId) { // Declare variables let input, filter, section, name_a, articles; input = document.getElementById(inputId); - filter = input.value.toUpperCase(); + filter = normalize(input.value); section = document.getElementById(sectionId); articles = section.getElementsByClassName("toggleWrapper"); for (i = 0; i < articles.length; i++) { name_a = articles[i].getElementsByTagName("a")[0]; txtValue = name_a.textContent || name_a.innerText; - if (txtValue.toUpperCase().indexOf(filter) > -1) { + if (normalize(txtValue).indexOf(filter) > -1) { articles[i].classList.remove("hidden"); } else { articles[i].classList.add("hidden");