-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
782 lines (699 loc) · 26.7 KB
/
index.html
File metadata and controls
782 lines (699 loc) · 26.7 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
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>X̱áat Ḵwáani Tracker — Where is the Salmon People plane?</title>
<meta name="description" content="Track Alaska Airlines' X̱áat Ḵwáani (Salmon People) Boeing 737, designed by Crystal Worl. Find out if this special plane is at your airport right now.">
<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=DM+Serif+Display:ital@0;1&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&display=swap" rel="stylesheet">
<style>
:root {
--midnight: #0B1D3A;
--atlas: #1B4B8F;
--ocean: #2563A8;
--salmon: #E8687D;
--salmon-light: #F2A0AC;
--salmon-pale: #FDE8EC;
--ice: #D6E8F7;
--white: #FAFBFD;
--gray-100: #F0F2F5;
--gray-200: #D8DCE2;
--gray-400: #8E95A2;
--gray-600: #4A5060;
--text: #1A1E28;
--radius: 16px;
--radius-sm: 10px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
font-family: 'DM Sans', sans-serif;
background: var(--white);
color: var(--text);
min-height: 100dvh;
-webkit-font-smoothing: antialiased;
overflow-x: hidden;
}
/* ── HERO ── */
.hero {
background: linear-gradient(165deg, var(--midnight) 0%, var(--atlas) 50%, var(--ocean) 100%);
color: white;
padding: 2rem 1.25rem 2.5rem;
position: relative;
overflow: hidden;
}
.hero::before {
content: '';
position: absolute;
top: -40%;
right: -20%;
width: 80%;
height: 120%;
background: radial-gradient(ellipse, rgba(232, 104, 125, 0.12) 0%, transparent 70%);
pointer-events: none;
}
.hero::after {
content: '';
position: absolute;
bottom: 0; left: 0; right: 0;
height: 60px;
background: url("data:image/svg+xml,%3Csvg viewBox='0 0 1200 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 60 C300 0 600 40 900 10 C1050 -5 1150 20 1200 15 L1200 60Z' fill='%23FAFBFD'/%3E%3C/svg%3E") no-repeat bottom center;
background-size: cover;
}
.hero-label {
font-size: 0.7rem;
font-weight: 500;
letter-spacing: 0.15em;
text-transform: uppercase;
opacity: 0.7;
margin-bottom: 0.5rem;
}
.hero-title {
font-family: 'DM Serif Display', serif;
font-size: 2.2rem;
line-height: 1.1;
margin-bottom: 0.25rem;
}
.hero-subtitle {
font-family: 'DM Serif Display', serif;
font-style: italic;
font-size: 1.15rem;
color: var(--salmon-light);
margin-bottom: 1rem;
}
.hero-desc {
font-size: 0.9rem;
line-height: 1.6;
opacity: 0.85;
max-width: 480px;
}
.hero-reg {
display: inline-block;
margin-top: 1rem;
padding: 0.3rem 0.75rem;
background: rgba(255,255,255,0.1);
border: 1px solid rgba(255,255,255,0.2);
border-radius: 100px;
font-size: 0.75rem;
font-weight: 500;
letter-spacing: 0.08em;
}
/* ── STATUS CARD ── */
.status-section {
padding: 0 1.25rem;
margin-top: -1rem;
position: relative;
z-index: 2;
}
.status-card {
background: white;
border-radius: var(--radius);
box-shadow: 0 4px 24px rgba(11,29,58,0.08), 0 1px 4px rgba(11,29,58,0.04);
padding: 1.5rem;
border: 1px solid var(--gray-100);
}
.status-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 1rem;
}
.status-dot {
width: 10px; height: 10px;
border-radius: 50%;
background: var(--gray-400);
flex-shrink: 0;
}
.status-dot.live { background: #22C55E; box-shadow: 0 0 8px rgba(34,197,94,0.4); }
.status-dot.ground { background: var(--salmon); box-shadow: 0 0 8px rgba(232,104,125,0.4); }
.status-dot.unknown { background: var(--gray-400); }
.status-dot.live, .status-dot.ground { animation: pulse-dot 2s ease-in-out infinite; }
@keyframes pulse-dot {
0%, 100% { transform: scale(1); }
50% { transform: scale(1.3); }
}
.status-label {
font-size: 0.7rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.12em;
color: var(--gray-400);
}
.status-refresh {
background: none;
border: 1px solid var(--gray-200);
border-radius: 100px;
padding: 0.35rem 0.75rem;
font-size: 0.7rem;
font-weight: 500;
color: var(--gray-600);
cursor: pointer;
transition: all 0.2s;
font-family: inherit;
}
.status-refresh:hover { background: var(--gray-100); }
.status-refresh:active { transform: scale(0.96); }
.status-refresh.spinning svg { animation: spin 0.8s ease; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.status-main {
font-family: 'DM Serif Display', serif;
font-size: 1.5rem;
line-height: 1.3;
margin-bottom: 0.75rem;
min-height: 2rem;
}
.status-detail {
font-size: 0.85rem;
color: var(--gray-600);
line-height: 1.6;
}
.status-meta {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 0.75rem;
margin-top: 1.25rem;
padding-top: 1.25rem;
border-top: 1px solid var(--gray-100);
}
.meta-item { display: flex; flex-direction: column; gap: 0.15rem; }
.meta-label {
font-size: 0.65rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.1em;
color: var(--gray-400);
}
.meta-value {
font-size: 0.95rem;
font-weight: 500;
color: var(--text);
}
/* ── NEARBY BANNER ── */
.nearby-banner {
display: none;
margin: 1rem 1.25rem 0;
padding: 1.25rem;
border-radius: var(--radius);
text-align: center;
animation: banner-in 0.5s ease;
}
.nearby-banner.here {
display: block;
background: linear-gradient(135deg, var(--salmon) 0%, #D4556A 100%);
color: white;
}
.nearby-banner.not-here {
display: block;
background: var(--gray-100);
color: var(--gray-600);
}
.nearby-banner .nearby-emoji { font-size: 2rem; margin-bottom: 0.5rem; display: block; }
.nearby-banner .nearby-title {
font-family: 'DM Serif Display', serif;
font-size: 1.3rem;
margin-bottom: 0.25rem;
}
.nearby-banner .nearby-detail { font-size: 0.85rem; opacity: 0.9; }
@keyframes banner-in {
from { opacity: 0; transform: translateY(8px); }
to { opacity: 1; transform: translateY(0); }
}
/* ── MAP ── */
.map-section { padding: 1.25rem; }
.map-container {
border-radius: var(--radius);
overflow: hidden;
border: 1px solid var(--gray-200);
background: var(--ice);
height: 260px;
position: relative;
}
.map-container iframe { width: 100%; height: 100%; border: none; }
.map-placeholder {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100%;
color: var(--gray-400);
font-size: 0.85rem;
gap: 0.5rem;
}
.map-placeholder svg { opacity: 0.3; }
/* ── BUTTONS ── */
.action-section { padding: 0 1.25rem 1rem; }
.btn-check {
width: 100%;
padding: 1rem;
border-radius: var(--radius-sm);
border: none;
font-family: inherit;
font-size: 0.95rem;
font-weight: 600;
cursor: pointer;
transition: all 0.2s;
background: var(--midnight);
color: white;
}
.btn-check:hover { background: var(--atlas); }
.btn-check:active { transform: scale(0.98); }
.btn-check:disabled { background: var(--gray-200); color: var(--gray-400); cursor: not-allowed; }
/* ── LINKS ── */
.links-section { padding: 0 1.25rem 1.5rem; }
.links-title {
font-size: 0.7rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.12em;
color: var(--gray-400);
margin-bottom: 0.75rem;
}
.link-row {
display: flex;
align-items: center;
gap: 0.75rem;
padding: 0.85rem 0;
border-bottom: 1px solid var(--gray-100);
text-decoration: none;
color: var(--text);
transition: opacity 0.15s;
}
.link-row:last-child { border-bottom: none; }
.link-row:hover { opacity: 0.7; }
.link-icon {
width: 36px; height: 36px;
border-radius: 10px;
display: flex;
align-items: center;
justify-content: center;
font-size: 1rem;
flex-shrink: 0;
}
.link-icon.blue { background: var(--ice); color: var(--atlas); }
.link-icon.pink { background: var(--salmon-pale); color: var(--salmon); }
.link-text { flex: 1; }
.link-text-title { font-weight: 500; font-size: 0.9rem; }
.link-text-desc { font-size: 0.75rem; color: var(--gray-400); margin-top: 0.1rem; }
.link-arrow { color: var(--gray-400); font-size: 0.85rem; }
/* ── ABOUT ── */
.about-section {
padding: 1.5rem 1.25rem 2rem;
background: var(--gray-100);
border-top: 1px solid var(--gray-200);
}
.about-title {
font-family: 'DM Serif Display', serif;
font-size: 1.25rem;
margin-bottom: 0.75rem;
}
.about-text {
font-size: 0.85rem;
line-height: 1.7;
color: var(--gray-600);
}
.about-text + .about-text { margin-top: 0.75rem; }
.about-credit {
margin-top: 1.5rem;
padding-top: 1rem;
border-top: 1px solid var(--gray-200);
font-size: 0.75rem;
color: var(--gray-400);
line-height: 1.6;
}
.about-credit a { color: var(--atlas); text-decoration: none; }
/* ── SHIMMER ── */
.shimmer {
background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
background-size: 200% 100%;
animation: shimmer 1.5s ease-in-out infinite;
border-radius: 6px;
color: transparent !important;
}
@keyframes shimmer {
0% { background-position: 200% 0; }
100% { background-position: -200% 0; }
}
.stale-badge {
display: inline-block;
padding: 0.2rem 0.5rem;
background: #FEF3C7;
color: #92400E;
border-radius: 100px;
font-size: 0.7rem;
font-weight: 500;
margin-top: 0.5rem;
}
/* ── RESPONSIVE ── */
@media (min-width: 600px) {
.hero { padding: 3rem 2rem 3.5rem; }
.hero-title { font-size: 2.8rem; }
.status-section, .map-section, .action-section, .links-section { padding-left: 2rem; padding-right: 2rem; }
.about-section { padding: 2rem; }
.status-meta { grid-template-columns: 1fr 1fr 1fr 1fr; }
.map-container { height: 340px; }
}
@media (min-width: 800px) {
body { max-width: 720px; margin: 0 auto; }
}
</style>
</head>
<body>
<!-- HERO -->
<header class="hero">
<div class="hero-label">Alaska Airlines Special Livery Tracker</div>
<h1 class="hero-title">X̱áat Ḵwáani</h1>
<div class="hero-subtitle">Salmon People</div>
<p class="hero-desc">
Track the Boeing 737 painted by Tlingit artist Crystal Worl in Northwest Coast formline art — the first domestic airline aircraft named in an Alaska Native language.
</p>
<span class="hero-reg">N559AS · Boeing 737-800</span>
</header>
<!-- STATUS -->
<section class="status-section">
<div class="status-card" id="statusCard">
<div class="status-header">
<div style="display:flex;align-items:center;gap:0.5rem;">
<div class="status-dot unknown" id="statusDot"></div>
<span class="status-label" id="statusLabel">Checking...</span>
</div>
<button class="status-refresh" id="refreshBtn" onclick="fetchStatus()">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" style="display:inline-block;vertical-align:middle;margin-right:3px;"><path d="M1 4v6h6"/><path d="M23 20v-6h-6"/><path d="M20.49 9A9 9 0 0 0 5.64 5.64L1 10m22 4l-4.64 4.36A9 9 0 0 1 3.51 15"/></svg>
Refresh
</button>
</div>
<div class="status-main shimmer" id="statusMain"> </div>
<div class="status-detail" id="statusDetail"></div>
<div class="status-meta" id="statusMeta" style="display:none;">
<div class="meta-item">
<span class="meta-label">Callsign</span>
<span class="meta-value" id="metaCallsign">—</span>
</div>
<div class="meta-item">
<span class="meta-label">Altitude</span>
<span class="meta-value" id="metaAlt">—</span>
</div>
<div class="meta-item">
<span class="meta-label">Speed</span>
<span class="meta-value" id="metaSpeed">—</span>
</div>
<div class="meta-item">
<span class="meta-label">Heading</span>
<span class="meta-value" id="metaHeading">—</span>
</div>
</div>
</div>
</section>
<!-- NEARBY BANNER -->
<div class="nearby-banner" id="nearbyBanner"></div>
<!-- MAP -->
<section class="map-section">
<div class="map-container" id="mapContainer">
<div class="map-placeholder" id="mapPlaceholder">
<svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7z"/><circle cx="12" cy="9" r="2.5"/></svg>
Waiting for position data...
</div>
</div>
</section>
<!-- CHECK MY AIRPORT -->
<section class="action-section">
<button class="btn-check" id="btnCheck" onclick="checkMyAirport()">
📍 Am I near this plane?
</button>
</section>
<!-- TRACKING LINKS -->
<section class="links-section">
<div class="links-title">Live Tracking & Gate Info</div>
<a class="link-row" href="https://www.flightaware.com/live/flight/N559AS" target="_blank" rel="noopener">
<div class="link-icon blue">✈</div>
<div class="link-text">
<div class="link-text-title">FlightAware</div>
<div class="link-text-desc">Gate info, route, arrival time</div>
</div>
<span class="link-arrow">→</span>
</a>
<a class="link-row" href="https://www.flightradar24.com/data/aircraft/n559as" target="_blank" rel="noopener">
<div class="link-icon blue">🛩</div>
<div class="link-text">
<div class="link-text-title">Flightradar24</div>
<div class="link-text-desc">3D view, playback, photos</div>
</div>
<span class="link-arrow">→</span>
</a>
<a class="link-row" href="https://globe.airplanes.live/?icao=A720EB" target="_blank" rel="noopener">
<div class="link-icon pink">🌐</div>
<div class="link-text">
<div class="link-text-title">Airplanes.live Map</div>
<div class="link-text-desc">Unfiltered live ADS-B tracking</div>
</div>
<span class="link-arrow">→</span>
</a>
</section>
<!-- ABOUT -->
<section class="about-section">
<h2 class="about-title">About this plane</h2>
<p class="about-text">
X̱áat Ḵwáani — "Salmon People" in the Tlingit language — is a Boeing 737-800 painted by Crystal Worl, a Tlingit, Athabascan, Yup'ik, and Filipino artist from Juneau, Alaska. Using Northwest Coast formline art, the design honors the ancestral importance of salmon and the deep connection between Indigenous peoples and this keystone species.
</p>
<p class="about-text">
Unveiled in May 2023, it is the first aircraft in U.S. domestic airline history named in an Alaska Native language. The livery took 12 days and 117 gallons of paint to complete. It replaced the beloved Salmon Thirty Salmon II on the same airframe.
</p>
<div class="about-credit">
Flight data from <a href="https://airplanes.live" target="_blank">Airplanes.live</a> open ADS-B network.
This is an unofficial fan tracker — not affiliated with Alaska Airlines or Crystal Worl.
<br>Built with care in Anchorage, Alaska.
</div>
</section>
<script>
// ── CONFIG ──
const ICAO_HEX = 'A720EB';
const REGISTRATION = 'N559AS';
const API_URL = `https://api.airplanes.live/v2/hex/${ICAO_HEX}`;
const REFRESH_INTERVAL = 30000;
// ── AIRPORT DATABASE ──
const AIRPORTS = [
{ code: 'ANC', name: 'Anchorage (ANC)', lat: 61.1743, lon: -149.9963, r: 3.5 },
{ code: 'SEA', name: 'Seattle-Tacoma (SEA)', lat: 47.4502, lon: -122.3088, r: 4 },
{ code: 'JNU', name: 'Juneau (JNU)', lat: 58.3550, lon: -134.5762, r: 2 },
{ code: 'SIT', name: 'Sitka (SIT)', lat: 57.0471, lon: -135.3616, r: 2 },
{ code: 'KTN', name: 'Ketchikan (KTN)', lat: 55.3556, lon: -131.7137, r: 2 },
{ code: 'WRG', name: 'Wrangell (WRG)', lat: 56.4843, lon: -132.3698, r: 1.5 },
{ code: 'PSG', name: 'Petersburg (PSG)', lat: 56.8017, lon: -132.9453, r: 1.5 },
{ code: 'YAK', name: 'Yakutat (YAK)', lat: 59.5033, lon: -139.6602, r: 1.5 },
{ code: 'CDV', name: 'Cordova (CDV)', lat: 60.4917, lon: -145.4776, r: 1.5 },
{ code: 'FAI', name: 'Fairbanks (FAI)', lat: 64.8141, lon: -147.8597, r: 2.5 },
{ code: 'BET', name: 'Bethel (BET)', lat: 60.7798, lon: -161.8380, r: 1.5 },
{ code: 'OME', name: 'Nome (OME)', lat: 64.5122, lon: -165.4453, r: 1.5 },
{ code: 'ADQ', name: 'Kodiak (ADQ)', lat: 57.7500, lon: -152.4938, r: 1.5 },
{ code: 'DUT', name: 'Dutch Harbor (DUT)', lat: 53.9001, lon: -166.5435, r: 1.5 },
{ code: 'PDX', name: 'Portland (PDX)', lat: 45.5887, lon: -122.5975, r: 3.5 },
{ code: 'SFO', name: 'San Francisco (SFO)', lat: 37.6213, lon: -122.3790, r: 4 },
{ code: 'OAK', name: 'Oakland (OAK)', lat: 37.7213, lon: -122.2208, r: 3 },
{ code: 'SJC', name: 'San Jose (SJC)', lat: 37.3626, lon: -121.9290, r: 3 },
{ code: 'LAX', name: 'Los Angeles (LAX)', lat: 33.9425, lon: -118.4081, r: 5 },
{ code: 'SAN', name: 'San Diego (SAN)', lat: 32.7338, lon: -117.1933, r: 3 },
{ code: 'PHX', name: 'Phoenix (PHX)', lat: 33.4373, lon: -112.0078, r: 4 },
{ code: 'DEN', name: 'Denver (DEN)', lat: 39.8561, lon: -104.6737, r: 5 },
{ code: 'BOS', name: 'Boston (BOS)', lat: 42.3656, lon: -71.0096, r: 3.5 },
{ code: 'JFK', name: 'New York JFK (JFK)', lat: 40.6413, lon: -73.7781, r: 4 },
{ code: 'EWR', name: 'Newark (EWR)', lat: 40.6895, lon: -74.1745, r: 3.5 },
{ code: 'DCA', name: 'Washington Reagan (DCA)', lat: 38.8512, lon: -77.0402, r: 3 },
{ code: 'IAD', name: 'Washington Dulles (IAD)', lat: 38.9531, lon: -77.4565, r: 4 },
{ code: 'HNL', name: 'Honolulu (HNL)', lat: 21.3187, lon: -157.9224, r: 4 },
{ code: 'OGG', name: 'Maui (OGG)', lat: 20.8986, lon: -156.4305, r: 2.5 },
{ code: 'LIH', name: 'Kauai (LIH)', lat: 21.9760, lon: -159.3389, r: 2 },
{ code: 'KOA', name: 'Kona (KOA)', lat: 19.7388, lon: -156.0456, r: 2.5 },
{ code: 'MSP', name: 'Minneapolis (MSP)', lat: 44.8848, lon: -93.2223, r: 4 },
{ code: 'ORD', name: 'Chicago O\'Hare (ORD)', lat: 41.9742, lon: -87.9073, r: 5 },
{ code: 'DFW', name: 'Dallas/Fort Worth (DFW)', lat: 32.8998, lon: -97.0403, r: 5 },
{ code: 'ATL', name: 'Atlanta (ATL)', lat: 33.6407, lon: -84.4277, r: 5 },
];
// ── STATE ──
let lastKnown = null;
try { lastKnown = JSON.parse(localStorage.getItem('xaat_last')); } catch(e) {}
let autoRefresh = null;
// ── HAVERSINE (nautical miles) ──
function distNm(lat1, lon1, lat2, lon2) {
const R = 3440.065;
const dLat = (lat2 - lat1) * Math.PI / 180;
const dLon = (lon2 - lon1) * Math.PI / 180;
const a = Math.sin(dLat/2)**2 + Math.cos(lat1*Math.PI/180)*Math.cos(lat2*Math.PI/180)*Math.sin(dLon/2)**2;
return R * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
}
function findAirport(lat, lon) {
let best = null, bestDist = Infinity;
for (const ap of AIRPORTS) {
const d = distNm(lat, lon, ap.lat, ap.lon);
if (d < ap.r && d < bestDist) { best = ap; bestDist = d; }
}
return best;
}
function headingToCompass(deg) {
const d = ['N','NNE','NE','ENE','E','ESE','SE','SSE','S','SSW','SW','WSW','W','WNW','NW','NNW'];
return d[Math.round(deg / 22.5) % 16];
}
function timeSince(ts) {
const sec = Math.floor((Date.now() - ts) / 1000);
if (sec < 60) return 'just now';
if (sec < 3600) return `${Math.floor(sec/60)}m ago`;
if (sec < 86400) return `${Math.floor(sec/3600)}h ago`;
return `${Math.floor(sec/86400)}d ago`;
}
// ── RENDER ──
function renderStatus(ac) {
const dot = document.getElementById('statusDot');
const label = document.getElementById('statusLabel');
const main = document.getElementById('statusMain');
const detail = document.getElementById('statusDetail');
const meta = document.getElementById('statusMeta');
main.classList.remove('shimmer');
if (!ac) {
dot.className = 'status-dot unknown';
label.textContent = 'Transponder Off';
if (lastKnown && lastKnown.time) {
const ago = timeSince(lastKnown.time);
main.textContent = lastKnown.airport ? `Last seen at ${lastKnown.airport}` : 'Last known position recorded';
detail.innerHTML = `Transponder went quiet ${ago}. The plane is likely parked at a gate with engines off.`;
detail.innerHTML += `<div class="stale-badge">Cached · ${ago}</div>`;
meta.style.display = 'none';
if (lastKnown.lat && lastKnown.lon) showMap(lastKnown.lat, lastKnown.lon);
} else {
main.textContent = 'Not currently broadcasting';
detail.textContent = 'The transponder is off — the plane is likely parked at a gate. Check FlightAware for the most recent flight info.';
meta.style.display = 'none';
}
return;
}
const isGround = ac.alt_baro === 'ground' || ac.alt_baro === 0;
const lat = ac.lat, lon = ac.lon;
const callsign = (ac.flight || '').trim();
const gs = ac.gs, track = ac.track, alt = ac.alt_baro;
const airport = (lat && lon) ? findAirport(lat, lon) : null;
// Cache
lastKnown = {
lat, lon,
airport: airport ? airport.name : null,
airportCode: airport ? airport.code : null,
time: Date.now(),
callsign
};
try { localStorage.setItem('xaat_last', JSON.stringify(lastKnown)); } catch(e) {}
if (isGround && airport) {
dot.className = 'status-dot ground';
label.textContent = 'On the Ground';
main.textContent = `At ${airport.name}`;
detail.textContent = callsign
? `Operating as ${callsign}. On the ground — possibly at a gate, taxiing, or on the ramp.`
: 'On the ground at this airport.';
} else if (isGround) {
dot.className = 'status-dot ground';
label.textContent = 'On the Ground';
main.textContent = 'On the ground';
detail.textContent = lat && lon
? `Position: ${lat.toFixed(3)}°, ${lon.toFixed(3)}°. Not matched to a known airport.`
: 'Ground mode detected but no position available.';
} else {
dot.className = 'status-dot live';
label.textContent = 'In Flight';
main.textContent = airport ? `Near ${airport.name}` : 'In the air';
let parts = [];
if (callsign) parts.push(`Flying as ${callsign}`);
if (alt && alt !== 'ground') parts.push(`at ${Number(alt).toLocaleString()} ft`);
if (gs) parts.push(`${Math.round(gs)} kts`);
detail.textContent = parts.join(' · ') || 'Airborne — tracking live.';
}
meta.style.display = 'grid';
document.getElementById('metaCallsign').textContent = callsign || '—';
document.getElementById('metaAlt').textContent = isGround ? 'Ground' : (alt ? `${Number(alt).toLocaleString()} ft` : '—');
document.getElementById('metaSpeed').textContent = gs ? `${Math.round(gs)} kts` : '—';
document.getElementById('metaHeading').textContent = track != null ? `${Math.round(track)}° ${headingToCompass(track)}` : '—';
if (lat && lon) showMap(lat, lon);
}
function showMap(lat, lon) {
const c = document.getElementById('mapContainer');
c.innerHTML = `<iframe
src="https://globe.airplanes.live/?icao=${ICAO_HEX}&zoom=11&hideSideBar&hideButtons&lat=${lat}&lon=${lon}"
loading="lazy"
title="Live aircraft position map"
allow="fullscreen"
></iframe>`;
}
// ── FETCH ──
async function fetchStatus() {
const btn = document.getElementById('refreshBtn');
btn.classList.add('spinning');
setTimeout(() => btn.classList.remove('spinning'), 800);
try {
const res = await fetch(API_URL);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const data = await res.json();
renderStatus(data.ac && data.ac.length > 0 ? data.ac[0] : null);
} catch (err) {
console.error('Fetch error:', err);
renderStatus(null);
}
}
// ── CHECK MY AIRPORT ──
function checkMyAirport() {
const btn = document.getElementById('btnCheck');
const banner = document.getElementById('nearbyBanner');
if (!navigator.geolocation) {
showBanner('not-here', 'Location unavailable', 'Your browser doesn\'t support geolocation.');
return;
}
btn.disabled = true;
btn.textContent = 'Getting your location...';
navigator.geolocation.getCurrentPosition(
(pos) => {
btn.disabled = false;
btn.textContent = '📍 Am I near this plane?';
const uLat = pos.coords.latitude, uLon = pos.coords.longitude;
if (!lastKnown || !lastKnown.lat) {
showBanner('not-here', 'Can\'t compare right now', 'No current position for the plane. Transponder may be off.');
return;
}
const dist = distNm(uLat, uLon, lastKnown.lat, lastKnown.lon);
const miles = Math.round(dist * 1.15078);
if (dist < 1.5) {
banner.className = 'nearby-banner here';
banner.style.display = 'block';
banner.innerHTML = `
<span class="nearby-emoji">🐟</span>
<div class="nearby-title">The Salmon People plane is here!</div>
<div class="nearby-detail">${dist < 0.3 ? 'You\'re right next to it!' : `About ${miles} mile${miles !== 1 ? 's' : ''} away.`} Look for the blue and pink formline salmon livery!<br>Check <a href="https://www.flightaware.com/live/flight/N559AS" target="_blank" style="color:white;text-decoration:underline;">FlightAware</a> for the gate number.</div>`;
} else if (dist < 8) {
showBanner('not-here', 'Close, but not quite', `About ${miles} miles from you${lastKnown.airport ? ` at ${lastKnown.airport}` : ''}.`);
} else {
const where = lastKnown.airport || `${lastKnown.lat.toFixed(1)}°, ${lastKnown.lon.toFixed(1)}°`;
showBanner('not-here', 'Not at your airport', `The plane is at ${where} — about ${miles.toLocaleString()} miles away.`);
}
},
() => {
btn.disabled = false;
btn.textContent = '📍 Am I near this plane?';
showBanner('not-here', 'Location access denied', 'Enable location access in your browser settings to use this feature.');
},
{ enableHighAccuracy: false, timeout: 10000, maximumAge: 60000 }
);
}
function showBanner(cls, title, desc) {
const banner = document.getElementById('nearbyBanner');
banner.className = `nearby-banner ${cls}`;
banner.style.display = 'block';
banner.innerHTML = `<div class="nearby-title">${title}</div><div class="nearby-detail">${desc}</div>`;
}
// ── INIT ──
fetchStatus();
autoRefresh = setInterval(fetchStatus, REFRESH_INTERVAL);
document.addEventListener('visibilitychange', () => {
if (document.hidden) {
clearInterval(autoRefresh);
} else {
fetchStatus();
autoRefresh = setInterval(fetchStatus, REFRESH_INTERVAL);
}
});
</script>
</body>
</html>