diff --git a/public/src/app.js b/public/src/app.js index 4be2beb8b9..75270eb325 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -299,8 +299,7 @@ var socket, app.makeNumbersHumanReadable = function(selector) { $(selector).each(function() { - var num = parseInt($(this).html(), 10); - $(this).html(utils.makeNumberHumanReadable(num)); + $(this).html(utils.makeNumberHumanReadable($(this).attr('title'))); }); } diff --git a/public/src/utils.js b/public/src/utils.js index f9e9c2d8d6..3e890b3f73 100644 --- a/public/src/utils.js +++ b/public/src/utils.js @@ -207,14 +207,17 @@ }, makeNumberHumanReadable: function(num) { - num = parseInt(num, 10); - if (num > 999999) { - return (num / 1000000).toFixed(1) + 'm'; + var n = parseInt(num, 10); + if(!n) { + return num; } - else if(num > 999) { - return (num / 1000).toFixed(1) + 'k'; + if (n > 999999) { + return (n / 1000000).toFixed(1) + 'm'; } - return num; + else if(n > 999) { + return (n / 1000).toFixed(1) + 'k'; + } + return n; } };