Spaces:
Paused
Paused
fix fish variable error in index
Browse files- internal/handler/index.html +17 -1
internal/handler/index.html
CHANGED
|
@@ -182,5 +182,21 @@ function loadStats() {
|
|
| 182 |
loadStats();
|
| 183 |
setInterval(loadStats, 30000);
|
| 184 |
</script>
|
| 185 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
</html>
|
|
|
|
| 182 |
loadStats();
|
| 183 |
setInterval(loadStats, 30000);
|
| 184 |
</script>
|
| 185 |
+
<script>
|
| 186 |
+
async function updateStats() {
|
| 187 |
+
try {
|
| 188 |
+
const r = await fetch("/stats");
|
| 189 |
+
const data = await r.json();
|
| 190 |
+
const keys = Object.values(data.keys || {});
|
| 191 |
+
keys.sort((a, b) => b.tokens - a.tokens);
|
| 192 |
+
const grid = document.querySelector(".commander-grid");
|
| 193 |
+
if (!grid) return;
|
| 194 |
+
grid.innerHTML = keys.slice(0, 4).map((u, i) => {
|
| 195 |
+
return "<div class="commander-card"><div class="cmd-name">" + (u.name || "Usuario") + " #" + (i+1) + "</div><div class="cmd-trait">REQS: " + u.requests + " // TOKENS: " + u.tokens + "</div></div>";
|
| 196 |
+
}).join("");
|
| 197 |
+
} catch(e) { console.error("Error stats:", e); }
|
| 198 |
+
}
|
| 199 |
+
setInterval(updateStats, 30000);
|
| 200 |
+
updateStats();
|
| 201 |
+
</script></body>
|
| 202 |
</html>
|