Repository navigation
Expand file tree
/
Copy patherror-log.html
More file actions
84 lines (75 loc) · 3.07 KB
/
Copy patherror-log.html
File metadata and controls
84 lines (75 loc) · 3.07 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TSLA Error Log</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-zinc-950 text-white font-mono min-h-screen p-8">
<div class="max-w-4xl mx-auto">
<div class="flex items-center justify-between mb-8">
<div>
<a href="index.html" class="text-zinc-600 hover:text-zinc-300 text-sm">← Back</a>
<h1 class="text-xl font-bold mt-2">TSLA Fetch Error Log</h1>
</div>
<button onclick="clearLog()"
class="px-4 py-2 text-sm bg-zinc-800 hover:bg-red-900 text-zinc-400 hover:text-red-300 rounded-xl transition">
Clear Log
</button>
</div>
<div id="log"></div>
</div>
<script>
const KEY = 'tsla_errors';
const PHASE_COLOR = {
'network-or-cors': 'text-red-400',
'http-error': 'text-orange-400',
'parse-error': 'text-purple-400',
'missing-price-field':'text-yellow-400',
'cache-read': 'text-amber-400',
};
function render() {
const log = JSON.parse(localStorage.getItem(KEY) || '[]');
const el = document.getElementById('log');
if (!log.length) {
el.innerHTML = `<p class="text-zinc-600 text-center py-20">No errors logged yet.</p>`;
return;
}
el.innerHTML = `
<table class="w-full text-sm border-collapse">
<thead>
<tr class="text-zinc-500 text-xs uppercase tracking-wider border-b border-zinc-800">
<th class="text-left pb-3 pr-4">Time</th>
<th class="text-left pb-3 pr-4">Source</th>
<th class="text-left pb-3 pr-4">Phase</th>
<th class="text-left pb-3 pr-4">Error</th>
<th class="text-left pb-3">Hint</th>
</tr>
</thead>
<tbody>
${log.map(e => `
<tr class="border-t border-zinc-800/60 hover:bg-zinc-900/40">
<td class="py-3 pr-4 text-zinc-500 whitespace-nowrap">
${new Date(e.time).toLocaleTimeString([], {hour:'2-digit',minute:'2-digit',second:'2-digit'})}
<div class="text-xs text-zinc-700">${new Date(e.time).toLocaleDateString()}</div>
</td>
<td class="py-3 pr-4 text-zinc-300 max-w-[140px] truncate" title="${e.source}">${e.source}</td>
<td class="py-3 pr-4 ${PHASE_COLOR[e.phase] || 'text-zinc-400'} whitespace-nowrap">${e.phase}</td>
<td class="py-3 pr-4 text-zinc-300">${e.error}${e.status ? ` <span class="text-zinc-600">(${e.status})</span>` : ''}</td>
<td class="py-3 text-zinc-500 text-xs">${e.hint ?? '—'}</td>
</tr>`).join('')}
</tbody>
</table>
<p class="text-zinc-700 text-xs mt-6">Last ${log.length} errors · stored in localStorage</p>`;
}
function clearLog() {
if (confirm('Clear all errors?')) {
localStorage.removeItem(KEY);
render();
}
}
render();
</script>
</body>
</html>