Update html/map.ejs
This commit is contained in:
parent
1b50ee4804
commit
5cd811369c
30
html/map.ejs
30
html/map.ejs
@ -774,7 +774,37 @@
|
|||||||
|
|
||||||
function tickCoords(){ updateCoordsFast(); setTimeout(tickCoords,120) } // fast enough, less CPU
|
function tickCoords(){ updateCoordsFast(); setTimeout(tickCoords,120) } // fast enough, less CPU
|
||||||
tickCoords();
|
tickCoords();
|
||||||
|
// Add a close (X) button inside the search bar
|
||||||
|
const searchBox = document.querySelector(".search");
|
||||||
|
if (searchBox) {
|
||||||
|
const closeBtn = document.createElement("button");
|
||||||
|
closeBtn.textContent = "✕";
|
||||||
|
closeBtn.className = "closebtn";
|
||||||
|
closeBtn.title = "Close search";
|
||||||
|
searchBox.appendChild(closeBtn);
|
||||||
|
|
||||||
|
closeBtn.addEventListener("click", () => {
|
||||||
|
const form = document.querySelector("#form");
|
||||||
|
const input = document.querySelector("#q");
|
||||||
|
const sugg = document.querySelector("#suggestions");
|
||||||
|
|
||||||
|
input.value = "";
|
||||||
|
sugg.style.display = "none";
|
||||||
|
form.style.display = "none"; // hides the search bar
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allow reopening search bar with `/` key
|
||||||
|
document.addEventListener("keydown", e => {
|
||||||
|
if (e.key === "/") {
|
||||||
|
const form = document.querySelector("#form");
|
||||||
|
if (form && form.style.display === "none") {
|
||||||
|
form.style.display = "block";
|
||||||
|
document.querySelector("#q").focus();
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
<script src="/static/data-mobile.js" defer></script>
|
<script src="/static/data-mobile.js" defer></script>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user