do some stuff again

This commit is contained in:
Bruno Rybársky 2022-06-12 12:41:52 +02:00
parent 204d55d514
commit 6d102d8512
23 changed files with 478 additions and 113 deletions

6
.vscode/tasks.json vendored

@ -5,7 +5,11 @@
{
"label": "Compile TypeScript",
"type": "shell",
"command": "npx tsc",
//make sure to run the other task
"dependsOn": [
"Compile TypeScript for web"
],
"command": "npx tsc -p tsconfig.json",
"group": "build",
"presentation": {
"reveal": "always"

9
commands/beep.js Normal file

@ -0,0 +1,9 @@
"use strict";
exports.__esModule = true;
exports.beep = void 0;
function beep(socket) {
socket.emit("bell");
return "Beeped\n";
}
exports.beep = beep;
//# sourceMappingURL=beep.js.map

1
commands/beep.js.map Normal file

@ -0,0 +1 @@
{"version":3,"file":"beep.js","sourceRoot":"","sources":["beep.ts"],"names":[],"mappings":";;;AACA,SAAS,IAAI,CAAC,MAAa;IACvB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACpB,OAAO,UAAU,CAAA;AACrB,CAAC;AACO,oBAAI"}

6
commands/beep.ts Normal file

@ -0,0 +1,6 @@
import {Socket} from "socket.io";
function beep(socket:Socket):string{
socket.emit("bell");
return "Beeped\n"
}
export {beep};

@ -2,6 +2,7 @@
exports.__esModule = true;
exports.resolveCommand = void 0;
var append_1 = require("./append");
var beep_1 = require("./beep");
var cat_1 = require("./cat");
var cd_1 = require("./cd");
var clear_1 = require("./clear");
@ -24,81 +25,98 @@ var spam_1 = require("./spam");
var touch_1 = require("./touch");
var wee_1 = require("./wee");
var woo_1 = require("./woo");
function sendbuffer(socket, bufferx, forcefulload) {
var bufx = bufferx[socket.id];
bufx += "\u2588";
if (forcefulload) {
socket.emit('buffer', bufx);
}
else {
socket.emit('bufferx', bufx);
}
}
function resolveCommand(commandname, socket, args, buffer, sessions, filesystem, curdir, curdirx) {
var bufko = "";
switch (commandname) {
case "help":
buffer[socket.id] += (0, help_1.help)();
bufko += (0, help_1.help)();
break;
case "man":
buffer[socket.id] += (0, man_1.man)(args);
bufko += (0, man_1.man)(args);
break;
case "beep":
bufko += (0, beep_1.beep)(socket);
break;
case "screenshot":
buffer[socket.id] += (0, screenshot_1.screenshot)(args, curdir, buffer, socket);
bufko += (0, screenshot_1.screenshot)(args, curdir, buffer, socket);
break;
case "append":
buffer[socket.id] += (0, append_1.append)(args, curdir[socket.id]);
bufko += (0, append_1.append)(args, curdir[socket.id]);
break;
case "overwrite":
buffer[socket.id] += (0, overwrite_1.overwrite)(args, curdir[socket.id]);
bufko += (0, overwrite_1.overwrite)(args, curdir[socket.id]);
break;
case "rm":
buffer[socket.id] += (0, rm_1.rm)(args, curdir, socket);
bufko += (0, rm_1.rm)(args, curdir, socket);
break;
case "mv":
buffer[socket.id] += (0, mv_1.mv)(args, curdir[socket.id]);
bufko += (0, mv_1.mv)(args, curdir[socket.id]);
break;
case "cp":
buffer[socket.id] += (0, cp_1.cp)(args, curdir[socket.id]);
bufko += (0, cp_1.cp)(args, curdir[socket.id]);
break;
case "mkdir":
buffer[socket.id] += (0, mkdir_1.mkdir)(args, curdir[socket.id]);
bufko += (0, mkdir_1.mkdir)(args, curdir[socket.id]);
break;
case "rmdir":
buffer[socket.id] += (0, rmdir_1.rmdir)(args, curdir, socket);
bufko += (0, rmdir_1.rmdir)(args, curdir, socket);
break;
case "touch":
buffer[socket.id] += (0, touch_1.touch)(args, curdir, socket);
bufko += (0, touch_1.touch)(args, curdir, socket);
break;
case "cat":
buffer[socket.id] += (0, cat_1.cat)(args, curdir[socket.id]);
bufko += (0, cat_1.cat)(args, curdir[socket.id]);
break;
case "exec":
buffer[socket.id] += (0, exec_1.exec)(args, curdir, socket, buffer, sessions, filesystem, curdirx);
bufko += (0, exec_1.exec)(args, curdir, socket, buffer, sessions, filesystem, curdirx);
break;
case "ls":
buffer[socket.id] += (0, ls_1.ls)(curdir[socket.id]);
bufko += (0, ls_1.ls)(curdir[socket.id]);
break;
case "cd":
buffer[socket.id] += (0, cd_1.cd)(args, curdir, socket, filesystem, curdirx);
bufko += (0, cd_1.cd)(args, curdir, socket, filesystem, curdirx);
break;
case "pwd":
buffer[socket.id] += (0, pwd_1.pwd)(curdirx[socket.id]);
bufko += (0, pwd_1.pwd)(curdirx[socket.id]);
break;
case "echo":
buffer[socket.id] += (0, echo_1.echo)(args);
bufko += (0, echo_1.echo)(args);
break;
case "clear":
buffer[socket.id] += (0, clear_1.clear)(buffer[socket.id]);
bufko += (0, clear_1.clear)(buffer[socket.id]);
break;
case "savesess":
buffer[socket.id] += (0, savesess_1.savesess)(args, sessions, filesystem, curdir, buffer, socket);
bufko += (0, savesess_1.savesess)(args, sessions, filesystem, curdir, buffer, socket);
break;
case "loadsess":
buffer[socket.id] += (0, loadsess_1.loadsess)(args, sessions, filesystem[socket.id], curdir[socket.id], buffer[socket.id]);
bufko += (0, loadsess_1.loadsess)(args, sessions, filesystem[socket.id], curdir[socket.id], buffer[socket.id]);
break;
case "wee":
buffer[socket.id] += (0, wee_1.wee)();
bufko += (0, wee_1.wee)();
break;
case "woo":
buffer[socket.id] += (0, woo_1.woo)();
bufko += (0, woo_1.woo)();
break;
case "resendbufko":
sendbuffer(socket, buffer, true);
break;
case "spam":
buffer[socket.id] += (0, spam_1.spam)(args);
bufko += (0, spam_1.spam)(args);
break;
default:
buffer[socket.id] += "Invalid command.\n";
bufko += "Invalid command.\n";
}
buffer[socket.id] += "#";
return bufko;
}
exports.resolveCommand = resolveCommand;
//# sourceMappingURL=commands.js.map

@ -1 +1 @@
{"version":3,"file":"commands.js","sourceRoot":"","sources":["commands.ts"],"names":[],"mappings":";;;AACA,mCAAkC;AAClC,6BAA4B;AAC5B,2BAA0B;AAC1B,iCAAgC;AAChC,2BAA0B;AAC1B,+BAA8B;AAC9B,+BAA8B;AAC9B,+BAA8B;AAC9B,uCAAsC;AACtC,2BAA0B;AAC1B,6BAA4B;AAC5B,iCAAgC;AAChC,2BAA0B;AAC1B,yCAAwC;AACxC,6BAA4B;AAC5B,2BAA0B;AAC1B,iCAAgC;AAChC,uCAAsC;AACtC,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IAAA,WAAI,EAAC,IAAI,CAAC,CAAC;YACpB,MAAM;QAEN;YACI,KAAK,IAAI,oBAAoB,CAAC;KACrC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AACO,wCAAc"}

@ -1,5 +1,6 @@
import { Socket } from 'socket.io';
import { append } from './append';
import { beep } from './beep';
import { cat } from './cat';
import { cd } from './cd';
import { clear } from './clear';
@ -22,81 +23,100 @@ import { spam } from './spam';
import { touch } from './touch';
import { wee } from './wee';
import { woo } from './woo';
function resolveCommand(commandname:string, socket:Socket, args:string[], buffer:{ [id: string]: string }, sessions:any, filesystem:any, curdir:any, curdirx:any) {
function sendbuffer(socket:Socket, bufferx: { [id: string]: string }, forcefulload:boolean) {
var bufx = bufferx[socket.id];
//add placeholder character(reserved unicode) for blinking cursor in client;
bufx += "\u2588";
if(forcefulload) {
socket.emit('buffer', bufx);
}
else {
socket.emit('bufferx', bufx);
}
}
function resolveCommand(commandname:string, socket:Socket, args:string[], buffer:{ [id: string]: string }, sessions:any, filesystem:any, curdir:any, curdirx:any):string {
var bufko = "";
switch (commandname) {
case "help":
buffer[socket.id] += help();
bufko += help();
break;
case "man":
buffer[socket.id] += man(args);
bufko += man(args);
break; //implement more commands
case "beep":
bufko += beep(socket);
break;
case "screenshot":
buffer[socket.id] += screenshot(args, curdir, buffer, socket);
bufko += screenshot(args, curdir, buffer, socket);
break;
case "append":
buffer[socket.id] += append(args, curdir[socket.id]);
bufko += append(args, curdir[socket.id]);
break;
case "overwrite":
buffer[socket.id] += overwrite(args, curdir[socket.id]);
bufko += overwrite(args, curdir[socket.id]);
break;
case "rm":
buffer[socket.id] += rm(args, curdir, socket);
bufko += rm(args, curdir, socket);
break;
case "mv":
buffer[socket.id] += mv(args, curdir[socket.id]);
bufko += mv(args, curdir[socket.id]);
break;
case "cp":
buffer[socket.id] += cp(args, curdir[socket.id]);
bufko += cp(args, curdir[socket.id]);
break;
case "mkdir":
buffer[socket.id] += mkdir(args, curdir[socket.id]);
bufko += mkdir(args, curdir[socket.id]);
break;
case "rmdir":
buffer[socket.id] += rmdir(args, curdir, socket);
bufko += rmdir(args, curdir, socket);
break;
case "touch":
buffer[socket.id] += touch(args, curdir, socket);
bufko += touch(args, curdir, socket);
break;
case "cat":
buffer[socket.id] += cat(args, curdir[socket.id]);
bufko += cat(args, curdir[socket.id]);
break;
case "exec":
buffer[socket.id] += exec(args, curdir, socket, buffer, sessions, filesystem, curdirx);
bufko += exec(args, curdir, socket, buffer, sessions, filesystem, curdirx);
break;
case "ls":
buffer[socket.id] += ls(curdir[socket.id]);
bufko += ls(curdir[socket.id]);
break;
case "cd":
buffer[socket.id] += cd(args, curdir, socket, filesystem, curdirx);
bufko += cd(args, curdir, socket, filesystem, curdirx);
break;
case "pwd":
buffer[socket.id] += pwd(curdirx[socket.id]);
bufko += pwd(curdirx[socket.id]);
break;
case "echo":
buffer[socket.id] += echo(args);
bufko += echo(args);
break;
case "clear":
buffer[socket.id] += clear(buffer[socket.id]);
bufko += clear(buffer[socket.id]);
break;
case "savesess":
buffer[socket.id] += savesess(args, sessions, filesystem, curdir, buffer, socket);
bufko += savesess(args, sessions, filesystem, curdir, buffer, socket);
break;
case "loadsess":
buffer[socket.id] += loadsess(args, sessions, filesystem[socket.id], curdir[socket.id], buffer[socket.id]);
bufko += loadsess(args, sessions, filesystem[socket.id], curdir[socket.id], buffer[socket.id]);
break;
case "wee":
buffer[socket.id] += wee();
bufko += wee();
break;
case "woo":
buffer[socket.id] += woo();
bufko += woo();
break;
case "resendbufko":
sendbuffer(socket, buffer, true);
break;
case "spam":
buffer[socket.id] += spam(args);
bufko += spam(args);
break;
//invalid command
default:
buffer[socket.id] += "Invalid command.\n";
bufko += "Invalid command.\n";
}
buffer[socket.id] += "#";
return bufko;
}
export {resolveCommand};

@ -22,6 +22,7 @@ function help() {
buf += "overwrite - overwrites the file with data\n";
buf += "append - appends the arguments to a file\n";
buf += "screenshot - takes a screenshot\n";
buf += "beep - makes a beep\n";
buf += "man - display longer help\n";
return buf;
}

@ -1 +1 @@
{"version":3,"file":"help.js","sourceRoot":"","sources":["help.ts"],"names":[],"mappings":";;;AAAA,SAAS,IAAI;IACT,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,GAAG,IAAI,uBAAuB,CAAC;IAC/B,GAAG,IAAI,0BAA0B,CAAC;IAClC,GAAG,IAAI,8BAA8B,CAAC;IACtC,GAAG,IAAI,iDAAiD,CAAC;IACzD,GAAG,IAAI,sCAAsC,CAAC;IAC9C,GAAG,IAAI,+BAA+B,CAAC;IACvC,GAAG,IAAI,mCAAmC,CAAC;IAC3C,GAAG,IAAI,uCAAuC,CAAC;IAC/C,GAAG,IAAI,8BAA8B,CAAC;IACtC,GAAG,IAAI,uBAAuB,CAAC;IAC/B,GAAG,IAAI,qBAAqB,CAAC;IAC7B,GAAG,IAAI,sBAAsB,CAAC;IAC9B,GAAG,IAAI,+BAA+B,CAAC;IACvC,GAAG,IAAI,sCAAsC,CAAC;IAC9C,GAAG,IAAI,0BAA0B,CAAC;IAClC,GAAG,IAAI,4BAA4B,CAAC;IACpC,GAAG,IAAI,6CAA6C,CAAC;IACrD,GAAG,IAAI,4CAA4C,CAAC;IACpD,GAAG,IAAI,mCAAmC,CAAC;IAC3C,GAAG,IAAI,6BAA6B,CAAC;IACrC,OAAO,GAAG,CAAC;AACf,CAAC;AACO,oBAAI"}
{"version":3,"file":"help.js","sourceRoot":"","sources":["help.ts"],"names":[],"mappings":";;;AAAA,SAAS,IAAI;IACT,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,GAAG,IAAI,uBAAuB,CAAC;IAC/B,GAAG,IAAI,0BAA0B,CAAC;IAClC,GAAG,IAAI,8BAA8B,CAAC;IACtC,GAAG,IAAI,iDAAiD,CAAC;IACzD,GAAG,IAAI,sCAAsC,CAAC;IAC9C,GAAG,IAAI,+BAA+B,CAAC;IACvC,GAAG,IAAI,mCAAmC,CAAC;IAC3C,GAAG,IAAI,uCAAuC,CAAC;IAC/C,GAAG,IAAI,8BAA8B,CAAC;IACtC,GAAG,IAAI,uBAAuB,CAAC;IAC/B,GAAG,IAAI,qBAAqB,CAAC;IAC7B,GAAG,IAAI,sBAAsB,CAAC;IAC9B,GAAG,IAAI,+BAA+B,CAAC;IACvC,GAAG,IAAI,sCAAsC,CAAC;IAC9C,GAAG,IAAI,0BAA0B,CAAC;IAClC,GAAG,IAAI,4BAA4B,CAAC;IACpC,GAAG,IAAI,6CAA6C,CAAC;IACrD,GAAG,IAAI,4CAA4C,CAAC;IACpD,GAAG,IAAI,mCAAmC,CAAC;IAC3C,GAAG,IAAI,uBAAuB,CAAC;IAC/B,GAAG,IAAI,6BAA6B,CAAC;IACrC,OAAO,GAAG,CAAC;AACf,CAAC;AACO,oBAAI"}

@ -19,6 +19,7 @@ function help(): string {
buf += "overwrite - overwrites the file with data\n";
buf += "append - appends the arguments to a file\n";
buf += "screenshot - takes a screenshot\n";
buf += "beep - makes a beep\n";
buf += "man - display longer help\n";
return buf;
}

@ -64,6 +64,9 @@ function man(args) {
case "man":
buf += "\'screenshot (command)\' This manual databank\n";
break;
case "beep":
buf += "\'beep\' This command makes a beep\n";
break;
default:
buf += "No such command\n";
}

@ -1 +1 @@
{"version":3,"file":"man.js","sourceRoot":"","sources":["man.ts"],"names":[],"mappings":";;;AAAA,SAAS,GAAG,CAAC,IAAmB;IAC5B,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,IAAG,IAAI,CAAC,MAAM,IAAI,CAAC,EAAC;QAChB,GAAG,IAAI,mBAAmB,CAAA;KAC7B;IACD,QAAQ,IAAI,CAAC,CAAC,CAAC,EAAC;QACZ,KAAK,MAAM;YACP,GAAG,IAAI,kDAAkD,CAAC;YAC1D,MAAM;QACV,KAAK,OAAO;YACR,GAAG,IAAI,gCAAgC,CAAC;YACxC,MAAM;QACV,KAAK,IAAI;YACL,GAAG,IAAI,uFAAuF,CAAC;YAC/F,MAAM;QACV,KAAK,IAAI;YACL,GAAG,IAAI,qDAAqD,CAAC;YAC7D,MAAM;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;YAC9C,MAAM;QAEV;YACI,GAAG,IAAI,mBAAmB,CAAA;KACjC;IACD,OAAO,GAAG,CAAC;AACf,CAAC;AACO,kBAAG"}

@ -59,8 +59,12 @@ function man(args: Array<string>):string{
buf += "\'screenshot (filename)\' Takes a screenshot of the console and saves it to a file\n";
break;
case "man":
buf += "\'screenshot (command)\' This manual databank\n"
break
buf += "\'screenshot (command)\' This manual databank\n";
break;
case "beep":
buf += "\'beep\' This command makes a beep\n";
break;
default:
buf += "No such command\n"
}

@ -17,18 +17,20 @@ app.get("/script.js", function (req, res) {
app.get("/style.css", function (req, res) {
res.sendFile(__dirname + '/website/style.css');
});
app.get("/jquery.js", function (req, res) {
res.sendFile(__dirname + '/website/jquery.js');
});
var buffer = {};
var filesystem = {};
var curdir = {};
var sessions = {};
var curdirx = {};
function sendbuffer(socket, bufferx) {
function sendbuffer(socket, bufferx, forcefulload) {
var bufx = bufferx[socket.id];
bufx += "\u2588";
socket.emit('buffer', bufx);
if (forcefulload) {
socket.emit('buffer', bufx);
}
else {
socket.emit('bufferx', bufx);
}
}
io.on('connection', function (socket) {
console.log('a user connected');
@ -39,7 +41,7 @@ io.on('connection', function (socket) {
buffer[socket.id] = "Welcome to the console!\n";
buffer[socket.id] += "Type 'help' to see the available commands.\n";
buffer[socket.id] += "#";
sendbuffer(socket, buffer);
sendbuffer(socket, buffer, true);
socket.on('keypress', function (data) {
console.log('a key was pressed');
var key = String.fromCharCode(data);
@ -49,6 +51,7 @@ io.on('connection', function (socket) {
var lines = buffer[socket.id].split("\n");
if (lines[lines.length - 1] != "#") {
lines[lines.length - 1] = lines[lines.length - 1].slice(0, -1);
socket.emit("lastline", lines[lines.length - 1]);
buffer[socket.id] = lines.join("\n");
}
}
@ -65,12 +68,16 @@ io.on('connection', function (socket) {
});
buffer[socket.id] += "\n";
console.log("Executing command: \"" + commandName + "\" with arguments: \"" + commandArgs + "\"");
(0, commands_1.resolveCommand)(commandName, socket, commandArgs, buffer, sessions, filesystem, curdir, curdirx);
var bufko = "\n" + (0, commands_1.resolveCommand)(commandName, socket, commandArgs, buffer, sessions, filesystem, curdir, curdirx);
console.log("This command \"" + commandName + "\" with args:\"" + commandArgs + "\" returned \"" + bufko + "\"");
bufko += "#";
socket.emit("bufferx", bufko + '\u2588');
buffer[socket.id] += bufko;
}
else {
buffer[socket.id] += key;
socket.emit("bufferx", key + "\u2588");
}
sendbuffer(socket, buffer);
});
});
io.on('disconnect', function (socket) {

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AACA,IAAI,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAC3B,IAAI,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AAEjC,IAAI,GAAG,GAAG,OAAO,EAAE,CAAC;AACpB,IAAI,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;AACpC,IAAI,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,IAAI,CAAC;AAC5B,IAAA,MAAM,GAAK,OAAO,CAAC,WAAW,CAAC,OAAzB,CAA0B;AAExC,IAAM,EAAE,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC;AAE9B,gDAAqD;AAErD,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,UAAC,GAAW,EAAE,GAAY;IACnC,GAAG,CAAC,QAAQ,CAAC,SAAS,GAAG,qBAAqB,CAAC,CAAC;AAClD,CAAC,CACF,CAAC;AACF,GAAG,CAAC,GAAG,CAAC,YAAY,EAAE,UAAC,GAAW,EAAE,GAAY;IAC5C,GAAG,CAAC,QAAQ,CAAC,SAAS,GAAG,oBAAoB,CAAC,CAAC;AAC/C,CAAC,CACJ,CAAC;AACF,GAAG,CAAC,GAAG,CAAC,YAAY,EAAE,UAAC,GAAW,EAAE,GAAY;IAC5C,GAAG,CAAC,QAAQ,CAAC,SAAS,GAAG,oBAAoB,CAAC,CAAC;AAC/C,CAAC,C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C;YACnH,OAAO,CAAC,GAAG,CAAC,iBAAiB,GAAE,WAAW,GAAE,iBAAiB,GAAC,WAAW,GAAC,gBAAgB,GAAC,KAAK,GAAC,IAAI,CAAC,CAAC;YACvG,KAAK,IAAI,GAAG,CAAC;YACb,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,GAAE,QAAQ,CAAC,CAAC;YACxC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,KAAK,CAAC;SAC9B;aACG;YAEA,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,GAAG,CAAC;YACzB,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,GAAC,QAAQ,CAAC,CAAC;SACxC;IAEL,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC;AACH,EAAE,CAAC,EAAE,CAAC,YAAY,EAAE,UAAC,MAAa;IAC9B,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IACjC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC;AAC3B,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE;IAChB,OAAO,CAAC,GAAG,CAAC,6BAA6B,EAAE,IAAI,CAAC,CAAC;AACrD,CAAC,CAAC,CAAC"}

@ -23,10 +23,6 @@ app.get("/style.css", (req:Request, res:Response) => {
res.sendFile(__dirname + '/website/style.css');
}
);
app.get("/jquery.js", (req:Request, res:Response) => {
res.sendFile(__dirname + '/website/jquery.js');
}
);
//initialize buffer
//var buffer = [];
//add type for typescript
@ -40,11 +36,16 @@ var sessions: any = {};
//var curdirx = [];
var curdirx: any = {};
//on connection
function sendbuffer(socket:Socket, bufferx: { [id: string]: string }) {
function sendbuffer(socket:Socket, bufferx: { [id: string]: string }, forcefulload:boolean) {
var bufx = bufferx[socket.id];
//add placeholder character(reserved unicode) for blinking cursor in client;
bufx += "\u2588";
if(forcefulload) {
socket.emit('buffer', bufx);
}
else {
socket.emit('bufferx', bufx);
}
}
io.on('connection', (socket:Socket) => {
console.log('a user connected');
@ -57,7 +58,7 @@ io.on('connection', (socket:Socket) => {
buffer[socket.id] += "Type 'help' to see the available commands.\n";
buffer[socket.id] += "#";
//send buffer
sendbuffer(socket, buffer);
sendbuffer(socket, buffer, true);
socket.on('keypress', (data) => {
console.log('a key was pressed');
@ -76,6 +77,7 @@ io.on('connection', (socket:Socket) => {
var lines = buffer[socket.id].split("\n");
if (lines[lines.length - 1] != "#") {
lines[lines.length - 1] = lines[lines.length - 1].slice(0, -1);
socket.emit("lastline", lines[lines.length - 1]);
buffer[socket.id] = lines.join("\n");
}
}
@ -98,14 +100,18 @@ io.on('connection', (socket:Socket) => {
buffer[socket.id] += "\n";
//remove # in beginning of commandname
console.log("Executing command: \"" + commandName + "\" with arguments: \"" + commandArgs + "\"");
resolveCommand(commandName, socket, commandArgs, buffer, sessions, filesystem, curdir, curdirx);
var bufko = "\n" + resolveCommand(commandName, socket, commandArgs, buffer, sessions, filesystem, curdir, curdirx);
console.log("This command \""+ commandName +"\" with args:\""+commandArgs+"\" returned \""+bufko+"\"");
bufko += "#";
socket.emit("bufferx", bufko+ '\u2588');
buffer[socket.id] += bufko;
}
else{
//add key to buffer
buffer[socket.id] += key;
socket.emit("bufferx", key+"\u2588");
}
//send buffer to client
sendbuffer(socket, buffer);
});
});
io.on('disconnect', (socket:Socket) => {

136
package-lock.json generated

@ -9,15 +9,23 @@
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"@types/jquery": "^3.5.14",
"express": "^4.18.1",
"jquery": "^3.6.0",
"serialize-anything": "^1.1.10",
"socket.io": "^4.5.1"
"socket.io": "^4.5.1",
"socket.io-client": "^4.5.1"
},
"devDependencies": {
"@types/express": "^4.17.13",
"typescript": "^4.7.3"
}
},
"node_modules/@socket.io/component-emitter": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.0.tgz",
"integrity": "sha512-+9jVqKhRSpsc591z5vX+X5Yyw+he/HCB4iQ/RYxw35CEPaY1gnsNE43nf9n9AaYjAQrTiI/mOwKUKdUs9vf7Xg=="
},
"node_modules/@types/body-parser": {
"version": "1.19.2",
"resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.2.tgz",
@ -75,6 +83,14 @@
"@types/range-parser": "*"
}
},
"node_modules/@types/jquery": {
"version": "3.5.14",
"resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-3.5.14.tgz",
"integrity": "sha512-X1gtMRMbziVQkErhTQmSe2jFwwENA/Zr+PprCkF63vFq+Yt5PZ4AlKqgmeNlwgn7dhsXEK888eIW2520EpC+xg==",
"dependencies": {
"@types/sizzle": "*"
}
},
"node_modules/@types/mime": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.2.tgz",
@ -108,6 +124,11 @@
"@types/node": "*"
}
},
"node_modules/@types/sizzle": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/@types/sizzle/-/sizzle-2.3.3.tgz",
"integrity": "sha512-JYM8x9EGF163bEyhdJBpR2QX1R5naCJHC8ucJylJ3w9/CVBaskdQ8WqBf8MmQrd1kRvp/a4TS8HJ+bxzR7ZJYQ=="
},
"node_modules/accepts": {
"version": "1.3.8",
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
@ -309,6 +330,18 @@
"node": ">=10.0.0"
}
},
"node_modules/engine.io-client": {
"version": "6.2.2",
"resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.2.2.tgz",
"integrity": "sha512-8ZQmx0LQGRTYkHuogVZuGSpDqYZtCM/nv8zQ68VZ+JkOpazJ7ICdsSpaO6iXwvaU30oFg5QJOJWj8zWqhbKjkQ==",
"dependencies": {
"@socket.io/component-emitter": "~3.1.0",
"debug": "~4.3.1",
"engine.io-parser": "~5.0.3",
"ws": "~8.2.3",
"xmlhttprequest-ssl": "~2.0.0"
}
},
"node_modules/engine.io-parser": {
"version": "5.0.4",
"resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.0.4.tgz",
@ -517,6 +550,11 @@
"node": ">= 0.10"
}
},
"node_modules/jquery": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/jquery/-/jquery-3.6.0.tgz",
"integrity": "sha512-JVzAR/AjBvVt2BmYhxRCSYysDsPcssdmTFnzyLEts9qNwmjmu4JTAMYubEfwVOSwpQ1I1sKKFcxhZCI2buerfw=="
},
"node_modules/media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
@ -795,6 +833,32 @@
"resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-2.4.0.tgz",
"integrity": "sha512-W4N+o69rkMEGVuk2D/cvca3uYsvGlMwsySWV447y99gUPghxq42BxqLNMndb+a1mm/5/7NeXVQS7RLa2XyXvYg=="
},
"node_modules/socket.io-client": {
"version": "4.5.1",
"resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-4.5.1.tgz",
"integrity": "sha512-e6nLVgiRYatS+AHXnOnGi4ocOpubvOUCGhyWw8v+/FxW8saHkinG6Dfhi9TU0Kt/8mwJIAASxvw6eujQmjdZVA==",
"dependencies": {
"@socket.io/component-emitter": "~3.1.0",
"debug": "~4.3.2",
"engine.io-client": "~6.2.1",
"socket.io-parser": "~4.2.0"
},
"engines": {
"node": ">=10.0.0"
}
},
"node_modules/socket.io-client/node_modules/socket.io-parser": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.0.tgz",
"integrity": "sha512-tLfmEwcEwnlQTxFB7jibL/q2+q8dlVQzj4JdRLJ/W/G1+Fu9VSxCx1Lo+n1HvXxKnM//dUuD0xgiA7tQf57Vng==",
"dependencies": {
"@socket.io/component-emitter": "~3.1.0",
"debug": "~4.3.1"
},
"engines": {
"node": ">=10.0.0"
}
},
"node_modules/socket.io-parser": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.0.4.tgz",
@ -892,9 +956,22 @@
"optional": true
}
}
},
"node_modules/xmlhttprequest-ssl": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-2.0.0.tgz",
"integrity": "sha512-QKxVRxiRACQcVuQEYFsI1hhkrMlrXHPegbbd1yn9UHOmRxY+si12nQYzri3vbzt8VdTTRviqcKxcyllFas5z2A==",
"engines": {
"node": ">=0.4.0"
}
}
},
"dependencies": {
"@socket.io/component-emitter": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.0.tgz",
"integrity": "sha512-+9jVqKhRSpsc591z5vX+X5Yyw+he/HCB4iQ/RYxw35CEPaY1gnsNE43nf9n9AaYjAQrTiI/mOwKUKdUs9vf7Xg=="
},
"@types/body-parser": {
"version": "1.19.2",
"resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.2.tgz",
@ -952,6 +1029,14 @@
"@types/range-parser": "*"
}
},
"@types/jquery": {
"version": "3.5.14",
"resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-3.5.14.tgz",
"integrity": "sha512-X1gtMRMbziVQkErhTQmSe2jFwwENA/Zr+PprCkF63vFq+Yt5PZ4AlKqgmeNlwgn7dhsXEK888eIW2520EpC+xg==",
"requires": {
"@types/sizzle": "*"
}
},
"@types/mime": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.2.tgz",
@ -985,6 +1070,11 @@
"@types/node": "*"
}
},
"@types/sizzle": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/@types/sizzle/-/sizzle-2.3.3.tgz",
"integrity": "sha512-JYM8x9EGF163bEyhdJBpR2QX1R5naCJHC8ucJylJ3w9/CVBaskdQ8WqBf8MmQrd1kRvp/a4TS8HJ+bxzR7ZJYQ=="
},
"accepts": {
"version": "1.3.8",
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
@ -1139,6 +1229,18 @@
"ws": "~8.2.3"
}
},
"engine.io-client": {
"version": "6.2.2",
"resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.2.2.tgz",
"integrity": "sha512-8ZQmx0LQGRTYkHuogVZuGSpDqYZtCM/nv8zQ68VZ+JkOpazJ7ICdsSpaO6iXwvaU30oFg5QJOJWj8zWqhbKjkQ==",
"requires": {
"@socket.io/component-emitter": "~3.1.0",
"debug": "~4.3.1",
"engine.io-parser": "~5.0.3",
"ws": "~8.2.3",
"xmlhttprequest-ssl": "~2.0.0"
}
},
"engine.io-parser": {
"version": "5.0.4",
"resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.0.4.tgz",
@ -1309,6 +1411,11 @@
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
"integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g=="
},
"jquery": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/jquery/-/jquery-3.6.0.tgz",
"integrity": "sha512-JVzAR/AjBvVt2BmYhxRCSYysDsPcssdmTFnzyLEts9qNwmjmu4JTAMYubEfwVOSwpQ1I1sKKFcxhZCI2buerfw=="
},
"media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
@ -1517,6 +1624,28 @@
"resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-2.4.0.tgz",
"integrity": "sha512-W4N+o69rkMEGVuk2D/cvca3uYsvGlMwsySWV447y99gUPghxq42BxqLNMndb+a1mm/5/7NeXVQS7RLa2XyXvYg=="
},
"socket.io-client": {
"version": "4.5.1",
"resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-4.5.1.tgz",
"integrity": "sha512-e6nLVgiRYatS+AHXnOnGi4ocOpubvOUCGhyWw8v+/FxW8saHkinG6Dfhi9TU0Kt/8mwJIAASxvw6eujQmjdZVA==",
"requires": {
"@socket.io/component-emitter": "~3.1.0",
"debug": "~4.3.2",
"engine.io-client": "~6.2.1",
"socket.io-parser": "~4.2.0"
},
"dependencies": {
"socket.io-parser": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.0.tgz",
"integrity": "sha512-tLfmEwcEwnlQTxFB7jibL/q2+q8dlVQzj4JdRLJ/W/G1+Fu9VSxCx1Lo+n1HvXxKnM//dUuD0xgiA7tQf57Vng==",
"requires": {
"@socket.io/component-emitter": "~3.1.0",
"debug": "~4.3.1"
}
}
}
},
"socket.io-parser": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.0.4.tgz",
@ -1572,6 +1701,11 @@
"resolved": "https://registry.npmjs.org/ws/-/ws-8.2.3.tgz",
"integrity": "sha512-wBuoj1BDpC6ZQ1B7DWQBYVLphPWkm8i9Y0/3YdHjHKHiohOJ1ws+3OccDWtH+PoC9DZD5WOTrJvNbWvjS6JWaA==",
"requires": {}
},
"xmlhttprequest-ssl": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-2.0.0.tgz",
"integrity": "sha512-QKxVRxiRACQcVuQEYFsI1hhkrMlrXHPegbbd1yn9UHOmRxY+si12nQYzri3vbzt8VdTTRviqcKxcyllFas5z2A=="
}
}
}

