-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
72 lines (61 loc) · 2.25 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
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Loading Screen by Nicolas</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<video id="video" autoplay muted loop>
<source src="assets/video.mp4" type="video/mp4" />
Your Browser does not support the video element /
Votre navigateur ne vous permet pas de lire cette video
</video>
<audio id="audio" src="assets/music.mp3" type="audio/mp3" autoplay looped></audio>
<div class="loadbar"><div class="thingy"></div></div>
<script type="text/javascript">
let count = 0;
let thisCount = 0;
let isVideoPlaying = true;
const video = document.getElementById('video');
const audio = document.getElementById('audio');
video.volume = 0.1;
audio.volume = 0.3;
const handlers = {
startInitFunctionOrder(data) {
count = data.count;
},
initFunctionInvoking(data) {
document.querySelector('.thingy').style.left = '0%';
document.querySelector('.thingy').style.width = (data.idx / count) * 100 + '%';
},
startDataFileEntries(data) {
count = data.count;
},
performMapLoadFunction(data) {
++thisCount;
document.querySelector('.thingy').style.left = '0%';
document.querySelector('.thingy').style.width = (thisCount / count) * 100 + '%';
},
};
window.addEventListener('message', function (e) {
(handlers[e.data.eventName] || function () {})(e.data);
});
window.addEventListener('keydown', function (e) {
if (e.key === ' ') {
if (isVideoPlaying) {
video.pause();
audio.pause();
} else {
video.play();
audio.play();
}
isVideoPlaying = !isVideoPlaying;
e.preventDefault();
}
});
</script>
</body>
</html>