-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcheck.html
More file actions
349 lines (312 loc) · 9.69 KB
/
Copy pathcheck.html
File metadata and controls
349 lines (312 loc) · 9.69 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PitFUSION API Check</title>
<script src="config.js"></script>
<style>
:root {
--bg: #060e1e;
--surface: #0d1e3d;
--border: rgba(255,255,255,0.12);
--gold: #f5c000;
--green: #2ecc71;
--red: #e74c3c;
--warn: #e86a10;
--text: #ffffff;
--dim: rgba(255,255,255,0.45);
--fd: 'Rajdhani', sans-serif;
}
@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@400;600;700&family=JetBrains+Mono:wght@400;700&display=swap');
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
background: var(--bg);
color: var(--text);
font-family: var(--fd);
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-start;
padding: 40px 20px;
}
header {
text-align: center;
margin-bottom: 40px;
}
.wordmark {
font-size: 2.4rem;
font-weight: 700;
letter-spacing: .1em;
text-transform: uppercase;
}
.wordmark .pit { color: #fff; }
.wordmark .fus { color: var(--gold); }
.subtitle {
font-size: 0.95rem;
color: var(--dim);
letter-spacing: .2em;
text-transform: uppercase;
margin-top: 4px;
}
.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
gap: 20px;
width: 100%;
max-width: 900px;
}
.card {
background: var(--surface);
border: 2px solid var(--border);
border-radius: 10px;
overflow: hidden;
}
.card-hdr {
padding: 14px 20px;
border-bottom: 1px solid var(--border);
display: flex;
align-items: center;
gap: 10px;
}
.card-name {
font-size: 1.2rem;
font-weight: 700;
letter-spacing: .08em;
text-transform: uppercase;
flex: 1;
}
.status-pill {
font-family: 'JetBrains Mono', monospace;
font-size: 0.75rem;
font-weight: 700;
padding: 3px 10px;
border-radius: 20px;
letter-spacing: .06em;
text-transform: uppercase;
transition: all .3s;
}
.pill-pending { background: rgba(255,255,255,0.08); color: var(--dim); border: 1px solid var(--border); }
.pill-ok { background: rgba(46,204,113,.15); color: var(--green); border: 1px solid rgba(46,204,113,.4); }
.pill-fail { background: rgba(231,76,60,.15); color: var(--red); border: 1px solid rgba(231,76,60,.4); }
.pill-warn { background: rgba(232,106,16,.15); color: var(--warn); border: 1px solid rgba(232,106,16,.4); }
.checks { padding: 12px 0; }
.check-row {
display: flex;
align-items: flex-start;
gap: 12px;
padding: 10px 20px;
border-bottom: 1px solid var(--border);
transition: background .15s;
}
.check-row:last-child { border-bottom: none; }
.check-icon {
font-size: 1.1rem;
width: 22px;
text-align: center;
flex-shrink: 0;
margin-top: 1px;
}
.check-info { flex: 1; min-width: 0; }
.check-label {
font-size: 0.95rem;
font-weight: 600;
color: var(--text);
margin-bottom: 2px;
}
.check-detail {
font-family: 'JetBrains Mono', monospace;
font-size: 0.72rem;
color: var(--dim);
word-break: break-all;
line-height: 1.4;
}
.check-time {
font-family: 'JetBrains Mono', monospace;
font-size: 0.72rem;
color: var(--dim);
white-space: nowrap;
flex-shrink: 0;
}
.spin {
display: inline-block;
animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.recheck-btn {
display: block;
margin: 30px auto 0;
padding: 10px 32px;
background: var(--gold);
color: #060e1e;
border: none;
border-radius: 6px;
font-family: var(--fd);
font-size: 1rem;
font-weight: 700;
letter-spacing: .1em;
text-transform: uppercase;
cursor: pointer;
transition: opacity .15s;
}
.recheck-btn:hover { opacity: .85; }
.recheck-btn:disabled { opacity: .4; cursor: not-allowed; }
.timestamp {
margin-top: 16px;
font-size: 0.8rem;
color: var(--dim);
font-family: 'JetBrains Mono', monospace;
letter-spacing: .05em;
}
.key-warning {
background: rgba(231,76,60,.1);
border: 1px solid rgba(231,76,60,.3);
border-radius: 8px;
padding: 12px 18px;
margin-bottom: 24px;
font-size: 0.9rem;
color: #ef9a9a;
max-width: 900px;
width: 100%;
display: none;
}
</style>
</head>
<body>
<header>
<div class="wordmark"><span class="pit">Pit</span><span class="fus">FUSION</span></div>
<div class="subtitle">API Connectivity Check</div>
</header>
<div class="key-warning" id="key-warning">
⚠ config.js not loaded or API keys missing — results may be inaccurate.
</div>
<div class="grid">
<!-- TBA card -->
<div class="card">
<div class="card-hdr">
<span class="card-name">The Blue Alliance</span>
<span class="status-pill pill-pending" id="tba-pill">Checking…</span>
</div>
<div class="checks" id="tba-checks"></div>
</div>
<!-- Nexus card -->
<div class="card">
<div class="card-hdr">
<span class="card-name">Nexus</span>
<span class="status-pill pill-pending" id="nexus-pill">Checking…</span>
</div>
<div class="checks" id="nexus-checks"></div>
</div>
</div>
<button class="recheck-btn" id="recheck-btn" onclick="runAll()">↻ Re-check</button>
<div class="timestamp" id="timestamp"></div>
<script>
const TBA = (typeof TBA_KEY !== 'undefined') ? TBA_KEY : null;
const NEXUS = (typeof NEXUS_KEY !== 'undefined') ? NEXUS_KEY : null;
if(!TBA || !NEXUS) {
document.getElementById('key-warning').style.display = 'block';
}
function row(icon, label, detail, time='') {
return `<div class="check-row">
<span class="check-icon">${icon}</span>
<div class="check-info">
<div class="check-label">${label}</div>
${detail ? `<div class="check-detail">${detail}</div>` : ''}
</div>
${time ? `<span class="check-time">${time}ms</span>` : ''}
</div>`;
}
function setPill(id, state, text) {
const el = document.getElementById(id);
el.className = `status-pill pill-${state}`;
el.textContent = text;
}
async function checkEndpoint(url, headers, label) {
const t0 = Date.now();
try {
const r = await fetch(url, { headers, cache: 'no-store' });
const ms = Date.now() - t0;
if (r.ok) {
return { ok: true, status: r.status, ms, detail: '' };
} else {
const body = await r.text().catch(() => '');
return { ok: false, status: r.status, ms, detail: body.slice(0, 120) };
}
} catch(e) {
return { ok: false, status: 0, ms: Date.now() - t0, detail: e.message };
}
}
async function runTBA(container, pill) {
container.innerHTML = row('⏳', 'Connecting…', '', '');
setPill(pill, 'pending', 'Checking…');
const headers = TBA ? { 'X-TBA-Auth-Key': TBA } : {};
const tests = [
{ label: 'API reachable', url: 'https://www.thebluealliance.com/api/v3/status' },
{ label: 'Auth key valid', url: 'https://www.thebluealliance.com/api/v3/events/2026/simple' },
{ label: 'Event data (2026mawor)', url: 'https://www.thebluealliance.com/api/v3/event/2026mawor/simple' },
{ label: 'Match data (2026mawor)', url: 'https://www.thebluealliance.com/api/v3/event/2026mawor/matches/simple' },
];
let html = '';
let allOk = true;
for (const t of tests) {
const res = await checkEndpoint(t.url, headers, t.label);
const icon = res.ok ? '✅' : (res.status === 401 || res.status === 403) ? '🔑' : '❌';
const detail = res.ok
? `HTTP ${res.status}`
: res.status === 0
? `Network error: ${res.detail}`
: `HTTP ${res.status}${res.detail ? ': ' + res.detail : ''}`;
html += row(icon, t.label, detail, res.ms);
if (!res.ok) allOk = false;
}
container.innerHTML = html;
setPill(pill, allOk ? 'ok' : 'fail', allOk ? 'Online' : 'Issues');
}
async function runNexus(container, pill) {
container.innerHTML = row('⏳', 'Connecting…', '', '');
setPill(pill, 'pending', 'Checking…');
const headers = NEXUS ? { 'Nexus-Api-Key': NEXUS } : {};
const tests = [
{ label: 'API reachable', url: 'https://frc.nexus/api/v1/events' },
{ label: 'Auth key valid', url: 'https://frc.nexus/api/v1/events' },
{ label: 'Event data (2026mawor)', url: 'https://frc.nexus/api/v1/event/2026mawor' },
{ label: 'Pit data (2026mawor)', url: 'https://frc.nexus/api/v1/event/2026mawor/pits' },
];
let html = '';
let allOk = true;
for (const t of tests) {
const res = await checkEndpoint(t.url, headers, t.label);
const icon = res.ok ? '✅' : (res.status === 401 || res.status === 403) ? '🔑' : '❌';
const detail = res.ok
? `HTTP ${res.status}`
: res.status === 0
? `Network error: ${res.detail}`
: res.status === 404
? `HTTP 404 — event may have ended`
: `HTTP ${res.status}${res.detail ? ': ' + res.detail : ''}`;
html += row(icon, t.label, detail, res.ms);
if (!res.ok && res.status !== 404) allOk = false;
}
container.innerHTML = html;
setPill(pill, allOk ? 'ok' : (allOk === null ? 'warn' : 'fail'), allOk ? 'Online' : 'Issues');
}
async function runAll() {
const btn = document.getElementById('recheck-btn');
btn.disabled = true;
btn.textContent = '⏳ Checking…';
document.getElementById('timestamp').textContent = '';
await Promise.all([
runTBA(document.getElementById('tba-checks'), 'tba-pill'),
runNexus(document.getElementById('nexus-checks'), 'nexus-pill'),
]);
const now = new Date();
document.getElementById('timestamp').textContent =
`Last checked: ${now.toLocaleDateString()} ${now.toLocaleTimeString()}`;
btn.disabled = false;
btn.textContent = '↻ Re-check';
}
runAll();
</script>
</body>
</html>