socktop-webterm/static/term.html
2019-03-29 10:55:49 -04:00

48 lines
1.3 KiB
HTML

<!doctype html>
<!--
Copyright (c) 2019 Fabian Freyer <fabian.freyer@physik.tu-berlin.de>
SPDX-License-Identifier: BSD-3-Clause
-->
<html>
<head>
<meta charset="UTF-8" />
<link rel="stylesheet" href="static/xterm/dist/xterm.css" />
<script src="static/xterm/dist/xterm.js"></script>
<script src="static/xterm/dist/addons/attach/attach.js"></script>
<script src="static/xterm/dist/addons/terminado/terminado.js"></script>
<script src="static/xterm/dist/addons/fit/fit.js"></script>
<script src="static/xterm/dist/addons/search/search.js"></script>
<style>
body {
margin: 0;
}
html, body, #terminal {
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<div id="terminal"></div>
<script>
Terminal.applyAddon(terminado);
Terminal.applyAddon(fit);
Terminal.applyAddon(search);
var term = new Terminal();
var protocol = (location.protocol === 'https:') ? 'wss://' : 'ws://';
var socketURL = protocol + location.hostname + ((location.port) ? (':' + location.port) : '') + "/websocket";
var sock = new WebSocket(socketURL);
sock.addEventListener('open', function() {
term.terminadoAttach(sock);
term.fit();
});
term.open(document.getElementById('terminal'));
window.onresize = function() {term.fit();};
</script>
</body>
</html>