fix minifying and reuse code

This commit is contained in:
KingKDot
2026-06-22 19:21:06 -05:00
parent 5f75f5ca6f
commit e2be2b4394
16 changed files with 277 additions and 206 deletions
+2 -14
View File
@@ -1,3 +1,5 @@
import { escapeHtml, formatBytes } from "./format.js";
const clientList = document.getElementById("client-list");
const clientSearch = document.getElementById("client-search");
const osFilter = document.getElementById("os-filter");
@@ -275,20 +277,6 @@ function setOsBadge(os) {
osBadge.classList.add("border-emerald-600", "text-emerald-300");
}
function formatBytes(bytes) {
const value = Number(bytes) || 0;
if (value < 1024) return `${value} B`;
if (value < 1024 * 1024) return `${(value / 1024).toFixed(1)} KB`;
if (value < 1024 * 1024 * 1024) return `${(value / 1024 / 1024).toFixed(2)} MB`;
return `${(value / 1024 / 1024 / 1024).toFixed(2)} GB`;
}
function escapeHtml(text) {
const div = document.createElement("div");
div.textContent = text;
return div.innerHTML;
}
clientSearch.addEventListener("input", filterAndRenderClients);
osFilter.addEventListener("change", filterAndRenderClients);