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:
@@ -2,13 +2,19 @@
|
||||
* 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) {
|
||||
const div = document.createElement("div");
|
||||
div.textContent = s;
|
||||
return div.innerHTML;
|
||||
return String(s).replace(/[&<>"']/g, (c) => ESCAPE_MAP[c]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user