restructure handle_data/main
This commit is contained in:
parent
45241d38e1
commit
c9351d1258
12
history.js
12
history.js
@ -39,13 +39,16 @@ function main() {
|
|||||||
document.body.insertBefore(mapDiv, document.body.firstChild)
|
document.body.insertBefore(mapDiv, document.body.firstChild)
|
||||||
|
|
||||||
var map = L.map(mapDiv, options)
|
var map = L.map(mapDiv, options)
|
||||||
|
var sidebar = mkSidebar(document.body)
|
||||||
|
var infobox = new Infobox(sidebar)
|
||||||
|
var gotoAnything = new gotoBuilder(config, infobox, showNodeinfo, showLinkinfo)
|
||||||
|
|
||||||
var urls = [ config.dataPath + 'nodes.json',
|
var urls = [ config.dataPath + 'nodes.json',
|
||||||
config.dataPath + 'graph.json'
|
config.dataPath + 'graph.json'
|
||||||
]
|
]
|
||||||
|
|
||||||
var p = Promise.all(urls.map(getJSON))
|
var p = Promise.all(urls.map(getJSON))
|
||||||
p.then(handle_data(config, map))
|
p.then(handle_data(config, sidebar, infobox, map, gotoAnything))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +88,7 @@ function subtract(a, b) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function handle_data(config, map) {
|
function handle_data(config, sidebar, infobox, map, gotoAnything) {
|
||||||
return function (data) {
|
return function (data) {
|
||||||
var nodedict = data[0]
|
var nodedict = data[0]
|
||||||
var nodes = Object.keys(nodedict.nodes).map(function (key) { return nodedict.nodes[key] })
|
var nodes = Object.keys(nodedict.nodes).map(function (key) { return nodedict.nodes[key] })
|
||||||
@ -151,11 +154,6 @@ function handle_data(config, map) {
|
|||||||
d.target.node.neighbours.push({ node: d.source.node, link: d })
|
d.target.node.neighbours.push({ node: d.source.node, link: d })
|
||||||
})
|
})
|
||||||
|
|
||||||
var sidebar = mkSidebar(document.body)
|
|
||||||
var infobox = new Infobox(sidebar)
|
|
||||||
|
|
||||||
var gotoAnything = new gotoBuilder(config, infobox, showNodeinfo, showLinkinfo)
|
|
||||||
|
|
||||||
var markers = mkmap(map, sidebar, now, newnodes, lostnodes, onlinenodes, links, gotoAnything)
|
var markers = mkmap(map, sidebar, now, newnodes, lostnodes, onlinenodes, links, gotoAnything)
|
||||||
|
|
||||||
gotoAnything.addMarkers(markers)
|
gotoAnything.addMarkers(markers)
|
||||||
|
Loading…
Reference in New Issue
Block a user