Issue 13468

Numbers format It would be nicer if numbers on ...

13468
Reporter: feedback bot
Assignee: cvizitiu
Type: Bug
Summary: Numbers format    It would be nicer if numbers on ...
Priority: Major
Resolution: Fixed
Status: Closed
Created: 2013-07-03 18:29:46.867
Updated: 2013-08-19 19:14:50.994
Resolved: 2013-08-19 19:14:50.973
        
        
Description: Numbers format

It would be nicer if numbers on home page (screenshot attached) have a format to be easier to read, maybe dot separated.

*Reporter*: Daniel Amariles]]>
    

Attachment Captura de pantalla 2013-07-03 a la(s) 11.23.14.png



Author: trobertson@gbif.org
Created: 2013-08-19 15:36:25.492
Updated: 2013-08-19 15:36:25.492
        
Not sure if there are any in the JS in the source code already, but something like https://code.google.com/p/jquery-numberformatter/ should be used for this.  The API response is correct to not include the formatting.


    


Author: trobertson@gbif.org
Created: 2013-08-19 16:08:44.145
Updated: 2013-08-19 16:08:44.145
        
This should do it [~cvizitiu@gbif.org]

JSFiddle here: http://jsfiddle.net/VSQjy/

but basically:
{code}
    function numberWithCommas(x) {
      return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
    }

		$(function() {
			$.getJSON(cfg.wsMetrics + 'occurrence/count?callback=?', function (data)
			{ $("#countOccurrences").html(numberWithCommas(data)); }
			);
			$.getJSON(cfg.wsClbSearch + '?dataset_key=d7dddbf4-2cf0-4f39-9b2a-bb099caae36c&limit=1&rank=species&status=accepted&callback=?', function (data)
			{ $("#countSpecies").html(numberWithCommas(data.count)); }
			);
			$.getJSON(cfg.wsRegSearch + '?limit=1&callback=?', function (data)
			{ $("#countDatasets").html(numberWithCommas(data.count)); }
			);
			$.getJSON(cfg.wsReg + 'organization?limit=1&callback=?', function (data)
			{ $("#countPublishers").html(numberWithCommas(data.count)); }
			);
		});
{code}
    


Author: cvizitiu@gbif.org
Comment: Applied the suggested JS
Created: 2013-08-19 19:14:50.992
Updated: 2013-08-19 19:14:50.992