Files
duty-teller/webapp/index.html
Nikolay Tatarinov 70b9050cb7 feat: improve error handling and logging in the web application
- Updated the error handling in `index.html` to include a retry button for failed app loads, enhancing user experience.
- Added session storage management to prevent repeated reloads on errors.
- Enhanced the `.gitignore` file to include log files, improving project cleanliness.
- Included error logging in `main.js` to ensure better tracking of issues during app initialization.
2026-03-03 00:10:30 +03:00

119 lines
4.9 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title></title>
<link rel="stylesheet" href="css/base.css">
<link rel="stylesheet" href="css/calendar.css">
<link rel="stylesheet" href="css/day-detail.css">
<link rel="stylesheet" href="css/hints.css">
<link rel="stylesheet" href="css/markers.css">
<link rel="stylesheet" href="css/duty-list.css">
<link rel="stylesheet" href="css/states.css">
</head>
<body>
<div class="container">
<div class="calendar-sticky" id="calendarSticky">
<header class="header">
<button type="button" class="nav nav--prev" id="prevMonth" aria-label="">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="15 18 9 12 15 6"/></svg>
</button>
<h1 class="title" id="monthTitle"></h1>
<button type="button" class="nav nav--next" id="nextMonth" aria-label="">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="9 18 15 12 9 6"/></svg>
</button>
</header>
<div class="weekdays">
<span></span><span></span><span></span><span></span><span></span><span></span><span></span>
</div>
<div class="calendar" id="calendar"></div>
</div>
<div class="duty-list" id="dutyList"></div>
<div class="loading" id="loading"><span class="loading__spinner" aria-hidden="true"></span><span class="loading__text"></span></div>
<div class="error" id="error" hidden></div>
<div class="access-denied" id="accessDenied" hidden></div>
<div id="currentDutyView" class="current-duty-view hidden"></div>
</div>
<script src="https://telegram.org/js/telegram-web-app.js"></script>
<script>
if (window.Telegram && window.Telegram.WebApp && window.Telegram.WebApp.ready) {
window.Telegram.WebApp.ready();
}
</script>
<script src="/app/config.js"></script>
<script type="importmap">
{
"scopes": {
"./js/": {
"./js/api.js": "./js/api.js?v=3",
"./js/auth.js": "./js/auth.js?v=3",
"./js/calendar.js": "./js/calendar.js?v=2",
"./js/constants.js": "./js/constants.js?v=2",
"./js/contactHtml.js": "./js/contactHtml.js?v=2",
"./js/currentDuty.js": "./js/currentDuty.js?v=2",
"./js/dateUtils.js": "./js/dateUtils.js?v=2",
"./js/dayDetail.js": "./js/dayDetail.js?v=2",
"./js/dom.js": "./js/dom.js?v=3",
"./js/dutyList.js": "./js/dutyList.js?v=2",
"./js/hints.js": "./js/hints.js?v=2",
"./js/i18n.js": "./js/i18n.js?v=3",
"./js/logger.js": "./js/logger.js?v=1",
"./js/theme.js": "./js/theme.js?v=2",
"./js/ui.js": "./js/ui.js?v=2",
"./js/utils.js": "./js/utils.js?v=2"
}
}
}
</script>
<script type="module" src="js/main.js?v=5" id="main-module"></script>
<script>
(function() {
var loadTimeout = 10000;
var mainScript = document.getElementById("main-module");
if (mainScript) {
mainScript.addEventListener("error", function() {
var retryKey = "__dtLoadRetry";
try {
if (!sessionStorage.getItem(retryKey)) {
sessionStorage.setItem(retryKey, "1");
location.reload();
return;
}
sessionStorage.removeItem(retryKey);
} catch (_) {}
var loading = document.getElementById("loading");
if (loading && !loading.classList.contains("hidden")) {
loading.classList.add("hidden");
}
var err = document.getElementById("error");
if (err) {
err.hidden = false;
err.textContent = "";
err.appendChild(document.createTextNode("Failed to load app. Check connection and try again. "));
var retryBtn = document.createElement("button");
retryBtn.type = "button";
retryBtn.className = "error-retry";
retryBtn.textContent = "Retry";
retryBtn.addEventListener("click", function() { location.reload(); });
err.appendChild(retryBtn);
}
});
}
setTimeout(function() {
if (window.__dtReady) return;
var loading = document.getElementById("loading");
if (loading && !loading.classList.contains("hidden")) {
loading.classList.add("hidden");
var err = document.getElementById("error");
if (err) {
err.hidden = false;
err.textContent = "App is taking too long to load. Check your connection and refresh.";
}
}
}, loadTimeout);
})();
</script>
</body>
</html>