Commit 1334e812 authored by Jakob Moser's avatar Jakob Moser
Browse files

Remove code from index.html, instead refer to newly created JS file

parent bebf6dd7
Loading
Loading
Loading
Loading
+1 −53
Original line number Diff line number Diff line
@@ -63,59 +63,7 @@
            </div>
            <footer>
            </footer>
            <script>
                const services = [
                    { prefix: "", category: "public" },
                    { prefix: "tickets", category: "public" },
                    { prefix: "finanzen", category: "down" },
                    { prefix: "todo", category: "public" },
                    { prefix: "framadate", category: "public" },
                    { prefix: "automation", category: "auth" },
                    { prefix: "traefik", category: "auth" },
                    { prefix: "grafana", category: "down" },
                    { prefix: "planet", category: "down" }
                ]

                function createBadge(href, name, status, additionalClass) {
                    const a = document.createElement("a")
                    a.href = href
                    a.target = "_blank"
                    a.classList.add("badge")
                    if (additionalClass !== undefined) {
                        a.classList.add(additionalClass)
                    }

                    const nameEl = document.createElement("span")
                    nameEl.textContent = name

                    const statusEl = document.createElement("span")
                    statusEl.textContent = status

                    a.append(nameEl, statusEl)

                    return a
                }

                function getServiceUrl(servicePrefix) {
                    return `https://${getServiceHost(servicePrefix)}`
                }

                function getServiceHost(servicePrefix) {
                    const hostPrefix = servicePrefix !== "" ? `${servicePrefix}.` : ""
                    return `${hostPrefix}fachschaft.cl.uni-heidelberg.de`
                }

                function createStatusBadge(servicePrefix) {
                    const serviceUrl = getServiceUrl(servicePrefix)
                    return createBadge(serviceUrl, servicePrefix || "Website", "Up")
                }

                services.forEach(service => {
                    const p = document.createElement("p")
                    p.appendChild(createStatusBadge(service.prefix))
                    document.getElementById(service.category).appendChild(p)
                })
            </script>
            <script type="module" src="js/index.mjs"></script>
        </article>
    </main>
    <footer>