Skip to content

Commit ba18742

Browse files
committed
add better esearch
Signed-off-by: Leonid Petrov <[email protected]>
1 parent e27444f commit ba18742

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

css/people-search.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ document.addEventListener('DOMContentLoaded', function() {
66

77
let activeCategory = 'all';
88

9+
// Normalize text by removing diacritics for search
10+
function normalizeText(text) {
11+
return text.normalize('NFD').replace(/[\u0300-\u036f]/g, '').toLowerCase();
12+
}
13+
914
// Highlight matching text
1015
function highlightText(element, searchTerm) {
1116
if (!searchTerm) return;
@@ -109,6 +114,7 @@ document.addEventListener('DOMContentLoaded', function() {
109114
row.dataset.personName = fullName.toLowerCase();
110115
row.dataset.personCategory = category;
111116
row.dataset.searchData = `${uvaId} ${fullName} ${position} ${specialty} ${office} ${email} ${phone} ${officeHours} ${researchTags}`.toLowerCase();
117+
row.dataset.searchDataNormalized = normalizeText(`${uvaId} ${fullName} ${position} ${specialty} ${office} ${email} ${phone} ${officeHours} ${researchTags}`);
112118
});
113119
});
114120
}
@@ -139,14 +145,16 @@ document.addEventListener('DOMContentLoaded', function() {
139145
matchesSearch = true;
140146
} else {
141147
const searchData = row.dataset.searchData;
148+
const searchDataNormalized = row.dataset.searchDataNormalized;
142149

143150
// Smart case matching
144151
if (originalSearchTerm !== originalSearchTerm.toLowerCase()) {
145152
// Contains uppercase letters - case sensitive search
146153
matchesSearch = row.textContent.includes(originalSearchTerm);
147154
} else {
148-
// All lowercase - case insensitive search
149-
matchesSearch = searchData.includes(searchTerm);
155+
// All lowercase - case insensitive search with diacritic normalization
156+
const normalizedSearchTerm = normalizeText(searchTerm);
157+
matchesSearch = searchData.includes(searchTerm) || searchDataNormalized.includes(normalizedSearchTerm);
150158
}
151159
}
152160

0 commit comments

Comments
 (0)