-
Notifications
You must be signed in to change notification settings - Fork 5
/
waiting-slides.js
104 lines (91 loc) · 2.8 KB
/
waiting-slides.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
curSlide = 0;
frames = [];
fileToFrame = {};
timer = null;
document.body.onload = initSlides;
document.onkeypress = handleKeypress;
function initSlides()
{
for (var i = 0; i < slides.length; i++) {
if (slides[i] === "upcomingevents")
{
for (var j = 0; j < upcoming_events.length; j += 2)
{
frame = document.createElement("iframe");
frame.src = "slides/general/upcomingevents.html?events=" + JSON.stringify(upcoming_events.slice(j, j+2));
frame.frameBorder = "0";
document.querySelector("body").appendChild(frame);
frames.push(frame);
}
}
else if (slides.indexOf(slides[i]) === i)
{
frame = document.createElement("iframe");
frame.src = slides[i];
frame.frameBorder = "0";
document.querySelector("body").appendChild(frame);
j = frames.push(frame) - 1;
fileToFrame[slides[i]] = j;
}
else
{
frames.push(frames[fileToFrame[slides[i]]]);
}
}
timer = document.querySelector("#timer");
transitionback = document.querySelector(".transition.back");
transitionfront = document.querySelector(".transition.front")
timer.addEventListener("animationiteration", progressSlides, false);
transitionback.addEventListener("animationend", clearTransitionClasses, false);
frames[0].onload = function()
{
timer.classList.add("timer");
timer.parentElement.classList.add("slideUp");
curSlide = frames.length - 1;
progressSlides();
};
}
function progressSlides()
{
transitionback.classList.add("slide");
transitionfront.classList.add("slide");
setTimeout(function() {
frames[curSlide].style.display = "none";
curSlide = (curSlide + 1) % frames.length;
frames[curSlide].style.display = "block";
}, 1000);
}
function clearTransitionClasses(e)
{
if (e.animationName === "slideout")
{
transitionback.classList.remove("slide");
transitionfront.classList.remove("slide");
}
}
function handleKeypress(e)
{
if (e.key == " ")
{
if (document.querySelector("#timer").classList.contains("timer"))
{
document.querySelector("#timer").classList.remove("timer");
}
else
{
document.querySelector("#timer").classList.add("timer");
}
}
else if (e.key == "Enter")
{
document.querySelector("#timer").classList.remove("timer");
progressSlides();
setTimeout(function() {
document.querySelector("#timer").classList.add("timer");
}, 10);
}
else if (e.key == "i")
{
window.location = "https://intro.hacksoc.net";
}
}