fdfd
This commit is contained in:
parent
a82158404d
commit
0ee2aea149
3 changed files with 219 additions and 177 deletions
|
@ -200,9 +200,11 @@ def messagereply(v, username, id):
|
|||
|
||||
cache.delete_memoized(User.notification_messages, user)
|
||||
|
||||
if not request.referrer or request.referrer.endswith('/notifications'): return redirect(f"/notifications?all=true#comment-{id}")
|
||||
else: return redirect(f"{request.referrer}#comment-{id}")
|
||||
|
||||
return jsonify({"html": render_template("comments.html",
|
||||
v=v,
|
||||
comments=[c],
|
||||
render_replies=False,
|
||||
)})
|
||||
|
||||
@app.get("/2faqr/<secret>")
|
||||
@auth_required
|
||||
|
|
|
@ -168,25 +168,35 @@
|
|||
{% if not c.parent_submission and c.author_id!=NOTIFICATIONS_ACCOUNT and c.author_id!=AUTOJANNY_ACCOUNT and c.author_id!=v.id %}
|
||||
<a class="btn btn-primary" href="javascript:void(0)" onclick="document.getElementById('reply-to-{{c.id}}').classList.toggle('d-none')">Reply</a>
|
||||
<pre></pre>
|
||||
<form class="d-none" id="reply-to-{{c.id}}" action="/@{{c.author.username}}/reply/{{c.id}}" method="post">
|
||||
<textarea id="input-message-{{c.id}}" form="reply-to-{{c.id}}" maxlength="1000" name="message" rows="3" class="form-control" required></textarea>
|
||||
<pre></pre>
|
||||
<pre class="btn btn-secondary format d-inline-block m-0 fas fa-bold" aria-hidden="true" onclick="makeBold('input-message-{{c.id}}')" data-toggle="tooltip" data-placement="bottom" title="Bold"></pre>
|
||||
|
||||
<form class="d-none" id="reply-to-{{c.id}}" action="/@{{c.author.username}}/reply/{{c.id}}" method="post" class="input-group" enctype="multipart/form-data">
|
||||
<input type="hidden" name="formkey" value="{{v.formkey}}">
|
||||
<input type="hidden" name="parent_fullname" value="{{c.fullname}}">
|
||||
<textarea name="body" form="reply-to-t3_{{c.id}}" class="comment-box form-control rounded" id="reply-form-body-{{c.fullname}}" aria-label="With textarea" rows="3"></textarea>
|
||||
<div class="comment-format" id="comment-format-bar-{{c.id}}">
|
||||
<label class="btn btn-secondary format d-inline-block m-0" for="gif-reply-btn-{{c.fullname}}">
|
||||
<span id="gif-reply-btn-{{c.fullname}}" class="font-weight-bolder text-uppercase" onclick="commentForm('reply-form-body-{{c.fullname}}');getGif()" aria-hidden="true" data-toggle="modal" data-target="#gifModal" data-toggle="tooltip" data-placement="bottom" title="Add GIF">GIF</span>
|
||||
</label>
|
||||
|
||||
<pre class="btn btn-secondary format d-inline-block m-0 fas fa-italic" aria-hidden="true" onclick="makeItalics('input-message-{{c.id}}')" data-toggle="tooltip" data-placement="bottom" title="Italicize"></pre>
|
||||
<label class="btn btn-secondary format d-inline-block m-0" for="gif-reply-btn-{{c.fullname}}">
|
||||
<i id="emoji-reply-btn-{{c.fullname}}" class="fas fa-smile-beam" onclick="loadEmojis('reply-form-body-{{c.fullname}}')" aria-hidden="true" data-toggle="modal" data-target="#emojiModal" data-toggle="tooltip" data-placement="bottom" title="Add Emoji"></i>
|
||||
</label>
|
||||
|
||||
<pre class="btn btn-secondary format d-inline-block m-0 fas fa-quote-right" aria-hidden="true" onclick="makeQuote('input-message-{{c.id}}')" data-toggle="tooltip" data-placement="bottom" title="Quote"></pre>
|
||||
|
||||
<pre style="line-height:1;" class="btn btn-secondary format d-inline-block m-0 font-weight-bolder text-uppercase" onclick="commentForm('input-message-{{c.id}}');getGif()" aria-hidden="true" data-toggle="modal" data-target="#gifModal" data-toggle="tooltip" data-placement="bottom" title="Add GIF">GIF</pre>
|
||||
|
||||
<pre class="btn btn-secondary format d-inline-block m-0 fas fa-smile-beam" onclick="loadEmojis('input-message-{{c.id}}')" aria-hidden="true" data-toggle="modal" data-target="#emojiModal" data-toggle="tooltip" data-placement="bottom" title="Add Emoji"></pre>
|
||||
|
||||
<input type="submit" value="Submit" class="btn btn-primary mt-3">
|
||||
<label class="btn btn-secondary format d-inline-block m-0" for="file-upload-reply-{{c.fullname}}">
|
||||
<div id="filename-show-reply-{{c.id}}"><i class="far fa-image"></i></div>
|
||||
<input id="file-upload-reply-{{c.fullname}}" type="file" name="file" accept="image/*" onchange="document.getElementById('filename-show-reply-{{c.id}}').innerHTML='image';" hidden>
|
||||
</label>
|
||||
<a href="javascript:void(0)" onclick="document.getElementById('reply-to-{{c.id}}').classList.add('d-none')" class="d-none d-md-block btn btn-link text-muted ml-auto cancel-form">Cancel</a>
|
||||
<a id="save-reply-to-{{c.fullname}}" class="d-none d-md-block btn btn-primary text-white ml-2" onclick="post_reply('{{c.fullname}}');" href="javascript:void(0)">Reply</a>
|
||||
</div>
|
||||
<a href="javascript:void(0)" onclick="document.getElementById('reply-to-{{c.id}}').classList.add('d-none')" class="d-block d-md-none btn btn-link text-muted ml-auto cancel-form">Cancel</a>
|
||||
<a id="save-reply-to-{{c.fullname}}" class="d-block d-md-none btn btn-primary text-white ml-2" onclick="post_reply('{{c.fullname}}');" href="javascript:void(0)">Reply</a>
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if c.parent_submission %}
|
||||
|
||||
{% if v and v.id==c.author_id %}
|
||||
<div id="comment-edit-{{c.id}}" class="d-none comment-write collapsed child">
|
||||
<form id="comment-edit-form-{{c.id}}" action="/edit_comment/{{c.id}}" method="post" class="input-group" enctype="multipart/form-data">
|
||||
|
@ -262,8 +272,7 @@
|
|||
{% endif %}
|
||||
|
||||
{% if v %}
|
||||
<li class="list-inline-item text-muted"><a href="javascript:void(0)" onclick="document.getElementById('reply-to-{{c.id}}').classList.remove('d-none')"><i class="fas fa-reply"
|
||||
aria-hidden="true"></i><span class="d-none d-md-inline-block">Reply</span></a></li>
|
||||
<li class="list-inline-item text-muted"><a href="javascript:void(0)" onclick="document.getElementById('reply-to-{{c.id}}').classList.remove('d-none')"><i class="fas fa-reply" aria-hidden="true"></i><span class="d-none d-md-inline-block">Reply</span></a></li>
|
||||
|
||||
{% if v.id!=c.author_id %}
|
||||
<li class="list-inline-item text-muted"><a href="javascript:void(0)" data-toggle="modal" data-target="#awardModal" onclick="awardModal('/comment/{{c.id}}/awards')"><i class="fas fa-gift"
|
||||
|
@ -353,7 +362,6 @@
|
|||
{% endif %}
|
||||
</div>
|
||||
|
||||
|
||||
<div id="reply-to-{{c.id}}" class="d-none">
|
||||
<div id="comment-form-space-{{c.fullname}}" class="comment-write collapsed child">
|
||||
<form id="reply-to-t3_{{c.id}}" action="/comment" method="post" class="input-group" enctype="multipart/form-data">
|
||||
|
@ -403,7 +411,6 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
|
|
@ -519,6 +519,39 @@
|
|||
|
||||
}
|
||||
|
||||
post_reply=function(fullname){
|
||||
|
||||
var form = new FormData();
|
||||
|
||||
form.append('formkey', formkey());
|
||||
form.append('parent_fullname', fullname);
|
||||
form.append('body', document.getElementById('reply-form-body-'+fullname).value);
|
||||
form.append('file', document.getElementById('file-upload-reply-'+fullname).files[0]);
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("post", "/comment");
|
||||
xhr.withCredentials=true;
|
||||
xhr.onload=function(){
|
||||
if (xhr.status==200) {
|
||||
commentForm=document.getElementById('comment-form-space-'+fullname);
|
||||
commentForm.innerHTML=JSON.parse(xhr.response)["html"];
|
||||
$('#toast-comment-success').toast('dispose');
|
||||
$('#toast-comment-error').toast('dispose');
|
||||
$('#toast-comment-success').toast('show');
|
||||
}
|
||||
else {
|
||||
var commentError = document.getElementById("comment-error-text");
|
||||
$('#toast-comment-success').toast('dispose');
|
||||
$('#toast-comment-error').toast('dispose');
|
||||
$('#toast-comment-error').toast('show');
|
||||
commentError.textContent = JSON.parse(xhr.response)["error"];
|
||||
}
|
||||
}
|
||||
xhr.send(form)
|
||||
|
||||
document.getElementById('save-reply-to-'+fullname).classList.add('disabled');
|
||||
|
||||
}
|
||||
|
||||
herald_comment=function(cid){
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue