feat: update language support and enhance API functionality
- Changed the default language in `index.html` from Russian to English, updating the title and button aria-labels for improved accessibility. - Refactored the `buildFetchOptions` function in `api.js` to include an optional external abort signal, enhancing request management. - Updated `fetchDuties` and `fetchCalendarEvents` to support request cancellation using the new abort signal, improving error handling. - Added unit tests for the API functions to ensure proper functionality, including handling of 403 errors and request cancellations. - Enhanced CSS styles for duty markers to improve visual consistency. - Removed unused code and improved the overall structure of the JavaScript files for better maintainability.
This commit is contained in:
@@ -10,7 +10,7 @@ import {
|
||||
firstDayOfMonth,
|
||||
lastDayOfMonth,
|
||||
dateKeyToDDMM,
|
||||
formatTimeLocal,
|
||||
formatHHMM,
|
||||
formatDateKey
|
||||
} from "./dateUtils.js";
|
||||
|
||||
@@ -25,8 +25,8 @@ export function dutyTimelineCardHtml(d, isCurrent) {
|
||||
const endLocal = localDateString(new Date(d.end_at));
|
||||
const startDDMM = dateKeyToDDMM(startLocal);
|
||||
const endDDMM = dateKeyToDDMM(endLocal);
|
||||
const startTime = formatTimeLocal(d.start_at);
|
||||
const endTime = formatTimeLocal(d.end_at);
|
||||
const startTime = formatHHMM(d.start_at);
|
||||
const endTime = formatHHMM(d.end_at);
|
||||
let timeStr;
|
||||
if (startLocal === endLocal) {
|
||||
timeStr = startDDMM + ", " + startTime + " – " + endTime;
|
||||
@@ -69,14 +69,14 @@ export function dutyItemHtml(d, typeLabelOverride, showUntilEnd, extraClass) {
|
||||
if (extraClass) itemClass += " " + extraClass;
|
||||
let timeOrRange = "";
|
||||
if (showUntilEnd && d.event_type === "duty") {
|
||||
timeOrRange = t(lang, "duty.until", { time: formatTimeLocal(d.end_at) });
|
||||
timeOrRange = t(lang, "duty.until", { time: formatHHMM(d.end_at) });
|
||||
} else if (d.event_type === "vacation" || d.event_type === "unavailable") {
|
||||
const startStr = formatDateKey(d.start_at);
|
||||
const endStr = formatDateKey(d.end_at);
|
||||
timeOrRange = startStr === endStr ? startStr : startStr + " – " + endStr;
|
||||
} else {
|
||||
timeOrRange =
|
||||
formatTimeLocal(d.start_at) + " – " + formatTimeLocal(d.end_at);
|
||||
formatHHMM(d.start_at) + " – " + formatHHMM(d.end_at);
|
||||
}
|
||||
return (
|
||||
'<div class="' +
|
||||
|
||||
Reference in New Issue
Block a user