This commit is contained in:
Mateusz Gruszczyński committed 2026-11-16 13:46:24 +01:00
1 parent 2d0d0f12c7
commit 963ec64398
11 files changed
+114 -28

No files matched your search

+12
View File
@@ -30,6 +30,17 @@ let adminAuthChannel = null; try { adminAuthChannel = new BroadcastChannel("rust
let languagePacks = new Map(), defaultLanguage = null;
function activePack() { return languagePacks.get(language) || languagePacks.get(defaultLanguage); }
function locale() { try { return Intl.getCanonicalLocales(activePack()?.meta.locale || "und")[0]; } catch { return "und"; } }
// Sorting calls a comparator O(n log n) times; String#localeCompare with a
// locale/options argument builds a new collator on every call, which made
// periodic table re-renders slow. Collators are cached per language.
const textCollators = new Map();
function textCollator(numeric = true) {
const key = `${activePack()?.meta.locale || "und"}|${numeric}`;
let collator = textCollators.get(key);
if (!collator) { collator = new Intl.Collator(locale(), numeric ? { numeric: true, sensitivity: "base" } : { sensitivity: "base" }); textCollators.set(key, collator); }
return collator;
}
function compareText(a, b, numeric = true) { return textCollator(numeric).compare(String(a), String(b)); }
function t(key) { const pack = activePack()?.translations; const fallback = languagePacks.get(defaultLanguage)?.translations; return (pack && Object.hasOwn(pack, key) ? pack[key] : fallback?.[key]) ?? key; }
async function loadLanguages() {
const bundle = await api("/assets/langs.json");
@@ -170,6 +181,7 @@ function setPanel(name, navigate = true) {
if (name === "web-server" && latestStatus) window.rustProxyWebServer?.renderLive?.(latestStatus, false);
if (name === "settings") window.rustProxySettings?.syncLocation?.();
window.rustProxyRefresh?.setPanel(name);
if (name === "overview") window.rustProxyVhosts?.flushOverviewViews?.();
if (name === "overview" && previousPanel !== name && typeof latestStatus !== "undefined" && latestStatus) { window.rustProxyStreamDashboard?.render?.(latestStatus, null, false); window.rustProxyDockerDashboard?.render?.(latestStatus, null, false); window.rustProxyBackendDashboard?.render?.(latestStatus, null, false); window.rustProxyExtraOverview?.render?.(latestStatus, false); window.rustProxyWideOverview?.render?.(latestStatus, false); window.rustProxyWebOverview?.render?.(latestStatus, false); }
if (name === "docker-vhosts" && previousPanel !== name && authenticated && envelope) void window.rustProxyRefresh?.manual("docker");
if (name === "tls") window.rustProxyAcme?.syncLocation?.();