26 lines
808 B
JavaScript
26 lines
808 B
JavaScript
document.addEventListener('DOMContentLoaded', documentReady, false);
|
|
window.onmessage = (event) => {
|
|
if (event.data == "close") {
|
|
document.querySelector("dialog[open]").close();
|
|
}
|
|
}
|
|
|
|
function documentReady() {
|
|
const iframe = document.querySelector("iframe");
|
|
iframe.onload=(event) => {
|
|
const openDialog = document.querySelector("dialog[open]");
|
|
if (openDialog) {
|
|
openDialog.close();
|
|
window.location.reload();
|
|
} else {
|
|
const dialog = document.querySelector("dialog")
|
|
if (iframe.contentWindow.location.href.split("/").pop() === "create") {
|
|
dialog.className = 'create';
|
|
} else {
|
|
dialog.className = 'update';
|
|
}
|
|
dialog.showModal()
|
|
|
|
}
|
|
}
|
|
} |