Add fontsize url parameter

pull/233/head
Tsung-en Hsiao 2021-08-23 07:01:03 +00:00
parent 2f0d5809ae
commit e4657761c9
2 changed files with 13 additions and 4 deletions

View File

@ -129,6 +129,11 @@ Passing an encoding
http://localhost:8888/#encoding=gbk http://localhost:8888/#encoding=gbk
``` ```
Passing a font size
```bash
http://localhost:8888/#fontsize=24
```
Passing a command executed right after login Passing a command executed right after login
```bash ```bash
http://localhost:8888/?command=pwd http://localhost:8888/?command=pwd

View File

@ -56,7 +56,7 @@ jQuery(function($){
key_max_size = 16384, key_max_size = 16384,
fields = ['hostname', 'port', 'username'], fields = ['hostname', 'port', 'username'],
form_keys = fields.concat(['password', 'totp']), 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_form_data = {},
url_opts_data = {}, url_opts_data = {},
validated_form_data, validated_form_data,
@ -360,12 +360,16 @@ jQuery(function($){
encoding = 'utf-8', encoding = 'utf-8',
decoder = window.TextDecoder ? new window.TextDecoder(encoding) : encoding, decoder = window.TextDecoder ? new window.TextDecoder(encoding) : encoding,
terminal = document.getElementById('terminal'), terminal = document.getElementById('terminal'),
term = new window.Terminal({ termOptions = {
cursorBlink: true,
theme: { theme: {
background: url_opts_data.bgcolor || 'black' 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.fitAddon = new window.FitAddon.FitAddon();
term.loadAddon(term.fitAddon); term.loadAddon(term.fitAddon);