This commit is contained in:
Aevann1 2021-10-06 01:41:55 +02:00
parent ade27e2ad6
commit 9b18e87e92
7 changed files with 44 additions and 74 deletions

View file

@ -1,7 +1,7 @@
function removeComment(post_id,button1,button2) { function removeComment(post_id,button1,button2) {
url="/ban_comment/"+post_id url="/ban_comment/"+post_id
callback=function(){ post(url)
try { try {
document.getElementById("comment-"+post_id+"-only").classList.add("banned"); document.getElementById("comment-"+post_id+"-only").classList.add("banned");
@ -9,11 +9,9 @@ function removeComment(post_id,button1,button2) {
document.getElementById("context").classList.add("banned"); document.getElementById("context").classList.add("banned");
} }
button=document.getElementById("remove-"+post_id); var button=document.getElementById("remove-"+post_id);
button.onclick=function(){approveComment(post_id)}; button.onclick=function(){approveComment(post_id)};
button.innerHTML='<i class="fas fa-clipboard-check"></i>Approve' button.innerHTML='<i class="fas fa-clipboard-check"></i>Approve'
}
post(url, callback, "Comment has been removed.")
if (typeof button1 !== 'undefined') { if (typeof button1 !== 'undefined') {
document.getElementById(button1).classList.toggle("d-md-inline-block"); document.getElementById(button1).classList.toggle("d-md-inline-block");
@ -24,19 +22,17 @@ function removeComment(post_id,button1,button2) {
function approveComment(post_id,button1,button2) { function approveComment(post_id,button1,button2) {
url="/unban_comment/"+post_id url="/unban_comment/"+post_id
callback=function(){ post(url)
try { try {
document.getElementById("comment-"+post_id+"-only").classList.remove("banned"); document.getElementById("comment-"+post_id+"-only").classList.remove("banned");
} catch(e) { } catch(e) {
document.getElementById("context").classList.remove("banned"); document.getElementById("context").classList.remove("banned");
} }
button=document.getElementById("remove-"+post_id); var button=document.getElementById("remove-"+post_id);
button.onclick=function(){removeComment(post_id)}; button.onclick=function(){removeComment(post_id)};
button.innerHTML='<i class="fas fa-trash-alt"></i>Remove' button.innerHTML='<i class="fas fa-trash-alt"></i>Remove'
}
post(url, callback, "Comment has been approved.")
if (typeof button1 !== 'undefined') { if (typeof button1 !== 'undefined') {
document.getElementById(button1).classList.toggle("d-md-inline-block"); document.getElementById(button1).classList.toggle("d-md-inline-block");
@ -48,14 +44,12 @@ function approveComment(post_id,button1,button2) {
function removeComment2(post_id,button1,button2) { function removeComment2(post_id,button1,button2) {
url="/ban_comment/"+post_id url="/ban_comment/"+post_id
callback=function(){ post(url)
document.getElementById("comment-"+post_id+"-only").classList.add("banned");
button=document.getElementById("remove-"+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(){approveComment(post_id)};
button.innerHTML='<i class="fas fa-clipboard-check"></i>Approve' button.innerHTML='<i class="fas fa-clipboard-check"></i>Approve'
}
post(url, callback, "Comment has been removed.")
if (typeof button1 !== 'undefined') { if (typeof button1 !== 'undefined') {
document.getElementById(button1).classList.toggle("d-none"); document.getElementById(button1).classList.toggle("d-none");
@ -66,15 +60,12 @@ function removeComment2(post_id,button1,button2) {
function approveComment2(post_id,button1,button2) { function approveComment2(post_id,button1,button2) {
url="/unban_comment/"+post_id url="/unban_comment/"+post_id
callback=function(){ post(url)
document.getElementById("comment-"+post_id+"-only").classList.remove("banned");
button=document.getElementById("remove-"+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(){removeComment(post_id)};
button.innerHTML='<i class="fas fa-trash-alt"></i>Remove' button.innerHTML='<i class="fas fa-trash-alt"></i>Remove'
}
post(url, callback, "Comment has been approved.")
if (typeof button1 !== 'undefined') { if (typeof button1 !== 'undefined') {
document.getElementById(button1).classList.toggle("d-none"); document.getElementById(button1).classList.toggle("d-none");

View file

@ -109,13 +109,9 @@ function delete_commentModal(id) {
this.innerHTML='<span class="spinner-border spinner-border-sm mr-2" role="status" aria-hidden="true"></span>Deleting comment'; this.innerHTML='<span class="spinner-border spinner-border-sm mr-2" role="status" aria-hidden="true"></span>Deleting comment';
this.disabled = true; this.disabled = true;
post('/delete/comment/' + id, post('/delete/comment/' + id)
callback = function() {
location.reload(); location.reload();
} }
)
}
}; };

View file

@ -1,18 +1,11 @@
function post(url, callback, errortext) { function post(url) {
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.open("POST", url, true); xhr.open("POST", url, true);
var form = new FormData() var form = new FormData()
form.append("formkey", formkey()); form.append("formkey", formkey());
xhr.withCredentials=true; xhr.withCredentials=true;
xhr.onerror=function() { alert(errortext); };
xhr.onload = function() {
if (xhr.status >= 200 && xhr.status < 300) {
callback();
} else {
xhr.onerror();
}
};
xhr.send(form); xhr.send(form);
window.location.reload(true)
}; };
function updatebgselection(){ function updatebgselection(){
@ -74,7 +67,7 @@ function updatebgselection(){
let bgsDir = backgrounds[bgselector.selectedIndex].folder; let bgsDir = backgrounds[bgselector.selectedIndex].folder;
for (i=0; i < bgsToDisplay.length; i++) { for (i=0; i < bgsToDisplay.length; i++) {
let onclickPost = bgsDir + "/" + bgsToDisplay[i]; let onclickPost = bgsDir + "/" + bgsToDisplay[i];
str += `<button class="btn btn-secondary m-1 p-0" style="width:15rem; overflow: hidden;"><img loading="lazy" style="padding:0.25rem; width: 15rem" src="/assets/images/backgrounds/${bgsDir}/${bgsToDisplay[i]}" alt="${bgsToDisplay[i]}-background" onclick="post('/settings/profile?background=${onclickPost}', function(){window.location.reload(true);})"/></button>`; str += `<button class="btn btn-secondary m-1 p-0" style="width:15rem; overflow: hidden;"><img loading="lazy" style="padding:0.25rem; width: 15rem" src="/assets/images/backgrounds/${bgsDir}/${bgsToDisplay[i]}" alt="${bgsToDisplay[i]}-background" onclick="post('/settings/profile?background=${onclickPost}')"/></button>`;
} }
bgContainer.innerHTML = str; bgContainer.innerHTML = str;
} }

View file

@ -33,14 +33,14 @@
{% if v %} {% if v %}
{% include "award_modal.html" %} {% include "award_modal.html" %}
<script src="/assets/js/comments_v.js?v=10"></script> <script src="/assets/js/comments_v.js?v=11"></script>
{% endif %} {% endif %}
<script src="https://cdn.jsdelivr.net/npm/clipboard@2.0.8/dist/clipboard.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/clipboard@2.0.8/dist/clipboard.min.js"></script>
{% if v and v.admin_level == 6 %} {% if v and v.admin_level == 6 %}
<script src="/assets/js/comments_admin.js?v=1"></script> <script src="/assets/js/comments_admin.js?v=2"></script>
{% endif %} {% endif %}
<script> <script>

View file

@ -1,28 +1,18 @@
<script> <script>
function post(url, callback, errortext) {
var xhr = new XMLHttpRequest();
xhr.open("POST", url, true);
var form = new FormData()
form.append("formkey", formkey());
xhr.withCredentials=true;
xhr.onerror=function() { alert(errortext); };
xhr.onload = function() {
if (xhr.status >= 200 && xhr.status < 300) {
callback();
} else {
xhr.onerror();
}
};
xhr.send(form);
};
function delete_postModal(id) { function delete_postModal(id) {
function delete_post(){ function delete_post(){
this.innerHTML='<span class="spinner-border spinner-border-sm mr-2" role="status" aria-hidden="true"></span>Deleting post'; this.innerHTML='<span class="spinner-border spinner-border-sm mr-2" role="status" aria-hidden="true"></span>Deleting post';
this.disabled = true; this.disabled = true;
post('/delete_post/' + id);
var url = '/delete_post/' + id
var xhr = new XMLHttpRequest();
xhr.open("POST", url, true);
var form = new FormData()
form.append("formkey", formkey());
xhr.withCredentials=true;
xhr.send(form);
location.reload(); location.reload();
} }

View file

@ -6,7 +6,7 @@
{% include "emoji_modal.html" %} {% include "emoji_modal.html" %}
{% include "gif_modal.html" %} {% include "gif_modal.html" %}
<script src="/assets/js/setting_profile.js?v=1"></script> <script src="/assets/js/settings_profile.js?v=2"></script>
<div id="posts" class="row"> <div id="posts" class="row">

View file

@ -45,7 +45,7 @@
{% if 'rdrama' not in request.host %} {% if 'rdrama' not in request.host %}
{% if v %} {% if v %}
<script src="/assets/js/comments_v.js?v=10"></script> <script src="/assets/js/comments_v.js?v=11"></script>
{% include "award_modal.html" %} {% include "award_modal.html" %}
{% include "emoji_modal.html" %} {% include "emoji_modal.html" %}
{% include "gif_modal.html" %} {% include "gif_modal.html" %}