@p.aleks/ajaxterm-ws
v1.0.1
Published
DEPRECATED. WebSocket fork of Ajaxterm that allows connecting to remote SSH servers.
Downloads
7
Readme
DEPRECATED
Do not use in new projects.
Fork of @kohsuke/ajaxterm4j version, replaced ajax with WebSocket.
Original author Antony Lesuisse Ajaxterm.
Ajaxterm was written by Antony Lesuisse (email: al AT udev.org), License Public Domain.
Usage
Specify WebSocket endpoint
import { terminal } from "@p.aleks/ajaxterm-ws";
function getEndpoint() {
return `wss://localhost:300/`
}
terminal('term', {
width: window.innerWidth,
height: window.innerHeight,
getEndpoint: getEndpoint
});
or
<!DOCTYPE html>
<html lang="en">
<head>
<title>Terminal</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="index.css">
<script src="index.js"></script>
</head>
<body style="background-color:#888">
<div id="term" class="ajaxterm"></div>
<script>
window.onload = function () {
function getEndpoint() {
const loc = document.location;
const host = loc.hostname;
const port = loc.port;
const ws_protocol = loc.protocol === 'https:' ? 'wss' : 'ws';
return `${ws_protocol}://${host}:${port}/`
}
ajaxterm.terminal('term', {
width: window.innerWidth,
height: window.innerHeight,
getEndpoint: getEndpoint
});
};
</script>
</body>
</html>