This commit is contained in:
Joe Ma 2022-09-12 12:42:20 +08:00
parent 9c72be7133
commit bd26de1a67
No known key found for this signature in database
GPG key ID: 7A0ECF5F5EDC587F

View file

@ -78,13 +78,18 @@
}
function update_file_status() {
const status = document.getElementById('file_stats');
if (this.files[0] === undefined) {
status.textContent = '0 bytes';
return;
}
let bytes = this.files[0]?.size ?? 0;
let size = bytes + ' bytes';
const units = ['KiB', 'MiB', 'GiB', 'TiB'];
for (let i = 0, approx = bytes / 1024; approx > 1; approx /= 1024, i++) {
size = approx.toFixed(3) + ' ' + units[i];
}
document.getElementById('file_size').textContent = `${this.files[0]?.type ?? 'application/application/octet-stream'}, ${size}`;
status.textContent = `${this.files[0]?.type ?? 'application/application/octet-stream'}, ${size}`;
}
function toggle_password() {