-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
39 lines (39 loc) · 1.39 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
---
---
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Taylor Swift</title>
</head>
<body>
<input type="range" id="inputvolume" onchange="setVolume()" max="10">
<audio id="audioelement">
<source id="song">
</audio>
<script>
{%- assign images = site.static_files | where_exp: "item", "item.path contains '/images/'" -%}
{%- assign audio = site.static_files | where_exp: "item", "item.path contains '/audio/'" -%}
let audioElement = document.getElementById("audioelement");
audioElement.addEventListener("ended", function () {
setTimeout(reloadPage, 2000);
});
const images = [{% for image in images %}'{{ image.path }}'{% unless forloop.last %},{% endunless %}{% endfor %}]
let image = images[Math.floor(Math.random()*images.length)];
document.body.style.backgroundImage = "url(" + image + ")";
const audio = [{% for song in audio %}'{{ song.path }}'{% unless forloop.last %},{% endunless %}{% endfor %}]
let song = audio[Math.floor(Math.random()*audio.length)];
document.getElementById('song').src = song;
audioElement.load();
audioElement.play();
function reloadPage() {
location.reload();
}
function setVolume() {
let valueinput = document.getElementById("inputvolume").value;
valueinput = (valueinput / 10);
audioElement.volume = valueinput;
}
</script>
</body>
</html>