router: save view in state
This commit is contained in:
parent
2d1fbba40f
commit
bc8943abc2
2 changed files with 90 additions and 37 deletions
lib
16
lib/gui.js
16
lib/gui.js
|
@ -40,7 +40,12 @@ function (chroma, Map, Sidebar, Tabs, Container, Meshstats, Linklist,
|
|||
|
||||
dataTargets.push(content)
|
||||
router.addTarget(content)
|
||||
router.reload()
|
||||
}
|
||||
|
||||
function mkView(K) {
|
||||
return function () {
|
||||
addContent(K)
|
||||
}
|
||||
}
|
||||
|
||||
contentDiv = document.createElement("div")
|
||||
|
@ -56,11 +61,11 @@ function (chroma, Map, Sidebar, Tabs, Container, Meshstats, Linklist,
|
|||
if (content.constructor === Map) {
|
||||
buttonToggle.classList.remove("next-graph")
|
||||
buttonToggle.classList.add("next-map")
|
||||
addContent(ForceGraph)
|
||||
router.view("g")
|
||||
} else {
|
||||
buttonToggle.classList.remove("next-map")
|
||||
buttonToggle.classList.add("next-graph")
|
||||
addContent(Map)
|
||||
router.view("m")
|
||||
}
|
||||
}
|
||||
contentDiv.appendChild(buttonToggle)
|
||||
|
@ -98,7 +103,10 @@ function (chroma, Map, Sidebar, Tabs, Container, Meshstats, Linklist,
|
|||
router.addTarget(title)
|
||||
router.addTarget(infobox)
|
||||
|
||||
addContent(Map)
|
||||
router.addView("m", mkView(Map))
|
||||
router.addView("g", mkView(ForceGraph))
|
||||
|
||||
router.view("m")
|
||||
|
||||
self.setData = function (data) {
|
||||
latestData = data
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue