Browse Source

handle most dependencies using requirejs

Nils Schneider 9 years ago
parent
commit
5651c605de
9 changed files with 30 additions and 15 deletions
  1. 21 0
      app.js
  2. 1 7
      index.html
  3. 1 1
      lib/infobox/node.js
  4. 1 1
      lib/linklist.js
  5. 2 2
      lib/main.js
  6. 1 1
      lib/map.js
  7. 1 1
      lib/meshstats.js
  8. 1 1
      lib/nodelist.js
  9. 1 1
      lib/simplenodelist.js

+ 21 - 0
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"])

+ 1 - 7
index.html

@@ -9,15 +9,9 @@
     <link rel="stylesheet" href="bower_components/ionicons/css/ionicons.min.css">
     <link rel="stylesheet" href="style.css">
     <script src="bower_components/es6-shim/es6-shim.min.js"></script>
-    <script src="bower_components/chroma-js/chroma.min.js"></script>
-    <script src="bower_components/moment/min/moment-with-locales.min.js"></script>
-    <script src="bower_components/leaflet/dist/leaflet.js"></script>
-    <script src="bower_components/Leaflet.label/dist/leaflet.label.js"></script>
-    <script src="bower_components/tablesort/tablesort.min.js"></script>
-    <script src="bower_components/tablesort/src/sorts/tablesort.numeric.js"></script>
     <script src="bower_components/intl/Intl.complete.js"></script>
     <script src="helper.js"></script>
-    <script src="bower_components/requirejs/require.js" data-main="lib/main"></script>
+    <script src="bower_components/requirejs/require.js" data-main="app"></script>
   </head>
   <body>
   </body>

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

+ 1 - 1
lib/linklist.js

@@ -1,4 +1,4 @@
-define(function () {
+define(["tablesort", "tablesort.numeric"], function (Tablesort) {
   return function(linkScale, router) {
     var self = this
     var el

+ 2 - 2
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) {

+ 1 - 1
lib/map.js

@@ -1,4 +1,4 @@
-define(function () {
+define(["leaflet", "moment", "leaflet.label"], function (L, moment) {
   var options = { worldCopyJump: true,
                   zoomControl: false
                 }

+ 1 - 1
lib/meshstats.js

@@ -1,4 +1,4 @@
-define(function () {
+define(["moment"], function (moment) {
   return function () {
     var self = this
     var p

+ 1 - 1
lib/nodelist.js

@@ -1,4 +1,4 @@
-define(function () {
+define(["tablesort", "tablesort.numeric"], function (Tablesort) {
   return function(router) {
     var self = this
     var el

+ 1 - 1
lib/simplenodelist.js

@@ -1,4 +1,4 @@
-define(function () {
+define(["moment"], function (moment) {
   return function(config, field, router, title) {
     var self = this
     var el