Files
duty-teller/webapp/js/dom.js
Nikolay Tatarinov a4d8d085c6 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.
2026-03-02 12:40:49 +03:00

54 lines
1.7 KiB
JavaScript

/**
* DOM references and shared application state.
*/
/** @type {HTMLDivElement|null} */
export const calendarEl = document.getElementById("calendar");
/** @type {HTMLElement|null} */
export const monthTitleEl = document.getElementById("monthTitle");
/** @type {HTMLDivElement|null} */
export const dutyListEl = document.getElementById("dutyList");
/** @type {HTMLElement|null} */
export const loadingEl = document.getElementById("loading");
/** @type {HTMLElement|null} */
export const errorEl = document.getElementById("error");
/** @type {HTMLElement|null} */
export const accessDeniedEl = document.getElementById("accessDenied");
/** @type {HTMLElement|null} */
export const headerEl = document.querySelector(".header");
/** @type {HTMLElement|null} */
export const weekdaysEl = document.querySelector(".weekdays");
/** @type {HTMLButtonElement|null} */
export const prevBtn = document.getElementById("prevMonth");
/** @type {HTMLButtonElement|null} */
export const nextBtn = document.getElementById("nextMonth");
/** Currently viewed month (mutable). */
export const state = {
/** @type {Date} */
current: new Date(),
/** @type {object[]} */
lastDutiesForList: [],
/** @type {ReturnType<typeof setInterval>|null} */
todayRefreshInterval: null,
/** @type {'ru'|'en'} */
lang: "ru",
/** One-time bind flag for sticky scroll shadow listener. */
stickyScrollBound: false,
/** One-time bind flag for calendar (info button) hint document listeners. */
calendarHintBound: false,
/** One-time bind flag for duty marker hint document listeners. */
dutyMarkerHintBound: false,
/** Whether initData retry after ACCESS_DENIED has been attempted. */
initDataRetried: false
};