Spaces:
Running
Running
Download script.js from Tornike2/lightswitch-explorer: direct link, hf CLI and curl.
- Browser
- Download file 853 Bytes
-
https://huggingface.co/spaces/Tornike2/lightswitch-explorer/resolve/main/script.js
- Command line
-
hf download hf://spaces/Tornike2/lightswitch-explorer/script.js
-
curl -L -o script.js https://huggingface.co/spaces/Tornike2/lightswitch-explorer/resolve/main/script.js
853 Bytes
| // Theme switching logic | |
| document.addEventListener('DOMContentLoaded', () => { | |
| // Check for saved theme preference or use default | |
| if (localStorage.getItem('color-theme') === 'dark' || (!('color-theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) { | |
| document.documentElement.classList.add('dark'); | |
| } else { | |
| document.documentElement.classList.remove('dark'); | |
| } | |
| }); | |
| // Function to toggle theme | |
| function toggleTheme() { | |
| if (document.documentElement.classList.contains('dark')) { | |
| document.documentElement.classList.remove('dark'); | |
| localStorage.setItem('color-theme', 'light'); | |
| } else { | |
| document.documentElement.classList.add('dark'); | |
| localStorage.setItem('color-theme', 'dark'); | |
| } | |
| } | |
| // Make it globally available | |
| window.toggleTheme = toggleTheme; |