]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Remove temporary IIFEs 4705/head
authormoisseev <moiseev@mezonplus.ru>
Thu, 16 Nov 2023 14:42:18 +0000 (17:42 +0300)
committermoisseev <moiseev@mezonplus.ru>
Thu, 16 Nov 2023 14:42:18 +0000 (17:42 +0300)
.eslintrc.json
interface/js/app/config.js
interface/js/app/graph.js
interface/js/app/history.js
interface/js/app/rspamd.js
interface/js/app/selectors.js
interface/js/app/symbols.js
interface/js/app/upload.js

index a2d754d5d371b1e1c9c33e3aa8d673b20f993581..c224b5d007803e3a3e4bdeca05765d5cb5ce855a 100644 (file)
@@ -28,7 +28,7 @@
         "line-comment-position": "off",
         "logical-assignment-operators": ["error", "never"],
         "max-params": ["warn", 6],
-        "max-statements": ["warn", 50],
+        "max-statements": ["warn", 55],
         "max-statements-per-line": ["error", { "max": 2 }],
         "multiline-comment-style": "off",
         "multiline-ternary": ["error", "always-multiline"],
index df912eeeaa860eea4c9f78b9191dcc32ba48694c..dd47578ae1b11b94451de6ccf7e05b3d0478c487 100644 (file)
@@ -144,109 +144,108 @@ define(["jquery", "app/rspamd"],
             });
         };
 
