From 9d21a40ddf8426d9d9690eaf333c45d215fe65bd Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Tue, 25 Aug 2015 14:48:02 +0100 Subject: [PATCH] Number formatting function for download counter refs #5652 - safari doesn't support the nice toLocaleString function - this adds a manual, cross-browser way of adding commas in the right places to long number strings --- core/client/app/routes/setup/one.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/client/app/routes/setup/one.js b/core/client/app/routes/setup/one.js index 73c4628be7..13890e8464 100644 --- a/core/client/app/routes/setup/one.js +++ b/core/client/app/routes/setup/one.js @@ -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'); });