@@ 200,6 200,10 @@ func (honk *Honk) IsReacted() bool {
return honk.Flags&flagIsReacted != 0
}
+func (honk *Honk) ShortXID() string {
+ return shortxid(honk.XID)
+}
+
type Donk struct {
FileID int64
XID string
@@ 1,4 1,4 @@
-<article class="honk {{ .Honk.Style }}" data-convoy="{{ .Honk.Convoy }}" data-hname="{{ .Honk.Handles }}" data-xid="{{ .Honk.XID }}" data-id="{{ .Honk.ID }}">
+<article id="{{ .Honk.ShortXID }}" class="honk {{ .Honk.Style }}" data-convoy="{{ .Honk.Convoy }}" data-hname="{{ .Honk.Handles }}" data-xid="{{ .Honk.XID }}" data-id="{{ .Honk.ID }}">
{{ $bonkcsrf := .BonkCSRF }}
{{ $IsPreview := .IsPreview }}
{{ $maplink := .MapLink }}
@@ 47,7 47,7 @@ in reply to: <a href="{{ .RID }}" rel=no
{{ end }}
<br>
{{ if $bonkcsrf }}
-<span class="left1em clip">convoy: <a class="convoylink" href="/t?c={{ .Convoy }}">{{ .Convoy }}</a></span>
+<span class="left1em clip">convoy: <a class="convoylink" href="/t?c={{ .Convoy }}#{{ .ShortXID }}">{{ .Convoy }}</a></span>
{{ end }}
</header>
<p>
@@ 194,7 194,7 @@ function statechanger(evt) {
}
switchtopage(data.name, data.arg)
}
-function switchtopage(name, arg) {
+function switchtopage(name, arg, anchor) {
var stash = curpagestate.name + ":" + curpagestate.arg
var honksonpage = document.getElementById("honksonpage")
var holder = honksonpage.children[0]
@@ 220,6 220,10 @@ function switchtopage(name, arg) {
if (msg) {
srvel.prepend(msg)
}
+ if (anchor) {
+ let el = document.getElementById(anchor)
+ el.scrollIntoView()
+ }
} else {
// or create one and fill it
honksonpage.prepend(document.createElement("div"))
@@ 227,6 231,10 @@ function switchtopage(name, arg) {
get("/hydra?" + encode(args), function(xhr) {
if (xhr.status == 200) {
fillinhonks(xhr, false)
+ if (anchor) {
+ let el = document.getElementById(anchor)
+ el.scrollIntoView()
+ }
} else {
refreshupdate(" status: " + xhr.status)
}
@@ 246,11 254,14 @@ function pageswitcher(name, arg) {
if (name == curpagestate.name && arg == curpagestate.arg) {
return false
}
- switchtopage(name, arg)
- var url = evt.srcElement.href
- if (!url) {
+ let url = evt.srcElement.href
+ if (!url)
url = evt.srcElement.parentElement.href
- }
+ let anchor
+ let arr = url.split("#")
+ if (arr.length == 2)
+ anchor = arr[1]
+ switchtopage(name, arg, anchor)
history.pushState(newpagestate(name, arg), "some title", url)
window.scrollTo(0, 0)
return false