document.addEventListener('DOMContentLoaded', () => { const themeToggleBtn = document.getElementById('theme-toggle-btn'); const body = document.body; // Ellenőrizzük, hogy van-e tárolt beállítás a localStorage-ban const savedTheme = localStorage.getItem('theme'); // Alkalmazzuk a tárolt beállítást, ha van if (savedTheme) { body.classList.add(savedTheme === 'dark' ? 'dark-mode' : 'light-mode'); themeToggleBtn.textContent = savedTheme === 'dark' ? '☀️' : '🌙'; } // Funkció a téma váltásához themeToggleBtn.addEventListener('click', () => { if (body.classList.contains('dark-mode')) { body.classList.remove('dark-mode'); body.classList.add('light-mode'); themeToggleBtn.textContent = '🌙'; localStorage.setItem('theme', 'light'); // Mentés a localStorage-ba } else { body.classList.remove('light-mode'); body.classList.add('dark-mode'); themeToggleBtn.textContent = '☀️'; localStorage.setItem('theme', 'dark'); // Mentés a localStorage-ba } }); });