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) {
url="/ban_comment/"+post_id
callback=function(){
post(url)
try {
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");
}
button=document.getElementById("remove-"+post_id);
var button=document.getElementById("remove-"+post_id);
button.onclick=function(){approveComment(post_id)};
button.innerHTML='<i class="fas fa-clipboard-check"></i>Approve'
}
post(url, callback, "Comment has been removed.")
if (typeof button1 !== 'undefined') {
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) {
url="/unban_comment/"+post_id
callback=function(){
post(url)
try {
document.getElementById("comment-"+post_id+"-only").classList.remove("banned");
} catch(e) {
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.innerHTML='<i class="fas fa-trash-alt"></i>Remove'
}
post(url, callback, "Comment has been approved.")
if (typeof button1 !== 'undefined') {
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) {
url="/ban_comment/"+post_id
callback=function(){
document.getElementById("comment-"+post_id+"-only").classList.add("banned");
post(url)
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.innerHTML='<i class="fas fa-clipboard-check"></i>Approve'
}
post(url, callback, "Comment has been removed.")
if (typeof button1 !== 'undefined') {
document.getElementById(button1).classList.toggle("d-none");
@ -66,15 +60,12 @@ function removeComment2(post_id,button1,button2) {
function approveComment2(post_id,button1,button2) {
url="/unban_comment/"+post_id
callback=function(){
document.getElementById("comment-"+post_id+"-only").classList.remove("banned");
post(url)
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.innerHTML='<i class="fas fa-trash-alt"></i>Remove'
}
post(url, callback, "Comment has been approved.")
if (typeof button1 !== 'undefined') {
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.disabled = true;
post('/delete/comment/' + id,
callback = function() {
post('/delete/comment/' + id)
location.reload();
}
)
}
};

View file

@ -1,18 +1,11 @@
function post(url, callback, errortext) {
function post(url) {
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);
window.location.reload(true)
};
function updatebgselection(){
@ -74,7 +67,7 @@ function updatebgselection(){
let bgsDir = backgrounds[bgselector.selectedIndex].folder;
for (i=0; i < bgsToDisplay.length; 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;
}

View file

@ -33,14 +33,14 @@
{% if v %}
{% 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 %}
<script src="https://cdn.jsdelivr.net/npm/clipboard@2.0.8/dist/clipboard.min.js"></script>
{% 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 %}
<script>

View file

@ -1,28 +1,18 @@
<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_post(){
this.innerHTML='<span class="spinner-border spinner-border-sm mr-2" role="status" aria-hidden="true"></span>Deleting post';
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();
}

View file

@ -6,7 +6,7 @@
{% include "emoji_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">

View file

@ -45,7 +45,7 @@
{% if 'rdrama' not in request.host %}
{% 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 "emoji_modal.html" %}
{% include "gif_modal.html" %}