From 2073d5dcf7d00e2fca3bcf5579ef898cb33bed86 Mon Sep 17 00:00:00 2001 From: Mehdi Chaid Date: Thu, 14 May 2026 14:09:23 -0400 Subject: [PATCH] fix: move block-scoped declarations to function scope in edit overlay --- web/flake-modal.js | 62 +++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/web/flake-modal.js b/web/flake-modal.js index 08e6dda..8e80574 100644 --- a/web/flake-modal.js +++ b/web/flake-modal.js @@ -74,6 +74,37 @@ export function openEditModal({ mode, name, data, dirs, family = "SDXL/Base" }) } // ---- Base + Flake type on same row ---- + let currentRootPath = ""; + let rootsCache = []; + let resolvedPathLabel = null; + + function getOutputPrefix() { + const folder = familyFolder(currentFamily); + return folder ? `img/${folder}/` : "img/"; + } + + function stripOutputPrefix(val) { + if (!val) return val; + const prefixes = ["img/sdxl/", "img/illustrious/", "img/pony/", "img/zib/", "img/zit/", "img/common/", "img/"]; + for (const p of prefixes) { + if (val.toLowerCase().startsWith(p)) return val.slice(p.length); + } + return val; + } + + function updateResolvedPath() { + if (!resolvedPathLabel) return; + const raw = (pathInput?.value || "").trim(); + if (!raw) { + resolvedPathLabel.textContent = ""; + return; + } + const rootPart = currentRootPath ? currentRootPath : "C://models/flakes/"; + const prefix = getOutputPrefix(); + const fullPath = `${rootPart}${prefix}${raw}.yaml`.replace(/\/\//g, "/"); + resolvedPathLabel.textContent = fullPath; + } + if (mode !== "default") { const typeRow = document.createElement("div"); css(typeRow, "display:flex;gap:8px;align-items:flex-start;"); @@ -131,37 +162,6 @@ export function openEditModal({ mode, name, data, dirs, family = "SDXL/Base" }) pathInput = makeComfyInput("", "characters/musashi"); pathRow.appendChild(pathInput); - let currentRootPath = ""; - let rootsCache = []; - let resolvedPathLabel = null; - - function getOutputPrefix() { - const folder = familyFolder(currentFamily); - return folder ? `img/${folder}/` : "img/"; - } - - function stripOutputPrefix(val) { - if (!val) return val; - const prefixes = ["img/sdxl/", "img/illustrious/", "img/pony/", "img/zib/", "img/zit/", "img/common/", "img/"]; - for (const p of prefixes) { - if (val.toLowerCase().startsWith(p)) return val.slice(p.length); - } - return val; - } - - function updateResolvedPath() { - if (!resolvedPathLabel) return; - const raw = (pathInput?.value || "").trim(); - if (!raw) { - resolvedPathLabel.textContent = ""; - return; - } - const rootPart = currentRootPath ? currentRootPath : "C://models/flakes/"; - const prefix = getOutputPrefix(); - const fullPath = `${rootPart}${prefix}${raw}.yaml`.replace(/\/\//g, "/"); - resolvedPathLabel.textContent = fullPath; - } - (async () => { try { const r = await fetch("/flakes/roots?type=flakes");