Spaces:
Running
Running
Download script.js from davesting/campus-promo-pulse: direct link, hf CLI and curl.
- Browser
- Download file 1.75 kB
-
https://huggingface.co/spaces/davesting/campus-promo-pulse/resolve/main/script.js
- Command line
-
hf download hf://spaces/davesting/campus-promo-pulse/script.js
-
curl -L -o script.js https://huggingface.co/spaces/davesting/campus-promo-pulse/resolve/main/script.js
1.75 kB
| // DOM Ready function | |
| document.addEventListener('DOMContentLoaded', function() { | |
| // Initialize tooltips | |
| const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]')); | |
| tooltipTriggerList.map(function(tooltipTriggerEl) { | |
| return new bootstrap.Tooltip(tooltipTriggerEl); | |
| }); | |
| // 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' | |
| }); | |
| }); | |
| }); | |
| // Form validation example | |
| const forms = document.querySelectorAll('.needs-validation'); | |
| Array.prototype.slice.call(forms).forEach(function(form) { | |
| form.addEventListener('submit', function(event) { | |
| if (!form.checkValidity()) { | |
| event.preventDefault(); | |
| event.stopPropagation(); | |
| } | |
| form.classList.add('was-validated'); | |
| }, false); | |
| }); | |
| }); | |
| // Theme switcher (dark/light mode) | |
| 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' || (!localStorage.getItem('theme') && window.matchMedia('(prefers-color-scheme: dark)').matches)) { | |
| document.documentElement.classList.add('dark'); | |
| } else { | |
| document.documentElement.classList.remove('dark'); | |
| } |