diff options
Diffstat (limited to 'VegaData/wwwroot/index.js')
| -rw-r--r-- | VegaData/wwwroot/index.js | 24 |
1 files changed, 14 insertions, 10 deletions
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 |
