document.addEventListener("DOMContentLoaded", async () => { clearDNSCache() await refreshAll() setInterval(refreshAll, 60000) }) let refreshing = false async function refreshAll(){ if(refreshing) return refreshing = true try{ await loadResources() await loadDomains() await loadMapping() await loadCancelled() loadInfrastructure() loadCosts() // Zeit setzen updateLastUpdate() }catch(e){ console.error("Refresh error", e) document.getElementById("lastUpdate").innerText = "🔴 Fehler beim Update" } refreshing = false } function clearDNSCache(){ for(const key in dnsCache){ delete dnsCache[key] } } function updateLastUpdate(){ const now = new Date() const time = now.toLocaleTimeString() // Lade-Indikator document.getElementById("lastUpdate").innerText = "🟢 Letztes Update: " + time } window.toggleDarkMode = function(){ document.body.classList.toggle("dark") localStorage.setItem( "darkmode", document.body.classList.contains("dark") ) } // beim Start laden document.addEventListener("DOMContentLoaded", () => { if(localStorage.getItem("darkmode") === "true"){ document.body.classList.add("dark") } }) function showError(msg) { const div = document.createElement("div") div.innerText = msg div.style.position = "fixed" div.style.bottom = "20px" div.style.right = "20px" div.style.background = "#dc2626" div.style.color = "white" div.style.padding = "10px 15px" div.style.borderRadius = "6px" div.style.zIndex = 9999 document.body.appendChild(div) setTimeout(() => { div.remove() }, 3000) }