This commit is contained in:
Aevann1 2021-12-31 17:17:13 +02:00
parent c5af36ad2e
commit e88971dd3e
7 changed files with 32 additions and 44 deletions

View file

@ -24,21 +24,18 @@ function post_toast3(url, button1, button2) {
xhr.withCredentials=true;
xhr.onload = function() {
try {
let data = JSON.parse(xhr.response)
if (xhr.status >= 200 && xhr.status < 300 && !data['error']) {
document.getElementById('toast-post-success-text').innerText = data["message"];
new bootstrap.Toast(document.getElementById('toast-post-success')).show();
let data = JSON.parse(xhr.response)
if (xhr.status >= 200 && xhr.status < 300 && data && data["message"]) {
document.getElementById('toast-post-success-text').innerText = data["message"];
new bootstrap.Toast(document.getElementById('toast-post-success')).show();
document.getElementById(button1).classList.toggle("d-none");
document.getElementById(button2).classList.toggle("d-none");
} else {
if (data["error"]) document.getElementById('toast-post-error-text').innerText = data["error"];
new bootstrap.Toast(document.getElementById('toast-post-error')).show();
}
document.getElementById(button1).classList.toggle("d-none");
document.getElementById(button2).classList.toggle("d-none");
} else {
if (data && data["error"]) document.getElementById('toast-post-error-text').innerText = data["error"];
new bootstrap.Toast(document.getElementById('toast-post-error')).show();
}
catch(e) {new bootstrap.Toast(document.getElementById('toast-post-error')).show();}
};
xhr.send(form);

View file

@ -26,21 +26,15 @@ function post_toast(url, reload, data) {
xhr.withCredentials=true;
xhr.onload = function() {
try {
let data = JSON.parse(xhr.response)
if (xhr.status >= 200 && xhr.status < 300 && !data['error']) {
document.getElementById('toast-post-success-text').innerText = data["message"];
new bootstrap.Toast(document.getElementById('toast-post-success')).show();
document.getElementById(button1).classList.toggle("d-none");
document.getElementById(button2).classList.toggle("d-none");
} else {
if (data["error"]) document.getElementById('toast-post-error-text').innerText = data["error"];
new bootstrap.Toast(document.getElementById('toast-post-error')).show();
}
let data = JSON.parse(xhr.response)
if (xhr.status >= 200 && xhr.status < 300 && data && data['message']) {
document.getElementById('toast-post-success-text').innerText = data["message"];
new bootstrap.Toast(document.getElementById('toast-post-success')).show();
if (reload == 1) {location.reload(true)}
} else {
if (data && data["error"]) document.getElementById('toast-post-error-text').innerText = data["error"];
new bootstrap.Toast(document.getElementById('toast-post-error')).show();
}
catch(e) {new bootstrap.Toast(document.getElementById('toast-post-error')).show();}
};
xhr.send(form);

View file

@ -15,21 +15,18 @@ function post_toast2(url, button1, button2) {
xhr.withCredentials=true;
xhr.onload = function() {
try {
let data = JSON.parse(xhr.response)
if (xhr.status >= 200 && xhr.status < 300 && !data['error']) {
document.getElementById('toast-post-success-text').innerText = data["message"];
new bootstrap.Toast(document.getElementById('toast-post-success')).show();
let data = JSON.parse(xhr.response)
if (xhr.status >= 200 && xhr.status < 300 && data && data["message"]) {
document.getElementById('toast-post-success-text').innerText = data["message"];
new bootstrap.Toast(document.getElementById('toast-post-success')).show();
document.getElementById(button1).classList.toggle("d-none");
document.getElementById(button2).classList.toggle("d-none");
} else {
if (data["error"]) document.getElementById('toast-post-error-text').innerText = data["error"];
new bootstrap.Toast(document.getElementById('toast-post-error')).show();
}
document.getElementById(button1).classList.toggle("d-none");
document.getElementById(button2).classList.toggle("d-none");
} else {
if (data && data["error"]) document.getElementById('toast-post-error-text').innerText = data["error"];
new bootstrap.Toast(document.getElementById('toast-post-error')).show();
}
catch(e) {new bootstrap.Toast(document.getElementById('toast-post-error')).show();}
};
xhr.send(form);

View file

@ -104,6 +104,6 @@
</nav>
{% endif %}
<script src="/static/assets/js/post_toast2.js?a=6"></script>
<script src="/static/assets/js/post_toast2.js?a=7"></script>
{% endblock %}

View file

@ -844,7 +844,7 @@
{% if v %}
<script src="/static/assets/js/marked.js?a=3"></script>
<script src="/static/assets/js/comments_v.js?a=6"></script>
<script src="/static/assets/js/comments_v.js?a=7"></script>
{% endif %}
<script src="/static/assets/js/clipboard.js?a=3"></script>

View file

@ -318,7 +318,7 @@
<script src="/static/assets/js/lozad.js?a=3"></script>
{% if v %}
<script src="/static/assets/js/post_toast2.js?a=6"></script>
<script src="/static/assets/js/post_toast2.js?a=7"></script>
<script src="/static/assets/js/formatting.js?a=3"></script>
<script src="/static/assets/js/default.js?a=3"></script>
{% endif %}

View file

@ -210,7 +210,7 @@
</div>
</nav>
<script src="/static/assets/js/header.js?a=6"></script>
<script src="/static/assets/js/header.js?a=7"></script>
<style>
.notif-count {