-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathneedyKnobs.html
57 lines (50 loc) · 1.58 KB
/
needyKnobs.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
<!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>Knobs/LED/Needy - Keep Talking</title>
</head>
<body>
<h3>Needy Knobs</h3>
<input type="text" id="txtLine1"><br>
<input type="text" id="txtLine2"><br>
<span id="out">
</span>
<script>
var txt1 = document.getElementById("txtLine1");
var txt2 = document.getElementById("txtLine2");
var out = document.getElementById("out");
txt1.addEventListener("keyup", change);
txt2.addEventListener("keyup", change);
change();
function change() {
out.innerText = ""
var val1 = txt1.value;
var val2 = txt2.value;
for (w in states) {
if (val1.length >= 6) {
if (w.startsWith(val1 + ";" + val2)) {
out.innerText += w + ": " + states[w] + "\n";
}
} else {
if (w.startsWith(val1)) {
out.innerText += w + ": " + states[w] + "\n";
}
}
}
}
var states = {
"001011;111101": "Up",
"101010;011011": "Up",
"011001;111101": "Down",
"101010;010001": "Down",
"000010;100111": "Left",
"000010;000110": "Left",
"101111;111010": "Right",
"101100;111010": "Right"
}
</script>
</body>
</html>