-        (() => {
-            var jar = {};
-            const editor = {
-                advanced: {
-                    codejar: true,
-                    elt: "div",
-                    class: "editor language-clike",
-                    readonly_attr: {contenteditable: false},
-                },
-                basic: {
-                    elt: "textarea",
-                    class: "form-control map-textarea",
-                    readonly_attr: {readonly: true},
-                }
-            };
-            let mode = "advanced";
-
-            // Modal form for maps
-            $(document).on("click", "[data-bs-toggle=\"modal\"]", function () {
-                var checked_server = rspamd.getSelector("selSrv");
-                var item = $(this).data("item");
-                rspamd.query("getmap", {
-                    headers: {
-                        Map: item.map
-                    },
-                    success: function (data) {
-                        // Highlighting a large amount of text is unresponsive
-                        mode = (new Blob([data[0].data]).size > 5120) ? "basic" : $("input[name=editorMode]:checked").val();
-
-                        $("<" + editor[mode].elt + ' id="editor" class="' + editor[mode].class + '" data-id="' + item.map + '">' +
-                            "</" + editor[mode].elt + ">").appendTo("#modalBody");
-
-                        if (editor[mode].codejar) {
-                            require(["codejar", "linenumbers", "prism"], function (CodeJar, withLineNumbers, Prism) {
-                                jar = new CodeJar(
-                                    document.querySelector("#editor"),
-                                    withLineNumbers((el) => Prism.highlightElement(el))
-                                );
-                                jar.updateCode(data[0].data);
-                            });
-                        } else {
-                            document.querySelector("#editor").innerHTML = rspamd.escapeHTML(data[0].data);
-                        }
 
-                        var icon = "fa-edit";
-                        if (item.editable === false || rspamd.read_only) {
-                            $("#editor").attr(editor[mode].readonly_attr);
-                            icon = "fa-eye";
-                            $("#modalSaveGroup").hide();
-                        } else {
-                            $("#modalSaveGroup").show();
-                        }
-                        $("#modalDialog .modal-header").find("[data-fa-i2svg]").addClass(icon);
-                        $("#modalTitle").html(item.uri);
+        var jar = {};
+        const editor = {
+            advanced: {
+                codejar: true,
+                elt: "div",
+                class: "editor language-clike",
+                readonly_attr: {contenteditable: false},
+            },
+            basic: {
+                elt: "textarea",
+                class: "form-control map-textarea",
+                readonly_attr: {readonly: true},
+            }
+        };
+        let mode = "advanced";
+
+        // Modal form for maps
+        $(document).on("click", "[data-bs-toggle=\"modal\"]", function () {
+            var checked_server = rspamd.getSelector("selSrv");
+            var item = $(this).data("item");
+            rspamd.query("getmap", {
+                headers: {
+                    Map: item.map
+                },
+                success: function (data) {
+                    // Highlighting a large amount of text is unresponsive
+                    mode = (new Blob([data[0].data]).size > 5120) ? "basic" : $("input[name=editorMode]:checked").val();
+
+                    $("<" + editor[mode].elt + ' id="editor" class="' + editor[mode].class + '" data-id="' + item.map + '">' +
+                        "</" + editor[mode].elt + ">").appendTo("#modalBody");
+
+                    if (editor[mode].codejar) {
+                        require(["codejar", "linenumbers", "prism"], function (CodeJar, withLineNumbers, Prism) {
+                            jar = new CodeJar(
+                                document.querySelector("#editor"),
+                                withLineNumbers((el) => Prism.highlightElement(el))
+                            );
+                            jar.updateCode(data[0].data);
+                        });
+                    } else {
+                        document.querySelector("#editor").innerHTML = rspamd.escapeHTML(data[0].data);
+                    }
 
-                        $("#modalDialog").modal("show");
-                    },
-                    errorMessage: "Cannot receive maps data",
-                    server: (checked_server === "All SERVERS") ? "local" : checked_server
-                });
-                return false;
-            });
-            $("#modalDialog").on("hidden.bs.modal", function () {
-                if (editor[mode].codejar) {
-                    jar.destroy();
-                    $(".codejar-wrap").remove();
-                } else {
-                    $("#editor").remove();
-                }
-            });
+                    var icon = "fa-edit";
+                    if (item.editable === false || rspamd.read_only) {
+                        $("#editor").attr(editor[mode].readonly_attr);
+                        icon = "fa-eye";
+                        $("#modalSaveGroup").hide();
+                    } else {
+                        $("#modalSaveGroup").show();
+                    }
+                    $("#modalDialog .modal-header").find("[data-fa-i2svg]").addClass(icon);
+                    $("#modalTitle").html(item.uri);
 
-            $("#saveActionsBtn").on("click", function () {
-                ui.saveActions();
-            });
-            $("#saveActionsClusterBtn").on("click", function () {
-                ui.saveActions("All SERVERS");
+                    $("#modalDialog").modal("show");
+                },
+                errorMessage: "Cannot receive maps data",
+                server: (checked_server === "All SERVERS") ? "local" : checked_server
             });
-
-            function saveMap(server) {
-                rspamd.query("savemap", {
-                    success: function () {
-                        rspamd.alertMessage("alert-success", "Map data successfully saved");
-                        $("#modalDialog").modal("hide");
-                    },
-                    errorMessage: "Save map error",
-                    method: "POST",
-                    headers: {
-                        Map: $("#editor").data("id"),
-                    },
-                    params: {
-                        data: editor[mode].codejar ? jar.toString() : $("#editor").val(),
-                        dataType: "text",
-                    },
-                    server: server
-                });
+            return false;
+        });
+        $("#modalDialog").on("hidden.bs.modal", function () {
+            if (editor[mode].codejar) {
+                jar.destroy();
+                $(".codejar-wrap").remove();
+            } else {
+                $("#editor").remove();
             }
-            $("#modalSave").on("click", function () {
-                saveMap();
-            });
-            $("#modalSaveAll").on("click", function () {
-                saveMap("All SERVERS");
+        });
+
+        $("#saveActionsBtn").on("click", function () {
+            ui.saveActions();
+        });
+        $("#saveActionsClusterBtn").on("click", function () {
+            ui.saveActions("All SERVERS");
+        });
+
+        function saveMap(server) {
+            rspamd.query("savemap", {
+                success: function () {
+                    rspamd.alertMessage("alert-success", "Map data successfully saved");
+                    $("#modalDialog").modal("hide");
+                },
+                errorMessage: "Save map error",
+                method: "POST",
+                headers: {
+                    Map: $("#editor").data("id"),
+                },
+                params: {
+                    data: editor[mode].codejar ? jar.toString() : $("#editor").val(),
+                    dataType: "text",
+                },
+                server: server
             });
-        })();
+        }
+        $("#modalSave").on("click", function () {
+            saveMap();
+        });
+        $("#modalSaveAll").on("click", function () {
+            saveMap("All SERVERS");
+        });
 
         return ui;
     });
index e55214c955a2699e8201431b26ef7da59c0d7572..3dca7da9ce07c1237e05b81dd20e5aacfdda537b 100644 (file)
@@ -199,6 +199,7 @@ define(["jquery", "app/rspamd", "d3evolution", "d3pie", "d3", "footable"],
                 graphs.graph = initGraph();
             }
 
+
             rspamd.query("graph", {
                 success: function (req_data) {
                     var data = null;
@@ -243,17 +244,16 @@ define(["jquery", "app/rspamd", "d3evolution", "d3pie", "d3", "footable"],
             });
         };
 
-        (() => {
-            // Handling mouse events on overlapping elements
-            $("#rrd-pie").mouseover(function () {
-                $("#rrd-pie,#rrd-pie-tooltip").css("z-index", "200");
-                $("#rrd-table_toggle").css("z-index", "300");
-            });
-            $("#rrd-table_toggle").mouseover(function () {
-                $("#rrd-pie,#rrd-pie-tooltip").css("z-index", "0");
-                $("#rrd-table_toggle").css("z-index", "0");
-            });
-        })();
+
+        // Handling mouse events on overlapping elements
+        $("#rrd-pie").mouseover(function () {
+            $("#rrd-pie,#rrd-pie-tooltip").css("z-index", "200");
+            $("#rrd-table_toggle").css("z-index", "300");
+        });
+        $("#rrd-table_toggle").mouseover(function () {
+            $("#rrd-pie,#rrd-pie-tooltip").css("z-index", "0");
+            $("#rrd-table_toggle").css("z-index", "0");
+        });
 
         return ui;
     });
index add8e86bd50b57131efbaef94c8b34dabf24af41..4118bc61da1c0c7d3438d4ecdafdf1f99ff9ff19 100644 (file)
@@ -379,36 +379,6 @@ define(["jquery", "app/rspamd", "d3", "footable"],
             });
         };
 
