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"
|
btn.parentElement.children[1].innerHTML = " " + lenhonks + " new"
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
function pageswitcher(name) {
|
function statechanger(evt) {
|
||||||
return function(evt) {
|
var name = evt.state
|
||||||
if (name == thispagename) {
|
if (!name) {
|
||||||
return false
|
return
|
||||||
}
|
}
|
||||||
|
switchtopage(name)
|
||||||
|
}
|
||||||
|
function switchtopage(name, evt) {
|
||||||
var honksonpage = document.getElementById("honksonpage")
|
var honksonpage = document.getElementById("honksonpage")
|
||||||
var holder = honksonpage.children[0]
|
var holder = honksonpage.children[0]
|
||||||
holder.remove()
|
holder.remove()
|
||||||
if (thispagename != "convoy") {
|
if (thispagename != "convoy") {
|
||||||
honksforpage[thispagename] = holder
|
honksforpage[thispagename] = holder
|
||||||
}
|
}
|
||||||
|
|
||||||
thispagename = name
|
thispagename = name
|
||||||
holder = honksforpage[name]
|
holder = honksforpage[name]
|
||||||
if (holder) {
|
if (holder) {
|
||||||
|
@ -112,7 +114,6 @@ function pageswitcher(name) {
|
||||||
honksonpage.prepend(document.createElement("div"))
|
honksonpage.prepend(document.createElement("div"))
|
||||||
var args = { "page" : name }
|
var args = { "page" : name }
|
||||||
if (name == "convoy") {
|
if (name == "convoy") {
|
||||||
console.log("convoy page")
|
|
||||||
var c = evt.srcElement.text
|
var c = evt.srcElement.text
|
||||||
args["c"] = c
|
args["c"] = c
|
||||||
} else {
|
} else {
|
||||||
|
@ -120,6 +121,15 @@ function pageswitcher(name) {
|
||||||
}
|
}
|
||||||
get("/hydra?" + encode(args), fillinhonks)
|
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
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -130,10 +140,10 @@ function relinkconvoys() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(function() {
|
(function() {
|
||||||
console.log("ok")
|
|
||||||
var el = document.getElementById("homelink")
|
var el = document.getElementById("homelink")
|
||||||
el.onclick = pageswitcher("home")
|
el.onclick = pageswitcher("home")
|
||||||
var el = document.getElementById("atmelink")
|
var el = document.getElementById("atmelink")
|
||||||
el.onclick = pageswitcher("atme")
|
el.onclick = pageswitcher("atme")
|
||||||
relinkconvoys()
|
relinkconvoys()
|
||||||
|
window.onpopstate = statechanger
|
||||||
})();
|
})();
|
||||||
|
|
Loading…
Reference in New Issue