This commit is contained in:
cay 2026-04-10 07:07:07 +01:00
parent ba952fe607
commit 0100b5b7ed

View File

@ -247,13 +247,13 @@ document.querySelector(".popup-close").onclick = () => {
document.querySelectorAll(".building").forEach((building) => {
building.addEventListener("mouseenter", async (e) => {
try {
const id = building.dataset.id;
// data-id bevorzugen, sonst ID aus href extrahieren (z.B. "/building/5" → "5")
const id = building.dataset.id || building.getAttribute("href")?.split("/").pop();
if (!id) return;
if (!tooltipCache[id]) {
const res = await fetch("/api/building/" + id);
if (!res.ok) throw new Error("API Fehler");
tooltipCache[id] = await res.json();
}