1
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
740 B
JavaScript

let video = document.getElementById("video");
let source = document.getElementById("source");
let video_list = document.getElementById("video-list").getElementsByTagName("img");
var i;
for (i = 0; i < video_list.length; i++) {
video_list[i].addEventListener("click", function() {
video.setAttribute("poster", this.getAttribute("src"));
source.setAttribute("src", this.dataset.video);
video.pause();
video.currentTime = 0;
video.load();
for (i = 0; i < video_list.length; i++) {
video_list[i].classList.remove("active");
}
this.classList.add("active");
video.style["box-shadow"] = this.dataset.shadow;
});
}
video.addEventListener("click", function() {
if (this.paused)
this.play();
else
this.pause();
});