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 20449d03ad76ae5697f3422477ddab0fd444d517
parent f4197f0e4c9133dc788a86544ae83b1d8cd40570
Author: Sheng <webmaster0115@gmail.com>
Date:   Sat, 18 Aug 2018 19:00:06 +0800

Added set_encoding and reset_encoding

Diffstat:
Mwebssh/static/js/main.js | 26+++++++++++++++++++++++---
Mwebssh/templates/index.html | 10+++++-----
2 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/webssh/static/js/main.js b/webssh/static/js/main.js @@ -66,9 +66,29 @@ jQuery(function($){ }); console.log(url); - console.log(encoding); + console.log('The deault encoding of your server is ' + encoding); wssh.sock = sock; wssh.term = term; + var test_decoder; + + wssh.set_encoding = function (new_encoding) { + try { + test_decoder = new window.TextDecoder(new_encoding); + } catch(TypeError) { + console.log('Unvalid encoding ' + new_encoding); + } finally { + if (test_decoder !== undefined) { + encoding = new_encoding; + console.log('Set encoding to ' + encoding); + } + test_decoder = undefined; + } + }; + + wssh.reset_encoding = function () { + encoding = msg.encoding; + console.log('Reset encoding to ' + msg.encoding); + }; term.on('data', function(data) { // console.log(data); @@ -119,7 +139,7 @@ jQuery(function($){ var form = $(this), url = form.attr('action'), - type = form.attr('type'), + type = form.attr('method'), data = new FormData(this); if (!data.get('hostname') || !data.get('port') || !data.get('username')) { @@ -129,7 +149,7 @@ jQuery(function($){ var pk = data.get('privatekey'); if (pk && pk.size > 16384) { - status.text('Key size exceeds maximum value.'); + status.text('Key size exceeds the maximum value.'); return; } diff --git a/webssh/templates/index.html b/webssh/templates/index.html @@ -21,21 +21,21 @@ </head> <body> <div class="container"> - <form id="connect" action="" type="post" enctype="multipart/form-data"> + <form id="connect" action="" method="post" enctype="multipart/form-data"> <div class="row"> <div class="col"> <label for="Hostname">Hostname</label> - <input class="form-control" type="text" name="hostname" value=""> + <input class="form-control" type="text" name="hostname" value="" required> </div> <div class="col"> <label for="Port">Port</label> - <input class="form-control" type="text" name="port" value=""> + <input class="form-control" type="number" name="port" min=1 max=65535 value="" required> </div> </div> <div class="row"> <div class="col"> <label for="Username">Username</label> - <input class="form-control" type="text" name="username" value=""> + <input class="form-control" type="text" name="username" value="" required> </div> <div class="col"> <label for="Username">Private Key</label> @@ -45,7 +45,7 @@ <div class="row"> <div class="col"> <label for="Password">Password</label> - <input class="form-control" type="password" name="password" placeholder="" value=""> + <input class="form-control" type="password" name="password" value=""> </div> <div class="col"> If Private Key is chosen, password will be used to decrypt the Private Key if it is encrypted, otherwise used as the password of username.