From d55d1c4ecf425e0db3c60790d9a40e80e91cdd11 Mon Sep 17 00:00:00 2001 From: simonpipe Date: Mon, 6 Jan 2025 08:51:50 +0000 Subject: [PATCH] script.js aktualisiert Stopp Button in die Titelzeile verlegt, als Symbol dargestellt und wird nur angezeigt, wenn auch ein Sender abgespielt wird. Header Bereich nur immer fix oben sichtbar. --- script.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/script.js b/script.js index 17b02f6..b02b127 100644 --- a/script.js +++ b/script.js @@ -54,7 +54,6 @@ document.addEventListener('DOMContentLoaded', function () { return; } - // URL-Validierung: Prüfen, ob die URL mit http:// oder https:// beginnt if (!isValidHttpUrl(presetUrl)) { alert("Bitte geben Sie eine gültige HTTP- oder HTTPS-URL ein."); return; @@ -63,27 +62,26 @@ document.addEventListener('DOMContentLoaded', function () { addNewPreset(presetName, presetUrl); savePresetToLocalStorage(presetName, presetUrl); - // Felder zurücksetzen newPresetNameInput.value = ''; newPresetUrlInput.value = ''; }); - // Hilfsfunktion zur Überprüfung von URLs - function isValidHttpUrl(url) { - try { - const parsedUrl = new URL(url); - return parsedUrl.protocol === "http:" || parsedUrl.protocol === "https:"; - } catch (e) { - return false; - } - } - exportButton.addEventListener('click', exportPresets); importButton.addEventListener('click', importPresets); loadPresetsLink.addEventListener('click', loadPresetsFromFile); stopButton.addEventListener('click', stopPlayback); } + // === Funktion: URL-Validierung === + function isValidHttpUrl(url) { + try { + const parsedUrl = new URL(url); + return parsedUrl.protocol === "http:" || parsedUrl.protocol === "https:"; + } catch (e) { + return false; + } + } + // === Funktion: Preset-Handling === function loadExistingPresets() { const presets = JSON.parse(localStorage.getItem('presets')) || []; @@ -172,9 +170,10 @@ document.addEventListener('DOMContentLoaded', function () { item.appendChild(audioElement); item.classList.add('playing'); currentPlayingItem = item; - currentStationName.textContent = item.querySelector('h3').textContent; + currentStationName.textContent = 'Es läuft: ' + item.querySelector('h3').textContent; - updateTitle(item.querySelector('h3').textContent); // Sendername in den Titel einfügen + stopButton.classList.remove('hidden'); // Stopp-Button einblenden + updateTitle(item.querySelector('h3').textContent); } function stopPlayback() { @@ -185,10 +184,11 @@ document.addEventListener('DOMContentLoaded', function () { audioElement.currentTime = 0; currentPlayingItem.classList.remove('playing'); currentPlayingItem = null; - currentStationName.textContent = 'Kein Sender ausgewählt.'; + currentStationName.textContent = 'Wähle einen Sender aus'; } } + stopButton.classList.add('hidden'); // Stopp-Button ausblenden updateTitle(''); }