From a19e0119d6abdfba30a097edbc4093619ff51b5c Mon Sep 17 00:00:00 2001 From: butlerx Date: Wed, 7 Jun 2017 15:53:04 +0100 Subject: [PATCH] add script for cron --- bin/cleanup | 1 + public/wetty/wetty.js | 75 +++++++++++++++++++++---------------------- 2 files changed, 38 insertions(+), 38 deletions(-) create mode 100644 bin/cleanup diff --git a/bin/cleanup b/bin/cleanup new file mode 100644 index 0000000..f60ff4f --- /dev/null +++ b/bin/cleanup @@ -0,0 +1 @@ +kill $(ps aux | grep "ssh" | awk '{print $2}') diff --git a/public/wetty/wetty.js b/public/wetty/wetty.js index 96048e5..345ba04 100644 --- a/public/wetty/wetty.js +++ b/public/wetty/wetty.js @@ -3,67 +3,66 @@ var socket = io(location.origin, {path: '/wetty/socket.io'}) var buf = ''; function Wetty(argv) { - this.argv_ = argv; - this.io = null; - this.pid_ = -1; + this.argv_ = argv; + this.io = null; + this.pid_ = -1; } Wetty.prototype.run = function() { - this.io = this.argv_.io.push(); + this.io = this.argv_.io.push(); - this.io.onVTKeystroke = this.sendString_.bind(this); - this.io.sendString = this.sendString_.bind(this); - this.io.onTerminalResize = this.onTerminalResize.bind(this); + this.io.onVTKeystroke = this.sendString_.bind(this); + this.io.sendString = this.sendString_.bind(this); + this.io.onTerminalResize = this.onTerminalResize.bind(this); } Wetty.prototype.sendString_ = function(str) { - socket.emit('input', str); + socket.emit('input', str); }; Wetty.prototype.onTerminalResize = function(col, row) { - socket.emit('resize', { col: col, row: row }); + socket.emit('resize', { col: col, row: row }); }; socket.on('connect', function() { - lib.init(function() { - hterm.defaultStorage = new lib.Storage.Local(); - term = new hterm.Terminal(); - window.term = term; - term.decorate(document.getElementById('terminal')); + lib.init(function() { + hterm.defaultStorage = new lib.Storage.Local(); + term = new hterm.Terminal(); + window.term = term; + term.decorate(document.getElementById('terminal')); - term.setCursorPosition(0, 0); - term.setCursorVisible(true); - term.prefs_.set('ctrl-c-copy', true); - term.prefs_.set('ctrl-v-paste', true); - term.prefs_.set('use-default-window-copy', true); + term.setCursorPosition(0, 0); + term.setCursorVisible(true); + term.prefs_.set('ctrl-c-copy', true); + term.prefs_.set('ctrl-v-paste', true); + term.prefs_.set('use-default-window-copy', true); - term.runCommandClass(Wetty, document.location.hash.substr(1)); - socket.emit('resize', { - col: term.screenSize.width, - row: term.screenSize.height - }); - - if (buf && buf != '') - { - term.io.writeUTF16(buf); - buf = ''; - } + term.runCommandClass(Wetty, document.location.hash.substr(1)); + socket.emit('resize', { + col: term.screenSize.width, + row: term.screenSize.height }); + + if (buf && buf != '') { + term.io.writeUTF16(buf); + buf = ''; + } + }); }); socket.on('output', function(data) { - if (!term) { - buf += data; - return; - } - term.io.writeUTF16(data); + if (!term) { + buf += data; + return; + } + term.io.writeUTF16(data); }); socket.on('logout', function(data) { - console.log("user logout"); - document.getElementById("overlay").style.display = "block"; + console.log("user logout"); + document.getElementById("overlay").style.display = "block"; }); socket.on('disconnect', function() { - console.log("Socket.io connection closed"); + console.log("Socket.io connection closed"); });