2023-01-26 21:56:48 +01:00
|
|
|
var csrftoken = ""
|
|
|
|
var honksforpage = { }
|
|
|
|
var curpagestate = { name: "", arg : "" }
|
|
|
|
var tophid = { }
|
|
|
|
var servermsgs = { }
|
|
|
|
|
2019-09-16 21:15:32 +02:00
|
|
|
function encode(hash) {
|
2023-01-26 22:40:03 +01:00
|
|
|
var s = []
|
|
|
|
for (var key in hash) {
|
|
|
|
var val = hash[key]
|
|
|
|
s.push(encodeURIComponent(key) + "=" + encodeURIComponent(val))
|
|
|
|
}
|
|
|
|
return s.join("&")
|
2019-09-16 21:15:32 +02:00
|
|
|
}
|
|
|
|
function post(url, data) {
|
|
|
|
var x = new XMLHttpRequest()
|
|
|
|
x.open("POST", url)
|
2022-04-01 21:40:45 +02:00
|
|
|
x.timeout = 30 * 1000
|
2019-09-16 21:15:32 +02:00
|
|
|
x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
|
|
|
|
x.send(data)
|
|
|
|
}
|
2022-04-01 21:40:45 +02:00
|
|
|
function get(url, whendone, whentimedout) {
|
2019-09-16 21:15:32 +02:00
|
|
|
var x = new XMLHttpRequest()
|
|
|
|
x.open("GET", url)
|
2022-04-01 21:45:02 +02:00
|
|
|
x.timeout = 15 * 1000
|
2022-01-28 03:58:37 +01:00
|
|
|
x.responseType = "json"
|
2019-09-16 21:15:32 +02:00
|
|
|
x.onload = function() { whendone(x) }
|
2022-04-01 21:40:45 +02:00
|
|
|
if (whentimedout) {
|
|
|
|
x.ontimeout = function(e) { whentimedout(x, e) }
|
|
|
|
}
|
2019-09-16 21:15:32 +02:00
|
|
|
x.send()
|
|
|
|
}
|
|
|
|
function bonk(el, xid) {
|
|
|
|
el.innerHTML = "bonked"
|
|
|
|
el.disabled = true
|
2019-10-14 04:59:02 +02:00
|
|
|
post("/bonk", encode({"js": "2", "CSRF": csrftoken, "xid": xid}))
|
|
|
|
return false
|
2019-09-16 21:15:32 +02:00
|
|
|
}
|
|
|
|
function unbonk(el, xid) {
|
|
|
|
el.innerHTML = "unbonked"
|
|
|
|
el.disabled = true
|
2019-09-19 04:17:50 +02:00
|
|
|
post("/zonkit", encode({"CSRF": csrftoken, "wherefore": "unbonk", "what": xid}))
|
2019-09-16 21:15:32 +02:00
|
|
|
}
|
|
|
|
function muteit(el, convoy) {
|
|
|
|
el.innerHTML = "muted"
|
|
|
|
el.disabled = true
|
2019-09-19 04:17:50 +02:00
|
|
|
post("/zonkit", encode({"CSRF": csrftoken, "wherefore": "zonvoy", "what": convoy}))
|
2019-09-16 21:15:32 +02:00
|
|
|
var els = document.querySelectorAll('article.honk')
|
|
|
|
for (var i = 0; i < els.length; i++) {
|
|
|
|
var e = els[i]
|
|
|
|
if (e.getAttribute("data-convoy") == convoy) {
|
|
|
|
e.remove()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function zonkit(el, xid) {
|
|
|
|
el.innerHTML = "zonked"
|
|
|
|
el.disabled = true
|
2019-09-19 04:17:50 +02:00
|
|
|
post("/zonkit", encode({"CSRF": csrftoken, "wherefore": "zonk", "what": xid}))
|
2019-09-16 21:15:32 +02:00
|
|
|
var p = el
|
|
|
|
while (p && p.tagName != "ARTICLE") {
|
|
|
|
p = p.parentElement
|
|
|
|
}
|
|
|
|
if (p) {
|
|
|
|
p.remove()
|
|
|
|
}
|
|
|
|
}
|
2019-10-11 22:03:17 +02:00
|
|
|
function flogit(el, how, xid) {
|
|
|
|
var s = how
|
|
|
|
if (s[s.length-1] != "e") { s += "e" }
|
|
|
|
s += "d"
|
2019-10-30 00:18:16 +01:00
|
|
|
if (s == "untaged") s = "untagged"
|
2020-02-18 18:29:03 +01:00
|
|
|
if (s == "reacted") s = "badonked"
|
2019-10-11 22:03:17 +02:00
|
|
|
el.innerHTML = s
|
2019-09-16 21:15:32 +02:00
|
|
|
el.disabled = true
|
2019-10-11 22:03:17 +02:00
|
|
|
post("/zonkit", encode({"CSRF": csrftoken, "wherefore": how, "what": xid}))
|
2019-09-16 21:15:32 +02:00
|
|
|
}
|
2019-10-20 21:06:15 +02:00
|
|
|
|
|
|
|
var lehonkform = document.getElementById("honkform")
|
|
|
|
var lehonkbutton = document.getElementById("honkingtime")
|
|
|
|
|
2019-11-15 21:54:24 +01:00
|
|
|
function oldestnewest(btn) {
|
|
|
|
var els = document.getElementsByClassName("glow")
|
|
|
|
if (els.length) {
|
|
|
|
els[els.length-1].scrollIntoView()
|
|
|
|
}
|
|
|
|
}
|
2019-10-29 05:26:05 +01:00
|
|
|
function removeglow() {
|
|
|
|
var els = document.getElementsByClassName("glow")
|
|
|
|
while (els.length) {
|
|
|
|
els[0].classList.remove("glow")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function fillinhonks(xhr, glowit) {
|
2022-01-28 03:58:37 +01:00
|
|
|
var resp = xhr.response
|
2019-09-24 23:55:17 +02:00
|
|
|
var stash = curpagestate.name + ":" + curpagestate.arg
|
2022-01-28 03:58:37 +01:00
|
|
|
tophid[stash] = resp.Tophid
|
|
|
|
var doc = document.createElement( 'div' );
|
|
|
|
doc.innerHTML = resp.Srvmsg
|
|
|
|
var srvmsg = doc
|
|
|
|
doc = document.createElement( 'div' );
|
|
|
|
doc.innerHTML = resp.Honks
|
|
|
|
var honks = doc.children
|
2019-10-07 18:34:36 +02:00
|
|
|
|
2022-02-05 22:53:19 +01:00
|
|
|
var mecount = document.getElementById("mecount")
|
|
|
|
if (resp.MeCount) {
|
|
|
|
mecount.innerHTML = "(" + resp.MeCount + ")"
|
|
|
|
} else {
|
|
|
|
mecount.innerHTML = ""
|
|
|
|
}
|
|
|
|
var chatcount = document.getElementById("chatcount")
|
|
|
|
if (resp.ChatCount) {
|
|
|
|
chatcount.innerHTML = "(" + resp.ChatCount + ")"
|
|
|
|
} else {
|
|
|
|
chatcount.innerHTML = ""
|
|
|
|
}
|
|
|
|
|
2019-10-07 18:34:36 +02:00
|
|
|
var srvel = document.getElementById("srvmsg")
|
2019-10-25 09:27:40 +02:00
|
|
|
while (srvel.children[0]) {
|
2019-10-07 19:18:30 +02:00
|
|
|
srvel.children[0].remove()
|
|
|
|
}
|
2019-10-07 18:34:36 +02:00
|
|
|
srvel.prepend(srvmsg)
|
|
|
|
|
2019-10-08 06:58:42 +02:00
|
|
|
var frontload = true
|
|
|
|
if (curpagestate.name == "convoy") {
|
|
|
|
frontload = false
|
|
|
|
}
|
|
|
|
|
2019-09-16 21:15:32 +02:00
|
|
|
var honksonpage = document.getElementById("honksonpage")
|
|
|
|
var holder = honksonpage.children[0]
|
|
|
|
var lenhonks = honks.length
|
|
|
|
for (var i = honks.length; i > 0; i--) {
|
2019-10-29 05:26:05 +01:00
|
|
|
var h = honks[i-1]
|
|
|
|
if (glowit)
|
|
|
|
h.classList.add("glow")
|
2019-10-08 06:58:42 +02:00
|
|
|
if (frontload) {
|
2019-10-29 05:26:05 +01:00
|
|
|
holder.prepend(h)
|
2019-10-08 06:58:42 +02:00
|
|
|
} else {
|
2019-10-29 05:26:05 +01:00
|
|
|
holder.append(h)
|
2019-10-08 06:58:42 +02:00
|
|
|
}
|
2019-09-16 21:15:32 +02:00
|
|
|
}
|
2019-09-24 23:55:17 +02:00
|
|
|
relinklinks()
|
2019-09-16 21:15:32 +02:00
|
|
|
return lenhonks
|
|
|
|
}
|
2019-09-24 23:55:17 +02:00
|
|
|
function hydrargs() {
|
|
|
|
var name = curpagestate.name
|
|
|
|
var arg = curpagestate.arg
|
|
|
|
var args = { "page" : name }
|
|
|
|
if (name == "convoy") {
|
|
|
|
args["c"] = arg
|
|
|
|
} else if (name == "combo") {
|
|
|
|
args["c"] = arg
|
2019-10-02 01:45:17 +02:00
|
|
|
} else if (name == "honker") {
|
|
|
|
args["xid"] = arg
|
2022-04-28 03:11:47 +02:00
|
|
|
} else if (name == "user") {
|
|
|
|
args["uname"] = arg
|
2019-09-24 23:55:17 +02:00
|
|
|
}
|
|
|
|
return args
|
|
|
|
}
|
2019-10-11 07:01:15 +02:00
|
|
|
function refreshupdate(msg) {
|
|
|
|
var el = document.querySelector("#refreshbox p span")
|
|
|
|
if (el) {
|
|
|
|
el.innerHTML = msg
|
|
|
|
}
|
|
|
|
}
|
2019-09-16 21:15:32 +02:00
|
|
|
function refreshhonks(btn) {
|
2019-10-29 05:26:05 +01:00
|
|
|
removeglow()
|
2019-09-16 21:15:32 +02:00
|
|
|
btn.innerHTML = "refreshing"
|
|
|
|
btn.disabled = true
|
2019-09-24 23:55:17 +02:00
|
|
|
var args = hydrargs()
|
|
|
|
var stash = curpagestate.name + ":" + curpagestate.arg
|
2019-10-20 20:36:55 +02:00
|
|
|
args["tophid"] = tophid[stash]
|
2019-09-16 21:15:32 +02:00
|
|
|
get("/hydra?" + encode(args), function(xhr) {
|
|
|
|
btn.innerHTML = "refresh"
|
|
|
|
btn.disabled = false
|
2022-04-01 21:40:45 +02:00
|
|
|
if (xhr.status == 200) {
|
|
|
|
var lenhonks = fillinhonks(xhr, true)
|
|
|
|
refreshupdate(" " + lenhonks + " new")
|
|
|
|
} else {
|
|
|
|
refreshupdate(" status: " + xhr.status)
|
|
|
|
}
|
|
|
|
}, function(xhr, e) {
|
|
|
|
btn.innerHTML = "refresh"
|
|
|
|
btn.disabled = false
|
|
|
|
refreshupdate(" timed out")
|
2019-09-16 21:15:32 +02:00
|
|
|
})
|
|
|
|
}
|
2019-09-16 21:46:33 +02:00
|
|
|
function statechanger(evt) {
|
2019-09-24 23:55:17 +02:00
|
|
|
var data = evt.state
|
|
|
|
if (!data) {
|
2019-09-16 21:46:33 +02:00
|
|
|
return
|
|
|
|
}
|
2019-09-24 23:55:17 +02:00
|
|
|
switchtopage(data.name, data.arg)
|
2019-09-16 21:46:33 +02:00
|
|
|
}
|
2019-09-24 23:55:17 +02:00
|
|
|
function switchtopage(name, arg) {
|
2019-10-07 19:18:30 +02:00
|
|
|
var stash = curpagestate.name + ":" + curpagestate.arg
|
2019-09-16 21:46:33 +02:00
|
|
|
var honksonpage = document.getElementById("honksonpage")
|
|
|
|
var holder = honksonpage.children[0]
|
|
|
|
holder.remove()
|
2019-10-07 19:18:30 +02:00
|
|
|
var srvel = document.getElementById("srvmsg")
|
|
|
|
var msg = srvel.children[0]
|
|
|
|
if (msg) {
|
|
|
|
msg.remove()
|
|
|
|
servermsgs[stash] = msg
|
2019-09-16 21:46:33 +02:00
|
|
|
}
|
2020-02-21 15:54:25 +01:00
|
|
|
showelement("refreshbox")
|
2019-10-07 19:18:30 +02:00
|
|
|
|
|
|
|
honksforpage[stash] = holder
|
|
|
|
|
2019-09-24 23:55:17 +02:00
|
|
|
curpagestate.name = name
|
|
|
|
curpagestate.arg = arg
|
|
|
|
// get the holder for the target page
|
2023-02-22 20:56:26 +01:00
|
|
|
stash = name + ":" + arg
|
2019-09-24 23:55:17 +02:00
|
|
|
holder = honksforpage[stash]
|
2019-09-16 21:46:33 +02:00
|
|
|
if (holder) {
|
|
|
|
honksonpage.prepend(holder)
|
2019-10-07 19:18:30 +02:00
|
|
|
msg = servermsgs[stash]
|
|
|
|
if (msg) {
|
|
|
|
srvel.prepend(msg)
|
|
|
|
}
|
2019-09-16 21:46:33 +02:00
|
|
|
} else {
|
2019-09-24 23:55:17 +02:00
|
|
|
// or create one and fill it
|
2019-09-16 21:46:33 +02:00
|
|
|
honksonpage.prepend(document.createElement("div"))
|
2019-09-24 23:55:17 +02:00
|
|
|
var args = hydrargs()
|
2022-04-01 21:40:45 +02:00
|
|
|
get("/hydra?" + encode(args), function(xhr) {
|
|
|
|
if (xhr.status == 200) {
|
2023-02-22 20:56:26 +01:00
|
|
|
fillinhonks(xhr, false)
|
2022-04-01 21:40:45 +02:00
|
|
|
} else {
|
|
|
|
refreshupdate(" status: " + xhr.status)
|
|
|
|
}
|
|
|
|
}, function(xhr, e) {
|
|
|
|
refreshupdate(" timed out")
|
|
|
|
})
|
2019-09-16 21:46:33 +02:00
|
|
|
}
|
2019-10-11 07:01:15 +02:00
|
|
|
refreshupdate("")
|
2019-09-16 21:46:33 +02:00
|
|
|
}
|
2019-09-24 23:55:17 +02:00
|
|
|
function newpagestate(name, arg) {
|
|
|
|
return { "name": name, "arg": arg }
|
|
|
|
}
|
|
|
|
function pageswitcher(name, arg) {
|
2019-09-16 21:15:32 +02:00
|
|
|
return function(evt) {
|
2019-10-03 22:08:31 +02:00
|
|
|
var topmenu = document.getElementById("topmenu")
|
|
|
|
topmenu.open = false
|
2019-09-24 23:55:17 +02:00
|
|
|
if (name == curpagestate.name && arg == curpagestate.arg) {
|
2019-09-16 21:15:32 +02:00
|
|
|
return false
|
|
|
|
}
|
2019-09-24 23:55:17 +02:00
|
|
|
switchtopage(name, arg)
|
2019-09-16 21:46:33 +02:00
|
|
|
var url = evt.srcElement.href
|
2019-10-07 22:33:31 +02:00
|
|
|
if (!url) {
|
|
|
|
url = evt.srcElement.parentElement.href
|
|
|
|
}
|
2019-09-24 23:55:17 +02:00
|
|
|
history.pushState(newpagestate(name, arg), "some title", url)
|
2019-10-01 23:02:53 +02:00
|
|
|
window.scrollTo(0, 0)
|
2019-09-16 21:15:32 +02:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
2019-09-24 23:55:17 +02:00
|
|
|
function relinklinks() {
|
2019-09-16 21:15:32 +02:00
|
|
|
var els = document.getElementsByClassName("convoylink")
|
2019-10-02 01:45:17 +02:00
|
|
|
while (els.length) {
|
|
|
|
els[0].onclick = pageswitcher("convoy", els[0].text)
|
|
|
|
els[0].classList.remove("convoylink")
|
2019-09-24 23:55:17 +02:00
|
|
|
}
|
|
|
|
els = document.getElementsByClassName("combolink")
|
2019-10-02 01:45:17 +02:00
|
|
|
while (els.length) {
|
|
|
|
els[0].onclick = pageswitcher("combo", els[0].text)
|
|
|
|
els[0].classList.remove("combolink")
|
|
|
|
}
|
|
|
|
els = document.getElementsByClassName("honkerlink")
|
|
|
|
while (els.length) {
|
2019-10-04 08:32:44 +02:00
|
|
|
var el = els[0]
|
|
|
|
var xid = el.getAttribute("data-xid")
|
|
|
|
el.onclick = pageswitcher("honker", xid)
|
|
|
|
el.classList.remove("honkerlink")
|
2019-09-16 21:15:32 +02:00
|
|
|
}
|
2023-01-26 21:56:48 +01:00
|
|
|
|
|
|
|
els = document.querySelectorAll("#honksonpage article button")
|
|
|
|
els.forEach(function(el) {
|
|
|
|
var honk = el.closest("article")
|
|
|
|
var convoy = honk.dataset.convoy
|
|
|
|
var hname = honk.dataset.hname
|
|
|
|
var xid = honk.dataset.xid
|
|
|
|
var id = Number(honk.dataset.id)
|
|
|
|
|
|
|
|
if (!(id > 0)) {
|
|
|
|
console.error("could not determine honk id")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if (el.classList.contains("unbonk")) {
|
|
|
|
el.onclick = function() {
|
|
|
|
unbonk(el, xid);
|
|
|
|
}
|
|
|
|
} else if (el.classList.contains("bonk")) {
|
|
|
|
el.onclick = function() {
|
|
|
|
bonk(el, xid)
|
|
|
|
}
|
|
|
|
} else if (el.classList.contains("honkback")) {
|
|
|
|
el.onclick = function() {
|
|
|
|
return showhonkform(el, xid, hname)
|
|
|
|
}
|
|
|
|
} else if (el.classList.contains("mute")) {
|
|
|
|
el.onclick = function() {
|
|
|
|
muteit(el, convoy);
|
|
|
|
}
|
|
|
|
} else if (el.classList.contains("evenmore")) {
|
|
|
|
var more = document.querySelector("#evenmore"+id);
|
|
|
|
el.onclick = function() {
|
|
|
|
more.classList.toggle("hide");
|
|
|
|
}
|
|
|
|
} else if (el.classList.contains("zonk")) {
|
|
|
|
el.onclick = function() {
|
|
|
|
zonkit(el, xid);
|
|
|
|
}
|
|
|
|
} else if (el.classList.contains("flogit-deack")) {
|
|
|
|
el.onclick = function() {
|
|
|
|
flogit(el, "deack", xid);
|
|
|
|
}
|
|
|
|
} else if (el.classList.contains("flogit-ack")) {
|
|
|
|
el.onclick = function() {
|
|
|
|
flogit(el, "ack", xid);
|
|
|
|
}
|
|
|
|
} else if (el.classList.contains("flogit-unsave")) {
|
|
|
|
el.onclick = function() {
|
|
|
|
flogit(el, "unsave", xid);
|
|
|
|
}
|
|
|
|
} else if (el.classList.contains("flogit-save")) {
|
|
|
|
el.onclick = function() {
|
|
|
|
flogit(el, "save", xid);
|
|
|
|
}
|
|
|
|
} else if (el.classList.contains("flogit-untag")) {
|
|
|
|
el.onclick = function() {
|
|
|
|
flogit(el, "untag", xid);
|
|
|
|
}
|
|
|
|
} else if (el.classList.contains("flogit-react")) {
|
|
|
|
el.onclick = function() {
|
|
|
|
flogit(el, "react", xid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2019-09-16 21:15:32 +02:00
|
|
|
}
|
2019-09-18 21:19:31 +02:00
|
|
|
function showhonkform(elem, rid, hname) {
|
2019-10-20 21:06:15 +02:00
|
|
|
var form = lehonkform
|
2019-09-18 21:19:31 +02:00
|
|
|
form.style = "display: block"
|
|
|
|
if (elem) {
|
|
|
|
form.remove()
|
2019-09-30 20:17:58 +02:00
|
|
|
elem.parentElement.parentElement.parentElement.insertAdjacentElement('beforebegin', form)
|
2019-09-18 21:19:31 +02:00
|
|
|
} else {
|
2019-10-20 21:06:15 +02:00
|
|
|
hideelement(lehonkbutton)
|
2019-09-18 21:19:31 +02:00
|
|
|
elem = document.getElementById("honkformhost")
|
|
|
|
elem.insertAdjacentElement('afterend', form)
|
|
|
|
}
|
|
|
|
var ridinput = document.getElementById("ridinput")
|
2023-02-22 20:56:26 +01:00
|
|
|
var honknoise = document.getElementById("honknoise")
|
2019-09-18 21:19:31 +02:00
|
|
|
if (rid) {
|
|
|
|
ridinput.value = rid
|
2021-01-29 03:46:46 +01:00
|
|
|
if (hname) {
|
|
|
|
honknoise.value = hname + " "
|
|
|
|
} else {
|
|
|
|
honknoise.value = ""
|
|
|
|
}
|
2019-10-20 21:06:15 +02:00
|
|
|
} else {
|
|
|
|
ridinput.value = ""
|
|
|
|
honknoise.value = ""
|
2019-09-18 21:19:31 +02:00
|
|
|
}
|
2019-10-20 21:23:41 +02:00
|
|
|
var updateinput = document.getElementById("updatexidinput")
|
|
|
|
updateinput.value = ""
|
2023-02-22 20:56:26 +01:00
|
|
|
honknoise.focus()
|
2019-10-14 04:59:02 +02:00
|
|
|
return false
|
2019-09-18 21:19:31 +02:00
|
|
|
}
|
2019-10-20 21:06:15 +02:00
|
|
|
function cancelhonking() {
|
|
|
|
hideelement(lehonkform)
|
|
|
|
showelement(lehonkbutton)
|
|
|
|
}
|
|
|
|
function showelement(el) {
|
|
|
|
if (typeof(el) == "string")
|
|
|
|
el = document.getElementById(el)
|
2020-02-25 19:45:59 +01:00
|
|
|
if (!el) return
|
2019-10-03 00:20:14 +02:00
|
|
|
el.style.display = "block"
|
|
|
|
}
|
2019-10-20 21:06:15 +02:00
|
|
|
function hideelement(el) {
|
|
|
|
if (typeof(el) == "string")
|
|
|
|
el = document.getElementById(el)
|
2020-02-25 19:45:59 +01:00
|
|
|
if (!el) return
|
2019-10-20 21:06:15 +02:00
|
|
|
el.style.display = "none"
|
|
|
|
}
|
2023-08-25 07:12:26 +02:00
|
|
|
function updatedonker(ev) {
|
|
|
|
var el = ev.target.parentElement
|
2019-09-18 21:19:31 +02:00
|
|
|
el.children[1].textContent = el.children[0].value.slice(-20)
|
2023-08-25 07:12:26 +02:00
|
|
|
el = el.nextSibling
|
2019-10-23 06:45:12 +02:00
|
|
|
el.value = ""
|
2023-08-25 07:12:26 +02:00
|
|
|
el = el.parentElement.nextSibling
|
|
|
|
el.style.display = ""
|
2019-09-18 21:19:31 +02:00
|
|
|
}
|
2019-10-05 22:41:17 +02:00
|
|
|
var checkinprec = 100.0
|
2019-10-05 19:11:24 +02:00
|
|
|
var gpsoptions = {
|
|
|
|
enableHighAccuracy: false,
|
|
|
|
timeout: 1000,
|
|
|
|
maximumAge: 0
|
|
|
|
};
|
2019-09-28 06:12:50 +02:00
|
|
|
function fillcheckin() {
|
|
|
|
if (navigator.geolocation) {
|
|
|
|
navigator.geolocation.getCurrentPosition(function(pos) {
|
2019-10-03 00:20:14 +02:00
|
|
|
showelement("placedescriptor")
|
|
|
|
var el = document.getElementById("placelatinput")
|
2019-09-28 22:24:55 +02:00
|
|
|
el.value = Math.round(pos.coords.latitude * checkinprec) / checkinprec
|
2019-09-28 06:12:50 +02:00
|
|
|
el = document.getElementById("placelonginput")
|
2019-09-28 22:24:55 +02:00
|
|
|
el.value = Math.round(pos.coords.longitude * checkinprec) / checkinprec
|
|
|
|
checkinprec = 10000.0
|
2019-10-05 19:11:24 +02:00
|
|
|
gpsoptions.enableHighAccuracy = true
|
|
|
|
gpsoptions.timeout = 2000
|
2019-09-28 06:12:50 +02:00
|
|
|
}, function(err) {
|
2019-10-03 00:20:14 +02:00
|
|
|
showelement("placedescriptor")
|
2023-02-22 20:56:26 +01:00
|
|
|
var el = document.getElementById("placenameinput")
|
2019-09-28 06:16:43 +02:00
|
|
|
el.value = err.message
|
2019-10-05 19:11:24 +02:00
|
|
|
}, gpsoptions)
|
2019-09-28 06:12:50 +02:00
|
|
|
}
|
|
|
|
}
|
2023-08-26 20:39:09 +02:00
|
|
|
|
|
|
|
function scrollnexthonk() {
|
|
|
|
var honks = document.getElementsByClassName("honk");
|
|
|
|
for (var i = 0; i < honks.length; i++) {
|
|
|
|
var h = honks[i];
|
|
|
|
var b = h.getBoundingClientRect();
|
|
|
|
if (b.top > 1.0) {
|
|
|
|
h.scrollIntoView();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function scrollprevioushonk() {
|
|
|
|
var honks = document.getElementsByClassName("honk");
|
|
|
|
for (var i = 1; i < honks.length; i++) {
|
|
|
|
var b = honks[i].getBoundingClientRect();
|
|
|
|
if (b.top > -1.0) {
|
|
|
|
honks[i-1].scrollIntoView();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-28 21:00:18 +02:00
|
|
|
function hotkey(e) {
|
2023-08-26 20:39:09 +02:00
|
|
|
if (e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement)
|
2023-08-28 21:00:18 +02:00
|
|
|
return
|
|
|
|
if (e.ctrlKey || e.altKey)
|
|
|
|
return
|
2023-08-26 20:39:09 +02:00
|
|
|
|
|
|
|
switch (e.code) {
|
|
|
|
case "KeyR":
|
|
|
|
refreshhonks(document.getElementById("honkrefresher"));
|
|
|
|
break;
|
|
|
|
case "KeyS":
|
|
|
|
oldestnewest(document.getElementById("newerscroller"));
|
|
|
|
break;
|
|
|
|
case "KeyJ":
|
|
|
|
scrollnexthonk();
|
|
|
|
break;
|
|
|
|
case "KeyK":
|
|
|
|
scrollprevioushonk();
|
|
|
|
break;
|
2023-08-26 20:56:28 +02:00
|
|
|
case "Slash":
|
|
|
|
document.getElementById("topmenu").open = true
|
|
|
|
document.getElementById("searchbox").focus()
|
|
|
|
e.preventDefault()
|
|
|
|
break
|
2023-08-26 20:39:09 +02:00
|
|
|
}
|
2023-08-28 21:00:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
document.addEventListener("keydown", hotkey)
|
2023-08-26 20:39:09 +02:00
|
|
|
|
2023-01-27 06:20:27 +01:00
|
|
|
function addemu(elem) {
|
|
|
|
const data = elem.alt
|
2023-01-26 22:27:11 +01:00
|
|
|
const box = document.getElementById("honknoise");
|
|
|
|
box.value += data;
|
|
|
|
}
|
|
|
|
function loademus() {
|
2023-02-22 20:56:26 +01:00
|
|
|
var div = document.getElementById("emupicker")
|
|
|
|
var request = new XMLHttpRequest()
|
2023-01-26 22:27:11 +01:00
|
|
|
request.open('GET', '/emus')
|
2023-01-27 06:20:27 +01:00
|
|
|
request.onload = function() {
|
2023-01-26 22:27:11 +01:00
|
|
|
div.innerHTML = request.responseText
|
2023-01-27 06:20:27 +01:00
|
|
|
div.querySelectorAll(".emu").forEach(function(el) {
|
|
|
|
el.onclick = function() {
|
|
|
|
addemu(el)
|
|
|
|
}
|
|
|
|
})
|
2023-01-26 22:27:11 +01:00
|
|
|
}
|
|
|
|
if (div.style.display === "none") {
|
|
|
|
div.style.display = "block";
|
|
|
|
} else {
|
|
|
|
div.style.display = "none";
|
|
|
|
}
|
|
|
|
request.send()
|
|
|
|
}
|
2023-01-26 21:56:48 +01:00
|
|
|
|
|
|
|
// init
|
|
|
|
(function() {
|
|
|
|
var me = document.currentScript;
|
|
|
|
csrftoken = me.dataset.csrf
|
|
|
|
curpagestate.name = me.dataset.pagename
|
|
|
|
curpagestate.arg = me.dataset.pagearg
|
|
|
|
tophid[curpagestate.name + ":" + curpagestate.arg] = me.dataset.tophid
|
|
|
|
servermsgs[curpagestate.name + ":" + curpagestate.arg] = me.dataset.srvmsg
|
|
|
|
|
2023-01-27 21:42:50 +01:00
|
|
|
var el = document.getElementById("homelink")
|
|
|
|
el.onclick = pageswitcher("home", "")
|
|
|
|
el = document.getElementById("atmelink")
|
|
|
|
el.onclick = pageswitcher("atme", "")
|
|
|
|
el = document.getElementById("firstlink")
|
|
|
|
el.onclick = pageswitcher("first", "")
|
|
|
|
el = document.getElementById("savedlink")
|
|
|
|
el.onclick = pageswitcher("saved", "")
|
|
|
|
el = document.getElementById("longagolink")
|
|
|
|
el.onclick = pageswitcher("longago", "")
|
|
|
|
|
2023-01-26 21:56:48 +01:00
|
|
|
var totop = document.querySelector(".nophone")
|
|
|
|
if (totop) {
|
|
|
|
totop.onclick = function() {
|
|
|
|
window.scrollTo(0,0)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var refreshbox = document.getElementById("refreshbox")
|
|
|
|
if (refreshbox) {
|
|
|
|
refreshbox.querySelectorAll("button").forEach(function(el) {
|
|
|
|
if (el.classList.contains("refresh")) {
|
|
|
|
el.onclick = function() {
|
|
|
|
refreshhonks(el)
|
|
|
|
}
|
|
|
|
} else if (el.classList.contains("scrolldown")) {
|
|
|
|
el.onclick = function() {
|
|
|
|
oldestnewest(el)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
if (me.dataset.srvmsg == "one honk maybe more") {
|
|
|
|
hideelement(refreshbox)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var td = document.getElementById("timedescriptor")
|
|
|
|
document.getElementById("addtimebutton").onclick = function() {
|
|
|
|
td.classList.toggle("hide")
|
|
|
|
}
|
|
|
|
document.getElementById("honkingtime").onclick = function() {
|
|
|
|
return showhonkform()
|
|
|
|
}
|
|
|
|
document.getElementById("checkinbutton").onclick = fillcheckin
|
2023-01-26 22:27:11 +01:00
|
|
|
document.getElementById("emuload").onclick = loademus
|
2023-01-26 21:56:48 +01:00
|
|
|
document.querySelector("#donker input").onchange = updatedonker
|
|
|
|
document.querySelector("button[name=cancel]").onclick = cancelhonking
|
2023-01-27 21:42:50 +01:00
|
|
|
|
|
|
|
relinklinks()
|
|
|
|
window.onpopstate = statechanger
|
|
|
|
history.replaceState(curpagestate, "some title", "")
|
|
|
|
|
|
|
|
hideelement("donkdescriptor")
|
2023-01-26 21:56:48 +01:00
|
|
|
})();
|