This commit is contained in:
Mateusz Gruszczyński committed 2026-10-06 11:29:34 +02:00
1 parent cf25423dde
commit 52cc137c73
50 files changed
+410 -172

No files matched your search

+16
View File
@@ -174,6 +174,22 @@ function uptime(value) {
}
function rateBytes(value) { value = Math.max(0, Number(value) || 0); if (value === 0) return "0.0 KiB"; value /= 1024; for (const unit of ["KiB", "MiB", "GiB", "TiB"]) { if (value < 1024 || unit === "TiB") { if (unit === "KiB" && value < 0.1) return "<0.1 KiB"; const digits = value < 10 ? 1 : 0; return `${Number(value.toFixed(digits))} ${unit}`; } value /= 1024; } }
function el(tag, text, cls) { const e = document.createElement(tag); if (text !== undefined) e.textContent = text; if (cls) e.className = cls; return e; }
function enhanceEnabledControl(input, hintKey = "entityEnableHint") {
const label = input?.closest("label"); if (!label) return () => {};
label.classList.add("vh-enable-control", "vh-wide");
let hint = label.querySelector(".vh-enable-hint");
if (!hint) { hint = el("small", undefined, "vh-enable-hint"); label.append(hint); }
hint.dataset.i18n = hintKey; hint.textContent = t(hintKey);
let state = label.querySelector(".vh-enable-state");
if (!state) { state = el("strong", undefined, "vh-enable-state"); label.append(state); }
const sync = () => {
const key = input.checked ? "vhEnabled" : "vhDisabled";
label.classList.toggle("is-disabled", !input.checked); label.classList.toggle("is-enabled", input.checked);
state.dataset.i18n = key; state.textContent = t(key);
};
input.addEventListener("change", sync); sync(); return sync;
}
window.rustProxyEnableControl = enhanceEnabledControl;
function action(label, fn) { const b = el("button", label, "quiet"); b.type = "button"; b.addEventListener("click", fn); return b; }
function renderStatus(s) {
const firstStatus = latestStatus === null; latestStatus = s; window.rustProxySettings?.render(); if (firstStatus) renderSettings();