diff --git a/script.js b/script.js index abcf0373..9c4ffe71 100644 --- a/script.js +++ b/script.js @@ -367,18 +367,31 @@ document.addEventListener('DOMContentLoaded', function() { moonIcon.className = 'moon-icon'; moonIcon.innerHTML = '🌙'; + const currentTheme = localStorage.getItem('theme'); + + if (currentTheme === 'dark') { + document.body.classList.add('dark-mode'); + modeToggle.replaceChild(moonIcon, sunIcon); + } else { + document.body.classList.add('light-mode'); + sunIcon.classList.add('glow'); + } + modeToggle.addEventListener('click', function() { document.body.classList.toggle('dark-mode'); document.body.classList.toggle('light-mode'); if (document.body.classList.contains('dark-mode')) { modeToggle.replaceChild(moonIcon, sunIcon); + localStorage.setItem('theme', 'dark'); } else { modeToggle.replaceChild(sunIcon, moonIcon); sunIcon.classList.add('glow'); + localStorage.setItem('theme', 'light'); } }); }); + // discount pop_up document.addEventListener('DOMContentLoaded', function() { // Show the popup after a slight delay