Commit 9eba6a8a authored by Janne Koschinski's avatar Janne Koschinski

Attempt at autosave

parent 57443a6f
......@@ -22,6 +22,7 @@ let lastTimeOut = null;
const doSave = () => {
const data = new FormData(document.forms.namedItem("upload"));
data.append("from_js", "true");
save.value = "Saving…";
postData(location.href, data).then((json) => {
save.value = "Saved";
......
......@@ -55,7 +55,11 @@ func pageImageDetail(ctx PageContext) http.Handler {
if err != nil {
panic(err)
}
http.Redirect(w, r, r.URL.Path, http.StatusFound)
if r.PostFormValue("fromjs") == "true" {
returnJson(w, true)
} else {
http.Redirect(w, r, r.URL.Path, http.StatusFound)
}
return
case "delete":
_, err = ctx.Database.Exec("DELETE FROM images WHERE id = $1 AND owner = $2", info.Id, user.Id)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment