1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-07-20 13:31:12 +02:00

files mode detached mode working, separate domain and logging refactor

This commit is contained in:
Kushagra Gour
2019-02-28 16:51:08 +05:30
parent 53533bf09a
commit 1d88db8e10
4 changed files with 90 additions and 17 deletions

View File

@@ -1,4 +1,5 @@
window.addEventListener('message', e => {
// Recieving from app window
if (e.data && e.data.contents) {
const frame = document.querySelector('iframe');
frame.src = frame.src;
@@ -7,7 +8,13 @@ window.addEventListener('message', e => {
frame.contentDocument.write(e.data.contents);
frame.contentDocument.close();
}, 10);
} else {
document.querySelector('iframe').src = e.data;
}
if (e.data && e.data.url) {
document.querySelector('iframe').src = e.data.url;
}
// Recieving from preview iframe
if (e.data && e.data.logs) {
window.opener.postMessage(e.data, '*');
}
});