-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathloader.js
54 lines (40 loc) · 1.46 KB
/
loader.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
(() => {
const script = document.currentScript;
const loadWidget = () => {
const widget= document.createElement("div");
const widgetStyle = widget.style;
widgetStyle.display = "none";
widgetStyle.boxSizing = "border-box";
widgetStyle.width = "400px";
widgetStyle.height = "647px";
widgetStyle.position = "absolute";
widgetStyle.top = "40px";
widgetStyle.right = "40px";
const iframe = document.createElement("iframe");
const iframeStyle = iframe.style;
iframeStyle.boxSizing = "borderBox";
iframeStyle.position = "absolute";
iframeStyle.right = 0;
iframeStyle.top = 0;
iframeStyle.width = "100%";
iframeStyle.height = "100%";
iframeStyle.border = 0;
iframeStyle.margin = 0;
iframeStyle.padding = 0;
iframeStyle.width = "500px";
widget.appendChild(iframe);
iframe.addEventListener("load", () => widgetStyle.display = "block" );
const widgetUrl = `http://localhost:3000`;
iframe.src = widgetUrl;
document.body.appendChild(widget);
}
if ( document.readyState === "complete" ) {
loadWidget();
} else {
document.addEventListener("readystatechange", () => {
if ( document.readyState === "complete" ) {
loadWidget();
}
});
}
})();