32 lines
1.2 KiB
JavaScript
32 lines
1.2 KiB
JavaScript
(() => {
|
|
const $i = document.getElementById.bind(document);
|
|
const $ffs = (size, binary) => {
|
|
if(size < 1)
|
|
return 'Zero Bytes';
|
|
|
|
var div = binary ? 1024 : 1000,
|
|
exp = Math.floor(Math.log(size) / Math.log(div)),
|
|
size = size / Math.pow(div, exp);
|
|
|
|
var symbol = ['', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'][exp];
|
|
|
|
return size.toFixed(2) + ' ' + symbol + (binary ? 'i' : '') + 'B';
|
|
};
|
|
|
|
const update = async () => {
|
|
const response = await fetch('/stats.json');
|
|
if(!response.ok)
|
|
console.error('stats request failed!!!!');
|
|
|
|
const stats = await response.json();
|
|
$i('-eeprom-stat-size-fmt').textContent = $ffs(stats.size);
|
|
$i('-eeprom-stat-size-byte').textContent = `${stats.size.toLocaleString()} bytes`;
|
|
$i('-eeprom-stat-files').textContent = stats.files.toLocaleString();
|
|
$i('-eeprom-stat-uploads').textContent = stats.uploads.toLocaleString();
|
|
$i('-eeprom-stat-types').textContent = stats.types.toLocaleString();
|
|
$i('-eeprom-stat-members').textContent = stats.members.toLocaleString();
|
|
};
|
|
|
|
setInterval(update, 5 * 60 * 1000);
|
|
update();
|
|
})();
|