Skip to content

Commit

Permalink
reset the counter each day
Browse files Browse the repository at this point in the history
  • Loading branch information
najmiter authored Feb 10, 2024
1 parent e53660e commit 1d26e72
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,23 @@ fetch("tasbih.json")
.then((tasbihaat) => {
const today = new Date();
const day = today.getDay();
const day_name = tasbihaat[day].day;

const old =
localStorage.getItem("today") ??
localStorage.setItem("today", day_name);

let counter_count =
old && old !== day_name ? 0 : +localStorage.getItem("counter") ?? 0;

let counter_count = +localStorage.getItem("counter") ?? 0;
const target = 100;

const qalma = document.getElementById("qalma");
const greeting = document.getElementById("greeting");
const counter_text = document.getElementById("counter-text");
const loop = document.getElementById("loop");

qalma.setAttribute("src", `imgs/${tasbihaat[day].day}.svg`);
qalma.setAttribute("src", `imgs/${day_name}.svg`);
greeting.textContent = `Target: ${target}`;
counter_text.textContent = counter_count;
loop.textContent = `Loop: ${localStorage.getItem("loop") ?? 0}`;
Expand Down

0 comments on commit 1d26e72

Please sign in to comment.