diff --git a/public/utils.js b/public/utils.js
index d15f1fb..afd224d 100644
--- a/public/utils.js
+++ b/public/utils.js
@@ -315,9 +315,9 @@ function setup() {
var posts = document.getElementsByClassName("post")
for (var i = 0; i < posts.length; i++) {
posts[i].addEventListener("click", postClick)
- var voteForm = posts[i].getElementsByClassName("link-btn")
- if (voteForm.length) {
- voteForm[0].addEventListener("submit", formSubmit)
+ var forms = posts[i].getElementsByClassName("link-btn")
+ for (var f = 0; f < forms.length; f++) {
+ forms[f].addEventListener("submit", formSubmit)
}
var url = posts[i].getElementsByClassName("url")[0].href
if (id = parseYoutube(url)) {
diff --git a/routes.go b/routes.go
index 630291a..96cef97 100644
--- a/routes.go
+++ b/routes.go
@@ -924,6 +924,14 @@ func UserOp(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
if err != nil {
fmt.Println(err)
}
+ if r.FormValue("xhr") != "" {
+ state.GetPost(postid)
+ state.PostID = 0
+ state.Op = "save_post"
+ state.XHR = true
+ Render(w, "index.html", state)
+ return
+ }
case "save_comment":
commentid, _ := strconv.Atoi(r.FormValue("commentid"))
_, err := state.Client.SaveComment(context.Background(), types.SaveComment{
diff --git a/templates/frontpage.html b/templates/frontpage.html
index 95b1e1f..d27dc5b 100644
--- a/templates/frontpage.html
+++ b/templates/frontpage.html
@@ -56,6 +56,6 @@
{{ template "sidebar.html" . }}
{{ end }}
-
+