eliminate need for js in various places
This commit is contained in:
parent
ecdaa8d8dd
commit
77617e06fb
|
@ -2,6 +2,8 @@ changelog
|
||||||
|
|
||||||
-- next
|
-- next
|
||||||
|
|
||||||
|
+ More JS free fallbacks for some basic functions.
|
||||||
|
|
||||||
+ Add chpass command.
|
+ Add chpass command.
|
||||||
|
|
||||||
+ Improved honker management.
|
+ Improved honker management.
|
||||||
|
|
|
@ -92,25 +92,25 @@ in reply to: <a href="{{ .RID }}" rel=noreferrer>{{ .RID }}</a>
|
||||||
<p>
|
<p>
|
||||||
{{ if .Honk.Public }}
|
{{ if .Honk.Public }}
|
||||||
{{ if .Honk.IsBonked }}
|
{{ if .Honk.IsBonked }}
|
||||||
<button onclick="unbonk(this, '{{ .Honk.XID }}');">unbonk</button>
|
<button onclick="return unbonk(this, '{{ .Honk.XID }}');">unbonk</button>
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<button onclick="bonk(this, '{{ .Honk.XID }}');">bonk</button>
|
<button onclick="return bonk(this, '{{ .Honk.XID }}');"><a href="/bonk?xid={{ .Honk.XID }}&CSRF={{ $bonkcsrf }}">bonk</a></button>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<button disabled>nope</button>
|
<button disabled>nope</button>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
<button onclick="showhonkform(this, '{{ .Honk.XID }}', '{{ .Honk.Handle }}');">honk back</button>
|
<button onclick="return showhonkform(this, '{{ .Honk.XID }}', '{{ .Honk.Handle }}');"><a href="/newhonk?rid={{ .Honk.XID }}">honk back</a></button>
|
||||||
<button onclick="muteit(this, '{{ .Honk.Convoy }}');">mute</button>
|
<button onclick="return muteit(this, '{{ .Honk.Convoy }}');">mute</button>
|
||||||
<button onclick="zonkit(this, '{{ .Honk.XID }}');">zonk</button>
|
<button onclick="return zonkit(this, '{{ .Honk.XID }}');">zonk</button>
|
||||||
{{ if .Honk.IsAcked }}
|
{{ if .Honk.IsAcked }}
|
||||||
<button onclick="flogit(this, 'deack', '{{ .Honk.XID }}');">deack</button>
|
<button onclick="return flogit(this, 'deack', '{{ .Honk.XID }}');">deack</button>
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<button onclick="flogit(this, 'ack', '{{ .Honk.XID }}');">ack</button>
|
<button onclick="return flogit(this, 'ack', '{{ .Honk.XID }}');">ack</button>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ if .Honk.IsSaved }}
|
{{ if .Honk.IsSaved }}
|
||||||
<button onclick="flogit(this, 'unsave', '{{ .Honk.XID }}');">unsave</button>
|
<button onclick="return flogit(this, 'unsave', '{{ .Honk.XID }}');">unsave</button>
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<button onclick="flogit(this, 'save', '{{ .Honk.XID }}');">save</button>
|
<button onclick="return flogit(this, 'save', '{{ .Honk.XID }}');">save</button>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
<button><a href="/edit?xid={{ .Honk.XID }}">edit</a></button>
|
<button><a href="/edit?xid={{ .Honk.XID }}">edit</a></button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<p id="honkformhost">
|
<p id="honkformhost">
|
||||||
<button onclick="showhonkform(); return false"><a href="/newhonk">it's honking time</a></button>
|
<button onclick="return showhonkform();"><a href="/newhonk">it's honking time</a></button>
|
||||||
<form id="honkform" action="/honk" method="POST" enctype="multipart/form-data" {{ if not .IsPreview }}style="display: none"{{ end }}>
|
<form id="honkform" action="/honk" method="POST" enctype="multipart/form-data" {{ if not .IsPreview }}style="display: none"{{ end }}>
|
||||||
<input type="hidden" name="CSRF" value="{{ .HonkCSRF }}">
|
<input type="hidden" name="CSRF" value="{{ .HonkCSRF }}">
|
||||||
<input type="hidden" name="updatexid" value = "{{ .UpdateXID }}">
|
<input type="hidden" name="updatexid" value = "{{ .UpdateXID }}">
|
||||||
|
|
|
@ -22,7 +22,8 @@ function get(url, whendone) {
|
||||||
function bonk(el, xid) {
|
function bonk(el, xid) {
|
||||||
el.innerHTML = "bonked"
|
el.innerHTML = "bonked"
|
||||||
el.disabled = true
|
el.disabled = true
|
||||||
post("/bonk", encode({"CSRF": csrftoken, "xid": xid}))
|
post("/bonk", encode({"js": "2", "CSRF": csrftoken, "xid": xid}))
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
function unbonk(el, xid) {
|
function unbonk(el, xid) {
|
||||||
el.innerHTML = "unbonked"
|
el.innerHTML = "unbonked"
|
||||||
|
@ -238,6 +239,7 @@ function showhonkform(elem, rid, hname) {
|
||||||
honknoise.value = "@" + hname + " "
|
honknoise.value = "@" + hname + " "
|
||||||
}
|
}
|
||||||
document.getElementById("honknoise").focus()
|
document.getElementById("honknoise").focus()
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
function showelement(id) {
|
function showelement(id) {
|
||||||
var el = document.getElementById(id)
|
var el = document.getElementById(id)
|
||||||
|
|
36
web.go
36
web.go
|
@ -848,6 +848,15 @@ func submitbonk(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
go honkworldwide(user, &bonk)
|
go honkworldwide(user, &bonk)
|
||||||
|
|
||||||
|
if r.FormValue("js") != "1" {
|
||||||
|
templinfo := getInfo(r)
|
||||||
|
templinfo["ServerMessage"] = "Bonked!"
|
||||||
|
err = readviews.Execute(w, "msg.html", templinfo)
|
||||||
|
if err != nil {
|
||||||
|
log.Print(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func sendzonkofsorts(xonk *Honk, user *WhatAbout, what string) {
|
func sendzonkofsorts(xonk *Honk, user *WhatAbout, what string) {
|
||||||
|
@ -983,6 +992,31 @@ func edithonkpage(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func newhonkpage(w http.ResponseWriter, r *http.Request) {
|
||||||
|
u := login.GetUserInfo(r)
|
||||||
|
rid := r.FormValue("rid")
|
||||||
|
noise := ""
|
||||||
|
|
||||||
|
xonk := getxonk(u.UserID, rid)
|
||||||
|
if xonk != nil {
|
||||||
|
_, replto := handles(xonk.Honker)
|
||||||
|
if replto != "" {
|
||||||
|
noise = "@" + replto + " "
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
templinfo := getInfo(r)
|
||||||
|
templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r)
|
||||||
|
templinfo["InReplyTo"] = rid
|
||||||
|
templinfo["Noise"] = noise
|
||||||
|
templinfo["ServerMessage"] = "compose honk"
|
||||||
|
templinfo["IsPreview"] = true
|
||||||
|
err := readviews.Execute(w, "honkpage.html", templinfo)
|
||||||
|
if err != nil {
|
||||||
|
log.Print(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func canedithonk(user *WhatAbout, honk *Honk) bool {
|
func canedithonk(user *WhatAbout, honk *Honk) bool {
|
||||||
if honk == nil || honk.Honker != user.URL || honk.What == "bonk" {
|
if honk == nil || honk.Honker != user.URL || honk.What == "bonk" {
|
||||||
return false
|
return false
|
||||||
|
@ -1686,6 +1720,7 @@ func serve() {
|
||||||
"views/funzone.html",
|
"views/funzone.html",
|
||||||
"views/login.html",
|
"views/login.html",
|
||||||
"views/xzone.html",
|
"views/xzone.html",
|
||||||
|
"views/msg.html",
|
||||||
"views/header.html",
|
"views/header.html",
|
||||||
"views/onts.html",
|
"views/onts.html",
|
||||||
"views/honkpage.js",
|
"views/honkpage.js",
|
||||||
|
@ -1743,6 +1778,7 @@ func serve() {
|
||||||
loggedin.HandleFunc("/atme", homepage)
|
loggedin.HandleFunc("/atme", homepage)
|
||||||
loggedin.HandleFunc("/hfcs", hfcspage)
|
loggedin.HandleFunc("/hfcs", hfcspage)
|
||||||
loggedin.HandleFunc("/xzone", xzone)
|
loggedin.HandleFunc("/xzone", xzone)
|
||||||
|
loggedin.HandleFunc("/newhonk", newhonkpage)
|
||||||
loggedin.HandleFunc("/edit", edithonkpage)
|
loggedin.HandleFunc("/edit", edithonkpage)
|
||||||
loggedin.Handle("/honk", login.CSRFWrap("honkhonk", http.HandlerFunc(submithonk)))
|
loggedin.Handle("/honk", login.CSRFWrap("honkhonk", http.HandlerFunc(submithonk)))
|
||||||
loggedin.Handle("/bonk", login.CSRFWrap("honkhonk", http.HandlerFunc(submitbonk)))
|
loggedin.Handle("/bonk", login.CSRFWrap("honkhonk", http.HandlerFunc(submitbonk)))
|
||||||
|
|
Loading…
Reference in New Issue