all repos — honk @ 3f3e8548b0001810cb640426b7b8aa800a8c142c

my fork of honk

update page message during switch
Ted Unangst tedu@tedunangst.com
Mon, 07 Oct 2019 13:18:30 -0400
commit

3f3e8548b0001810cb640426b7b8aa800a8c142c

parent

36ef97d65f05da2974d350425df73dd7a4140b4c

2 files changed, 19 insertions(+), 7 deletions(-)

jump to
M views/honkpage.htmlviews/honkpage.html

@@ -31,6 +31,9 @@ var honksforpage = { }

var curpagestate = { name: "{{ .PageName }}", arg : "{{ .PageArg }}" } var topxid = { } topxid[curpagestate.name + ":" + curpagestate.arg] = "{{ .TopXID }}" +var servermsgs = { } +servermsgs[curpagestate.name + ":" + curpagestate.arg] = "{{ .ServerMessage }}" + </script> <script src="/honkpage.js{{ .JSParam }}"></script> {{ end }}
M views/honkpage.jsviews/honkpage.js

@@ -71,7 +71,9 @@ var srvmsg = doc.children[0].children[1].children[1]

var honks = doc.children[0].children[1].children[2].children var srvel = document.getElementById("srvmsg") - srvel.children[0].remove() + if (srvel.children[0]) { + srvel.children[0].remove() + } srvel.prepend(srvmsg) var honksonpage = document.getElementById("honksonpage")

@@ -90,10 +92,8 @@ var args = { "page" : name }

if (name == "convoy") { args["c"] = arg } else if (name == "combo") { - console.log("loading combo " + arg) args["c"] = arg } else if (name == "honker") { - console.log("loading honker " + arg) args["xid"] = arg } return args

@@ -119,14 +119,19 @@ }

switchtopage(data.name, data.arg) } function switchtopage(name, arg) { + var stash = curpagestate.name + ":" + curpagestate.arg var honksonpage = document.getElementById("honksonpage") var holder = honksonpage.children[0] holder.remove() - // if not convoy, save current page - if (curpagestate.name != "convoy") { - var stash = curpagestate.name + ":" + curpagestate.arg - honksforpage[stash] = holder + var srvel = document.getElementById("srvmsg") + var msg = srvel.children[0] + if (msg) { + msg.remove() + servermsgs[stash] = msg } + + honksforpage[stash] = holder + curpagestate.name = name curpagestate.arg = arg // get the holder for the target page

@@ -134,6 +139,10 @@ var stash = name + ":" + arg

holder = honksforpage[stash] if (holder) { honksonpage.prepend(holder) + msg = servermsgs[stash] + if (msg) { + srvel.prepend(msg) + } } else { // or create one and fill it honksonpage.prepend(document.createElement("div"))