-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
27 lines (24 loc) · 883 Bytes
/
index.html
File metadata and controls
27 lines (24 loc) · 883 Bytes
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Accelerator</title>
</head>
<body>
<script>
var parts = window.location.href.split('/');
var id = parts[parts.length - 1];
var ws = new WebSocket('ws://192.168.2.8:8080');
function deviceMotionHandler(e) {
accel = {id: id, x: e.accelerationIncludingGravity.x, y: e.accelerationIncludingGravity.y, z: e.accelerationIncludingGravity.z }
ws.send(JSON.stringify(accel));
}
if (window.DeviceMotionEvent) {
console.log('orientation and motion supported');
window.addEventListener('devicemotion', deviceMotionHandler);
} else {
alert('Esto no funciona en este browser')
}
</script>
</body>
</html>