-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathlinklist.js
More file actions
56 lines (46 loc) · 1.69 KB
/
linklist.js
File metadata and controls
56 lines (46 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
define(["sorttable", "virtual-dom"], function (SortTable, V) {
function linkName(d, trim) {
return nodeName(d.source.node, trim) + " – " + nodeName(d.target.node, trim)
}
var headings = [{ name: "Knoten",
sort: function (a, b) {
return linkName(a).localeCompare(linkName(b))
},
reverse: false
},
{ name: "TQ",
sort: function (a, b) { return a.tq - b.tq},
reverse: true
},
{ name: "Entfernung",
sort: function (a, b) {
return (a.distance === undefined ? -1 : a.distance) -
(b.distance === undefined ? -1 : b.distance)
},
reverse: true
}]
return function(linkScale, router) {
var table = new SortTable(headings, 2, renderRow)
function renderRow(d) {
var td1Content = [V.h("a", {href: "#", onclick: router.link(d), title: linkName(d)}, linkName(d, true))]
if (d.vpn)
td1Content.push(" (VPN)")
var td1 = V.h("td", td1Content)
var td2 = V.h("td", {style: {color: linkScale(d.tq).hex()}}, showTq(d))
var td3 = V.h("td", showDistance(d))
return V.h("tr", [td1, td2, td3])
}
this.render = function (d) {
var el = document.createElement("div")
el.last = V.h("div")
d.appendChild(el)
var h2 = document.createElement("h2")
h2.textContent = "Verbindungen"
el.appendChild(h2)
el.appendChild(table.el)
}
this.setData = function (d) {
table.setData(d.graph.links)
}
}
})