style: enhance layout and functionality of duty markers and calendar
- Updated CSS for `.day` and `.access-denied` to improve layout and visual consistency. - Introduced a new function `dutyOverlapsLocalRange` in `dateUtils.js` to check duty overlaps within a specified date range. - Refactored `dutyItemHtml` in `dutyList.js` to utilize `formatTimeLocal` for time formatting, enhancing readability. - Added utility functions in `hints.js` for parsing duty marker data and building time prefixes, streamlining hint rendering logic. - Improved the `showAccessDenied` function in `ui.js` to display detailed server messages when access is denied.
This commit is contained in:
@@ -26,7 +26,8 @@ import {
|
||||
firstDayOfMonth,
|
||||
lastDayOfMonth,
|
||||
getMonday,
|
||||
localDateString
|
||||
localDateString,
|
||||
dutyOverlapsLocalRange
|
||||
} from "./dateUtils.js";
|
||||
|
||||
initTheme();
|
||||
@@ -113,12 +114,9 @@ async function loadMonth() {
|
||||
const last = lastDayOfMonth(current);
|
||||
const firstKey = localDateString(first);
|
||||
const lastKey = localDateString(last);
|
||||
const dutiesInMonth = duties.filter((d) => {
|
||||
const byDateLocal = dutiesByDate([d]);
|
||||
return Object.keys(byDateLocal).some(
|
||||
(key) => key >= firstKey && key <= lastKey
|
||||
);
|
||||
});
|
||||
const dutiesInMonth = duties.filter((d) =>
|
||||
dutyOverlapsLocalRange(d, firstKey, lastKey)
|
||||
);
|
||||
state.lastDutiesForList = dutiesInMonth;
|
||||
renderDutyList(dutiesInMonth);
|
||||
if (state.todayRefreshInterval) {
|
||||
@@ -197,16 +195,17 @@ if (nextBtn) {
|
||||
(e) => {
|
||||
if (e.changedTouches.length === 0) return;
|
||||
if (accessDeniedEl && !accessDeniedEl.hidden) return;
|
||||
if (prevBtn && prevBtn.disabled) return;
|
||||
const t = e.changedTouches[0];
|
||||
const deltaX = t.clientX - startX;
|
||||
const deltaY = t.clientY - startY;
|
||||
if (Math.abs(deltaX) <= SWIPE_THRESHOLD) return;
|
||||
if (Math.abs(deltaY) > Math.abs(deltaX)) return;
|
||||
if (deltaX > SWIPE_THRESHOLD) {
|
||||
if (prevBtn && prevBtn.disabled) return;
|
||||
state.current.setMonth(state.current.getMonth() - 1);
|
||||
loadMonth();
|
||||
} else if (deltaX < -SWIPE_THRESHOLD) {
|
||||
if (nextBtn && nextBtn.disabled) return;
|
||||
state.current.setMonth(state.current.getMonth() + 1);
|
||||
loadMonth();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user