suna/agentpress/examples/example_agent/workspace/script.js

54 lines
1.7 KiB
JavaScript
Raw Normal View History

2024-11-18 06:36:37 +08:00
document.addEventListener('DOMContentLoaded', () => {
2024-11-18 08:38:31 +08:00
const mobileMenu = document.querySelector('.mobile-menu');
const navLinks = document.querySelector('.nav-links');
const contactForm = document.getElementById('contact-form');
2024-11-18 06:36:37 +08:00
2024-11-18 08:38:31 +08:00
mobileMenu.addEventListener('click', () => {
navLinks.classList.toggle('active');
mobileMenu.classList.toggle('open');
2024-11-18 06:36:37 +08:00
});
2024-11-18 08:38:31 +08:00
const smoothScroll = (target) => {
const element = document.querySelector(target);
if (element) {
element.scrollIntoView({ behavior: 'smooth' });
}
};
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
smoothScroll(this.getAttribute('href'));
if (navLinks.classList.contains('active')) {
navLinks.classList.remove('active');
mobileMenu.classList.remove('open');
}
2024-11-18 06:36:37 +08:00
});
});
contactForm.addEventListener('submit', (e) => {
e.preventDefault();
2024-11-18 08:38:31 +08:00
const formData = new FormData(contactForm);
const data = Object.fromEntries(formData.entries());
alert(`Thank you for your message, ${data.name}! We'll get back to you soon.`);
2024-11-18 06:36:37 +08:00
contactForm.reset();
});
2024-11-18 08:38:31 +08:00
const observerOptions = {
threshold: 0.1
};
const fadeInObserver = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('fade-in');
}
});
}, observerOptions);
document.querySelectorAll('.feature, .about-content, .contact-container').forEach(section => {
fadeInObserver.observe(section);
});
2024-11-18 06:36:37 +08:00
});