|
@@ -119,7 +119,8 @@ function load(url,html = false)
|
|
|
.catch(() => {});
|
|
|
}
|
|
|
|
|
|
-// POST upload of data from within a form, with progress and response text
|
|
|
+// POST upload of data from within a form, with (optional)
|
|
|
+// progress and response text, and redirect after success
|
|
|
function upload(form,data) {
|
|
|
var xhr = new XMLHttpRequest();
|
|
|
|
|
@@ -165,15 +166,6 @@ function upload(form,data) {
|
|
|
return xhr;
|
|
|
}
|
|
|
|
|
|
-// Upload a data file blob
|
|
|
-function uploadfile() {
|
|
|
- event.preventDefault();
|
|
|
- const form = event.target.form || event.target;
|
|
|
- var files = form.elements['file'];
|
|
|
- return (files.files.length == 1)
|
|
|
- ? upload(form,files.files[0]) : files.click();
|
|
|
-}
|
|
|
-
|
|
|
// key=value formatting of form data; including inverted checkboxes
|
|
|
function textformdata(form) {
|
|
|
var data = '';
|
|
@@ -196,7 +188,13 @@ function textformdata(form) {
|
|
|
function uploadform() {
|
|
|
event.preventDefault();
|
|
|
const form = event.target.form || event.target;
|
|
|
- return upload(form,textformdata(form));
|
|
|
+ var files = form.elements['file'];
|
|
|
+ if (files == undefined)
|
|
|
+ return upload(form,textformdata(form));
|
|
|
+ else if (files.files.length == 1)
|
|
|
+ return upload(form,files.files[0]);
|
|
|
+ else
|
|
|
+ return files.click();
|
|
|
}
|
|
|
|
|
|
// Flip the status of an INPUT element between text and password
|