Refactoring of main page

This commit is contained in:
2023-06-13 17:21:54 +02:00
parent bdcfed4e05
commit 17edc1eb45
9 changed files with 351 additions and 483 deletions

32
js/background.js Normal file
View File

@ -0,0 +1,32 @@
(function(){
var btn = document.getElementById("play-background");
/** @type {HTMLVideoElement} */
var video = document.getElementById("background-video");
var poster = document.getElementById("background-poster");
btn.hidden = false
btn.addEventListener("click", function(e) {
e.preventDefault()
if(btn.classList.contains("playing")) {
video.pause();
} else {
video.play()
}
})
video.addEventListener("pause", function(e) {
btn.querySelector(".play").hidden = false;
btn.querySelector(".pause").hidden = true;
btn.classList.remove("playing")
})
video.addEventListener("play", function(e) {
btn.querySelector(".play").hidden = true;
btn.querySelector(".pause").hidden = false;
poster.hidden = true;
btn.classList.add("playing")
})
})()