-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.html
More file actions
493 lines (432 loc) · 26.6 KB
/
Copy pathtemplate.html
File metadata and controls
493 lines (432 loc) · 26.6 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
<!DOCTYPE html>
<html lang="es" class="dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>IP Flame! - Wall of Shame</title>
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' fill='none'%3E%3Crect width='32' height='32' rx='6' fill='%230a0a0f'/%3E%3Crect x='9' y='9' width='14' height='14' rx='2' stroke='%2300d4ff' stroke-width='1.5' fill='%2312121a'/%3E%3Crect x='12' y='12' width='8' height='8' rx='1' stroke='%2300d4ff' stroke-width='0.75' opacity='0.5'/%3E%3Ccircle cx='16' cy='16' r='1.5' fill='%2300d4ff'/%3E%3Cline x1='13' y1='5' x2='13' y2='9' stroke='%2300d4ff' stroke-width='1' stroke-linecap='round'/%3E%3Cline x1='16' y1='5' x2='16' y2='9' stroke='%2300d4ff' stroke-width='1' stroke-linecap='round'/%3E%3Cline x1='19' y1='5' x2='19' y2='9' stroke='%2300d4ff' stroke-width='1' stroke-linecap='round'/%3E%3Cline x1='13' y1='23' x2='13' y2='27' stroke='%2300d4ff' stroke-width='1' stroke-linecap='round'/%3E%3Cline x1='16' y1='23' x2='16' y2='27' stroke='%2300d4ff' stroke-width='1' stroke-linecap='round'/%3E%3Cline x1='19' y1='23' x2='19' y2='27' stroke='%2300d4ff' stroke-width='1' stroke-linecap='round'/%3E%3Cline x1='5' y1='13' x2='9' y2='13' stroke='%2300d4ff' stroke-width='1' stroke-linecap='round'/%3E%3Cline x1='5' y1='16' x2='9' y2='16' stroke='%2300d4ff' stroke-width='1' stroke-linecap='round'/%3E%3Cline x1='5' y1='19' x2='9' y2='19' stroke='%2300d4ff' stroke-width='1' stroke-linecap='round'/%3E%3Cline x1='23' y1='13' x2='27' y2='13' stroke='%2300d4ff' stroke-width='1' stroke-linecap='round'/%3E%3Cline x1='23' y1='16' x2='27' y2='16' stroke='%2300d4ff' stroke-width='1' stroke-linecap='round'/%3E%3Cline x1='23' y1='19' x2='27' y2='19' stroke='%2300d4ff' stroke-width='1' stroke-linecap='round'/%3E%3C/svg%3E">
<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=Space+Mono:ital,wght@0,400;0,700;1,400;1,700&family=Syne:wght@400..800&display=swap" rel="stylesheet">
<script src="https://cdn.tailwindcss.com"></script>
<style>
body { font-family: 'Syne', sans-serif; background: #0a0a0d; }
.font-mono { font-family: 'Space Mono', monospace; }
.glow-red { box-shadow: 0 0 20px rgba(239, 68, 68, 0.35); }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #0a0a0d; }
::-webkit-scrollbar-thumb { background: #2d2d35; border-radius: 3px; }
.risk-low { background: rgba(34,197,94,0.12); color: #4ade80; border: 1px solid rgba(34,197,94,0.25); }
.risk-medium { background: rgba(234,179,8,0.12); color: #facc15; border: 1px solid rgba(234,179,8,0.25); }
.risk-high { background: rgba(249,115,22,0.12); color: #fb923c; border: 1px solid rgba(249,115,22,0.25); }
.risk-critical { background: rgba(239,68,68,0.15); color: #f87171; border: 1px solid rgba(239,68,68,0.3); }
.badge-low { background: rgba(34,197,94,0.12); color: #4ade80; border: 1px solid rgba(34,197,94,0.25); }
.badge-med { background: rgba(234,179,8,0.12); color: #facc15; border: 1px solid rgba(234,179,8,0.25); }
.badge-high { background: rgba(249,115,22,0.12); color: #fb923c; border: 1px solid rgba(249,115,22,0.25); }
.badge-crit { background: rgba(239,68,68,0.15); color: #f87171; border: 1px solid rgba(239,68,68,0.3); }
.pattern-tag {
display: inline-block; background: rgba(139,92,246,0.12); color: #a78bfa;
border: 1px solid rgba(139,92,246,0.25); border-radius: 4px;
padding: 1px 5px; font-size: 9px; font-family: 'Space Mono', monospace;
margin: 1px; white-space: nowrap;
}
.threat-tag {
display: inline-block; border-radius: 4px; padding: 1px 5px;
font-size: 8px; font-family: 'Space Mono', monospace;
margin: 1px; font-weight: bold; text-transform: uppercase;
}
.threat-tor { background: rgba(239,68,68,0.2); color: #f87171; border: 1px solid rgba(239,68,68,0.4); }
.threat-vpn { background: rgba(249,115,22,0.2); color: #fb923c; border: 1px solid rgba(249,115,22,0.4); }
.threat-proxy { background: rgba(234,179,8,0.2); color: #facc15; border: 1px solid rgba(234,179,8,0.4); }
.threat-dc { background: rgba(99,102,241,0.15); color: #818cf8; border: 1px solid rgba(99,102,241,0.3); }
.status-2xx { color: #4ade80; } .status-3xx { color: #60a5fa; }
.status-4xx { color: #facc15; } .status-5xx { color: #f87171; }
.expand-btn { cursor: pointer; user-select: none; }
.expand-btn:hover { background: #111118; }
.hit-detail-row { display: none; }
.hit-detail-row.open { display: table-row; }
.req-badge {
display: block; max-width: 220px; overflow: hidden; text-overflow: ellipsis;
white-space: nowrap; background: rgba(239,68,68,0.08); color: #fca5a5;
border: 1px solid rgba(239,68,68,0.2); border-radius: 4px;
padding: 2px 6px; font-family: 'Space Mono', monospace; font-size: 10px;
}
.host-badge {
display: block; max-width: 160px; overflow: hidden; text-overflow: ellipsis;
white-space: nowrap; background: rgba(34,211,238,0.08); color: #67e8f9;
border: 1px solid rgba(34,211,238,0.2); border-radius: 4px;
padding: 2px 6px; font-family: 'Space Mono', monospace; font-size: 10px;
}
.ua-cell {
max-width: 150px; overflow: hidden; text-overflow: ellipsis;
white-space: nowrap; font-family: 'Space Mono', monospace; font-size: 10px;
color: #6b7280;
}
.hits-table { width: 100%; border-collapse: collapse; }
.hits-table th { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: #6b7280; padding: 5px 10px; border-bottom: 1px solid #1f1f28; }
.hits-table td { font-size: 10px; padding: 4px 10px; border-bottom: 1px solid #151520; color: #9ca3af; font-family: 'Space Mono', monospace; word-break: break-all; }
.hits-table tr:last-child td { border-bottom: none; }
.hits-table tr:hover td { background: rgba(255,255,255,0.02); }
.stat-card { background: #111116; border: 1px solid #1e1e28; border-radius: 16px; padding: 24px; }
@keyframes ping { 75%, 100% { transform: scale(2); opacity: 0; } }
.animate-ping { animation: ping 1s cubic-bezier(0,0,0.2,1) infinite; }
.risk-bar-bg { background: #1a1a24; border-radius: 4px; height: 5px; width: 60px; overflow: hidden; }
.risk-bar-fill { height: 100%; border-radius: 4px; }
.risk-fill-low { background: #4ade80; } .risk-fill-medium { background: #facc15; }
.risk-fill-high { background: #fb923c; } .risk-fill-critical { background: #f87171; }
.filter-btn { cursor: pointer; transition: all 0.15s; }
.filter-btn:hover { transform: scale(1.05); }
/* Paginacion */
.page-btn {
cursor: pointer; padding: 4px 10px; border-radius: 6px; font-size: 12px;
font-family: 'Space Mono', monospace; border: 1px solid #1e1e28;
background: #111116; color: #9ca3af; transition: all 0.15s;
}
.page-btn:hover { background: #1e1e28; color: #fff; }
.page-btn.active { background: rgba(139,92,246,0.2); color: #a78bfa; border-color: rgba(139,92,246,0.4); }
.page-btn:disabled { opacity: 0.3; cursor: default; }
/* Tabla compacta */
.main-table th { padding: 10px 8px; font-size: 10px; }
.main-table td { padding: 8px 8px; }
</style>
</head>
<body class="text-gray-300 p-4 md:p-8">
<div class="max-w-[1920px] mx-auto">
<!-- HEADER -->
<div class="flex flex-col items-center mb-8 text-center">
<div class="relative mb-4">
<svg class="w-16 h-16 text-red-500 glow-red rounded-full p-2 bg-[#111116] border border-red-900/50"
viewBox="0 0 24 24" fill="currentColor">
<path d="M17.66 11.2C17.43 10.9 17.15 10.64 16.89 10.38C16.22 9.78 15.46 9.35 14.82 8.72C13.33 7.26 13 4.85 13.95 3C13 3.23 12.17 3.75 11.46 4.32C8.87 6.4 7.85 10.07 9.07 13.22C9.11 13.32 9.15 13.42 9.15 13.55C9.15 13.77 9 13.97 8.8 14.05C8.57 14.15 8.33 14.09 8.14 13.93C8.08 13.88 8.04 13.83 8 13.76C6.87 12.33 6.69 10.28 7.45 8.64C5.78 10 4.87 12.3 5 14.47C5.06 14.97 5.12 15.47 5.29 15.97C5.43 16.57 5.7 17.17 6 17.7C7.08 19.43 8.95 20.67 10.96 20.92C13.1 21.19 15.39 20.8 17.03 19.32C18.86 17.66 19.5 15 18.56 12.72L18.43 12.46C18.22 12 17.66 11.2 17.66 11.2Z"/>
</svg>
</div>
<h1 class="text-3xl md:text-4xl font-extrabold tracking-tighter text-white mb-1">
IP FLAME! <span class="text-red-500">WALL OF SHAME</span>
</h1>
<p class="text-gray-500 text-sm">Sockets AR — Threat Intelligence Dashboard v3.2</p>
</div>
<!-- STAT CARDS -->
<div class="grid grid-cols-2 md:grid-cols-4 gap-3 mb-6">
<div class="stat-card glow-red text-center">
<p class="text-[10px] text-gray-500 uppercase tracking-widest font-bold mb-1">Threat Actors</p>
<p class="text-4xl font-extrabold text-red-500 font-mono">{{.Total}}</p>
</div>
<div class="stat-card text-center">
<p class="text-[10px] text-gray-500 uppercase tracking-widest font-bold mb-1">Total Hits</p>
<p class="text-4xl font-extrabold text-orange-400 font-mono">{{.TotalHits}}</p>
</div>
<div class="stat-card text-center">
<p class="text-[10px] text-gray-500 uppercase tracking-widest font-bold mb-1">Estado</p>
<div class="flex items-center justify-center gap-2 mt-2">
<span class="relative flex h-2 w-2">
<span class="animate-ping absolute inline-flex h-full w-full rounded-full bg-green-400 opacity-75"></span>
<span class="relative inline-flex rounded-full h-2 w-2 bg-green-500"></span>
</span>
<p class="text-sm font-bold text-green-400">ACTIVO</p>
</div>
</div>
<div class="stat-card text-center">
<p class="text-[10px] text-gray-500 uppercase tracking-widest font-bold mb-1">Ultimo escaneo</p>
<p class="text-sm font-bold text-white mt-1 font-mono">{{.GeneratedAt}}</p>
</div>
</div>
<!-- TOOLBAR: filtros + paginacion -->
<div class="flex flex-wrap gap-2 mb-3 items-center">
<span class="text-[10px] text-gray-500 uppercase tracking-wider font-bold mr-1">Riesgo:</span>
<button onclick="applyFilter('all')" class="filter-btn px-2 py-1 rounded text-[10px] font-mono font-bold bg-[#111116] border border-[#1e1e28] text-gray-400 hover:text-white">TODOS</button>
<button onclick="applyFilter('critical')" class="filter-btn px-2 py-1 rounded text-[10px] font-mono font-bold risk-critical">CRIT</button>
<button onclick="applyFilter('high')" class="filter-btn px-2 py-1 rounded text-[10px] font-mono font-bold risk-high">HIGH</button>
<button onclick="applyFilter('medium')" class="filter-btn px-2 py-1 rounded text-[10px] font-mono font-bold risk-medium">MED</button>
<button onclick="applyFilter('low')" class="filter-btn px-2 py-1 rounded text-[10px] font-mono font-bold risk-low">LOW</button>
<span class="mx-2 text-gray-700">|</span>
<span class="text-[10px] text-gray-500 uppercase tracking-wider font-bold mr-1">País:</span>
<select id="country-filter" onchange="applyCountryFilter()" class="bg-[#111116] border border-[#1e1e28] text-gray-400 text-xs font-mono rounded px-2 py-1 cursor-pointer">
<option value="all">TODOS</option>
</select>
<span class="mx-2 text-gray-700">|</span>
<span class="text-[10px] text-gray-500 uppercase tracking-wider font-bold mr-1">Por pagina:</span>
<select id="page-size" onchange="changePageSize()" class="bg-[#111116] border border-[#1e1e28] text-gray-400 text-xs font-mono rounded px-2 py-1 cursor-pointer">
<option value="25">25</option>
<option value="50" selected>50</option>
<option value="100">100</option>
<option value="250">250</option>
<option value="0">Todos</option>
</select>
<span class="ml-auto text-[10px] text-gray-600 font-mono" id="status-text"></span>
</div>
<!-- PAGINACION TOP -->
<div class="flex justify-center gap-1 mb-3" id="pagination-top"></div>
<!-- TABLA PRINCIPAL -->
<div class="rounded-2xl border border-[#1e1e28] overflow-hidden shadow-2xl">
<div class="bg-[#0d0d12] px-4 py-3 border-b border-[#1e1e28] flex items-center justify-between">
<span class="text-xs font-bold text-gray-400 uppercase tracking-wider">Registro de IPs Maliciosas</span>
<span class="text-[10px] text-gray-600 font-mono">risk score ↓ · click para expandir</span>
</div>
<table class="w-full text-sm text-left main-table" id="actors-table">
<thead class="text-xs text-gray-500 uppercase bg-[#0d0d12] border-b border-[#1e1e28]">
<tr>
<th class="w-6"></th>
<th>IP / Geo</th>
<th class="text-center">Risk</th>
<th class="text-center">Hits</th>
{{if .HasHostData}}<th>Destino</th>{{end}}
<th>Periodo</th>
<th>Patrones</th>
<th>Request</th>
<th>UA</th>
</tr>
</thead>
<tbody id="table-body">
{{range $i, $o := .Actors}}
<tr class="border-b border-[#151520] expand-btn actor-row"
data-risk="{{.RiskLevel}}" data-country="{{.CountryCode}}" data-idx="{{$i}}"
onclick="toggleHits({{$i}})">
<td class="text-center">
<span class="expand-icon text-gray-600 text-[10px]" id="icon-{{$i}}">▶</span>
</td>
<td>
<div class="font-mono font-bold text-white text-xs">{{.IP}}</div>
<div class="text-[10px] text-gray-500">{{if .City}}{{.City}}, {{end}}{{.Country}}</div>
<div class="text-[10px] text-gray-600 font-mono">{{.ISPName}}</div>
<div class="text-[10px] text-gray-700 font-mono">{{.ASN}}</div>
{{if or .IsTor .IsVPN .IsProxy .IsDatacenter}}
<div class="mt-0.5">
{{if .IsTor}}<span class="threat-tag threat-tor">TOR</span>{{end}}
{{if .IsVPN}}<span class="threat-tag threat-vpn">VPN</span>{{end}}
{{if .IsProxy}}<span class="threat-tag threat-proxy">PROXY</span>{{end}}
{{if .IsDatacenter}}<span class="threat-tag threat-dc">DC</span>{{end}}
</div>
{{end}}
</td>
<td class="text-center">
<span class="font-mono font-bold text-sm px-1.5 py-0.5 rounded
{{if eq .RiskLevel "critical"}}risk-critical
{{else if eq .RiskLevel "high"}}risk-high
{{else if eq .RiskLevel "medium"}}risk-medium
{{else}}risk-low{{end}}">{{.RiskScore}}</span>
<div class="text-[8px] uppercase font-bold mt-0.5
{{if eq .RiskLevel "critical"}}text-red-400
{{else if eq .RiskLevel "high"}}text-orange-400
{{else if eq .RiskLevel "medium"}}text-yellow-400
{{else}}text-green-400{{end}}">{{.RiskLevel}}</div>
<div class="risk-bar-bg mx-auto mt-0.5">
<div class="risk-bar-fill
{{if eq .RiskLevel "critical"}}risk-fill-critical
{{else if eq .RiskLevel "high"}}risk-fill-high
{{else if eq .RiskLevel "medium"}}risk-fill-medium
{{else}}risk-fill-low{{end}}"
style="width:{{.RiskScore}}%"></div>
</div>
</td>
<td class="text-center">
<span class="font-mono font-bold text-sm px-2 py-0.5 rounded
{{if gt .HitCount 100}}badge-crit
{{else if gt .HitCount 20}}badge-high
{{else if gt .HitCount 5}}badge-med
{{else}}badge-low{{end}}">{{.HitCount}}</span>
</td>
{{if $.HasHostData}}
<td>
{{if .TopHost}}<span class="host-badge" title="{{.TopHost}}">{{.TopHost}}</span>
{{else}}<span class="text-gray-700 text-xs">-</span>{{end}}
</td>
{{end}}
<td>
{{if .FirstSeen}}
<div class="text-[10px] font-mono text-gray-500 whitespace-nowrap">
{{.FirstSeen}}
{{if ne .FirstSeen .LastSeen}}<br><span class="text-gray-700">↓</span><br>{{.LastSeen}}{{end}}
</div>
{{else}}<span class="text-gray-700 text-xs">-</span>{{end}}
</td>
<td class="max-w-[200px]">
<div class="flex flex-wrap gap-0.5">
{{range .MatchedPatterns}}<span class="pattern-tag">{{.}}</span>{{end}}
</div>
</td>
<td>
<span class="req-badge" title="{{.TopRequest}}">{{.TopRequest}}</span>
</td>
<td>
<div class="ua-cell" title="{{.TopUA}}">{{.TopUA}}</div>
</td>
</tr>
<tr class="hit-detail-row border-b border-[#1a1a24] bg-[#08080c]" id="detail-{{$i}}" data-detail-for="{{$i}}">
<td colspan="{{if $.HasHostData}}9{{else}}8{{end}}" class="p-0">
<div class="px-4 py-3 border-l-2 border-purple-800/50">
<div class="flex items-center justify-between mb-2">
<p class="text-[10px] text-purple-400 font-bold uppercase tracking-wider">
Hits de {{.IP}} — {{.HitCount}} requests
</p>
<div class="flex gap-1">
{{if .IsTor}}<span class="threat-tag threat-tor">TOR</span>{{end}}
{{if .IsVPN}}<span class="threat-tag threat-vpn">VPN</span>{{end}}
{{if .IsProxy}}<span class="threat-tag threat-proxy">PROXY</span>{{end}}
{{if .IsDatacenter}}<span class="threat-tag threat-dc">DC</span>{{end}}
</div>
</div>
<div class="overflow-x-auto max-h-64 overflow-y-auto">
<table class="hits-table">
<thead><tr>
<th>#</th><th>Timestamp</th>
{{if $.HasHostData}}<th>Host</th>{{end}}
<th>Status</th><th>Patron</th><th>Request</th><th>UA</th>
</tr></thead>
<tbody>
{{range $j, $h := .AllHits}}
<tr>
<td class="text-gray-600 w-6">{{$j}}</td>
<td class="text-gray-500 whitespace-nowrap">{{$h.Timestamp}}</td>
{{if $.HasHostData}}<td class="text-cyan-400/70 whitespace-nowrap">{{$h.Host}}</td>{{end}}
<td class="whitespace-nowrap">
<span class="font-bold
{{if hasPrefix $h.StatusCode "2"}}status-2xx
{{else if hasPrefix $h.StatusCode "3"}}status-3xx
{{else if hasPrefix $h.StatusCode "4"}}status-4xx
{{else if hasPrefix $h.StatusCode "5"}}status-5xx
{{else}}text-gray-500{{end}}">{{$h.StatusCode}}</span>
</td>
<td><span class="pattern-tag">{{$h.MatchedPattern}}</span></td>
<td class="text-red-400/80">{{$h.RequestPath}}</td>
<td class="text-gray-500">{{$h.UserAgent}}</td>
</tr>
{{end}}
</tbody>
</table>
</div>
</div>
</td>
</tr>
{{end}}
</tbody>
</table>
</div>
<!-- PAGINACION BOTTOM -->
<div class="flex justify-center gap-1 mt-3" id="pagination-bottom"></div>
<!-- FOOTER -->
<div class="mt-4 text-center text-[10px] text-gray-700 font-mono">
Sockets AR — IP FLAME! v3.2 · {{.GeneratedAt}} · {{.Total}} threat actors · {{.TotalHits}} hits
</div>
</div>
<script>
let currentFilter = 'all';
let currentCountry = 'all';
let currentPage = 1;
let pageSize = 50;
// Cachear todas las filas al inicio
const allRows = Array.from(document.querySelectorAll('.actor-row'));
const allDetails = {};
document.querySelectorAll('.hit-detail-row').forEach(d => {
allDetails[d.dataset.detailFor] = d;
});
// Poblar dropdown de países dinámicamente
(function populateCountryFilter() {
const countries = {};
allRows.forEach(r => {
const code = r.dataset.country;
if (code && code !== '') countries[code] = (countries[code] || 0) + 1;
});
const sorted = Object.entries(countries).sort((a, b) => b[1] - a[1]);
const sel = document.getElementById('country-filter');
sorted.forEach(([code, count]) => {
const opt = document.createElement('option');
opt.value = code;
opt.textContent = code + ' (' + count + ')';
sel.appendChild(opt);
});
})();
function toggleHits(idx) {
const row = document.getElementById('detail-' + idx);
const icon = document.getElementById('icon-' + idx);
if (!row || !icon) return;
const open = row.classList.toggle('open');
icon.textContent = open ? '\u25BC' : '\u25B6';
icon.style.color = open ? '#a78bfa' : '';
}
function getFilteredRows() {
return allRows.filter(r => {
const riskOk = currentFilter === 'all' || r.dataset.risk === currentFilter;
const countryOk = currentCountry === 'all' || r.dataset.country === currentCountry;
return riskOk && countryOk;
});
}
function applyFilter(level) {
currentFilter = level;
currentPage = 1;
render();
}
function applyCountryFilter() {
currentCountry = document.getElementById('country-filter').value;
currentPage = 1;
render();
}
function changePageSize() {
pageSize = parseInt(document.getElementById('page-size').value);
currentPage = 1;
render();
}
function goToPage(p) {
currentPage = p;
render();
// Scroll suave al top de la tabla
document.getElementById('actors-table').scrollIntoView({ behavior: 'smooth', block: 'start' });
}
function render() {
const filtered = getFilteredRows();
const total = filtered.length;
const ps = pageSize === 0 ? total : pageSize;
const totalPages = Math.max(1, Math.ceil(total / ps));
if (currentPage > totalPages) currentPage = totalPages;
const start = (currentPage - 1) * ps;
const end = start + ps;
const visible = new Set(filtered.slice(start, end));
// Mostrar/ocultar filas
allRows.forEach(row => {
const show = visible.has(row);
row.style.display = show ? '' : 'none';
const idx = row.dataset.idx;
const detail = allDetails[idx];
if (detail) {
if (!show) {
detail.classList.remove('open');
detail.style.display = 'none';
const icon = document.getElementById('icon-' + idx);
if (icon) { icon.textContent = '\u25B6'; icon.style.color = ''; }
} else {
detail.style.display = '';
}
}
});
// Status text
const riskLabel = currentFilter === 'all' ? '' : ' ' + currentFilter.toUpperCase();
const countryLabel = currentCountry === 'all' ? '' : ' ' + currentCountry;
document.getElementById('status-text').textContent =
total + ' threat actors' + riskLabel + countryLabel + ' | pagina ' + currentPage + '/' + totalPages;
// Renderizar botones de paginacion
renderPagination('pagination-top', totalPages);
renderPagination('pagination-bottom', totalPages);
}
function renderPagination(containerId, totalPages) {
const c = document.getElementById(containerId);
if (totalPages <= 1) { c.innerHTML = ''; return; }
let html = '';
html += '<button class="page-btn" onclick="goToPage(1)" ' + (currentPage===1?'disabled':'') + '>«</button>';
html += '<button class="page-btn" onclick="goToPage('+(currentPage-1)+')" ' + (currentPage===1?'disabled':'') + '>‹</button>';
// Rango de paginas visibles (max 7)
let pStart = Math.max(1, currentPage - 3);
let pEnd = Math.min(totalPages, pStart + 6);
if (pEnd - pStart < 6) pStart = Math.max(1, pEnd - 6);
if (pStart > 1) html += '<span class="text-gray-600 text-xs px-1">...</span>';
for (let p = pStart; p <= pEnd; p++) {
html += '<button class="page-btn' + (p===currentPage?' active':'') + '" onclick="goToPage('+p+')">'+p+'</button>';
}
if (pEnd < totalPages) html += '<span class="text-gray-600 text-xs px-1">...</span>';
html += '<button class="page-btn" onclick="goToPage('+(currentPage+1)+')" ' + (currentPage===totalPages?'disabled':'') + '>›</button>';
html += '<button class="page-btn" onclick="goToPage('+totalPages+')" ' + (currentPage===totalPages?'disabled':'') + '>»</button>';
c.innerHTML = html;
}
// Render inicial
render();
</script>
</body>
</html>