diff --git a/js/main.js b/js/main.js index c7c3d80..227b94f 100644 --- a/js/main.js +++ b/js/main.js @@ -60,8 +60,9 @@ const main = () => { */ const removeButtons = (parentOfButtons) => { const buttons = parentOfButtons.getElementsByTagName("button"); - for (let index = 0; index < buttons.length; index++) { - parentOfButtons.removeChild(buttons[index]); + console.log(buttons); + while (buttons.length) { + parentOfButtons.removeChild(buttons[0]); } }; @@ -79,6 +80,10 @@ const updateVideo = (videoFolder, videosList, tree, source, videoId) => { source.src = `${videoFolder}/${videosList[videoId][0]}.${videosList[videoId][1]}`; source.type = `video/${videosList[videoId][1]}`; + // Force the reload of the video + // TODO(enhancement): Keep previous volume + videoElement.load(); + // Add buttons at the end of the video videoElement.addEventListener( "ended", @@ -123,8 +128,4 @@ const updateVideo = (videoFolder, videosList, tree, source, videoId) => { }, { once: true } ); - - // Force the reload of the video - // TODO(enhancement): Keep previous volume - videoElement.load(); };