-        (() => {
-            rspamd.set_page_size("history", $("#history_page_size").val());
-            rspamd.bindHistoryTableEventHandlers("history", 8);
-
-            $("#updateHistory").off("click");
-            $("#updateHistory").on("click", function (e) {
-                e.preventDefault();
-                ui.getHistory();
-            });
-
-            // @reset history log
-            $("#resetHistory").off("click");
-            $("#resetHistory").on("click", function (e) {
-                e.preventDefault();
-                if (!confirm("Are you sure you want to reset history log?")) { // eslint-disable-line no-alert
-                    return;
-                }
-                rspamd.destroyTable("history");
-                rspamd.destroyTable("errors");
-
-                rspamd.query("historyreset", {
-                    success: function () {
-                        ui.getHistory();
-                        ui.getErrors();
-                    },
-                    errorMessage: "Cannot reset history log"
-                });
-            });
-        })();
-
         function initErrorsTable(rows) {
             rspamd.tables.errors = FooTable.init("#errorsLog", {
                 columns: [
@@ -479,5 +449,34 @@ define(["jquery", "app/rspamd", "d3", "footable"],
             });
         };
 
+
+        rspamd.set_page_size("history", $("#history_page_size").val());
+        rspamd.bindHistoryTableEventHandlers("history", 8);
+
+        $("#updateHistory").off("click");
+        $("#updateHistory").on("click", function (e) {
+            e.preventDefault();
+            ui.getHistory();
+        });
+
+        // @reset history log
+        $("#resetHistory").off("click");
+        $("#resetHistory").on("click", function (e) {
+            e.preventDefault();
+            if (!confirm("Are you sure you want to reset history log?")) { // eslint-disable-line no-alert
+                return;
+            }
+            rspamd.destroyTable("history");
+            rspamd.destroyTable("errors");
+
+            rspamd.query("historyreset", {
+                success: function () {
+                    ui.getHistory();
+                    ui.getErrors();
+                },
+                errorMessage: "Cannot reset history log"
+            });
+        });
+
         return ui;
     });
