]> source.dussan.org Git - rspamd.git/commitdiff
[WebUI] Add missing handler for file input 4922/head
authormoisseev <moiseev@mezonplus.ru>
Fri, 12 Apr 2024 17:55:47 +0000 (20:55 +0300)
committermoisseev <moiseev@mezonplus.ru>
Fri, 12 Apr 2024 17:55:47 +0000 (20:55 +0300)
interface/index.html
interface/js/app/upload.js

index 5b3187309181535115d341370ca9af44152229d7..329446a872f6f918ef7d8f6299ed509972afd2bf 100644 (file)
                                                <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">
index 5f330002b1b7d36e3a2120f7cbd5fe1469aeaa9d..a484a41aaced5e3ab6c270b2c43de73038a2fc69 100644 (file)
@@ -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;
     });