Added parse_xterm_style function

pull/12/head
Sheng 2018-02-26 11:15:59 +08:00
parent 1508e055f6
commit 7474fb762b
1 changed files with 14 additions and 3 deletions

View File

@ -1,7 +1,8 @@
jQuery(function($){ jQuery(function($){
var status = $('#status'), var status = $('#status'),
btn = $('.btn-primary'); btn = $('.btn-primary'),
style = {};
$('form#connect').submit(function(event) { $('form#connect').submit(function(event) {
event.preventDefault(); event.preventDefault();
@ -37,10 +38,20 @@ jQuery(function($){
}); });
function parse_xterm_style() {
var text = $('.xterm-helpers style').text();
var arr = text.split('xterm-normal-char{width:');
style.width = parseInt(arr[1]) + 1;
arr = text.split('div{height:');
style.height = parseInt(arr[1]);
}
function current_geometry() { function current_geometry() {
cols = parseInt(window.innerWidth / 10); if (!style.width || !style.height) {
rows = parseInt(window.innerHeight / 24); parse_xterm_style();
}
cols = parseInt(window.innerWidth / style.width);
rows = parseInt(window.innerHeight / style.height);
return [cols, rows]; return [cols, rows];
} }