-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
42 lines (36 loc) · 1.26 KB
/
index.js
File metadata and controls
42 lines (36 loc) · 1.26 KB
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
const ROUTE_TABLE = {
'<default>': '/administrator-hub',
'feef.0000': '/employee-hub',
'seed.1111': '/mirror/seed.html'
};
async function delay(millis) {
await new Promise((resolve) => setTimeout(resolve, millis));
}
document.addEventListener('DOMContentLoaded', async () => {
const dcdi = new URLSearchParams(window.location.search).get('dcdi') || '<default>';
resolveDCDI(dcdi);
});
async function resolveDCDI(dcdi) {
await log(`DCDI is set to "${dcdi}". Performing target lookup in the local network...`, 100);
const dest = ROUTE_TABLE[dcdi];
if (dest) {
await log('Target found. Establishing a Direct Connect (TM) protocol link...', 500);
await log('^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@', 200);
await delay(50);
window.location.href = dest;
document.body.classList.add('navigated-away');
}
else {
await log('Target not found. Attempting to connect to the default endpoint...', 500);
await delay(1500);
resolveDCDI('<default>');
}
}
async function log(text, textDelay) {
if (textDelay > 0)
await delay(textDelay);
const log = document.getElementById("log");
const line = document.createElement("li");
line.appendChild(document.createTextNode(text));
log.appendChild(line);
}