diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2018-08-03 14:15:04 +0100 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2018-08-03 15:16:39 +0100 |
commit | 26b8209ecdef4bb8c94b7fa3aa2fca7281de5e2b (patch) | |
tree | 51787ad3908a72e52dac47e0240042b82d1eafec /app/assets/javascripts/terminal | |
parent | 0116930bb0ae30bcb7b43b87371f1418e74661f1 (diff) | |
download | gitlab-ce-26b8209ecdef4bb8c94b7fa3aa2fca7281de5e2b.tar.gz |
Focus terminal on load
Use object.assign for default option
Diffstat (limited to 'app/assets/javascripts/terminal')
-rw-r--r-- | app/assets/javascripts/terminal/terminal.js | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/app/assets/javascripts/terminal/terminal.js b/app/assets/javascripts/terminal/terminal.js index 8a94c9f4fe1..74c5bbe45a4 100644 --- a/app/assets/javascripts/terminal/terminal.js +++ b/app/assets/javascripts/terminal/terminal.js @@ -1,19 +1,13 @@ import $ from 'jquery'; import { Terminal } from 'xterm'; import * as fit from 'xterm/lib/addons/fit/fit'; -import * as attach from 'xterm/lib/addons/attach/attach'; export default class GLTerminal { - constructor(options) { - this.options = options || {}; - - if (!Object.prototype.hasOwnProperty.call(this.options, 'cursorBlink')) { - this.options.cursorBlink = true; - } - - if (!Object.prototype.hasOwnProperty.call(this.options, 'screenKeys')) { - this.options.screenKeys = true; - } + constructor(options = {}) { + this.options = Object.assign({}, { + cursorBlink: true, + screenKeys: true, + }, options); this.container = document.querySelector(options.selector); @@ -37,16 +31,15 @@ export default class GLTerminal { createTerminal() { Terminal.applyAddon(fit); - Terminal.applyAddon(attach); this.terminal = new Terminal(this.options); - //TODO - CHECK IF WE SHOULD USE `attach` instead this.socket = new WebSocket(this.socketUrl, ['terminal.gitlab.com']); this.socket.binaryType = 'arraybuffer'; this.terminal.open(this.container); this.terminal.fit(); + this.terminal.focus(); this.socket.onopen = () => { this.runTerminal(); |