From c4cf5f330606ba8b32686d27bc2c2c8620a6edf0 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Mon, 21 Nov 2022 22:18:03 +0100 Subject: [PATCH] * add possible enhancement * white text at the end, following recent dark theme change --- js/main.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/js/main.js b/js/main.js index f278654..c7c3d80 100644 --- a/js/main.js +++ b/js/main.js @@ -36,7 +36,9 @@ const main = () => { // Add property to the player currentVideo = document.createElement("video"); + // TODO(enhancement): Custom controls? currentVideo.controls = true; + // TODO(enhancement): Better fit window currentVideo.width = window.innerWidth - window.innerWidth / 2; currentVideo.style = "display: block; margin: auto;"; @@ -69,20 +71,20 @@ const removeButtons = (parentOfButtons) => { * @param {{number: string[]}} videosList List of videos filenames * @param {{int: int[]}} tree List of all the videos from videosList with the next possibles choices from the video * @param {HTMLSourceElement} source Current video - * @param {number} newVideoId Video ID to add to the main element + * @param {number} videoId Video ID to add to the main element */ -const updateVideo = (videoFolder, videosList, tree, source, newVideoId) => { +const updateVideo = (videoFolder, videosList, tree, source, videoId) => { const videoElement = source.parentElement; const mainElement = videoElement.parentElement; - source.src = `${videoFolder}/${videosList[newVideoId][0]}.${videosList[newVideoId][1]}`; - source.type = `video/${videosList[newVideoId][1]}`; + source.src = `${videoFolder}/${videosList[videoId][0]}.${videosList[videoId][1]}`; + source.type = `video/${videosList[videoId][1]}`; // Add buttons at the end of the video videoElement.addEventListener( "ended", () => { - if (tree[newVideoId]) { - tree[newVideoId].forEach((nextVideoId, counter) => { + if (tree[videoId]) { + tree[videoId].forEach((nextVideoId, counter) => { const button = document.createElement("button"); // TODO(enhancement): Add custom label for the button redirection @@ -114,7 +116,7 @@ const updateVideo = (videoFolder, videosList, tree, source, newVideoId) => { } else { removeButtons(mainElement); const endText = document.createElement("h1"); - endText.style = "font-size: 11vh;"; + endText.style = "font-size: 11vh; color: white;"; endText.innerText = "Merci d'avoir regardé !"; mainElement.appendChild(endText); } @@ -123,5 +125,6 @@ const updateVideo = (videoFolder, videosList, tree, source, newVideoId) => { ); // Force the reload of the video + // TODO(enhancement): Keep previous volume videoElement.load(); };