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