changes how daily percent is calculated to support more precision and quicker updates
This commit is contained in:
@@ -49,9 +49,9 @@
|
||||
const WORK_DAYS = config.workDays;
|
||||
const UPDATE_INTERVAL = config.updateInterval;
|
||||
|
||||
const TOTAL_WORK_MINUTES =
|
||||
(WORK_END_HOUR * 60 + WORK_END_MINUTE) -
|
||||
(WORK_START_HOUR * 60 + WORK_START_MINUTE);
|
||||
const TOTAL_WORK_SECONDS =
|
||||
(WORK_END_HOUR * 3600 + WORK_END_MINUTE * 60) -
|
||||
(WORK_START_HOUR * 3600 + WORK_START_MINUTE * 60);
|
||||
|
||||
const WEEKLY_DAY_WEIGHT = 100 / WORK_DAYS.length;
|
||||
|
||||
@@ -83,17 +83,18 @@
|
||||
dailyPercent = 100;
|
||||
statusText.textContent = "Workday complete 🎉";
|
||||
} else {
|
||||
const elapsedMinutes = Math.floor((now - start) / 60000);
|
||||
const elapsedSeconds = (now - start) / 1000;
|
||||
|
||||
dailyPercent = Math.min(
|
||||
(elapsedMinutes / TOTAL_WORK_MINUTES) * 100,
|
||||
100
|
||||
(elapsedSeconds / TOTAL_WORK_SECONDS) * 100,
|
||||
100
|
||||
);
|
||||
statusText.textContent = "Grinding…";
|
||||
}
|
||||
|
||||
// Daily progress
|
||||
dailyFill.style.width = dailyPercent + "%";
|
||||
dailyPercentText.textContent = dailyPercent.toFixed(1) + "%";
|
||||
dailyPercentText.textContent = dailyPercent.toFixed(4) + "%";
|
||||
|
||||
// Weekly progress
|
||||
const completedDays = WORK_DAYS.filter(d => d < day).length;
|
||||
@@ -104,7 +105,7 @@
|
||||
weeklyPercent = Math.min(weeklyPercent, 100);
|
||||
|
||||
weeklyFill.style.width = weeklyPercent + "%";
|
||||
weeklyPercentText.textContent = weeklyPercent.toFixed(1) + "%";
|
||||
weeklyPercentText.textContent = weeklyPercent.toFixed(4) + "%";
|
||||
}
|
||||
|
||||
updateProgress();
|
||||
|
||||
Reference in New Issue
Block a user