moved format number functions to utils

This commit is contained in:
barisusakli
2014-03-31 14:43:44 -04:00
parent f01cb88c57
commit b1a6d394e3
11 changed files with 35 additions and 35 deletions

View File

@@ -198,6 +198,12 @@
return (firstChar === '.' || firstChar === '/');
},
makeNumbersHumanReadable: function(elements) {
elements.each(function() {
$(this).html(utils.makeNumberHumanReadable($(this).attr('title')));
});
},
makeNumberHumanReadable: function(num) {
var n = parseInt(num, 10);
if(!n) {
@@ -212,6 +218,17 @@
return n;
},
addCommasToNumbers: function (elements) {
elements.each(function (index, element) {
$(element).html(utils.addCommas($(element).html()));
});
},
// takes a string like 1000 and returns 1,000
addCommas: function (text) {
return text.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");
},
toISOString: function(timestamp) {
if(!timestamp) {
return '';