-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom_template_example.html
More file actions
665 lines (601 loc) · 22 KB
/
custom_template_example.html
File metadata and controls
665 lines (601 loc) · 22 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tacview Log Analyzer - Custom Template Example</title>
<style>
/*
==========================================
CUSTOM TEMPLATE EXAMPLE - ENHANCED
==========================================
This is an example custom template for Tacview Log Analyzer with enhanced file picker.
To use this template:
1. Copy this file to the same directory as TacviewLogAnalyzer.exe
2. Rename it to "index.html"
3. Customize the styling and layout as desired
4. Run TacviewLogAnalyzer.exe (will auto-start web interface)
FEATURES INCLUDED:
- 📂 File browser with directory navigation
- 🎨 Custom dark terminal-style theme
- ⚡ Animated UI elements and glow effects
- 📱 Responsive design for mobile/desktop
The template uses Jinja2 syntax for data binding.
All data variables (vm.pilots, vm.overview, etc.) remain the same.
Only the HTML structure and CSS styling can be customized.
==========================================
*/
/* Dark theme with terminal-style aesthetics */
body {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: #00ff41;
font-family: 'Courier New', monospace;
margin: 0;
padding: 1rem;
min-height: 100vh;
}
/* Custom notice banner */
.custom-notice {
background: linear-gradient(45deg, #ff6b35, #f7931e);
color: #000;
padding: 0.8rem;
text-align: center;
font-weight: bold;
border-radius: 8px;
margin-bottom: 1rem;
box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}
h1 {
color: #00ffff;
text-shadow: 0 0 10px #00ffff;
text-align: center;
font-size: 2.5rem;
margin-bottom: 1rem;
}
h2, h3 {
color: #00ffff;
text-shadow: 0 0 5px #00ffff;
}
/* Form styling */
form {
background: rgba(0, 0, 0, 0.3);
padding: 1rem;
border-radius: 8px;
margin-bottom: 1rem;
}
input[type="text"] {
background: #1a1a1a;
color: #00ff41;
border: 2px solid #00ff41;
padding: 0.5rem;
border-radius: 4px;
font-family: inherit;
}
button {
background: linear-gradient(45deg, #00ff41, #00cc33);
color: #000;
border: none;
padding: 0.5rem 1rem;
border-radius: 4px;
cursor: pointer;
font-weight: bold;
transition: all 0.3s ease;
}
button:hover {
transform: translateY(-2px);
box-shadow: 0 4px 8px rgba(0, 255, 65, 0.3);
}
/* Pilot section styling */
.pilot {
background: rgba(0, 0, 0, 0.4);
margin: 0.8rem 0;
border-radius: 8px;
border-left: 4px solid #00ff41;
}
summary {
cursor: pointer;
font-weight: 600;
padding: 0.8rem;
transition: background 0.3s ease;
}
summary:hover {
background: rgba(0, 255, 65, 0.1);
}
.counts {
font-size: 0.9rem;
color: #ffff00;
margin-left: 0.5rem;
}
.muted {
color: #888;
}
/* Table styling */
table {
border-collapse: collapse;
margin: 0.5rem 0;
width: 100%;
background: rgba(0, 0, 0, 0.5);
border-radius: 8px;
overflow: hidden;
}
th, td {
border: 1px solid #333;
padding: 0.5rem;
text-align: left;
}
th {
background: linear-gradient(45deg, #333, #555);
color: #00ffff;
font-weight: bold;
}
tr:nth-child(even) {
background: rgba(255, 255, 255, 0.05);
}
tr:hover {
background: rgba(0, 255, 65, 0.1);
}
/* Code styling */
code {
background: #1a1a1a;
color: #00ff41;
padding: 0.2rem 0.4rem;
border-radius: 4px;
border: 1px solid #333;
}
/* Error styling */
.error {
color: #ff4444;
background: rgba(255, 68, 68, 0.1);
padding: 1rem;
border-radius: 8px;
border-left: 4px solid #ff4444;
}
/* Sorting controls */
#pilot-sorting {
background: rgba(0, 0, 0, 0.3);
padding: 1rem;
border-radius: 8px;
margin: 1rem 0;
}
#pilot-sorting button {
margin: 0.2rem;
font-size: 0.9rem;
}
/* Responsive design */
@media (max-width: 768px) {
body {
padding: 0.5rem;
}
h1 {
font-size: 2rem;
}
table {
font-size: 0.8rem;
}
input[type="text"] {
width: 100%;
box-sizing: border-box;
}
}
/* Animation for loading */
@keyframes glow {
0%, 100% { text-shadow: 0 0 5px #00ffff; }
50% { text-shadow: 0 0 20px #00ffff, 0 0 30px #00ffff; }
}
.glow-animation {
animation: glow 2s ease-in-out infinite;
}
/* File picker styles (custom themed) */
.file-picker {
background: rgba(0, 0, 0, 0.8);
border: 2px solid #00ff41;
border-radius: 10px;
padding: 1.5rem;
margin: 1rem 0;
box-shadow: 0 0 20px rgba(0, 255, 65, 0.3);
}
.file-picker h3 {
margin-top: 0;
color: #00ffff;
text-shadow: 0 0 10px #00ffff;
}
.btn {
padding: 0.8rem 1.5rem;
border: 2px solid #00ff41;
background: rgba(0, 255, 65, 0.1);
border-radius: 5px;
cursor: pointer;
color: #00ff41;
font-family: 'Courier New', monospace;
font-weight: bold;
text-decoration: none;
transition: all 0.3s ease;
}
.btn:hover {
background: rgba(0, 255, 65, 0.2);
box-shadow: 0 0 15px rgba(0, 255, 65, 0.5);
transform: translateY(-2px);
}
.btn-primary {
background: rgba(0, 255, 255, 0.1);
border-color: #00ffff;
color: #00ffff;
}
.btn-primary:hover {
background: rgba(0, 255, 255, 0.2);
box-shadow: 0 0 15px rgba(0, 255, 255, 0.5);
}
#fileBrowserPopup {
border: 2px solid #ff6b35;
background: rgba(0, 0, 0, 0.95);
border-radius: 8px;
box-shadow: 0 0 25px rgba(255, 107, 53, 0.4);
}
#fileList > div {
transition: all 0.2s ease;
}
#fileList > div:hover {
background: rgba(0, 255, 65, 0.1) !important;
transform: translateX(5px);
}
</style>
</head>
<body>
<!-- Custom notice to show template is active -->
<div class="custom-notice">
🚀 CUSTOM TEMPLATE ACTIVE! 🚀<br>
This is an example of how you can customize the Tacview Log Analyzer interface.
</div>
<h1 class="glow-animation">🎯 Tacview Log Analyzer</h1>
<!-- Enhanced File Browser -->
<div class="file-picker">
<h3>📁 Select XML File</h3>
<!-- File browser interface -->
<div style="margin-bottom: 1rem;">
<button type="button" class="btn btn-primary" onclick="showFileBrowser()">
📂 Browse Files
</button>
<span id="selectedFileName" style="margin-left: 1rem; color: #00ff41;"></span>
</div>
<!-- File browser popup -->
<div id="fileBrowserPopup" style="display: none; border: 1px solid #ccc; background: white; padding: 1rem; margin-top: 0.5rem;">
<div style="border-bottom: 1px solid #eee; padding-bottom: 0.5rem; margin-bottom: 0.5rem;">
<strong style="color: #00ffff;">Select XML File</strong>
<button onclick="hideFileBrowser()" style="float: right; border: none; background: none; font-size: 1.2em; cursor: pointer; color: #ff6b35;">×</button>
</div>
<div id="currentPath" style="font-family: monospace; font-size: 0.9em; color: #00ff41; margin-bottom: 0.5rem;"></div>
<div id="fileList" style="max-height: 200px; overflow-y: auto; border: 1px solid #00ff41;">
<div class="loading">Loading files...</div>
</div>
<div style="margin-top: 0.5rem;">
<button type="button" class="btn" onclick="navigateUp()">⬆️ Up</button>
<button type="button" class="btn btn-primary" id="selectBtn" onclick="loadSelectedFile()" disabled>Load File</button>
</div>
</div>
<!-- Advanced: Direct path input -->
<details>
<summary style="cursor: pointer; color: #00ff41; font-size: 0.9em;">Advanced: Enter path manually</summary>
<form method="get" style="margin-top: 0.5rem;">
<label style="color: #00ffff;">
📁 XML file path:
<input type="text" name="xml" id="pathInput" value="{{ xml or '' }}" size="80" placeholder="Enter path to your Tacview XML file..." style="background: rgba(0,0,0,0.8); color: #00ff41; border: 1px solid #00ff41; padding: 0.5rem; border-radius: 3px;"/>
<button type="submit" class="btn btn-primary">🔍 Load & Analyze</button>
</label>
</form>
</details>
</div>
{% if error %}
<div class="error">❌ {{ error }}</div>
{% endif %}
{% if hasData %}
<p class="muted">✅ Loaded: <code>{{ xml }}</code></p>
{% if vm.overview %}
<h2>📊 Mission Overview</h2>
<table>
<thead>
<tr>
<th>👨✈️ Human Pilots</th>
<th>🛬 Landed</th>
<th>💥 Ejected / Shot down</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{ vm.overview.humanPilots }}</td>
<td>{{ vm.overview.landedPilots }}</td>
<td>{{ vm.overview.ejectedOrShotPilots }}</td>
</tr>
</tbody>
</table>
{% if vm.overview.shotsByWeapon %}
<h3>🚀 Shots / Hits / Kills by Weapon</h3>
<table>
<thead>
<tr>
<th>🔫 Weapon</th>
<th>🎯 Shots</th>
<th>💥 Hits</th>
<th>☠️ Kills</th>
</tr>
</thead>
<tbody>
{% for row in vm.overview.shotsByWeapon %}
<tr>
<td>{{ row.weapon }}</td>
<td>{{ row.shots }}</td>
<td>{{ row.hits }}</td>
<td>{{ row.kills }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
{% endif %}
<!-- Pilot sorting controls -->
<div id="pilot-sorting" style="display: none; gap: 0.5rem; flex-wrap: wrap">
<strong>🔄 Sort pilots:</strong>
<button type="button" data-sort="shots" title="Sort by total shots (desc)">🎯 Shots ↓</button>
<button type="button" data-sort="kills" title="Sort by total kills (desc)">☠️ Kills ↓</button>
<button type="button" data-sort="aakills" title="Sort by AA kills (desc)">✈️ AA-Kills ↓</button>
<button type="button" data-sort="agkills" title="Sort by AG kills (desc)">🏗️ A-G Kills ↓</button>
<button type="button" data-sort="name" title="Sort alphabetically by pilot name">📝 Name A→Z</button>
<button type="button" data-sort="default" title="Original order (shots desc)">🔄 Default</button>
</div>
<!-- Pilot details -->
<div id="pilots-container">
{% for p in vm.pilots %}
<details
class="pilot"
data-pilot-name="{{ p.pilot or '' }}"
data-pilot-shots="{{ p.totals.shots }}"
data-pilot-kills="{{ p.totals.kills }}"
data-pilot-aakills="{{ p.totalsAA.kills }}"
data-pilot-agkills="{{ p.totalsAG.kills }}"
data-default-index="{{ loop.index0 }}"
>
<summary>
👨✈️ {{ p.pilot or 'Unknown' }}
<span class="counts">
🎯 Shots {{ p.totals.shots }}{% if p.totalsFriendly and p.totalsFriendly.shots %} / {{ p.totalsFriendly.shots }} FF{% endif %}
· 💥 Hits {{ p.totals.hits }}{% if p.totalsFriendly and p.totalsFriendly.hits %} / {{ p.totalsFriendly.hits }} FF{% endif %}
· ☠️ Kills {{ p.totals.kills }}{% if p.totalsFriendly and p.totalsFriendly.kills %} / {{ p.totalsFriendly.kills }} FF{% endif %}
· ❌ Misses {{ p.totals.misses }}
· ⏱️ Flight {{ p.flightTime }}{% if p.flightEnd %} · 🏁 End {{ p.flightEnd }}{% endif %}
<br />
<span class="muted">
✈️ A-A S/H/K: {{ p.totalsAA.shots }}/{{ p.totalsAA.hits }}/{{ p.totalsAA.kills }}
· 🏗️ A-G S/H/K: {{ p.totalsAG.shots }}/{{ p.totalsAG.hits }}/{{ p.totalsAG.kills }}
</span>
</span>
</summary>
<details open style="margin-left: 1rem">
<summary>🔫 Weapon summary ({{ p.byWeapon | length }})</summary>
<table>
<thead>
<tr>
<th>🚀 Weapon</th>
<th>🎯 Shots</th>
<th>💥 Hits</th>
<th>☠️ Kills</th>
<th>❌ Misses</th>
</tr>
</thead>
<tbody>
{% for w in p.byWeapon %}
<tr>
<td>{{ w.weapon }}</td>
<td>{{ w.shots }}</td>
<td>{{ w.hits }}</td>
<td>{{ w.kills }}</td>
<td>{{ w.misses }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</details>
<details style="margin-left: 1rem">
<summary>📋 Events ({{ (p.chains | length) + (p.misses | length) }})</summary>
<table>
<thead>
<tr>
<th>⏰ ShotT</th>
<th>🔫 Weapon</th>
<th>🎯 Target</th>
<th>💥 HitT</th>
<th>☠️ KillT</th>
<th>💀 Extra Kills</th>
<th>🏷️ Flags</th>
<th>🏁 Domain</th>
</tr>
</thead>
<tbody>
{% for c in p.chains %}
<tr>
<td title="{{ '%.2f'|format(c.shotT) }}">
{{ c.shotStr or ('%.2f'|format(c.shotT)) }}
</td>
<td>{{ c.weapon }}</td>
<td>{{ c.targetName or '' }}</td>
<td title="{{ c.hitT and '%.2f'|format(c.hitT) or '' }}">
{{ c.hitStr }}
</td>
<td title="{{ c.killT and '%.2f'|format(c.killT) or '' }}">
{{ c.killStr }}
</td>
<td>
{% if c.extraKillNames and c.extraKillNames|length > 0 %}
{{ c.extraKillNames|join(', ') }}
{% endif %}
</td>
<td>
{% if c.intercepted %}🛡️ Intercepted by {{ c.interceptorName }}{% endif %}
{% if c.shooterMismatch %}{% if c.intercepted %}, {% endif %}⚠️ ShooterMismatch{% endif %}
{% if c.friendly %}{% if c.intercepted or c.shooterMismatch %}, {% endif %}🤝 Friendly{% endif %}
</td>
<td>{{ c.domain }}</td>
</tr>
{% endfor %}
{% for m in p.misses %}
<tr>
<td title="{{ '%.2f'|format(m.shotT) }}">
{{ m.shotStr or ('%.2f'|format(m.shotT)) }}
</td>
<td>{{ m.weapon }}</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>
{% if m.intercepted %}🛡️ Intercepted by {{ m.interceptorName }}
{% else %}❌ Miss{% endif %}
</td>
<td>{{ m.domain }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</details>
</details>
{% endfor %}
</div>
{% endif %}
<!-- JavaScript for sorting functionality (unchanged from original) -->
<script>
(function () {
const container = document.getElementById("pilots-container");
const bar = document.getElementById("pilot-sorting");
if (!container || !bar) return;
const pilots = Array.from(container.querySelectorAll("details.pilot"));
if (pilots.length === 0) return;
bar.style.display = "flex";
const original = pilots.slice();
function applySort(kind) {
let sorted = pilots.slice();
// helper to safely parse numeric dataset values (defaults to 0)
const getNum = (el, key) => {
const v = el.dataset[key];
const n = Number(v);
return Number.isFinite(n) ? n : 0;
};
if (kind === "shots") {
sorted.sort(
(a, b) =>
Number(b.dataset.pilotShots) - Number(a.dataset.pilotShots) ||
a.dataset.pilotName.localeCompare(b.dataset.pilotName)
);
} else if (kind === "kills") {
sorted.sort(
(a, b) =>
Number(b.dataset.pilotKills) - Number(a.dataset.pilotKills) ||
a.dataset.pilotName.localeCompare(b.dataset.pilotName)
);
} else if (kind === "aakills") {
sorted.sort(
(a, b) =>
getNum(b, "pilotAakills") - getNum(a, "pilotAakills") ||
a.dataset.pilotName.localeCompare(b.dataset.pilotName)
);
} else if (kind === "agkills") {
sorted.sort(
(a, b) =>
getNum(b, "pilotAgkills") - getNum(a, "pilotAgkills") ||
a.dataset.pilotName.localeCompare(b.dataset.pilotName)
);
} else if (kind === "name") {
sorted.sort((a, b) =>
a.dataset.pilotName.localeCompare(b.dataset.pilotName)
);
} else if (kind === "default") {
sorted = original.slice();
}
// detach then append in order
const frag = document.createDocumentFragment();
sorted.forEach((el) => frag.appendChild(el));
container.innerHTML = "";
container.appendChild(frag);
}
bar.addEventListener("click", (e) => {
const btn = e.target.closest("button[data-sort]");
if (!btn) return;
applySort(btn.dataset.sort);
});
})();
// File browser functionality (custom themed)
let currentPath = '';
let selectedFile = '';
function showFileBrowser() {
document.getElementById('fileBrowserPopup').style.display = 'block';
loadDirectory('');
}
function hideFileBrowser() {
document.getElementById('fileBrowserPopup').style.display = 'none';
}
function loadDirectory(path) {
currentPath = path;
const fileList = document.getElementById('fileList');
const pathDiv = document.getElementById('currentPath');
fileList.innerHTML = '<div style="padding: 0.5rem; color: #00ff41;">Loading...</div>';
const url = path ? `/ui/api/browse?path=${encodeURIComponent(path)}` : '/ui/api/browse';
fetch(url)
.then(response => response.json())
.then(data => {
pathDiv.textContent = data.current_path;
fileList.innerHTML = '';
// Add directories
data.directories.forEach(dir => {
const item = document.createElement('div');
item.style.cssText = 'padding: 0.3rem; cursor: pointer; border-bottom: 1px solid rgba(0,255,65,0.3); color: #00ffff;';
item.innerHTML = `📁 ${dir.name}`;
item.onclick = () => loadDirectory(dir.path);
fileList.appendChild(item);
});
// Add XML files
data.files.forEach(file => {
const item = document.createElement('div');
item.style.cssText = 'padding: 0.3rem; cursor: pointer; border-bottom: 1px solid rgba(0,255,65,0.3); color: #00ff41;';
item.innerHTML = `📄 ${file.name}`;
item.onclick = () => selectFile(file.path, file.name);
if (selectedFile === file.path) item.style.background = 'rgba(0,255,65,0.2)';
fileList.appendChild(item);
});
if (data.directories.length === 0 && data.files.length === 0) {
fileList.innerHTML = '<div style="padding: 0.5rem; color: #ff6b35;">No XML files found</div>';
}
})
.catch(err => {
fileList.innerHTML = `<div style="padding: 0.5rem; color: #ff6b35;">Error: ${err.message}</div>`;
});
}
function selectFile(filePath, fileName) {
selectedFile = filePath;
document.getElementById('selectedFileName').textContent = `Selected: ${fileName}`;
document.getElementById('selectBtn').disabled = false;
document.getElementById('selectBtn').textContent = `Load "${fileName}"`;
// Refresh the file list to show selection
const fileList = document.getElementById('fileList');
Array.from(fileList.children).forEach(item => {
if (item.textContent.includes(fileName)) {
item.style.background = 'rgba(0,255,65,0.2)';
} else {
item.style.background = '';
}
});
}
function loadSelectedFile() {
if (selectedFile) {
document.getElementById('pathInput').value = selectedFile;
document.querySelector('form').submit();
}
}
function navigateUp() {
fetch(`/ui/api/browse?path=${encodeURIComponent(currentPath)}`)
.then(response => response.json())
.then(data => {
if (data.parent_path) {
loadDirectory(data.parent_path);
}
});
}
</script>
</body>
</html>