test
This commit is contained in:
parent
16f7aefb82
commit
e45936b53f
@ -280,11 +280,57 @@ export function ActionItem(p: { action: ActionInfo, identifierSubstring?: string
|
|||||||
content="A site to manage game servers built with react and go using docker"
|
content="A site to manage game servers built with react and go using docker"
|
||||||
/>
|
/>
|
||||||
<title>Server Manager</title>
|
<title>Server Manager</title>
|
||||||
|
|
||||||
<script src="xterm/lib/xterm.js"></script>
|
<script src="xterm/lib/xterm.js"></script>
|
||||||
|
<script src="xterm-addon-fit/lib/xterm-addon-fit.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
|
<script>
|
||||||
|
|
||||||
|
window.onload = function() {
|
||||||
|
const Terminal = window.Terminal;
|
||||||
|
const FitAddon = window.FitAddon;
|
||||||
|
const terminalContainer = document.getElementById('terminal-container');
|
||||||
|
|
||||||
|
const terminal = new Terminal();
|
||||||
|
const fitAddon = new FitAddon();
|
||||||
|
terminal.loadAddon(fitAddon);
|
||||||
|
terminal.open(terminalContainer);
|
||||||
|
fitAddon.fit();
|
||||||
|
|
||||||
|
if (websocket) {
|
||||||
|
const socket = new WebSocket("`+websocket+`");
|
||||||
|
|
||||||
|
socket.onerror = (ev) => {
|
||||||
|
console.log(ev);
|
||||||
|
};
|
||||||
|
|
||||||
|
socket.addEventListener('open', () => {
|
||||||
|
socket.send(JSON.stringify({ CommandType: 'resize', Arguments: \`\${terminal.cols}x\`\${terminal.rows} }));
|
||||||
|
});
|
||||||
|
|
||||||
|
terminal.onResize(({ cols, rows }) => {
|
||||||
|
socket.send(JSON.stringify({ CommandType: 'resize', Arguments: \`\${cols}x\`\${rows} }));
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.addEventListener('message', (event) => {
|
||||||
|
terminal.write(JSON.parse(event.data));
|
||||||
|
});
|
||||||
|
|
||||||
|
terminal.onData((data) => {
|
||||||
|
socket.send(JSON.stringify({ CommandType: 'insert', Arguments: data }));
|
||||||
|
});
|
||||||
|
|
||||||
|
window.addEventListener('beforeunload', () => {
|
||||||
|
socket.close();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener('resize', () => {
|
||||||
|
fitAddon.fit();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
`)
|
`)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user