summaryrefslogtreecommitdiff
path: root/web/share/js/tools.js
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2019-11-10 00:59:27 +0300
committerDevaev Maxim <[email protected]>2019-11-10 01:02:31 +0300
commit090bb3866afb0f8e347ab5c3b9c1fba41f4d2255 (patch)
treee49e31d69e3c6b53f26231cd938d2fe6e59e49c8 /web/share/js/tools.js
parent67bc2b0e085addc841f6cf0911fd5a2249875a98 (diff)
otg msd ui
Diffstat (limited to 'web/share/js/tools.js')
-rw-r--r--web/share/js/tools.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/web/share/js/tools.js b/web/share/js/tools.js
index f249de33..8212b62f 100644
--- a/web/share/js/tools.js
+++ b/web/share/js/tools.js
@@ -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");