JOWilkins's picture
create a new information page with the following info: 1,020 vehicles
3b53676 verified
Raw History Blame Contribute Delete
4.13 kB
// Main JavaScript for FleetFlex Pro Solutions
// Initialize Feather Icons
document.addEventListener('DOMContentLoaded', function() {
if (typeof feather !== 'undefined') {
feather.replace();
}
// Add smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
target.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
});
// Add intersection observer for fade-in animations
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('fade-in-up');
observer.unobserve(entry.target);
}
});
}, observerOptions);
// Observe all sections for animation
document.querySelectorAll('section').forEach(section => {
observer.observe(section);
});
// Stats counter animation
const statsSection = document.querySelector('.bg-white');
const statsObserver = new IntersectionObserver(function(entries) {
entries.forEach(entry => {
if (entry.isIntersecting) {
animateStats();
statsObserver.unobserve(entry.target);
}
});
}, { threshold: 0.5 });
if (statsSection) {
statsObserver.observe(statsSection);
}
});
// Animate statistics counters
function animateStats() {
const counters = document.querySelectorAll('.text-4xl');
const speed = 200; // The lower the slower
counters.forEach(counter => {
const target = +counter.innerText.replace(',', '');
const increment = target / speed;
let current = 0;
const updateCount = () => {
current += increment;
if (current < target) {
counter.innerText = Math.floor(current).toLocaleString();
setTimeout(updateCount, 1);
} else {
counter.innerText = target.toLocaleString();
}
};
updateCount();
});
}
// Handle form submissions
function handleContactForm(event) {
event.preventDefault();
// Show loading state
const submitBtn = event.target.querySelector('button[type="submit"]');
const originalText = submitBtn.innerHTML;
submitBtn.innerHTML = '<div class="loading-dots"><div></div><div></div><div></div><div></div></div>';
// Simulate API call
setTimeout(() => {
submitBtn.innerHTML = originalText;
alert('Thank you for your message! We will get back to you soon.');
event.target.reset();
}, 2000);
}
// Mobile menu toggle functionality
function toggleMobileMenu() {
const mobileMenu = document.getElementById('mobile-menu');
if (mobileMenu) {
mobileMenu.classList.toggle('hidden');
}
}
// Add scroll effect to header
window.addEventListener('scroll', function() {
const header = document.querySelector('custom-header');
if (header && header.shadowRoot) {
const headerElement = header.shadowRoot.querySelector('header');
if (window.scrollY > 100) {
headerElement.classList.add('bg-white', 'shadow-lg');
headerElement.classList.remove('bg-transparent');
} else {
headerElement.classList.remove('bg-white', 'shadow-lg');
headerElement.classList.add('bg-transparent');
}
}
});
// Initialize any third-party APIs if needed
function initializeExternalAPIs() {
// Placeholder for any external API integrations
console.log('External APIs initialized');
}
// Export functions for use in components if needed
window.FleetFlex = {
toggleMobileMenu,
handleContactForm,
animateStats
};