Skip to content

Commit

Permalink
193: normalize accents in user list search
Browse files Browse the repository at this point in the history
  • Loading branch information
Atmos4 committed Apr 8, 2024
1 parent f02062d commit b067fcc
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions assets/js/section-search.js
Original file line number Diff line number Diff line change
@@ -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");
Expand Down

0 comments on commit b067fcc

Please sign in to comment.