update page message during switch
This commit is contained in:
parent
4fa61e5cea
commit
5c0b7f1973
|
@ -31,6 +31,9 @@ var honksforpage = { }
|
||||||
var curpagestate = { name: "{{ .PageName }}", arg : "{{ .PageArg }}" }
|
var curpagestate = { name: "{{ .PageName }}", arg : "{{ .PageArg }}" }
|
||||||
var topxid = { }
|
var topxid = { }
|
||||||
topxid[curpagestate.name + ":" + curpagestate.arg] = "{{ .TopXID }}"
|
topxid[curpagestate.name + ":" + curpagestate.arg] = "{{ .TopXID }}"
|
||||||
|
var servermsgs = { }
|
||||||
|
servermsgs[curpagestate.name + ":" + curpagestate.arg] = "{{ .ServerMessage }}"
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<script src="/honkpage.js{{ .JSParam }}"></script>
|
<script src="/honkpage.js{{ .JSParam }}"></script>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
@ -71,7 +71,9 @@ function fillinhonks(xhr) {
|
||||||
var honks = doc.children[0].children[1].children[2].children
|
var honks = doc.children[0].children[1].children[2].children
|
||||||
|
|
||||||
var srvel = document.getElementById("srvmsg")
|
var srvel = document.getElementById("srvmsg")
|
||||||
|
if (srvel.children[0]) {
|
||||||
srvel.children[0].remove()
|
srvel.children[0].remove()
|
||||||
|
}
|
||||||
srvel.prepend(srvmsg)
|
srvel.prepend(srvmsg)
|
||||||
|
|
||||||
var honksonpage = document.getElementById("honksonpage")
|
var honksonpage = document.getElementById("honksonpage")
|
||||||
|
@ -90,10 +92,8 @@ function hydrargs() {
|
||||||
if (name == "convoy") {
|
if (name == "convoy") {
|
||||||
args["c"] = arg
|
args["c"] = arg
|
||||||
} else if (name == "combo") {
|
} else if (name == "combo") {
|
||||||
console.log("loading combo " + arg)
|
|
||||||
args["c"] = arg
|
args["c"] = arg
|
||||||
} else if (name == "honker") {
|
} else if (name == "honker") {
|
||||||
console.log("loading honker " + arg)
|
|
||||||
args["xid"] = arg
|
args["xid"] = arg
|
||||||
}
|
}
|
||||||
return args
|
return args
|
||||||
|
@ -119,14 +119,19 @@ function statechanger(evt) {
|
||||||
switchtopage(data.name, data.arg)
|
switchtopage(data.name, data.arg)
|
||||||
}
|
}
|
||||||
function switchtopage(name, arg) {
|
function switchtopage(name, arg) {
|
||||||
|
var stash = curpagestate.name + ":" + curpagestate.arg
|
||||||
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 not convoy, save current page
|
var srvel = document.getElementById("srvmsg")
|
||||||
if (curpagestate.name != "convoy") {
|
var msg = srvel.children[0]
|
||||||
var stash = curpagestate.name + ":" + curpagestate.arg
|
if (msg) {
|
||||||
honksforpage[stash] = holder
|
msg.remove()
|
||||||
|
servermsgs[stash] = msg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
honksforpage[stash] = holder
|
||||||
|
|
||||||
curpagestate.name = name
|
curpagestate.name = name
|
||||||
curpagestate.arg = arg
|
curpagestate.arg = arg
|
||||||
// get the holder for the target page
|
// get the holder for the target page
|
||||||
|
@ -134,6 +139,10 @@ function switchtopage(name, arg) {
|
||||||
holder = honksforpage[stash]
|
holder = honksforpage[stash]
|
||||||
if (holder) {
|
if (holder) {
|
||||||
honksonpage.prepend(holder)
|
honksonpage.prepend(holder)
|
||||||
|
msg = servermsgs[stash]
|
||||||
|
if (msg) {
|
||||||
|
srvel.prepend(msg)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// or create one and fill it
|
// or create one and fill it
|
||||||
honksonpage.prepend(document.createElement("div"))
|
honksonpage.prepend(document.createElement("div"))
|
||||||
|
|
Loading…
Reference in New Issue