refactor(frontend): remove unused modal code and expose htmx to window

This commit is contained in:
Herculino Trotta
2024-10-09 22:24:23 -03:00
parent faaef38919
commit 983df8483a

View File

@@ -2,47 +2,19 @@ import htmx from "htmx.org";
import _hyperscript from 'hyperscript.org/dist/_hyperscript.min';
import Alpine from "alpinejs";
import mask from '@alpinejs/mask';
window.htmx = htmx;
window.Alpine = Alpine;
Alpine.start();
Alpine.plugin(mask);
_hyperscript.browserInit();
let modalEle = document.getElementById("modal");
if (modalEle) {
const modal = new bootstrap.Modal(modalEle); // eslint-disable-line no-undef
htmx.on("htmx:beforeSwap", (e) => {
// Empty response targeting #dialog => hide the modal
if (e.detail.target.id === "dialog" && !e.detail.xhr.response) {
modal.hide();
e.detail.shouldSwap = false;
}
});
htmx.on("hidden.bs.modal", () => {
document.getElementById("dialog").innerHTML = "";
});
}
const successAudio = new Audio("/static/sounds/success.mp3");
const popAudio = new Audio("/static/sounds/pop.mp3");
window.paidSound = successAudio;
window.unpaidSound = popAudio;
// htmx.on("paid", () => {
// successAudio.pause();
// successAudio.currentTime = 0;
// successAudio.play();
// });
//
// htmx.on("unpaid", () => {
// popAudio.pause();
// popAudio.currentTime = 0;
// popAudio.play();
// });
/**
* Parse a localized number to a float.
* @param {string} stringNumber - the localized number