File size: 852 Bytes
402d195
fafa3f8
402d195
 
 
 
 
 
 
599878e
fafa3f8
402d195
 
 
fafa3f8
 
599878e
fafa3f8
 
402d195
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
document.addEventListener('DOMContentLoaded', function() {
    const socket = io.connect('http://' + document.domain + ':' + location.port + '/terminal');
    const input = document.getElementById('terminal-input');
    const output = document.getElementById('terminal-output');

    input.addEventListener('keypress', function(e) {
        if (e.key === 'Enter') {
            const command = input.value;
            output.innerHTML += `<div><span class="prompt">$</span> ${command}</div>`;
            console.log(`Sending command: ${command}`); // Debugging log
            socket.emit('input', {command: command});
            input.value = '';
        }
    });

    socket.on('output', function(data) {
        console.log(`Received output: ${data.output}`); // Debugging log
        output.innerHTML += `<div>${data.output}</div>`;
    });
});