-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
58 lines (44 loc) · 1.26 KB
/
index.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
55
import CBrowser from './src/browser'
export function InitBrowserDefault(reqid, opts) {
document.addEventListener("readystatechange", function() {
if (document.readyState != "complete") {
return;
}
opts = opts || {};
// if in iframe, notify parent of reqid
if (window != window.parent && !opts.noNotifyParent) {
window.parent.postMessage({"type": "reqid", "reqid": reqid}, "*");
}
if (!opts.on_countdown) {
opts.on_countdown = function(seconds, countdown_text) {
var text = document.getElementById("countdown");
if (text) {
text.innerText = countdown_text;
}
}
}
if (!opts.on_event) {
opts.on_event = function(type, data) {
if (type == "fail" || type == "expire") {
window.location.reload();
}
}
}
if (opts.proxy_ws === undefined) {
if (!window.location.port) {
opts.proxy_ws = "_websockify?port=";
}
}
if (opts.audio === undefined) {
opts.audio = true;
}
if (opts.fill_window === undefined) {
opts.fill_window = true;
}
if (opts.inactiveSecs === undefined) {
opts.inactiveSecs = 10;
}
var id = opts.id || "#browser";
return new CBrowser(reqid, id, opts);
});
}