From 5651c605deee368a2516000c8c9b748cef250759 Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Sun, 29 Mar 2015 03:35:10 +0200 Subject: [PATCH] handle most dependencies using requirejs --- app.js | 21 +++++++++++++++++++++ index.html | 8 +------- lib/infobox/node.js | 2 +- lib/linklist.js | 2 +- lib/main.js | 4 ++-- lib/map.js | 2 +- lib/meshstats.js | 2 +- lib/nodelist.js | 2 +- lib/simplenodelist.js | 2 +- 9 files changed, 30 insertions(+), 15 deletions(-) create mode 100644 app.js diff --git a/app.js b/app.js new file mode 100644 index 0000000..9906995 --- /dev/null +++ b/app.js @@ -0,0 +1,21 @@ +require.config({ + urlArgs: "bust=" + (new Date()).getTime(), + baseUrl: "lib", + paths: { + "leaflet": "../bower_components/leaflet/dist/leaflet", + "leaflet.label": "../bower_components/Leaflet.label/dist/leaflet.label", + "chroma-js": "../bower_components/chroma-js/chroma.min", + "moment": "../bower_components/moment/min/moment-with-locales.min", + "tablesort": "../bower_components/tablesort/tablesort.min", + "tablesort.numeric": "../bower_components/tablesort/src/sorts/tablesort.numeric" + }, + shim: { + "leaflet.label": ["leaflet"], + "tablesort": { + exports: "Tablesort" + }, + "tablesort.numeric": ["tablesort"] + } +}) + +require(["main"]) diff --git a/index.html b/index.html index 6342a65..464ada1 100644 --- a/index.html +++ b/index.html @@ -9,15 +9,9 @@ - - - - - - - + diff --git a/lib/infobox/node.js b/lib/infobox/node.js index e03709e..c46a020 100644 --- a/lib/infobox/node.js +++ b/lib/infobox/node.js @@ -1,4 +1,4 @@ -define(function () { +define(["moment", "tablesort", "tablesort.numeric"], function (moment, Tablesort) { return function(config, el, router, d) { var h2 = document.createElement("h2") h2.textContent = d.nodeinfo.hostname diff --git a/lib/linklist.js b/lib/linklist.js index 2856a48..97fe9f4 100644 --- a/lib/linklist.js +++ b/lib/linklist.js @@ -1,4 +1,4 @@ -define(function () { +define(["tablesort", "tablesort.numeric"], function (Tablesort) { return function(linkScale, router) { var self = this var el diff --git a/lib/main.js b/lib/main.js index 4c47767..46f38fb 100644 --- a/lib/main.js +++ b/lib/main.js @@ -1,5 +1,5 @@ -require(["config", "router", "map", "sidebar", "tabs", "container", "meshstats", "linklist", "nodelist", "simplenodelist", "infobox/main"], -function (Config, Router, Map, Sidebar, Tabs, Container, Meshstats, Linklist, Nodelist, SimpleNodelist, Infobox) { +require(["config", "moment", "chroma-js", "router", "map", "sidebar", "tabs", "container", "meshstats", "linklist", "nodelist", "simplenodelist", "infobox/main"], +function (Config, moment, chroma, Router, Map, Sidebar, Tabs, Container, Meshstats, Linklist, Nodelist, SimpleNodelist, Infobox) { main(Config) function main(config) { diff --git a/lib/map.js b/lib/map.js index 2a3577d..a295000 100644 --- a/lib/map.js +++ b/lib/map.js @@ -1,4 +1,4 @@ -define(function () { +define(["leaflet", "moment", "leaflet.label"], function (L, moment) { var options = { worldCopyJump: true, zoomControl: false } diff --git a/lib/meshstats.js b/lib/meshstats.js index 8ee10f7..b8ca925 100644 --- a/lib/meshstats.js +++ b/lib/meshstats.js @@ -1,4 +1,4 @@ -define(function () { +define(["moment"], function (moment) { return function () { var self = this var p diff --git a/lib/nodelist.js b/lib/nodelist.js index 184f113..68869ab 100644 --- a/lib/nodelist.js +++ b/lib/nodelist.js @@ -1,4 +1,4 @@ -define(function () { +define(["tablesort", "tablesort.numeric"], function (Tablesort) { return function(router) { var self = this var el diff --git a/lib/simplenodelist.js b/lib/simplenodelist.js index 11f99f8..5302319 100644 --- a/lib/simplenodelist.js +++ b/lib/simplenodelist.js @@ -1,4 +1,4 @@ -define(function () { +define(["moment"], function (moment) { return function(config, field, router, title) { var self = this var el