-
-
Notifications
You must be signed in to change notification settings - Fork 311
/
index.html
150 lines (103 loc) · 3.91 KB
/
index.html
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<!DOCTYPE html>
<html lang="en">
<head>
<title>Tholian Stealth</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Content-Security-Policy" content="worker-src 'self'; script-src 'self' 'unsafe-inline'; frame-src 'self'">
<meta name="application-name" content="Tholian Stealth">
<meta name="theme-color" content="#000000">
<meta name="viewport" content="initial-scale=1, user-scalable=no">
<link rel="manifest" href="index.webmanifest">
<link rel="shortcut icon" href="design/common/tholian.ico">
<link rel="icon" type="image/svg+xml" sizes="any" href="design/common/tholian.svg">
<link rel="apple-touch-icon" sizes="180x180" href="design/common/tholian-apple.png">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-title" content="Tholian Stealth">
<meta name="mobile-web-app-capable" content="yes">
<!-- Browser UI -->
<link rel="stylesheet" href="design/index.css">
</head>
<body data-theme="dark">
<!-- Browser PWA -->
<script type="module">
import { console } from './extern/base.mjs';
import { ENVIRONMENT } from './source/ENVIRONMENT.mjs';
import { URL } from './source/parser/URL.mjs';
import { Browser } from './source/Browser.mjs';
import { dispatch } from './design/index.mjs';
window.onerror = (err) => {
console.error(err);
};
console.log('Browser: Initializing ...');
// BROWSER has to be global for internal pages
const browser = window.BROWSER = new Browser({
host: ENVIRONMENT.hostname,
debug: ENVIRONMENT.flags.debug
});
setTimeout(() => {
dispatch(window, browser, true);
}, 100);
setTimeout(() => {
if (ENVIRONMENT.flags.debug === true && URL.isURL(ENVIRONMENT.flags.url) === true) {
console.info('Browser: Debug Mode active');
browser.once('connect', () => {
let tab = browser.open('stealth:debug?url=' + ENVIRONMENT.flags.url.link);
if (tab !== null) {
browser.show(tab);
}
});
} else if (ENVIRONMENT.flags.debug === true) {
console.info('Browser: Debug Mode active');
browser.once('connect', () => {
let tab = browser.open('stealth:debug');
if (tab !== null) {
browser.show(tab);
}
});
} else if (URL.isURL(ENVIRONMENT.flags.url) === true) {
let tab = browser.open(ENVIRONMENT.flags.url.link);
if (tab !== null) {
browser.show(tab);
}
} else {
let worker = (window.navigator || {}).serviceWorker || null;
if (worker !== null && typeof worker.register === 'function') {
worker.register('service.js').then((service) => {
console.info('Browser: Service connected to http://localhost:65432.');
}).catch((err) => {
console.error('Browser: Service could not connect to http://localhost:65432.');
});
}
}
}, 200);
setTimeout(() => {
browser.once('connect', () => {
setTimeout(() => {
if (browser.tab === null) {
browser.show(browser.open(browser.settings['interface'].opentab));
}
}, 1000);
});
browser.on('connect', () => {
console.info('Browser: Connected to ws://' + ENVIRONMENT.hostname + ':65432.');
});
browser.on('disconnect', () => {
console.error('Browser: Disconnected from ws://' + ENVIRONMENT.hostname + ':65432.');
});
browser.on('disconnect', () => {
// console.log('Browser: Reconnecting to ws://' + ENVIRONMENT.hostname + ':65432 after ' + (browser.__state.reconnect * 30) + ' seconds ...');
// browser.reconnect();
});
let onbeforeunload = window['onbeforeunload'] || null;
if (onbeforeunload === null) {
onbeforeunload = window['onbeforeunload'] = () => {
browser.disconnect();
};
}
browser.connect();
}, 300);
</script>
</body>
</html>