Clean up remove/approveCommentDesktop2 functions into something a little more comprehensible.
This commit is contained in:
parent
e9ca6e3239
commit
51ec2d7adf
3 changed files with 30 additions and 26 deletions
|
@ -1,7 +1,17 @@
|
|||
function removeComment(post_id,button1,button2) {
|
||||
function removeCommentBackend(post_id) {
|
||||
url="/ban_comment/"+post_id
|
||||
|
||||
post(url)
|
||||
}
|
||||
|
||||
function approveCommentBackend(post_id) {
|
||||
url="/unban_comment/"+post_id
|
||||
|
||||
post(url)
|
||||
}
|
||||
|
||||
function removeCommentDesktop(post_id,button1,button2) {
|
||||
removeCommentBackend(post_id)
|
||||
|
||||
try {
|
||||
document.getElementById("comment-"+post_id+"-only").classList.add("banned");
|
||||
|
@ -10,7 +20,7 @@ function removeComment(post_id,button1,button2) {
|
|||
}
|
||||
|
||||
var button=document.getElementById("remove-"+post_id);
|
||||
button.onclick=function(){approveComment(post_id)};
|
||||
button.onclick=function(){approveCommentDesktop(post_id)};
|
||||
button.innerHTML='<i class="fas fa-clipboard-check"></i>Approve'
|
||||
|
||||
if (typeof button1 !== 'undefined') {
|
||||
|
@ -19,19 +29,17 @@ function removeComment(post_id,button1,button2) {
|
|||
}
|
||||
};
|
||||
|
||||
function approveComment(post_id,button1,button2) {
|
||||
url="/unban_comment/"+post_id
|
||||
|
||||
post(url)
|
||||
function approveCommentDesktop(post_id,button1,button2) {
|
||||
approveCommentBackend(post_id)
|
||||
|
||||
try {
|
||||
document.getElementById("comment-"+post_id+"-only").classList.remove("banned");
|
||||
} catch(e) {
|
||||
document.getElementById("context").classList.remove("banned");
|
||||
}
|
||||
|
||||
|
||||
var button=document.getElementById("remove-"+post_id);
|
||||
button.onclick=function(){removeComment(post_id)};
|
||||
button.onclick=function(){removeCommentDesktop(post_id)};
|
||||
button.innerHTML='<i class="fas fa-trash-alt"></i>Remove'
|
||||
|
||||
if (typeof button1 !== 'undefined') {
|
||||
|
@ -41,14 +49,12 @@ function approveComment(post_id,button1,button2) {
|
|||
}
|
||||
|
||||
|
||||
function removeComment2(post_id,button1,button2) {
|
||||
url="/ban_comment/"+post_id
|
||||
|
||||
post(url)
|
||||
function removeCommentMobile(post_id,button1,button2) {
|
||||
removeCommentBackend(post_id)
|
||||
|
||||
document.getElementById("comment-"+post_id+"-only").classList.add("banned");
|
||||
var button=document.getElementById("remove-"+post_id);
|
||||
button.onclick=function(){approveComment(post_id)};
|
||||
button.onclick=function(){approveCommentMobile(post_id)};
|
||||
button.innerHTML='<i class="fas fa-clipboard-check"></i>Approve'
|
||||
|
||||
if (typeof button1 !== 'undefined') {
|
||||
|
@ -57,14 +63,12 @@ function removeComment2(post_id,button1,button2) {
|
|||
}
|
||||
};
|
||||
|
||||
function approveComment2(post_id,button1,button2) {
|
||||
url="/unban_comment/"+post_id
|
||||
|
||||
post(url)
|
||||
function approveCommentMobile(post_id,button1,button2) {
|
||||
approveCommentBackend(post_id)
|
||||
|
||||
document.getElementById("comment-"+post_id+"-only").classList.remove("banned");
|
||||
var button=document.getElementById("remove-"+post_id);
|
||||
button.onclick=function(){removeComment(post_id)};
|
||||
button.onclick=function(){removeCommentMobile(post_id)};
|
||||
button.innerHTML='<i class="fas fa-trash-alt"></i>Remove'
|
||||
|
||||
if (typeof button1 !== 'undefined') {
|
||||
|
|
|
@ -47,11 +47,11 @@
|
|||
|
||||
{% if v.admin_level >= 2 %}
|
||||
{% if "/reported/" in request.path %}
|
||||
<button class="dropdown-item list-inline-item text-success" onclick="approveComment('{{c.id}}')"><i class="fas fa-check text-success fa-fw"></i>Approve</button>
|
||||
<button class="dropdown-item list-inline-item text-danger" onclick="removeComment('{{c.id}}')"><i class="fas fa-ban text-danger fa-fw"></i>Remove</button>
|
||||
<button class="dropdown-item list-inline-item text-success" onclick="approveCommentDesktop('{{c.id}}')"><i class="fas fa-check text-success fa-fw"></i>Approve</button>
|
||||
<button class="dropdown-item list-inline-item text-danger" onclick="removeCommentDesktop('{{c.id}}')"><i class="fas fa-ban text-danger fa-fw"></i>Remove</button>
|
||||
{% else %}
|
||||
<button id="approve-{{c.id}}" class="dropdown-item list-inline-item d-none {% if c.is_banned %}d-md-block{% endif %} text-success" onclick="approveComment('{{c.id}}','approve-{{c.id}}','remove-{{c.id}}')"><i class="fas fa-check text-success fa-fw"></i>Approve</button>
|
||||
<button id="remove-{{c.id}}" class="dropdown-item list-inline-item d-none {% if not c.is_banned %}d-md-block{% endif %} text-danger" onclick="removeComment('{{c.id}}','approve-{{c.id}}','remove-{{c.id}}')"><i class="fas fa-ban text-danger fa-fw"></i>Remove</button>
|
||||
<button id="approve-{{c.id}}" class="dropdown-item list-inline-item d-none {% if c.is_banned %}d-md-block{% endif %} text-success" onclick="approveCommentDesktop('{{c.id}}','approve-{{c.id}}','remove-{{c.id}}')"><i class="fas fa-check text-success fa-fw"></i>Approve</button>
|
||||
<button id="remove-{{c.id}}" class="dropdown-item list-inline-item d-none {% if not c.is_banned %}d-md-block{% endif %} text-danger" onclick="removeCommentDesktop('{{c.id}}','approve-{{c.id}}','remove-{{c.id}}')"><i class="fas fa-ban text-danger fa-fw"></i>Remove</button>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
|
|
|
@ -28,11 +28,11 @@
|
|||
{% endif %}
|
||||
|
||||
{% if "/reported/" in request.path %}
|
||||
<a class="list-group-item text-danger" role="button" onclick="removeComment2('{{c.id}}')" data-bs-dismiss="modal"><i class="fas fa-ban text-danger mr-2"></i>Remove</a>
|
||||
<a class="list-group-item text-success" role="button" onclick="approveComment2('{{c.id}}')" data-bs-dismiss="modal"><i class="fas fa-check text-success mr-2"></i>Approve</a>
|
||||
<a class="list-group-item text-danger" role="button" onclick="removeCommentMobile('{{c.id}}')" data-bs-dismiss="modal"><i class="fas fa-ban text-danger mr-2"></i>Remove</a>
|
||||
<a class="list-group-item text-success" role="button" onclick="approveCommentMobile('{{c.id}}')" data-bs-dismiss="modal"><i class="fas fa-check text-success mr-2"></i>Approve</a>
|
||||
{% else %}
|
||||
<a id="remove2-{{c.id}}" class="{% if c.is_banned %}d-none{% endif %} list-group-item text-danger" role="button" onclick="removeComment2('{{c.id}}','approve2-{{c.id}}','remove2-{{c.id}}')" data-bs-dismiss="modal"><i class="fas fa-ban text-danger mr-2"></i>Remove</a>
|
||||
<a id="approve2-{{c.id}}" class="{% if not c.is_banned %}d-none{% endif %} list-group-item text-success" role="button" onclick="approveComment2('{{c.id}}','approve2-{{c.id}}','remove2-{{c.id}}')" data-bs-dismiss="modal"><i class="fas fa-check text-success mr-2"></i>Approve</a>
|
||||
<a id="remove2-{{c.id}}" class="{% if c.is_banned %}d-none{% endif %} list-group-item text-danger" role="button" onclick="removeCommentMobile('{{c.id}}','approve2-{{c.id}}','remove2-{{c.id}}')" data-bs-dismiss="modal"><i class="fas fa-ban text-danger mr-2"></i>Remove</a>
|
||||
<a id="approve2-{{c.id}}" class="{% if not c.is_banned %}d-none{% endif %} list-group-item text-success" role="button" onclick="approveCommentMobile('{{c.id}}','approve2-{{c.id}}','remove2-{{c.id}}')" data-bs-dismiss="modal"><i class="fas fa-check text-success mr-2"></i>Approve</a>
|
||||
{% endif %}
|
||||
|
||||
{% if c.oauth_app %}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue