|
|
| |
| |
| document.addEventListener('DOMContentLoaded', function() { |
| |
| document.querySelectorAll('a[href^="#"]').forEach(anchor => { |
| anchor.addEventListener('click', function (e) { |
| e.preventDefault(); |
| document.querySelector(this.getAttribute('href')).scrollIntoView({ |
| behavior: 'smooth' |
| }); |
| }); |
| }); |
|
|
| |
| window.toggleMobileMenu = function() { |
| const menu = document.getElementById('mobile-menu'); |
| menu.classList.toggle('hidden'); |
| }; |
|
|
| |
| const courseCards = document.querySelectorAll('.course-card'); |
| courseCards.forEach(card => { |
| card.addEventListener('mouseenter', () => { |
| card.classList.add('shadow-lg'); |
| }); |
| card.addEventListener('mouseleave', () => { |
| card.classList.remove('shadow-lg'); |
| }); |
| }); |
|
|
| |
| const observerOptions = { |
| threshold: 0.1 |
| }; |
|
|
| const observer = new IntersectionObserver((entries) => { |
| entries.forEach(entry => { |
| if (entry.isIntersecting) { |
| entry.target.classList.add('animate-fadeIn'); |
| } |
| }); |
| }, observerOptions); |
|
|
| document.querySelectorAll('.animate-on-scroll').forEach(element => { |
| observer.observe(element); |
| }); |
| }); |
| |
| async function importFigmaDesign(fileId, nodeIds) { |
| try { |
| const response = await fetch('/api/figma/import', { |
| method: 'POST', |
| headers: { |
| 'Content-Type': 'application/json' |
| }, |
| body: JSON.stringify({ fileId, nodeIds }) |
| }); |
| |
| const data = await response.json(); |
| if (data.success) { |
| return data; |
| } else { |
| throw new Error(data.error || 'Failed to import design'); |
| } |
| } catch (error) { |
| console.error('Figma import failed:', error); |
| return { success: false, error: error.message }; |
| } |
| } |
| try { |
| const response = await fetch('https://api.example.com/courses/featured'); |
| const data = await response.json(); |
| |
| } catch (error) { |
| console.error('Error fetching courses:', error); |
| } |
| } |
|
|
| |
| window.onload = function() { |
| feather.replace(); |
| if (window.location.pathname === '/') { |
| fetchFeaturedCourses(); |
| } |
| }; |