2019-09-03 15:04:18 +02:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
2019-09-03 16:15:30 +02:00
|
|
|
<title>bash</title>
|
|
|
|
<link rel="stylesheet" href="/node_modules/xterm/dist/xterm.css" />
|
|
|
|
<link rel="stylesheet" href="/node_modules/xterm/dist/addons/fullscreen/fullscreen.css" />
|
|
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/es6-promise/4.1.1/es6-promise.auto.min.js"></script>
|
|
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/fetch/1.0.0/fetch.min.js"></script>
|
|
|
|
<script src="/node_modules/xterm/dist/xterm.js"></script>
|
|
|
|
<script src="/node_modules/xterm/dist/addons/fit/fit.js"></script>
|
|
|
|
<script src="/node_modules/xterm/dist/addons/attach/attach.js"></script>
|
|
|
|
<script src="/node_modules/xterm/dist/addons/winptyCompat/winptyCompat.js"></script>
|
2019-09-03 15:04:18 +02:00
|
|
|
</head>
|
|
|
|
<body>
|
2019-09-03 16:15:30 +02:00
|
|
|
<div id="terminal"></div>
|
2019-09-03 15:04:18 +02:00
|
|
|
<script>
|
2019-09-03 16:15:30 +02:00
|
|
|
// No idea what these are about. Just copied them from the demo code
|
|
|
|
Terminal.applyAddon(attach);
|
|
|
|
Terminal.applyAddon(fit);
|
|
|
|
Terminal.applyAddon(winptyCompat);
|
|
|
|
// The terminal
|
|
|
|
const term = new Terminal();
|
|
|
|
// No idea what this does
|
|
|
|
term.winptyCompatInit();
|
|
|
|
// This kinda makes sense
|
|
|
|
const container = document.getElementById('terminal');
|
|
|
|
term.open(container);
|
|
|
|
// Open the websocket connection to the backend
|
|
|
|
const protocol = (location.protocol === 'https:') ? 'wss://' : 'ws://';
|
|
|
|
const port = location.port ? `:${location.port}` : '';
|
|
|
|
const socketUrl = `${protocol}${location.hostname}${port}/shell`;
|
|
|
|
const socket = new WebSocket(socketUrl);
|
|
|
|
// Attach the socket to the terminal
|
|
|
|
socket.onopen = (ev) => { term.attach(socket); };
|
|
|
|
// Not going to worry about close/error for the websocket
|
2019-09-03 15:04:18 +02:00
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|