Skip to content

Commit adbb89f

Browse files
committed
Update full_ppl_b821cc04426d8c54bded02406e5a5ef5.md
1 parent 1eb8c51 commit adbb89f

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

full_ppl_b821cc04426d8c54bded02406e5a5ef5.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,17 @@ document.addEventListener('DOMContentLoaded', (event) => {
5151
const table = document.querySelector('table');
5252
const rows = table.querySelectorAll('tr');
5353

54+
function removeAccents(str) {
55+
return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
56+
}
57+
5458
function performSearch() {
55-
const searchTerm = searchInput.value.toLowerCase();
59+
const searchTerm = removeAccents(searchInput.value.toLowerCase());
5660

5761
rows.forEach((row, index) => {
5862
if (index === 0) return; // Skip header row
5963

60-
const name = row.cells[0].textContent.toLowerCase();
64+
const name = removeAccents(row.cells[0].textContent.toLowerCase());
6165
const uvaId = row.cells[1].textContent.toLowerCase();
6266

6367
if (name.includes(searchTerm) || uvaId.includes(searchTerm)) {
@@ -73,10 +77,19 @@ document.addEventListener('DOMContentLoaded', (event) => {
7377
[0, 1].forEach(cellIndex => {
7478
const cell = row.cells[cellIndex];
7579
const originalText = cell.textContent;
76-
const highlightedText = originalText.replace(
77-
new RegExp(searchTerm, 'gi'),
78-
match => `<span class="highlight">${match}</span>`
79-
);
80+
const normalizedText = removeAccents(originalText);
81+
let highlightedText = '';
82+
let lastIndex = 0;
83+
84+
const regex = new RegExp(searchTerm, 'gi');
85+
let match;
86+
while ((match = regex.exec(normalizedText)) !== null) {
87+
highlightedText += originalText.slice(lastIndex, match.index);
88+
highlightedText += `<span class="highlight">${originalText.slice(match.index, match.index + match[0].length)}</span>`;
89+
lastIndex = match.index + match[0].length;
90+
}
91+
highlightedText += originalText.slice(lastIndex);
92+
8093
cell.innerHTML = highlightedText;
8194
});
8295
}

0 commit comments

Comments
 (0)