From b0f64a2949725a2c30949384c08c6b757cb50803 Mon Sep 17 00:00:00 2001 From: Pitchaya Boonsarngsuk Date: Sat, 23 Mar 2019 12:50:44 +0000 Subject: [PATCH] Fix first run --- index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 1a0537d..cbfeb38 100644 --- a/index.js +++ b/index.js @@ -102,6 +102,7 @@ const createVidList = () => { var hls = null; var currentVideoIndex = 0; +var firstRun = true; if(window.location.hash) { let hash = window.location.hash; if(hash.startsWith('#playlistEntry')) { @@ -113,9 +114,12 @@ if(window.location.hash) { } const changeVid = index => { - if (index === currentVideoIndex){ + if (index === currentVideoIndex && !firstRun){ return; } + if(firstRun) { + firstRun = false; + } let oldSelectedVideo = document.querySelector(`#playlistEntry${currentVideoIndex}`); oldSelectedVideo.classList.remove("bg-dark"); oldSelectedVideo.classList.remove("text-light");