@ -10,9 +10,12 @@
"author": "",
"license": "ISC",
"dependencies": {
"@types/jquery": "^3.5.14",
"express": "^4.18.1",
"jquery": "^3.6.0",
"serialize-anything": "^1.1.10",
"socket.io": "^4.5.1"
"socket.io": "^4.5.1",
"socket.io-client": "^4.5.1"
},
"devDependencies": {
"@types/express": "^4.17.13",

104
script.ts Normal file

@ -0,0 +1,104 @@
function setareacontent(content:string):void{
//this appends to the bottom of the console and scrolls to the bottom make sure we start typing at the bottom
var console = document.getElementById("console");
if (console != null) {
console.innerHTML = content;
console.scrollTop = console.scrollHeight;
}
}
function addareacontent(content:string):void{
//this appends to the bottom of the console and scrolls to the bottom make sure we start typing at the bottom
var console = document.getElementById("console");
if (console != null) {
console.innerHTML += content;
console.scrollTop = console.scrollHeight;
}
}
function resizeit():void{
let con = $("#console");
let windowx = $("window");
let consolecont = $("#consolecont");
if (con != null && windowx != null && con != undefined&& windowx != undefined&&consolecont != null&&consolecont!=undefined) {
let winheight = windowx.height();
let conoffset = con.offset();
if (winheight != undefined && conoffset != undefined){
consolecont.css('height', winheight - 10);
let height = (winheight - conoffset.top)*0.96;
$('#console').css('height', height);
$('#rows').val(winheight - conoffset.top - 10);
}
}
else{
console.log("error");
}
}
$(function(){
//fit console to screen
//$('#console').css('height', $(window).height() - $('#console').offset().top - 10);
//account for the input box
let host = 'ws://127.0.0.1:8480';
var socket = io.connect(host)
resizeit();
//resize it on window resize
//$(window).resize(function(){
$(window).on('resize', function(){
resizeit();
});
//on key press on any part of html page
//$("#console").keyup(function(e){
$("#console").on('keyup', function(e){
//if enter key is pressed
//get the input
e.preventDefault();
//resolve e.code to char
let key = e.which;
//send to server via socket if connected
if (key == 8){
socket.emit('keypress', key);
}
});
// $("#console").keypress(function(e){
$("#console").on('keypress', function(e){
//if enter key is pressed
//get the input
e.preventDefault();
//resolve e.code to char
let key = e.which;
//send to server via socket if connected
socket.emit('keypress', key);
});
//connect to the server
//on connect
socket.on('connect', function(){
setareacontent("Connected to server");
});
//on disconnect
socket.on('disconnect', function(){
setareacontent("Disconnected from server");
});
//on error
socket.on('error', function(err:any){
setareacontent("Error: " + err);
});
//on message
socket.on('buffer', function(msg:any){
setareacontent(msg);
});
socket.on('bufferx', function(msg:any){
addareacontent(msg);
});
})
function flash(){
//if u+2800 is present in the console then replace it with 2588
let console = document.getElementById("console");
if (console != null) {
if(console.innerHTML.indexOf("\u2800") > -1){
console.innerHTML = console.innerHTML.replace("\u2800", "\u2588");
}
else{
console.innerHTML = console.innerHTML.replace("\u2588", "\u2800");
}
}
}
setInterval(flash, 500);

@ -1,11 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"noImplicitAny": true,
"removeComments": true,
"preserveConstEnums": true,
"suppressImplicitAnyIndexErrors": true,
"sourceMap": true
"sourceMap": true,
"esModuleInterop": true
},
"files": [
"index.ts"

@ -1,15 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script src="/socket.io/socket.io.js"></script>
<link rel="stylesheet" href="style.css">
<meta charset="utf-8">
<script src="jquery.js"></script>
<!--include socket.io.js and jquery-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js" integrity="sha512-894YE6QWD5I59HgZOGReFYm4dnWc1Qt5NtvYSaNcOP+u1T9qYdvdihz0PPSiiqn/+/3e7Jo4EaG7TubfWGUrMQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.5.1/socket.io.js" integrity="sha512-9mpsATI0KClwt+xVZfbcf2lJ8IFBAwsubJ6mI3rtULwyM3fBmQFzj0It4tGqxLOGQwGfJdk/G+fANnxfq9/cew==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="script.js" ></script>
</head>
<body>
<div id="consolecont">
<textarea id="console" readonly></textarea>
</div>
<textarea id="console" readonly></textarea>
</body>
</html>

2
website/jquery.js vendored

File diff suppressed because one or more lines are too long

@ -1,39 +1,77 @@
function addareacontent(content){
"use strict";
function setareacontent(content) {
//this appends to the bottom of the console and scrolls to the bottom make sure we start typing at the bottom
var console = document.getElementById("console");
console.innerHTML = content;
console.scrollTop = console.scrollHeight;
}
function resizeit(){
$('#consolecont').css('height', $(window).height() - 10);
let height = ($(window).height() - $('#console').offset().top)*0.96;
$('#console').css('height', height);
$('#rows').val($(window).height() - $('#console').offset().top - 10);
function addareacontent(content) {
//this appends to the bottom of the console and scrolls to the bottom make sure we start typing at the bottom
var console = document.getElementById("console");
//replace the u+2800 and u+2588 with nothing in the console
console.innerHTML = console.innerHTML.replace("\u{2800}", "").replace("\u{2588}", "");
console.innerHTML += content;
console.scrollTop = console.scrollHeight;
}
function setlastline(content){
let console = document.getElementById("console");
//split by \n
let lines = console.innerHTML.split("\n");
//get the last line
lines[lines.length - 1] = content;
//join the lines back together
console.innerHTML = lines.join("\n")+'\u2588';
}
function resizeit() {
let con = $("#console");
let windowx = $(window);
let winheight = windowx.height();
let conoffset = con.offset();
con.css('height', winheight - 10);
$('#rows').val(winheight - conoffset.top - 10);
}
function revertcol(){
$("#console").css('background-color', '#000000');
$("#console").css('color', '#00FF00');
}
function bell(){
//plays a beep and inverts colors and they are reverted back after some time
$("#console").css('background-color', '#00AC00');
$("#console").css('color', '#000000');
setTimeout(revertcol, 25);
//generate a beep
var snd = new Audio("data:audio/wav;base64,//uQRAAAAWMSLwUIYAAsYkXgoQwAEaYLWfkWgAI0wWs/ItAAAGDgYtAgAyN+QWaAAihwMWm4G8QQRDiMcCBcH3Cc+CDv/7xA4Tvh9Rz/y8QADBwMWgQAZG/ILNAARQ4GLTcDeIIIhxGOBAuD7hOfBB3/94gcJ3w+o5/5eIAIAAAVwWgQAVQ2ORaIQwEMAJiDg95G4nQL7mQVWI6GwRcfsZAcsKkJvxgxEjzFUgfHoSQ9Qq7KNwqHwuB13MA4a1q/DmBrHgPcmjiGoh//EwC5nGPEmS4RcfkVKOhJf+WOgoxJclFz3kgn//dBA+ya1GhurNn8zb//9NNutNuhz31f////9vt///z+IdAEAAAK4LQIAKobHItEIYCGAExBwe8jcToF9zIKrEdDYIuP2MgOWFSE34wYiR5iqQPj0JIeoVdlG4VD4XA67mAcNa1fhzA1jwHuTRxDUQ//iYBczjHiTJcIuPyKlHQkv/LHQUYkuSi57yQT//uggfZNajQ3Vmz+Zt//+mm3Wm3Q576v////+32///5/EOgAAADVghQAAAAA//uQZAUAB1WI0PZugAAAAAoQwAAAEk3nRd2qAAAAACiDgAAAAAAABCqEEQRLCgwpBGMlJkI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uQZB4ABZx5zfMakeAAAAmwAAAAF5F3P0w9GtAAACfAAAAAwLhMDmAYWMgVEG1U0FIGCBgXBXAtfMH10000EEEEEECUBYln03TTTdNBDZopopYvrTTdNa325mImNg3TTPV9q3pmY0xoO6bv3r00y+IDGid/9aaaZTGMuj9mpu9Mpio1dXrr5HERTZSmqU36A3CumzN/9Robv/Xx4v9ijkSRSNLQhAWumap82WRSBUqXStV/YcS+XVLnSS+WLDroqArFkMEsAS+eWmrUzrO0oEmE40RlMZ5+ODIkAyKAGUwZ3mVKmcamcJnMW26MRPgUw6j+LkhyHGVGYjSUUKNpuJUQoOIAyDvEyG8S5yfK6dhZc0Tx1KI/gviKL6qvvFs1+bWtaz58uUNnryq6kt5RzOCkPWlVqVX2a/EEBUdU1KrXLf40GoiiFXK///qpoiDXrOgqDR38JB0bw7SoL+ZB9o1RCkQjQ2CBYZKd/+VJxZRRZlqSkKiws0WFxUyCwsKiMy7hUVFhIaCrNQsKkTIsLivwKKigsj8XYlwt/WKi2N4d//uQRCSAAjURNIHpMZBGYiaQPSYyAAABLAAAAAAAACWAAAAApUF/Mg+0aohSIRobBAsMlO//Kk4soosy1JSFRYWaLC4qZBYWFRGZdwqKiwkNBVmoWFSJkWFxX4FFRQWR+LsS4W/rFRb/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////VEFHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAU291bmRib3kuZGUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMjAwNGh0dHA6Ly93d3cuc291bmRib3kuZGUAAAAAAAAAACU=");
snd.play();
}
$(document).ready(function(){
//fit console to screen
//$('#console').css('height', $(window).height() - $('#console').offset().top - 10);
//account for the input box
let host = 'ws://127.0.0.1:8480';
socket = io.connect(host);
var socket = io.connect(host);
resizeit();
//resize it on window resize
$(window).resize(function(){
//$(window).resize(function(){
$(window).on('resize', function () {
resizeit();
});
//on key press on any part of html page
$("#console").keyup(function(e){
//$("#console").keyup(function(e){
$("#console").on('keyup', function (e) {
//if enter key is pressed
//get the input
e.preventDefault();
//resolve e.code to char
let key = e.which;
//send to server via socket if connected
if (key == 8){
if (key == 8) {
socket.emit('keypress', key);
}
});
$("#console").keypress(function(e){
// $("#console").keypress(function(e){
$("#console").on('keypress', function (e) {
//if enter key is pressed
//get the input
e.preventDefault();
@ -43,33 +81,40 @@ $(document).ready(function(){
socket.emit('keypress', key);
});
//connect to the server
//on connect
socket.on('connect', function(){
addareacontent("Connected to server");
socket.on('connect', function () {
setareacontent("Connected to server");
});
//on disconnect
socket.on('disconnect', function(){
addareacontent("Disconnected from server");
socket.on('disconnect', function () {
setareacontent("Disconnected from server");
});
//on error
socket.on('error', function(err){
addareacontent("Error: " + err);
socket.on('error', function (err) {
setareacontent("Error: " + err);
});
//on message
socket.on('buffer', function(msg){
socket.on('buffer', function (msg) {
setareacontent(msg);
});
socket.on('bufferx', function (msg) {
addareacontent(msg);
});
})
function flash(){
socket.on('lastline', function (msg) {
setlastline(msg);
});
socket.on('bell', bell);
});
function flash() {
//if u+2800 is present in the console then replace it with 2588
let console = document.getElementById("console");
if(console.innerHTML.indexOf("\u2800") > -1){
console.innerHTML = console.innerHTML.replace("\u2800", "\u2588");
}
else{
console.innerHTML = console.innerHTML.replace("\u2588", "\u2800");
if (console != null) {
if (console.innerHTML.indexOf("\u2800") > -1) {
console.innerHTML = console.innerHTML.replace("\u2800", "\u2588");
}
else {
console.innerHTML = console.innerHTML.replace("\u2588", "\u2800");
}
}
}
setInterval(flash, 500);