Counter-Up icon indicating copy to clipboard operation
Counter-Up copied to clipboard

Numbers with spaces

Open ronnyandre opened this issue 11 years ago • 2 comments

Is it possible to add support for numbers with spaces as thousand separator? (e.g. 123 456)

ronnyandre avatar Jul 07 '14 11:07 ronnyandre

I've found a little solution,

on line 50 of jquery.counterup.js you will find:

newNum = newNum.toString().replace(/(\d+)(\d{3})/, '$1'+','+'$2');

Replace by this:

newNum = newNum.toString().replace(/(\d+)(\d{3})/, '$1'+' '+'$2');

For working, you need to use the comma (,) in the html

Le-future avatar Jul 15 '14 09:07 Le-future

In my fork I merged a bunch of PRs - it's already on bower and NPM. You can get this with the new "formatter" option:

$('.counter').counterUp({
  delay: 100,
  time: 1600,
  formatter: function (n) {
  return n.replace(/,/g, ' ');
});

ciromattia avatar Mar 24 '16 11:03 ciromattia