index 2f1f66394f8f95d7857896e16c6d968ac469d3da..faec47f7fa270c42cc4e63e70120f4086c93cc9e 100644 (file)
@@ -439,150 +439,6 @@ function ($, NProgress) {
 
     // Public functions
     ui.alertMessage = alertMessage;
-    (() => {
-        (function initSettings() {
-            var selected_locale = null;
-            var custom_locale = null;
-            const localeTextbox = ".popover #settings-popover #locale";
-
-            function validateLocale(saveToLocalStorage) {
-                function toggle_form_group_class(remove, add) {
-                    $(localeTextbox).removeClass("is-" + remove).addClass("is-" + add);
-                }
-
-                var now = new Date();
-
-                if (custom_locale.length) {
-                    try {
-                        now.toLocaleString(custom_locale);
-
-                        if (saveToLocalStorage) localStorage.setItem("custom_locale", custom_locale);
-                        locale = (selected_locale === "custom") ? custom_locale : null;
-                        toggle_form_group_class("invalid", "valid");
-                    } catch (err) {
-                        locale = null;
-                        toggle_form_group_class("valid", "invalid");
-                    }
-                } else {
-                    if (saveToLocalStorage) localStorage.setItem("custom_locale", null);
-                    locale = null;
-                    $(localeTextbox).removeClass("is-valid is-invalid");
-                }
-
-                // Display date example
-                $(".popover #settings-popover #date-example").text(
-                    (locale)
-                        ? now.toLocaleString(locale)
-                        : now.toLocaleString()
-                );
-            }
-
-            $("#settings").popover({
-                container: "body",
-                placement: "bottom",
-                html: true,
-                sanitize: false,
-                content: function () {
-                    // Using .clone() has the side-effect of producing elements with duplicate id attributes.
-                    return $("#settings-popover").clone();
-                }
-            // Restore the tooltip of the element that the popover is attached to.
-            }).attr("title", function () {
-                return $(this).attr("data-original-title");
-            });
-            $("#settings").on("click", function (e) {
-                e.preventDefault();
-            });
-            $("#settings").on("inserted.bs.popover", function () {
-                selected_locale = localStorage.getItem("selected_locale") || "browser";
-                custom_locale = localStorage.getItem("custom_locale") || "";
-                validateLocale();
-
-                $('.popover #settings-popover input:radio[name="locale"]').val([selected_locale]);
-                $(localeTextbox).val(custom_locale);
-
-                ajaxSetup(localStorage.getItem("ajax_timeout"), true);
-            });
-            $(document).on("change", '.popover #settings-popover input:radio[name="locale"]', function () {
-                selected_locale = this.value;
-                localStorage.setItem("selected_locale", selected_locale);
-                validateLocale();
-            });
-            $(document).on("input", localeTextbox, function () {
-                custom_locale = $(localeTextbox).val();
-                validateLocale(true);
-            });
-            $(document).on("input", ajaxTimeoutBox, function () {
-                ajaxSetup($(ajaxTimeoutBox).val(), false, true);
-            });
-            $(document).on("click", ".popover #settings-popover #ajax-timeout-restore", function () {
-                ajaxSetup(null, true, true);
-            });
-
-            // Dismiss Bootstrap popover by clicking outside
-            $("body").on("click", function (e) {
-                $(".popover").each(function () {
-                    if (
-                        // Popover's descendant
-                        $(this).has(e.target).length ||
-                        // Button (or icon within a button) that triggers the popover.
-                        $(e.target).closest("button").attr("aria-describedby") === this.id
-                    ) return;
-                    $("#settings").popover("hide");
-                });
-            });
-        }());
-
-        $("#selData").change(function () {
-            tabClick("#throughput_nav");
-        });
-
-        $(document).ajaxStart(function () {
-            $("#refresh > svg").addClass("fa-spin");
-        });
-        $(document).ajaxComplete(function () {
-            setTimeout(function () {
-                $("#refresh > svg").removeClass("fa-spin");
-            }, 1000);
-        });
-
-        $('a[data-bs-toggle="tab"]').on("shown.bs.tab", function () {
-            tabClick("#" + $(this).attr("id"));
-        });
-        $("#refresh, #disconnect").on("click", function (e) {
-            e.preventDefault();
-            tabClick("#" + $(this).attr("id"));
-        });
-        $(".dropdown-menu a").click(function (e) {
-            e.preventDefault();
-            var classList = $(this).attr("class");
-            var menuClass = (/\b(?:dynamic|history|preset)\b/).exec(classList)[0];
-            $(".dropdown-menu a.active." + menuClass).removeClass("active");
-            $(this).addClass("active");
-            tabClick("#autoRefresh");
-        });
-
-        $("#selSrv").change(function () {
-            checked_server = this.value;
-            $("#selSrv [value=\"" + checked_server + "\"]").prop("checked", true);
-            if (checked_server === "All SERVERS") {
-                $("#learnServers").show();
-            } else {
-                $("#learnServers").hide();
-            }
-            tabClick("#" + $("#tablist > .nav-item > .nav-link.active").attr("id"));
-        });
-
-        // Radio buttons
-        $(document).on("click", "input:radio[name=\"clusterName\"]", function () {
-            if (!this.disabled) {
-                checked_server = this.value;
-                tabClick("#status_nav");
-            }
-        });
-
-        $("#loading").addClass("d-none");
-    })();
 
     ui.connect = function () {
         // Prevent locking out of the WebUI if timeout is too low.
@@ -1078,5 +934,149 @@ function ($, NProgress) {
         return null;
     };
 
+
+    (function initSettings() {
+        var selected_locale = null;
+        var custom_locale = null;
+        const localeTextbox = ".popover #settings-popover #locale";
+
+        function validateLocale(saveToLocalStorage) {
+            function toggle_form_group_class(remove, add) {
+                $(localeTextbox).removeClass("is-" + remove).addClass("is-" + add);
+            }
+
+            var now = new Date();
+
+            if (custom_locale.length) {
+                try {
+                    now.toLocaleString(custom_locale);
+
+                    if (saveToLocalStorage) localStorage.setItem("custom_locale", custom_locale);
+                    locale = (selected_locale === "custom") ? custom_locale : null;
+                    toggle_form_group_class("invalid", "valid");
+                } catch (err) {
+                    locale = null;
+                    toggle_form_group_class("valid", "invalid");
+                }
+            } else {
+                if (saveToLocalStorage) localStorage.setItem("custom_locale", null);
+                locale = null;
+                $(localeTextbox).removeClass("is-valid is-invalid");
+            }
+
+            // Display date example
+            $(".popover #settings-popover #date-example").text(
+                (locale)
+                    ? now.toLocaleString(locale)
+                    : now.toLocaleString()
+            );
+        }
+
+        $("#settings").popover({
+            container: "body",
+            placement: "bottom",
+            html: true,
+            sanitize: false,
+            content: function () {
+                // Using .clone() has the side-effect of producing elements with duplicate id attributes.
+                return $("#settings-popover").clone();
+            }
+        // Restore the tooltip of the element that the popover is attached to.
+        }).attr("title", function () {
+            return $(this).attr("data-original-title");
+        });
+        $("#settings").on("click", function (e) {
+            e.preventDefault();
+        });
+        $("#settings").on("inserted.bs.popover", function () {
+            selected_locale = localStorage.getItem("selected_locale") || "browser";
+            custom_locale = localStorage.getItem("custom_locale") || "";
+            validateLocale();
+
+            $('.popover #settings-popover input:radio[name="locale"]').val([selected_locale]);
+            $(localeTextbox).val(custom_locale);
+
+            ajaxSetup(localStorage.getItem("ajax_timeout"), true);
+        });
+        $(document).on("change", '.popover #settings-popover input:radio[name="locale"]', function () {
+            selected_locale = this.value;
+            localStorage.setItem("selected_locale", selected_locale);
+            validateLocale();
+        });
+        $(document).on("input", localeTextbox, function () {
+            custom_locale = $(localeTextbox).val();
+            validateLocale(true);
+        });
+        $(document).on("input", ajaxTimeoutBox, function () {
+            ajaxSetup($(ajaxTimeoutBox).val(), false, true);
+        });
+        $(document).on("click", ".popover #settings-popover #ajax-timeout-restore", function () {
+            ajaxSetup(null, true, true);
+        });
+
+        // Dismiss Bootstrap popover by clicking outside
+        $("body").on("click", function (e) {
+            $(".popover").each(function () {
+                if (
+                    // Popover's descendant
+                    $(this).has(e.target).length ||
+                    // Button (or icon within a button) that triggers the popover.
+                    $(e.target).closest("button").attr("aria-describedby") === this.id
+                ) return;
+                $("#settings").popover("hide");
+            });
+        });
+    }());
+
+    $("#selData").change(function () {
+        tabClick("#throughput_nav");
+    });
+
+    $(document).ajaxStart(function () {
+        $("#refresh > svg").addClass("fa-spin");
+    });
+    $(document).ajaxComplete(function () {
+        setTimeout(function () {
+            $("#refresh > svg").removeClass("fa-spin");
+        }, 1000);
+    });
+
+    $('a[data-bs-toggle="tab"]').on("shown.bs.tab", function () {
+        tabClick("#" + $(this).attr("id"));
+    });
+    $("#refresh, #disconnect").on("click", function (e) {
+        e.preventDefault();
+        tabClick("#" + $(this).attr("id"));
+    });
+    $(".dropdown-menu a").click(function (e) {
+        e.preventDefault();
+        var classList = $(this).attr("class");
+        var menuClass = (/\b(?:dynamic|history|preset)\b/).exec(classList)[0];
+        $(".dropdown-menu a.active." + menuClass).removeClass("active");
+        $(this).addClass("active");
+        tabClick("#autoRefresh");
+    });
+
+    $("#selSrv").change(function () {
+        checked_server = this.value;
+        $("#selSrv [value=\"" + checked_server + "\"]").prop("checked", true);
+        if (checked_server === "All SERVERS") {
+            $("#learnServers").show();
+        } else {
+            $("#learnServers").hide();
+        }
+        tabClick("#" + $("#tablist > .nav-item > .nav-link.active").attr("id"));
+    });
+
+    // Radio buttons
+    $(document).on("click", "input:radio[name=\"clusterName\"]", function () {
+        if (!this.disabled) {
+            checked_server = this.value;
+            tabClick("#status_nav");
+        }
+    });
+
+    $("#loading").addClass("d-none");
+
     return ui;
 });
