dok/public/js/building.js
2026-03-13 08:24:59 +00:00

22 lines
546 B
JavaScript

fetch("/api/buildings")
.then((res) => res.json())
.then((buildings) => {
buildings.forEach((building) => {
const element = document.querySelector(
`.building[data-id="${building.id}"]`,
);
if (!element) return;
let title = element.querySelector("title");
// Falls kein title existiert → erstellen
if (!title) {
title = document.createElementNS("http://www.w3.org/2000/svg", "title");
element.prepend(title);
}
title.textContent = building.name;
});
});