rename gotoAnything to router

This commit is contained in:
Nils Schneider 2015-03-25 19:45:21 +01:00
commit 265cb2e5eb
7 changed files with 39 additions and 39 deletions

View file

@ -10,25 +10,25 @@ function (Map, Sidebar, Meshstats, Linklist, SimpleNodelist, Infobox) {
var sidebar = new Sidebar(document.body)
var gotoAnything = new Router(config)
var router = new Router(config)
var infobox = new Infobox(config, sidebar, gotoAnything)
gotoAnything.addTarget(infobox)
var infobox = new Infobox(config, sidebar, router)
router.addTarget(infobox)
var map = new Map(linkScale, sidebar, gotoAnything)
var map = new Map(linkScale, sidebar, router)
document.body.insertBefore(map.div, document.body.firstChild)
gotoAnything.addTarget(map)
router.addTarget(map)
var meshstats = new Meshstats()
sidebar.add(meshstats)
var newnodeslist = new SimpleNodelist(config, "firstseen", gotoAnything, "Neue Knoten")
var newnodeslist = new SimpleNodelist(config, "firstseen", router, "Neue Knoten")
sidebar.add(newnodeslist)
var lostnodeslist = new SimpleNodelist(config, "lastseen", gotoAnything, "Verschwundene Knoten")
var lostnodeslist = new SimpleNodelist(config, "lastseen", router, "Verschwundene Knoten")
sidebar.add(lostnodeslist)
var linklist = new Linklist(linkScale, gotoAnything)
var linklist = new Linklist(linkScale, router)
sidebar.add(linklist)
var urls = [ config.dataPath + 'nodes.json',
@ -36,11 +36,11 @@ function (Map, Sidebar, Meshstats, Linklist, SimpleNodelist, Infobox) {
]
var p = Promise.all(urls.map(getJSON))
p.then(handle_data(sidebar, meshstats, linklist, newnodeslist, lostnodeslist, infobox, map, gotoAnything))
p.then(handle_data(sidebar, meshstats, linklist, newnodeslist, lostnodeslist, infobox, map, router))
})
}
function handle_data(sidebar, meshstats, linklist, newnodeslist, lostnodeslist, infobox, map, gotoAnything) {
function handle_data(sidebar, meshstats, linklist, newnodeslist, lostnodeslist, infobox, map, router) {
return function (data) {
var nodedict = data[0]
var nodes = Object.keys(nodedict.nodes).map(function (key) { return nodedict.nodes[key] })
@ -122,12 +122,12 @@ function (Map, Sidebar, Meshstats, Linklist, SimpleNodelist, Infobox) {
historyDict.links[linkId(d)] = d
})
gotoAnything.reset(false)
router.reset(false)
gotoHistory(gotoAnything, historyDict, window.location.hash)
gotoHistory(router, historyDict, window.location.hash)
window.onpopstate = function (d) {
gotoHistory(gotoAnything, historyDict, d.state)
gotoHistory(router, historyDict, d.state)
}
}
}
@ -146,7 +146,7 @@ function (Map, Sidebar, Meshstats, Linklist, SimpleNodelist, Infobox) {
window.history.pushState(s, undefined, s)
}
function gotoHistory(gotoAnything, dict, s) {
function gotoHistory(router, dict, s) {
if (!s.startsWith("#!"))
return
@ -158,14 +158,14 @@ function (Map, Sidebar, Meshstats, Linklist, SimpleNodelist, Infobox) {
var id = args[1]
if (id in dict.nodes)
gotoAnything.node(dict.nodes[id], true, false)()
router.node(dict.nodes[id], true, false)()
}
if (args[0] === "l") {
var id = args[1]
if (id in dict.links)
gotoAnything.link(dict.links[id], true, false)()
router.link(dict.links[id], true, false)()
}
}