fixxed connect button

This commit is contained in:
oberon 2026-02-16 09:07:41 +01:00
parent 702eba2370
commit 4f96b919be

View File

@ -17,13 +17,13 @@ document.addEventListener('DOMContentLoaded', () => {
if (!connectBtn) {
console.warn('Nicht auf der Steuerseite Connect-Button nicht gefunden');
return;
// Dennoch Status und Soundboard-Logik initialisieren (falls vorhanden)
}
// ── Config aus Template ────────────────────────────────────────────────────
// ── Config & globale Sounds aus Template ──────────────────────────────────
const config = {{ config | tojson | safe }};
const globalSounds = {{ global_sounds | tojson | safe }};
window.mkConfig = config; // global für Konsistenz
window.mkConfig = config; // global vergbar
console.log("Config im JS:", config);
console.log("Globale Sounds:", globalSounds);
@ -85,6 +85,7 @@ document.addEventListener('DOMContentLoaded', () => {
});
// ── Connect-Button ────────────────────────────────────────────────────────
if (connectBtn) {
connectBtn.addEventListener('click', async () => {
connectBtn.disabled = true;
connectBtn.innerHTML = '<span class="spinner-border spinner-border-sm me-2" role="status" aria-hidden="true"></span> Verbinde...';
@ -127,6 +128,7 @@ document.addEventListener('DOMContentLoaded', () => {
connectBtn.innerHTML = '<i class="bi bi-bluetooth me-2"></i> Mit Hub verbinden';
}
});
}
// ── Alle stoppen ──────────────────────────────────────────────────────────
if (stopAllBtn) {
@ -301,7 +303,7 @@ document.addEventListener('DOMContentLoaded', () => {
});
});
// ── Event-Listener Toggle-Buttons (Licht/Sound/Fogger) ──────────────────
// ── Event-Listener Toggle-Buttons ──────────────────────────────────────
document.querySelectorAll('.toggle-btn').forEach(btn => {
btn.addEventListener('click', async () => {
const current = btn.dataset.state;
@ -335,7 +337,6 @@ document.addEventListener('DOMContentLoaded', () => {
}
} catch (err) {
console.error('sendControl Fehler:', err);
// Bei Fehler: Verbindungsprüfung triggern
updateStatus(false, 'Fehler beim Senden');
}
}
@ -355,7 +356,6 @@ document.addEventListener('DOMContentLoaded', () => {
btn.addEventListener('click', async () => {
const soundId = btn.dataset.soundId;
// Alten Play-Button zurücksetzen
if (currentSoundButton && currentSoundButton !== btn) {
currentSoundButton.classList.remove('btn-success');
currentSoundButton.classList.add('btn-outline-primary', 'btn-outline-secondary');
@ -395,7 +395,7 @@ document.addEventListener('DOMContentLoaded', () => {
});
});
// ── Stop-Button für aktuellen Sound
// ── Stop-Button für aktuellen Sound ────────────────────────────────────────
document.querySelectorAll('.stop-sound-btn').forEach(btn => {
btn.addEventListener('click', async () => {
try {
@ -420,7 +420,7 @@ document.addEventListener('DOMContentLoaded', () => {
});
});
// ── Volume-Regler
// ── Volume-Regler ──────────────────────────────────────────────────────────
if (volumeSlider && volumeDisplay) {
volumeSlider.addEventListener('input', () => {
const vol = volumeSlider.value / 100;