fixxes soundboard auto-start
This commit is contained in:
@@ -50,7 +50,6 @@
|
||||
const content = document.getElementById('sb-content');
|
||||
|
||||
let currentSB = null;
|
||||
let autoTimer = null;
|
||||
const statusBox = (msg, type='info') => {
|
||||
console.log(msg);
|
||||
};
|
||||
@@ -80,6 +79,7 @@
|
||||
renderBackgrounds(sb.backgrounds || []);
|
||||
renderSounds(sb.sounds || []);
|
||||
renderRandom(sb.random_pool || []);
|
||||
updateAutoStatus();
|
||||
}
|
||||
|
||||
function renderBackgrounds(list) {
|
||||
@@ -169,7 +169,11 @@
|
||||
});
|
||||
const data = await res.json();
|
||||
if (data.success) {
|
||||
status.textContent = `Aktiv (nächster in ${(data.next_seconds/60).toFixed(1)} min)`;
|
||||
if (data.next_seconds !== undefined && data.next_seconds !== null) {
|
||||
status.textContent = `Aktiv (nächster in ${(data.next_seconds/60).toFixed(1)} min)`;
|
||||
} else {
|
||||
status.textContent = 'Aktiv';
|
||||
}
|
||||
start.disabled = true;
|
||||
stop.disabled = false;
|
||||
} else {
|
||||
@@ -188,6 +192,33 @@
|
||||
};
|
||||
}
|
||||
|
||||
async function updateAutoStatus() {
|
||||
const res = await fetch('/api/soundboard/status');
|
||||
const data = await res.json();
|
||||
const status = document.getElementById('auto-status');
|
||||
const start = document.getElementById('auto-start');
|
||||
const stop = document.getElementById('auto-stop');
|
||||
if (!status || !start || !stop) return;
|
||||
if (data.active) {
|
||||
if (data.next_seconds !== null && data.next_seconds !== undefined) {
|
||||
status.textContent = `Aktiv (nächster in ${(data.next_seconds/60).toFixed(1)} min)`;
|
||||
} else {
|
||||
status.textContent = 'Aktiv';
|
||||
}
|
||||
start.disabled = true;
|
||||
stop.disabled = false;
|
||||
// optional: Formularwerte mit Serverparametern füllen
|
||||
if (data.interval_min) document.getElementById('auto-interval-min').value = data.interval_min;
|
||||
if (data.interval_max) document.getElementById('auto-interval-max').value = data.interval_max;
|
||||
if (data.delay_min !== undefined && data.delay_min !== null) document.getElementById('auto-delay-min').value = data.delay_min;
|
||||
if (data.delay_max !== undefined && data.delay_max !== null) document.getElementById('auto-delay-max').value = data.delay_max;
|
||||
} else {
|
||||
status.textContent = 'Aus';
|
||||
start.disabled = false;
|
||||
stop.disabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
async function playSound(sound) {
|
||||
const payload = {
|
||||
sound_id: sound.id || sound.file,
|
||||
@@ -240,6 +271,8 @@
|
||||
// Autoload erstes Thema (falls vorhanden)
|
||||
if (selectEl && selectEl.value) {
|
||||
loadSoundboard(selectEl.value);
|
||||
} else {
|
||||
updateAutoStatus();
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user