-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinteractions.js
36 lines (32 loc) · 1.1 KB
/
interactions.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
function onCodeInput(number) {
let currentText = document.getElementById("guess" + number).value;
if (currentText.length >= 2) {
document.getElementById("guess" + number).value = currentText.charAt(1);
}
//Check If Correct Code
if (
correctCode[0] == guess1.value &&
correctCode[1] == guess2.value &&
correctCode[2] == guess3.value
) {
guess1.disabled = true;
guess2.disabled = true;
guess3.disabled = true;
continueButton.disabled = false;
headerLabel.innerHTML = "GOOD JOB!";
//Animations
document.getElementById("lockAnimation").style.backgroundPosition =
"0px -32px";
animateWithReflow("continueButton", "bounce-in");
}
}
function revealAnswer() {
document.getElementById("answerLabel").innerHTML =
correctCode[0] + "" + correctCode[1] + "" + correctCode[2];
}
function animateWithReflow(element, animation) {
document.getElementById(element).classList.remove(animation);
void document.getElementById(element).offsetWidth;
document.getElementById(element).classList.add(animation);
document.getElementById(element).style.opacity = "1";
}