From b9d9f999531d93c27829cfbe28436a00ccd50013 Mon Sep 17 00:00:00 2001 From: Miala <65893041+Miala-python@users.noreply.github.com> Date: Wed, 30 Oct 2024 17:41:41 +0100 Subject: [PATCH] set_bg_vid --- lib/pl_view.js | 22 ++++++++++++++++++++++ loop.js | 13 +------------ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/lib/pl_view.js b/lib/pl_view.js index 5d8847a..e31bf47 100644 --- a/lib/pl_view.js +++ b/lib/pl_view.js @@ -1,6 +1,26 @@ // https://i.ytimg.com/vi/dvuhQEDXvN8/hqdefault.jpg console.log('PLVIEW v¤>44<'); +function set_bg_vid(){ + // Set the correct bg for active video and last active video + + // var pl_view_active def in pl_load to false + // var id def in pl_load to 0 + + try { + if (pl_view_active !== false) { + document.getElementById('pl_view_article_' + pl_view_active).classList.remove('has-background-grey-dark'); + } + } catch (error) { } + pl_view_active = id; + + // Known ERR: loop.js:81 TypeError: Cannot read properties of null (reading 'classList') at changeVideo (loop.js:78:61) + // => just stop try... + // console.log('Try add dark bg to article with id:'+id); //-> Return ID 0 + // => Need set first ID for first time ... + document.getElementById('pl_view_article_' + id).classList.add('has-background-grey-dark'); +} + function plv_load_pict(){ let pl_view_HTML = `
@@ -45,6 +65,8 @@ function plv_load_pict(){ var pl_view = document.getElementById("pl_view"); pl_view.innerHTML = pl_view_HTML; + + set_bg_vid(); } function setYouTubeVideoTitle(my_id, videoId) { diff --git a/loop.js b/loop.js index 81677c9..1c88445 100644 --- a/loop.js +++ b/loop.js @@ -69,18 +69,7 @@ function changeVideo(nid, pgs_rest = true) { try { if ($PLAYLIST_VIEW !== false) { - try { - if (pl_view_active !== false) { - document.getElementById('pl_view_article_' + pl_view_active).classList.remove('has-background-grey-dark'); - } - } catch (error) { } - pl_view_active = id; - - // Known ERR: loop.js:81 TypeError: Cannot read properties of null (reading 'classList') at changeVideo (loop.js:78:61) - // => just stop try... - // console.log('Try add dark bg to article with id:'+id); //-> Return ID 0 - // => Need set first ID for first time ... - document.getElementById('pl_view_article_' + id).classList.add('has-background-grey-dark'); + set_bg_vid(); } } catch (error) { console.log(error) }