Merge branch 'huashengdun:master' into master

pull/223/head
masc0 2021-08-28 10:30:42 +02:00 committed by GitHub
commit 7b29b1d00e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 5 deletions

View File

@ -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
@ -132,6 +132,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

View File

@ -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,21 @@ jQuery(function($){
encoding = 'utf-8',
decoder = window.TextDecoder ? new window.TextDecoder(encoding) : encoding,
terminal = document.getElementById('terminal'),
term = new window.Terminal({
termOptions = {
cursorBlink: true,
theme: {
background: url_opts_data.bgcolor || 'black'
}
});
};
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);
term.fitAddon = new window.FitAddon.FitAddon();
term.loadAddon(term.fitAddon);