-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaccTest.html
More file actions
215 lines (186 loc) · 6.57 KB
/
Copy pathaccTest.html
File metadata and controls
215 lines (186 loc) · 6.57 KB
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet">
<meta name="theme-color" content="#16191C">
<style>
body {
overflow: hidden;
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Chrome/Safari/Opera */
-khtml-user-select: none; /* Konqueror */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none; /* Non-prefixed version, currently
not supported by any browser */
cursor: default;
}
small {
font-size: 60%;
}
#check {
position: absolute;
width: 80%;
top: 0px;
left: 0px;
color: white;
font-family: 'Montserrat', sans-serif;
font-size: 500%;
text-align: center;
padding-top: 20px;
border: none;
background: rgb(22,25,28);
margin: 0% 10%;
padding-top: 20%;
}
#extra {
position: absolute;
width: 80%;
top: 0px;
left: 0px;
color: white;
font-family: 'Montserrat', sans-serif;
font-size: 500%;
text-align: center;
padding-top: 20px;
border: none;
background: #303F9F;
margin: 0% 10%;
padding-top: 10%;
visibility: hidden;
}
#coords {
position: absolute;
width: 100%;
left: 0px;
bottom: 2%;
font-family: 'Montserrat', sans-serif;
font-size: 225%;
color: rgb(242,245,248);
text-align: center;
}
#verder {
font-family: 'Montserrat', sans-serif;
position: absolute;
left: 25%;
bottom: 25%;
width: 50%;
padding: 2% 0%;
cursor: pointer;
background: #536DFE;
color: #B3E5FC;
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.26);
transition: all ease 0.3s;
text-align: center;
font-size: 300%;
}
#verder:hover {
box-shadow: 0 8px 17px 0 rgba(0, 0, 0, 0.2);
}
#verder:active {
background: #334DDE;
}
</style>
<script>
var isVerder = false
function gaVerder() {
if (!isVerder) {
isVerder = true
document.getElementById('check').style.visibility = "hidden"
document.getElementById('coords').style.visibility = "visible"
document.getElementById('extra').style.visibility = "visible"
document.body.style.background = "#303F9F"
document.getElementsByName('theme-color')[0].content = "#3F51B5"
document.getElementById('verder').innerHTML = "← terug"
navigator.geolocation.watchPosition(geoSucces, geoError, {enableHighAccuracy:true,maximumAge:30000,timeout:27000})
} else {
isVerder = false
document.getElementById('check').style.visibility = "visible"
document.getElementById('coords').style.visibility = "visible"
document.getElementById('extra').style.visibility = "hidden"
document.body.style.background = "rgb(22,25,28)"
document.getElementsByName('theme-color')[0].content = "#16191C"
document.getElementById('verder').innerHTML = "verder →"
}
}
/*
* LOCATIE
*
function geoSucces(position) {
$.getJSON('https://maps.googleapis.com/maps/api/geocode/json?address='+ position.coords.latitude +","+ position.coords.longitude +'&key=AIzaSyA_uqQ2c-rh0mdrUtveNjJTPdoSNSKRbCo', function(data) {
var obj = JSON.stringify(data, null, 2)
var gArr = $.parseJSON(obj)
document.getElementById('extra').innerHTML = "Je bent nu op " + gArr.results[0].formatted_address
})
if (isVerder) {
document.getElementById('coords').innerHTML = "lat: " + position.coords.latitude.toFixed(5) + ", lon: " + position.coords.longitude.toFixed(5) + "<br>nauwkeurigheid: " + Math.round(position.coords.accuracy) + "m<br><i><small>Gemaakt door sdw7020 \\_(ツ)_/¯</small></i>"
}
}
function geoError() {
}
navigator.geolocation.watchPosition(geoSucces, geoError, {enableHighAccuracy:true,maximumAge:30000,timeout:27000})
*/
/*
* TAFEL
*/
if(window.DeviceMotionEvent){
window.addEventListener("devicemotion", motion, false)
} else{
document.body.innerHTML = "DeviceMotionEvent wordt niet ondersteund door je browser"
}
var lastCoords = [0,0,0]
var antiBlink = new Date().getTime()
var t1 = new Date().getTime()
var isLongEnough = false
function motion(event) {
var isOnTable = false
var x = event.accelerationIncludingGravity.x
var y = event.accelerationIncludingGravity.y
var z = event.accelerationIncludingGravity.z
var t = new Date().getTime()
var diffX = Math.abs(x - lastCoords[0])
var diffY = Math.abs(y - lastCoords[1])
var diffZ = Math.abs(z - lastCoords[2])
var sen = 0.07
if (diffX <= sen && diffY <= sen && diffZ <= sen) {
isOnTable = true
} else {
isOnTable = false
}
if (!isVerder) {
document.getElementById('coords').innerHTML = "S: " + sen + "<br>x: " + x.toFixed(2) + ", y: " + y.toFixed(2) + ", z: " + z.toFixed(2) + "<br>dx: " + diffX.toFixed(2) + ", dy: " + diffY.toFixed(2) + ", dz: " + diffZ.toFixed(2) + "<br>t: " + t + "<br><i><small>Gemaakt door sdw7020 \\_(ツ)_/¯</small></i>"
if (isOnTable) {
if (!isLongEnough) {
isLongEnough = true
antiBlink = new Date().getTime()
}
if (t - antiBlink > 100) {
document.getElementById('check').style.background = "#4CAF50"
document.body.style.background = "#4CAF50"
document.getElementsByName('theme-color')[0].content = "#4CAF50"
document.getElementById('check').innerHTML = "Je apparaat ligt nu waarschijnlijk op een tafel"
}
} else {
isLongEnough = false
document.getElementById('check').style.background = "#F44336"
document.body.style.background = "#F44336"
document.getElementsByName('theme-color')[0].content = "#F44336"
document.getElementById('check').innerHTML = "Je hebt je apparaat nu in je handen"
}
}
var t2 = new Date().getTime()
if (t2 - t1 >= 40) {
t1 += 40
return lastCoords = [x, y, z]
}
}
</script>
</head>
<body>
<div id="check"></div>
<div id="extra"></div>
<div id="coords"></div>
<!--<div onclick="gaVerder()" id="verder">verder →</div>-->
</body>
</html>