Spaces:
Running
Running
Download 731aimd3/script.js from u11310019/interactive-multi-web: direct link, hf CLI and curl.
- Browser
- Download file 3.24 kB
-
https://huggingface.co/spaces/u11310019/interactive-multi-web/resolve/main/731aimd3/script.js
- Command line
-
hf download hf://spaces/u11310019/interactive-multi-web/731aimd3/script.js
-
curl -L -o script.js https://huggingface.co/spaces/u11310019/interactive-multi-web/resolve/main/731aimd3/script.js
3.24 kB
| /* ========================================================================== | |
| DISCORD DESIGN SYSTEM INTERACTIVE SCRIPT | |
| ========================================================================== */ | |
| document.addEventListener('DOMContentLoaded', () => { | |
| // 1. Mobile Navigation Toggle | |
| const mobileMenuBtn = document.getElementById('mobileMenuBtn'); | |
| const navLinks = document.getElementById('navLinks'); | |
| if (mobileMenuBtn && navLinks) { | |
| mobileMenuBtn.addEventListener('click', () => { | |
| navLinks.classList.toggle('active'); | |
| }); | |
| } | |
| // 2. FAQ Accordion Functionality | |
| const faqAccordions = document.querySelectorAll('.faq-accordion'); | |
| faqAccordions.forEach(accordion => { | |
| accordion.addEventListener('click', () => { | |
| const isOpen = accordion.classList.contains('open'); | |
| // Close other accordions | |
| faqAccordions.forEach(item => item.classList.remove('open')); | |
| if (!isOpen) { | |
| accordion.classList.add('open'); | |
| } | |
| }); | |
| }); | |
| // 3. Modal Dialog System (ex-modal-card) | |
| const modalOverlay = document.getElementById('modalOverlay'); | |
| const openModalBtn = document.getElementById('openModalBtn'); | |
| const closeModalBtn = document.getElementById('closeModalBtn'); | |
| if (openModalBtn && modalOverlay) { | |
| openModalBtn.addEventListener('click', () => { | |
| modalOverlay.classList.add('active'); | |
| }); | |
| } | |
| if (closeModalBtn && modalOverlay) { | |
| closeModalBtn.addEventListener('click', () => { | |
| modalOverlay.classList.remove('active'); | |
| }); | |
| } | |
| if (modalOverlay) { | |
| modalOverlay.addEventListener('click', (e) => { | |
| if (e.target === modalOverlay) { | |
| modalOverlay.classList.remove('active'); | |
| } | |
| }); | |
| } | |
| // 4. Toast Notification System (ex-toast) | |
| const toastContainer = document.getElementById('toastContainer'); | |
| const triggerToastBtn = document.getElementById('triggerToastBtn'); | |
| if (triggerToastBtn && toastContainer) { | |
| triggerToastBtn.addEventListener('click', () => { | |
| showToast('DESIGN-discord.md 設計代幣已成功套用至當前 DOM 樹!'); | |
| }); | |
| } | |
| window.showToast = function(message) { | |
| if (!toastContainer) return; | |
| const toast = document.createElement('div'); | |
| toast.className = 'ex-toast'; | |
| toast.innerHTML = `<strong>代幣系統通知</strong>: ${message}`; | |
| toastContainer.appendChild(toast); | |
| setTimeout(() => { | |
| toast.style.opacity = '0'; | |
| toast.style.transition = 'opacity 0.3s ease'; | |
| setTimeout(() => toast.remove(), 300); | |
| }, 3500); | |
| }; | |
| // 5. Nitro Pricing Cycle Switcher | |
| const cycleBtns = document.querySelectorAll('[data-billing-cycle]'); | |
| cycleBtns.forEach(btn => { | |
| btn.addEventListener('click', () => { | |
| cycleBtns.forEach(b => b.classList.remove('active')); | |
| btn.classList.add('active'); | |
| const cycle = btn.getAttribute('data-billing-cycle'); | |
| const prices = document.querySelectorAll('.pricing-price'); | |
| if (cycle === 'yearly') { | |
| prices[0].textContent = '$2.99 / 月 (年繳 $29.99)'; | |
| prices[1].textContent = '$9.99 / 月 (年繳 $99.99)'; | |
| } else { | |
| prices[0].textContent = '$2.99 / 月'; | |
| prices[1].textContent = '$9.99 / 月'; | |
| } | |
| }); | |
| }); | |
| }); | |