diff --git a/public/src/utils.common.js b/public/src/utils.common.js index eecd064bf8..8396ce4bf9 100644 --- a/public/src/utils.common.js +++ b/public/src/utils.common.js @@ -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; }, diff --git a/public/src/utils.js b/public/src/utils.js index 77b2377c7f..bcb4bdb98f 100644 --- a/public/src/utils.js +++ b/public/src/utils.js @@ -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'); }); };