From 2087fc6efe82c335ecf096321802f0237e9c8e98 Mon Sep 17 00:00:00 2001 From: Shuanglei Tao Date: Wed, 10 Jan 2018 00:45:12 +0800 Subject: [PATCH] Sync window title with the terminal --- html/js/app.js | 11 +++++++++-- src/index.html | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/html/js/app.js b/html/js/app.js index ecdfefe..8c3bb7a 100644 --- a/html/js/app.js +++ b/html/js/app.js @@ -147,7 +147,7 @@ var terminalContainer = document.getElementById('terminal-container'), textEncoder = new TextEncoder(), authToken = (typeof tty_auth_token !== 'undefined') ? tty_auth_token : null, autoReconnect = -1, - term, pingTimer, wsError; + term, pingTimer, title, wsError; var openWs = function() { var ws = new WebSocket(url, ['tty']); @@ -241,6 +241,12 @@ var openWs = function() { }, 500); }); + term.on('title', function (data) { + if (data && data !== '') { + document.title = (data + ' | ' + title); + } + }); + term.on('data', sendData); while (terminalContainer.firstChild) { @@ -273,7 +279,8 @@ var openWs = function() { case '1': // pong break; case '2': - document.title = textDecoder.decode(data); + title = textDecoder.decode(data); + document.title = title; break; case '3': var preferences = JSON.parse(textDecoder.decode(data)); diff --git a/src/index.html b/src/index.html index 6c0f172..1bdfcca 100644 --- a/src/index.html +++ b/src/index.html @@ -51,6 +51,6 @@ blockquote,body,dd,dl,dt,fieldset,figure,h1,h2,h3,h4,h5,h6,hr,html,iframe,legend - + -- 2.43.4