endorsement/public/js/users.js
Maxime Bloch 0a570aa2c6
add some css to the mix
add search to userlist
2019-08-04 22:27:47 +02:00

27 lines
831 B
JavaScript

function searchUser(search) {
matches = [];
users.forEach(user => {
if (user.id.toLowerCase().includes(search.toLowerCase())) {
matches.push(user);
}
});
if (matches.length === 0) {
document.getElementById("users-parent").innerHTML = "<p>No matches found</p>";
} else {
var html = "";
matches.forEach(match => {
html += `
<a href="/users/${match.id}" class="tile is-child box is-4">
<!-- The magical tile element! -->
<p class="title">${ match.id }</p>
<div class="content">
${ match.achievements.length } achievement${(match.achievements.length != 1) ? "s" : "" }
</div>
</a>
`
});
document.getElementById("users-parent").innerHTML = html;
}
}