-
Notifications
You must be signed in to change notification settings - Fork 0
/
quadone.js
59 lines (52 loc) · 1.6 KB
/
quadone.js
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
function replaceSymbols(inputElement) {
if (inputElement.value.includes("pi")) {
inputElement.value = inputElement.value.replace("pi", "π");
}
if (inputElement.value.includes("sqrt")) {
inputElement.value = inputElement.value.replace("sqrt", "√");
}
if (inputElement.value.includes("deg")) {
inputElement.value = inputElement.value.replace("deg", "°");
}
}
function clearUC() {
var currentInput;
for (i = 1; i < 23; i++) {
currentInput = document.getElementById("uc"+i);
currentInput.value = "";
currentInput.style.backgroundColor = "white";
}
focusedInput = document.getElementById("uc1");
focusedInput.focus();
}
var focusedInput = document.getElementById("uc1");
function checkUC() {
var currentInput;
for (i = 1; i < 23; i++) {
currentInput = document.getElementById("uc"+i);
if (currentInput.value != "") {
if (currentInput.value == currentInput.dataset.solution) {
currentInput.style.backgroundColor = "lightgreen";
} else {
currentInput.style.backgroundColor = "lightcoral";
}
}
}
focusedInput = document.getElementById("uc1");
focusedInput.focus();
}
function setFocus() {
focusedInput = document.activeElement;
}
function addRoot() {
focusedInput.value += "√";
focusedInput.focus();
}
function addPi() {
focusedInput.value += "π";
focusedInput.focus();
}
function addDegree() {
focusedInput.value += "°";
focusedInput.focus();
}