Download script.js from Bazoq/commentcritic-hate-speech-annotation-hub: direct link, hf CLI and curl.
- Browser
- Download file 2.78 kB
-
https://huggingface.co/spaces/Bazoq/commentcritic-hate-speech-annotation-hub/resolve/main/script.js
- Command line
-
hf download hf://spaces/Bazoq/commentcritic-hate-speech-annotation-hub/script.js
-
curl -L -o script.js https://huggingface.co/spaces/Bazoq/commentcritic-hate-speech-annotation-hub/resolve/main/script.js
2.78 kB
| // Main application scripts | |
| document.addEventListener('DOMContentLoaded', () => { | |
| // Initialize tooltips | |
| const tooltipElements = document.querySelectorAll('[data-tooltip]'); | |
| tooltipElements.forEach(el => { | |
| const tooltipText = el.getAttribute('data-tooltip'); | |
| const tooltip = document.createElement('div'); | |
| tooltip.className = 'absolute hidden bg-gray-800 text-white text-xs rounded py-1 px-2 bottom-full mb-2 whitespace-nowrap'; | |
| tooltip.textContent = tooltipText; | |
| el.appendChild(tooltip); | |
| el.addEventListener('mouseenter', () => { | |
| tooltip.classList.remove('hidden'); | |
| }); | |
| el.addEventListener('mouseleave', () => { | |
| tooltip.classList.add('hidden'); | |
| }); | |
| }); | |
| // 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' | |
| }); | |
| }); | |
| }); | |
| // Initialize animations | |
| const animateOnScroll = () => { | |
| const elements = document.querySelectorAll('.scroll-animate'); | |
| elements.forEach(el => { | |
| const rect = el.getBoundingClientRect(); | |
| const isVisible = (rect.top <= window.innerHeight * 0.8); | |
| if (isVisible && !el.classList.contains('animate-fade-in-up')) { | |
| el.classList.add('animate-fade-in-up'); | |
| } | |
| }); | |
| }; | |
| window.addEventListener('scroll', animateOnScroll); | |
| animateOnScroll(); // Initial check | |
| }); | |
| // Dark mode toggle functionality | |
| class ThemeToggle { | |
| static init() { | |
| const toggle = document.getElementById('theme-toggle'); | |
| if (!toggle) return; | |
| // Check for saved theme preference or use system preference | |
| const savedTheme = localStorage.getItem('theme'); | |
| const systemDark = window.matchMedia('(prefers-color-scheme: dark)').matches; | |
| if (savedTheme === 'dark' || (!savedTheme && systemDark)) { | |
| document.documentElement.classList.add('dark'); | |
| toggle.checked = true; | |
| } | |
| toggle.addEventListener('change', (e) => { | |
| if (e.target.checked) { | |
| document.documentElement.classList.add('dark'); | |
| localStorage.setItem('theme', 'dark'); | |
| } else { | |
| document.documentElement.classList.remove('dark'); | |
| localStorage.setItem('theme', 'light'); | |
| } | |
| }); | |
| } | |
| } | |
| // Initialize when DOM is loaded | |
| document.addEventListener('DOMContentLoaded', ThemeToggle.init); |