Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix niceNum implementation
- Previous state was not locale-dependent
  • Loading branch information
danmooney2 committed Oct 20, 2022
commit ead22d9d19d242354ee91b017d68305d0176e807
21 changes: 3 additions & 18 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -572,26 +572,11 @@ if (/MSIE [5-9]/.test(navigator.userAgent)) {

app.filter("niceNum", function () {
return function (num) {
var niceNum = "";
var step = 1;

while (num >= 1) {
rest = num % 1000;

//Put it in a nice string
if (num > 1000) {
if (rest < 10) {
rest = "00" + rest;
} else if (rest < 100) {
rest = "0" + rest;
}
}

niceNum = rest + "'" + niceNum;
num = Math.floor(num / 1000);
if (!num || isNaN(num)) {
return 0;
}

return niceNum === "" ? "0" : niceNum.substring(0, niceNum.length - 1);
return parseInt(num, 10).toLocaleString();
};
});

Expand Down