Download script.js from Bozartify/deepsite-project-n1cs2: direct link, hf CLI and curl.
- Browser
- Download file 7.91 kB
-
https://huggingface.co/spaces/Bozartify/deepsite-project-n1cs2/resolve/main/script.js
- Command line
-
hf download hf://spaces/Bozartify/deepsite-project-n1cs2/script.js
-
curl -L -o script.js https://huggingface.co/spaces/Bozartify/deepsite-project-n1cs2/resolve/main/script.js
7.91 kB
| // ===== SHARED JS - AI Chapter Forge ===== | |
| // Initialize Lucide icons | |
| function initIcons() { | |
| if (typeof lucide !== 'undefined') { | |
| lucide.createIcons(); | |
| } | |
| } | |
| // ===== CURSOR GLOW ===== | |
| function initCursorGlow() { | |
| const cursorGlow = document.getElementById('cursorGlow'); | |
| if (!cursorGlow) return; | |
| document.addEventListener('mousemove', (e) => { | |
| cursorGlow.style.left = e.clientX + 'px'; | |
| cursorGlow.style.top = e.clientY + 'px'; | |
| cursorGlow.style.opacity = '1'; | |
| }); | |
| } | |
| // ===== SCROLL REVEAL ===== | |
| function initScrollReveal() { | |
| const revealObserver = new IntersectionObserver((entries) => { | |
| entries.forEach(entry => { | |
| if (entry.isIntersecting) { | |
| entry.target.classList.add('active'); | |
| } | |
| }); | |
| }, { threshold: 0.1, rootMargin: '0px 0px -50px 0px' }); | |
| document.querySelectorAll('.reveal, .reveal-left, .reveal-scale').forEach(el => { | |
| revealObserver.observe(el); | |
| }); | |
| } | |
| // ===== ANIMATED COUNTERS ===== | |
| function initCounters() { | |
| const counterObserver = new IntersectionObserver((entries) => { | |
| entries.forEach(entry => { | |
| if (entry.isIntersecting && !entry.target.classList.contains('counted')) { | |
| entry.target.classList.add('counted'); | |
| const target = parseInt(entry.target.getAttribute('data-target')); | |
| const suffix = entry.target.getAttribute('data-suffix') || ''; | |
| if (target) { | |
| animateCounter(entry.target, target, suffix); | |
| } | |
| } | |
| }); | |
| }, { threshold: 0.5 }); | |
| document.querySelectorAll('.counter').forEach(el => counterObserver.observe(el)); | |
| } | |
| function animateCounter(el, target, suffix) { | |
| const duration = 2000; | |
| const start = performance.now(); | |
| const step = (now) => { | |
| const elapsed = now - start; | |
| const progress = Math.min(elapsed / duration, 1); | |
| const eased = 1 - Math.pow(1 - progress, 4); | |
| const current = Math.floor(eased * target); | |
| el.textContent = current.toLocaleString() + suffix; | |
| if (progress < 1) { | |
| requestAnimationFrame(step); | |
| } else { | |
| el.textContent = target.toLocaleString() + suffix; | |
| } | |
| }; | |
| requestAnimationFrame(step); | |
| } | |
| // ===== NAV SCROLL EFFECT ===== | |
| function initNavScroll() { | |
| const mainNav = document.getElementById('mainNav'); | |
| if (!mainNav) return; | |
| window.addEventListener('scroll', () => { | |
| if (window.scrollY > 50) { | |
| mainNav.classList.add('glass', 'nav-scrolled'); | |
| } else { | |
| mainNav.classList.remove('glass', 'nav-scrolled'); | |
| } | |
| }); | |
| } | |
| // ===== MOBILE MENU ===== | |
| function initMobileMenu() { | |
| const toggle = document.getElementById('mobileMenuToggle'); | |
| const menu = document.getElementById('mobileMenu'); | |
| const close = document.getElementById('mobileMenuClose'); | |
| const overlay = document.getElementById('mobileMenuOverlay'); | |
| if (!toggle || !menu) return; | |
| function openMenu() { | |
| menu.classList.add('open'); | |
| if (overlay) overlay.classList.remove('hidden'); | |
| document.body.style.overflow = 'hidden'; | |
| } | |
| function closeMenu() { | |
| menu.classList.remove('open'); | |
| if (overlay) overlay.classList.add('hidden'); | |
| document.body.style.overflow = ''; | |
| } | |
| toggle.addEventListener('click', openMenu); | |
| if (close) close.addEventListener('click', closeMenu); | |
| if (overlay) overlay.addEventListener('click', closeMenu); | |
| // Close on link click | |
| menu.querySelectorAll('a').forEach(link => { | |
| link.addEventListener('click', closeMenu); | |
| }); | |
| } | |
| // ===== SMOOTH SCROLL OFFSET ===== | |
| function initSmoothScroll() { | |
| document.querySelectorAll('a[href^="#"]').forEach(anchor => { | |
| anchor.addEventListener('click', function(e) { | |
| e.preventDefault(); | |
| const target = document.querySelector(this.getAttribute('href')); | |
| if (target) { | |
| const offset = 80; | |
| const targetPosition = target.getBoundingClientRect().top + window.pageYOffset - offset; | |
| window.scrollTo({ top: targetPosition, behavior: 'smooth' }); | |
| } | |
| }); | |
| }); | |
| } | |
| // ===== TOAST SYSTEM ===== | |
| function showToast(message, type = 'success') { | |
| // Remove existing toast | |
| const existingToast = document.getElementById('toast'); | |
| if (existingToast) existingToast.remove(); | |
| const iconMap = { success: 'check-circle', error: 'alert-circle', info: 'info' }; | |
| const colorMap = { success: 'text-green-400', error: 'text-red-400', info: 'text-blue-400' }; | |
| const toast = document.createElement('div'); | |
| toast.id = 'toast'; | |
| toast.className = 'fixed bottom-6 right-6 z-[60] flex'; | |
| toast.innerHTML = ` | |
| <div class="glass-heavy rounded-2xl px-6 py-4 flex items-center gap-3 shadow-2xl animate-scale-in"> | |
| <i data-lucide="${iconMap[type] || 'check-circle'}" class="w-5 h-5 ${colorMap[type] || 'text-green-400'}"></i> | |
| <span class="text-sm font-semibold text-white">${message}</span> | |
| </div> | |
| `; | |
| document.body.appendChild(toast); | |
| initIcons(); | |
| setTimeout(() => { | |
| toast.remove(); | |
| }, 3000); | |
| } | |
| // ===== FAQ ACCORDION ===== | |
| function initFAQ() { | |
| document.querySelectorAll('.faq-item').forEach(item => { | |
| const btn = item.querySelector('.faq-toggle'); | |
| if (!btn) return; | |
| btn.addEventListener('click', () => { | |
| const isOpen = item.classList.contains('open'); | |
| // Close all | |
| document.querySelectorAll('.faq-item.open').forEach(openItem => { | |
| openItem.classList.remove('open'); | |
| const answer = openItem.querySelector('.faq-answer'); | |
| if (answer) answer.style.maxHeight = '0'; | |
| }); | |
| // Open clicked | |
| if (!isOpen) { | |
| item.classList.add('open'); | |
| const answer = item.querySelector('.faq-answer'); | |
| if (answer) answer.style.maxHeight = answer.scrollHeight + 'px'; | |
| } | |
| }); | |
| }); | |
| } | |
| // ===== UTILITY ===== | |
| function delay(ms) { return new Promise(r => setTimeout(r, ms)); } | |
| // ===== INIT ALL ===== | |
| document.addEventListener('DOMContentLoaded', () => { | |
| initIcons(); | |
| initCursorGlow(); | |
| initScrollReveal(); | |
| initCounters(); | |
| initNavScroll(); | |
| initMobileMenu(); | |
| initSmoothScroll(); | |
| initFAQ(); | |
| // Info Modal | |
| const infoBtn = document.getElementById('themeInfoBtn'); | |
| if (infoBtn) { | |
| infoBtn.addEventListener('click', () => { | |
| const modal = document.getElementById('infoModal'); | |
| if (modal) { | |
| modal.classList.remove('hidden'); | |
| modal.classList.add('flex'); | |
| initIcons(); | |
| } | |
| }); | |
| } | |
| // Close modal | |
| document.querySelectorAll('[data-close-modal]').forEach(btn => { | |
| btn.addEventListener('click', () => { | |
| const modal = btn.closest('[data-modal]'); | |
| if (modal) { | |
| modal.classList.add('hidden'); | |
| modal.classList.remove('flex'); | |
| } | |
| }); | |
| }); | |
| document.querySelectorAll('[data-modal]').forEach(modal => { | |
| modal.addEventListener('click', (e) => { | |
| if (e.target === modal) { | |
| modal.classList.add('hidden'); | |
| modal.classList.remove('flex'); | |
| } | |
| }); | |
| }); | |
| // Escape key | |
| document.addEventListener('keydown', (e) => { | |
| if (e.key === 'Escape') { | |
| document.querySelectorAll('[data-modal]').forEach(modal => { | |
| if (!modal.classList.contains('hidden')) { | |
| modal.classList.add('hidden'); | |
| modal.classList.remove('flex'); | |
| } | |
| }); | |
| } | |
| }); | |
| }); |