mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-13 22:41:32 -05:00
Merge pull request #5722 from ErisDS/download-count
Number formatting function for download counter
This commit is contained in:
commit
4b8eedf2bc
1 changed files with 8 additions and 1 deletions
|
@ -27,7 +27,14 @@ var DownloadCountPoller = Ember.Object.extend({
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
ajax(this.get('url')).then(function (data) {
|
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 () {
|
}).catch(function () {
|
||||||
self.set('count', 'many, many');
|
self.set('count', 'many, many');
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue