export function alert(message) { return new Promise(next => { if (document.getElementById("popup-container")) throw new Error("Popup already exist !") document.querySelector("body").insertAdjacentHTML("afterend", `
`); document.getElementById("popup-ok").addEventListener("click", () => { document.getElementById("popup-container").remove(); next(); }); }); } export function confirm(message) { return new Promise(next => { if (document.getElementById("popup-container")) throw new Error("Popup already exist !") document.querySelector("body").insertAdjacentHTML("afterend", ``); document.getElementById("popup-ok").addEventListener("click", () => { document.getElementById("popup-container").remove(); next(true); }); document.getElementById("popup-cancel").addEventListener("click", () => { document.getElementById("popup-container").remove(); next(false); }); }); } export function prompt(message, inputArgs) { return new Promise(next => { if (document.getElementById("popup-container")) throw new Error("Popup already exist !") document.querySelector("body").insertAdjacentHTML("afterend", ``); document.getElementById("popup-ok").addEventListener("click", () => { let val = document.querySelector("#popup input").value document.getElementById("popup-container").remove(); next(val); }); document.getElementById("popup-cancel").addEventListener("click", () => { document.getElementById("popup-container").remove(); next(null); }); }); }