From e4657761c9d05117dcbb6da22193f74c5ea291d7 Mon Sep 17 00:00:00 2001 From: Tsung-en Hsiao Date: Mon, 23 Aug 2021 07:01:03 +0000 Subject: [PATCH 1/3] Add fontsize url parameter --- README.md | 5 +++++ webssh/static/js/main.js | 12 ++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c8e96b3..0ea6c25 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,11 @@ Passing an encoding http://localhost:8888/#encoding=gbk ``` +Passing a font size +```bash +http://localhost:8888/#fontsize=24 +``` + Passing a command executed right after login ```bash http://localhost:8888/?command=pwd diff --git a/webssh/static/js/main.js b/webssh/static/js/main.js index fb43f2c..f7411e5 100644 --- a/webssh/static/js/main.js +++ b/webssh/static/js/main.js @@ -56,7 +56,7 @@ jQuery(function($){ key_max_size = 16384, fields = ['hostname', 'port', 'username'], form_keys = fields.concat(['password', 'totp']), - opts_keys = ['bgcolor', 'title', 'encoding', 'command', 'term'], + opts_keys = ['bgcolor', 'title', 'encoding', 'command', 'term', 'fontsize'], url_form_data = {}, url_opts_data = {}, validated_form_data, @@ -360,12 +360,16 @@ jQuery(function($){ encoding = 'utf-8', decoder = window.TextDecoder ? new window.TextDecoder(encoding) : encoding, terminal = document.getElementById('terminal'), - term = new window.Terminal({ - cursorBlink: true, + termOptions = { theme: { background: url_opts_data.bgcolor || 'black' } - }); + }; + + if (url_opts_data.fontsize !== undefined) + termOptions.fontSize = parseInt(url_opts_data.fontsize); + + var term = new window.Terminal(termOptions); term.fitAddon = new window.FitAddon.FitAddon(); term.loadAddon(term.fitAddon); From 0d14b8d4ae9d97b4f436af05dc71446a85c09d89 Mon Sep 17 00:00:00 2001 From: yc5 Date: Tue, 24 Aug 2021 19:54:36 +0800 Subject: [PATCH 2/3] update readme images with relative links --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0ea6c25..3874705 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,8 @@ A simple web application to be used as an ssh client to connect to your ssh serv ### Preview -![Login](https://github.com/huashengdun/webssh/raw/master/preview/login.png) -![Terminal](https://github.com/huashengdun/webssh/raw/master/preview/terminal.png) +![Login](preview/login.png) +![Terminal](preview/terminal.png) ### How it works From ddbb2c3fb1fec9d57ca3b1beefbbe09232ad827b Mon Sep 17 00:00:00 2001 From: Sheng Date: Wed, 25 Aug 2021 19:18:28 +0800 Subject: [PATCH 3/3] Ignore invalid font size --- webssh/static/js/main.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/webssh/static/js/main.js b/webssh/static/js/main.js index f7411e5..8f1e7e1 100644 --- a/webssh/static/js/main.js +++ b/webssh/static/js/main.js @@ -361,13 +361,18 @@ jQuery(function($){ decoder = window.TextDecoder ? new window.TextDecoder(encoding) : encoding, terminal = document.getElementById('terminal'), termOptions = { + cursorBlink: true, theme: { background: url_opts_data.bgcolor || 'black' } }; - if (url_opts_data.fontsize !== undefined) - termOptions.fontSize = parseInt(url_opts_data.fontsize); + if (url_opts_data.fontsize) { + var fontsize = window.parseInt(url_opts_data.fontsize); + if (fontsize && fontsize > 0) { + termOptions.fontSize = fontsize; + } + } var term = new window.Terminal(termOptions);