Fix averages on admin page
This commit is contained in:
@@ -24,12 +24,12 @@ function addUploadHistory(fileID) {
|
||||
|
||||
function printDate(date, hours, minutes, seconds) {
|
||||
let dateStr = date.getFullYear()
|
||||
+"-"+("00"+(date.getMonth()+1)).slice(-2)
|
||||
+"-"+("00"+date.getDate()).slice(-2)
|
||||
+ "-" + ("00" + (date.getMonth() + 1)).slice(-2)
|
||||
+ "-" + ("00" + date.getDate()).slice(-2)
|
||||
|
||||
if (hours) { dateStr += " "+("00"+date.getHours()).slice(-2) }
|
||||
if (minutes) { dateStr += ":"+("00"+date.getMinutes()).slice(-2) }
|
||||
if (seconds) { dateStr += ":"+("00"+date.getMinutes()).slice(-2) }
|
||||
if (hours) { dateStr += " " + ("00" + date.getHours()).slice(-2) }
|
||||
if (minutes) { dateStr += ":" + ("00" + date.getMinutes()).slice(-2) }
|
||||
if (seconds) { dateStr += ":" + ("00" + date.getMinutes()).slice(-2) }
|
||||
return dateStr
|
||||
}
|
||||
|
||||
@@ -50,9 +50,9 @@ function copyText(text) {
|
||||
}
|
||||
|
||||
function domainURL() {
|
||||
let url = window.location.protocol+"//"+window.location.hostname;
|
||||
let url = window.location.protocol + "//" + window.location.hostname;
|
||||
if (window.location.port != "") {
|
||||
url = url+":"+window.location.port;
|
||||
url = url + ":" + window.location.port;
|
||||
}
|
||||
return url;
|
||||
}
|
||||
@@ -60,44 +60,45 @@ function domainURL() {
|
||||
function formatNumber(amt, precision) {
|
||||
if (precision < 3) { precision = 3; }
|
||||
if (amt >= 1e6) {
|
||||
return (amt/1e6).toPrecision(precision) + "M";
|
||||
return (amt / 1e6).toPrecision(precision) + "M";
|
||||
} else if (amt >= 1e3) {
|
||||
return (amt/1e3).toPrecision(precision) + "k";
|
||||
return (amt / 1e3).toPrecision(precision) + "k";
|
||||
}
|
||||
return amt
|
||||
}
|
||||
|
||||
function formatThousands(x) {
|
||||
// Inject a space every three digits
|
||||
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ");
|
||||
}
|
||||
|
||||
function formatDataVolume(amt, precision) {
|
||||
if (precision < 3) { precision = 3; }
|
||||
if (amt >= 1e18) {
|
||||
return (amt/1e18).toPrecision(precision) + " EB";
|
||||
}else if (amt >= 1e15) {
|
||||
return (amt/1e15).toPrecision(precision) + " PB";
|
||||
}else if (amt >= 1e12) {
|
||||
return (amt/1e12).toPrecision(precision) + " TB";
|
||||
return (amt / 1e18).toPrecision(precision) + " EB";
|
||||
} else if (amt >= 1e15) {
|
||||
return (amt / 1e15).toPrecision(precision) + " PB";
|
||||
} else if (amt >= 1e12) {
|
||||
return (amt / 1e12).toPrecision(precision) + " TB";
|
||||
} else if (amt >= 1e9) {
|
||||
return (amt/1e9).toPrecision(precision) + " GB";
|
||||
return (amt / 1e9).toPrecision(precision) + " GB";
|
||||
} else if (amt >= 1e6) {
|
||||
return (amt/1e6).toPrecision(precision) + " MB";
|
||||
return (amt / 1e6).toPrecision(precision) + " MB";
|
||||
} else if (amt >= 1e3) {
|
||||
return (amt/1e3).toPrecision(precision) + " kB";
|
||||
return (amt / 1e3).toPrecision(precision) + " kB";
|
||||
}
|
||||
return amt + " B"
|
||||
return Math.floor(amt) + " B"
|
||||
}
|
||||
|
||||
const second = 1000
|
||||
const minute = second*60
|
||||
const hour = minute*60
|
||||
const day = hour*24
|
||||
const minute = second * 60
|
||||
const hour = minute * 60
|
||||
const day = hour * 24
|
||||
|
||||
function formatDuration(ms) {
|
||||
let res = ""
|
||||
if (ms >= day) { res += Math.floor(ms/day) + "d " }
|
||||
if (ms >= hour) { res += Math.floor((ms%day)/hour) + "h " }
|
||||
if (ms >= minute) { res += Math.floor((ms%hour)/minute) + "m " }
|
||||
return res + ((ms%minute)/second).toFixed(3) + "s"
|
||||
if (ms >= day) { res += Math.floor(ms / day) + "d " }
|
||||
if (ms >= hour) { res += Math.floor((ms % day) / hour) + "h " }
|
||||
if (ms >= minute) { res += Math.floor((ms % hour) / minute) + "m " }
|
||||
return res + ((ms % minute) / second).toFixed(3) + "s"
|
||||
}
|
||||
|
Reference in New Issue
Block a user