Files
seal/templates/k8s/k8s-pod-webssh.html
2019-06-10 17:12:53 +08:00

53 lines
1.1 KiB
Python

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>django webssh 例子</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/xterm/3.13.2/xterm.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="terms"></div>
</body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/xterm/3.13.2/xterm.js"></script>
<script>
var socket = new WebSocket('ws://' + window.location.host + '/ws/{{ name }}/{{ namespace }}');
socket.onopen = function () {
var term = new Terminal();
term.open(document.getElementById('terms'));
term.on('data', function (data) {
console.log(data);
socket.send(data);
});
socket.onmessage = function (msg) {
console.log(msg);
console.log(msg.data);
term.write(msg.data);
};
socket.onerror = function (e) {
console.log(e);
};
socket.onclose = function (e) {
console.log(e);
term.destroy();
};
};
</script>
</html>