Download script.js from hugging2021/robojacky-s-ultimate-draft-clone: direct link, hf CLI and curl.
- Browser
- Download file 1.58 kB
-
https://huggingface.co/spaces/hugging2021/robojacky-s-ultimate-draft-clone/resolve/main/script.js
- Command line
-
hf download hf://spaces/hugging2021/robojacky-s-ultimate-draft-clone/script.js
-
curl -L -o script.js https://huggingface.co/spaces/hugging2021/robojacky-s-ultimate-draft-clone/resolve/main/script.js
1.58 kB
| document.addEventListener('DOMContentLoaded', function() { | |
| // Theme toggle functionality | |
| const themeToggle = document.getElementById('theme-toggle'); | |
| const htmlElement = document.documentElement; | |
| // Check for saved theme preference or use preferred color scheme | |
| if (localStorage.getItem('theme') === 'dark' || | |
| (!localStorage.getItem('theme') && window.matchMedia('(prefers-color-scheme: dark)').matches)) { | |
| htmlElement.classList.add('dark'); | |
| } else { | |
| htmlElement.classList.remove('dark'); | |
| } | |
| themeToggle.addEventListener('click', function() { | |
| htmlElement.classList.toggle('dark'); | |
| localStorage.setItem('theme', htmlElement.classList.contains('dark') ? 'dark' : 'light'); | |
| feather.replace(); | |
| }); | |
| // Update feather icons when theme changes | |
| const observer = new MutationObserver(function(mutations) { | |
| mutations.forEach(function(mutation) { | |
| if (mutation.attributeName === 'class') { | |
| feather.replace(); | |
| } | |
| }); | |
| }); | |
| observer.observe(htmlElement, { | |
| attributes: true | |
| }); | |
| // Initialize tooltips for buttons | |
| const buttons = document.querySelectorAll('button'); | |
| buttons.forEach(button => { | |
| if (button.querySelector('[data-feather]')) { | |
| const icon = button.querySelector('[data-feather]'); | |
| const iconName = icon.getAttribute('data-feather'); | |
| button.setAttribute('title', iconName.charAt(0).toUpperCase() + iconName.slice(1)); | |
| } | |
| }); | |
| }); |