File manager - Edit - /home/webapp69.cm.in.th/u69319090015/Shop/assets/js/theme-toggle.js
Back
// Dark Mode Toggle Logic (function() { const savedTheme = localStorage.getItem('theme') || (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'); document.documentElement.setAttribute('data-bs-theme', savedTheme); window.addEventListener('DOMContentLoaded', () => { const toggleBtn = document.getElementById('themeToggleBtn'); const themeIcon = document.getElementById('themeIcon'); function updateIcon(theme) { if (themeIcon) { if (theme === 'dark') { themeIcon.className = 'bi bi-sun-fill text-warning'; } else { themeIcon.className = 'bi bi-moon-stars-fill'; } } } updateIcon(savedTheme); if (toggleBtn) { toggleBtn.addEventListener('click', () => { const currentTheme = document.documentElement.getAttribute('data-bs-theme'); const newTheme = currentTheme === 'dark' ? 'light' : 'dark'; document.documentElement.setAttribute('data-bs-theme', newTheme); localStorage.setItem('theme', newTheme); updateIcon(newTheme); }); } }); })();
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.26 |
proxy
|
phpinfo
|
Settings