Selaa lähdekoodia

move config.js to config.json, load by XHR

Nils Schneider 8 vuotta sitten
vanhempi
commit
102c8af873
4 muutettua tiedostoa jossa 15 lisäystä ja 15 poistoa
  1. 9 9
      README.md
  2. 1 1
      app.js
  3. 2 2
      config.json.example
  4. 3 3
      lib/main.js

+ 9 - 9
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

+ 1 - 1
app.js

@@ -32,5 +32,5 @@ require.config({
 })
 
 require(["main", "helper"], function (main) {
-  main()
+  getJSON("config.json").then(main)
 })

+ 2 - 2
config.js.example → 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"
     }
   ]
-})
+}

+ 3 - 3
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]