-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
86 lines (74 loc) · 2.71 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
body {
background: #000;
color: #fff;
font-family: monospace;
text-align: center;
}
</style>
</head>
<body>
<script>
const frames = []
window.onload = function() {
const audio = document.getElementById('audio')
const volumeInput = document.getElementById('volume')
const element = document.getElementById('output')
volumeInput.value = audio.volume * 100
volumeInput.oninput = function() {
audio.volume = (volumeInput.value / 100)
}
for(let i = 0; i <= 21; i++) {
fetch(`chunks/chunk${i}.html`)
.then(data => {
return data.text()
})
.then(data => {
const chunk = data.split('---END OF FRAME---')
const chunkFrames = []
chunk.forEach(frame => {
frames.push(frame)
})
// frames[i * 240] = chunkFrames[i]
})
.then(() => {
if (i === 21) {
console.log('complete!')
document.getElementById('audio').play()
startAnimation(element)
}
})
}
};
let j = 0
function startAnimation(element) {
let interval = setInterval(() => {
if(j > frames.length) {
clearInterval(interval)
} else {
console.log(frames[j].length)
element.innerHTML = frames[j]
j++
}
}, 41.6666666667)
}
</script>
<h1>Bad Apple text version</h1>
<pre id="output">Loading...</pre>
<audio id="audio">
<source src="audio.ogg" type="audio/ogg">
Your browser does not support the audio tag.
</audio>
<span style="vertical-align: super; ">Volume:</span>
<input type="range" id="volume">
<p>Checkout my <a href="http://github.com/k-egor-smirnov">GitHub</a> to find more my intresting projects</p>
<p><a href="http://github.com/k-egor-smirnov/bad-apple">Bad Apple repository</a></p>
</body>
</html>