add more kill controls
This commit is contained in:
parent
5183a83124
commit
c9075e46ff
27
honk.go
27
honk.go
|
@ -789,11 +789,32 @@ func savebonk(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func zonkit(w http.ResponseWriter, r *http.Request) {
|
func zonkit(w http.ResponseWriter, r *http.Request) {
|
||||||
xid := r.FormValue("xid")
|
wherefore := r.FormValue("wherefore")
|
||||||
|
var what string
|
||||||
|
switch wherefore {
|
||||||
|
case "this honk":
|
||||||
|
what = r.FormValue("honk")
|
||||||
|
wherefore = "zonk"
|
||||||
|
case "this honker":
|
||||||
|
what = r.FormValue("honker")
|
||||||
|
wherefore = "zonker"
|
||||||
|
case "this convoy":
|
||||||
|
what = r.FormValue("convoy")
|
||||||
|
wherefore = "zonvoy"
|
||||||
|
}
|
||||||
|
if what == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
log.Printf("zonking %s", xid)
|
log.Printf("zonking %s %s", wherefore, what)
|
||||||
userinfo := login.GetUserInfo(r)
|
userinfo := login.GetUserInfo(r)
|
||||||
stmtZonkIt.Exec(userinfo.UserID, xid)
|
if wherefore == "zonk" {
|
||||||
|
stmtZonkIt.Exec(userinfo.UserID, what)
|
||||||
|
} else {
|
||||||
|
db := opendatabase()
|
||||||
|
db.Exec("insert into zonkers (userid, name, wherefore) values (?, ?, ?)",
|
||||||
|
userinfo.UserID, what, wherefore)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func savehonk(w http.ResponseWriter, r *http.Request) {
|
func savehonk(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
|
@ -25,10 +25,24 @@ convoy: <a href="/t?c={{ .Convoy }}">{{ .Convoy }}</a>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ if and .Bonk (not (eq .Honk.What "zonked")) }}
|
{{ if and .BonkCSRF (not (eq .Honk.What "zonked")) }}
|
||||||
<p>
|
<p>
|
||||||
|
<div>
|
||||||
<button onclick="bonk(this, '{{ .Honk.XID }}'); return false;"><a href="/bonk">bonk</a></button>
|
<button onclick="bonk(this, '{{ .Honk.XID }}'); return false;"><a href="/bonk">bonk</a></button>
|
||||||
<button onclick="showhonkform('{{ .Honk.XID }}', '{{ .Honk.Username }}'); return false;"><a href="/newhonk">tonk</a></button>
|
<button onclick="showhonkform('{{ .Honk.XID }}', '{{ .Honk.Username }}'); return false;"><a href="/newhonk">tonk</a></button>
|
||||||
<button onclick="zonkit(this, '{{ .Honk.XID }}'); return false;"><a href="/zonkit">zonk</a></button>
|
<form class="inlineform" action="/zonkit" method="POST">
|
||||||
|
<input type="hidden" name="CSRF" value="{{ .BonkCSRF }}">
|
||||||
|
<input type="hidden" name="honk" value="{{ .Honk.XID }}">
|
||||||
|
<input type="hidden" name="honker" value="{{ .Honk.Honker }}">
|
||||||
|
<input type="hidden" name="convoy" value="{{ .Honk.Convoy }}">
|
||||||
|
<select name="wherefore">
|
||||||
|
<option>this honk</option>
|
||||||
|
<option>this honker</option>
|
||||||
|
<option>this convoy</option>
|
||||||
|
</select>
|
||||||
|
<button onclick="zonkit(this); return false;"><a href="/zonkit">zonk</a></button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<p>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -24,11 +24,19 @@
|
||||||
<div>
|
<div>
|
||||||
{{ $BonkCSRF := .HonkCSRF }}
|
{{ $BonkCSRF := .HonkCSRF }}
|
||||||
{{ range .Honks }}
|
{{ range .Honks }}
|
||||||
{{ template "honk.html" map "Honk" . "Bonk" $BonkCSRF }}
|
{{ template "honk.html" map "Honk" . "BonkCSRF" $BonkCSRF }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
{{ if $BonkCSRF }}
|
{{ if $BonkCSRF }}
|
||||||
<script>
|
<script>
|
||||||
|
function encode(hash) {
|
||||||
|
var s = []
|
||||||
|
for (var key in hash) {
|
||||||
|
var val = hash[key]
|
||||||
|
s.push(escape(key) + "=" + escape(val))
|
||||||
|
}
|
||||||
|
return s.join("&")
|
||||||
|
}
|
||||||
function post(url, data) {
|
function post(url, data) {
|
||||||
var x = new XMLHttpRequest()
|
var x = new XMLHttpRequest()
|
||||||
x.open("POST", url)
|
x.open("POST", url)
|
||||||
|
@ -38,12 +46,19 @@ function post(url, data) {
|
||||||
function bonk(el, xid) {
|
function bonk(el, xid) {
|
||||||
el.innerHTML = "bonked"
|
el.innerHTML = "bonked"
|
||||||
el.disabled = true
|
el.disabled = true
|
||||||
post("/bonk", "CSRF={{ $BonkCSRF }}&xid=" + xid)
|
post("/bonk", "CSRF={{ $BonkCSRF }}&xid=" + escape(xid))
|
||||||
}
|
}
|
||||||
function zonkit(el, xid) {
|
function zonkit(el) {
|
||||||
el.innerHTML = "zonked"
|
el.innerHTML = "zonked"
|
||||||
el.disabled = true
|
el.disabled = true
|
||||||
post("/zonkit", "CSRF={{ $BonkCSRF }}&xid=" + xid)
|
var data = { }
|
||||||
|
for (var i in el.parentElement.elements) {
|
||||||
|
var e = el.parentElement.elements[i]
|
||||||
|
if (e.name) {
|
||||||
|
data[e.name] = e.value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
post("/zonkit", encode(data))
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
@ -46,7 +46,7 @@ input {
|
||||||
margin-top 1em;
|
margin-top 1em;
|
||||||
margin-bottom: 1em;
|
margin-bottom: 1em;
|
||||||
}
|
}
|
||||||
button, form input[type=submit] {
|
button, form input[type=submit], select {
|
||||||
font-size: 0.8em;
|
font-size: 0.8em;
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
color: #dde;
|
color: #dde;
|
||||||
|
@ -150,6 +150,11 @@ button a {
|
||||||
.zonked .noise a {
|
.zonked .noise a {
|
||||||
color: #a79;
|
color: #a79;
|
||||||
}
|
}
|
||||||
|
.inlineform {
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
|
.inlineform select {
|
||||||
|
}
|
||||||
img {
|
img {
|
||||||
max-width: 100%
|
max-width: 100%
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue