mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 14:05:46 +01:00
moved format number functions to utils
This commit is contained in:
@@ -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 '';
|
||||
|
||||
Reference in New Issue
Block a user