Merge pull request #237 from fakeyw/dev_set_font_color

Add url param to change font color
This commit is contained in:
Shengdun Hua
2021-09-04 06:10:09 +08:00
committed by GitHub
2 changed files with 17 additions and 2 deletions
+5
View File
@@ -119,6 +119,11 @@ Passing a terminal background color
http://localhost:8888/#bgcolor=green http://localhost:8888/#bgcolor=green
``` ```
Passing a terminal font color
```bash
http://localhost:8888/#fontcolor=red
```
Passing a user defined title Passing a user defined title
```bash ```bash
http://localhost:8888/?title=my-ssh-server http://localhost:8888/?title=my-ssh-server
+12 -2
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', 'fontsize'], opts_keys = ['bgcolor', 'title', 'encoding', 'command', 'term', 'fontsize', 'fontcolor'],
url_form_data = {}, url_form_data = {},
url_opts_data = {}, url_opts_data = {},
validated_form_data, validated_form_data,
@@ -196,6 +196,11 @@ jQuery(function($){
}); });
} }
function set_font_color(term, color) {
term.setOption('theme', {
foreground: color
});
}
function custom_font_is_loaded() { function custom_font_is_loaded() {
if (!custom_font) { if (!custom_font) {
@@ -363,7 +368,8 @@ jQuery(function($){
termOptions = { termOptions = {
cursorBlink: true, cursorBlink: true,
theme: { theme: {
background: url_opts_data.bgcolor || 'black' background: url_opts_data.bgcolor || 'black',
foreground: url_opts_data.fontcolor || 'white'
} }
}; };
@@ -494,6 +500,10 @@ jQuery(function($){
set_backgound_color(term, color); set_backgound_color(term, color);
}; };
wssh.set_fontcolor = function(color) {
set_font_color(term, color);
};
wssh.custom_font = function() { wssh.custom_font = function() {
update_font_family(term); update_font_family(term);
}; };