From 102c8af8734f506fe6448377d249d1ab21832d1e Mon Sep 17 00:00:00 2001
From: Nils Schneider <nils@nilsschneider.net>
Date: Sun, 19 Jul 2015 19:45:25 +0200
Subject: [PATCH] move config.js to config.json, load by XHR

---
 README.md                                | 18 +++++++++---------
 app.js                                   |  2 +-
 config.js.example => config.json.example |  4 ++--
 lib/main.js                              |  6 +++---
 4 files changed, 15 insertions(+), 15 deletions(-)
 rename config.js.example => config.json.example (97%)

diff --git a/README.md b/README.md
index 7773335..176f249 100644
--- a/README.md
+++ b/README.md
@@ -37,9 +37,17 @@ Execute these commands on your server as a normal user to prepare the dependenci
     npm install bower grunt-cli
     node_modules/.bin/bower install
 
+# Building
+
+Just run the following command from the meshviewer directory:
+
+    node_modules/.bin/grunt
+
+This will generate `build/` containing all required files.
+
 # Configure
 
-Copy `config.js.example` to `config.js` and change it to match your community.
+Copy `config.json.example` to `build/config.json` and change it to match your community.
 
 ## dataPath (string)
 
@@ -133,12 +141,4 @@ Examples for `globalInfos`:
 
 In order to have global statistics available, you have to run the backend with parameter `--with-rrd` (this only creates globalGraph.png) or generate them in other ways.
 
-# Building
-
-Just run the following command from the meshviewer directory:
-
-    node_modules/.bin/grunt
-
-This will generate `build/` containing all required files.
-
 [CORS enabled]: http://enable-cors.org/server.html
diff --git a/app.js b/app.js
index 71c87e6..e848121 100644
--- a/app.js
+++ b/app.js
@@ -32,5 +32,5 @@ require.config({
 })
 
 require(["main", "helper"], function (main) {
-  main()
+  getJSON("config.json").then(main)
 })
diff --git a/config.js.example b/config.json.example
similarity index 97%
rename from config.js.example
rename to config.json.example
index fff1db5..8d7e9ed 100644
--- a/config.js.example
+++ b/config.json.example
@@ -1,4 +1,4 @@
-define({
+{
   "dataPath": "https://map.luebeck.freifunk.net/data/",
   "siteName": "Freifunk Lübeck",
   "mapSigmaScale": 0.5,
@@ -18,4 +18,4 @@ define({
       "name": "Stamen.TonerLite"
     }
   ]
-})
+}
diff --git a/lib/main.js b/lib/main.js
index bb2e740..c517768 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -1,6 +1,6 @@
-define(["../config", "moment", "router", "leaflet", "gui", "numeral"],
-function (config, moment, Router, L, GUI, numeral) {
-  return function () {
+define(["moment", "router", "leaflet", "gui", "numeral"],
+function (moment, Router, L, GUI, numeral) {
+  return function (config) {
     function handleData(data) {
       var dataNodes = data[0]
       var dataGraph = data[1]
-- 
GitLab