Files
duty-teller/webapp/js/dom.js
Nikolay Tatarinov 67ba9826c7 feat: unify language handling across the application
- Updated the language configuration to use a single source of truth from `DEFAULT_LANGUAGE` for the bot, API, and Mini App, eliminating auto-detection from user settings.
- Refactored the `get_lang` function to always return `DEFAULT_LANGUAGE`, ensuring consistent language usage throughout the application.
- Modified the handling of language in various components, including API responses and UI elements, to reflect the new language management approach.
- Enhanced documentation and comments to clarify the changes in language handling.
- Added unit tests to verify the new language handling behavior and ensure coverage for the updated functionality.
2026-03-02 23:05:28 +03:00

80 lines
2.1 KiB
JavaScript

/**
* DOM references and shared application state.
* Element refs are resolved lazily via getters so modules can be imported before DOM is ready.
*/
/** @returns {HTMLDivElement|null} */
export function getCalendarEl() {
return document.getElementById("calendar");
}
/** @returns {HTMLElement|null} */
export function getMonthTitleEl() {
return document.getElementById("monthTitle");
}
/** @returns {HTMLDivElement|null} */
export function getDutyListEl() {
return document.getElementById("dutyList");
}
/** @returns {HTMLElement|null} */
export function getLoadingEl() {
return document.getElementById("loading");
}
/** @returns {HTMLElement|null} */
export function getErrorEl() {
return document.getElementById("error");
}
/** @returns {HTMLElement|null} */
export function getAccessDeniedEl() {
return document.getElementById("accessDenied");
}
/** @returns {HTMLElement|null} */
export function getHeaderEl() {
return document.querySelector(".header");
}
/** @returns {HTMLElement|null} */
export function getWeekdaysEl() {
return document.querySelector(".weekdays");
}
/** @returns {HTMLButtonElement|null} */
export function getPrevBtn() {
return document.getElementById("prevMonth");
}
/** @returns {HTMLButtonElement|null} */
export function getNextBtn() {
return document.getElementById("nextMonth");
}
/** @returns {HTMLDivElement|null} */
export function getCurrentDutyViewEl() {
return document.getElementById("currentDutyView");
}
/** 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: "en",
/** 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
};