mirror of
https://github.com/rystaf/mlmym.git
synced 2024-11-21 21:27:15 +00:00
delete comment confirm()
This commit is contained in:
parent
352360218b
commit
aaf0234e5b
|
@ -55,6 +55,11 @@ function commentClick(e) {
|
|||
targ = form
|
||||
} else { return }
|
||||
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,
|
||||
function(res){
|
||||
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"))
|
||||
state.PostID = postid
|
||||
}
|
||||
if r.FormValue("parentid") != "" {
|
||||
if r.FormValue("parentid") != "" && r.FormValue("parentid") != "0" {
|
||||
parentid, _ := strconv.Atoi(r.FormValue("parentid"))
|
||||
state.GetComment(parentid)
|
||||
}
|
||||
|
@ -1428,6 +1428,13 @@ func UserOp(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
|||
if err != nil {
|
||||
fmt.Println(err)
|
||||
} 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)
|
||||
r.URL.Fragment = "c" + commentid
|
||||
r.URL.RawQuery = ""
|
||||
|
|
|
@ -61,14 +61,16 @@
|
|||
{{ if .State.Session }}
|
||||
{{ 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>
|
||||
{{ if not .P.Comment.Deleted }}
|
||||
<li>
|
||||
<form class="delete" method="POST">
|
||||
<input type="hidden" name="commentid" value="{{.P.Comment.ID}}">
|
||||
<input type="hidden" name="op" value="delete_comment">
|
||||
<input type="submit" value="delete">
|
||||
<input type="submit" name="submit" value="delete">
|
||||
</form>
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
<li>
|
||||
<form class="link-btn" method="POST">
|
||||
<input type="hidden" name="commentid" value="{{.P.Comment.ID}}">
|
||||
|
|
Loading…
Reference in a new issue