-
Notifications
You must be signed in to change notification settings - Fork 0
/
TheBatman.js
53 lines (45 loc) · 1.3 KB
/
TheBatman.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
var text = "I am Vengeance, I am the Night, I am Batman.";
var i = 0;
var speed = 70;
var wait = 1000;
var audio = document.getElementById("audio");
var video = document.getElementById("video");
function typeWriter() {
if (i < text.length) {
if (text.charAt(i) == ",") {
speed = wait;
} else {
speed = 70;
}
document.getElementById("main-text").innerHTML += text.charAt(i);
i++;
setTimeout(typeWriter, speed);
}
}
function startAudio() {
audio.play();
audio.loop = true;
audio.autoplay = true;
audio.volume = 0.1;
}
function transition() {
document.getElementById("main-text").style.opacity = "0";
document.getElementById("main-text").style.transition = "all 2s";
video.style.opacity = "0.7";
video.style.transition = "all 2s";
}
function startVideo() {
video.play();
video.loop = true;
video.autoplay = true;
transition();
}
document.getElementById("main-text").style.display = "none";
document.getElementById("btn").onclick = function () {
document.body.style.cursor = "none";
document.getElementById("btn").style.display = "none";
document.getElementById("main-text").style.display = "block";
typeWriter();
setTimeout(startAudio, 5500);
setTimeout(startVideo, 5500);
};