mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 06:40:54 +03:00
WebUI: improve fileSizeIEC function and make it more readable
Fixes #1974 Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -76,9 +76,17 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
|
|||||||
return div.innerHTML;
|
return div.innerHTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
function fileSizeIEC(a,b,c,d,e){
|
function fileSizeIEC(bytes){
|
||||||
return (b=Math,c=b.log,d=1024,e=c(a)/c(d)|0,a/b.pow(d,e)).toFixed(1)
|
const thresh = 1024;
|
||||||
+' '+(e?'KMGTPEZY'[--e]+'iB':'Bytes')
|
if (bytes < thresh){
|
||||||
|
return bytes + ' Bytes';
|
||||||
|
}
|
||||||
|
|
||||||
|
const units = ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
|
||||||
|
let i = Math.floor(Math.log(bytes) / Math.log(thresh));
|
||||||
|
let size = bytes / Math.pow(thresh, i);
|
||||||
|
|
||||||
|
return size.toFixed(1) + ' ' + units[i - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
function humanizeSpeed(a,b,c,d,e){
|
function humanizeSpeed(a,b,c,d,e){
|
||||||
|
|||||||
Reference in New Issue
Block a user