Refactor web server and release workflow

This commit is contained in:
2026-07-14 18:35:24 +01:00
parent 9070ded66d
commit 4e0e87c86c
76 changed files with 616 additions and 84 deletions
+82
View File
@@ -0,0 +1,82 @@
(function () {
function dismissToast(toast) {
if (!toast) {
return;
}
toast.classList.add('toast-hide');
window.setTimeout(function () {
if (toast && toast.parentNode) {
toast.parentNode.removeChild(toast);
}
}, 220);
}
function showToast(message) {
var text = String(message || '').trim();
if (!text) {
return;
}
var existingToast = document.getElementById('app-toast');
var existingBody = existingToast ? existingToast.querySelector('.toast-body') : null;
if (existingToast && existingBody) {
existingBody.textContent = text;
existingToast.classList.remove('toast-hide');
window.clearTimeout(existingToast._dismissTimer);
existingToast._dismissTimer = window.setTimeout(function () {
dismissToast(existingToast);
}, 4000);
return;
}
var toast = document.createElement('div');
toast.className = 'toast';
toast.setAttribute('role', 'status');
toast.setAttribute('aria-live', 'polite');
toast.innerHTML = '<div class="toast-body"></div><button type="button" class="toast-close" aria-label="Dismiss notification">×</button>';
toast.querySelector('.toast-body').textContent = text;
var closeButton = toast.querySelector('.toast-close');
closeButton.addEventListener('click', function () {
dismissToast(toast);
});
document.body.appendChild(toast);
toast._dismissTimer = window.setTimeout(function () {
dismissToast(toast);
}, 4000);
}
function initToast() {
var toast = document.getElementById('app-toast');
var closeButton = document.getElementById('app-toast-close');
if (!toast || !closeButton) {
return;
}
try {
var url = new URL(window.location.href);
if (url.searchParams.has('message')) {
url.searchParams.delete('message');
window.history.replaceState({}, document.title, url.pathname + url.search + url.hash);
}
} catch (_error) {
// ignore URL cleanup failures
}
closeButton.addEventListener('click', function () {
dismissToast(toast);
});
window.setTimeout(function () {
dismissToast(toast);
}, 4000);
}
window.dismissToast = dismissToast;
window.showToast = showToast;
window.initToast = initToast;
initToast();
}());