File size: 8,752 Bytes
beeef79
83c1239
beeef79
 
 
 
 
83c1239
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
beeef79
 
83c1239
 
 
 
 
 
 
 
 
 
980d109
beeef79
 
 
 
980d109
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
beeef79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f13caf0
 
 
 
 
beeef79
f13caf0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
beeef79
f13caf0
beeef79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232

// Create hail and lightning animation
function createHailAnimation() {
    const container = document.createElement('div');
    container.className = 'hail-container';
    document.body.appendChild(container);

    // Create lightning effect
    const lightning = document.createElement('div');
    lightning.className = 'lightning';
    container.appendChild(lightning);

    // Random lightning flashes
    function triggerLightning() {
        const duration = 2 + Math.random() * 3;
        const delay = Math.random() * 15;
        
        lightning.style.animation = `lightning ${duration}s ${delay}s linear`;
        
        setTimeout(() => {
            lightning.style.animation = 'none';
            setTimeout(triggerLightning, Math.random() * 10000 + 5000); // Next flash in 5-15 seconds
        }, (duration + delay) * 1000);
    }

    // Start lightning
    triggerLightning();
    // Create car container with lightning illumination effect
    const carContainer = document.createElement('div');
    carContainer.className = 'car-container';
    carContainer.style.filter = 'brightness(0.7)';
    carContainer.style.transition = 'filter 0.3s ease';
    
    // Sync car brightness with lightning
    lightning.addEventListener('animationstart', () => {
        carContainer.style.filter = 'brightness(1.5)';
    });
    lightning.addEventListener('animationend', () => {
        carContainer.style.filter = 'brightness(0.7)';
    });
    const car = document.createElement('div');
    car.className = 'car';
    carContainer.appendChild(car);
    document.body.appendChild(carContainer);

    // Add rain effect
    function createRain() {
        const rain = document.createElement('div');
        rain.className = 'rain';
        container.appendChild(rain);

        for (let i = 0; i < 100; i++) {
            const drop = document.createElement('div');
            drop.className = 'rain-drop';
            drop.style.left = `${Math.random() * 100}%`;
            drop.style.animationDuration = `${0.5 + Math.random() * 0.5}s`;
            drop.style.animationDelay = `${Math.random() * 2}s`;
            rain.appendChild(drop);
        }
    }

    createRain();
// Generate hail
    function generateHail() {
        const hail = document.createElement('div');
        hail.className = 'hail';
        
        // Random position
        const left = Math.random() * 100;
        const duration = 2 + Math.random() * 3;
        const delay = Math.random() * 5;
        const size = 4 + Math.random() * 4;
        
        hail.style.left = `${left}%`;
        hail.style.width = `${size}px`;
        hail.style.height = `${size}px`;
        hail.style.animationDuration = `${duration}s`;
        hail.style.animationDelay = `${delay}s`;
        
        container.appendChild(hail);
        
        // Create impact effect when hail hits car
        setTimeout(() => {
            if (left > 35 && left < 65) { // Only show impacts on car
                const impact = document.createElement('div');
                impact.className = 'hail-impact';
                impact.style.left = `${Math.random() * 80 + 10}%`;
                impact.style.top = `${Math.random() * 50 + 20}%`;
                car.appendChild(impact);
                
                setTimeout(() => {
                    impact.remove();
                }, 300);
            }
        }, duration * 1000 * (1 - (50 / window.innerHeight)));
        
        // Remove hail after animation
        setTimeout(() => {
            hail.remove();
        }, duration * 1000);
    }
    
    // Initial hail
    for (let i = 0; i < 50; i++) {
        generateHail();
    }
    
    // Continuous hail generation
    setInterval(generateHail, 100);
}

