commit 1a11c378b2d19c8d0c028a5ab574139cdafc84d4
parent 234653f32447e410df7ba16499449fe00e1d7418
Author: Sheng <webmaster0115@gmail.com>
Date: Sat, 15 Sep 2018 09:31:03 +0800
Support Safari 11.x
Diffstat:
1 file changed, 28 insertions(+), 2 deletions(-)
diff --git a/webssh/static/js/main.js b/webssh/static/js/main.js
@@ -432,12 +432,38 @@ jQuery(function($){
}
+ function disable_file_inputs(inputs) {
+ var i, input;
+
+ for (i = 0; i < inputs.length; i++) {
+ input = inputs[i];
+ if (input.files.length === 0) {
+ input.setAttribute('disabled', '');
+ }
+ }
+ }
+
+
+ function enable_file_inputs(inputs) {
+ var i;
+
+ for (i = 0; i < inputs.length; i++) {
+ inputs[i].removeAttribute('disabled');
+ }
+ }
+
+
function connect_without_options() {
// use data from the form
var form = document.querySelector(form_id),
+ inputs = form.querySelectorAll('input[type="file"]'),
url = form.action,
- data = new FormData(form),
- pk = data.get('privatekey');
+ data, pk;
+
+ disable_file_inputs(inputs);
+ data = new FormData(form);
+ pk = data.get('privatekey');
+ enable_file_inputs(inputs);
function ajax_post() {
store_items(fields, data);