Skip to content

Commit

Permalink
fix: remember box height and scroll position
Browse files Browse the repository at this point in the history
  • Loading branch information
qx6ghqkz committed Dec 5, 2024
1 parent 79943c5 commit 22453cb
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,13 @@ <h1 class="display-4">gallery-dl</h1>
btn.innerText = "Hide Logs";
box.style.display = "inline";
loadBox();
localStorage.setItem("logs","shown");
localStorage.setItem("logs", "shown");
}
else {
saveBox();
btn.innerText = "Show Logs";
box.style.display = "none";
localStorage.setItem("logs","hidden");
localStorage.setItem("logs", "hidden");
}
}

Expand All @@ -262,9 +262,10 @@ <h1 class="display-4">gallery-dl</h1>
box.style.height = sessionStorage.getItem("boxHeight") + "px";
}
else {
box.scrollTop = box.scrollHeight;
box.style.height = "";
}
if ("scrollPos" in sessionStorage && sessionStorage.getItem("scrollPos") != "0") {

if ("scrollPos" in sessionStorage) {
box.scrollTop = sessionStorage.getItem("scrollPos");
}
else {
Expand All @@ -280,7 +281,9 @@ <h1 class="display-4">gallery-dl</h1>
}

window.onbeforeunload = function(event) {
saveBox();
if (localStorage.getItem("logs") == "shown") {
saveBox();
}
}
</script>
</body>
Expand Down

0 comments on commit 22453cb

Please sign in to comment.