Compare commits

..

No commits in common. "ca6539923c84ae97ff31ac2811e9262cc514955f" and "21681ea96e33aaca189ff92ce518f58ef20f5907" have entirely different histories.

2 changed files with 63 additions and 0 deletions

29
public/js/building.js Normal file
View File

@ -0,0 +1,29 @@
fetch("/api/buildings")
.then((res) => {
if (!res.ok) {
throw new Error("API Fehler");
}
return res.json();
})
.then((buildings) => {
buildings.forEach((building) => {
const element = document.querySelector(
`.building[data-id="${building.id}"]`,
);
if (!element) return;
let title = element.querySelector("title");
if (!title) {
title = document.createElementNS("http://www.w3.org/2000/svg", "title");
element.prepend(title);
}
title.textContent = building.name;
});
})
.catch((error) => {
console.error("Buildings API Fehler:", error);
});
//test

34
public/js/buildings.js Normal file
View File

@ -0,0 +1,34 @@
const express = require("express");
const router = express.Router();
const auth = require("../middleware/auth");
/* ================================
Gebäude Seiten
================================ */
// Gebäude per ID — Weiterleitung zur Karte (Popup wird per JS geöffnet)
router.get("/building/:id", auth, (req, res) => {
res.redirect("/launcher");
});
router.get("/castle", auth, (req, res) => {
res.render("buildings/castle");
});
router.get("/market", auth, (req, res) => {
res.render("buildings/market");
});
router.get("/church", auth, (req, res) => {
res.render("buildings/church");
});
router.get("/portal", auth, (req, res) => {
res.render("buildings/portal");
});
router.get("/tower", auth, (req, res) => {
res.render("buildings/tower");
});
module.exports = router;