From 141e98f027b67b3f5f9ba61d3cc08a4de729ec93 Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Thu, 2 Apr 2015 02:33:17 +0200 Subject: [PATCH] replace Intl.NumberFormat with numeraljs --- app.js | 5 ++++- bower.json | 4 ++-- helper.js | 6 ++---- html/index.html | 1 - index.html | 1 - lib/main.js | 6 ++++-- tasks/build.js | 4 +--- 7 files changed, 13 insertions(+), 14 deletions(-) diff --git a/app.js b/app.js index d5e5602..1782431 100644 --- a/app.js +++ b/app.js @@ -8,6 +8,8 @@ require.config({ "tablesort": "../bower_components/tablesort/tablesort.min", "tablesort.numeric": "../bower_components/tablesort/src/sorts/tablesort.numeric", "d3": "../bower_components/d3/d3.min", + "numeral": "../bower_components/numeraljs/min/numeral.min", + "numeral-intl": "../bower_components/numeraljs/min/languages.min", "helper": "../helper" }, shim: { @@ -15,8 +17,9 @@ require.config({ "tablesort": { exports: "Tablesort" }, + "numeral-intl": ["numeral"], "tablesort.numeric": ["tablesort"], - "helper": [] + "helper": ["numeral-intl"] } }) diff --git a/bower.json b/bower.json index 01cbcd2..d102891 100644 --- a/bower.json +++ b/bower.json @@ -10,7 +10,6 @@ "dependencies": { "Leaflet.label": "~0.2.1", "chroma-js": "~0.6.1", - "intl": "~0.1.4", "leaflet": "~0.7.3", "ionicons": "~2.0.1", "moment": "~2.9.0", @@ -20,7 +19,8 @@ "es6-shim": "~0.27.1", "almond": "~0.3.1", "r.js": "~2.1.16", - "d3": "~3.5.5" + "d3": "~3.5.5", + "numeraljs": "~1.5.3" }, "authors": [ "Nils Schneider " diff --git a/helper.js b/helper.js index 51f07f6..7450d79 100644 --- a/helper.js +++ b/helper.js @@ -105,13 +105,11 @@ function showDistance(d) { if (isNaN(d.distance)) return - return (new Intl.NumberFormat("de-DE", {maximumFractionDigits: 0}).format(d.distance)) + " m" + return numeral(d.distance).format("0,0") + " m" } function showTq(d) { - var opts = { maximumFractionDigits: 0 } - - return (new Intl.NumberFormat("de-DE", opts).format(100/d.tq)) + "%" + return numeral(1/d.tq).format("0%") } function linkId(d) { diff --git a/html/index.html b/html/index.html index cc12838..57e9eb1 100644 --- a/html/index.html +++ b/html/index.html @@ -7,7 +7,6 @@ - diff --git a/index.html b/index.html index 932eb3a..268b1af 100644 --- a/index.html +++ b/index.html @@ -9,7 +9,6 @@ - diff --git a/lib/main.js b/lib/main.js index d7562f8..d9a2121 100644 --- a/lib/main.js +++ b/lib/main.js @@ -1,5 +1,5 @@ -define(["config", "moment", "router", "leaflet", "gui"], -function (config, moment, Router, L, GUI) { +define(["config", "moment", "router", "leaflet", "gui", "numeral"], +function (config, moment, Router, L, GUI, numeral) { return function () { function handleData(data) { var nodes = Object.keys(data[0].nodes).map(function (key) { return data[0].nodes[key] }) @@ -77,7 +77,9 @@ function (config, moment, Router, L, GUI) { } } + numeral.language("de") moment.locale("de") + var router = new Router() var urls = [ config.dataPath + "nodes.json", diff --git a/tasks/build.js b/tasks/build.js index cfa89a7..0db0b0a 100644 --- a/tasks/build.js +++ b/tasks/build.js @@ -13,9 +13,7 @@ module.exports = function(grunt) { dest: "build/" }, vendorjs: { - src: [ "es6-shim/es6-shim.min.js", - "intl/Intl.complete.js" - ], + src: [ "es6-shim/es6-shim.min.js" ], expand: true, cwd: "bower_components/", dest: "build/vendor/"