Spaces:
Running
Running
Upload index.html
Browse files- index.html +87 -0
index.html
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Dinnerbone5443 API Hub</title>
|
| 7 |
+
<style>
|
| 8 |
+
:root { --bg: #09090b; --panel: #18181b; --accent: #38bdf8; --text: #f4f4f5; --muted: #a1a1aa; }
|
| 9 |
+
body { font-family: ui-sans-serif, system-ui, sans-serif; background: var(--bg); color: var(--text); display: flex; justify-content: center; align-items: center; min-height: 100vh; margin: 0; }
|
| 10 |
+
.container { background: var(--panel); padding: 2.5rem; border-radius: 1rem; width: 100%; max-width: 450px; box-shadow: 0 10px 25px rgba(0,0,0,0.5); border: 1px solid #27272a; }
|
| 11 |
+
h2 { margin: 0 0 1.5rem 0; color: var(--accent); text-align: center; font-weight: 600; letter-spacing: -0.5px; }
|
| 12 |
+
select, input { width: 100%; padding: 0.85rem; margin-bottom: 1rem; border-radius: 0.5rem; border: 1px solid #3f3f46; background: var(--bg); color: var(--text); font-size: 1rem; box-sizing: border-box; transition: border 0.2s; cursor: pointer; }
|
| 13 |
+
select:focus, input:focus { outline: none; border-color: var(--accent); }
|
| 14 |
+
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1rem; background: #0f0f11; padding: 1rem; border-radius: 0.5rem; border: 1px solid #27272a; }
|
| 15 |
+
.stat-box { text-align: center; }
|
| 16 |
+
.stat-val { font-size: 1.25rem; font-weight: bold; color: var(--accent); }
|
| 17 |
+
.stat-label { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 0.25rem; }
|
| 18 |
+
.help-text { font-size: 0.85rem; color: var(--muted); text-align: center; margin-top: 1.5rem; }
|
| 19 |
+
</style>
|
| 20 |
+
</head>
|
| 21 |
+
<body>
|
| 22 |
+
<div class="container">
|
| 23 |
+
<h2>Jizzy's API Hub :D</h2>
|
| 24 |
+
|
| 25 |
+
<select id="providerSelect"></select>
|
| 26 |
+
<input type="text" id="outputUrl" readonly title="Click to copy">
|
| 27 |
+
|
| 28 |
+
<div class="stats-grid">
|
| 29 |
+
<div class="stat-box">
|
| 30 |
+
<div class="stat-val" id="usageCount">0</div>
|
| 31 |
+
<div class="stat-label">Total Requests</div>
|
| 32 |
+
</div>
|
| 33 |
+
<div class="stat-box">
|
| 34 |
+
<div class="stat-val" id="avgTime">0ms</div>
|
| 35 |
+
<div class="stat-label">Avg Latency</div>
|
| 36 |
+
</div>
|
| 37 |
+
</div>
|
| 38 |
+
|
| 39 |
+
<p class="help-text">Touch Grass <b>Daily</b> Every second</p>
|
| 40 |
+
</div>
|
| 41 |
+
|
| 42 |
+
<script>
|
| 43 |
+
const host = window.location.origin;
|
| 44 |
+
let statsData = {};
|
| 45 |
+
|
| 46 |
+
// Fetch endpoints and stats in parallel
|
| 47 |
+
Promise.all([
|
| 48 |
+
fetch('/api/endpoints').then(res => res.json()),
|
| 49 |
+
fetch('/api/stats').then(res => res.json())
|
| 50 |
+
]).then(([endpoints, stats]) => {
|
| 51 |
+
statsData = stats;
|
| 52 |
+
const select = document.getElementById('providerSelect');
|
| 53 |
+
|
| 54 |
+
for (const [nickname, info] of Object.entries(endpoints)) {
|
| 55 |
+
let opt = document.createElement('option');
|
| 56 |
+
opt.value = nickname;
|
| 57 |
+
opt.textContent = info.name;
|
| 58 |
+
select.appendChild(opt);
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
const updateUI = () => {
|
| 62 |
+
const selected = select.value;
|
| 63 |
+
document.getElementById('outputUrl').value = `${host}/${selected}/v1`;
|
| 64 |
+
|
| 65 |
+
// Update stats based on selection
|
| 66 |
+
if(statsData[selected]) {
|
| 67 |
+
document.getElementById('usageCount').textContent = statsData[selected].count;
|
| 68 |
+
document.getElementById('avgTime').textContent = statsData[selected].avgTime + 'ms';
|
| 69 |
+
}
|
| 70 |
+
};
|
| 71 |
+
|
| 72 |
+
select.addEventListener('change', updateUI);
|
| 73 |
+
updateUI();
|
| 74 |
+
});
|
| 75 |
+
|
| 76 |
+
// Copy to clipboard logic
|
| 77 |
+
document.getElementById('outputUrl').addEventListener('click', function() {
|
| 78 |
+
this.select();
|
| 79 |
+
navigator.clipboard.writeText(this.value).then(() => {
|
| 80 |
+
const originalBg = this.style.backgroundColor;
|
| 81 |
+
this.style.backgroundColor = '#166534'; // flash green
|
| 82 |
+
setTimeout(() => this.style.backgroundColor = originalBg, 200);
|
| 83 |
+
});
|
| 84 |
+
});
|
| 85 |
+
</script>
|
| 86 |
+
</body>
|
| 87 |
+
</html>
|