export function dialog(header, body, callback = async (result, form) => { }) { let 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; document.body.append(dialog); dialog.showModal(); dialog.addEventListener("close", async () => { await callback(dialog.returnValue, new FormData(dialog.querySelector("form"))); dialog.parentElement.removeChild(dialog); }); return dialog; } export function alert(message) { let 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; }