2015-03-29 17:54:43 +00:00
|
|
|
define([ "chroma-js", "map", "sidebar", "tabs", "container", "meshstats",
|
2015-08-26 23:31:19 +00:00
|
|
|
"legend", "linklist", "nodelist", "simplenodelist", "infobox/main",
|
2015-07-07 22:36:57 +00:00
|
|
|
"proportions", "forcegraph", "title", "about", "datadistributor",
|
|
|
|
"filters/filtergui" ],
|
2015-08-26 23:31:19 +00:00
|
|
|
function (chroma, Map, Sidebar, Tabs, Container, Meshstats, Legend, Linklist,
|
2015-04-07 20:06:12 +00:00
|
|
|
Nodelist, SimpleNodelist, Infobox, Proportions, ForceGraph,
|
2015-07-07 22:36:57 +00:00
|
|
|
Title, About, DataDistributor, FilterGUI) {
|
2015-03-29 17:54:43 +00:00
|
|
|
return function (config, router) {
|
2016-05-22 11:23:43 +00:00
|
|
|
var self = this;
|
|
|
|
var content;
|
|
|
|
var contentDiv;
|
2015-03-29 17:54:43 +00:00
|
|
|
|
2016-05-22 11:23:43 +00:00
|
|
|
var linkScale = chroma.scale(chroma.interpolate.bezier(["#04C714", "#FF5500", "#F02311"])).domain([1, 5]);
|
|
|
|
var sidebar;
|
2015-04-01 01:55:45 +00:00
|
|
|
|
2016-05-22 11:23:43 +00:00
|
|
|
var buttons = document.createElement("div");
|
|
|
|
buttons.classList.add("buttons");
|
2015-07-06 23:56:11 +00:00
|
|
|
|
2016-05-22 11:23:43 +00:00
|
|
|
var fanout = new DataDistributor();
|
|
|
|
var fanoutUnfiltered = new DataDistributor();
|
|
|
|
fanoutUnfiltered.add(fanout);
|
2015-07-08 19:28:00 +00:00
|
|
|
|
2015-04-01 01:55:45 +00:00
|
|
|
function removeContent() {
|
|
|
|
if (!content)
|
2016-05-22 11:23:43 +00:00
|
|
|
return;
|
2015-04-01 01:55:45 +00:00
|
|
|
|
2016-05-22 11:23:43 +00:00
|
|
|
router.removeTarget(content);
|
|
|
|
fanout.remove(content);
|
2015-07-07 22:36:57 +00:00
|
|
|
|
2016-05-22 11:23:43 +00:00
|
|
|
content.destroy();
|
2015-07-11 22:11:18 +00:00
|
|
|
|
2016-05-22 11:23:43 +00:00
|
|
|
content = null;
|
2015-04-01 01:55:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function addContent(K) {
|
2016-05-22 11:23:43 +00:00
|
|
|
removeContent();
|
2015-04-01 01:55:45 +00:00
|
|
|
|
2016-05-22 11:23:43 +00:00
|
|
|
content = new K(config, linkScale, sidebar.getWidth, router, buttons);
|
|
|
|
content.render(contentDiv);
|
2015-04-01 01:55:45 +00:00
|
|
|
|
2016-05-22 11:23:43 +00:00
|
|
|
fanout.add(content);
|
|
|
|
router.addTarget(content);
|
2015-07-06 22:06:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function mkView(K) {
|
|
|
|
return function () {
|
2016-05-22 11:23:43 +00:00
|
|
|
addContent(K);
|
|
|
|
};
|
2015-04-01 01:55:45 +00:00
|
|
|
}
|
|
|
|
|
2016-05-22 11:23:43 +00:00
|
|
|
contentDiv = document.createElement("div");
|
|
|
|
contentDiv.classList.add("content");
|
|
|
|
document.body.appendChild(contentDiv);
|
2015-04-02 02:11:49 +00:00
|
|
|
|
2016-05-22 11:23:43 +00:00
|
|
|
sidebar = new Sidebar(document.body);
|
2015-04-02 02:11:49 +00:00
|
|
|
|
2016-05-22 11:23:43 +00:00
|
|
|
contentDiv.appendChild(buttons);
|
2015-07-06 23:56:11 +00:00
|
|
|
|
2016-05-22 11:23:43 +00:00
|
|
|
var buttonToggle = document.createElement("button");
|
|
|
|
buttonToggle.textContent = "\uF133";
|
2015-04-01 01:55:45 +00:00
|
|
|
buttonToggle.onclick = function () {
|
2015-07-07 10:51:12 +00:00
|
|
|
if (content.constructor === Map)
|
2016-05-22 11:23:43 +00:00
|
|
|
router.view("g");
|
2015-07-07 10:51:12 +00:00
|
|
|
else
|
2016-05-22 11:23:43 +00:00
|
|
|
router.view("m");
|
|
|
|
};
|
|
|
|
|
|
|
|
buttons.appendChild(buttonToggle);
|
|
|
|
|
|
|
|
var title = new Title(config);
|
|
|
|
|
|
|
|
var header = new Container("header");
|
|
|
|
var infobox = new Infobox(config, sidebar, router);
|
|
|
|
var tabs = new Tabs();
|
|
|
|
var overview = new Container();
|
|
|
|
var meshstats = new Meshstats(config);
|
|
|
|
var legend = new Legend();
|
|
|
|
var newnodeslist = new SimpleNodelist("new", "firstseen", router, "Neue Knoten");
|
|
|
|
var lostnodeslist = new SimpleNodelist("lost", "lastseen", router, "Verschwundene Knoten");
|
|
|
|
var nodelist = new Nodelist(router);
|
|
|
|
var linklist = new Linklist(linkScale, router);
|
|
|
|
var statistics = new Proportions(config, fanout);
|
|
|
|
var about = new About();
|
|
|
|
|
|
|
|
fanoutUnfiltered.add(meshstats);
|
|
|
|
fanoutUnfiltered.add(newnodeslist);
|
|
|
|
fanoutUnfiltered.add(lostnodeslist);
|
|
|
|
fanout.add(nodelist);
|
|
|
|
fanout.add(linklist);
|
|
|
|
fanout.add(statistics);
|
|
|
|
|
|
|
|
sidebar.add(header);
|
|
|
|
header.add(meshstats);
|
|
|
|
header.add(legend);
|
|
|
|
|
|
|
|
overview.add(newnodeslist);
|
|
|
|
overview.add(lostnodeslist);
|
|
|
|
|
|
|
|
var filterGUI = new FilterGUI(fanout);
|
|
|
|
fanout.watchFilters(filterGUI);
|
|
|
|
header.add(filterGUI);
|
|
|
|
|
|
|
|
sidebar.add(tabs);
|
|
|
|
tabs.add("Aktuelles", overview);
|
|
|
|
tabs.add("Knoten", nodelist);
|
|
|
|
tabs.add("Verbindungen", linklist);
|
|
|
|
tabs.add("Statistiken", statistics);
|
|
|
|
tabs.add("Über", about);
|
|
|
|
|
|
|
|
router.addTarget(title);
|
|
|
|
router.addTarget(infobox);
|
|
|
|
|
|
|
|
router.addView("m", mkView(Map));
|
|
|
|
router.addView("g", mkView(ForceGraph));
|
|
|
|
|
|
|
|
router.view("m");
|
|
|
|
|
|
|
|
self.setData = fanoutUnfiltered.setData;
|
|
|
|
|
|
|
|
return self;
|
|
|
|
};
|
|
|
|
});
|