- 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.
21 lines
380 B
JavaScript
21 lines
380 B
JavaScript
/**
|
|
* Common utilities.
|
|
*/
|
|
|
|
const ESCAPE_MAP = {
|
|
"&": "&",
|
|
"<": "<",
|
|
">": ">",
|
|
'"': """,
|
|
"'": "'",
|
|
};
|
|
|
|
/**
|
|
* Escape string for safe use in HTML (text content / attributes).
|
|
* @param {string} s - Raw string
|
|
* @returns {string} HTML-escaped string
|
|
*/
|
|
export function escapeHtml(s) {
|
|
return String(s).replace(/[&<>"']/g, (c) => ESCAPE_MAP[c]);
|
|
}
|