Updated static files

This commit is contained in:
Sheng
2019-02-14 13:25:26 +08:00
parent d74c097471
commit 5a52b20feb
7 changed files with 39 additions and 22 deletions
+27 -10
View File
@@ -89,9 +89,23 @@ jQuery(function($){
}
function current_geometry() {
function get_cell_size(term) {
style.width = term._core.renderer.dimensions.actualCellWidth;
style.height = term._core.renderer.dimensions.actualCellHeight;
}
function toggle_fullscreen(term) {
var func = term.toggleFullScreen || term.toggleFullscreen;
func.call(term, true);
}
function current_geometry(term) {
if (!style.width || !style.height) {
parse_xterm_style();
try {
get_cell_size(term);
} catch (TypeError) {
parse_xterm_style();
}
}
var cols = parseInt(window.innerWidth / style.width, 10) - 1;
@@ -216,7 +230,7 @@ jQuery(function($){
}
function resize_terminal(term) {
var geometry = current_geometry();
var geometry = current_geometry(term);
term.on_resize(geometry.cols, geometry.rows);
}
@@ -258,7 +272,7 @@ jQuery(function($){
wssh.geometry = function() {
// for console use
var geometry = current_geometry();
var geometry = current_geometry(term);
console.log('Current window geometry: ' + JSON.stringify(geometry));
};
@@ -302,7 +316,7 @@ jQuery(function($){
var valid_args = false;
if (cols > 0 && rows > 0) {
var geometry = current_geometry();
var geometry = current_geometry(term);
if (cols <= geometry.cols && rows <= geometry.rows) {
valid_args = true;
}
@@ -316,7 +330,7 @@ jQuery(function($){
};
term.on_resize = function(cols, rows) {
if (cols !== this.geometry[0] || rows !== this.geometry[1]) {
if (cols !== this.cols || rows !== this.rows) {
console.log('Resizing terminal to geometry: ' + format_geometry(cols, rows));
this.resize(cols, rows);
sock.send(JSON.stringify({'resize': [cols, rows]}));
@@ -329,9 +343,9 @@ jQuery(function($){
});
sock.onopen = function() {
// $('.container').hide();
term.open(terminal, true);
term.toggleFullscreen(true);
term.open(terminal);
toggle_fullscreen(term);
term.focus();
state = CONNECTED;
title_element.text = title_text;
};
@@ -350,7 +364,6 @@ jQuery(function($){
term = undefined;
sock = undefined;
reset_wssh();
// $('.container').show();
status.text(e.reason);
state = DISCONNECTED;
title_text = 'WebSSH';
@@ -600,4 +613,8 @@ jQuery(function($){
window.addEventListener('message', cross_origin_connect, false);
if (window.Terminal.applyAddon) {
window.Terminal.applyAddon(window.fullscreen);
}
});