document.addEventListener('DOMContentLoaded', function() {
    // Create hail animation
    createHailAnimation();
// Weather API functions
const API_KEY = 'YOUR_OPENWEATHERMAP_API_KEY'; // Replace with your actual API key
const weatherContainer = document.getElementById('weatherContainer');
const weatherSearchBtn = document.getElementById('weatherSearchBtn');
const locationInput = document.getElementById('locationInput');

async function fetchWeather(location) {
    try {
        const response = await fetch(`https://api.openweathermap.org/data/2.5/forecast?q=${location}&appid=${API_KEY}&units=imperial`);
        const data = await response.json();
        
        if (data.cod !== "200") throw new Error(data.message);
        
        // Filter to get one forecast per day (every 8th item in the array)
        const dailyForecasts = data.list.filter((item, index) => index % 8 === 0).slice(0, 3);
        
        weatherContainer.innerHTML = dailyForecasts.map(forecast => {
            const date = new Date(forecast.dt * 1000);
            const iconUrl = `https://openweathermap.org/img/wn/${forecast.weather[0].icon}@2x.png`;
            
            return `
                <div class="bg-blue-50 rounded-lg p-4 text-center">
                    <h3 class="font-semibold text-lg mb-2">${date.toLocaleDateString('en-US', { weekday: 'short', month: 'short', day: 'numeric' })}</h3>
                    <img src="${iconUrl}" alt="${forecast.weather[0].description}" class="mx-auto w-16 h-16">
                    <div class="flex justify-center space-x-4 mt-2">
                        <span class="text-2xl font-bold">${Math.round(forecast.main.temp)}°F</span>
                        <span class="text-gray-600 mt-1">${forecast.weather[0].main}</span>
                    </div>
                    <div class="grid grid-cols-2 gap-2 mt-4 text-sm">
                        <div class="bg-blue-100 rounded p-2">
                            <i data-feather="wind" class="w-4 h-4 inline mr-1"></i>
                            ${Math.round(forecast.wind.speed)} mph
                        </div>
                        <div class="bg-blue-100 rounded p-2">
                            <i data-feather="droplet" class="w-4 h-4 inline mr-1"></i>
                            ${forecast.main.humidity}%
                        </div>
                    </div>
                </div>
            `;
        }).join('');
        
        feather.replace();
    } catch (error) {
        weatherContainer.innerHTML = `
            <div class="col-span-3 text-center p-4 bg-red-50 rounded-lg">
                <p class="text-red-600">${error.message}</p>
            </div>
        `;
    }
}

// Event listeners for weather search
weatherSearchBtn.addEventListener('click', () => {
    if (locationInput.value.trim()) {
        fetchWeather(locationInput.value.trim());
    }
});

locationInput.addEventListener('keypress', (e) => {
    if (e.key === 'Enter' && locationInput.value.trim()) {
        fetchWeather(locationInput.value.trim());
    }
});

// Form submission handler
const appointmentForm = document.getElementById('appointmentForm');
const confirmationModal = document.getElementById('confirmationModal');
    
    if (appointmentForm) {
        appointmentForm.addEventListener('submit', function(e) {
            e.preventDefault();
            
            // In a real app, you would send this data to your backend
            const formData = {
                name: document.getElementById('name').value,
                email: document.getElementById('email').value,
                phone: document.getElementById('phone').value,
                vehicle: document.getElementById('vehicle').value,
                date: document.getElementById('date').value,
                time: document.getElementById('time').value,
                notes: document.getElementById('notes').value
            };
            
            console.log('Form submitted:', formData); // For debugging
            
            // Show confirmation modal
            confirmationModal.classList.remove('hidden');
            
            // Reset form
            appointmentForm.reset();
            
            // Close modal after 5 seconds (optional)
            // setTimeout(closeModal, 5000);
        });
    }
    
    // Date picker restrictions (today and future dates only)
    const dateInput = document.getElementById('date');
    if (dateInput) {
        const today = new Date().toISOString().split('T')[0];
        dateInput.setAttribute('min', today);
    }
});

// Modal functions
function closeModal() {
    const confirmationModal = document.getElementById('confirmationModal');
    confirmationModal.classList.add('hidden');
}

// Close modal when clicking outside
window.addEventListener('click', function(event) {
    const confirmationModal = document.getElementById('confirmationModal');
    if (event.target === confirmationModal) {
        closeModal();
    }
});