changes how daily percent is calculated to support more precision and quicker updates

This commit is contained in:
2026-01-12 21:30:11 -05:00
parent 936ce2fc96
commit bcf994ab7b

View File

@@ -49,9 +49,9 @@
const WORK_DAYS = config.workDays; const WORK_DAYS = config.workDays;
const UPDATE_INTERVAL = config.updateInterval; const UPDATE_INTERVAL = config.updateInterval;
const TOTAL_WORK_MINUTES = const TOTAL_WORK_SECONDS =
(WORK_END_HOUR * 60 + WORK_END_MINUTE) - (WORK_END_HOUR * 3600 + WORK_END_MINUTE * 60) -
(WORK_START_HOUR * 60 + WORK_START_MINUTE); (WORK_START_HOUR * 3600 + WORK_START_MINUTE * 60);
const WEEKLY_DAY_WEIGHT = 100 / WORK_DAYS.length; const WEEKLY_DAY_WEIGHT = 100 / WORK_DAYS.length;
@@ -83,9 +83,10 @@
dailyPercent = 100; dailyPercent = 100;
statusText.textContent = "Workday complete 🎉"; statusText.textContent = "Workday complete 🎉";
} else { } else {
const elapsedMinutes = Math.floor((now - start) / 60000); const elapsedSeconds = (now - start) / 1000;
dailyPercent = Math.min( dailyPercent = Math.min(
(elapsedMinutes / TOTAL_WORK_MINUTES) * 100, (elapsedSeconds / TOTAL_WORK_SECONDS) * 100,
100 100
); );
statusText.textContent = "Grinding…"; statusText.textContent = "Grinding…";
@@ -93,7 +94,7 @@
// Daily progress // Daily progress
dailyFill.style.width = dailyPercent + "%"; dailyFill.style.width = dailyPercent + "%";
dailyPercentText.textContent = dailyPercent.toFixed(1) + "%"; dailyPercentText.textContent = dailyPercent.toFixed(4) + "%";
// Weekly progress // Weekly progress
const completedDays = WORK_DAYS.filter(d => d < day).length; const completedDays = WORK_DAYS.filter(d => d < day).length;
@@ -104,7 +105,7 @@
weeklyPercent = Math.min(weeklyPercent, 100); weeklyPercent = Math.min(weeklyPercent, 100);
weeklyFill.style.width = weeklyPercent + "%"; weeklyFill.style.width = weeklyPercent + "%";
weeklyPercentText.textContent = weeklyPercent.toFixed(1) + "%"; weeklyPercentText.textContent = weeklyPercent.toFixed(4) + "%";
} }
updateProgress(); updateProgress();