From 9bd2a1c202cdeb504ea018bf89c56e3d6e4cfc24 Mon Sep 17 00:00:00 2001 From: paris Date: Thu, 10 Apr 2014 15:54:39 +0000 Subject: [PATCH] Implemented the attach addon --- addons/attach/attach.js | 23 +++++++++++++ addons/attach/index.html | 38 +++++++++++++++++++++ {addon => addons}/fullscreen/fullscreen.css | 0 {addon => addons}/fullscreen/fullscreen.js | 0 4 files changed, 61 insertions(+) create mode 100644 addons/attach/attach.js create mode 100644 addons/attach/index.html rename {addon => addons}/fullscreen/fullscreen.css (100%) rename {addon => addons}/fullscreen/fullscreen.js (100%) diff --git a/addons/attach/attach.js b/addons/attach/attach.js new file mode 100644 index 00000000..12eb1359 --- /dev/null +++ b/addons/attach/attach.js @@ -0,0 +1,23 @@ +/* + * Implements the attach method, that + * attaches the terminal to a WebSocket stream. + * + * The bidirectional argument indicates, whether the terminal should + * send data to the socket as well and is true, by default. + */ +Terminal.prototype.attach = function (socket, bidirectional) { + var term = this; + + bidirectional = (typeof bidirectional == 'undefined') ? true : bidirectional; + this.socket = socket; + + socket.addEventListener('message', function (ev) { + term.write(ev.data); + }); + + if (bidirectional) { + this.on('data', function (data) { + socket.send(data); + }); + } +} \ No newline at end of file diff --git a/addons/attach/index.html b/addons/attach/index.html new file mode 100644 index 00000000..654a0245 --- /dev/null +++ b/addons/attach/index.html @@ -0,0 +1,38 @@ + + + + + + + + + +
+ + +
+
+ + + \ No newline at end of file diff --git a/addon/fullscreen/fullscreen.css b/addons/fullscreen/fullscreen.css similarity index 100% rename from addon/fullscreen/fullscreen.css rename to addons/fullscreen/fullscreen.css diff --git a/addon/fullscreen/fullscreen.js b/addons/fullscreen/fullscreen.js similarity index 100% rename from addon/fullscreen/fullscreen.js rename to addons/fullscreen/fullscreen.js