Hide the form when connecting

No need to show the form when connecting to a ssh server
if form arguments are passed via url
pull/83/head
Sheng 2019-08-23 09:55:42 +08:00
parent a11d5a01e5
commit 4e51d2c3ab
2 changed files with 19 additions and 2 deletions

View File

@ -38,6 +38,8 @@ var wssh = {};
jQuery(function($){ jQuery(function($){
var status = $('#status'), var status = $('#status'),
btn = $('.btn-primary'), btn = $('.btn-primary'),
form_container = $('.form-container'),
waiter = $('#waiter'),
style = {}, style = {},
default_title = 'WebSSH', default_title = 'WebSSH',
title_element = document.querySelector('title'), title_element = document.querySelector('title'),
@ -314,6 +316,15 @@ jQuery(function($){
if (fill_form && validated_form_data) { if (fill_form && validated_form_data) {
restore_items(fields.concat(['password']), validated_form_data); restore_items(fields.concat(['password']), validated_form_data);
validated_form_data = undefined;
}
if (waiter.css('display') !== 'none') {
waiter.hide();
}
if (form_container.css('display') === 'none') {
form_container.show();
} }
} }
@ -692,6 +703,9 @@ jQuery(function($){
data._origin = event_origin; data._origin = event_origin;
} }
status.text('');
btn.prop('disabled', true);
$.ajax({ $.ajax({
url: url, url: url,
type: 'post', type: 'post',
@ -802,9 +816,11 @@ jQuery(function($){
log_status('Password via url must be encoded in base64.'); log_status('Password via url must be encoded in base64.');
} else { } else {
if (get_object_length(url_form_data)) { if (get_object_length(url_form_data)) {
waiter.show();
connect(url_form_data); connect(url_form_data);
} else { } else {
restore_items(fields); restore_items(fields);
form_container.show();
} }
} }

View File

@ -27,7 +27,9 @@
</style> </style>
</head> </head>
<body> <body>
<div class="container"> <div id="waiter" style="display: none"> Connecting ... </div>
<div class="container form-container" style="display: none">
<form id="connect" action="" method="post" enctype="multipart/form-data"{% if debug %} novalidate{% end %}> <form id="connect" action="" method="post" enctype="multipart/form-data"{% if debug %} novalidate{% end %}>
<div class="row"> <div class="row">
<div class="col"> <div class="col">
@ -71,7 +73,6 @@
<button type="submit" class="btn btn-primary">Connect</button> <button type="submit" class="btn btn-primary">Connect</button>
<button type="reset" class="btn btn-danger">Reset</button> <button type="reset" class="btn btn-danger">Reset</button>
</form> </form>
</div> </div>
<div class="container"> <div class="container">