This commit is contained in:
Aevann1 2021-12-31 15:08:40 +02:00
parent f6d5455c5e
commit 6b9cbf6a83
7 changed files with 44 additions and 34 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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