Merge pull request #5722 from ErisDS/download-count

Number formatting function for download counter
This commit is contained in:
Sebastian Gierlinger 2015-08-26 10:36:12 +02:00
commit 72f8d405ed

View File

@ -27,7 +27,14 @@ var DownloadCountPoller = Ember.Object.extend({
var self = this;
ajax(this.get('url')).then(function (data) {
self.set('count', data.count.toLocaleString());
var count = data.count.toString(),
pattern = /(-?\d+)(\d{3})/;
while (pattern.test(count)) {
count = count.replace(pattern, '$1,$2');
}
self.set('count', count);
}).catch(function () {
self.set('count', 'many, many');
});