2015-03-29 19:54:43 +02:00
|
|
|
define([ "chroma-js", "map", "sidebar", "tabs", "container", "meshstats",
|
2015-08-27 01:31:19 +02:00
|
|
|
"legend", "linklist", "nodelist", "simplenodelist", "infobox/main",
|
2015-04-07 22:06:12 +02:00
|
|
|
"proportions", "forcegraph", "title", "about" ],
|
2015-08-27 01:31:19 +02:00
|
|
|
function (chroma, Map, Sidebar, Tabs, Container, Meshstats, Legend, Linklist,
|
2015-04-07 22:06:12 +02:00
|
|
|
Nodelist, SimpleNodelist, Infobox, Proportions, ForceGraph,
|
|
|
|
Title, About) {
|
2015-03-29 19:54:43 +02:00
|
|
|
return function (config, router) {
|
|
|
|
var self = this
|
|
|
|
var dataTargets = []
|
2015-04-01 03:55:45 +02:00
|
|
|
var latestData
|
|
|
|
var content
|
2015-04-02 04:11:49 +02:00
|
|
|
var contentDiv
|
2015-03-29 19:54:43 +02:00
|
|
|
|
2015-07-07 12:42:57 +02:00
|
|
|
var linkScale = chroma.scale(chroma.interpolate.bezier(["#04C714", "#FF5500", "#F02311"])).domain([1, 5])
|
2015-04-02 04:11:49 +02:00
|
|
|
var sidebar
|
2015-04-01 03:55:45 +02:00
|
|
|
|
2015-07-07 01:56:11 +02:00
|
|
|
var buttons = document.createElement("div")
|
|
|
|
buttons.classList.add("buttons")
|
|
|
|
|
2015-04-02 22:10:11 +02:00
|
|
|
function dataTargetRemove(d) {
|
|
|
|
dataTargets = dataTargets.filter( function (e) { return d !== e })
|
|
|
|
}
|
|
|
|
|
2015-04-01 03:55:45 +02:00
|
|
|
function removeContent() {
|
|
|
|
if (!content)
|
|
|
|
return
|
|
|
|
|
|
|
|
router.removeTarget(content)
|
2015-04-02 22:10:11 +02:00
|
|
|
dataTargetRemove(content)
|
2015-04-01 03:55:45 +02:00
|
|
|
content.destroy()
|
2015-07-12 00:11:18 +02:00
|
|
|
|
2015-04-01 03:55:45 +02:00
|
|
|
content = null
|
|
|
|
}
|
|
|
|
|
|
|
|
function addContent(K) {
|
|
|
|
removeContent()
|
|
|
|
|
2015-07-12 00:09:57 +02:00
|
|
|
content = new K(config, linkScale, sidebar.getWidth, router, buttons)
|
2015-07-12 00:11:18 +02:00
|
|
|
content.render(contentDiv)
|
2015-04-01 03:55:45 +02:00
|
|
|
|
|
|
|
if (latestData)
|
|
|
|
content.setData(latestData)
|
|
|
|
|
|
|
|
dataTargets.push(content)
|
|
|
|
router.addTarget(content)
|
2015-07-07 00:06:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function mkView(K) {
|
|
|
|
return function () {
|
|
|
|
addContent(K)
|
|
|
|
}
|
2015-04-01 03:55:45 +02:00
|
|
|
}
|
|
|
|
|
2015-04-02 04:11:49 +02:00
|
|
|
contentDiv = document.createElement("div")
|
|
|
|
contentDiv.classList.add("content")
|
|
|
|
document.body.appendChild(contentDiv)
|
|
|
|
|
|
|
|
sidebar = new Sidebar(document.body)
|
|
|
|
|
2015-07-07 01:56:11 +02:00
|
|
|
contentDiv.appendChild(buttons)
|
|
|
|
|
2015-04-01 03:55:45 +02:00
|
|
|
var buttonToggle = document.createElement("button")
|
2015-07-07 12:51:12 +02:00
|
|
|
buttonToggle.textContent = ""
|
2015-04-01 03:55:45 +02:00
|
|
|
buttonToggle.onclick = function () {
|
2015-07-07 12:51:12 +02:00
|
|
|
if (content.constructor === Map)
|
2015-07-07 00:06:38 +02:00
|
|
|
router.view("g")
|
2015-07-07 12:51:12 +02:00
|
|
|
else
|
2015-07-07 00:06:38 +02:00
|
|
|
router.view("m")
|
2015-04-01 03:55:45 +02:00
|
|
|
}
|
2015-07-07 01:56:11 +02:00
|
|
|
|
|
|
|
buttons.appendChild(buttonToggle)
|
2015-04-01 03:55:45 +02:00
|
|
|
|
2015-04-05 23:44:43 +02:00
|
|
|
var title = new Title(config)
|
2015-07-08 21:28:26 +02:00
|
|
|
|
|
|
|
var header = new Container("header")
|
2015-03-29 19:54:43 +02:00
|
|
|
var infobox = new Infobox(config, sidebar, router)
|
|
|
|
var tabs = new Tabs()
|
|
|
|
var overview = new Container()
|
2015-07-08 16:32:26 +02:00
|
|
|
var meshstats = new Meshstats(config)
|
2015-08-27 01:31:19 +02:00
|
|
|
var legend = new Legend()
|
2015-04-26 11:52:21 +02:00
|
|
|
var newnodeslist = new SimpleNodelist("new", "firstseen", router, "Neue Knoten")
|
|
|
|
var lostnodeslist = new SimpleNodelist("lost", "lastseen", router, "Verschwundene Knoten")
|
2015-03-29 19:54:43 +02:00
|
|
|
var nodelist = new Nodelist(router)
|
|
|
|
var linklist = new Linklist(linkScale, router)
|
2015-06-07 18:47:14 +02:00
|
|
|
var statistics = new Proportions(config)
|
2015-04-07 22:06:12 +02:00
|
|
|
var about = new About()
|
2015-03-29 19:54:43 +02:00
|
|
|
|
|
|
|
dataTargets.push(meshstats)
|
|
|
|
dataTargets.push(newnodeslist)
|
|
|
|
dataTargets.push(lostnodeslist)
|
|
|
|
dataTargets.push(nodelist)
|
|
|
|
dataTargets.push(linklist)
|
2015-03-30 02:58:47 +02:00
|
|
|
dataTargets.push(statistics)
|
2015-03-29 19:54:43 +02:00
|
|
|
|
2015-07-08 21:28:26 +02:00
|
|
|
sidebar.add(header)
|
|
|
|
header.add(meshstats)
|
2015-08-27 01:31:19 +02:00
|
|
|
header.add(legend)
|
2015-07-08 21:28:26 +02:00
|
|
|
|
2015-03-29 19:54:43 +02:00
|
|
|
overview.add(newnodeslist)
|
|
|
|
overview.add(lostnodeslist)
|
|
|
|
|
|
|
|
sidebar.add(tabs)
|
2015-07-08 21:28:26 +02:00
|
|
|
tabs.add("Aktuelles", overview)
|
2015-04-07 22:06:12 +02:00
|
|
|
tabs.add("Knoten", nodelist)
|
2015-03-29 19:54:43 +02:00
|
|
|
tabs.add("Verbindungen", linklist)
|
2015-03-30 02:58:47 +02:00
|
|
|
tabs.add("Statistiken", statistics)
|
2015-04-07 22:06:12 +02:00
|
|
|
tabs.add("Über", about)
|
2015-03-29 19:54:43 +02:00
|
|
|
|
2015-04-05 23:44:43 +02:00
|
|
|
router.addTarget(title)
|
2015-03-29 19:54:43 +02:00
|
|
|
router.addTarget(infobox)
|
2015-04-01 03:55:45 +02:00
|
|
|
|
2015-07-07 00:06:38 +02:00
|
|
|
router.addView("m", mkView(Map))
|
|
|
|
router.addView("g", mkView(ForceGraph))
|
|
|
|
|
|
|
|
router.view("m")
|
2015-03-29 19:54:43 +02:00
|
|
|
|
|
|
|
self.setData = function (data) {
|
2015-04-01 03:55:45 +02:00
|
|
|
latestData = data
|
|
|
|
|
2015-03-29 19:54:43 +02:00
|
|
|
dataTargets.forEach(function (d) {
|
|
|
|
d.setData(data)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
return self
|
|
|
|
}
|
|
|
|
})
|