Use custom function for number formatting

This commit is contained in:
2015-03-17 16:26:23 +07:00
parent bb0154638a
commit 32914aca2b
5 changed files with 14 additions and 9 deletions
+10
View File
@@ -17,3 +17,13 @@ function formatDate(ts, showYear) {
return month +' '+ day;
}
}
function formatNumber(num) {
x = (''+ num).split('.');
x1 = x[0];
x2 = x.length > 1 ? '.' + x[1] : '';
while (/(\d+)(\d{3})/.test(x1)) {
x1 = x1.replace(/(\d+)(\d{3})/, '$1,$2');
}
return x1 + x2;
}