From 559893ed6468000ef2891d48061a8b2cef79f89b Mon Sep 17 00:00:00 2001 From: Luis Pereira Date: Sun, 2 Nov 2025 22:18:34 +0000 Subject: [PATCH] fix: redirection when navigating between frameset --- static/js/front-page.js | 37 ++++++++++++++++++++++---------- static/js/player.js | 14 ++++++++++++ template/admin.ctml | 4 ++-- template/front-page-content.ctml | 1 + template/front-page.ctml | 2 +- template/profile.ctml | 4 ++-- template/users.ctml | 2 +- 7 files changed, 47 insertions(+), 17 deletions(-) diff --git a/static/js/front-page.js b/static/js/front-page.js index f21fb68..ff41d5f 100644 --- a/static/js/front-page.js +++ b/static/js/front-page.js @@ -79,13 +79,14 @@ window.addEventListener('DOMContentLoaded', function() { // Set initial quality display to match the selected stream const selector = document.getElementById('stream-quality'); const streamBaseUrl = document.getElementById('stream-base-url'); - const config = getStreamConfig(streamBaseUrl.value, selector.value); - document.getElementById('stream-url').textContent = config.url; - document.getElementById('stream-format').textContent = config.format; - - const statusQuality = document.querySelector('[data-text="stream-quality"]'); - if (statusQuality) { - statusQuality.textContent = config.format; + if (streamBaseUrl && selector) { + const config = getStreamConfig(streamBaseUrl.value, selector.value); + document.getElementById('stream-url').textContent = config.url; + document.getElementById('stream-format').textContent = config.format; + const statusQuality = document.querySelector('[data-text="stream-quality"]'); + if (statusQuality) { + statusQuality.textContent = config.format; + } } // Update playing information right after load updateNowPlaying(); @@ -185,14 +186,28 @@ function disableFramesetMode() { window.location.href = '/asteroid/'; } +function redirectWhenFrame() { + const path = window.location.pathname; + const isFramesetPage = window.parent !== window.self; + const isContentFrame = path.includes('asteroid/content'); + + if (isFramesetPage && !isContentFrame) { + window.location.href = '/asteroid/content'; + } + if (!isFramesetPage && isContentFrame) { + window.location.href = '/asteroid'; + } +} + // Check if user prefers frameset mode on page load window.addEventListener('DOMContentLoaded', function() { const path = window.location.pathname; - const isFramesetPage = path.includes('/frameset') || path.includes('/content') || - path.includes('/audio-player-frame') || path.includes('/player-content'); - - if (localStorage.getItem('useFrameset') === 'true' && !isFramesetPage && path === '/asteroid/') { + const isFramesetPage = window.parent !== window.self; + + if (localStorage.getItem('useFrameset') === 'true' && !isFramesetPage && path.includes('/asteroid')) { // User wants frameset but is on regular front page, redirect window.location.href = '/asteroid/frameset'; } + + redirectWhenFrame(); }); diff --git a/static/js/player.js b/static/js/player.js index dcfcb12..e172720 100644 --- a/static/js/player.js +++ b/static/js/player.js @@ -14,6 +14,7 @@ let filteredLibraryTracks = []; document.addEventListener('DOMContentLoaded', function() { audioPlayer = document.getElementById('audio-player'); + redirectWhenFrame(); loadTracks(); loadPlaylists(); setupEventListeners(); @@ -28,6 +29,19 @@ document.addEventListener('DOMContentLoaded', function() { } }); +function redirectWhenFrame () { + const path = window.location.pathname; + const isFramesetPage = window.parent !== window.self; + const isContentFrame = path.includes('player-content'); + + if (isFramesetPage && !isContentFrame) { + window.location.href = '/asteroid/player-content'; + } + if (!isFramesetPage && isContentFrame) { + window.location.href = '/asteroid/player'; + } +} + function setupEventListeners() { // Search document.getElementById('search-tracks').addEventListener('input', filterTracks); diff --git a/template/admin.ctml b/template/admin.ctml index 5310f18..06012f2 100644 --- a/template/admin.ctml +++ b/template/admin.ctml @@ -12,8 +12,8 @@

🎛️ ADMIN DASHBOARD