v0.38.10
This commit is contained in:
1 parent
38a23e2210
commit
45b1fc04c7
36 files changed
+9594
-7892
No files matched your search
@@ -103,6 +103,54 @@
|
||||
button.addEventListener("keydown", event => { const index = cacheTabs.indexOf(button); let next; if (event.key === "ArrowRight" || event.key === "ArrowDown") next = (index + 1) % cacheTabs.length; else if (event.key === "ArrowLeft" || event.key === "ArrowUp") next = (index + cacheTabs.length - 1) % cacheTabs.length; else if (event.key === "Home") next = 0; else if (event.key === "End") next = cacheTabs.length - 1; else return; event.preventDefault(); selectCacheTab(cacheTabs[next].dataset.cacheSettingsTab, true); });
|
||||
}
|
||||
selectCacheTab("general");
|
||||
const cacheGuideDialog = $("cache-vcl-guide-dialog");
|
||||
let guideEditor = null;
|
||||
let guideIsLocal = false;
|
||||
function openCacheGuide(trigger) {
|
||||
if (!cacheGuideDialog) return;
|
||||
// One guide serves the static global editor and both dynamic vhost editors.
|
||||
// Keep its destination tied to the button that opened it; never silently
|
||||
// insert a vhost example into global rules or vice versa.
|
||||
guideEditor = trigger?.closest(".cache-rules") || $("cache-rules-root")?.querySelector(".cache-rules") || null;
|
||||
guideIsLocal = guideEditor?.classList.contains("cache-rules-vhost") === true;
|
||||
const isDocker = guideIsLocal && !!guideEditor.closest(".docker-cache-editor");
|
||||
const compatible = $("cache-varnish-compatible").checked;
|
||||
const enabled = $("cache-enabled").checked;
|
||||
const ttl = Math.max(0, Number($("cache-default-ttl").value) || 0);
|
||||
const grace = Math.max(0, Number($("cache-varnish-grace").value) || 0);
|
||||
const mode = $("cache-guide-mode");
|
||||
mode.textContent = t(compatible ? "cacheGuideModeOn" : "cacheGuideModeOff");
|
||||
mode.classList.toggle("live", compatible);
|
||||
$("cache-guide-ttl").textContent = t("cacheGuideTtlStatus").replace("{seconds}", ttl);
|
||||
$("cache-guide-grace").textContent = t("cacheGuideGraceStatus").replace("{seconds}", grace);
|
||||
$("cache-guide-current-note").textContent = t(!enabled ? "cacheGuideCacheOffNote" : !compatible ? "cacheGuideRfcNote" : ttl > 0 ? "cacheGuideCompatNote" : "cacheGuideCompatZeroNote");
|
||||
$("cache-guide-context").textContent = t(isDocker ? "cacheGuideContextDocker" : guideIsLocal ? "cacheGuideContextVhost" : "cacheGuideContextGlobal");
|
||||
$("cache-guide-scope-note").textContent = t(isDocker ? "cacheGuideScopeDocker" : guideIsLocal ? "cacheGuideScopeVhost" : "cacheGuideScopeGlobal");
|
||||
if (!cacheGuideDialog.open) cacheGuideDialog.showModal();
|
||||
}
|
||||
// Event delegation is needed: the ordinary vhost dialog and the Docker
|
||||
// service editors are created after settings.js has registered its events.
|
||||
document.addEventListener("click", event => {
|
||||
const button = event.target.closest?.(".cache-guide-trigger");
|
||||
if (!button) return;
|
||||
event.preventDefault();
|
||||
openCacheGuide(button);
|
||||
});
|
||||
$("cache-vcl-guide-close")?.addEventListener("click", () => cacheGuideDialog.close());
|
||||
cacheGuideDialog?.querySelectorAll(".cache-guide-import-example").forEach(button => button.addEventListener("click", () => {
|
||||
const source = button.closest(".cache-guide-card")?.querySelector("pre code")?.textContent?.trim();
|
||||
const importer = guideEditor?.isConnected ? guideEditor.querySelector(".cache-rules-import") : null;
|
||||
const editor = importer?.querySelector("textarea");
|
||||
if (!source || !editor) { toast(t("cacheGuideImporterUnavailable"), true); return; }
|
||||
editor.value = [editor.value.trim(), source].filter(Boolean).join("\n\n");
|
||||
// Invalidates any pending partial-import preview from an older source.
|
||||
editor.dispatchEvent(new Event("input", { bubbles: true }));
|
||||
importer.hidden = false;
|
||||
cacheGuideDialog.close();
|
||||
if (!guideIsLocal) selectCacheTab("rules");
|
||||
importer.scrollIntoView({ block: "nearest", behavior: "smooth" });
|
||||
editor.focus({ preventScroll: true });
|
||||
}));
|
||||
const loggingTabs = [...document.querySelectorAll("[data-logging-settings-tab]")];
|
||||
function selectLoggingTab(name, focus = false) {
|
||||
if (!loggingTabs.some(button => button.dataset.loggingSettingsTab === name)) return;
|
||||
|
||||
Reference in new issue
Block a user