move some functions into admin/base.html

This commit is contained in:
mst 2025-03-11 16:05:31 +03:00
parent 6d1ef386f5
commit 6304d8aeea
No known key found for this signature in database
2 changed files with 14 additions and 17 deletions

View file

@ -93,6 +93,20 @@
{% block scripts %}
<script src="{{ url_for('static', filename='js/toastify.min.js') }}"></script>
<script>
function showToast(message, type, gravity = "top", position = "right") {
Toastify({
text: message,
duration: 3000,
gravity: gravity,
position: position,
stopOnFocus: true,
className: `alert alert-${type} shadow alert-dismissible`,
close: true
}).showToast();
}
function saveConfig() {
document.getElementById('saveConfig').click();
};
document.addEventListener('htmx:afterRequest', function(event) {
const jsonResponse = event.detail.xhr.response;
if (jsonResponse && event.detail.target.dataset.dontshowtoast != '') {

View file

@ -320,11 +320,6 @@
document.body.removeChild(a);
}
function saveConfig() {
document.getElementById('saveConfig').click();
};
document.body.addEventListener("htmx:beforeRequest", function(evt) {
console.log("HTMX is making a request to:", evt.detail.pathInfo.finalRequestPath);
});
@ -333,18 +328,6 @@
console.log("HTMX swap completed on:", evt.detail.target);
});
function showToast(message, type, gravity = "top", position = "right") {
Toastify({
text: message,
duration: 3000,
gravity: gravity,
position: position,
stopOnFocus: true,
className: `alert alert-${type} shadow alert-dismissible`,
close: true
}).showToast();
}
function clearCmText(toast = false) {
cmTextarea.value = "";
view.update([view.state.update({changes: {from: 0, to: view.state.doc.length, insert: ""}})]);