Spaces:
Running
Running
Download script.js from dalabin/codecraft-academy-pro: direct link, hf CLI and curl.
- Browser
- Download file 2.7 kB
-
https://huggingface.co/spaces/dalabin/codecraft-academy-pro/resolve/main/script.js
- Command line
-
hf download hf://spaces/dalabin/codecraft-academy-pro/script.js
-
curl -L -o script.js https://huggingface.co/spaces/dalabin/codecraft-academy-pro/resolve/main/script.js
2.7 kB
| // Shared JavaScript across all pages | |
| // Toggle module content | |
| function toggleModule(moduleNumber) { | |
| const moduleContent = document.getElementById(`module-${moduleNumber}`); | |
| const icon = document.querySelector(`.module-icon[data-module="${moduleNumber}"]`); | |
| moduleContent.classList.toggle('hidden'); | |
| moduleContent.classList.add('fade-in'); | |
| if (moduleContent.classList.contains('hidden')) { | |
| feather.replace(); | |
| } else { | |
| icon.setAttribute('data-feather', 'chevron-up'); | |
| feather.replace(); | |
| } | |
| } | |
| // Toggle FAQ content | |
| function toggleFAQ(faqNumber) { | |
| const faqContent = document.getElementById(`faq-${faqNumber}`); | |
| const icon = document.querySelector(`.faq-icon[data-faq="${faqNumber}"]`); | |
| faqContent.classList.toggle('hidden'); | |
| faqContent.classList.add('fade-in'); | |
| if (faqContent.classList.contains('hidden')) { | |
| feather.replace(); | |
| } else { | |
| icon.setAttribute('data-feather', 'chevron-up'); | |
| feather.replace(); | |
| } | |
| } | |
| // Dark mode toggle functionality | |
| function toggleDarkMode() { | |
| const html = document.documentElement; | |
| html.classList.toggle('dark'); | |
| // Save preference to localStorage | |
| if (html.classList.contains('dark')) { | |
| localStorage.setItem('darkMode', 'enabled'); | |
| } else { | |
| localStorage.setItem('darkMode', 'disabled'); | |
| } | |
| } | |
| // Check for saved dark mode preference | |
| document.addEventListener('DOMContentLoaded', () => { | |
| // Check for dark mode preference | |
| if (localStorage.getItem('darkMode') === 'enabled') { | |
| document.documentElement.classList.add('dark'); | |
| } else if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) { | |
| document.documentElement.classList.add('dark'); | |
| } | |
| // Initialize tooltips for icons | |
| feather.replace(); | |
| // Smooth scrolling for anchor links | |
| document.querySelectorAll('a[href^="#"]').forEach(anchor => { | |
| anchor.addEventListener('click', function (e) { | |
| e.preventDefault(); | |
| const targetId = this.getAttribute('href'); | |
| const targetElement = document.querySelector(targetId); | |
| if (targetElement) { | |
| window.scrollTo({ | |
| top: targetElement.offsetTop - 80, | |
| behavior: 'smooth' | |
| }); | |
| } | |
| }); | |
| }); | |
| }); | |
| // Track enrollment button clicks | |
| document.querySelectorAll('[href="#enroll"], button').forEach(button => { | |
| button.addEventListener('click', () => { | |
| // In a real app, you would send this to analytics | |
| console.log('Enrollment button clicked'); | |
| }); | |
| }); |