-
Notifications
You must be signed in to change notification settings - Fork 0
/
metronome.html
42 lines (41 loc) · 1.53 KB
/
metronome.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
<html>
<head>
<title>Metronome</title>
<script>
document.addEventListener("DOMContentLoaded", function(event) {
var newtime = 750;
var url_string = window.location.href; //
var url = new URL(url_string);
var bpm = url.searchParams.get("bpm");
if (bpm > 0) {
newtime = (60/bpm)*1000;
}
var color = 0;
multiStep();
function multiStep() {
switch (color) {
case 0:
document.body.style.background = "red";
color++;
break;
case 1:
document.body.style.background = "yellow";
color++;
break;
case 2:
document.body.style.background = "green";
color++;
break;
case 3:
document.body.style.background = "blue";
color = 0;
break;
}
setTimeout(multiStep, newtime);
}
});
</script>
</head>
<body>
</body>
</html>