first commit
This commit is contained in:
28
js/search.js
Normal file
28
js/search.js
Normal file
@ -0,0 +1,28 @@
|
||||
function searchGames() {
|
||||
search = 1;
|
||||
var txt = $("#gamesearch").val();
|
||||
if (txt == "") {
|
||||
$("#games .suggest").show();
|
||||
} else {
|
||||
$("#games .suggest").hide();
|
||||
}
|
||||
$("#games .game").hide();
|
||||
$("#games .game").each(function () {
|
||||
if ($(this).text().toUpperCase().indexOf(txt.toUpperCase()) != -1 || $(this).attr("id").toUpperCase().indexOf(txt.toUpperCase()) != -1) {
|
||||
$(this).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
let urlParams = new URLSearchParams(window.location.search);
|
||||
let q = urlParams.get("q");
|
||||
if (q) {
|
||||
document.getElementById("gamesearch").value = q;
|
||||
searchGames();
|
||||
urlParams.delete("q");
|
||||
window.history.replaceState({}, document.title, location.pathname);
|
||||
}
|
||||
document.getElementById("gamesearch").addEventListener("input", () => {
|
||||
searchGames();
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user