-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcastnet_map.html
More file actions
716 lines (624 loc) · 22.8 KB
/
Copy pathcastnet_map.html
File metadata and controls
716 lines (624 loc) · 22.8 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CASTNET — Civilian IMSI Catcher Detection Network</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.9.4/leaflet.min.css"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.9.4/leaflet.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet.heat/0.2.0/leaflet-heat.js"></script>
<style>
@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Orbitron:wght@400;700;900&display=swap');
:root {
--green: #00ff41;
--green-dim: #00aa2a;
--green-dark: #003d0f;
--red: #ff2a2a;
--amber: #ffaa00;
--blue: #00aaff;
--bg: #000d02;
--panel: #000f03;
--border: #004010;
--text: #00cc33;
--text-dim: #007a1e;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
background: var(--bg);
color: var(--text);
font-family: 'Share Tech Mono', monospace;
height: 100vh;
display: flex;
flex-direction: column;
overflow: hidden;
}
/* Scanline overlay */
body::after {
content: '';
position: fixed;
inset: 0;
background: repeating-linear-gradient(
0deg,
transparent,
transparent 2px,
rgba(0,0,0,0.08) 2px,
rgba(0,0,0,0.08) 4px
);
pointer-events: none;
z-index: 9999;
}
/* ── Header ── */
header {
padding: 8px 16px;
border-bottom: 1px solid var(--border);
display: flex;
align-items: center;
justify-content: space-between;
flex-shrink: 0;
background: var(--panel);
}
.logo {
font-family: 'Orbitron', monospace;
font-weight: 900;
font-size: 1.1rem;
letter-spacing: 0.3em;
color: var(--green);
text-shadow: 0 0 10px var(--green), 0 0 20px var(--green-dim);
}
.tagline {
font-size: 0.65rem;
color: var(--text-dim);
letter-spacing: 0.1em;
}
.status-bar {
display: flex;
gap: 20px;
align-items: center;
font-size: 0.7rem;
}
.status-item {
display: flex;
flex-direction: column;
align-items: flex-end;
}
.status-label { color: var(--text-dim); font-size: 0.6rem; letter-spacing: 0.1em; }
.status-value { color: var(--green); font-size: 0.85rem; font-weight: bold; }
.status-value.alert { color: var(--red); animation: blink 1s infinite; }
.status-value.amber { color: var(--amber); }
.status-value.blue { color: var(--blue); }
@keyframes blink {
0%, 100% { opacity: 1; }
50% { opacity: 0.3; }
}
/* ── Main layout ── */
.main {
display: flex;
flex: 1;
overflow: hidden;
}
/* ── Sidebar ── */
.sidebar {
width: 290px;
flex-shrink: 0;
border-right: 1px solid var(--border);
display: flex;
flex-direction: column;
background: var(--panel);
overflow: hidden;
}
.sidebar-section {
border-bottom: 1px solid var(--border);
padding: 10px 12px;
}
.sidebar-section h3 {
font-family: 'Orbitron', monospace;
font-size: 0.6rem;
letter-spacing: 0.2em;
color: var(--text-dim);
margin-bottom: 8px;
text-transform: uppercase;
}
/* Nodes */
.node-list { display: flex; flex-direction: column; gap: 6px; }
.node-card {
border: 1px solid var(--border);
padding: 6px 8px;
background: var(--green-dark);
position: relative;
overflow: hidden;
}
.node-card::before {
content: '';
position: absolute;
left: 0; top: 0; bottom: 0;
width: 3px;
background: var(--green);
box-shadow: 0 0 6px var(--green);
}
.node-name { font-size: 0.75rem; color: var(--green); margin-bottom: 2px; }
.node-stats { font-size: 0.62rem; color: var(--text-dim); display: flex; gap: 10px; }
.node-stat-val { color: var(--green); }
/* CID reference panel */
.cid-list {
max-height: 120px;
overflow-y: auto;
font-size: 0.6rem;
}
.cid-list::-webkit-scrollbar { width: 3px; }
.cid-list::-webkit-scrollbar-thumb { background: var(--border); }
.cid-entry {
display: flex;
justify-content: space-between;
padding: 1px 0;
border-bottom: 1px solid rgba(0,64,16,0.2);
}
.cid-num { color: var(--red); }
.cid-label { color: var(--text-dim); }
/* Detection feed */
.feed {
flex: 1;
overflow-y: auto;
padding: 6px 0;
}
.feed::-webkit-scrollbar { width: 4px; }
.feed::-webkit-scrollbar-track { background: var(--bg); }
.feed::-webkit-scrollbar-thumb { background: var(--border); }
.feed-item {
padding: 5px 12px;
border-bottom: 1px solid rgba(0,64,16,0.3);
font-size: 0.62rem;
line-height: 1.5;
animation: fadeIn 0.3s ease;
}
.feed-item.rogue { background: rgba(255,42,42,0.05); }
.feed-item.watchlist { background: rgba(255,170,0,0.04); }
@keyframes fadeIn {
from { opacity: 0; transform: translateX(-4px); }
to { opacity: 1; transform: translateX(0); }
}
.feed-cid { color: var(--red); font-weight: bold; }
.feed-watchlist { color: var(--amber); font-weight: bold; }
.feed-clean { color: var(--text-dim); }
.feed-ts { color: var(--text-dim); font-size: 0.55rem; }
.feed-node { color: var(--amber); }
.feed-rsrp { color: var(--green-dim); }
/* ── Map ── */
#map {
flex: 1;
background: #000d02;
}
.leaflet-container { background: #000d02; font-family: 'Share Tech Mono', monospace; }
.leaflet-tile { filter: invert(1) hue-rotate(90deg) saturate(0.4) brightness(0.4); }
.leaflet-popup-content-wrapper {
background: var(--panel);
border: 1px solid var(--green);
color: var(--text);
border-radius: 0;
box-shadow: 0 0 12px rgba(0,255,65,0.3);
font-family: 'Share Tech Mono', monospace;
font-size: 0.7rem;
}
.leaflet-popup-tip { background: var(--panel); }
.leaflet-popup-close-button { color: var(--green) !important; }
/* ── Bottom bar ── */
.bottom-bar {
padding: 4px 16px;
border-top: 1px solid var(--border);
font-size: 0.6rem;
color: var(--text-dim);
display: flex;
justify-content: space-between;
flex-shrink: 0;
background: var(--panel);
}
.pulse {
display: inline-block;
width: 6px; height: 6px;
background: var(--green);
border-radius: 50%;
margin-right: 5px;
animation: pulse 2s infinite;
box-shadow: 0 0 4px var(--green);
vertical-align: middle;
}
@keyframes pulse {
0%, 100% { opacity: 1; transform: scale(1); }
50% { opacity: 0.4; transform: scale(0.8); }
}
/* Loading screen */
.loading {
position: absolute;
inset: 0;
display: flex;
align-items: center;
justify-content: center;
background: var(--bg);
z-index: 1000;
font-family: 'Orbitron', monospace;
font-size: 0.8rem;
letter-spacing: 0.3em;
color: var(--green);
text-shadow: 0 0 10px var(--green);
flex-direction: column;
gap: 12px;
}
.loading-bar {
width: 200px;
height: 2px;
background: var(--border);
position: relative;
overflow: hidden;
}
.loading-bar::after {
content: '';
position: absolute;
left: -40%;
width: 40%;
height: 100%;
background: var(--green);
animation: loading 1s infinite linear;
box-shadow: 0 0 8px var(--green);
}
@keyframes loading { to { left: 100%; } }
/* API offline banner */
.offline-banner {
display: none;
background: rgba(255,42,42,0.15);
border-bottom: 1px solid var(--red);
padding: 4px 16px;
font-size: 0.65rem;
color: var(--red);
text-align: center;
flex-shrink: 0;
}
</style>
</head>
<body>
<div class="loading" id="loading">
<div>CASTNET INITIALISING</div>
<div class="loading-bar"></div>
<div style="font-size:0.55rem;color:var(--text-dim)">CONNECTING TO CENTRAL API</div>
</div>
<header>
<div>
<div class="logo">⬡ CASTNET</div>
<div class="tagline">CIVILIAN IMSI CATCHER DETECTION NETWORK — CRANBOURNE EAST VIC — v0.1.1</div>
</div>
<div class="status-bar">
<div class="status-item">
<span class="status-label">NODES</span>
<span class="status-value" id="hdr-nodes">--</span>
</div>
<div class="status-item">
<span class="status-label">ROGUE DETECTIONS</span>
<span class="status-value alert" id="hdr-rogue">--</span>
</div>
<div class="status-item">
<span class="status-label">UNIQUE CIDs</span>
<span class="status-value amber" id="hdr-cids">--</span>
</div>
<div class="status-item">
<span class="status-label">KNOWN ROGUE</span>
<span class="status-value blue" id="hdr-known">18</span>
</div>
<div class="status-item">
<span class="status-label">TOTAL EVENTS</span>
<span class="status-value" id="hdr-total">--</span>
</div>
<button id="heat-toggle" onclick="toggleHeat()" style="
background:transparent;border:1px solid #004010;color:#00aa2a;
font-family:inherit;font-size:0.75em;padding:4px 10px;cursor:pointer;
letter-spacing:1px;" title="Toggle RSRP heat map">
[HEAT: OFF]
</button>
</div>
</header>
<div class="offline-banner" id="offline-banner">
⚠ API OFFLINE — Displaying static known rogue CID data only
</div>
<div class="main">
<div class="sidebar">
<div class="sidebar-section">
<h3>▸ Active Nodes</h3>
<div class="node-list" id="node-list">
<div style="color:var(--text-dim);font-size:0.65rem">No nodes connected</div>
</div>
</div>
<div class="sidebar-section">
<h3>▸ Known Rogue CIDs (18)</h3>
<div class="cid-list" id="cid-reference"></div>
</div>
<div class="sidebar-section" style="padding-bottom:4px">
<h3>▸ Detection Feed</h3>
</div>
<div class="feed" id="feed">
<div style="color:var(--text-dim);font-size:0.65rem;padding:8px 12px">Waiting for detections...</div>
</div>
</div>
<div id="map"></div>
</div>
<div class="bottom-bar">
<div><span class="pulse"></span>LIVE — AUTO-REFRESH 30s</div>
<div id="last-update">--</div>
<div>CASTNET v0.1.1 — Because Stingrays are fish too. 🎣</div>
</div>
<script>
// ── Configuration ─────────────────────────────────────────────────────────────
const API_BASE = ''; // empty = same origin (Flask serves this file)
const REFRESH_MS = 30000;
const HOME_LAT = -38.1135;
const HOME_LON = 145.2830;
const HOME_LABEL = 'Home — Cranbourne East';
// Known rogue CIDs — KEEP IN SYNC with castnet_api.py and castnet_node.py
// Updated May 2026: 18 confirmed CIDs across Telstra TAC=12385 and Vodafone TAC=30336
const ROGUE_CID_DATA = [
// Telstra AU — TAC 12385
{ ci: 137713195, label: 'Telstra TAC=12385', note: 'Highest obs count' },
{ ci: 137713175, label: 'Telstra TAC=12385', note: 'Prendergast Ave 331m' },
{ ci: 137713165, label: 'Telstra TAC=12385', note: 'Confirmed' },
{ ci: 137713155, label: 'Telstra TAC=12385', note: 'Confirmed' },
{ ci: 135836191, label: 'Telstra TAC=12385', note: 'Collison Rd 912m' },
{ ci: 135836171, label: 'Telstra TAC=12385', note: 'Casey Fields 2424m' },
{ ci: 135836161, label: 'Telstra TAC=12385', note: 'Added May 2026' },
// Vodafone AU — TAC 30336
{ ci: 8409357, label: 'Vodafone TAC=30336', note: 'Highest Voda obs' },
{ ci: 8409367, label: 'Vodafone TAC=30336', note: 'Confirmed' },
{ ci: 8409387, label: 'Vodafone TAC=30336', note: 'Confirmed' },
{ ci: 8409397, label: 'Vodafone TAC=30336', note: 'Anomalous sub-2s' },
{ ci: 8435470, label: 'Vodafone TAC=30336', note: 'Added May 2026' },
{ ci: 8435480, label: 'Vodafone TAC=30336', note: 'Confirmed' },
// Post-ACMA visit — appeared 8 May 2026
{ ci: 8666381, label: 'Post-ACMA May 8', note: 'Zero OpenCelliD hits' },
{ ci: 8666391, label: 'Post-ACMA May 8', note: 'Zero OpenCelliD hits' },
{ ci: 8666411, label: 'Post-ACMA May 8', note: 'Zero OpenCelliD hits' },
];
const ROGUE_CIDS = new Set(ROGUE_CID_DATA.map(d => d.ci));
// Known OpenCelliD geo-locations for static fallback display
const KNOWN_LOCATIONS = [
{ ci: 137713175, lat: -38.1108, lon: 145.2856, label: 'Prendergast Ave, CE', radius: 331, note: 'OpenCelliD Apr 2026' },
{ ci: 135836191, lat: -38.1090, lon: 145.2910, label: 'Collison Rd, CE', radius: 912, note: 'OpenCelliD Oct 2025' },
{ ci: 135836171, lat: -38.0990, lon: 145.3050, label: 'Casey Fields area', radius: 2424, note: 'OpenCelliD Aug 2025' },
];
// ── Map setup ─────────────────────────────────────────────────────────────────
const map = L.map('map', {
center: [HOME_LAT, HOME_LON],
zoom: 14,
zoomControl: true,
attributionControl: false,
});
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
}).addTo(map);
// Home marker
const homeIcon = L.divIcon({
html: `<div style="
width:12px;height:12px;
background:#00ff41;border:2px solid #000;border-radius:50%;
box-shadow:0 0 8px #00ff41,0 0 16px #00aa2a;
"></div>`,
iconSize: [12,12], iconAnchor: [6,6], className: '',
});
L.marker([HOME_LAT, HOME_LON], { icon: homeIcon })
.addTo(map)
.bindPopup(`<b style="color:#00ff41">${HOME_LABEL}</b><br>Investigation base`);
const markerMap = {};
// ── Marker icons ──────────────────────────────────────────────────────────────
function rogueIcon(rsrp) {
const intensity = rsrp ? Math.min(1, Math.max(0.3, (rsrp + 140) / 80)) : 0.5;
const r = Math.round(255 * intensity);
return L.divIcon({
html: `<div style="
width:14px;height:14px;
background:rgb(${r},42,42);border:2px solid #ff2a2a;border-radius:2px;
box-shadow:0 0 8px #ff2a2a,0 0 16px rgba(255,42,42,0.4);
transform:rotate(45deg);
"></div>`,
iconSize: [14,14], iconAnchor: [7,7], className: '',
});
}
function staticRogueIcon() {
return L.divIcon({
html: `<div style="
width:14px;height:14px;
background:#aa1a1a;border:2px solid #ff2a2a;border-radius:2px;
box-shadow:0 0 6px rgba(255,42,42,0.5);
transform:rotate(45deg);opacity:0.7;
"></div>`,
iconSize: [14,14], iconAnchor: [7,7], className: '',
});
}
// ── Static fallback: known OpenCelliD locations ───────────────────────────────
function showStaticKnownLocations() {
KNOWN_LOCATIONS.forEach(loc => {
// Range ring
L.circle([loc.lat, loc.lon], {
radius: loc.radius,
color: '#ff2a2a', fillColor: '#ff2a2a', fillOpacity: 0.07,
weight: 1, dashArray: '4 4',
}).addTo(map);
// Centre marker
L.marker([loc.lat, loc.lon], { icon: staticRogueIcon() })
.addTo(map)
.bindPopup(`
<div style="min-width:160px">
<div style="color:#ff2a2a;font-weight:bold;margin-bottom:4px">🚨 ROGUE CID=${loc.ci}</div>
<div>${loc.label}</div>
<div style="color:#007a1e;font-size:0.9em">${loc.note}</div>
<div style="color:#007a1e;font-size:0.9em">±${loc.radius}m radius</div>
<div style="color:#ffaa00;margin-top:4px;font-size:0.85em">⚠ Static — no live GPS data yet</div>
</div>
`);
});
}
// ── Populate CID reference sidebar ───────────────────────────────────────────
function populateCidReference() {
const el = document.getElementById('cid-reference');
el.innerHTML = '';
ROGUE_CID_DATA.forEach(d => {
const row = document.createElement('div');
row.className = 'cid-entry';
row.innerHTML = `
<span class="cid-num">${d.ci}</span>
<span class="cid-label">${d.note}</span>
`;
el.appendChild(row);
});
}
// ── Fetch: summary ────────────────────────────────────────────────────────────
async function fetchSummary() {
const res = await fetch(`${API_BASE}/api/v1/summary`);
const data = await res.json();
document.getElementById('hdr-nodes').textContent = data.active_nodes ?? '--';
document.getElementById('hdr-rogue').textContent = data.rogue_detections ?? '--';
document.getElementById('hdr-cids').textContent = data.unique_rogue_cids ?? '--';
document.getElementById('hdr-known').textContent = data.known_rogue_cid_count ?? ROGUE_CID_DATA.length;
document.getElementById('hdr-total').textContent = data.total_events ?? '--';
const nodeList = document.getElementById('node-list');
nodeList.innerHTML = '';
const nodes = data.nodes || [];
if (nodes.length === 0) {
nodeList.innerHTML = '<div style="color:var(--text-dim);font-size:0.65rem">No nodes connected</div>';
} else {
nodes.forEach(n => {
const age = Math.round((Date.now() - new Date(n.last_seen)) / 60000);
const card = document.createElement('div');
card.className = 'node-card';
card.innerHTML = `
<div class="node-name">▸ ${n.node_id}</div>
<div class="node-stats">
<span>HITS: <span class="node-stat-val">${n.rogue_hits}</span></span>
<span>SCANS: <span class="node-stat-val">${n.total_scans}</span></span>
<span>LAST: <span class="node-stat-val">${age}m ago</span></span>
</div>`;
nodeList.appendChild(card);
});
}
return data;
}
// ── Fetch: detections ────────────────────────────────────────────────────────
async function fetchDetections() {
const res = await fetch(`${API_BASE}/api/v1/detections?hours=24&rogue_only=true`);
const data = await res.json();
const feed = document.getElementById('feed');
feed.innerHTML = '';
if (data.length === 0) {
feed.innerHTML = '<div style="color:var(--text-dim);font-size:0.65rem;padding:8px 12px">No rogue detections in last 24h</div>';
return data;
}
data.slice(0, 50).forEach(d => {
const item = document.createElement('div');
item.className = 'feed-item rogue';
const ts = new Date(d.timestamp).toLocaleTimeString('en-AU');
item.innerHTML = `
<div><span class="feed-cid">🚨 CID=${d.ci}</span> <span class="feed-rsrp">${d.rsrp ?? '?'}dBm</span></div>
<div><span class="feed-node">${d.node_id}</span> <span class="feed-ts">${ts}</span></div>`;
feed.appendChild(item);
});
return data;
}
// ── Fetch: map GeoJSON ────────────────────────────────────────────────────────
// -- RSRP Heat layer -----------------------------------------------------------
let heatLayer = null;
let heatEnabled = false;
function toggleHeat() {
heatEnabled = !heatEnabled;
document.getElementById('heat-toggle').textContent =
heatEnabled ? '[HEAT: ON]' : '[HEAT: OFF]';
document.getElementById('heat-toggle').style.color =
heatEnabled ? '#ff2a2a' : '#00aa2a';
if (!heatEnabled && heatLayer) {
map.removeLayer(heatLayer);
heatLayer = null;
}
}
function updateHeatLayer(features) {
if (!heatEnabled) return;
if (heatLayer) map.removeLayer(heatLayer);
// Convert RSRP to intensity -- RSRP range typically -140 to -44 dBm
// Stronger signal (less negative) = higher intensity = hotter on map
const points = features
.filter(f => f.geometry && f.properties.rsrp)
.map(f => {
const rsrp = parseFloat(f.properties.rsrp);
const intensity = Math.max(0, Math.min(1, (rsrp + 140) / 96));
return [
f.geometry.coordinates[1],
f.geometry.coordinates[0],
intensity
];
});
if (points.length === 0) return;
heatLayer = L.heatLayer(points, {
radius: 35,
blur: 25,
maxZoom: 17,
max: 1.0,
gradient: { 0.0: '#003d0f', 0.3: '#ffaa00', 0.6: '#ff6600', 1.0: '#ff2a2a' }
}).addTo(map);
}
async function fetchMap() {
const res = await fetch(`${API_BASE}/api/v1/map`);
const data = await res.json();
// Clear existing live markers
Object.values(markerMap).forEach(m => map.removeLayer(m));
Object.keys(markerMap).forEach(k => delete markerMap[k]);
if (!data.features || data.features.length === 0) {
// No live GPS data yet — static known locations already shown on boot
return;
}
// Group by CID — show one marker per CID at most recent location
const byCid = {};
data.features.forEach(f => {
const ci = f.properties.ci;
if (!byCid[ci]) byCid[ci] = [];
byCid[ci].push(f);
});
Object.entries(byCid).forEach(([ci, features]) => {
const latest = features[0];
const coords = latest.geometry.coordinates;
const p = latest.properties;
const lat = coords[1];
const lon = coords[0];
const marker = L.marker([lat, lon], { icon: rogueIcon(p.rsrp) })
.addTo(map)
.bindPopup(`
<div style="min-width:160px">
<div style="color:#ff2a2a;font-weight:bold;margin-bottom:4px">🚨 ROGUE CID=${ci}</div>
<div>TAC: ${p.tac ?? '?'}</div>
<div>RSRP: ${p.rsrp ?? '?'} dBm</div>
<div>TA: ${p.timing_advance ?? '?'}</div>
<div>Node: <span style="color:#ffaa00">${p.node_id}</span></div>
<div>Detections: <span style="color:#00ff41">${features.length}</span></div>
<div style="color:#007a1e;font-size:0.9em;margin-top:4px">
${new Date(p.timestamp).toLocaleString('en-AU')}
</div>
</div>
`);
markerMap[ci] = marker;
});
updateHeatLayer(data.features);
}
// ── Main refresh ──────────────────────────────────────────────────────────────
async function refresh() {
try {
await Promise.all([fetchSummary(), fetchDetections(), fetchMap()]);
document.getElementById('offline-banner').style.display = 'none';
document.getElementById('last-update').textContent =
'LAST UPDATE: ' + new Date().toLocaleTimeString('en-AU');
} catch (e) {
document.getElementById('offline-banner').style.display = 'block';
document.getElementById('last-update').textContent = 'API OFFLINE';
console.warn('API unreachable:', e.message);
}
}
// ── Boot ──────────────────────────────────────────────────────────────────────
window.addEventListener('load', async () => {
populateCidReference();
showStaticKnownLocations(); // always show known geo-locations
await refresh();
document.getElementById('loading').style.display = 'none';
setInterval(refresh, REFRESH_MS);
});
</script>
</body>
</html>