-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
136 lines (132 loc) · 3.71 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<!doctype html>
<html>
<head>
<title>
Tournament buttons
</title>
<base target="_blank">
<script src="https://epicenterprograms.github.io/standards/behavior/general.js"></script>
<script>
var S = Standards.general;
var clicked = false;
var leftColor = 120;
var rightColor = 240;
var buzzer;
function countDown(color) {
clicked = true;
let deciseconds = 50;
let interval1 = setInterval(function () {
S.getId("message").textContent = (deciseconds / 10).toFixed(1);
if (deciseconds <= 0) {
clearInterval(interval1);
if (buzzer) {
buzzer.play("a4-");
}
if (color == leftColor) {
document.body.style.background = "hsl(" + rightColor + ", 100%, 75%)";
} else {
document.body.style.background = "hsl(" + leftColor + ", 100%, 75%)";
}
deciseconds = 100;
let interval2 = setInterval(function () {
S.getId("message").textContent = (deciseconds / 10).toFixed(1);
if (deciseconds <= 0) {
if (buzzer) {
buzzer.play("a4-");
}
document.body.style.background = "";
S.getId("message").textContent = "Ready";
clicked = false;
clearInterval(interval2);
}
deciseconds--;
}, 100);
}
deciseconds--;
}, 100);
}
S.listen("button1", ["click", "touchstart"], function () {
if (!clicked) {
document.body.style.background = "hsl(" + leftColor + ", 100%, 75%)";
countDown(leftColor);
}
});
S.listen("button2", ["click", "touchstart"], function () {
if (!clicked) {
document.body.style.background = "hsl(" + rightColor + ", 100%, 75%)";
countDown(rightColor);
}
});
S.listen("leftButtonColor", "change", function () {
leftColor = this.value;
S.getId("button1").style.background = "hsl(" + leftColor + ", 100%, 50%)";
S.getId("button1").style.borderColor = "hsl(" + leftColor + ", 100%, 25%)";
});
S.listen("rightButtonColor", "change", function () {
rightColor = this.value;
S.getId("button2").style.background = "hsl(" + rightColor + ", 100%, 50%)";
S.getId("button2").style.borderColor = "hsl(" + this.value + ", 100%, 25%)";
});
S.listen("makeBuzzingNoises", "change", function () {
if (this.checked) {
S.makeToneGenerator().then(function () {
buzzer = new S.Sound({ waveform: "sawtooth" });
});
} else {
buzzer = undefined;
}
});
</script>
<link rel="stylesheet" href="https://epicenterprograms.github.io/standards/formatting/foundation.css">
<style>
.button-container button {
display: block;
margin: 4rem;
border-radius: 5rem;
width: 10rem;
height: 10rem;
}
#button1 {
border: 1rem solid hsl(120, 100%, 25%);
background: hsl(120, 100%, 50%);
}
#button2 {
border: 1rem solid hsl(240, 100%, 25%);
background: hsl(240, 100%, 50%);
}
@media (max-width: 1000px) {
.button-container {
display: block;
}
.button-container button {
margin: 4rem auto 4rem;
}
}
</style>
</head>
<body class="generic-background">
<h1 class="main-title">
Tournament buttons
</h1>
<br>
<h2 class="generic-color" id="message">
Ready
</h2>
<br>
<div class="button-container">
<button id="button1"></button>
<input type="range" id="leftButtonColor" min="0" max="360" value="120">
</div>
<div class="button-container">
<button style="visibility:hidden"></button>
</div>
<div class="button-container">
<button id="button2"></button>
<input type="range" id="rightButtonColor" min="0" max="360" value="240">
</div>
<br>
<br>
<br>
<input type="checkbox" id="makeBuzzingNoises"><label for="makeBuzzingNoises">Make buzzing noises</label>
</body>
</html>