index b47488ad0f68816bc6af74db180711277089ce5c..8e9da052b347bd78c2e611422033447b8e06d607 100644 (file)
@@ -91,56 +91,55 @@ define(["jquery", "app/rspamd"],
             if (!$("#selectorsSelArea").is(".is-valid, .is-invalid")) checkSelectors();
         };
 
-        (() => {
-            function toggleSidebar(side) {
-                $("#sidebar-" + side).toggleClass("collapsed");
-                var contentClass = "col-lg-6";
-                var openSidebarsCount = $("#sidebar-left").hasClass("collapsed") +
-                        $("#sidebar-right").hasClass("collapsed");
-                switch (openSidebarsCount) {
-                    case 1:
-                        contentClass = "col-lg-9";
-                        break;
-                    case 2:
-                        contentClass = "col-lg-12";
-                        break;
-                    default:
-                }
-                $("#content").removeClass("col-lg-12 col-lg-9 col-lg-6")
-                    .addClass(contentClass);
+
+        function toggleSidebar(side) {
+            $("#sidebar-" + side).toggleClass("collapsed");
+            var contentClass = "col-lg-6";
+            var openSidebarsCount = $("#sidebar-left").hasClass("collapsed") +
+                    $("#sidebar-right").hasClass("collapsed");
+            switch (openSidebarsCount) {
+                case 1:
+                    contentClass = "col-lg-9";
+                    break;
+                case 2:
+                    contentClass = "col-lg-12";
+                    break;
+                default:
             }
-            $("#sidebar-tab-left>a").click(function () {
-                toggleSidebar("left");
-                return false;
-            });
-            $("#sidebar-tab-right>a").click(function () {
-                toggleSidebar("right");
-                return false;
-            });
+            $("#content").removeClass("col-lg-12 col-lg-9 col-lg-6")
+                .addClass(contentClass);
+        }
+        $("#sidebar-tab-left>a").click(function () {
+            toggleSidebar("left");
+            return false;
+        });
+        $("#sidebar-tab-right>a").click(function () {
+            toggleSidebar("right");
+            return false;
+        });
 
-            $("#selectorsMsgClean").on("click", function () {
-                $("#selectorsChkMsgBtn").attr("disabled", true);
-                $("#selectorsMsgArea").val("");
-                return false;
-            });
-            $("#selectorsClean").on("click", function () {
-                $("#selectorsSelArea").val("");
-                checkSelectors();
-                return false;
-            });
-            $("#selectorsChkMsgBtn").on("click", function () {
-                $("#selectorsResArea").val("");
-                checkMsg($("#selectorsMsgArea").val());
-                return false;
-            });
+        $("#selectorsMsgClean").on("click", function () {
+            $("#selectorsChkMsgBtn").attr("disabled", true);
+            $("#selectorsMsgArea").val("");
+            return false;
+        });
+        $("#selectorsClean").on("click", function () {
+            $("#selectorsSelArea").val("");
+            checkSelectors();
+            return false;
+        });
+        $("#selectorsChkMsgBtn").on("click", function () {
+            $("#selectorsResArea").val("");
+            checkMsg($("#selectorsMsgArea").val());
+            return false;
+        });
 
-            $("#selectorsMsgArea").on("input", function () {
-                enable_disable_check_btn();
-            });
-            $("#selectorsSelArea").on("input", function () {
-                checkSelectors();
-            });
-        })();
+        $("#selectorsMsgArea").on("input", function () {
+            enable_disable_check_btn();
+        });
+        $("#selectorsSelArea").on("input", function () {
+            checkSelectors();
+        });
 
         return ui;
     });
