export function dialog (header, body, callback = async (result, form) => { }) { const dialog = document.createElement("dialog"); dialog.innerHTML = `

`; dialog.className = "w3-container w3-card w3-border-0"; dialog.querySelector("#prompt").innerText = header; dialog.querySelector("form").innerHTML = body; dialog.addEventListener("close", async () => { await callback(dialog.returnValue, new FormData(dialog.querySelector("form"))); dialog.parentElement.removeChild(dialog); }); document.body.append(dialog); dialog.showModal(); return dialog; } export function alert (message) { const dialog = document.createElement("dialog"); dialog.innerHTML = `

${message}

`; dialog.className = "w3-container w3-card w3-border-0"; document.body.append(dialog); dialog.showModal(); dialog.addEventListener("close", () => { dialog.parentElement.removeChild(dialog); }); return dialog; }