gui: kiB -> KiB (fixes #5017) (#5021)

This commit is contained in:
Simon Frei 2018-06-20 16:51:30 +02:00 committed by GitHub
parent d69a9d52a9
commit 238476bfcd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -205,8 +205,8 @@ function unitPrefixed(input, binary) {
if (input === undefined || isNaN(input)) { if (input === undefined || isNaN(input)) {
return '0 '; return '0 ';
} }
factor = 1000; var factor = 1000;
i = ''; var i = '';
if (binary) { if (binary) {
factor = 1024; factor = 1024;
i = 'i' i = 'i'
@ -237,10 +237,14 @@ function unitPrefixed(input, binary) {
} }
if (input > factor) { if (input > factor) {
input /= factor; input /= factor;
if (binary && input >= 1000) { var prefix = ' k';
return input.toLocaleString(undefined, {maximumFractionDigits: 0}) + ' k' + i; if (binary) {
prefix = ' K';
} }
return input.toLocaleString(undefined, {maximumSignificantDigits: 3}) + ' k' + i; if (binary && input >= 1000) {
return input.toLocaleString(undefined, {maximumFractionDigits: 0}) + prefix + i;
}
return input.toLocaleString(undefined, {maximumSignificantDigits: 3}) + prefix + i;
} }
return Math.round(input).toLocaleString() + ' '; return Math.round(input).toLocaleString() + ' ';
}; };