Added client-side

This commit is contained in:
BuildTools 2019-09-03 15:04:18 +02:00
parent 3b89fdef60
commit 0bf0b9d0a5
2 changed files with 31 additions and 1 deletions

30
index.html Normal file
View File

@ -0,0 +1,30 @@
<!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">
<title>webssh_plus</title>
<script src="/socket.io/socket.io.js"></script>
</head>
<body>
<script>
// Connect to the socket.io server
var socket = io.connect('http://localhost:8080');
// Wait for data from the server
socket.on('output', function (data) {
// Insert some line breaks where they belong
data = data.replace("n", "");
data = data.replace("r", "");
// Append the data to our terminal
$('.terminal').append(data);
});
// Listen for user input and pass it to the server
$(document).on("keypress",function(e){
var char = String.fromCharCode(e.which);
socket.emit("input", char);
});
</script>
</body>
</html>

View File

@ -4,7 +4,7 @@ var express = require('express');
var https = require('https'); var https = require('https');
var http = require('http'); var http = require('http');
var fs = require('fs'); var fs = require('fs');
var pty = require('pty.js'); var pty = require('node-pty');
// Set up express server // Set up express server
let app = express(); let app = express();