-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwireSequences.html
131 lines (114 loc) · 4.01 KB
/
wireSequences.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
<!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">
<title>Wire Sequences - Keep Talking</title>
<style>
.red {
background-color: red;
color: black;
}
.blue {
background-color: blue;
color: white;
}
.black {
background-color: black;
color: white;
}
button {
width: 30px;
height: 30px;
}
#btnReset {
width: 100px;
}
</style>
</head>
<body>
<button id="btnReset">RESET</button>
<table>
<tbody>
<tr><td><button id="rA" class="red" letter="A">A</button><button id="rB" class="red" letter="B">B</button><button id="rC" class="red" letter="C">C</button></td></tr>
<tr><td><button id="bA" class="blue" letter="A">A</button><button id="bB" class="blue" letter="B">B</button><button id="bC" class="blue" letter="C">C</button></td></tr>
<tr><td><button id="sA" class="black" letter="A">A</button><button id="sB" class="black" letter="B">B</button><button id="sC" class="black" letter="C">C</button></td></tr>
</tbody>
</table>
<span id = "out"></span>
<span id = "warning"></span>
<script>
var out = document.getElementById("out");
var btnsRed = document.getElementsByClassName("red");
var btnsBlue = document.getElementsByClassName("blue");
var btnsBlack = document.getElementsByClassName("black");
var numbRed = 0, numbBlue = 0, numbBlack = 0;
var warning = document.getElementById("warning");
function init() {
for (var i = 0; i<3; i++) {
btnsRed[i].addEventListener("click", buttonRed);
btnsBlue[i].addEventListener("click", buttonBlue);
btnsBlack[i].addEventListener("click", buttonBlack);
}
btnReset.addEventListener("click", reset);
}
function buttonRed(arg) {
var letter = arg.target.getAttribute("letter");
if (numbRed>8) {
warning.innerText += "No more red cables\r\n";
} else {
if (red[numbRed].indexOf(letter)>=0) {
out.innerText += "CUT\r\n";
} else {
out.innerText += "Don't cut\r\n";
}
numbRed++;
}
}
function buttonBlue(arg) {
var letter = arg.target.getAttribute("letter");
if (numbBlue>8) {
warning.innerText += "No more blue cables!\r\n";
} else {
if (blue[numbBlue].indexOf(letter)>=0) {
out.innerText += "CUT\r\n";
} else {
out.innerText += "Don't cut\r\n";
}
numbBlue++;
}
}
function buttonBlack(arg) {
var letter = arg.target.getAttribute("letter");
if (numbBlack>8) {
warning.innerText += "No more black cables!\r\n";
} else {
if (black[numbBlack].indexOf(letter)>=0) {
out.innerText += "CUT\r\n";
} else {
out.innerText += "Don't cut\r\n";
}
numbBlack++;
}
}
function reset() {
out.innerText = "";
warning.innerText = "";
numbRed = 0;
numbBlue = 0;
numbBlack = 0;
}
var red = [
["C"],["B"],["A"],["A","C"],["B"],["A","C"],["A","B","C"],["A","B"],["B"]
]
var blue = [
["B"],["A","C"],["B"],["A"],["B"],["B","C"],["C"],["A","C"],["A"]
]
var black = [
["A","B","C"],["A","C"],["B"],["A","C"],["B"],["B","C"],["A","B"],["C"],["C"]
]
init();
</script>
</body>
</html>