Spaces:
Running
Running
Download script.js from talib12/chatfusion-pro: direct link, hf CLI and curl.
- Browser
- Download file 1.28 kB
-
https://huggingface.co/spaces/talib12/chatfusion-pro/resolve/main/script.js
- Command line
-
hf download hf://spaces/talib12/chatfusion-pro/script.js
-
curl -L -o script.js https://huggingface.co/spaces/talib12/chatfusion-pro/resolve/main/script.js
1.28 kB
| // Theme toggle functionality | |
| document.addEventListener('DOMContentLoaded', () => { | |
| // Check for saved theme preference or use preferred color scheme | |
| const savedTheme = localStorage.getItem('theme') || | |
| (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'); | |
| document.documentElement.classList.toggle('dark', savedTheme === 'dark'); | |
| // Initialize sidebar and messenger states | |
| const sidebarState = localStorage.getItem('sidebarState') || 'expanded'; | |
| const messengerState = localStorage.getItem('messengerState') || 'expanded'; | |
| // Apply initial states | |
| document.dispatchEvent(new CustomEvent('sidebarStateChange', { detail: sidebarState })); | |
| document.dispatchEvent(new CustomEvent('messengerStateChange', { detail: messengerState })); | |
| // Global event listeners | |
| document.addEventListener('themeToggle', () => { | |
| const isDark = document.documentElement.classList.toggle('dark'); | |
| localStorage.setItem('theme', isDark ? 'dark' : 'light'); | |
| }); | |
| }); | |
| // Utility functions | |
| function debounce(func, timeout = 300) { | |
| let timer; | |
| return (...args) => { | |
| clearTimeout(timer); | |
| timer = setTimeout(() => { func.apply(this, args); }, timeout); | |
| }; | |
| } |