experiment with history.pushState
This commit is contained in:
parent
ae1fff2d90
commit
872e044d6c
|
@ -92,18 +92,20 @@ function refreshhonks(btn) {
|
|||
btn.parentElement.children[1].innerHTML = " " + lenhonks + " new"
|
||||
})
|
||||
}
|
||||
function pageswitcher(name) {
|
||||
return function(evt) {
|
||||
if (name == thispagename) {
|
||||
return false
|
||||
function statechanger(evt) {
|
||||
var name = evt.state
|
||||
if (!name) {
|
||||
return
|
||||
}
|
||||
switchtopage(name)
|
||||
}
|
||||
function switchtopage(name, evt) {
|
||||
var honksonpage = document.getElementById("honksonpage")
|
||||
var holder = honksonpage.children[0]
|
||||
holder.remove()
|
||||
if (thispagename != "convoy") {
|
||||
honksforpage[thispagename] = holder
|
||||
}
|
||||
|
||||
thispagename = name
|
||||
holder = honksforpage[name]
|
||||
if (holder) {
|
||||
|
@ -112,7 +114,6 @@ function pageswitcher(name) {
|
|||
honksonpage.prepend(document.createElement("div"))
|
||||
var args = { "page" : name }
|
||||
if (name == "convoy") {
|
||||
console.log("convoy page")
|
||||
var c = evt.srcElement.text
|
||||
args["c"] = c
|
||||
} else {
|
||||
|
@ -120,6 +121,15 @@ function pageswitcher(name) {
|
|||
}
|
||||
get("/hydra?" + encode(args), fillinhonks)
|
||||
}
|
||||
}
|
||||
function pageswitcher(name) {
|
||||
return function(evt) {
|
||||
if (name == thispagename) {
|
||||
return false
|
||||
}
|
||||
switchtopage(name, evt)
|
||||
var url = evt.srcElement.href
|
||||
history.pushState(name, "some title", url)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
@ -130,10 +140,10 @@ function relinkconvoys() {
|
|||
}
|
||||
}
|
||||
(function() {
|
||||
console.log("ok")
|
||||
var el = document.getElementById("homelink")
|
||||
el.onclick = pageswitcher("home")
|
||||
var el = document.getElementById("atmelink")
|
||||
el.onclick = pageswitcher("atme")
|
||||
relinkconvoys()
|
||||
window.onpopstate = statechanger
|
||||
})();
|
||||
|
|
Loading…
Reference in New Issue