From d0e78cca029cfd6b9a4da19bb903d09683b72bf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastjan=20Arti=C4=8D?= Date: Thu, 30 Apr 2026 15:17:16 +0000 Subject: [PATCH] Persist UI settings v localStorage (no-subs, station, mode, ...) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit User feedback: 'ko refrešam se ponovno vklopi kljukica da ni podnapisov to bo problem' Saved fields: - no-subs (checkbox) - auto-chorus (checkbox) - include-prebuild (checkbox) - mode (track/center/blur) - quality (fast/medium/high) - llm-provider (claude/gemini/auto) - tv-station (FOLX SLOVENIJA / ONE DE / ...) On page load: re-aplicira saved values On change: shrani v localStorage TV station: tudi posodobi aktiven tab style Defaults ostanejo isti če nikoli niso spremenjeni. --- templates/index.html | 45 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/templates/index.html b/templates/index.html index 342b9a3..ad5c042 100644 --- a/templates/index.html +++ b/templates/index.html @@ -692,8 +692,53 @@ btn.style.color = "#fff"; btn.style.borderColor = "var(--accent)"; $("#tv-station-input").value = btn.dataset.station; + // Persist + try { localStorage.setItem("reels_tv_station", btn.dataset.station); } catch(e) {} }); }); + + // ─── Settings persist v localStorage ───────────────────────── + // Da se ohranijo med page reload-i (no-subs, mode, quality, station, ...) + const PERSIST_FIELDS = [ + { id: "no-subs", type: "checkbox" }, + { id: "auto-chorus", type: "checkbox" }, + { id: "include-prebuild", type: "checkbox" }, + { id: "mode", type: "select" }, + { id: "quality", type: "select" }, + { id: "llm-provider", type: "select" }, + ]; + + // Load saved values na DOM ready + PERSIST_FIELDS.forEach(f => { + const el = document.getElementById(f.id); + if (!el) return; + const saved = localStorage.getItem("reels_" + f.id); + if (saved !== null) { + if (f.type === "checkbox") el.checked = saved === "true"; + else el.value = saved; + } + // Persist na vsako spremembo + el.addEventListener("change", () => { + try { + if (f.type === "checkbox") localStorage.setItem("reels_" + f.id, el.checked ? "true" : "false"); + else localStorage.setItem("reels_" + f.id, el.value); + } catch(e) {} + }); + }); + + // Saved TV station + const savedStation = localStorage.getItem("reels_tv_station"); + if (savedStation) { + $("#tv-station-input").value = savedStation; + // Aktiven gumb + document.querySelectorAll(".tv-tab").forEach(b => { + const isActive = b.dataset.station === savedStation; + b.classList.toggle("active", isActive); + b.style.background = isActive ? "var(--accent)" : "transparent"; + b.style.color = isActive ? "#fff" : "#ccc"; + b.style.borderColor = isActive ? "var(--accent)" : "#444"; + }); + } function parseTimestamp(s) { s = s.trim();