|
@@ -59,6 +59,15 @@ function escapeHtml(str) {
|
|
|
.replace(/'/g, ''');
|
|
.replace(/'/g, ''');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+function formatBytes(bytes) {
|
|
|
|
|
+ if (bytes === undefined || bytes === null || isNaN(bytes) || bytes === 0) return '0 B';
|
|
|
|
|
+ const k = 1024;
|
|
|
|
|
+ const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
|
|
|
|
|
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
|
|
|
+ if (i < 0 || i >= sizes.length) return `${bytes} B`;
|
|
|
|
|
+ return `${parseFloat((bytes / Math.pow(k, i)).toFixed(2))} ${sizes[i]}`;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// Initialize on page load
|
|
// Initialize on page load
|
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
|
const hash = window.location.hash.replace('#', '') || 'dashboard';
|
|
const hash = window.location.hash.replace('#', '') || 'dashboard';
|