forked from NeilVdB/ThomasMoreCiscoLighthouse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
audio.html
135 lines (113 loc) · 3.94 KB
/
audio.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<!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">
<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">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Cabin:400,500,600,700">
<title>Audio</title>
</head>
<body>
<a href="index.html">
<div class="terug">
Back
</div>
</a>
<audio class="hidden" id="audio-player" src="images/audio.mp3" type="audio/mp3">
</audio>
<div class="row justify-content-center">
<div class="col-9">
<h3 class="center title-padding">Let's hear what the parties have to say</h3>
<div class="row">
<div class="col-6">
<a>
<button type="button" class="btn btn-vote btn-primary btn-geel btn-lg btn-block">
<img src="images/cdhvoorzitteroriginal.jpg" width="150px">
<p>CDH</p>
</button>
</a>
</div>
<div class="col-6">
<a>
<button type="button" class="btn btn-vote btn-primary btn-oranje btn-lg btn-block">
<img src="images/psvoorzitteroriginal.jpg">
<p>Elio di Rupo - PS</p></button>
</a>
</div>
<div class="col-6">
<a>
<button type="button" class="btn btn-vote btn-primary btn-groen btn-lg btn-block">
<img src="images/ecolovoorzitteroriginal.jpg" height="75px">
<p>Ecolo</p>
</button>
</a>
</div>
<div class="col-6 flex">
<a>
<button type="button" class="btn btn-vote btn-primary btn-blauw btn-lg btn-block">
<img src="images/mrvoorzitteroriginal.jpg">
<p>MR</p>
</button>
</a>
</div>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
var run = true;
var interval = 500;
var intervalObj;
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].red == 1) {
navigatie("index.html");
} else if (obj[0].blue == 1) {
clearInterval(intervalObj);
$("#audio-player").trigger('play');
} else if (obj[0].orange == 1) {
clearInterval(intervalObj);
$("#audio-player").trigger('play');
} else if (obj[0].green == 1) {
clearInterval(intervalObj);
$("#audio-player").trigger('play');
} else if (obj[0].yellow == 1) {
clearInterval(intervalObj);
$("#audio-player").trigger('play');
}
}
$('#audio-player').on('ended', function() {
intervalObj = setInterval(function () {
readcontrollers();
}, interval);
});
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 () {
intervalObj = setInterval(function () {
readcontrollers();
}, interval);
});
</script>
</body>
</html>