-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
62 lines (60 loc) · 1.77 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Overlay Demo</title>
<style>
* {
box-sizing: border-box;
}
html,
body {
font-family: sans-serif;
background-color: white;
}
.json-formatter-row {
font-family: 'Consolas', 'Courier New', 'Courier', monospace !important;
}
</style>
</head>
<body>
<main>
<h2>Overlay Demo</h2>
<h4>Data received:</h4>
<div id="data"></div>
</main>
<script src="https://cdn.jsdelivr.net/npm/json-formatter-js@2.3.4/dist/json-formatter.umd.min.js"></script>
<script src="overlay.min.js"></script>
<script>
// init api
const overlay = new OverlayAPI({
extendData: true,
silentMode: false,
});
// add listener
overlay.addListener('ChangeZone', (data) => {
console.log('new listener of ChangeZone', data);
});
// list `ChangeZone` listeners
console.log(overlay.getAllListener('ChangeZone'));
// remove unused listeners
overlay.removeAllListener('ChangeZone');
// add listener to display
overlay.addListener('CombatData', (data) => {
if (document.getElementById('data').childNodes.length > 0) {
document.getElementById('data').innerHTML = '';
}
let formatter = new JSONFormatter(data, 3);
document.getElementById('data').appendChild(formatter.render());
});
overlay.startEvent();
// pass some fake data for development simulation
fetch('./fake.json')
.then((res) => res.json())
.then((obj) => {
overlay.simulateData(obj);
});
</script>
</body>
</html>