gfd
This commit is contained in:
parent
573c945d44
commit
6e9bdd7ef1
6 changed files with 60 additions and 48 deletions
Binary file not shown.
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 19 KiB |
Binary file not shown.
Before Width: | Height: | Size: 19 KiB |
|
@ -113,23 +113,33 @@ function toggleEdit(id){
|
||||||
|
|
||||||
|
|
||||||
function delete_commentModal(id) {
|
function delete_commentModal(id) {
|
||||||
|
|
||||||
document.getElementById("deleteCommentButton").onclick = function() {
|
document.getElementById("deleteCommentButton").onclick = function() {
|
||||||
|
|
||||||
this.innerHTML='Deleting comment';
|
|
||||||
this.disabled = true;
|
|
||||||
|
|
||||||
var url = '/delete/comment/' + id
|
|
||||||
const xhr = new XMLHttpRequest();
|
const xhr = new XMLHttpRequest();
|
||||||
xhr.open("POST", url);
|
xhr.open("POST", `/delete_comment/${id}`);
|
||||||
xhr.setRequestHeader('xhr', 'xhr');
|
xhr.setRequestHeader('xhr', 'xhr');
|
||||||
var form = new FormData()
|
var form = new FormData()
|
||||||
form.append("formkey", formkey());
|
form.append("formkey", formkey());
|
||||||
xhr.onload = function() {location.reload(true);};
|
xhr.onload = function() {
|
||||||
xhr.send(form);
|
let data
|
||||||
|
try {data = JSON.parse(xhr.response)}
|
||||||
|
catch(e) {console.log(e)}
|
||||||
|
if (xhr.status >= 200 && xhr.status < 300 && data && data['message']) {
|
||||||
|
document.getElementById(`comment-${id}`).classList.add('deleted');
|
||||||
|
document.getElementById(`delete-${id}`).classList.add('d-none');
|
||||||
|
document.getElementById(`undelete-${id}`).classList.remove('d-none');
|
||||||
|
document.getElementById(`delete2-${id}`).classList.add('d-none');
|
||||||
|
document.getElementById(`undelete2-${id}`).classList.remove('d-none');
|
||||||
|
document.getElementById('toast-comment-success-text').innerText = data["message"];
|
||||||
|
bootstrap.Toast.getOrCreateInstance(document.getElementById('toast-comment-success')).show();
|
||||||
|
} else {
|
||||||
|
document.getElementById('toast-comment-error-text').innerText = "Error, please try again later."
|
||||||
|
if (data && data["error"]) document.getElementById('toast-comment-error-text').innerText = data["error"];
|
||||||
|
bootstrap.Toast.getOrCreateInstance(document.getElementById('toast-comment-error')).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
xhr.send(form);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function post_reply(id){
|
function post_reply(id){
|
||||||
const btn = document.getElementById(`save-reply-to-${id}`)
|
const btn = document.getElementById(`save-reply-to-${id}`)
|
||||||
|
|
|
@ -81,13 +81,13 @@ def stats():
|
||||||
"total posts": g.db.query(Submission.id).count(),
|
"total posts": g.db.query(Submission.id).count(),
|
||||||
"posting users": g.db.query(Submission.author_id).distinct().count(),
|
"posting users": g.db.query(Submission.author_id).distinct().count(),
|
||||||
"listed posts": g.db.query(Submission.id).filter_by(is_banned=False).filter(Submission.deleted_utc == 0).count(),
|
"listed posts": g.db.query(Submission.id).filter_by(is_banned=False).filter(Submission.deleted_utc == 0).count(),
|
||||||
"removed posts": g.db.query(Submission.id).filter_by(is_banned=True).count(),
|
"removed posts (by admins)": g.db.query(Submission.id).filter_by(is_banned=True).count(),
|
||||||
"deleted posts": g.db.query(Submission.id).filter(Submission.deleted_utc > 0).count(),
|
"deleted posts (by author)": g.db.query(Submission.id).filter(Submission.deleted_utc > 0).count(),
|
||||||
"posts last 24h": g.db.query(Submission.id).filter(Submission.created_utc > day).count(),
|
"posts last 24h": g.db.query(Submission.id).filter(Submission.created_utc > day).count(),
|
||||||
"total comments": g.db.query(Comment.id).filter(Comment.author_id.notin_((AUTOJANNY_ID,NOTIFICATIONS_ID))).count(),
|
"total comments": g.db.query(Comment.id).filter(Comment.author_id.notin_((AUTOJANNY_ID,NOTIFICATIONS_ID))).count(),
|
||||||
"commenting users": g.db.query(Comment.author_id).distinct().count(),
|
"commenting users": g.db.query(Comment.author_id).distinct().count(),
|
||||||
"removed comments": g.db.query(Comment.id).filter_by(is_banned=True).count(),
|
"removed comments (by admins)": g.db.query(Comment.id).filter_by(is_banned=True).count(),
|
||||||
"deleted comments": g.db.query(Comment.id).filter(Comment.deleted_utc > 0).count(),
|
"deleted comments (by author)": g.db.query(Comment.id).filter(Comment.deleted_utc > 0).count(),
|
||||||
"comments last_24h": g.db.query(Comment.id).filter(Comment.created_utc > day, Comment.author_id.notin_((AUTOJANNY_ID,NOTIFICATIONS_ID))).count(),
|
"comments last_24h": g.db.query(Comment.id).filter(Comment.created_utc > day, Comment.author_id.notin_((AUTOJANNY_ID,NOTIFICATIONS_ID))).count(),
|
||||||
"post votes": g.db.query(Vote.id).count(),
|
"post votes": g.db.query(Vote.id).count(),
|
||||||
"post voting users": g.db.query(Vote.user_id).distinct().count(),
|
"post voting users": g.db.query(Vote.user_id).distinct().count(),
|
||||||
|
|
|
@ -693,11 +693,9 @@
|
||||||
<a id="undistinguish2-{{c.id}}" class="list-group-item {% if not c.distinguish_level %}d-none{% endif %} text-info" role="button" onclick="post_toast2(this,'/distinguish_comment/{{c.id}}','distinguish2-{{c.id}}','undistinguish2-{{c.id}}')" data-bs-dismiss="modal"><i class="fas fa-id-badge text-info"></i>Undistinguish</a>
|
<a id="undistinguish2-{{c.id}}" class="list-group-item {% if not c.distinguish_level %}d-none{% endif %} text-info" role="button" onclick="post_toast2(this,'/distinguish_comment/{{c.id}}','distinguish2-{{c.id}}','undistinguish2-{{c.id}}')" data-bs-dismiss="modal"><i class="fas fa-id-badge text-info"></i>Undistinguish</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if c.deleted_utc %}
|
<button id="undelete-{{c.id}}" class="{% if not c.deleted_utc %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-success" role="button" onclick="post_toast2(this,'/undelete_comment/{{c.id}}', 'delete-{{c.id}}', 'undelete-{{c.id}}');document.getElementById('comment-{{c.id}}').classList.remove('deleted')" data-bs-dismiss="modal"><i class="far fa-trash-alt text-center mr-3"></i>Undelete</button>
|
||||||
<a role="button" onclick="post_toast(this,'/undelete/comment/{{c.id}}')" data-bs-dismiss="modal" class="list-group-item"><i class="fas fa-trash-alt"></i>Undelete</a>
|
|
||||||
{% else %}
|
<button id="delete-{{c.id}}" class="{% if c.deleted_utc %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-danger" data-bs-toggle="modal" data-bs-dismiss="modal" data-bs-target="#deleteCommentModal" onclick="delete_commentModal('{{c.id}}')"><i class="far fa-trash-alt mr-3"></i>Delete</button>
|
||||||
<a role="button" data-bs-toggle="modal" data-bs-target="#deleteCommentModal" onclick="delete_commentModal('{{c.id}}')" class="list-group-item"><i class="fas fa-trash-alt"></i>Delete</a>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
<a id="mark2-{{c.id}}" class="{% if c.over_18 %}d-none{% endif %} list-group-item text-danger" role="button" onclick="post_toast2(this,'/toggle_comment_nsfw/{{c.id}}','mark2-{{c.id}}','unmark2-{{c.id}}')" data-bs-dismiss="modal"><i class="fas fa-eye-evil text-danger"></i>Mark +18</a>
|
<a id="mark2-{{c.id}}" class="{% if c.over_18 %}d-none{% endif %} list-group-item text-danger" role="button" onclick="post_toast2(this,'/toggle_comment_nsfw/{{c.id}}','mark2-{{c.id}}','unmark2-{{c.id}}')" data-bs-dismiss="modal"><i class="fas fa-eye-evil text-danger"></i>Mark +18</a>
|
||||||
<a id="unmark2-{{c.id}}" class="{% if not c.over_18 %}d-none{% endif %} list-group-item text-danger" role="button" onclick="post_toast2(this,'/toggle_comment_nsfw/{{c.id}}','mark2-{{c.id}}','unmark2-{{c.id}}')" data-bs-dismiss="modal"><i class="fas fa-eye-evil text-danger"></i>Unmark +18</a>
|
<a id="unmark2-{{c.id}}" class="{% if not c.over_18 %}d-none{% endif %} list-group-item text-danger" role="button" onclick="post_toast2(this,'/toggle_comment_nsfw/{{c.id}}','mark2-{{c.id}}','unmark2-{{c.id}}')" data-bs-dismiss="modal"><i class="fas fa-eye-evil text-danger"></i>Unmark +18</a>
|
||||||
|
@ -815,7 +813,7 @@
|
||||||
<div class="modal fade" id="deleteCommentModal" tabindex="-1" role="dialog" aria-labelledby="deleteCommentModalTitle" aria-hidden="true">
|
<div class="modal fade" id="deleteCommentModal" tabindex="-1" role="dialog" aria-labelledby="deleteCommentModalTitle" aria-hidden="true">
|
||||||
<div class="modal-dialog modal-dialog-centered" role="document">
|
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header d-none d-md-flex">
|
||||||
<h5 class="modal-title">Delete comment?</h5>
|
<h5 class="modal-title">Delete comment?</h5>
|
||||||
<button class="close" data-bs-dismiss="modal" aria-label="Close">
|
<button class="close" data-bs-dismiss="modal" aria-label="Close">
|
||||||
<span aria-hidden="true"><i class="far fa-times"></i></span>
|
<span aria-hidden="true"><i class="far fa-times"></i></span>
|
||||||
|
@ -824,14 +822,18 @@
|
||||||
<div class="modal-body text-center">
|
<div class="modal-body text-center">
|
||||||
|
|
||||||
<div class="py-4">
|
<div class="py-4">
|
||||||
<i class="fad fa-trash-alt text-muted" style="font-size: 3.5rem;"></i>
|
<i class="fad fa-trash-alt text-muted d-none d-md-block" style="font-size: 3.5rem;"></i>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p>Your comment will be removed everywhere on {{SITE_NAME}}. This action can be undone.</p>
|
<div class="h4 d-md-none">Delete comment?</div>
|
||||||
</div>
|
|
||||||
<div class="modal-footer">
|
<p class="d-none d-md-block">Your comment will be deleted everywhere on {{SITE_NAME}}.</p>
|
||||||
<button class="btn btn-link text-muted" data-bs-dismiss="modal">Cancel</button>
|
|
||||||
<button id="deleteCommentButton" class="btn btn-danger">Delete comment</button>
|
<p class="text-muted d-md-none">Your comment will be deleted everywhere on {{SITE_NAME}}.</p>
|
||||||
|
|
||||||
|
<button id="deleteCommentButton" class="btn btn-danger btn-block mt-5" data-bs-dismiss="modal">Delete comment</button>
|
||||||
|
|
||||||
|
<button class="btn btn-secondary btn-block" data-bs-dismiss="modal">Cancel</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -964,7 +966,7 @@
|
||||||
|
|
||||||
{% if v %}
|
{% if v %}
|
||||||
<script src="/static/assets/js/marked.js?a=242"></script>
|
<script src="/static/assets/js/marked.js?a=242"></script>
|
||||||
<script src="/static/assets/js/comments_v.js?a=247"></script>
|
<script src="/static/assets/js/comments_v.js?a=248"></script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<script src="/static/assets/js/clipboard.js?a=250"></script>
|
<script src="/static/assets/js/clipboard.js?a=250"></script>
|
||||||
|
|
|
@ -17,9 +17,9 @@
|
||||||
|
|
||||||
<div class="h4 d-md-none">Delete post?</div>
|
<div class="h4 d-md-none">Delete post?</div>
|
||||||
|
|
||||||
<p class="d-none d-md-block">Your post will be removed everywhere on {{SITE_NAME}}. This action can be undone.</p>
|
<p class="d-none d-md-block">Your post will be deleted everywhere on {{SITE_NAME}}.</p>
|
||||||
|
|
||||||
<p class="text-muted d-md-none">Your post will be removed everywhere on {{SITE_NAME}}. This action can be undone.</p>
|
<p class="text-muted d-md-none">Your post will be deleted everywhere on {{SITE_NAME}}.</p>
|
||||||
|
|
||||||
<button id="deletePostButton" class="btn btn-danger btn-block mt-5" data-bs-dismiss="modal">Delete post</button>
|
<button id="deletePostButton" class="btn btn-danger btn-block mt-5" data-bs-dismiss="modal">Delete post</button>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue