mirror of
https://github.com/tsl0922/ttyd.git
synced 2025-12-22 11:54:19 +01:00
Sync window title with the terminal
This commit is contained in:
@@ -147,7 +147,7 @@ var terminalContainer = document.getElementById('terminal-container'),
|
|||||||
textEncoder = new TextEncoder(),
|
textEncoder = new TextEncoder(),
|
||||||
authToken = (typeof tty_auth_token !== 'undefined') ? tty_auth_token : null,
|
authToken = (typeof tty_auth_token !== 'undefined') ? tty_auth_token : null,
|
||||||
autoReconnect = -1,
|
autoReconnect = -1,
|
||||||
term, pingTimer, wsError;
|
term, pingTimer, title, wsError;
|
||||||
|
|
||||||
var openWs = function() {
|
var openWs = function() {
|
||||||
var ws = new WebSocket(url, ['tty']);
|
var ws = new WebSocket(url, ['tty']);
|
||||||
@@ -241,6 +241,12 @@ var openWs = function() {
|
|||||||
}, 500);
|
}, 500);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
term.on('title', function (data) {
|
||||||
|
if (data && data !== '') {
|
||||||
|
document.title = (data + ' | ' + title);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
term.on('data', sendData);
|
term.on('data', sendData);
|
||||||
|
|
||||||
while (terminalContainer.firstChild) {
|
while (terminalContainer.firstChild) {
|
||||||
@@ -273,7 +279,8 @@ var openWs = function() {
|
|||||||
case '1': // pong
|
case '1': // pong
|
||||||
break;
|
break;
|
||||||
case '2':
|
case '2':
|
||||||
document.title = textDecoder.decode(data);
|
title = textDecoder.decode(data);
|
||||||
|
document.title = title;
|
||||||
break;
|
break;
|
||||||
case '3':
|
case '3':
|
||||||
var preferences = JSON.parse(textDecoder.decode(data));
|
var preferences = JSON.parse(textDecoder.decode(data));
|
||||||
|
|||||||
2
src/index.html
vendored
2
src/index.html
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user