feat: added time to shift
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
<div class="vblock">
|
||||
<div class="hblock">
|
||||
<div class="next-break jetbrains-mono" id="nextBreak"></div>
|
||||
<div class="next-break secondary jetbrains-mono" id="shift1End"></div>
|
||||
<div class="next-break secondary jetbrains-mono" id="endOfDay"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+23
-2
@@ -17,7 +17,10 @@ const WEEKEND_BREAKS = [
|
||||
const WEEKDAY_END_OF_DAY = "23:00";
|
||||
const WEEKEND_END_OF_DAY = "22:00";
|
||||
|
||||
let clockEl, dateEl, nextBreakEl, endOfDayEl;
|
||||
const WEEKDAY_SHIFT1_END = "15:00";
|
||||
const WEEKEND_SHIFT1_END = "15:30";
|
||||
|
||||
let clockEl, dateEl, nextBreakEl, endOfDayEl, shift1EndEl;
|
||||
let breakNodes = [];
|
||||
let lastDayKey = "";
|
||||
|
||||
@@ -55,10 +58,19 @@ function getWorkDayEndForToday(now) {
|
||||
return day === 0 || day === 6 ? WEEKEND_END_OF_DAY : WEEKDAY_END_OF_DAY;
|
||||
}
|
||||
|
||||
function getShift1EndForToday(now) {
|
||||
const day = now.getDay();
|
||||
return day === 0 || day === 6 ? WEEKEND_SHIFT1_END : WEEKDAY_SHIFT1_END;
|
||||
}
|
||||
|
||||
function getEndOfDayMs(now) {
|
||||
return breakMsForToday(getWorkDayEndForToday(now), now);
|
||||
}
|
||||
|
||||
function getShift1EndMs(now) {
|
||||
return breakMsForToday(getShift1EndForToday(now), now);
|
||||
}
|
||||
|
||||
function formatDuration(ms) {
|
||||
const totalSeconds = Math.floor(ms / 1000);
|
||||
const h = Math.floor(totalSeconds / 3600);
|
||||
@@ -265,7 +277,13 @@ function updateNextBreak() {
|
||||
const endOfDayMs = getEndOfDayMs(now);
|
||||
const timeUntilEndOfDay = Math.max(0, endOfDayMs - now.getTime());
|
||||
endOfDayEl.textContent =
|
||||
"До конца работы · " + formatDuration(timeUntilEndOfDay);
|
||||
"До конца рабочего дня · " + formatDuration(timeUntilEndOfDay);
|
||||
|
||||
const shift1Ms = getShift1EndMs(now);
|
||||
const timeUntilShift1End = Math.max(0, shift1Ms - now.getTime());
|
||||
shift1EndEl.textContent =
|
||||
"До конца смены 1 (" + getShift1EndForToday(now) + ") · " +
|
||||
formatDuration(timeUntilShift1End);
|
||||
|
||||
scheduleNextBreakTick();
|
||||
}
|
||||
@@ -292,6 +310,7 @@ function init() {
|
||||
dateEl = document.getElementById("currentDate");
|
||||
nextBreakEl = document.getElementById("nextBreak");
|
||||
endOfDayEl = document.getElementById("endOfDay");
|
||||
shift1EndEl = document.getElementById("shift1End");
|
||||
|
||||
buildBreakBlocks();
|
||||
buildCalendar();
|
||||
@@ -314,7 +333,9 @@ if (typeof module !== "undefined" && module.exports) {
|
||||
module.exports = {
|
||||
getBreaksForToday,
|
||||
getWorkDayEndForToday,
|
||||
getShift1EndForToday,
|
||||
getEndOfDayMs,
|
||||
getShift1EndMs,
|
||||
breakTimeToMinutes,
|
||||
formatDuration,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user