// Funkce pro přepnutí tématu document.addEventListener('DOMContentLoaded', function () { const themeToggle = document.getElementById('bd-theme'); const themeButtons = document.querySelectorAll('[data-bs-theme-value]'); const root = document.documentElement; // Nastavení aktuálního tématu function setTheme(theme) { root.setAttribute('data-bs-theme', theme); localStorage.setItem('theme', theme); // Uloží výběr do localStorage updateActiveButton(theme); } // Aktualizace aktivního tlačítka function updateActiveButton(theme) { themeButtons.forEach(button => { const isActive = button.getAttribute('data-bs-theme-value') === theme; button.setAttribute('aria-pressed', isActive); }); } // Načtení uloženého tématu (pokud existuje) const storedTheme = localStorage.getItem('theme') || 'auto'; setTheme(storedTheme); // Přidání události pro kliknutí na tlačítka themeButtons.forEach(button => { button.addEventListener('click', function () { const theme = this.getAttribute('data-bs-theme-value'); setTheme(theme); }); }); });