summaryrefslogtreecommitdiff
path: root/web/share/js/tools.js
diff options
context:
space:
mode:
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");