refactoring

This commit is contained in:
Maxim Devaev
2023-03-19 20:14:14 +02:00
parent 8798c2f8df
commit b5d10afcca
2 changed files with 28 additions and 34 deletions

View File

@@ -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);
},
};
};