-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
47 lines (33 loc) · 886 Bytes
/
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
<!DOCTYPE html>
<html>
<body id = 'bod' >
<p id = 'testing' >Hello</p>
</body>
<script src="/socket.io/socket.io.js"></script>
<script>
var testing = document.getElementById('testing');
var bod = document.getElementById('bod');
var socket = io();
socket.emit('test', {message:"Hello"});
socket.on('response', function(data){
console.log("Got Response");
testing.style.display = 'none';
});
document.onmousedown = function(event){
if(event.clientX < (0.5 * bod.clientWidth)){
socket.emit('jumpStart',{direction: 'left'});
}
else {
socket.emit('jumpStart',{direction: 'right'});
}
}
document.onmouseup = function(event){
if(event.clientX < (0.5 * bod.clientWidth)){
socket.emit('jumpStop',{direction: 'left'});
}
else {
socket.emit('jumpStop',{direction: 'right'});
}
}
</script>
</html>