From 9448868357415f63c382e32a0777c0cad1c9be30 Mon Sep 17 00:00:00 2001 From: ivar Date: Wed, 8 Oct 2025 10:57:18 +0200 Subject: n --- VegaData/wwwroot/index.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'VegaData/wwwroot') diff --git a/VegaData/wwwroot/index.js b/VegaData/wwwroot/index.js index cad938d..8ce5c62 100644 --- a/VegaData/wwwroot/index.js +++ b/VegaData/wwwroot/index.js @@ -62,7 +62,7 @@ function urlId(e) { return `${e.movieVersion}${e.startDateTime}`.replaceAll("-", "").replaceAll(" ", "").replaceAll(":", "") } -async function renderShows(query = search.value) { +async function renderShows(query, rendered) { query = query?.trim(); sqp({ q: query ?? "" }) @@ -126,19 +126,23 @@ async function renderShows(query = search.value) { if (!lis.length) ulShows.replaceChildren(...[t("i", undefined, "Dessverre")]) else ulShows.replaceChildren(...lis); + const interval = setInterval(() => { + const element = document.querySelector("#ulShows"); + if (element.childNodes.length > 0) { + clearInterval(interval); + rendered(); + } + }, 50); } -document.addEventListener("DOMContentLoaded", () => { +renderShows(search.value, () => { if (gqp("q")) search.value = gqp("q") search.addEventListener("input", e => renderShows(e.currentTarget.value)); - renderShows(); const id = location.href.indexOf("#") !== -1 ? location.href.substring(location.href.indexOf("#")) : "" - document.querySelectorAll(".time").forEach(el => el.classList.remove("activeShow")) if (id !== "") { - setTimeout(() => { - const target = document.querySelector(id) - target.scrollIntoView({ behavior: "smooth", block: "center" }) - target.classList.add("activeShow") - }, 50) + const target = document.querySelector(id) + target.scrollIntoView({ behavior: "smooth", block: "center" }) + target.classList.add("activeShow") + document.querySelectorAll(".time").forEach(el => el.id !== id.slice(1) && el.classList.remove("activeShow")) } -}) +}); \ No newline at end of file -- cgit v1.3