fg
This commit is contained in:
parent
95f8dec3a9
commit
4096f36acb
2 changed files with 19 additions and 113 deletions
|
@ -846,10 +846,10 @@ def undelete_comment(cid, v):
|
||||||
return {"message": "Comment undeleted!"}
|
return {"message": "Comment undeleted!"}
|
||||||
|
|
||||||
|
|
||||||
@app.post("/comment_pin/<cid>")
|
@app.post("/pin_comment/<cid>")
|
||||||
@auth_required
|
@auth_required
|
||||||
@validate_formkey
|
@validate_formkey
|
||||||
def toggle_comment_pin(cid, v):
|
def toggle_pin_comment(cid, v):
|
||||||
|
|
||||||
comment = get_comment(cid, v=v)
|
comment = get_comment(cid, v=v)
|
||||||
|
|
||||||
|
|
|
@ -32,24 +32,18 @@
|
||||||
} else if (xhr.status >= 300 && xhr.status < 400) {
|
} else if (xhr.status >= 300 && xhr.status < 400) {
|
||||||
window.location.href = JSON.parse(xhr.response)["redirect"]
|
window.location.href = JSON.parse(xhr.response)["redirect"]
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
data=JSON.parse(xhr.response);
|
data=JSON.parse(xhr.response);
|
||||||
|
} catch(e) {}
|
||||||
|
|
||||||
var myToast = new bootstrap.Toast(document.getElementById('toast-post-error'));
|
var myToast = new bootstrap.Toast(document.getElementById('toast-post-success'));
|
||||||
myToast.hide();
|
myToast.hide();
|
||||||
myToast.show();
|
var myToast = new bootstrap.Toast(document.getElementById('toast-post-error'));
|
||||||
document.getElementById('toast-post-error-text').innerText = data["error"];
|
myToast.hide();
|
||||||
return false
|
myToast.show();
|
||||||
} catch(e) {
|
document.getElementById('toast-post-error-text').innerText = "Error. Try again later.";
|
||||||
var myToast = new bootstrap.Toast(document.getElementById('toast-post-success'));
|
return false
|
||||||
myToast.hide();
|
|
||||||
|
|
||||||
var myToast = new bootstrap.Toast(document.getElementById('toast-post-error'));
|
|
||||||
myToast.hide();
|
|
||||||
myToast.show();
|
|
||||||
document.getElementById('toast-post-error-text').innerText = "Error. Try again later.";
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -350,93 +344,6 @@
|
||||||
document.getElementById(button2).classList.toggle("d-none");
|
document.getElementById(button2).classList.toggle("d-none");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
admin_comment=function(cid,button1,button2,distinguish){
|
|
||||||
|
|
||||||
|
|
||||||
var xhr = new XMLHttpRequest();
|
|
||||||
xhr.open("post", "/distinguish_comment/"+cid);
|
|
||||||
|
|
||||||
var form = new FormData();
|
|
||||||
|
|
||||||
form.append('formkey', formkey());
|
|
||||||
|
|
||||||
xhr.withCredentials=true;
|
|
||||||
xhr.onload=function(){
|
|
||||||
if (xhr.status==200) {
|
|
||||||
comment=document.getElementById('comment-'+cid+'-only');
|
|
||||||
comment.innerHTML=JSON.parse(xhr.response)["html"];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
var commentError = document.getElementById("comment-error-text");
|
|
||||||
var myToast = new bootstrap.Toast(document.getElementById('toast-post-success'));
|
|
||||||
myToast.hide();
|
|
||||||
var myToast = new bootstrap.Toast(document.getElementById('toast-post-error'));
|
|
||||||
myToast.hide();
|
|
||||||
myToast.show();
|
|
||||||
|
|
||||||
commentError.textContent = JSON.parse(xhr.response)["error"];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
xhr.send(form)
|
|
||||||
|
|
||||||
document.getElementById(button1).classList.toggle("d-md-inline-block");
|
|
||||||
document.getElementById(button2).classList.toggle("d-md-inline-block");
|
|
||||||
|
|
||||||
var myToast = new bootstrap.Toast(document.getElementById('toast-post-success'));
|
|
||||||
myToast.hide();
|
|
||||||
myToast.show();
|
|
||||||
|
|
||||||
if (distinguish=='yes') {
|
|
||||||
document.getElementById('toast-post-success-text').innerText = "Comment distinguished!";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
document.getElementById('toast-post-success-text').innerText = "Comment undistinguished!";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
admin_comment2=function(cid,button1,button2,distinguish){
|
|
||||||
var xhr = new XMLHttpRequest();
|
|
||||||
xhr.open("post", "/distinguish_comment/"+cid);
|
|
||||||
|
|
||||||
var form = new FormData();
|
|
||||||
|
|
||||||
form.append('formkey', formkey());
|
|
||||||
|
|
||||||
xhr.withCredentials=true;
|
|
||||||
xhr.onload=function(){
|
|
||||||
if (xhr.status==200) {
|
|
||||||
comment=document.getElementById('comment-'+cid+'-only');
|
|
||||||
comment.innerHTML=JSON.parse(xhr.response)["html"];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
var commentError = document.getElementById("comment-error-text");
|
|
||||||
var myToast = new bootstrap.Toast(document.getElementById('toast-post-success'));
|
|
||||||
myToast.hide();
|
|
||||||
var myToast = new bootstrap.Toast(document.getElementById('toast-post-error'));
|
|
||||||
myToast.hide();
|
|
||||||
myToast.show();
|
|
||||||
|
|
||||||
commentError.textContent = JSON.parse(xhr.response)["error"];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
xhr.send(form)
|
|
||||||
|
|
||||||
document.getElementById(button1).classList.toggle("d-none");
|
|
||||||
document.getElementById(button2).classList.toggle("d-none");
|
|
||||||
|
|
||||||
var myToast = new bootstrap.Toast(document.getElementById('toast-post-success'));
|
|
||||||
myToast.hide();
|
|
||||||
myToast.show();
|
|
||||||
if (distinguish=='yes') {
|
|
||||||
document.getElementById('toast-post-success-text').innerText = "Comment distinguished!";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
document.getElementById('toast-post-success-text').innerText = "Comment undistinguished!";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
@ -768,10 +675,9 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if v and v.admin_level==6 and v.id==c.author_id %}
|
{% if v and v.admin_level==6 and v.id==c.author_id %}
|
||||||
<li id="undistinguish-{{c.id}}" class="list-inline-item d-none {% if c.distinguish_level %}d-md-inline-block{% endif %}"><a class="text-info" href="javascript:void(0)" onclick="admin_comment('{{c.id}}','distinguish-{{c.id}}','undistinguish-{{c.id}}','no')"><i class="fas fa-id-badge text-info fa-fw"></i>Undistinguish</a></li>
|
<li id="undistinguish-{{c.id}}" class="list-inline-item d-none {% if c.distinguish_level %}d-md-inline-block{% endif %}"><a class="text-info" href="javascript:void(0)" onclick="post_toast3('/unsave_comment/{{c.id}}','distinguish-{{c.id}}','undistinguish-{{c.id}}','no')"><i class="fas fa-id-badge text-info fa-fw"></i>Undistinguish</a></li>
|
||||||
<li id="distinguish-{{c.id}}" class="list-inline-item d-none {% if not c.distinguish_level %}d-md-inline-block{% endif %}"><a class="text-info" href="javascript:void(0)" onclick="admin_comment('{{c.id}}','distinguish-{{c.id}}','undistinguish-{{c.id}}','yes')"><i class="fas fa-id-badge text-info fa-fw"></i>Distinguish</a></li>
|
<li id="distinguish-{{c.id}}" class="list-inline-item d-none {% if not c.distinguish_level %}d-md-inline-block{% endif %}"><a class="text-info" href="javascript:void(0)" onclick="post_toast3('/unsave_comment/{{c.id}}','distinguish-{{c.id}}','undistinguish-{{c.id}}','yes')"><i class="fas fa-id-badge text-info fa-fw"></i>Distinguish</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
@ -781,9 +687,9 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if v and c.post and (v.admin_level >= 1 or v.id == c.post.author_id) and c.level == 1 %}
|
{% if v and c.post and (v.admin_level >= 1 or v.id == c.post.author_id) and c.level == 1 %}
|
||||||
<li id="unpin-{{c.id}}" class="{% if c.is_pinned %}d-md-inline-block{% endif %} list-inline-item text-muted d-none"><a class="text-info" href="javascript:void(0)" data-bs-dismiss="modal" data-bs-target="#actionsModal-{{c.id}}" onclick="post_toast3('/comment_pin/{{c.id}}','pin-{{c.id}}','unpin-{{c.id}}')"><i class="fas fa-thumbtack fa-rotate--45 text-info fa-fw"></i>Unpin</a></li>
|
<li id="unpin-{{c.id}}" class="{% if c.is_pinned %}d-md-inline-block{% endif %} list-inline-item text-muted d-none"><a class="text-info" href="javascript:void(0)" data-bs-dismiss="modal" data-bs-target="#actionsModal-{{c.id}}" onclick="post_toast3('/pin_comment/{{c.id}}','pin-{{c.id}}','unpin-{{c.id}}')"><i class="fas fa-thumbtack fa-rotate--45 text-info fa-fw"></i>Unpin</a></li>
|
||||||
|
|
||||||
<li id="pin-{{c.id}}" class="{% if not c.is_pinned %}d-md-inline-block{% endif %} list-inline-item text-muted d-none"><a class="text-info" href="javascript:void(0)" data-bs-dismiss="modal" data-bs-target="#actionsModal-{{c.id}}" onclick="post_toast3('/comment_pin/{{c.id}}','pin-{{c.id}}','unpin-{{c.id}}')"><i class="fas fa-thumbtack fa-rotate--45 text-info fa-fw"></i>Pin</a></li>
|
<li id="pin-{{c.id}}" class="{% if not c.is_pinned %}d-md-inline-block{% endif %} list-inline-item text-muted d-none"><a class="text-info" href="javascript:void(0)" data-bs-dismiss="modal" data-bs-target="#actionsModal-{{c.id}}" onclick="post_toast3('/pin_comment/{{c.id}}','pin-{{c.id}}','unpin-{{c.id}}')"><i class="fas fa-thumbtack fa-rotate--45 text-info fa-fw"></i>Pin</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
@ -925,14 +831,14 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if v and c.post and (v.admin_level >= 1 or v.id == c.post.author_id) and c.level == 1 %}
|
{% if v and c.post and (v.admin_level >= 1 or v.id == c.post.author_id) and c.level == 1 %}
|
||||||
<li id="pin2-{{c.id}}" class="list-group-item {% if c.is_pinned %}d-none{% endif %} text-info" href="javascript:void(0)" data-bs-target="#actionsModal-{{c.id}}" onclick="post_toast2('/comment_pin/{{c.id}}','pin2-{{c.id}}','unpin2-{{c.id}}')" data-bs-dismiss="modal"><i class="fas fa-thumbtack fa-rotate--45 text-info"></i>Pin</li>
|
<li id="pin2-{{c.id}}" class="list-group-item {% if c.is_pinned %}d-none{% endif %} text-info" href="javascript:void(0)" data-bs-target="#actionsModal-{{c.id}}" onclick="post_toast2('/pin_comment/{{c.id}}','pin2-{{c.id}}','unpin2-{{c.id}}')" data-bs-dismiss="modal"><i class="fas fa-thumbtack fa-rotate--45 text-info"></i>Pin</li>
|
||||||
<li id="unpin2-{{c.id}}" class="list-group-item {% if not c.is_pinned %}d-none{% endif %} text-info" href="javascript:void(0)" data-bs-target="#actionsModal-{{c.id}}" onclick="post_toast2('/comment_pin/{{c.id}}','pin2-{{c.id}}','unpin2-{{c.id}}')" data-bs-dismiss="modal"><i class="fas fa-thumbtack fa-rotate--45 text-info"></i>Unpin</li>
|
<li id="unpin2-{{c.id}}" class="list-group-item {% if not c.is_pinned %}d-none{% endif %} text-info" href="javascript:void(0)" data-bs-target="#actionsModal-{{c.id}}" onclick="post_toast2('/pin_comment/{{c.id}}','pin2-{{c.id}}','unpin2-{{c.id}}')" data-bs-dismiss="modal"><i class="fas fa-thumbtack fa-rotate--45 text-info"></i>Unpin</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if v %}
|
{% if v %}
|
||||||
{% if v.admin_level>=1 and v.id==c.author_id %}
|
{% if v.admin_level>=1 and v.id==c.author_id %}
|
||||||
<li id="distinguish2-{{c.id}}" class="list-group-item {% if c.distinguish_level %}d-none{% endif %} text-info" href="javascript:void(0)" onclick="admin_comment2('{{c.id}}','distinguish2-{{c.id}}','undistinguish2-{{c.id}}')" data-bs-dismiss="modal"><i class="fas fa-id-badge text-info"></i>Distinguish</li>
|
<li id="distinguish2-{{c.id}}" class="list-group-item {% if c.distinguish_level %}d-none{% endif %} text-info" href="javascript:void(0)" onclick="post_toast2('/unsave_comment/{{c.id}}','distinguish2-{{c.id}}','undistinguish2-{{c.id}}')" data-bs-dismiss="modal"><i class="fas fa-id-badge text-info"></i>Distinguish</li>
|
||||||
<li id="undistinguish2-{{c.id}}" class="list-group-item {% if not c.distinguish_level %}d-none{% endif %} text-info" href="javascript:void(0)" onclick="admin_comment2('{{c.id}}','distinguish2-{{c.id}}','undistinguish2-{{c.id}}')" data-bs-dismiss="modal"><i class="fas fa-id-badge text-info"></i>Undistinguish</li>
|
<li id="undistinguish2-{{c.id}}" class="list-group-item {% if not c.distinguish_level %}d-none{% endif %} text-info" href="javascript:void(0)" onclick="post_toast2('/unsave_comment/{{c.id}}','distinguish2-{{c.id}}','undistinguish2-{{c.id}}')" data-bs-dismiss="modal"><i class="fas fa-id-badge text-info"></i>Undistinguish</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if v.admin_level>=3 %}
|
{% if v.admin_level>=3 %}
|
||||||
{% if "/reported/" in request.path %}
|
{% if "/reported/" in request.path %}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue