Spaces:
Running
Running
File size: 2,209 Bytes
ffeb8d4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
// Shared JavaScript across all pages
document.addEventListener('DOMContentLoaded', function() {
console.log('AI Website Builder loaded');
// Add animation to elements when they come into view
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('animate-fade-in');
}
});
}, { threshold: 0.1 });
// Observe feature cards
document.querySelectorAll('.grid > div').forEach(card => {
card.style.opacity = '0';
card.style.transform = 'translateY(20px)';
card.style.transition = 'opacity 0.6s ease, transform 0.6s ease';
observer.observe(card);
});
// Add fade-in animation class
const style = document.createElement('style');
style.textContent = `
.animate-fade-in {
opacity: 1 !important;
transform: translateY(0) !important;
}
`;
document.head.appendChild(style);
// Handle form submission
const promptTextarea = document.getElementById('prompt');
const generateButton = document.querySelector('button.flex.items-center.gap-2');
if (generateButton) {
generateButton.addEventListener('click', function() {
const prompt = promptTextarea.value.trim();
if (prompt) {
// In a real app, this would send the prompt to an AI service
console.log('Generating website for prompt:', prompt);
// Add visual feedback
this.innerHTML = '<i data-feather="loader"></i> Generating...';
feather.replace();
// Simulate API call
setTimeout(() => {
this.innerHTML = '<i data-feather="zap"></i> Generate Website';
feather.replace();
alert('Website generated successfully! In a real application, this would open your new AI-created website.');
}, 2000);
} else {
alert('Please describe your website first');
}
});
}
}); |