diff options
author | moisseev <moiseev@mezonplus.ru> | 2024-04-12 20:55:47 +0300 |
---|---|---|
committer | moisseev <moiseev@mezonplus.ru> | 2024-04-12 20:55:47 +0300 |
commit | 3637e1ee4d810d94887614a5a57ed3739fc2abcb (patch) | |
tree | ce2a99cc38c123ba5e7f6d7eddea00e6826d7570 /interface | |
parent | 48583c49818cbd06b977c9fc1b23949699f364d1 (diff) | |
download | rspamd-3637e1ee4d810d94887614a5a57ed3739fc2abcb.tar.gz rspamd-3637e1ee4d810d94887614a5a57ed3739fc2abcb.zip |
[WebUI] Add missing handler for file input
Diffstat (limited to 'interface')
-rw-r--r-- | interface/index.html | 2 | ||||
-rw-r--r-- | interface/js/app/upload.js | 36 |
2 files changed, 21 insertions, 17 deletions
diff --git a/interface/index.html b/interface/index.html index 5b3187309..329446a87 100644 --- a/interface/index.html +++ b/interface/index.html @@ -383,7 +383,7 @@ <span class="h6 fw-bolder my-auto">Scan suspected message</span> <div class="d-flex input-group-sm align-items-center ms-auto"> <label for="formFile" class="col-auto col-form-label-sm me-1">Choose a file:</label> - <input class="form-control form-control-sm btn btn-secondary" id="formFile" type="file"> + <input class="form-control form-control-sm btn btn-secondary" id="formFile" type="file" multiple> </div> </div> <div class="card-body"> diff --git a/interface/js/app/upload.js b/interface/js/app/upload.js index 5f330002b..a484a41aa 100644 --- a/interface/js/app/upload.js +++ b/interface/js/app/upload.js @@ -259,6 +259,24 @@ define(["jquery", "app/common", "app/libft"], return false; }); + function fileInputHandler(obj) { + ({files} = obj); + filesIdx = 0; + + if (files.length === 1) { + setFileInputFiles(0); + enable_disable_scan_btn(); + readFile((result) => { + $("#scanMsgSource").val(result); + enable_disable_scan_btn(); + }); + // eslint-disable-next-line no-alert + } else if (files.length < 10 || confirm("Are you sure you want to scan " + files.length + " files?")) { + getScanTextHeaders(); + readFile((result) => scanText(result)); + } + } + const dragoverClassList = "outline-dashed-primary bg-primary-subtle"; $("#scanMsgSource") .on("dragenter dragover dragleave drop", (e) => { @@ -271,23 +289,9 @@ define(["jquery", "app/common", "app/libft"], .on("dragleave drop", () => { $("#scanMsgSource").removeClass(dragoverClassList); }) - .on("drop", (e) => { - ({files} = e.originalEvent.dataTransfer); - filesIdx = 0; + .on("drop", (e) => fileInputHandler(e.originalEvent.dataTransfer)); - if (files.length === 1) { - setFileInputFiles(0); - enable_disable_scan_btn(); - readFile((result) => { - $("#scanMsgSource").val(result); - enable_disable_scan_btn(); - }); - // eslint-disable-next-line no-alert - } else if (files.length < 10 || confirm("Are you sure you want to scan " + files.length + " files?")) { - getScanTextHeaders(); - readFile((result) => scanText(result)); - } - }); + $("#formFile").on("change", (e) => fileInputHandler(e.target)); return ui; }); |