main.js: create only after data is ready
This commit is contained in:
parent
64c9e42eb4
commit
090254c781
40
lib/main.js
40
lib/main.js
@ -3,34 +3,40 @@ function (Router, Map, Sidebar, Meshstats, Linklist, SimpleNodelist, Infobox) {
|
||||
getJSON("config.json").then(main)
|
||||
|
||||
function main(config) {
|
||||
moment.locale("de")
|
||||
var linklist, lostnodeslist, map, meshstats, newnodeslist, router
|
||||
|
||||
var linkScale = chroma.scale(chroma.interpolate.bezier(['green', 'yellow', 'red'])).domain([1, 5])
|
||||
var sidebar = new Sidebar(document.body)
|
||||
var router = new Router(config)
|
||||
function createGUI() {
|
||||
moment.locale("de")
|
||||
|
||||
var map = new Map(linkScale, sidebar, router)
|
||||
document.body.insertBefore(map.div, document.body.firstChild)
|
||||
router = new Router(config)
|
||||
|
||||
var infobox = new Infobox(config, sidebar, router)
|
||||
var meshstats = new Meshstats()
|
||||
var newnodeslist = new SimpleNodelist(config, "firstseen", router, "Neue Knoten")
|
||||
var lostnodeslist = new SimpleNodelist(config, "lastseen", router, "Verschwundene Knoten")
|
||||
var linklist = new Linklist(linkScale, 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)
|
||||
|
||||
sidebar.add(meshstats)
|
||||
sidebar.add(newnodeslist)
|
||||
sidebar.add(lostnodeslist)
|
||||
sidebar.add(linklist)
|
||||
map = new Map(linkScale, sidebar, router)
|
||||
document.body.insertBefore(map.div, document.body.firstChild)
|
||||
|
||||
router.addTarget(infobox)
|
||||
router.addTarget(map)
|
||||
meshstats = new Meshstats()
|
||||
newnodeslist = new SimpleNodelist(config, "firstseen", router, "Neue Knoten")
|
||||
lostnodeslist = new SimpleNodelist(config, "lastseen", router, "Verschwundene Knoten")
|
||||
linklist = new Linklist(linkScale, router)
|
||||
|
||||
sidebar.add(meshstats)
|
||||
sidebar.add(newnodeslist)
|
||||
sidebar.add(lostnodeslist)
|
||||
sidebar.add(linklist)
|
||||
|
||||
router.addTarget(infobox)
|
||||
router.addTarget(map)
|
||||
}
|
||||
|
||||
var urls = [ config.dataPath + 'nodes.json',
|
||||
config.dataPath + 'graph.json'
|
||||
]
|
||||
|
||||
Promise.all(urls.map(getJSON))
|
||||
.then(function (d) { createGUI(); return d })
|
||||
.then(handle_data)
|
||||
.then(function () { router.loadState(window.location.hash) })
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user