generalize setData/dataTargets
This commit is contained in:
parent
a031ac336d
commit
f1512a6ed7
36
lib/main.js
36
lib/main.js
@ -1,27 +1,33 @@
|
||||
define(["config", "moment", "chroma-js", "router", "map", "sidebar", "tabs", "container", "meshstats", "linklist", "nodelist", "simplenodelist", "infobox/main", "leaflet"],
|
||||
function (config, moment, chroma, Router, Map, Sidebar, Tabs, Container, Meshstats, Linklist, Nodelist, SimpleNodelist, Infobox, L) {
|
||||
return function () {
|
||||
var linklist, lostnodeslist, map, meshstats, newnodeslist, nodelist, router
|
||||
var dataTargets = []
|
||||
var router
|
||||
|
||||
function createGUI() {
|
||||
moment.locale("de")
|
||||
|
||||
router = new Router()
|
||||
|
||||
var linkScale = chroma.scale(chroma.interpolate.bezier(["green", "yellow", "red"])).domain([1, 5])
|
||||
var sidebar = new Sidebar(document.body)
|
||||
var infobox = new Infobox(config, sidebar, router)
|
||||
var tabs = new Tabs()
|
||||
var overview = new Container()
|
||||
|
||||
map = new Map(linkScale, sidebar, router)
|
||||
var map = new Map(linkScale, sidebar, router)
|
||||
document.body.insertBefore(map.div, document.body.firstChild)
|
||||
|
||||
meshstats = new Meshstats()
|
||||
newnodeslist = new SimpleNodelist(config, "new", "firstseen", router, "Neue Knoten")
|
||||
lostnodeslist = new SimpleNodelist(config, "lost", "lastseen", router, "Verschwundene Knoten")
|
||||
nodelist = new Nodelist(router)
|
||||
linklist = new Linklist(linkScale, router)
|
||||
var meshstats = new Meshstats()
|
||||
var newnodeslist = new SimpleNodelist(config, "new", "firstseen", router, "Neue Knoten")
|
||||
var lostnodeslist = new SimpleNodelist(config, "lost", "lastseen", router, "Verschwundene Knoten")
|
||||
var nodelist = new Nodelist(router)
|
||||
var linklist = new Linklist(linkScale, router)
|
||||
|
||||
dataTargets.push(map)
|
||||
dataTargets.push(meshstats)
|
||||
dataTargets.push(newnodeslist)
|
||||
dataTargets.push(lostnodeslist)
|
||||
dataTargets.push(nodelist)
|
||||
dataTargets.push(linklist)
|
||||
|
||||
overview.add(meshstats)
|
||||
overview.add(newnodeslist)
|
||||
@ -109,6 +115,8 @@ function (config, moment, chroma, Router, Map, Sidebar, Tabs, Container, Meshsta
|
||||
}
|
||||
}
|
||||
|
||||
router = new Router()
|
||||
|
||||
var urls = [ config.dataPath + "nodes.json",
|
||||
config.dataPath + "graph.json"
|
||||
]
|
||||
@ -120,13 +128,9 @@ function (config, moment, chroma, Router, Map, Sidebar, Tabs, Container, Meshsta
|
||||
})
|
||||
.then(handleData)
|
||||
.then(function (d) {
|
||||
map.setData(d)
|
||||
meshstats.setData(d)
|
||||
nodelist.setData(d)
|
||||
linklist.setData(d)
|
||||
newnodeslist.setData(d)
|
||||
lostnodeslist.setData(d)
|
||||
router.setData(d)
|
||||
dataTargets.forEach(function (t) {
|
||||
t.setData(d)
|
||||
})
|
||||
})
|
||||
.then(function () { router.start() })
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user