JS cleanup: moved format Currency & formatNumber functions together

with network tables JS
This commit is contained in:
Chuck Williams 2017-05-04 03:05:02 -06:00 committed by moocowmoo
parent fe72accf9b
commit 4ccf18a881
2 changed files with 11 additions and 12 deletions

View file

@ -1,12 +0,0 @@
/**
* Created by cwilliams on 5/4/17.
*/
function formatNumber (num) {
return num.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,")
}
function formatCurrency (num,decimal) {
var _decimal;
_decimal = typeof decimal !== "undefined" ? decimal : 2;
return parseFloat(num).toFixed(_decimal).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,")
}

View file

@ -113,6 +113,17 @@
} }
}); });
function formatNumber(num) {
return num.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,');
}
function formatCurrency(num,decimal) {
var _decimal;
_decimal = typeof decimal !== 'undefined' ? decimal : 2;
return parseFloat(num).toFixed(_decimal).replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,');
}
}(jQuery)); }(jQuery));