CI / Trivy (dependências, segredos e configuração) (push) Successful in 1m2s
CI / Testes e imagem Docker (linux/arm64) (push) Successful in 4m24s
Release / Plano (reaproveitar a imagem?) (push) Successful in 5s
Release / ci (push) Skipped
Release / Publica a imagem (linux/arm64) (push) Successful in 18s
Release / Cria a release no Gitea (push) Successful in 4s
Interface reescrita (design próprio, tema claro/escuro, a11y WCAG 2.2 AA), seções do site e artigo IDEIA @ CSBC 2025. Tradutor portado para JS com paridade 100% contra o Python; sem Tailwind nem axios. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
77 lines
2.7 KiB
JavaScript
77 lines
2.7 KiB
JavaScript
import { getTranslation } from './i18n.js';
|
||
|
||
const ICONS = {
|
||
info: "fa-circle-info",
|
||
warning: "fa-triangle-exclamation",
|
||
error: "fa-circle-xmark",
|
||
success: "fa-circle-check"
|
||
};
|
||
|
||
export function announce(msg) {
|
||
const el = document.getElementById("sr_status");
|
||
if (!el || !msg) return;
|
||
el.textContent = "";
|
||
setTimeout(() => { el.textContent = msg; }, 50);
|
||
}
|
||
|
||
export function showToast(message, severity = "info", duration = 6000) {
|
||
let container = document.getElementById("toast-container");
|
||
if (!container) {
|
||
container = document.createElement("div");
|
||
container.id = "toast-container";
|
||
container.setAttribute("aria-live", "polite");
|
||
document.body.appendChild(container);
|
||
}
|
||
duration = Math.max(duration, 6000);
|
||
|
||
const toast = document.createElement("div");
|
||
toast.className = `toast toast-${severity}`;
|
||
toast.setAttribute("role", severity === "error" ? "alert" : "status");
|
||
|
||
const icon = document.createElement("i");
|
||
icon.className = `fas ${ICONS[severity] || ICONS.info}`;
|
||
icon.setAttribute("aria-hidden", "true");
|
||
const text = document.createElement("span");
|
||
text.className = "toast__text";
|
||
text.textContent = message;
|
||
const close = document.createElement("button");
|
||
close.type = "button";
|
||
close.className = "toast__close";
|
||
close.setAttribute("aria-label", getTranslation("toast_close") || "Close");
|
||
close.innerHTML = '<span aria-hidden="true">×</span>';
|
||
toast.append(icon, text, close);
|
||
container.appendChild(toast);
|
||
|
||
requestAnimationFrame(() => toast.classList.add("show"));
|
||
|
||
let timer = null;
|
||
let removed = false;
|
||
const dismiss = () => {
|
||
if (removed) return;
|
||
removed = true;
|
||
clearTimeout(timer);
|
||
toast.classList.remove("show");
|
||
setTimeout(() => toast.remove(), 300);
|
||
};
|
||
const start = () => { clearTimeout(timer); timer = setTimeout(dismiss, duration); };
|
||
const pause = () => clearTimeout(timer);
|
||
toast.addEventListener("mouseenter", pause);
|
||
toast.addEventListener("mouseleave", start);
|
||
toast.addEventListener("focusin", pause);
|
||
toast.addEventListener("focusout", start);
|
||
close.addEventListener("click", dismiss);
|
||
start();
|
||
return toast;
|
||
}
|
||
|
||
export function highlightInput(inputTextbox) {
|
||
const container = inputTextbox.closest(".text-area-container") || inputTextbox;
|
||
inputTextbox.scrollIntoView({ behavior: "smooth", block: "center" });
|
||
inputTextbox.focus({ preventScroll: true });
|
||
|
||
container.classList.remove("input-attention");
|
||
void container.offsetWidth; // Force reflow
|
||
container.classList.add("input-attention");
|
||
setTimeout(() => container.classList.remove("input-attention"), 1900);
|
||
}
|