otg msd ui

This commit is contained in:
Devaev Maxim
2019-11-10 00:59:27 +03:00
parent 67bc2b0e08
commit 090bb3866a
4 changed files with 236 additions and 116 deletions

View File

@@ -55,6 +55,15 @@ export var tools = new function() {
return id;
};
this.formatSize = function(size) {
if (size > 0) {
let index = Math.floor( Math.log(size) / Math.log(1024) );
return (size / Math.pow(1024, index)).toFixed(2) * 1 + " " + ["B", "KiB", "MiB", "GiB", "TiB"][index];
} else {
return 0;
}
};
/************************************************************************/
this.getCookie = function(name) {
@@ -110,6 +119,11 @@ export var tools = new function() {
};
};
this.setProgressPercent = function(el, title, percent) {
el.setAttribute("data-label", title);
$(`${el.id}-value`).style.width = `${percent}%`;
};
/************************************************************************/
let __debug = (new URL(window.location.href)).searchParams.get("debug");