summaryrefslogtreecommitdiff
path: root/web/share/js/tools.js
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2023-03-19 20:14:14 +0200
committerMaxim Devaev <[email protected]>2023-03-19 20:14:14 +0200
commitb5d10afccaa828f5642f1bdc37c9bbc36cdedcb8 (patch)
tree45eb50233be8b8204f879df47545dea63358bc4d /web/share/js/tools.js
parent8798c2f8df694b8dcaedd0fee9a7c0a2fe8fc7d5 (diff)
refactoring
Diffstat (limited to 'web/share/js/tools.js')
-rw-r--r--web/share/js/tools.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/web/share/js/tools.js b/web/share/js/tools.js
index ca31f1f8..07c8da19 100644
--- a/web/share/js/tools.js
+++ b/web/share/js/tools.js
@@ -300,6 +300,18 @@ export var tools = new function() {
el.setAttribute("data-label", title);
$(`${el.id}-value`).style.width = `${percent}%`;
},
+ "setPercentOf": function(el, max, value) {
+ let percent = Math.round(value * 100 / max);
+ self.progress.setValue(el, `${percent}%`, percent);
+ },
+ "setSizeOf": function(el, title, size, free) {
+ let size_str = self.formatSize(size);
+ let used = size - free;
+ let used_str = self.formatSize(used);
+ let percent = used / size * 100;
+ title = title.replace("%s", `${used_str} of ${size_str}`);
+ self.progress.setValue(el, title, percent);
+ },
};
};