-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.html
54 lines (45 loc) · 1.17 KB
/
test.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
<label for="current">Current</label>
<br/>
<input id="current"/>
<br/>
<label for="all">All devices:</label>
<br/>
<textarea id="all" rows=8></textarea>
<br/>
<label for="scratch">Just a text area:</label>
<br/>
<textarea id="scratch" rows=8></textarea>
<br/>
<button id="start">Start</button>
<button id="stop">Stop</button>
<br/>
Change events:
<pre id="changes">
</pre>
<script>
window.module = {}
</script>
<script src="index.js"></script>
<script>
function monitorChanges (e) {
document.querySelector('#changes').textContent = `
${e.previous} 🔜 ${e.current}
${document.querySelector('#changes').textContent}
`
}
warez = module.exports
warez.start()
warez.onDeviceChange(monitorChanges)
document.querySelector('#start').addEventListener('click', (e) => {
warez.start()
warez.onDeviceChange(monitorChanges)
})
document.querySelector('#stop').addEventListener('click', (e) => {
warez.stop()
warez.removeDeviceChangeHandler(monitorChanges)
})
setInterval(() => {
document.querySelector('#current').value = warez.currentDevice()
document.querySelector('#all').value = warez.allDevices().join('\n')
}, 500)
</script>