forked from rDrama/rDrama
1
0
Fork 0
master
Aevann1 2021-09-26 12:24:04 +02:00
parent 8efb3ab9af
commit 5efe1640ad
2 changed files with 28 additions and 16 deletions

View File

@ -19,8 +19,9 @@
xhr.onload = function() { xhr.onload = function() {
if (xhr.status >= 200 && xhr.status < 300) { if (xhr.status >= 200 && xhr.status < 300) {
document.getElementById('toast-post-success').toast('dispose'); var myToast = new bootstrap.Toast(document.getElementById('toast-post-success'));
document.getElementById('toast-post-success').toast('show'); myToast.hide();
myToast.show();
try { try {
document.getElementById('toast-post-success-text').innerText = JSON.parse(xhr.response)["message"]; document.getElementById('toast-post-success-text').innerText = JSON.parse(xhr.response)["message"];
} catch(e) { } catch(e) {
@ -34,14 +35,18 @@
try { try {
data=JSON.parse(xhr.response); data=JSON.parse(xhr.response);
document.getElementById('toast-post-error').toast('dispose'); var myToast = new bootstrap.Toast(document.getElementById('toast-post-error'));
document.getElementById('toast-post-error').toast('show'); myToast.hide();
myToast.show();
document.getElementById('toast-post-error-text').innerText = data["error"]; document.getElementById('toast-post-error-text').innerText = data["error"];
return false return false
} catch(e) { } catch(e) {
document.getElementById('toast-post-success').toast('dispose'); var myToast = new bootstrap.Toast(document.getElementById('toast-post-success'));
document.getElementById('toast-post-error').toast('dispose'); myToast.hide();
document.getElementById('toast-post-error').toast('show');
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."; document.getElementById('toast-post-error-text').innerText = "Error. Try again later.";
return false return false
} }
@ -412,8 +417,9 @@
document.getElementById(button1).classList.toggle("d-none"); document.getElementById(button1).classList.toggle("d-none");
document.getElementById(button2).classList.toggle("d-none"); document.getElementById(button2).classList.toggle("d-none");
document.getElementById('toast-post-success').toast('dispose'); var myToast = new bootstrap.Toast(document.getElementById('toast-post-success'));
document.getElementById('toast-post-success').toast('show'); myToast.hide();
myToast.show();
if (distinguish=='yes') { if (distinguish=='yes') {
document.getElementById('toast-post-success-text').innerText = "Comment distinguished!"; document.getElementById('toast-post-success-text').innerText = "Comment distinguished!";
} }
@ -489,7 +495,7 @@
<div class="comment-body"> <div class="comment-body">
<div id="comment-{{c.id}}-only" class=""> <div id="comment-{{c.id}}-only">
<div class="user-info"> <div class="user-info">
<span class="comment-collapse d-md-none" onclick="collapse_comment('{{c.id}}')"></span> <span class="comment-collapse d-md-none" onclick="collapse_comment('{{c.id}}')"></span>

View File

@ -62,9 +62,12 @@
let result = callback(xhr); let result = callback(xhr);
if (xhr.status >= 200 && xhr.status < 300) { if (xhr.status >= 200 && xhr.status < 300) {
document.getElementById('toast-post-error').toast('dispose'); var myToast = new bootstrap.Toast(document.getElementById('toast-post-error'));
document.getElementById('toast-post-success').toast('dispose'); myToast.hide();
document.getElementById('toast-post-success').toast('show');
var myToast = new bootstrap.Toast(document.getElementById('toast-post-success'));
myToast.hide();
myToast.show();
try { try {
if(typeof result == "string") { if(typeof result == "string") {
@ -78,9 +81,12 @@
return true; return true;
} else { } else {
document.getElementById('toast-post-success').toast('dispose'); var myToast = new bootstrap.Toast(document.getElementById('toast-post-success'));
document.getElementById('toast-post-error').toast('dispose'); myToast.hide();
document.getElementById('toast-post-error').toast('show');
var myToast = new bootstrap.Toast(document.getElementById('toast-post-error'));
myToast.hide();
myToast.show();
try { try {
if(typeof result == "string") { if(typeof result == "string") {