webssh

Web based ssh client https://github.com/huashengdun/webssh webssh.huashengdun.org/
git clone http://git.hanabi.in/repos/webssh.git
Log | Files | Refs | README | LICENSE

commit 7474fb762bef4b59ea5c9c7302d19f948a79e2f9
parent 1508e055f6f6be00ed6b1545b24d173708f67143
Author: Sheng <webmaster0115@gmail.com>
Date:   Mon, 26 Feb 2018 11:15:59 +0800

Added parse_xterm_style function

Diffstat:
Mstatic/js/main.js | 17++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/static/js/main.js b/static/js/main.js @@ -1,7 +1,8 @@ jQuery(function($){ var status = $('#status'), - btn = $('.btn-primary'); + btn = $('.btn-primary'), + style = {}; $('form#connect').submit(function(event) { 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() { - cols = parseInt(window.innerWidth / 10); - rows = parseInt(window.innerHeight / 24); + if (!style.width || !style.height) { + parse_xterm_style(); + } + cols = parseInt(window.innerWidth / style.width); + rows = parseInt(window.innerHeight / style.height); return [cols, rows]; }