-
Notifications
You must be signed in to change notification settings - Fork 0
/
index2.js
89 lines (75 loc) · 1.84 KB
/
index2.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
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
// // var container = document.querySelector("#container");
// // container.addEventListener("click",function(){
// // container.classList.toggle("flipme");
// // });
// var containers = document.getElementsByClassName("container");
// var i = 2;
// document.addEventListener('keyup', function (e) {
// if (e.key == "ArrowRight")
// {
// containers[i].classList.toggle("moveme");
// i--;
// }
// if (e.key == "ArrowLeft")
// {
// i++;
// containers[i].classList.toggle("moveme");
// }
// })
// var the_learning_screen = document.getElementsByClassName("the_learning_screen");
// // for (var j = 0; j < containers.length; j++) {
// the_learning_screen[0].addEventListener("click",function(){
// this.classList.toggle("flipme");
// });
// // }
var containers = document.getElementsByClassName("container");
for (var j = 0; j < containers.length; j++) {
containers[j].style.display = "none";
containers[j].addEventListener("click",function(){
this.classList.toggle("flipme");
});
}
containers[4].style.display = "inline";
var i = 4;
document.addEventListener('keyup', function (e) {
if (e.key == "ArrowUp")
{
containers[i].classList.toggle("flipme");
}
});
document.addEventListener('keyup', function (e) {
if (e.key == "ArrowRight")
{
if (i == 0)
{
}
else if (i > 0)
{
containers[i].classList.toggle("moveme");
containers[i-1].style.display = "inline";
i--;
}
}
if (e.key == "ArrowLeft")
{
if (i < 0)
{
containers[0].classList.toggle("moveme");
i = 0;
}
else if (i == 0)
{
containers[1].classList.toggle("moveme");
containers[0].style.display = "none";
i = 1;
}
else if (i == 4)
{
}
else{
containers[i+1].classList.toggle("moveme");
containers[i].style.display = "none";
i++;
}
}
});