From 719c83e23485ef7caefbc574c23ba91a2e661ce8 Mon Sep 17 00:00:00 2001 From: raylu Date: Tue, 22 Oct 2013 23:56:11 -0700 Subject: whelp.gg, footer, firefox format_isk fix --- web/static/js/common.js | 46 ++++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 18 deletions(-) (limited to 'web/static/js/common.js') diff --git a/web/static/js/common.js b/web/static/js/common.js index e7a4e75..6ea91e3 100644 --- a/web/static/js/common.js +++ b/web/static/js/common.js @@ -1,20 +1,30 @@ -Object.append(window.ykill, { - 'api': function(path, cb) { - new Request.JSON({ - 'url': ykill.api_host + path, - 'onSuccess': cb, - }).get(); - }, +(function() { + var locale_options = false; + try { + (0).toLocaleString('i'); + } catch (e) { // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString#Example:_Checking_for_support_for_locales_and_options_arguments + locale_options = e.name == 'RangeError'; + } + Object.append(window.ykill, { + 'api': function(path, cb) { + new Request.JSON({ + 'url': ykill.api_host + path, + 'onSuccess': cb, + }).get(); + }, - 'portrait': function(id, text, img_dir, img_suffix) { - var img = new Element('img', { - 'src': '//image.eveonline.com/' + img_dir + '/' + id + img_suffix, - 'alt': text, - }); - return img; - }, + 'portrait': function(id, text, img_dir, img_suffix) { + var img = new Element('img', { + 'src': '//image.eveonline.com/' + img_dir + '/' + id + img_suffix, + 'alt': text, + }); + return img; + }, - 'format_isk': function(isk) { - return isk.toLocaleString('en-US', {'minimumFractionDigits': 2, 'maximumFractionDigits': 2}); - }, -}); + 'format_isk': function(isk) { + if (!locale_options) + return parseFloat(isk.toFixed(2)).toLocaleString(); + return isk.toLocaleString('en-US', {'minimumFractionDigits': 2, 'maximumFractionDigits': 2}); + }, + }); +})(); -- cgit v1.2.3