fix showonotherpages
This commit is contained in:
45
script.js
45
script.js
@@ -372,12 +372,12 @@ const createSlideElement = (movie, hasVideo = false) => {
|
|||||||
if (logo) logo.style.left = 'calc(50% - 17vw)';
|
if (logo) logo.style.left = 'calc(50% - 17vw)';
|
||||||
|
|
||||||
videoContainer.style.width = '34.4vw';
|
videoContainer.style.width = '34.4vw';
|
||||||
/*} else if (player.getPlayerState() === YT.PlayerState.CUED) {
|
/*} else if (player.getPlayerState() === YT.PlayerState.CUED) {
|
||||||
console.log('Video cued - attempting restart');
|
console.log('Video cued - attempting restart');
|
||||||
player.playVideo();
|
player.playVideo();
|
||||||
} else if (player.getPlayerState() === -1) {
|
} else if (player.getPlayerState() === -1) {
|
||||||
console.log('Video unstarted - attempting restart');
|
console.log('Video unstarted - attempting restart');
|
||||||
player.playVideo();*/
|
player.playVideo();*/
|
||||||
} else if (player.getPlayerState() === YT.PlayerState.ENDED) {
|
} else if (player.getPlayerState() === YT.PlayerState.ENDED) {
|
||||||
clearMonitorOutroInterval();
|
clearMonitorOutroInterval();
|
||||||
setTimeout(fetchRandomMovie, 20);
|
setTimeout(fetchRandomMovie, 20);
|
||||||
@@ -665,21 +665,25 @@ const checkNavigation = () => {
|
|||||||
|
|
||||||
// Check if parent is available and if the iframe is in an embedded environment
|
// Check if parent is available and if the iframe is in an embedded environment
|
||||||
if (!showOnOtherPages && window.parent && window.parent !== window) {
|
if (!showOnOtherPages && window.parent && window.parent !== window) {
|
||||||
const homeTab = window.parent.document.getElementById('homeTab');
|
const isHomePage = url => url.includes('/home') || url.endsWith('/web/') || url.endsWith('/web/index.html');
|
||||||
const isHomeTabActive = homeTab && homeTab.classList.contains('is-active');
|
if (isHomePage(newLocation)) {
|
||||||
|
const homeTab = window.parent.document.getElementById('homeTab');
|
||||||
|
const isHomeTabActive = homeTab && homeTab.classList.contains('is-active');
|
||||||
|
|
||||||
// Check if the user is switching tabs while on the homepage to eg. favorites or requests, if so, stop the slideshow
|
// Check if the user is switching tabs while on the homepage to eg. favorites or requests, if so, stop the slideshow
|
||||||
if (isHomeTabActive && !isHomePageActive) {
|
if (isHomeTabActive && !isHomePageActive) {
|
||||||
console.log("HomeTab is active, reactivating slideshow");
|
console.log("HomeTab is active, reactivating slideshow");
|
||||||
isHomePageActive = true;
|
isHomePageActive = true;
|
||||||
window.parent.document.querySelector('.featurediframe').style.display = 'block';
|
window.parent.document.querySelector('.featurediframe').style.display = 'block';
|
||||||
cleanup();
|
//cleanup();
|
||||||
fetchRandomMovie();
|
fetchRandomMovie();
|
||||||
} else if (!isHomeTabActive && isHomePageActive) {
|
} else if (!isHomeTabActive && isHomePageActive) {
|
||||||
console.log("Leaving HomeTab, cleaning up slideshow");
|
console.log("Leaving HomeTab, cleaning up slideshow");
|
||||||
isHomePageActive = false;
|
isHomePageActive = false;
|
||||||
window.parent.document.querySelector('.featurediframe').style.display = 'none';
|
window.parent.document.querySelector('.featurediframe').style.display = 'none';
|
||||||
cleanup();
|
stopBackgroundVideo();
|
||||||
|
cleanup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.error("Spotlight iframe is not in an embedded environment, has a different domain or showOnOtherPages is set to true");
|
console.error("Spotlight iframe is not in an embedded environment, has a different domain or showOnOtherPages is set to true");
|
||||||
@@ -701,6 +705,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
const isHomePage = url => url.includes('/home') || url.endsWith('/web/') || url.endsWith('/web/index.html');
|
const isHomePage = url => url.includes('/home') || url.endsWith('/web/') || url.endsWith('/web/index.html');
|
||||||
if (isHomePage(window.top.location.href)) {
|
if (isHomePage(window.top.location.href)) {
|
||||||
isHomePageActive = true;
|
isHomePageActive = true;
|
||||||
|
console.log("Homepage detected, starting slideshow");
|
||||||
readCustomList().then(list => {
|
readCustomList().then(list => {
|
||||||
if (list) { movieList = list; currentMovieIndex = 0; }
|
if (list) { movieList = list; currentMovieIndex = 0; }
|
||||||
fetchRandomMovie();
|
fetchRandomMovie();
|
||||||
|
Reference in New Issue
Block a user