mirror of
https://github.com/HeyPuter/puter.git
synced 2026-09-20 20:26:21 +00:00
ux: use financial units instead of SI for credits
Instead of K, M, G, T, P it's K, M, B, T, Q.
This commit is contained in:
@@ -88,8 +88,8 @@ export default {
|
||||
<h3 style="margin-bottom: 5px; font-size: 14px;">${html_encode(name)}:</h3>
|
||||
<span style="font-size: 13px; margin-bottom: 3px;">${i18n('used_of', {
|
||||
...entry,
|
||||
used: window.format_SI(entry.used),
|
||||
available: window.format_SI(entry.available),
|
||||
used: window.format_credits(entry.used),
|
||||
available: window.format_credits(entry.available),
|
||||
})}</span>
|
||||
<div class="usage-progbar-wrapper" style="width: 100%;">
|
||||
<div class="usage-progbar" style="width: ${Number(entry.usage_percentage)}%;"><span class="usage-progbar-percent">${Number(entry.usage_percentage)}%</span></div>
|
||||
@@ -116,8 +116,8 @@ export default {
|
||||
.innerText = '' + Number(event.usage_percentage) + '%';
|
||||
const used_of_str = i18n('used_of', {
|
||||
...event,
|
||||
used: window.format_SI(event.used),
|
||||
available: window.format_SI(event.available),
|
||||
used: window.format_credits(event.used),
|
||||
available: window.format_credits(event.available),
|
||||
});
|
||||
el_divContent
|
||||
.querySelector(`[data-id=${sanitize_id(event.id)}] > span`)
|
||||
|
||||
+19
-2
@@ -2730,7 +2730,7 @@ window.get_profile_picture = async function(username){
|
||||
return icon;
|
||||
}
|
||||
|
||||
window.format_SI = (num) => {
|
||||
window.format_with_units = (num, { mulUnits, divUnits, precision = 3 }) => {
|
||||
if ( num === 0 ) return "0";
|
||||
|
||||
const mulUnits = ["", "K", "M", "G", "T", "P", "E", "Z", "Y"];
|
||||
@@ -2749,7 +2749,24 @@ window.format_SI = (num) => {
|
||||
}
|
||||
|
||||
const scaled = num / Math.pow(10, exp * 3);
|
||||
const rounded = Number.parseFloat(scaled.toPrecision(3));
|
||||
const rounded = Number.parseFloat(scaled.toPrecision(precision));
|
||||
|
||||
return `${rounded}${symbol}`;
|
||||
};
|
||||
|
||||
window.format_SI = (num) => {
|
||||
if ( num === 0 ) return "0";
|
||||
|
||||
const mulUnits = ["", "K", "M", "G", "T", "P", "E", "Z", "Y"];
|
||||
const divUnits = ["m", "µ", "n", "p", "f", "a", "z", "y"];
|
||||
|
||||
return window.format_with_units(num, { mulUnits, divUnits });
|
||||
};
|
||||
|
||||
window.format_credits = (num) => {
|
||||
if ( num === 0 ) return "0";
|
||||
|
||||
const mulUnits = ["", "K", "M", "B", "T", "Q"];
|
||||
|
||||
return window.format_with_units(num, { mulUnits })
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user