-
Notifications
You must be signed in to change notification settings - Fork 3
/
controls.html
97 lines (78 loc) · 2.53 KB
/
controls.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Die Digitale Initiativen Pizza Machine - Jede(r) versteht um was es geht - Controls</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0,
maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, minimal-ui" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="HandheldFriendly" content="true" />
<meta name="mobile-web-app-capable" content="yes" />
<style>
body {
margin: 0;
padding: 0;
background-color: #000000;
}
html, body{
height: 100%;
}
#controls {
position: absolute;
top: 50%;
left: 50%;
-moz-transform: translateX(-50%) translateY(-50%);
-webkit-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
user-drag: none;
user-select: none;
-moz-user-select: none;
-webkit-user-drag: none;
-webkit-user-select: none;
-ms-user-select: none;
}
</style>
</head>
<body>
<img id="controls" src="assets/controls.png" usemap="#controls" />
<map name="controls">
<area shape="rect" coords="0,340,117,457" alt="Links" href="#" id="left" data="left">
<area shape="rect" coords="117,340,247,457" alt="Enter" href="#" id="enter" data="enter">
<area shape="rect" coords="247,340,360,457" alt="Rechts" href="#" id="right" data="right">
</map>
<script>
let bang = new URLSearchParams(window.location.search).get('hash').split('|').shift();
console.log(new URLSearchParams(window.location.search).get('hash').split('|'));
let channel = new URLSearchParams(window.location.search).get('hash').split('|').pop();
let socketUrl = 'wss://us-nyc-1.websocket.me/v3/'
+ channel
+ '?api_key=QJ3733IrJhU667fuYoITyxYedPDd9VST5xuhV6Xz¬ify_self';
let socket = new WebSocket(socketUrl);
socket.onmessage = function(message) {
let data = JSON.parse(message.data);
if(data.bang != bang) return;
switch(data.event) {
case 'vibrate':
break;
}
}
socket.onopen = function() {
socket.send(JSON.stringify({
event: 'control-ready',
bang: bang
}));
};
function sendMessage() {
socket.send(JSON.stringify({
event: 'control',
key: this.attributes['data'].nodeValue,
bang: bang
}));
};
document.getElementById('left').addEventListener('click', sendMessage);
document.getElementById('enter').addEventListener('click', sendMessage);
document.getElementById('right').addEventListener('click', sendMessage);
</script>
</body>
</html>