Download script.js from muhammadsaadkhatri/pythonic-student-wizard: direct link, hf CLI and curl.
- Browser
- Download file 1.79 kB
-
https://huggingface.co/spaces/muhammadsaadkhatri/pythonic-student-wizard/resolve/main/script.js
- Command line
-
hf download hf://spaces/muhammadsaadkhatri/pythonic-student-wizard/script.js
-
curl -L -o script.js https://huggingface.co/spaces/muhammadsaadkhatri/pythonic-student-wizard/resolve/main/script.js
1.79 kB
| // DOM Content Loaded event | |
| document.addEventListener('DOMContentLoaded', function() { | |
| // Smooth scrolling for anchor links | |
| document.querySelectorAll('a[href^="#"]').forEach(anchor => { | |
| anchor.addEventListener('click', function (e) { | |
| e.preventDefault(); | |
| document.querySelector(this.getAttribute('href')).scrollIntoView({ | |
| behavior: 'smooth' | |
| }); | |
| }); | |
| }); | |
| // Tooltip initialization | |
| const tooltipTriggers = document.querySelectorAll('[data-tooltip]'); | |
| tooltipTriggers.forEach(trigger => { | |
| trigger.addEventListener('mouseenter', function() { | |
| const tooltip = document.createElement('div'); | |
| tooltip.classList.add('bg-gray-800', 'text-white', 'px-2', 'py-1', 'rounded', 'text-xs', 'absolute', 'z-50', 'whitespace-nowrap'); | |
| tooltip.textContent = this.getAttribute('data-tooltip'); | |
| document.body.appendChild(tooltip); | |
| const rect = this.getBoundingClientRect(); | |
| tooltip.style.top = `${rect.top - 30}px`; | |
| tooltip.style.left = `${rect.left + rect.width/2 - tooltip.offsetWidth/2}px`; | |
| this.addEventListener('mouseleave', function() { | |
| tooltip.remove(); | |
| }); | |
| }); | |
| }); | |
| }); | |
| // Theme toggle functionality | |
| function toggleTheme() { | |
| const html = document.documentElement; | |
| if (html.classList.contains('dark')) { | |
| html.classList.remove('dark'); | |
| localStorage.setItem('theme', 'light'); | |
| } else { | |
| html.classList.add('dark'); | |
| localStorage.setItem('theme', 'dark'); | |
| } | |
| } | |
| // Check for saved theme preference | |
| if (localStorage.getItem('theme') === 'dark') { | |
| document.documentElement.classList.add('dark'); | |
| } |