forked from NeilVdB/ThomasMoreCiscoLighthouse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
121 lines (100 loc) · 4.13 KB
/
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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<!--<script src="https://code.jquery.com/jquery-3.3.1.min.js" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/flexboxgrid/6.3.1/flexboxgrid.min.css">
<link rel="stylesheet" href="css/style.css">
<title>Welcome!</title>
</head>
<body class="bg-image">
<div>
<div class="language-switch">
<div class="input-group-prepend">
<button class="btn btn-outline-secondary dropdown-toggle" type="button" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">English</button>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" href="#">Nederlands</a>
<a class="dropdown-item" href="#">Français</a>
</div>
</div>
</div>
<div class="row buttons">
<div class="col-6"></div>
<div class="col-3 offset-1">
<a href="explore.html"><button type="button" class="btn btn-primary btn-blauw btn-lg btn-block">Explore</button></a>
<a href="audio.html"><button type="button" class="btn btn-primary btn-oranje btn-lg btn-block margin-top">Listen
to audio</button></a>
<a href="feedback.html"><button type="button" class="btn btn-primary btn-groen btn-lg btn-block margin-top">Give
feedback</button></a>
<button onclick="kiesRandom()" type="button" class="btn btn-primary btn-geel btn-lg btn-block margin-top">Surprise
me!</button>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$('.dropdown-toggle').dropdown()
</script>
<script>
var run = true;
function kiesRandom() {
run = false;
let randomNumber = Math.floor(Math.random() * 3);
switch (randomNumber) {
case 0:
window.location.href = "explore.html";
break;
case 1:
window.location.href = "audio.html";
break;
case 2:
window.location.href = "feedback.html";
break;
}
}
function readcontrollers(){
if (!run){
return;
}
var input = getRemote("/cgi-bin/test.py");
input = input.replace(/'/g, '"');
input = input.replace(/True/g, 1);
input = input.replace(/False/g, 2);
console.log(input.trim());
var obj = JSON.parse(input.trim());
if (obj[0].blue == 1){
navigatie("explore.html");
} else if (obj[0].orange == 1){
navigatie("audio.html");
}else if (obj[0].green == 1){
navigatie("feedback.html");
}else if (obj[0].yellow == 1){
kiesRandom();
}
}
function getRemote(remote_url) {
return $.ajax({
type: "GET",
url: remote_url,
async: false
}).responseText;
}
function navigatie(url) {
run = false;
window.location.href = url;
}
$(document).ready(function() {
setTimeout(function () {
setInterval(function(){ readcontrollers(); }, 500);
})
}, 2000);
</script>
</body>
</html>