Spaces:
Sleeping
Sleeping
Download landing-script.js from edichat/edi.chat.test: direct link, hf CLI and curl.
- Browser
- Download file 16.6 kB
-
https://huggingface.co/spaces/edichat/edi.chat.test/resolve/main/landing-script.js
- Command line
-
hf download hf://spaces/edichat/edi.chat.test/landing-script.js
-
curl -L -o landing-script.js https://huggingface.co/spaces/edichat/edi.chat.test/resolve/main/landing-script.js
16.6 kB
| // Landing Page JavaScript | |
| // DOM Content Loaded | |
| document.addEventListener('DOMContentLoaded', function() { | |
| initializeAnimations(); | |
| initializeNavigation(); | |
| initializeROICalculator(); | |
| initializeChatDemo(); | |
| initializeContactForm(); | |
| initializeScrollAnimations(); | |
| }); | |
| // Navigation functionality | |
| function initializeNavigation() { | |
| const navbar = document.querySelector('.navbar'); | |
| const hamburger = document.getElementById('hamburger'); | |
| const navMenu = document.getElementById('navMenu'); | |
| // Scroll effect for navbar | |
| window.addEventListener('scroll', function() { | |
| if (window.scrollY > 50) { | |
| navbar.classList.add('scrolled'); | |
| } else { | |
| navbar.classList.remove('scrolled'); | |
| } | |
| }); | |
| // Mobile menu toggle | |
| hamburger.addEventListener('click', function() { | |
| navMenu.classList.toggle('active'); | |
| hamburger.classList.toggle('active'); | |
| }); | |
| // Smooth scrolling for nav links | |
| document.querySelectorAll('.nav-link').forEach(link => { | |
| link.addEventListener('click', function(e) { | |
| e.preventDefault(); | |
| const targetId = this.getAttribute('href'); | |
| const targetSection = document.querySelector(targetId); | |
| if (targetSection) { | |
| targetSection.scrollIntoView({ | |
| behavior: 'smooth', | |
| block: 'start' | |
| }); | |
| } | |
| // Close mobile menu if open | |
| navMenu.classList.remove('active'); | |
| hamburger.classList.remove('active'); | |
| }); | |
| }); | |
| } | |
| // Scroll animations | |
| function initializeScrollAnimations() { | |
| const observerOptions = { | |
| threshold: 0.1, | |
| rootMargin: '0px 0px -50px 0px' | |
| }; | |
| const observer = new IntersectionObserver(function(entries) { | |
| entries.forEach(entry => { | |
| if (entry.isIntersecting) { | |
| entry.target.classList.add('aos-animate'); | |
| } | |
| }); | |
| }, observerOptions); | |
| // Observe all elements with data-aos attribute | |
| document.querySelectorAll('[data-aos]').forEach(el => { | |
| observer.observe(el); | |
| }); | |
| } | |
| // ROI Calculator | |
| function initializeROICalculator() { | |
| const studentCountInput = document.getElementById('studentCount'); | |
| const staffCountInput = document.getElementById('staffCount'); | |
| const staffSalaryInput = document.getElementById('staffSalary'); | |
| const annualSavingsElement = document.getElementById('annualSavings'); | |
| const paybackPeriodElement = document.getElementById('paybackPeriod'); | |
| const threeYearROIElement = document.getElementById('threeYearROI'); | |
| function calculateROI() { | |
| const studentCount = parseInt(studentCountInput.value) || 0; | |
| const staffCount = parseInt(staffCountInput.value) || 0; | |
| const staffSalary = parseInt(staffSalaryInput.value) || 0; | |
| // Calculate based on 70% efficiency improvement | |
| const currentAnnualCost = staffCount * staffSalary; | |
| const staffReduction = Math.floor(staffCount * 0.7); | |
| const annualSavings = staffReduction * staffSalary; | |
| // Estimate edi.chat cost based on student count | |
| let monthlyCost = 2500; // Base cost | |
| if (studentCount > 2500) monthlyCost = 5500; | |
| if (studentCount > 15000) monthlyCost = 12000; | |
| const annualCost = monthlyCost * 12; | |
| const netSavings = annualSavings - annualCost; | |
| // Payback period in months | |
| const paybackMonths = annualCost / (annualSavings / 12); | |
| // 3-year ROI | |
| const threeYearSavings = netSavings * 3; | |
| const threeYearROI = (threeYearSavings / annualCost) * 100; | |
| // Update display | |
| annualSavingsElement.textContent = `$${netSavings.toLocaleString()}`; | |
| paybackPeriodElement.textContent = `${paybackMonths.toFixed(1)} months`; | |
| threeYearROIElement.textContent = `${Math.max(0, threeYearROI).toFixed(0)}%`; | |
| } | |
| // Add event listeners | |
| [studentCountInput, staffCountInput, staffSalaryInput].forEach(input => { | |
| input.addEventListener('input', calculateROI); | |
| }); | |
| // Initial calculation | |
| calculateROI(); | |
| } | |
| // Chat Demo Animation | |
| function initializeChatDemo() { | |
| const messagesContainer = document.getElementById('chatMessages'); | |
| if (!messagesContainer) return; | |
| // Simulate typing animation | |
| function simulateTyping() { | |
| const messages = messagesContainer.querySelectorAll('.message'); | |
| // Hide all messages initially | |
| messages.forEach((message, index) => { | |
| message.style.opacity = '0'; | |
| message.style.transform = 'translateY(20px)'; | |
| }); | |
| // Show messages with delay | |
| messages.forEach((message, index) => { | |
| setTimeout(() => { | |
| message.style.transition = 'opacity 0.5s ease, transform 0.5s ease'; | |
| message.style.opacity = '1'; | |
| message.style.transform = 'translateY(0)'; | |
| }, index * 1500); | |
| }); | |
| } | |
| // Start simulation when chat demo is visible | |
| const chatDemo = document.querySelector('.chat-demo'); | |
| const observerOptions = { | |
| threshold: 0.5, | |
| rootMargin: '0px' | |
| }; | |
| const observer = new IntersectionObserver(function(entries) { | |
| entries.forEach(entry => { | |
| if (entry.isIntersecting) { | |
| setTimeout(simulateTyping, 1000); | |
| observer.unobserve(entry.target); | |
| } | |
| }); | |
| }, observerOptions); | |
| if (chatDemo) { | |
| observer.observe(chatDemo); | |
| } | |
| } | |
| // Contact Form | |
| function initializeContactForm() { | |
| const contactForm = document.getElementById('contactForm'); | |
| if (!contactForm) return; | |
| contactForm.addEventListener('submit', async function(e) { | |
| e.preventDefault(); | |
| const submitButton = contactForm.querySelector('.submit-button'); | |
| const buttonText = submitButton.querySelector('.button-text'); | |
| const buttonLoading = submitButton.querySelector('.button-loading'); | |
| // Show loading state | |
| buttonText.style.display = 'none'; | |
| buttonLoading.style.display = 'flex'; | |
| submitButton.disabled = true; | |
| // Collect form data | |
| const formData = new FormData(contactForm); | |
| const data = Object.fromEntries(formData.entries()); | |
| try { | |
| // Simulate form submission | |
| await new Promise(resolve => setTimeout(resolve, 2000)); | |
| // Show success message | |
| showNotification('Thank you! We\'ll contact you within 24 hours to schedule your demo.', 'success'); | |
| contactForm.reset(); | |
| } catch (error) { | |
| showNotification('There was an error submitting your request. Please try again.', 'error'); | |
| } | |
| // Reset button state | |
| buttonText.style.display = 'inline'; | |
| buttonLoading.style.display = 'none'; | |
| submitButton.disabled = false; | |
| }); | |
| } | |
| // Demo Modal | |
| function openDemo() { | |
| const modal = document.getElementById('demoModal'); | |
| modal.classList.add('show'); | |
| document.body.style.overflow = 'hidden'; | |
| } | |
| function closeDemo() { | |
| const modal = document.getElementById('demoModal'); | |
| modal.classList.remove('show'); | |
| document.body.style.overflow = 'auto'; | |
| } | |
| // Close modal when clicking outside | |
| document.getElementById('demoModal').addEventListener('click', function(e) { | |
| if (e.target === this) { | |
| closeDemo(); | |
| } | |
| }); | |
| // Scroll to contact section | |
| function scrollToContact() { | |
| document.getElementById('contact').scrollIntoView({ | |
| behavior: 'smooth', | |
| block: 'start' | |
| }); | |
| } | |
| // Notification system | |
| function showNotification(message, type = 'info') { | |
| // Remove existing notifications | |
| const existingNotifications = document.querySelectorAll('.notification'); | |
| existingNotifications.forEach(notification => notification.remove()); | |
| // Create notification element | |
| const notification = document.createElement('div'); | |
| notification.className = `notification notification-${type}`; | |
| notification.innerHTML = ` | |
| <div class="notification-content"> | |
| <span class="notification-message">${message}</span> | |
| <button class="notification-close" onclick="this.parentElement.parentElement.remove()">×</button> | |
| </div> | |
| `; | |
| // Add styles | |
| notification.style.cssText = ` | |
| position: fixed; | |
| top: 20px; | |
| right: 20px; | |
| background: ${type === 'success' ? '#10B981' : type === 'error' ? '#EF4444' : '#4F46E5'}; | |
| color: white; | |
| padding: 16px 20px; | |
| border-radius: 12px; | |
| box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2); | |
| z-index: 3000; | |
| max-width: 400px; | |
| animation: slideInFromRight 0.3s ease; | |
| `; | |
| // Add notification to body | |
| document.body.appendChild(notification); | |
| // Auto remove after 5 seconds | |
| setTimeout(() => { | |
| if (notification.parentElement) { | |
| notification.style.animation = 'slideOutToRight 0.3s ease'; | |
| setTimeout(() => notification.remove(), 300); | |
| } | |
| }, 5000); | |
| } | |
| // Initialize animations | |
| function initializeAnimations() { | |
| // Add CSS animations | |
| const style = document.createElement('style'); | |
| style.textContent = ` | |
| @keyframes slideInFromRight { | |
| from { | |
| transform: translateX(100%); | |
| opacity: 0; | |
| } | |
| to { | |
| transform: translateX(0); | |
| opacity: 1; | |
| } | |
| } | |
| @keyframes slideOutToRight { | |
| from { | |
| transform: translateX(0); | |
| opacity: 1; | |
| } | |
| to { | |
| transform: translateX(100%); | |
| opacity: 0; | |
| } | |
| } | |
| .notification-content { | |
| display: flex; | |
| align-items: center; | |
| justify-content: space-between; | |
| gap: 16px; | |
| } | |
| .notification-close { | |
| background: none; | |
| border: none; | |
| color: white; | |
| font-size: 1.5rem; | |
| cursor: pointer; | |
| padding: 0; | |
| line-height: 1; | |
| } | |
| .notification-close:hover { | |
| opacity: 0.8; | |
| } | |
| .hamburger.active span:nth-child(1) { | |
| transform: rotate(45deg) translate(5px, 5px); | |
| } | |
| .hamburger.active span:nth-child(2) { | |
| opacity: 0; | |
| } | |
| .hamburger.active span:nth-child(3) { | |
| transform: rotate(-45deg) translate(7px, -6px); | |
| } | |
| @media (max-width: 768px) { | |
| .nav-menu.active { | |
| display: flex !important; | |
| position: absolute; | |
| top: 100%; | |
| left: 0; | |
| right: 0; | |
| background: white; | |
| flex-direction: column; | |
| padding: 20px; | |
| box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1); | |
| border-radius: 0 0 15px 15px; | |
| } | |
| .nav-menu.active .nav-link { | |
| padding: 10px 0; | |
| border-bottom: 1px solid #E5E7EB; | |
| } | |
| .nav-menu.active .nav-link:last-child { | |
| border-bottom: none; | |
| } | |
| .nav-menu.active .cta-button { | |
| margin-top: 10px; | |
| align-self: center; | |
| } | |
| } | |
| `; | |
| document.head.appendChild(style); | |
| } | |
| // Pricing card interactions | |
| document.addEventListener('DOMContentLoaded', function() { | |
| const pricingCards = document.querySelectorAll('.pricing-card'); | |
| pricingCards.forEach(card => { | |
| card.addEventListener('mouseenter', function() { | |
| this.style.transform = 'translateY(-10px) scale(1.02)'; | |
| }); | |
| card.addEventListener('mouseleave', function() { | |
| this.style.transform = 'translateY(0) scale(1)'; | |
| }); | |
| }); | |
| }); | |
| // Feature card hover effects | |
| document.addEventListener('DOMContentLoaded', function() { | |
| const featureCards = document.querySelectorAll('.feature-card'); | |
| featureCards.forEach(card => { | |
| card.addEventListener('mouseenter', function() { | |
| const icon = this.querySelector('.feature-icon'); | |
| if (icon) { | |
| icon.style.transform = 'scale(1.1) rotate(5deg)'; | |
| } | |
| }); | |
| card.addEventListener('mouseleave', function() { | |
| const icon = this.querySelector('.feature-icon'); | |
| if (icon) { | |
| icon.style.transform = 'scale(1) rotate(0deg)'; | |
| } | |
| }); | |
| }); | |
| }); | |
| // Testimonial card animations | |
| document.addEventListener('DOMContentLoaded', function() { | |
| const testimonialCards = document.querySelectorAll('.testimonial-card'); | |
| testimonialCards.forEach((card, index) => { | |
| card.style.animationDelay = `${index * 0.2}s`; | |
| }); | |
| }); | |
| // Smooth reveal animation for sections | |
| function revealOnScroll() { | |
| const reveals = document.querySelectorAll('[data-aos]'); | |
| reveals.forEach(element => { | |
| const windowHeight = window.innerHeight; | |
| const elementTop = element.getBoundingClientRect().top; | |
| const elementVisible = 150; | |
| if (elementTop < windowHeight - elementVisible) { | |
| element.classList.add('aos-animate'); | |
| } | |
| }); | |
| } | |
| window.addEventListener('scroll', revealOnScroll); | |
| // Initialize parallax effect for hero background | |
| function initializeParallax() { | |
| const floatingElements = document.querySelectorAll('.floating-element'); | |
| window.addEventListener('scroll', () => { | |
| const scrolled = window.pageYOffset; | |
| const rate = scrolled * -0.5; | |
| floatingElements.forEach((element, index) => { | |
| const speed = 0.5 + (index * 0.1); | |
| element.style.transform = `translateY(${rate * speed}px)`; | |
| }); | |
| }); | |
| } | |
| // Initialize on load | |
| document.addEventListener('DOMContentLoaded', function() { | |
| initializeParallax(); | |
| // Add loading animation for the page | |
| document.body.style.opacity = '0'; | |
| document.body.style.transition = 'opacity 0.5s ease'; | |
| setTimeout(() => { | |
| document.body.style.opacity = '1'; | |
| }, 100); | |
| }); | |
| // Keyboard navigation | |
| document.addEventListener('keydown', function(e) { | |
| // Close modal with Escape key | |
| if (e.key === 'Escape') { | |
| const modal = document.getElementById('demoModal'); | |
| if (modal.classList.contains('show')) { | |
| closeDemo(); | |
| } | |
| } | |
| }); | |
| // Performance optimization - Lazy load images | |
| function lazyLoadImages() { | |
| const images = document.querySelectorAll('img[data-src]'); | |
| const imageObserver = new IntersectionObserver((entries, observer) => { | |
| entries.forEach(entry => { | |
| if (entry.isIntersecting) { | |
| const img = entry.target; | |
| img.src = img.dataset.src; | |
| img.classList.remove('lazy'); | |
| observer.unobserve(img); | |
| } | |
| }); | |
| }); | |
| images.forEach(img => imageObserver.observe(img)); | |
| } | |
| // Initialize lazy loading | |
| document.addEventListener('DOMContentLoaded', lazyLoadImages); | |
| // Add custom cursor effect for interactive elements | |
| function initializeCustomCursor() { | |
| const cursor = document.createElement('div'); | |
| cursor.className = 'custom-cursor'; | |
| cursor.style.cssText = ` | |
| position: fixed; | |
| width: 20px; | |
| height: 20px; | |
| background: rgba(79, 70, 229, 0.3); | |
| border-radius: 50%; | |
| pointer-events: none; | |
| z-index: 9999; | |
| transition: transform 0.1s ease; | |
| display: none; | |
| `; | |
| document.body.appendChild(cursor); | |
| document.addEventListener('mousemove', (e) => { | |
| cursor.style.left = e.clientX - 10 + 'px'; | |
| cursor.style.top = e.clientY - 10 + 'px'; | |
| cursor.style.display = 'block'; | |
| }); | |
| // Scale up on hover over interactive elements | |
| const interactiveElements = document.querySelectorAll('button, a, .feature-card, .pricing-card, .testimonial-card'); | |
| interactiveElements.forEach(element => { | |
| element.addEventListener('mouseenter', () => { | |
| cursor.style.transform = 'scale(2)'; | |
| cursor.style.background = 'rgba(79, 70, 229, 0.5)'; | |
| }); | |
| element.addEventListener('mouseleave', () => { | |
| cursor.style.transform = 'scale(1)'; | |
| cursor.style.background = 'rgba(79, 70, 229, 0.3)'; | |
| }); | |
| }); | |
| } | |
| // Initialize custom cursor on desktop only | |
| if (window.innerWidth > 768) { | |
| document.addEventListener('DOMContentLoaded', initializeCustomCursor); | |
| } |