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) {
|
updateUI(title) {
|
||||||
const stationDisplay = document.getElementById('current-station-name');
|
const stationDisplay = document.getElementById('current-station-name');
|
||||||
|
const senderContainer = document.getElementById('aktueller-sender');
|
||||||
if (!stationDisplay) return;
|
if (!stationDisplay) return;
|
||||||
|
|
||||||
|
// 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');
|
||||||
|
|
||||||
// 1. Alles vor dem Songtitel isolieren
|
|
||||||
let currentContent = stationDisplay.innerHTML;
|
let currentContent = stationDisplay.innerHTML;
|
||||||
let stationPart = currentContent.split(' ')[0].split(' <i class="fa-solid fa-music"')[0].trim();
|
let stationPart = currentContent.split(' ')[0].split(' <i class="fa-solid fa-music"')[0].trim();
|
||||||
|
|
||||||
// 2. Dubletten-Check & Fehler-Filter
|
|
||||||
const tempDiv = document.createElement("div");
|
const tempDiv = document.createElement("div");
|
||||||
tempDiv.innerHTML = stationPart;
|
tempDiv.innerHTML = stationPart;
|
||||||
const stationNameOnly = tempDiv.textContent.trim();
|
const stationNameOnly = tempDiv.textContent.trim();
|
||||||
|
|
||||||
const cleanTitle = title.toLowerCase().trim();
|
const cleanTitle = title.toLowerCase().trim();
|
||||||
const cleanStation = stationNameOnly.toLowerCase();
|
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 ---
|
if (cleanTitle === cleanStation || cleanTitle.includes(cleanStation) || title.includes('0848') || isErrorTitle) {
|
||||||
const isErrorTitle = cleanTitle.includes('error code:') ||
|
stationDisplay.innerHTML = stationPart;
|
||||||
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
|
|
||||||
} else {
|
} else {
|
||||||
// 3. Anzeige neu zusammenbauen
|
|
||||||
stationDisplay.innerHTML = `${stationPart} <i class="fa-solid fa-music"></i> ${title}`;
|
stationDisplay.innerHTML = `${stationPart} <i class="fa-solid fa-music"></i> ${title}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- LAUFSCHRIFT-ÜBERPRÜFUNG ---
|
// Der sichere Aufruf mit Arrow-Function
|
||||||
setTimeout(() => this.checkMarqueeOverflow(), 50);
|
setTimeout(() => {
|
||||||
|
this.checkMarqueeOverflow();
|
||||||
|
}, 150);
|
||||||
},
|
},
|
||||||
|
|
||||||
checkMarqueeOverflow() {
|
checkMarqueeOverflow() {
|
||||||
|
|
@ -73,14 +74,17 @@ const MetaHandler = {
|
||||||
const textElement = document.getElementById('current-station-name');
|
const textElement = document.getElementById('current-station-name');
|
||||||
|
|
||||||
if (textElement && senderContainer) {
|
if (textElement && senderContainer) {
|
||||||
textElement.classList.remove('marquee-active');
|
const textWidth = textElement.scrollWidth;
|
||||||
|
const availableWidth = senderContainer.offsetWidth - 30;
|
||||||
|
|
||||||
// Wir messen die verfügbare Breite im Container abzüglich des Paddings
|
if (textWidth > availableWidth) {
|
||||||
const availableWidth = senderContainer.clientWidth - 20; // 20px Abzug für das seitliche Padding (15px links/rechts)
|
senderContainer.classList.add('has-marquee'); // Container links bündig machen
|
||||||
|
setTimeout(() => {
|
||||||
// Wenn der Text breiter ist als der verfügbare Platz innen
|
textElement.classList.add('marquee-active'); // Animation starten
|
||||||
if (textElement.scrollWidth > availableWidth) {
|
}, 50);
|
||||||
textElement.classList.add('marquee-active');
|
} else {
|
||||||
|
textElement.classList.remove('marquee-active');
|
||||||
|
senderContainer.classList.remove('has-marquee');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -101,9 +105,16 @@ const MetaHandler = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const stationDisplay = document.getElementById('current-station-name');
|
const stationDisplay = document.getElementById('current-station-name');
|
||||||
|
const senderContainer = document.getElementById('aktueller-sender');
|
||||||
|
|
||||||
if (stationDisplay) {
|
if (stationDisplay) {
|
||||||
stationDisplay.classList.remove('marquee-active');
|
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