Files
2026-10-30 05:54:28 +00:00

111 lines
4.5 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<title>AeroMC-Server</title>
<style>
body { font-family: "Segoe UI", sans-serif; font-size: 13px; color: #d8d8d8; background: #2d2d2d; margin: 0; padding: 12px; }
label { display: block; margin-bottom: 4px; color: #a8a8a8; }
select { width: 100%; padding: 6px; background: #3d3d3d; color: #fff; border: 1px solid #555; border-radius: 4px; }
input { width: 100%; box-sizing: border-box; padding: 6px; background: #3d3d3d; color: #fff; border: 1px solid #555; border-radius: 4px; }
.hint { margin-top: 10px; color: #8a8a8a; font-size: 12px; }
</style>
</head>
<body>
<label for="instanz">Instanz</label>
<select id="instanz"><option value="">Lade …</option></select>
<label for="server" style="margin-top:12px">Server dieser Instanz</label>
<select id="server"><option value="">– Instanz wählen –</option></select>
<label for="adresse" style="margin-top:12px">oder Adresse eingeben</label>
<input id="adresse" type="text" placeholder="z. B. mc.example.net:25565" />
<p class="hint" id="hinweis"></p>
<script>
// bei diesen Tasten darf die Instanz leer bleiben (= alle Instanzen)
const OPTIONAL = [];
let ws, uuid, aktion, einstellungen = {}, wiederholung = null;
function frageInstanzen() {
if (ws.readyState !== 1) return;
const id = einstellungen.instanceId;
ws.send(JSON.stringify({ event: 'sendToPlugin', action: aktion, context: uuid, payload: id ? { frage: 'server', id } : { frage: 'instanzen' } }));
}
function speichere() {
ws.send(JSON.stringify({ event: 'setSettings', context: uuid, payload: einstellungen }));
}
function fuelleServer(liste) {
const sel = document.getElementById('server');
sel.innerHTML = '';
const leer = document.createElement('option');
leer.value = ''; leer.textContent = liste.length ? '– bitte wählen –' : 'Keine Server in dieser Instanz';
sel.appendChild(leer);
for (const x of liste) {
const o = document.createElement('option');
o.value = x.ip; o.textContent = (x.name ? x.name + ' – ' : '') + x.ip; o.dataset.name = x.name || '';
sel.appendChild(o);
}
sel.value = liste.some((x) => x.ip === einstellungen.server) ? einstellungen.server : '';
}
function fuelle(p) {
// solange AeroMC nicht erreichbar ist, alle 2 s neu fragen - ein Neuauswählen der Taste ist dann nicht nötig
if (p.erreichbar) { clearInterval(wiederholung); wiederholung = null; }
else if (!wiederholung) wiederholung = setInterval(frageInstanzen, 2000);
const sel = document.getElementById('instanz');
const hinweis = document.getElementById('hinweis');
sel.innerHTML = '';
if (!p.erreichbar) {
sel.innerHTML = '<option value="">AeroMC nicht erreichbar</option>';
hinweis.textContent = 'AeroMC starten und unter Optionen → Allgemein „Stream Deck erlauben“ einschalten. Dieses Fenster aktualisiert sich dann selbst.';
return;
}
hinweis.textContent = '';
const leer = document.createElement('option');
leer.value = ''; leer.textContent = OPTIONAL.includes(aktion) ? 'Alle Instanzen' : '– bitte wählen –';
sel.appendChild(leer);
for (const i of p.instanzen) {
const o = document.createElement('option');
o.value = i.id; o.textContent = i.name;
sel.appendChild(o);
}
sel.value = einstellungen.instanceId || '';
if (p.server) fuelleServer(p.server);
}
function connectElgatoStreamDeckSocket(port, inUUID, registerEvent, info, actionInfo) {
uuid = inUUID;
const a = JSON.parse(actionInfo);
aktion = a.action;
einstellungen = (a.payload && a.payload.settings) || {};
ws = new WebSocket('ws://127.0.0.1:' + port);
ws.onopen = () => {
ws.send(JSON.stringify({ event: registerEvent, uuid }));
frageInstanzen();
};
ws.onmessage = (e) => {
const m = JSON.parse(e.data);
if (m.event === 'sendToPropertyInspector') fuelle(m.payload || {});
};
document.getElementById('adresse').value = einstellungen.adresse || '';
document.getElementById('instanz').addEventListener('change', (ev) => {
einstellungen.instanceId = ev.target.value;
einstellungen.server = ''; einstellungen.serverName = '';
speichere();
fuelleServer([]);
frageInstanzen();
});
document.getElementById('server').addEventListener('change', (ev) => {
einstellungen.server = ev.target.value;
einstellungen.serverName = ev.target.selectedOptions[0] ? ev.target.selectedOptions[0].dataset.name || '' : '';
speichere();
});
document.getElementById('adresse').addEventListener('input', (ev) => {
einstellungen.adresse = ev.target.value.trim();
speichere();
});
}
</script>
</body>
</html>