Check wssh is connected before connecting

pull/26/head v0.3.5
Sheng 2018-08-22 18:55:09 +08:00
parent a5d3cbfee8
commit 24a619ae6b
2 changed files with 9 additions and 1 deletions

View File

@ -1,2 +1,2 @@
__version_info__ = (0, 3, 4)
__version_info__ = (0, 3, 5)
__version__ = '.'.join(map(str, __version_info__))

View File

@ -8,6 +8,7 @@ jQuery(function($){
var status = $('#status'),
btn = $('.btn-primary'),
style = {},
connected = false,
key_max_size = 16384,
form_id = '#connect',
names = ['hostname', 'port', 'username', 'password'],
@ -208,6 +209,7 @@ jQuery(function($){
$('.container').hide();
term.open(terminal, true);
term.toggleFullscreen(true);
connected = true;
};
sock.onmessage = function(msg) {
@ -241,6 +243,7 @@ jQuery(function($){
reset_wssh();
$('.container').show();
status.text(e.reason);
connected = false;
};
$(window).resize(function(){
@ -252,6 +255,11 @@ jQuery(function($){
function connect() {
if (connected) {
console.log('This client was already connected.');
return;
}
var form = document.querySelector(form_id),
url = form.action,
data = new FormData(form),