Skip to content

Commit

Permalink
Merge pull request #35 from Neofox/feature/search_bar_accent
Browse files Browse the repository at this point in the history
search bar now ignore case and can ignore accent
  • Loading branch information
Neofox authored Mar 22, 2019
2 parents 2b7c3a8 + 144c4bf commit 60be9ea
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions templates/child_list/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,20 @@
$('#searchInput').on('keyup', function (e) {
if ($('#searchInput').val() !== '') {
let searchTerm = $('#searchInput').val();
let searchTerm = $('#searchInput').val().toLowerCase();
let filteredChildren = $.grep(children, function (child) {
return child.firstname.includes(searchTerm) || child.lastname.includes(searchTerm);
const name = (child.firstname + ' ' + child.lastname).toLowerCase();
const normalizedname = name.normalize('NFD').replace(/[\u0300-\u036f]/g, "");
return name.includes(searchTerm) || normalizedname.includes(searchTerm);
});
$('#childrens').html(generateChildList(filteredChildren));
} else {
$('#childrens').html(generateChildList(children));
}
});
$('#childrens').html(generateChildList(children));
function generateChildList(children) {
return children.map((child) => {
let pathSheet = `/sheet/${child.id}/daily`;
Expand Down

0 comments on commit 60be9ea

Please sign in to comment.