Closed Xarrow closed 4 years ago
Thanks @Xarrow, what was the problem with the previous implementation?
$(window).resize(function() {
resizeTerm(term, ws);
});
$(() => {
let ws = new WebSocket('ws://' + location.host + '/terminal');
let term = new Terminal({
cursorBlink: true,
});
term.on('data', command => {
console.log(command);
ws.send(
action('TERMINAL_COMMAND', {
command,
})
);
});
.....
term
is not in resize
scope, and it always throw term is not defined
when window resize . So resize is not work.
In fixed main.js
$(() => {
let ws = new WebSocket('ws://' + location.host + '/terminal');
let term = new Terminal({
cursorBlink: true,
});
//.......
ws.onopen = () => {
ws.send(action('TERMINAL_INIT'));
ws.send(action('TERMINAL_READY'));
term.open(document.getElementById('#terminal'), true);
term.toggleFullscreen(true);
$(window).resize(function() {
resizeTerm(term, ws);
});
};
I put resize
function into ws.open
block , it will trigger resize when ws onopen at once. And log has been print in console .
Thanks for explanation. I appreciate your effort.
Thanks @Xarrow, what was the problem with the previous implementation?