-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtool-20-HTTP-Status-Code-Explorer.html
More file actions
597 lines (499 loc) · 23.2 KB
/
tool-20-HTTP-Status-Code-Explorer.html
File metadata and controls
597 lines (499 loc) · 23.2 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tool 20 - HTTP Status Code Explorer - Developer Toolbox</title>
<link rel="stylesheet" href="assets/core.css">
<style>
.status-explorer {
max-width: 1200px;
margin: 2rem auto;
position: relative;
z-index: 10;
display: flex;
flex-direction: column;
gap: 2rem;
min-height: 700px;
}
@media (min-width: 900px) {
.status-explorer {
flex-direction: row;
}
}
/* Left side: Search & Grid */
.explorer-main {
flex: 2;
display: flex;
flex-direction: column;
gap: 1.5rem;
}
.filter-panel {
background: rgba(0, 0, 0, 0.4);
border: 1px solid var(--border-color);
border-radius: var(--radius-md);
padding: 1.5rem;
display: flex;
flex-direction: column;
gap: 1rem;
}
.search-wrapper {
position: relative;
}
.search-input {
width: 100%;
padding: 1rem 1rem 1rem 3rem;
background: rgba(255, 255, 255, 0.05);
border: 1px solid var(--border-color);
border-radius: var(--radius-sm);
color: var(--text-primary);
font-size: 1.1rem;
outline: none;
transition: border-color 0.3s;
}
.search-input:focus {
border-color: var(--accent-primary);
}
.search-icon {
position: absolute;
left: 1rem;
top: 50%;
transform: translateY(-50%);
color: var(--text-secondary);
}
.category-filters {
display: flex;
gap: 0.5rem;
flex-wrap: wrap;
}
.cat-btn {
background: transparent;
border: 1px solid var(--border-color);
color: var(--text-secondary);
padding: 0.5rem 1rem;
border-radius: 20px;
cursor: pointer;
transition: all 0.2s;
font-size: 0.9rem;
}
.cat-btn.active,
.cat-btn:hover {
background: var(--accent-primary);
color: #000;
border-color: var(--accent-primary);
}
.status-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
gap: 1rem;
max-height: 500px;
overflow-y: auto;
padding-right: 0.5rem;
}
.status-item {
background: rgba(255, 255, 255, 0.05);
border: 1px solid var(--border-color);
border-radius: var(--radius-sm);
padding: 1rem;
text-align: center;
cursor: pointer;
transition: all 0.2s;
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.status-item:hover,
.status-item.selected {
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}
.status-code {
font-size: 1.8rem;
font-weight: bold;
font-family: var(--font-mono);
}
/* Color coding by class */
.cat-1xx .status-code {
color: #34ace0;
}
/* Info */
.cat-2xx .status-code {
color: #33d9b2;
}
/* Success */
.cat-3xx .status-code {
color: #ffb142;
}
/* Redirect */
.cat-4xx .status-code {
color: #ff5252;
}
/* Client Error */
.cat-5xx .status-code {
color: #b33939;
}
/* Server Error */
.status-item.selected {
border-color: var(--accent-primary);
background: rgba(187, 134, 252, 0.1);
}
/* Right side: Details Panel */
.details-panel {
flex: 1;
background: rgba(0, 0, 0, 0.6);
border: 1px solid var(--border-color);
border-radius: var(--radius-md);
padding: 2rem;
display: flex;
flex-direction: column;
gap: 1.5rem;
backdrop-filter: blur(10px);
height: fit-content;
position: sticky;
top: 2rem;
}
.empty-state {
text-align: center;
color: var(--text-secondary);
padding: 3rem 0;
font-style: italic;
}
.detail-header {
display: flex;
align-items: baseline;
gap: 1rem;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
padding-bottom: 1rem;
}
.detail-code {
font-size: 3rem;
font-weight: bold;
font-family: var(--font-mono);
}
.cat-1xx .detail-code {
color: #34ace0;
}
.cat-2xx .detail-code {
color: #33d9b2;
}
.cat-3xx .detail-code {
color: #ffb142;
}
.cat-4xx .detail-code {
color: #ff5252;
}
.cat-5xx .detail-code {
color: #b33939;
}
.detail-phrase {
font-size: 1.5rem;
color: var(--text-primary);
}
.detail-section h4 {
color: var(--text-secondary);
text-transform: uppercase;
font-size: 0.85rem;
letter-spacing: 1px;
margin-bottom: 0.5rem;
margin-top: 0;
}
.detail-desc {
line-height: 1.6;
font-size: 1.05rem;
}
.code-snippet {
background: #1e1e1e;
padding: 1rem;
border-radius: var(--radius-sm);
font-family: var(--font-mono);
font-size: 0.9rem;
overflow-x: auto;
border: 1px solid #333;
color: #d4d4d4;
white-space: pre-wrap;
}
/* 3D background container */
#canvas-container {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1;
opacity: 0.3;
pointer-events: none;
}
</style>
</head>
<body class="theme-dark">
<div id="canvas-container"></div>
<main class="main-content" style="position: relative; z-index: 10;">
<div class="container" style="max-width: 1400px;">
<div class="tool-header">
<div>
<a href="index.html" class="back-link">← Back to Toolbox</a>
<h1>20. HTTP Status Code Explorer</h1>
<p style="color: var(--text-secondary); margin-top: 0.5rem;">Quick reference for standard HTTP
status codes.</p>
</div>
<div>
<select id="theme-select" aria-label="Select Theme">
<option value="dark">Dark Theme</option>
<option value="light">Light Theme</option>
<option value="solarized">Solarized</option>
<option value="neon">Neon Glow</option>
<option value="highcontrast">High Contrast</option>
</select>
</div>
</div>
<div class="status-explorer">
<div class="explorer-main">
<div class="filter-panel">
<div class="search-wrapper">
<span class="search-icon">🔍</span>
<input type="text" id="status-search" class="search-input"
placeholder="Search code (e.g. 404) or phrase (e.g. Not Found)..." autocomplete="off">
</div>
<div class="category-filters" id="cat-filters">
<button class="cat-btn active" data-cat="all">All</button>
<button class="cat-btn" data-cat="1xx">1xx Info</button>
<button class="cat-btn" data-cat="2xx">2xx Success</button>
<button class="cat-btn" data-cat="3xx">3xx Redirection</button>
<button class="cat-btn" data-cat="4xx">4xx Client Error</button>
<button class="cat-btn" data-cat="5xx">5xx Server Error</button>
</div>
</div>
<div class="status-grid" id="status-grid">
<!-- Items injected by JS -->
</div>
</div>
<div class="details-panel" id="details-panel">
<div class="empty-state">
Select a status code to view details.
</div>
<!-- Details injected by JS -->
</div>
</div>
</div>
</main>
<!-- Three.js and GSAP for 3D Background -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
<script src="assets/core.js"></script>
<script>
// --- Core Status Codes Data ---
// Simplified curated list for demonstration
const statusData = [
{ code: 100, phrase: "Continue", cat: "1xx", desc: "The server has received the request headers and the client should proceed to send the request body.", curl: "curl -v -X POST -H 'Expect: 100-continue' ..." },
{ code: 101, phrase: "Switching Protocols", cat: "1xx", desc: "The requester has asked the server to switch protocols and the server has agreed to do so. Common with WebSockets.", curl: "curl -v --include --no-buffer --header 'Connection: Upgrade' ..." },
{ code: 200, phrase: "OK", cat: "2xx", desc: "Standard response for successful HTTP requests. The actual response will depend on the request method used.", curl: "curl -I https://example.com" },
{ code: 201, phrase: "Created", cat: "2xx", desc: "The request has been fulfilled, resulting in the creation of a new resource (usually POST/PUT).", curl: "curl -X POST -d 'data' https://api.com/items" },
{ code: 202, phrase: "Accepted", cat: "2xx", desc: "The request has been accepted for processing, but the processing has not been completed (async tasks).", curl: "curl -X POST https://api.com/jobs" },
{ code: 204, phrase: "No Content", cat: "2xx", desc: "The server successfully processed the request and is not returning any content.", curl: "curl -X DELETE https://api.com/items/1" },
{ code: 301, phrase: "Moved Permanently", cat: "3xx", desc: "This and all future requests should be directed to the given URI.", curl: "curl -I https://old-domain.com" },
{ code: 302, phrase: "Found", cat: "3xx", desc: "Tells the client to look at (browse to) another URL. 302 has been superseded by 303 and 307.", curl: "curl -I https://example.com/login" },
{ code: 304, phrase: "Not Modified", cat: "3xx", desc: "Indicates that the resource has not been modified since the version specified by the request headers If-Modified-Since or If-None-Match.", curl: "curl -I -H 'If-Modified-Since: Wed, 21 Oct 2015 07:28:00 GMT' ..." },
{ code: 400, phrase: "Bad Request", cat: "4xx", desc: "The server cannot or will not process the request due to an apparent client error (e.g., malformed request syntax).", curl: "curl -X POST -d 'invalid json' https://api.com/submit" },
{ code: 401, phrase: "Unauthorized", cat: "4xx", desc: "Similar to 403 Forbidden, but specifically for use when authentication is required and has failed or has not yet been provided.", curl: "curl -I https://api.com/protected" },
{ code: 403, phrase: "Forbidden", cat: "4xx", desc: "The request contained valid data and was understood by the server, but the server is refusing action (e.g. lack of permissions).", curl: "curl -I https://api.com/admin" },
{ code: 404, phrase: "Not Found", cat: "4xx", desc: "The requested resource could not be found but may be available in the future. Subsequent requests by the client are permissible.", curl: "curl -I https://example.com/does-not-exist" },
{ code: 405, phrase: "Method Not Allowed", cat: "4xx", desc: "A request method is not supported for the requested resource (e.g. a GET request on a form that requires data to be presented via POST).", curl: "curl -X POST https://example.com/static.html" },
{ code: 409, phrase: "Conflict", cat: "4xx", desc: "Indicates that the request could not be processed because of conflict in the current state of the resource (e.g. edit conflict).", curl: "curl -X PUT https://api.com/resource" },
{ code: 429, phrase: "Too Many Requests", cat: "4xx", desc: "The user has sent too many requests in a given amount of time. Intended for use with rate-limiting schemes.", curl: "for i in {1..100}; do curl https://api.com; done" },
{ code: 500, phrase: "Internal Server Error", cat: "5xx", desc: "A generic error message, given when an unexpected condition was encountered and no more specific message is suitable.", curl: "curl -I https://broken-api.com" },
{ code: 502, phrase: "Bad Gateway", cat: "5xx", desc: "The server was acting as a gateway or proxy and received an invalid response from the upstream server.", curl: "curl -I https://proxy.com" },
{ code: 503, phrase: "Service Unavailable", cat: "5xx", desc: "The server cannot handle the request (because it is overloaded or down for maintenance).", curl: "curl -I https://overloaded-api.com" },
{ code: 504, phrase: "Gateway Timeout", cat: "5xx", desc: "The server was acting as a gateway or proxy and did not receive a timely response from the upstream server.", curl: "curl -I https://timeout.com" }
];
const gridEl = document.getElementById('status-grid');
const detailsEl = document.getElementById('details-panel');
const searchInput = document.getElementById('status-search');
const filterBtns = document.getElementById('cat-filters').querySelectorAll('.cat-btn');
let currentCat = 'all';
let currentSearch = '';
let selectedCode = null;
function renderGrid() {
gridEl.innerHTML = '';
const filtered = statusData.filter(item => {
const matchCat = currentCat === 'all' || item.cat === currentCat;
const searchLower = currentSearch.toLowerCase();
const matchSearch = item.code.toString().includes(searchLower) || item.phrase.toLowerCase().includes(searchLower);
return matchCat && matchSearch;
});
filtered.forEach(item => {
const div = document.createElement('div');
div.className = `status-item cat-${item.cat} ${selectedCode === item.code ? 'selected' : ''}`;
div.innerHTML = `
<div class="status-code">${item.code}</div>
<div style="font-size: 0.85rem; color: var(--text-secondary);">${item.phrase}</div>
`;
div.addEventListener('click', () => {
selectCode(item);
});
gridEl.appendChild(div);
});
// Trigger 3D rearrangement
if (window.triggerLayout) window.triggerLayout(filtered.length);
}
function selectCode(item) {
selectedCode = item.code;
// Update grid selection visually
document.querySelectorAll('.status-item').forEach(el => el.classList.remove('selected'));
const selectedEl = Array.from(gridEl.children).find(el => el.querySelector('.status-code').textContent == item.code);
if (selectedEl) selectedEl.classList.add('selected');
// Render details
detailsEl.className = `details-panel cat-${item.cat}`;
detailsEl.innerHTML = `
<div class="detail-header">
<div class="detail-code">${item.code}</div>
<div class="detail-phrase">${item.phrase}</div>
</div>
<div class="detail-section">
<h4>Description</h4>
<div class="detail-desc">${item.desc}</div>
</div>
<div class="detail-section">
<h4>Example curl Call</h4>
<div class="code-snippet">${item.curl}</div>
</div>
`;
// Trigger 3D highlight
if (window.triggerHighlight) window.triggerHighlight(item.cat);
}
// Setup Filtering
filterBtns.forEach(btn => {
btn.addEventListener('click', (e) => {
filterBtns.forEach(b => b.classList.remove('active'));
btn.classList.add('active');
currentCat = btn.getAttribute('data-cat');
renderGrid();
});
});
// Setup Search
searchInput.addEventListener('input', (e) => {
currentSearch = e.target.value;
renderGrid();
});
// Initial Render
renderGrid();
// --- 3D Background Setup (Floating Data Plaques) ---
let scene, camera, renderer, plaqueGroup;
let plaques = [];
// Colors mapping
const catColors = {
"1xx": 0x34ace0,
"2xx": 0x33d9b2,
"3xx": 0xffb142,
"4xx": 0xff5252,
"5xx": 0xb33939
};
const init3D = () => {
const container = document.getElementById('canvas-container');
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera(50, window.innerWidth / window.innerHeight, 0.1, 1000);
camera.position.z = 40;
renderer = new THREE.WebGLRenderer({ alpha: true, antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
container.appendChild(renderer.domElement);
const ambientLight = new THREE.AmbientLight(0xffffff, 0.6);
scene.add(ambientLight);
// A light that moves to highlight specific plaques
const spotLight = new THREE.SpotLight(0xffffff, 2);
spotLight.position.set(0, 20, 20);
spotLight.angle = 0.5;
spotLight.penumbra = 0.5;
scene.add(spotLight);
plaqueGroup = new THREE.Group();
scene.add(plaqueGroup);
// Create plaques for ALL data items
const geo = new THREE.BoxGeometry(4, 2, 0.2);
statusData.forEach((item, i) => {
// Each plaque has a base color depending on category
const colorHex = catColors[item.cat];
const mat = new THREE.MeshStandardMaterial({
color: 0x333333, // base dark
emissive: colorHex,
emissiveIntensity: 0.1, // faint glow initially
roughness: 0.3,
metalness: 0.8
});
const mesh = new THREE.Mesh(geo, mat);
// Add wireframe edge for tech look
const edges = new THREE.EdgesGeometry(geo);
const line = new THREE.LineSegments(edges, new THREE.LineBasicMaterial({ color: colorHex, opacity: 0.5, transparent: true }));
mesh.add(line);
// Initial random scatter distribution in background
mesh.position.set(
(Math.random() - 0.5) * 60,
(Math.random() - 0.5) * 30,
(Math.random() - 0.5) * -20 // push back
);
mesh.rotation.y = (Math.random() - 0.5) * 0.5;
mesh.userData = {
originY: mesh.position.y,
speed: 0.01 + Math.random() * 0.02,
offset: Math.random() * Math.PI * 2,
cat: item.cat
};
plaques.push(mesh);
plaqueGroup.add(mesh);
});
// Action Triggers
window.triggerLayout = (visibleCount) => {
// When searching, sort of cluster or scatter them
// We'll just do a quick spin
gsap.to(plaqueGroup.rotation, {
y: plaqueGroup.rotation.y + Math.PI / 2,
duration: 1,
ease: "power2.out"
});
};
window.triggerHighlight = (cat) => {
// Make the plaques of the selected category glow brightly momentarily
plaques.forEach(p => {
if (p.userData.cat === cat) {
gsap.to(p.material, {
emissiveIntensity: 0.8,
duration: 0.3,
yoyo: true,
repeat: 3 // pulse 3 times
});
// Jolt forward
gsap.to(p.position, {
z: p.position.z + 5,
duration: 0.5,
yoyo: true, // go back
repeat: 1
});
} else {
// dim others
gsap.to(p.material, { emissiveIntensity: 0.05, duration: 0.5 });
}
});
};
const animate = () => {
requestAnimationFrame(animate);
// Idle floating behavior
const time = Date.now() * 0.001;
plaques.forEach(p => {
p.position.y = p.userData.originY + Math.sin(time + p.userData.offset) * 2;
});
// Slow ambient rotation of whole group
plaqueGroup.rotation.y += 0.001;
renderer.render(scene, camera);
};
animate();
window.addEventListener('resize', () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
});
window.dispatchEvent(new Event('resize'));
};
if (document.getElementById('canvas-container')) {
init3D();
}
</script>
</body>
</html>