history: gotoProxy

This commit is contained in:
Nils Schneider 2015-03-21 15:59:25 +01:00
parent 670635163d
commit 7bffcb608b

View File

@ -155,9 +155,11 @@ function handle_data(config, map) {
var markers = mkmap(map, newnodes, lostnodes, onlinenodes, graph) var markers = mkmap(map, newnodes, lostnodes, onlinenodes, graph)
addToList(document.getElementById("newnodes"), config.showContact, "firstseen", markers, newnodes) var gotoAnything = gotoBuilder(markers, showNodeinfo)
addToList(document.getElementById("lostnodes"), config.showContact, "lastseen", markers, lostnodes)
addToLongLinksList(document.getElementById("longlinks"), markers, longlinks) addToList(document.getElementById("newnodes"), config.showContact, "firstseen", gotoAnything.node, newnodes)
addToList(document.getElementById("lostnodes"), config.showContact, "lastseen", gotoAnything.node, lostnodes)
addToLongLinksList(document.getElementById("longlinks"), gotoAnything.link, longlinks)
showMeshstats(document.getElementById("meshstats"), nodes) showMeshstats(document.getElementById("meshstats"), nodes)
} }
@ -279,14 +281,14 @@ function addLinksToMap(map, graph) {
return markersDict return markersDict
} }
function addToLongLinksList(el, markers, links) { function addToLongLinksList(el, gotoProxy, links) {
links.forEach( function (d) { links.forEach( function (d) {
var row = document.createElement("tr") var row = document.createElement("tr")
var td1 = document.createElement("td") var td1 = document.createElement("td")
var a = document.createElement("a") var a = document.createElement("a")
a.textContent = d.source.node.nodeinfo.hostname + " " + d.target.node.nodeinfo.hostname a.textContent = d.source.node.nodeinfo.hostname + " " + d.target.node.nodeinfo.hostname
a.href = "#" a.href = "#"
a.onclick = markers[linkId(d)] a.onclick = gotoProxy(d)
td1.appendChild(a) td1.appendChild(a)
row.appendChild(td1) row.appendChild(td1)
@ -302,7 +304,7 @@ function addToLongLinksList(el, markers, links) {
}) })
} }
function addToList(el, showContact, tf, markers, list) { function addToList(el, showContact, tf, gotoProxy, list) {
list.forEach( function (d) { list.forEach( function (d) {
var time = moment(d[tf]).fromNow() var time = moment(d[tf]).fromNow()
@ -312,10 +314,8 @@ function addToList(el, showContact, tf, markers, list) {
a.classList.add("hostname") a.classList.add("hostname")
a.classList.add(d.flags.online ? "online" : "offline") a.classList.add(d.flags.online ? "online" : "offline")
a.textContent = d.nodeinfo.hostname a.textContent = d.nodeinfo.hostname
if (d.nodeinfo.node_id in markers) { a.href = "#"
a.href = "#" a.onclick = gotoProxy(d)
a.onclick = markers[d.nodeinfo.node_id]
}
td1.appendChild(a) td1.appendChild(a)
if ("location" in d.nodeinfo) { if ("location" in d.nodeinfo) {
@ -368,3 +368,23 @@ function showMeshstats(el, nodes) {
function showNodeinfo(d) { function showNodeinfo(d) {
var object = document.getElementById("nodeinfo") var object = document.getElementById("nodeinfo")
} }
function gotoBuilder(markers, nodes) {
function gotoNode(d) {
if (d.nodeinfo.node_id in markers)
markers[d.nodeinfo.node_id]()
return false
}
function gotoLink(d) {
if (linkId(d) in markers)
markers[linkId(d)]()
return false
}
return { node: function (d) { return function () { return gotoNode(d) }},
link: function (d) { return function () { return gotoLink(d) }}
}
}