set document.title on router events
This commit is contained in:
parent
6c862182f5
commit
3b75f01ccd
@ -1,8 +1,8 @@
|
|||||||
define([ "chroma-js", "map", "sidebar", "tabs", "container", "meshstats",
|
define([ "chroma-js", "map", "sidebar", "tabs", "container", "meshstats",
|
||||||
"linklist", "nodelist", "simplenodelist", "infobox/main",
|
"linklist", "nodelist", "simplenodelist", "infobox/main",
|
||||||
"proportions", "forcegraph" ],
|
"proportions", "forcegraph", "title" ],
|
||||||
function (chroma, Map, Sidebar, Tabs, Container, Meshstats, Linklist,
|
function (chroma, Map, Sidebar, Tabs, Container, Meshstats, Linklist,
|
||||||
Nodelist, SimpleNodelist, Infobox, Proportions, ForceGraph) {
|
Nodelist, SimpleNodelist, Infobox, Proportions, ForceGraph, Title) {
|
||||||
return function (config, router) {
|
return function (config, router) {
|
||||||
var self = this
|
var self = this
|
||||||
var dataTargets = []
|
var dataTargets = []
|
||||||
@ -59,6 +59,7 @@ function (chroma, Map, Sidebar, Tabs, Container, Meshstats, Linklist,
|
|||||||
}
|
}
|
||||||
contentDiv.appendChild(buttonToggle)
|
contentDiv.appendChild(buttonToggle)
|
||||||
|
|
||||||
|
var title = new Title(config)
|
||||||
var infobox = new Infobox(config, sidebar, router)
|
var infobox = new Infobox(config, sidebar, router)
|
||||||
var tabs = new Tabs()
|
var tabs = new Tabs()
|
||||||
var overview = new Container()
|
var overview = new Container()
|
||||||
@ -86,6 +87,7 @@ function (chroma, Map, Sidebar, Tabs, Container, Meshstats, Linklist,
|
|||||||
tabs.add("Verbindungen", linklist)
|
tabs.add("Verbindungen", linklist)
|
||||||
tabs.add("Statistiken", statistics)
|
tabs.add("Statistiken", statistics)
|
||||||
|
|
||||||
|
router.addTarget(title)
|
||||||
router.addTarget(infobox)
|
router.addTarget(infobox)
|
||||||
|
|
||||||
addContent(Map)
|
addContent(Map)
|
||||||
|
31
lib/title.js
Normal file
31
lib/title.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
define(function () {
|
||||||
|
return function (config) {
|
||||||
|
function setTitle(d) {
|
||||||
|
var title = [config.siteName]
|
||||||
|
|
||||||
|
if (d !== undefined)
|
||||||
|
title.push(d)
|
||||||
|
|
||||||
|
document.title = title.join(": ")
|
||||||
|
}
|
||||||
|
|
||||||
|
this.resetView = function () {
|
||||||
|
setTitle()
|
||||||
|
}
|
||||||
|
|
||||||
|
this.gotoNode = function (d) {
|
||||||
|
if (d)
|
||||||
|
setTitle(d.nodeinfo.hostname)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.gotoLink = function (d) {
|
||||||
|
if (d)
|
||||||
|
setTitle(d.source.node.nodeinfo.hostname + " – " + d.target.node.nodeinfo.hostname)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.destroy = function () {
|
||||||
|
}
|
||||||
|
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
})
|
Loading…
Reference in New Issue
Block a user