index a183a270c0845cb9cbe105f8987242f2c020cb65..8718599d7b13696dad318a8c6a3ef1cd6e7e7f72 100644 (file)
@@ -242,19 +242,18 @@ define(["jquery", "app/rspamd", "footable"],
                 });
         };
 
-        (() => {
-            $("#updateSymbols").on("click", function (e) {
-                e.preventDefault();
-                var checked_server = rspamd.getSelector("selSrv");
-                rspamd.query("symbols", {
-                    success: function (data) {
-                        var items = process_symbols_data(data[0].data)[0];
-                        rspamd.tables.symbols.rows.load(items);
-                    },
-                    server: (checked_server === "All SERVERS") ? "local" : checked_server
-                });
+
+        $("#updateSymbols").on("click", function (e) {
+            e.preventDefault();
+            var checked_server = rspamd.getSelector("selSrv");
+            rspamd.query("symbols", {
+                success: function (data) {
+                    var items = process_symbols_data(data[0].data)[0];
+                    rspamd.tables.symbols.rows.load(items);
+                },
+                server: (checked_server === "All SERVERS") ? "local" : checked_server
             });
-        })();
+        });
 
         return ui;
     });
index a63fd4f66882a59a825b171d537dba6c9e6405a2..269d32460d3e77f2b8c8ab85be4babf4b63e9213 100644 (file)
@@ -240,72 +240,71 @@ define(["jquery", "app/rspamd"],
             });
         }
 
