glow effect for new honks

This commit is contained in:
Ted Unangst 2019-10-29 00:26:05 -04:00
parent d4cc995044
commit a324b33294
2 changed files with 20 additions and 5 deletions

View File

@ -66,7 +66,14 @@ function flogit(el, how, xid) {
var lehonkform = document.getElementById("honkform") var lehonkform = document.getElementById("honkform")
var lehonkbutton = document.getElementById("honkingtime") var lehonkbutton = document.getElementById("honkingtime")
function fillinhonks(xhr) { function removeglow() {
var els = document.getElementsByClassName("glow")
while (els.length) {
els[0].classList.remove("glow")
}
}
function fillinhonks(xhr, glowit) {
var doc = xhr.responseXML var doc = xhr.responseXML
var stash = curpagestate.name + ":" + curpagestate.arg var stash = curpagestate.name + ":" + curpagestate.arg
tophid[stash] = doc.children[0].children[1].children[0].innerText tophid[stash] = doc.children[0].children[1].children[0].innerText
@ -88,10 +95,13 @@ function fillinhonks(xhr) {
var holder = honksonpage.children[0] var holder = honksonpage.children[0]
var lenhonks = honks.length var lenhonks = honks.length
for (var i = honks.length; i > 0; i--) { for (var i = honks.length; i > 0; i--) {
var h = honks[i-1]
if (glowit)
h.classList.add("glow")
if (frontload) { if (frontload) {
holder.prepend(honks[i-1]) holder.prepend(h)
} else { } else {
holder.append(honks[i-1]) holder.append(h)
} }
} }
@ -118,13 +128,14 @@ function refreshupdate(msg) {
} }
} }
function refreshhonks(btn) { function refreshhonks(btn) {
removeglow()
btn.innerHTML = "refreshing" btn.innerHTML = "refreshing"
btn.disabled = true btn.disabled = true
var args = hydrargs() var args = hydrargs()
var stash = curpagestate.name + ":" + curpagestate.arg var stash = curpagestate.name + ":" + curpagestate.arg
args["tophid"] = tophid[stash] args["tophid"] = tophid[stash]
get("/hydra?" + encode(args), function(xhr) { get("/hydra?" + encode(args), function(xhr) {
var lenhonks = fillinhonks(xhr) var lenhonks = fillinhonks(xhr, true)
btn.innerHTML = "refresh" btn.innerHTML = "refresh"
btn.disabled = false btn.disabled = false
refreshupdate(" " + lenhonks + " new") refreshupdate(" " + lenhonks + " new")
@ -166,7 +177,7 @@ function switchtopage(name, arg) {
// or create one and fill it // or create one and fill it
honksonpage.prepend(document.createElement("div")) honksonpage.prepend(document.createElement("div"))
var args = hydrargs() var args = hydrargs()
get("/hydra?" + encode(args), fillinhonks) get("/hydra?" + encode(args), function(xhr) { fillinhonks(xhr, false) })
} }
refreshupdate("") refreshupdate("")
} }

View File

@ -152,6 +152,10 @@ input[type=file] {
display: none; display: none;
} }
.glow {
box-shadow: 0px 0px 16px $fg;
}
.honk { .honk {
margin: auto; margin: auto;
background: $bg-dark; background: $bg-dark;