Skip to content

Commit

Permalink
save annotations & dark-mode states 2 localStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
rdavydov committed Oct 31, 2023
1 parent 66b7916 commit c0407ce
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions assets/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,24 @@ $(document).ready(function () {
if (!localStorage.getItem("dark-mode")) localStorage.setItem("dark-mode", true);
if (!localStorage.getItem("sort-by")) localStorage.setItem("sort-by", "Name ascending");

// Restore settings from localStorage on page load
$('#annotations').prop("checked", localStorage.getItem("annotations") === "true");
$('#dark-mode').prop("checked", localStorage.getItem("dark-mode") === "true");

// Handle the annotation toggle click event
$('#annotations').click(() => {
var isChecked = $('#annotations').prop("checked");
localStorage.setItem("annotations", isChecked);
updateAnnotations();
});

// Handle the dark mode toggle click event
$('#dark-mode').click(() => {
var isChecked = $('#dark-mode').prop("checked");
localStorage.setItem("dark-mode", isChecked);
toggleDarkMode();
});

$('#startDate').val(formatDate(startDate));
$('#endDate').val(formatDate(endDate));

Expand Down

0 comments on commit c0407ce

Please sign in to comment.