-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
524 lines (480 loc) · 18.1 KB
/
index.html
File metadata and controls
524 lines (480 loc) · 18.1 KB
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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Hawaiʻi Island Safety Check Locator Map</title>
<!-- Preload hero image for faster first paint -->
<link rel="preload" as="image" href="backimage.jpg">
<!-- Google Fonts for softer, more organic feel -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@400;500;600;700&display=swap" rel="stylesheet">
<!-- Critical CSS (just the first viewport) is inlined via <style>.
The rest sits in style.css so browsers can cache it aggressively. -->
<style>
:root{
--brand-teal:#28a391;
--volcanic-black:#2c2c2c;
--forest-green:#4a7c59;
--ocean-blue:#4a90e2;
--lava-red:#e74c3c;
--font-light:#ffffff;
--font-dark:#1e1e1e;
}
*{box-sizing:border-box;margin:0;padding:0;}
body{
font-family: 'Nunito Sans', system-ui, -apple-system, sans-serif;
font-size: 16px;
line-height: 1.5;
color: var(--font-dark);
}
.hero{
background: url('./backimage.jpg') center center/cover no-repeat;
color:var(--font-light);
text-align:center;
padding:15vh 1.5rem 10vh;
min-height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
}
.hero h1{
font-size:clamp(2.5rem,6vw,4rem);
margin-bottom:.75em;
line-height:1.1;
font-weight: 700;
text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.hero p{
max-width:min(800px, 85%);
margin:0 auto 2.2em;
font-size:clamp(1.1rem,3vw,1.4rem);
line-height:1.5;
font-weight: 400;
text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.source-note {
font-size: 0.9rem;
color: rgba(255,255,255,0.8);
font-style: italic;
margin-top: 0.5rem;
text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.cta{
background: linear-gradient(135deg, var(--brand-teal) 0%, #239a87 100%);
color:#fff;border:0;border-radius:12px;
padding:1.125rem 2.8rem;font-size:1.2rem;
cursor:pointer;transition:all .2s;
font-family: inherit;
font-weight: 600;
position: relative;
overflow: hidden;
box-shadow: 0 4px 15px rgba(40, 163, 145, 0.3);
text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.cta:hover{
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(40, 163, 145, 0.4);
background: linear-gradient(135deg, #2bb8a3 0%, #239a87 100%);
}
.cta:disabled {
opacity: 0.7;
cursor: not-allowed;
transform: none;
}
.cta .button-icon {
font-size: 1.2em;
margin-right: 8px;
display: inline-block;
}
.location-options{
display: flex;
flex-direction: column;
align-items: center;
gap: 1.5rem;
margin-bottom: 3rem;
}
.or-divider{
color: rgba(255,255,255,0.7);
font-size: 0.9rem;
position: relative;
padding: 0 1rem;
}
.or-divider::before,
.or-divider::after{
content: '';
position: absolute;
top: 50%;
width: 60px;
height: 1px;
background: rgba(255,255,255,0.3);
}
.or-divider::before{left: -70px;}
.or-divider::after{right: -70px;}
.address-input-section{
display: flex;
gap: 0.75rem;
width: 100%;
max-width: 500px;
align-items: center;
}
.address-input{
flex: 1;
padding: 1rem 1.25rem;
border: 2px solid rgba(255,255,255,0.3);
border-radius: 12px;
background: rgba(255,255,255,0.15);
color: var(--font-light);
font-size: 1.1rem;
backdrop-filter: blur(15px);
transition: all 0.2s ease;
font-family: inherit;
box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}
.address-input::placeholder{
color: rgba(255,255,255,0.7);
}
.address-input:focus{
outline: none;
border-color: var(--brand-teal);
background: rgba(255,255,255,0.2);
box-shadow: 0 0 0 3px rgba(40, 163, 145, 0.2);
}
.cta-secondary{
background: linear-gradient(135deg, rgba(40, 163, 145, 0.9) 0%, rgba(35, 154, 135, 0.9) 100%);
border: 2px solid rgba(255,255,255,0.2);
padding: 1rem 1.75rem;
font-size: 1.1rem;
border-radius: 12px;
font-weight: 600;
box-shadow: 0 4px 15px rgba(40, 163, 145, 0.2);
}
.cta-secondary:hover{
background: linear-gradient(135deg, var(--brand-teal) 0%, #239a87 100%);
border-color: rgba(255,255,255,0.3);
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(40, 163, 145, 0.3);
}
.privacy-note {
font-size: 0.85rem;
color: rgba(255,255,255,0.6);
margin-top: 1rem;
font-style: italic;
}
.loading-spinner {
display: none;
width: 20px;
height: 20px;
border: 2px solid rgba(255,255,255,0.3);
border-radius: 50%;
border-top-color: white;
animation: spin 1s ease-in-out infinite;
margin-right: 8px;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
.about-section{
max-width: 600px;
margin: 0 auto;
padding: 2rem 1.5rem;
background: rgba(255,255,255,0.08);
border-radius: 16px;
backdrop-filter: blur(15px);
border: 1px solid rgba(255,255,255,0.15);
box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}
.about-content h3{
color: var(--font-light);
font-size: 1.25rem;
margin-bottom: 1rem;
text-align: center;
font-weight: 600;
}
.about-content p{
color: rgba(255,255,255,0.9);
font-size: 1rem;
line-height: 1.6;
margin-bottom: 1.5rem;
text-align: center;
}
.support-links{
display: flex;
gap: 2rem;
justify-content: center;
flex-wrap: wrap;
}
.support-item{
text-align: center;
}
.support-item strong{
display: block;
color: var(--font-light);
font-size: 0.9rem;
margin-bottom: 0.5rem;
font-weight: 600;
}
.donation-link, .contact-link{
color: var(--brand-teal);
text-decoration: none;
font-weight: 500;
padding: 8px 16px;
border-radius: 6px;
background: rgba(40, 163, 145, 0.2);
display: inline-block;
transition: all 0.2s ease;
border: 1px solid rgba(40, 163, 145, 0.3);
}
.donation-link:hover, .contact-link:hover{
background: rgba(40, 163, 145, 0.3);
transform: translateY(-1px);
}
</style>
<!-- Main stylesheet (everything below the fold) -->
<link rel="stylesheet" href="style.css">
<!-- Leaflet CSS for maps -->
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
</head>
<body>
<header class="hero">
<h1>Find a Safety Check Station<br>Near You — Fast & Free</h1>
<p>A local resource built for the people of Hawaiʻi. No hassle. No spam.<br>Just the info you need to get legal and stay safe.</p>
<p class="source-note">(Locations are from Hawaii Department of Transportation website)</p>
<!-- Location Input Options -->
<div class="location-options">
<button class="cta" id="locateBtn" type="button">
<span class="loading-spinner" id="locationSpinner"></span>
<span class="button-icon">📍</span>
<span class="button-text">Use My Location</span>
</button>
<div class="or-divider">
<span>or</span>
</div>
<div class="address-input-section">
<input type="text" id="addressInput" placeholder="Enter your address or ZIP code" class="address-input">
<button class="cta cta-secondary" id="searchBtn" type="button">
<span class="loading-spinner" id="searchSpinner"></span>
<span class="button-icon">🔍</span>
<span class="button-text">Find Stations</span>
</button>
</div>
<p class="privacy-note">Your location is only used to find nearby stations. We don't store or share it.</p>
</div>
<div id="status" hidden>Finding nearby safety check stations…</div>
<!-- About Section -->
<div class="about-section">
<div class="about-content">
<h3>About This Site</h3>
<p>This tool was built to make life easier. Getting your safety check is required, but finding a nearby place shouldn't be a hassle. We created something simple, fast, and accurate for our Big Island community.</p>
<div class="support-links">
<div class="support-item">
<strong>Support This Project</strong>
<a href="https://paypal.me/yourusername" target="_blank" class="donation-link">☕ Buy us a coffee</a>
</div>
<div class="support-item">
<strong>Get in Touch</strong>
<a href="mailto:akakabrian19@gmail.com" class="contact-link">akakabrian19@gmail.com</a>
</div>
</div>
</div>
</div>
</header>
<section id="results" hidden>
<div class="results-header">
<h3>Nearest Safety Check Stations</h3>
<a href="#" id="changeLocationBtn" class="change-location-link">📍 Change Location</a>
</div>
<div id="map"></div>
<div id="stationList"></div>
</section>
<!-- Footer with map attribution and local pride -->
<footer class="page-footer">
<div class="footer-content">
<p>Map data © <a href="https://stadiamaps.com/" target="_blank">Stadia Maps</a>, © <a href="https://openmaptiles.org/" target="_blank">OpenMapTiles</a>, © <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap contributors</a></p>
<p style="margin-top: 0.5rem; font-size: 0.65rem; color: rgba(255,255,255,0.5);">Proudly built in Puna District on Moku O Keawe 🌺</p>
</div>
</footer>
<!-- Leaflet JavaScript for maps -->
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
<!-- Your logic, loaded last with defer so it never blocks rendering -->
<script src="app.js" defer></script>
<!-- Add the missing searchByAddress function with improved UX -->
<script>
// Enhanced button state management
function setButtonLoading(buttonId, spinnerId, isLoading, loadingText, normalText) {
const button = document.getElementById(buttonId);
const spinner = document.getElementById(spinnerId);
const buttonText = button.querySelector('.button-text');
if (isLoading) {
button.disabled = true;
spinner.style.display = 'inline-block';
buttonText.textContent = loadingText;
} else {
button.disabled = false;
spinner.style.display = 'none';
buttonText.textContent = normalText;
}
}
// Add the missing searchByAddress function
async function searchByAddress() {
const address = document.getElementById('addressInput').value.trim();
if (!address) {
showError('Please enter an address or ZIP code.');
return;
}
// Show loading state
setButtonLoading('searchBtn', 'searchSpinner', true, 'Searching...', 'Find Stations');
const statusEl = document.getElementById('status');
statusEl.removeAttribute('hidden');
statusEl.textContent = 'Finding your location...';
try {
// Ensure stations data is loaded
if (safetyStations.length === 0) {
statusEl.textContent = 'Loading safety station data...';
await loadStationsData();
}
// Geocode the address
statusEl.textContent = 'Looking up address...';
const geocodeResult = await geocodeAddress(address);
if (!geocodeResult.success) {
showError(geocodeResult.error || 'Unable to find that location. Please try a different address.');
setButtonLoading('searchBtn', 'searchSpinner', false, 'Searching...', 'Find Stations');
return;
}
const { lat, lng } = geocodeResult;
console.log('Geocoded address:', address, 'to coordinates:', lat, lng);
// Check if the location is within Big Island bounds
if (!isWithinBigIsland(lat, lng)) {
showLocationError(lat, lng);
setButtonLoading('searchBtn', 'searchSpinner', false, 'Searching...', 'Find Stations');
return;
}
// Set user location
userLocation = { lat, lng };
// Find nearest stations
statusEl.textContent = 'Finding nearby safety check stations...';
const nearestStations = findNearestStations(lat, lng, currentStationCount);
console.log('Found nearest stations:', nearestStations.length);
if (nearestStations.length === 0) {
showError('No safety check stations found within 25 miles of your location.');
setButtonLoading('searchBtn', 'searchSpinner', false, 'Searching...', 'Find Stations');
return;
}
// Hide hero section and show results
document.querySelector('.hero').style.display = 'none';
statusEl.setAttribute('hidden', '');
// Show results
document.getElementById('results').removeAttribute('hidden');
// Scroll to top to show results
window.scrollTo({ top: 0, behavior: 'smooth' });
// Initialize map and display results
setTimeout(() => {
initializeMap(lat, lng, nearestStations);
displayStationsList(nearestStations);
}, 100);
} catch (error) {
console.error('Search error:', error);
showError('An error occurred while searching. Please try again.');
setButtonLoading('searchBtn', 'searchSpinner', false, 'Searching...', 'Find Stations');
}
}
// Enhanced showError function
function showError(message) {
const statusEl = document.getElementById('status');
statusEl.innerHTML = `<span style="color: #ff6b6b;">⚠️ ${message}</span>`;
statusEl.removeAttribute('hidden');
// Reset all button states
setButtonLoading('locateBtn', 'locationSpinner', false, 'Getting Location...', 'Use My Location');
setButtonLoading('searchBtn', 'searchSpinner', false, 'Searching...', 'Find Stations');
}
// Enhanced getUserLocationAndFindStations function
async function getUserLocationAndFindStationsEnhanced() {
console.log('Location button clicked');
setButtonLoading('locateBtn', 'locationSpinner', true, 'Getting Location...', 'Use My Location');
const statusEl = document.getElementById('status');
statusEl.removeAttribute('hidden');
statusEl.textContent = 'Getting your location...';
// Check if we're on HTTPS or localhost
const isSecure = location.protocol === 'https:' || location.hostname === 'localhost' || location.hostname === '127.0.0.1';
if (!isSecure) {
showError('Location access requires HTTPS. Please use a secure hosting service.');
return;
}
if (!navigator.geolocation) {
showError('Geolocation is not supported by this browser.');
return;
}
navigator.geolocation.getCurrentPosition(
async function(position) {
console.log('Location received:', position.coords.latitude, position.coords.longitude);
userLocation = {
lat: position.coords.latitude,
lng: position.coords.longitude
};
// Check if user is within Big Island bounds
if (!isWithinBigIsland(userLocation.lat, userLocation.lng)) {
showLocationError(userLocation.lat, userLocation.lng);
return;
}
// Now ensure stations data is loaded before showing results
if (safetyStations.length === 0) {
statusEl.textContent = 'Loading safety station data…';
try {
await loadStationsData();
} catch (error) {
showError('Unable to load safety station data. Please try again.');
return;
}
}
// Find nearest stations
statusEl.textContent = 'Finding nearby safety check stations…';
const nearestStations = findNearestStations(userLocation.lat, userLocation.lng, currentStationCount);
console.log('Found nearest stations:', nearestStations.length);
// Hide hero section and show results
document.querySelector('.hero').style.display = 'none';
statusEl.setAttribute('hidden', '');
// Show results
document.getElementById('results').removeAttribute('hidden');
// Snap to top to show results
window.scrollTo({ top: 0, behavior: 'instant' });
// Initialize map and display results
setTimeout(() => {
initializeMap(userLocation.lat, userLocation.lng, nearestStations);
displayStationsList(nearestStations);
}, 100);
},
function(error) {
console.error('Geolocation error:', error);
let errorMessage = 'Unable to retrieve your location. ';
switch(error.code) {
case error.PERMISSION_DENIED:
errorMessage += 'Please allow location access in your browser settings.';
break;
case error.POSITION_UNAVAILABLE:
errorMessage += 'Location information is unavailable. Please check your GPS/location services.';
break;
case error.TIMEOUT:
errorMessage += 'Location request timed out. Please try again.';
break;
default:
errorMessage += `An unknown error occurred (Code: ${error.code}). Make sure you're using HTTPS.`;
break;
}
showError(errorMessage);
},
{
enableHighAccuracy: true,
timeout: 10000,
maximumAge: 300000 // 5 minutes
}
);
}
// Override the original function when DOM is ready
document.addEventListener('DOMContentLoaded', function() {
// Replace the getUserLocationAndFindStations function
window.getUserLocationAndFindStations = getUserLocationAndFindStationsEnhanced;
});
</script>
</body>
</html>