mirror of
https://github.com/rystaf/mlmym.git
synced 2024-11-22 05:36:16 +00:00
delete comment confirm()
This commit is contained in:
parent
352360218b
commit
aaf0234e5b
|
@ -55,6 +55,11 @@ function commentClick(e) {
|
||||||
targ = form
|
targ = form
|
||||||
} else { return }
|
} else { return }
|
||||||
e.target.disabled = "disabled"
|
e.target.disabled = "disabled"
|
||||||
|
if (data.get("op") == "delete_comment") {
|
||||||
|
if (!confirm("Are you sure you want to delete?")) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
request(targ.action || "", data,
|
request(targ.action || "", data,
|
||||||
function(res){
|
function(res){
|
||||||
if (data.get("op") == "block_user") {
|
if (data.get("op") == "block_user") {
|
||||||
|
|
|
@ -1297,7 +1297,7 @@ func UserOp(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||||
postid, _ := strconv.Atoi(ps.ByName("postid"))
|
postid, _ := strconv.Atoi(ps.ByName("postid"))
|
||||||
state.PostID = postid
|
state.PostID = postid
|
||||||
}
|
}
|
||||||
if r.FormValue("parentid") != "" {
|
if r.FormValue("parentid") != "" && r.FormValue("parentid") != "0" {
|
||||||
parentid, _ := strconv.Atoi(r.FormValue("parentid"))
|
parentid, _ := strconv.Atoi(r.FormValue("parentid"))
|
||||||
state.GetComment(parentid)
|
state.GetComment(parentid)
|
||||||
}
|
}
|
||||||
|
@ -1428,6 +1428,13 @@ func UserOp(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
} else {
|
} else {
|
||||||
|
if r.FormValue("xhr") != "" {
|
||||||
|
state.XHR = true
|
||||||
|
state.Comments = append(state.Comments, Comment{P: resp.CommentView, State: &state})
|
||||||
|
state.CommentID = commentid
|
||||||
|
Render(w, "index.html", state)
|
||||||
|
return
|
||||||
|
}
|
||||||
commentid := strconv.Itoa(resp.CommentView.Comment.ID)
|
commentid := strconv.Itoa(resp.CommentView.Comment.ID)
|
||||||
r.URL.Fragment = "c" + commentid
|
r.URL.Fragment = "c" + commentid
|
||||||
r.URL.RawQuery = ""
|
r.URL.RawQuery = ""
|
||||||
|
|
|
@ -61,13 +61,15 @@
|
||||||
{{ if .State.Session }}
|
{{ if .State.Session }}
|
||||||
{{ if and (eq .P.Comment.CreatorID .State.Session.UserID) (ne .Op "edit") }}
|
{{ if and (eq .P.Comment.CreatorID .State.Session.UserID) (ne .Op "edit") }}
|
||||||
<li><a class="edit" for="c{{.P.Comment.ID}}" href="/{{.State.Host}}/comment/{{.P.Comment.ID}}?edit">edit</a></li>
|
<li><a class="edit" for="c{{.P.Comment.ID}}" href="/{{.State.Host}}/comment/{{.P.Comment.ID}}?edit">edit</a></li>
|
||||||
|
{{ if not .P.Comment.Deleted }}
|
||||||
<li>
|
<li>
|
||||||
<form class="delete" method="POST">
|
<form class="delete" method="POST">
|
||||||
<input type="hidden" name="commentid" value="{{.P.Comment.ID}}">
|
<input type="hidden" name="commentid" value="{{.P.Comment.ID}}">
|
||||||
<input type="hidden" name="op" value="delete_comment">
|
<input type="hidden" name="op" value="delete_comment">
|
||||||
<input type="submit" value="delete">
|
<input type="submit" name="submit" value="delete">
|
||||||
</form>
|
</form>
|
||||||
</li>
|
</li>
|
||||||
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
<li>
|
<li>
|
||||||
<form class="link-btn" method="POST">
|
<form class="link-btn" method="POST">
|
||||||
|
|
Loading…
Reference in a new issue