feat: allow changing fixed param

This commit is contained in:
Barış Soner Uşaklı
2022-12-12 12:36:48 -05:00
parent 574dd8eecb
commit c007ebe326
2 changed files with 6 additions and 5 deletions

View File

@@ -439,15 +439,15 @@ const utils = {
return !utils.isAbsoluteUrl(url);
},
makeNumberHumanReadable: function (num) {
makeNumberHumanReadable: function (num, toFixed = 1) {
const n = parseInt(num, 10);
if (!n) {
return num;
}
if (n > 999999) {
return (n / 1000000).toFixed(1) + 'm';
return (n / 1000000).toFixed(toFixed) + 'm';
} else if (n > 999) {
return (n / 1000).toFixed(1) + 'k';
return (n / 1000).toFixed(toFixed) + 'k';
}
return n;
},

View File

@@ -17,8 +17,9 @@ utils.getLanguage = function () {
utils.makeNumbersHumanReadable = function (elements) {
elements.each(function () {
$(this)
.html(utils.makeNumberHumanReadable($(this).attr('title')))
const $this = $(this);
const toFixed = $this.attr('data-toFixed') || 1;
$this.html(utils.makeNumberHumanReadable($(this).attr('title'), toFixed))
.removeClass('hidden');
});
};