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

European "." and ","

Open Guaito opened this issue 10 years ago • 2 comments

Can you manage also the european number format (opposite to english) in terms of "." and "," inside numbers? i.e.:

  • "." for > thousand
  • "," for decimal < 1

Thanks in advance

Guaito avatar May 28 '15 20:05 Guaito

Hi,

I was looking for this, too. Since I saw there was not much of feedback, I thought I'd look for it myself.

Might not be the most suitable solution, but I've added:

newNum = newNum.replace(/\./g, settings.commaSeparator);

after:

newNum = parseFloat(num / divisions * i).toFixed(decimalPlaces);

inside the if (isFloat) {}-statement.

I've also added a couple of parameters to the settings for re-use, which you can adjust whenever you call the function:

    // Defaults
    var settings = $.extend({
      'time': 400,
      'delay': 10,
      'commaSeparator': '.',
      'thousandSeparator': ','
    }, options);

Blacksnipe avatar Oct 08 '15 07:10 Blacksnipe

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, for example if you have no decimals:

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

Feel free to mangle the regex for decimal support.

ciromattia avatar Mar 24 '16 11:03 ciromattia