-        (() => {
-            rspamd.set_page_size("scan", $("#scan_page_size").val());
-            rspamd.bindHistoryTableEventHandlers("scan", 3);
 
-            $("#cleanScanHistory").off("click");
-            $("#cleanScanHistory").on("click", function (e) {
-                e.preventDefault();
-                if (!confirm("Are you sure you want to clean scan history?")) { // eslint-disable-line no-alert
-                    return;
-                }
-                rspamd.destroyTable("scan");
-                rspamd.symbols.scan.length = 0;
-                $("#cleanScanHistory").attr("disabled", true);
-            });
+        rspamd.set_page_size("scan", $("#scan_page_size").val());
+        rspamd.bindHistoryTableEventHandlers("scan", 3);
 
-            function enable_disable_scan_btn() {
-                $("#scan button:not(#cleanScanHistory, #scanOptionsToggle)").prop("disabled", ($.trim($("textarea").val()).length === 0));
+        $("#cleanScanHistory").off("click");
+        $("#cleanScanHistory").on("click", function (e) {
+            e.preventDefault();
+            if (!confirm("Are you sure you want to clean scan history?")) { // eslint-disable-line no-alert
+                return;
             }
+            rspamd.destroyTable("scan");
+            rspamd.symbols.scan.length = 0;
+            $("#cleanScanHistory").attr("disabled", true);
+        });
+
+        function enable_disable_scan_btn() {
+            $("#scan button:not(#cleanScanHistory, #scanOptionsToggle)").prop("disabled", ($.trim($("textarea").val()).length === 0));
+        }
+        enable_disable_scan_btn();
+        $("textarea").on("input", function () {
             enable_disable_scan_btn();
-            $("textarea").on("input", function () {
-                enable_disable_scan_btn();
-            });
+        });
 
-            $("#scanClean").on("click", function () {
-                $("#scan button:not(#cleanScanHistory, #scanOptionsToggle)").attr("disabled", true);
-                $("#scanForm")[0].reset();
-                $("#scanResult").hide();
-                $("#scanOutput tbody").remove();
-                $("html, body").animate({scrollTop:0}, 1000);
-                return false;
-            });
+        $("#scanClean").on("click", function () {
+            $("#scan button:not(#cleanScanHistory, #scanOptionsToggle)").attr("disabled", true);
+            $("#scanForm")[0].reset();
+            $("#scanResult").hide();
+            $("#scanOutput tbody").remove();
+            $("html, body").animate({scrollTop:0}, 1000);
+            return false;
+        });
 
-            $(".card-close-btn").on("click", function () {
-                $(this).closest(".card").slideUp();
-            });
+        $(".card-close-btn").on("click", function () {
+            $(this).closest(".card").slideUp();
+        });
 
-            $("[data-upload]").on("click", function () {
-                var source = $(this).data("upload");
-                var data = $("#scanMsgSource").val();
-                var headers = {};
-                if ($.trim(data).length > 0) {
-                    if (source === "scan") {
-                        headers = ["IP", "User", "From", "Rcpt", "Helo", "Hostname"].reduce(function (o, header) {
-                            var value = $("#scan-opt-" + header.toLowerCase()).val();
-                            if (value !== "") o[header] = value;
-                            return o;
-                        }, {});
-                        if ($("#scan-opt-pass-all").prop("checked")) headers.Pass = "all";
-                        scanText(data, headers);
-                    } else if (source === "compute-fuzzy") {
-                        getFuzzyHashes(data);
-                    } else {
-                        if (source === "fuzzy") {
-                            headers = {
-                                flag: $("#fuzzyFlagText").val(),
-                                weight: $("#fuzzyWeightText").val()
-                            };
-                        }
-                        uploadText(data, source, headers);
-                    }
+        $("[data-upload]").on("click", function () {
+            var source = $(this).data("upload");
+            var data = $("#scanMsgSource").val();
+            var headers = {};
+            if ($.trim(data).length > 0) {
+                if (source === "scan") {
+                    headers = ["IP", "User", "From", "Rcpt", "Helo", "Hostname"].reduce(function (o, header) {
+                        var value = $("#scan-opt-" + header.toLowerCase()).val();
+                        if (value !== "") o[header] = value;
+                        return o;
+                    }, {});
+                    if ($("#scan-opt-pass-all").prop("checked")) headers.Pass = "all";
+                    scanText(data, headers);
+                } else if (source === "compute-fuzzy") {
+                    getFuzzyHashes(data);
                 } else {
-                    rspamd.alertMessage("alert-error", "Message source field cannot be blank");
+                    if (source === "fuzzy") {
+                        headers = {
+                            flag: $("#fuzzyFlagText").val(),
+                            weight: $("#fuzzyWeightText").val()
+                        };
+                    }
+                    uploadText(data, source, headers);
                 }
-                return false;
-            });
-        })();
+            } else {
+                rspamd.alertMessage("alert-error", "Message source field cannot be blank");
+            }
+            return false;
+        });
 
         return ui;
     });