improved searchBar functionality:
on page reload, it now displays the query fitting to the entered string
This commit is contained in:
@@ -41,16 +41,7 @@ searchButton.addEventListener("click", () => {
|
||||
});
|
||||
|
||||
searchBar.addEventListener("input", () => {
|
||||
if (searchBar.value === "") {
|
||||
searchSection.classList.add("hidden");
|
||||
recentSection.classList.remove("hidden");
|
||||
mostLikedSection.classList.remove("hidden");
|
||||
} else {
|
||||
searchSection.classList.remove("hidden");
|
||||
recentSection.classList.add("hidden");
|
||||
mostLikedSection.classList.add("hidden");
|
||||
}
|
||||
|
||||
updateSections();
|
||||
clearTimeout(searchBarTimeout);
|
||||
searchBarTimeout = setTimeout(() => {
|
||||
const searchString = searchBar.value;
|
||||
@@ -137,6 +128,21 @@ function incrementPageCount() {
|
||||
lastQuery.currentPage++;
|
||||
}
|
||||
|
||||
window.onload = function () {
|
||||
document.getElementById("search-entry").value = "";
|
||||
function updateSections() {
|
||||
if (searchBar.value === "") {
|
||||
searchSection.classList.add("hidden");
|
||||
recentSection.classList.remove("hidden");
|
||||
mostLikedSection.classList.remove("hidden");
|
||||
} else {
|
||||
searchSection.classList.remove("hidden");
|
||||
recentSection.classList.add("hidden");
|
||||
mostLikedSection.classList.add("hidden");
|
||||
}
|
||||
}
|
||||
|
||||
window.onload = function () {
|
||||
updateSections();
|
||||
if (searchBar.value !== "") {
|
||||
search(searchBar.value);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user