mirror of
https://github.com/yudai/gotty.git
synced 2025-09-21 21:40:49 +02:00
Initialize repository
This commit is contained in:
commit
cba86dd046
91 changed files with 8966 additions and 0 deletions
52
resources/gotty.js
Normal file
52
resources/gotty.js
Normal file
|
@ -0,0 +1,52 @@
|
|||
(function() {
|
||||
var httpsEnabled = window.location.protocol == "https:";
|
||||
var url = (httpsEnabled ? 'wss://' : 'ws://') + window.location.host + window.location.pathname + 'ws';
|
||||
var protocols = ["gotty"];
|
||||
var ws = new WebSocket(url, protocols);
|
||||
|
||||
var term;
|
||||
|
||||
|
||||
ws.onopen = function(event) {
|
||||
hterm.defaultStorage = new lib.Storage.Local()
|
||||
|
||||
term = new hterm.Terminal();
|
||||
|
||||
term.onTerminalReady = function() {
|
||||
var io = term.io.push();
|
||||
|
||||
io.onVTKeystroke = function(str) {
|
||||
ws.send("0" + str);
|
||||
};
|
||||
|
||||
io.sendString = io.onVTKeystroke;
|
||||
|
||||
io.onTerminalResize = function(columns, rows) {
|
||||
ws.send(
|
||||
"1" + JSON.stringify(
|
||||
{
|
||||
name: "resize_terminal",
|
||||
arguments: {
|
||||
columns: columns,
|
||||
rows: rows,
|
||||
},
|
||||
}
|
||||
)
|
||||
)
|
||||
};
|
||||
|
||||
term.installKeyboard();
|
||||
};
|
||||
|
||||
term.decorate(document.body);
|
||||
};
|
||||
|
||||
ws.onmessage = function(event) {
|
||||
term.io.writeUTF16(event.data);
|
||||
}
|
||||
|
||||
ws.onclose = function(event) {
|
||||
term.io.print("Connection closed.");
|
||||
term.uninstallKeyboard();
|
||||
}
|
||||
})()
|
11
resources/index.html
Normal file
11
resources/index.html
Normal file
|
@ -0,0 +1,11 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>GoTTy</title>
|
||||
<style>body {height: 100%; width: 100%; margin: 0px;}</style>
|
||||
</head>
|
||||
<body>
|
||||
<script src="hterm.js"></script>
|
||||
<script src="gotty.js"></script>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue