0a570aa2c6
add search to userlist
27 lines
831 B
JavaScript
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;
|
|
|
|
}
|
|
}
|