Update js/meta-handler.js
This commit is contained in:
parent
45a2e0aff9
commit
3a4e69c2a5
1 changed files with 36 additions and 25 deletions
|
|
@ -33,39 +33,40 @@ const MetaHandler = {
|
|||
|
||||
updateUI(title) {
|
||||
const stationDisplay = document.getElementById('current-station-name');
|
||||
const senderContainer = document.getElementById('aktueller-sender');
|
||||
if (!stationDisplay) return;
|
||||
|
||||
// 1. Alles vor dem Songtitel isolieren
|
||||
// 1. ALLES zurücksetzen - radikal
|
||||
stationDisplay.classList.remove('marquee-active');
|
||||
if (senderContainer) {
|
||||
senderContainer.classList.remove('has-marquee');
|
||||
}
|
||||
|
||||
// Reset für saubere Neumessung
|
||||
stationDisplay.classList.remove('marquee-active');
|
||||
if (senderContainer) senderContainer.classList.remove('has-marquee');
|
||||
|
||||
let currentContent = stationDisplay.innerHTML;
|
||||
let stationPart = currentContent.split(' ')[0].split(' <i class="fa-solid fa-music"')[0].trim();
|
||||
|
||||
// 2. Dubletten-Check & Fehler-Filter
|
||||
const tempDiv = document.createElement("div");
|
||||
tempDiv.innerHTML = stationPart;
|
||||
const stationNameOnly = tempDiv.textContent.trim();
|
||||
|
||||
const cleanTitle = title.toLowerCase().trim();
|
||||
const cleanStation = stationNameOnly.toLowerCase();
|
||||
const isErrorTitle = cleanTitle.includes('error code:') || cleanTitle.includes('internal server error') || cleanTitle.includes('500 error');
|
||||
|
||||
// --- NEU: Liste der unerwünschten Titel ---
|
||||
const isErrorTitle = cleanTitle.includes('error code:') ||
|
||||
cleanTitle.includes('internal server error') ||
|
||||
cleanTitle.includes('500 error');
|
||||
|
||||
// Überprüfung auf Dubletten, Telefonnummern ODER Fehlermeldungen
|
||||
if (cleanTitle === cleanStation ||
|
||||
cleanTitle.includes(cleanStation) ||
|
||||
title.includes('0848') ||
|
||||
isErrorTitle) { // <--- Hier wird der Fehler-Filter angewendet
|
||||
|
||||
stationDisplay.innerHTML = stationPart; // Nur Sendername anzeigen
|
||||
if (cleanTitle === cleanStation || cleanTitle.includes(cleanStation) || title.includes('0848') || isErrorTitle) {
|
||||
stationDisplay.innerHTML = stationPart;
|
||||
} else {
|
||||
// 3. Anzeige neu zusammenbauen
|
||||
stationDisplay.innerHTML = `${stationPart} <i class="fa-solid fa-music"></i> ${title}`;
|
||||
}
|
||||
|
||||
// --- LAUFSCHRIFT-ÜBERPRÜFUNG ---
|
||||
setTimeout(() => this.checkMarqueeOverflow(), 50);
|
||||
// Der sichere Aufruf mit Arrow-Function
|
||||
setTimeout(() => {
|
||||
this.checkMarqueeOverflow();
|
||||
}, 150);
|
||||
},
|
||||
|
||||
checkMarqueeOverflow() {
|
||||
|
|
@ -73,14 +74,17 @@ const MetaHandler = {
|
|||
const textElement = document.getElementById('current-station-name');
|
||||
|
||||
if (textElement && senderContainer) {
|
||||
const textWidth = textElement.scrollWidth;
|
||||
const availableWidth = senderContainer.offsetWidth - 30;
|
||||
|
||||
if (textWidth > availableWidth) {
|
||||
senderContainer.classList.add('has-marquee'); // Container links bündig machen
|
||||
setTimeout(() => {
|
||||
textElement.classList.add('marquee-active'); // Animation starten
|
||||
}, 50);
|
||||
} else {
|
||||
textElement.classList.remove('marquee-active');
|
||||
|
||||
// Wir messen die verfügbare Breite im Container abzüglich des Paddings
|
||||
const availableWidth = senderContainer.clientWidth - 20; // 20px Abzug für das seitliche Padding (15px links/rechts)
|
||||
|
||||
// Wenn der Text breiter ist als der verfügbare Platz innen
|
||||
if (textElement.scrollWidth > availableWidth) {
|
||||
textElement.classList.add('marquee-active');
|
||||
senderContainer.classList.remove('has-marquee');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -101,9 +105,16 @@ const MetaHandler = {
|
|||
}
|
||||
|
||||
const stationDisplay = document.getElementById('current-station-name');
|
||||
const senderContainer = document.getElementById('aktueller-sender');
|
||||
|
||||
if (stationDisplay) {
|
||||
stationDisplay.classList.remove('marquee-active');
|
||||
// Hinweis: Der Inhalt wird beim Stoppen meist durch die main.js auf "Wähle einen Sender" zurückgesetzt
|
||||
}
|
||||
|
||||
// NEU: Auch den Container wieder in den Urzustand (zentriert) versetzen
|
||||
if (senderContainer) {
|
||||
senderContainer.classList.remove('has-marquee');
|
||||
senderContainer.style.justifyContent = ''; // Falls ein manueller Style gesetzt wurde
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue