Skip to content

Commit

Permalink
Update clock.js
Browse files Browse the repository at this point in the history
  • Loading branch information
EuJinnLucaShow committed Dec 18, 2023
1 parent 83537db commit 0b6df24
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/js/clock.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ const setClock = () => {
sec.style.transform = `rotateZ(${ss}deg)`;
};

// first time
setClock();
// Update every 1000 ms
setInterval(setClock, 1000);

const switchTheme = (evt) => {
Expand All @@ -27,18 +25,18 @@ const switchTheme = (evt) => {
document.documentElement.setAttribute("data-theme", "dark");
} else {
switchBtn.textContent = "light";
localStorage.setItem("theme", "light"); //add this
localStorage.setItem("theme", "light");
document.documentElement.setAttribute("data-theme", "light");
}
};

const switchModeBtn = document.querySelector(".switch-btn");
switchModeBtn.addEventListener("click", switchTheme, false);
switchModeBtn.addEventListener("click", switchTheme);

let currentTheme = "dark";
let currentTheme = "light";
currentTheme = localStorage.getItem("theme")
? localStorage.getItem("theme")
: null;
: "light";

if (currentTheme) {
document.documentElement.setAttribute("data-theme", currentTheme);
Expand Down

0 comments on commit 0b6df24

Please sign in to comment.