This repository has been archived by the owner on May 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
682aebb
commit 683061d
Showing
6 changed files
with
164 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,87 +5,19 @@ | |
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<link rel="icon" href="/assets/terminal.ico?v=1"> | ||
<title>atx-agent terminal</title> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/xterm.min.css"> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/addons/fullscreen/fullscreen.min.css"> | ||
<style> | ||
* { | ||
margin: 0; | ||
} | ||
|
||
html, | ||
body { | ||
height: 100%; | ||
} | ||
|
||
#xterm { | ||
height: 100%; | ||
background-color: black; | ||
padding-left: 5px; | ||
} | ||
</style> | ||
<title>ATX-Agent</title> | ||
</head> | ||
|
||
<body> | ||
<div id="xterm"></div> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/xterm.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/addons/fit/fit.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/addons/fullscreen/fullscreen.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/jquery.ba-resize.min.js"></script> | ||
<script> | ||
var term; | ||
var websocket = new WebSocket("ws://" + location.host + "/term"); | ||
websocket.binaryType = "arraybuffer"; | ||
|
||
function ab2str(buf) { | ||
return String.fromCharCode.apply(null, new Uint8Array(buf)); | ||
} | ||
websocket.onopen = function(evt) { | ||
term = new Terminal({ | ||
screenKeys: true, | ||
useStyle: true, | ||
cursorBlink: true, | ||
}); | ||
|
||
term.on('data', function(data) { | ||
websocket.send(new TextEncoder().encode("\x00" + data)); | ||
}); | ||
term.on('resize', function(evt) { | ||
websocket.send(new TextEncoder().encode("\x01" + JSON.stringify({ | ||
cols: evt.cols, | ||
rows: evt.rows | ||
}))) | ||
}); | ||
term.on('title', function(title) { | ||
document.title = title; | ||
}); | ||
|
||
term.open(document.getElementById('xterm')); | ||
term.fit(); | ||
$("#xterm").resize(function() { | ||
term.fit() | ||
}) | ||
|
||
websocket.onmessage = function(evt) { | ||
if (evt.data instanceof ArrayBuffer) { | ||
term.write(ab2str(evt.data)); | ||
} else { | ||
alert(evt.data) | ||
} | ||
} | ||
websocket.onclose = function(evt) { | ||
term.write("Session terminated"); | ||
term.destroy(); | ||
} | ||
websocket.onerror = function(evt) { | ||
if (typeof console.log == "function") { | ||
console.log(evt) | ||
} | ||
} | ||
} | ||
</script> | ||
<h1>Hello ATX-Agent</h1> | ||
<ul> | ||
<li> | ||
<a href="/term">Web terminal</a> | ||
</li> | ||
<li> | ||
<a href="/info">API /info</a> | ||
</li> | ||
</ul> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<!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"> | ||
<link rel="icon" href="/assets/terminal.ico?v=1"> | ||
<title>atx-agent terminal</title> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/xterm.min.css"> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/addons/fullscreen/fullscreen.min.css"> | ||
<style> | ||
* { | ||
margin: 0; | ||
} | ||
|
||
html, | ||
body { | ||
height: 100%; | ||
} | ||
|
||
#xterm { | ||
height: 100%; | ||
background-color: black; | ||
padding-left: 5px; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<div id="xterm"></div> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/xterm.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/addons/fit/fit.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/addons/fullscreen/fullscreen.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/jquery.ba-resize.min.js"></script> | ||
<script> | ||
var term; | ||
var websocket = new WebSocket("ws://" + location.host + "/term"); | ||
websocket.binaryType = "arraybuffer"; | ||
|
||
function ab2str(buf) { | ||
return String.fromCharCode.apply(null, new Uint8Array(buf)); | ||
} | ||
websocket.onopen = function(evt) { | ||
term = new Terminal({ | ||
screenKeys: true, | ||
useStyle: true, | ||
cursorBlink: true, | ||
}); | ||
|
||
term.on('data', function(data) { | ||
websocket.send(new TextEncoder().encode("\x00" + data)); | ||
}); | ||
term.on('resize', function(evt) { | ||
websocket.send(new TextEncoder().encode("\x01" + JSON.stringify({ | ||
cols: evt.cols, | ||
rows: evt.rows | ||
}))) | ||
}); | ||
term.on('title', function(title) { | ||
document.title = title; | ||
}); | ||
|
||
term.open(document.getElementById('xterm')); | ||
term.fit(); | ||
$("#xterm").resize(function() { | ||
term.fit() | ||
}) | ||
|
||
websocket.onmessage = function(evt) { | ||
if (evt.data instanceof ArrayBuffer) { | ||
term.write(ab2str(evt.data)); | ||
} else { | ||
alert(evt.data) | ||
} | ||
} | ||
websocket.onclose = function(evt) { | ||
term.write("Session terminated"); | ||
term.destroy(); | ||
} | ||
websocket.onerror = function(evt) { | ||
if (typeof console.log == "function") { | ||
console.log(evt) | ||
} | ||
} | ||
} | ||
</script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters