var ueberschrift = document.querySelector('h1'); if(!localStorage.getItem('erstesmal')) { localStorage.setItem('erstesmal', 'da'); } else { var myArray = ['Herzlich willkommen zurück!', 'Schön, dass du wieder da bist!', ' Toll, du bist wieder da!', 'Sei gegrüßt, Freund!', 'Du bist immer willkommen!']; var rand = Math.floor(Math.random()*myArray.length); var rValue = myArray[rand]; ueberschrift.textContent = rValue; } document.addEventListener('DOMContentLoaded', function () { const toggle = document.getElementById('toggle-input'); function updateUI(theme) { toggle.checked = theme === 'light'; } toggle.addEventListener('click', () => { const theme = toggle.checked ? 'light' : 'dark'; setTheme(theme, true); updateUI(theme); }); const osPreference = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'; const preferredTheme = localStorage.getItem('preferred-theme') || osPreference; setTheme(preferredTheme, false); updateUI(preferredTheme); function setTheme(theme, persist = false) { const on = theme; const off = theme === 'light' ? 'dark' : 'light' const htmlEl = document.documentElement; htmlEl.classList.add(on); htmlEl.classList.remove(off); if (persist) { localStorage.setItem('preferred-theme', theme); } } }); function myFunction() { var x = document.getElementById("myLinks"); if (x.style.display === "block") { x.style.display = "none"; } else { x.style.display = "block"; } }