23 lines
No EOL
687 B
JavaScript
23 lines
No EOL
687 B
JavaScript
function sendCommand() {
|
|
const input = $("console-command");
|
|
const command = input.value.trim();
|
|
if (!command) return;
|
|
|
|
fetch('/api/command', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ username, command })
|
|
}).then(res => {
|
|
if (!res.ok) throw new Error("Nie udało się wysłać komendy.");
|
|
input.value = '';
|
|
}).catch(err => {
|
|
alert("Błąd wysyłania komendy.");
|
|
console.error(err);
|
|
});
|
|
}
|
|
|
|
function loadLogs() {
|
|
fetch(`/api/logs?username=${username}`)
|
|
.then(r => r.json())
|
|
.then(data => { $("console-log").textContent = data.logs; });
|
|
} |