commit 2bed972: [Minor] Get rid of 'var' declarations

moisseev moiseev at mezonplus.ru
Fri Nov 17 14:35:04 UTC 2023


Author: moisseev
Date: 2023-11-17 13:02:41 +0300
URL: https://github.com/rspamd/rspamd/commit/2bed972703dfe52206eb06e8583eb39b38596cc4

[Minor] Get rid of 'var' declarations

---
 .eslintrc.json                |   1 -
 interface/js/app/config.js    |  42 ++++++++--------
 interface/js/app/graph.js     |  38 +++++++--------
 interface/js/app/history.js   |  36 +++++++-------
 interface/js/app/rspamd.js    | 110 +++++++++++++++++++++---------------------
 interface/js/app/selectors.js |  20 ++++----
 interface/js/app/stats.js     |  66 ++++++++++++-------------
 interface/js/app/symbols.js   |  48 +++++++++---------
 interface/js/app/upload.js    |  24 ++++-----
 9 files changed, 192 insertions(+), 193 deletions(-)

diff --git a/.eslintrc.json b/.eslintrc.json
index c224b5d00..322185acc 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -41,7 +41,6 @@
         "no-negated-condition": "off",
         "no-plusplus": "off",
         "no-ternary": "off",
-        "no-var": "off",
         "object-curly-newline": ["error", { "consistent": true }],
         "object-property-newline": ["error", { "allowAllPropertiesOnSameLine": true }],
         "object-shorthand": "off",
diff --git a/interface/js/app/config.js b/interface/js/app/config.js
index dd47578ae..d62298693 100644
--- a/interface/js/app/config.js
+++ b/interface/js/app/config.js
@@ -27,16 +27,16 @@
 define(["jquery", "app/rspamd"],
     function ($, rspamd) {
         "use strict";
-        var ui = {};
+        const ui = {};
 
         ui.getActions = function getActions(checked_server) {
             rspamd.query("actions", {
                 success: function (data) {
                     $("#actionsFormField").empty();
-                    var items = [];
+                    const items = [];
                     $.each(data[0].data, function (i, item) {
-                        var actionsOrder = ["greylist", "add header", "rewrite subject", "reject"];
-                        var idx = actionsOrder.indexOf(item.action);
+                        const actionsOrder = ["greylist", "add header", "rewrite subject", "reject"];
+                        const idx = actionsOrder.indexOf(item.action);
                         if (idx >= 0) {
                             items.push({
                                 idx: idx,
@@ -67,11 +67,11 @@ define(["jquery", "app/rspamd"],
 
         ui.saveActions = function (server) {
             function descending(arr) {
-                var desc = true;
-                var filtered = arr.filter(function (el) {
+                let desc = true;
+                const filtered = arr.filter(function (el) {
                     return el !== null;
                 });
-                for (var i = 0; i < filtered.length - 1; i++) {
+                for (let i = 0; i < filtered.length - 1; i++) {
                     if (filtered[i + 1] >= filtered[i]) {
                         desc = false;
                         break;
@@ -80,9 +80,9 @@ define(["jquery", "app/rspamd"],
                 return desc;
             }
 
-            var elts = (function () {
-                var values = [];
-                var inputs = $("#actionsForm :input[data-id=\"action\"]");
+            const elts = (function () {
+                const values = [];
+                const inputs = $("#actionsForm :input[data-id=\"action\"]");
                 // Rspamd order: [spam, rewrite_subject, probable_spam, greylist]
                 values[0] = parseFloat(inputs[3].value);
                 values[1] = parseFloat(inputs[2].value);
@@ -92,7 +92,7 @@ define(["jquery", "app/rspamd"],
                 return JSON.stringify(values);
             }());
             // String to array for comparison
-            var eltsArray = JSON.parse(elts);
+            const eltsArray = JSON.parse(elts);
             if (eltsArray[0] < 0) {
                 rspamd.alertMessage("alert-modal alert-error", "Spam can not be negative");
             } else if (eltsArray[1] < 0) {
@@ -116,23 +116,23 @@ define(["jquery", "app/rspamd"],
         };
 
         ui.getMaps = function (checked_server) {
-            var $listmaps = $("#listMaps");
+            const $listmaps = $("#listMaps");
             $listmaps.closest(".card").hide();
             rspamd.query("maps", {
                 success: function (json) {
-                    var data = json[0].data;
+                    const data = json[0].data;
                     $listmaps.empty();
                     $("#modalBody").empty();
-                    var $tbody = $("<tbody>");
+                    const $tbody = $("<tbody>");
 
                     $.each(data, function (i, item) {
-                        var $td = '<td><span class="badge text-bg-secondary">Read</span></td>';
+                        let $td = '<td><span class="badge text-bg-secondary">Read</span></td>';
                         if (!(item.editable === false || rspamd.read_only)) {
                             $td = $($td).append(' <span class="badge text-bg-success">Write</span>');
                         }
-                        var $tr = $("<tr>").append($td);
+                        const $tr = $("<tr>").append($td);
 
-                        var $span = $('<span class="map-link" data-bs-toggle="modal" data-bs-target="#modalDialog">' + item.uri + "</span>").data("item", item);
+                        const $span = $('<span class="map-link" data-bs-toggle="modal" data-bs-target="#modalDialog">' + item.uri + "</span>").data("item", item);
                         $span.wrap("<td>").parent().appendTo($tr);
                         $("<td>" + item.description + "</td>").appendTo($tr);
                         $tr.appendTo($tbody);
@@ -145,7 +145,7 @@ define(["jquery", "app/rspamd"],
         };
 
 
-        var jar = {};
+        let jar = {};
         const editor = {
             advanced: {
                 codejar: true,
@@ -163,8 +163,8 @@ define(["jquery", "app/rspamd"],
 
         // Modal form for maps
         $(document).on("click", "[data-bs-toggle=\"modal\"]", function () {
-            var checked_server = rspamd.getSelector("selSrv");
-            var item = $(this).data("item");
+            const checked_server = rspamd.getSelector("selSrv");
+            const item = $(this).data("item");
             rspamd.query("getmap", {
                 headers: {
                     Map: item.map
@@ -188,7 +188,7 @@ define(["jquery", "app/rspamd"],
                         document.querySelector("#editor").innerHTML = rspamd.escapeHTML(data[0].data);
                     }
 
-                    var icon = "fa-edit";
+                    let icon = "fa-edit";
                     if (item.editable === false || rspamd.read_only) {
                         $("#editor").attr(editor[mode].readonly_attr);
                         icon = "fa-eye";
diff --git a/interface/js/app/graph.js b/interface/js/app/graph.js
index 3dca7da9c..b7276f1c1 100644
--- a/interface/js/app/graph.js
+++ b/interface/js/app/graph.js
@@ -29,7 +29,7 @@ define(["jquery", "app/rspamd", "d3evolution", "d3pie", "d3", "footable"],
     function ($, rspamd, D3Evolution, D3Pie, d3) {
         "use strict";
 
-        var rrd_pie_config = {
+        const rrd_pie_config = {
             cornerRadius: 2,
             size: {
                 canvasWidth: 400,
@@ -56,11 +56,11 @@ define(["jquery", "app/rspamd", "d3evolution", "d3pie", "d3", "footable"],
             },
         };
 
-        var ui = {};
-        var prevUnit = "msg/s";
+        const ui = {};
+        let prevUnit = "msg/s";
 
         ui.draw = function (graphs, neighbours, checked_server, type) {
-            var graph_options = {
+            const graph_options = {
                 title: "Rspamd throughput",
                 width: 1060,
                 height: 370,
@@ -73,7 +73,7 @@ define(["jquery", "app/rspamd", "d3evolution", "d3pie", "d3", "footable"],
             };
 
             function initGraph() {
-                var graph = new D3Evolution("graph", $.extend({}, graph_options, {
+                const graph = new D3Evolution("graph", $.extend({}, graph_options, {
                     yScale: rspamd.getSelector("selYScale"),
                     type: rspamd.getSelector("selType"),
                     interpolate: rspamd.getSelector("selInterpolate"),
@@ -96,16 +96,16 @@ define(["jquery", "app/rspamd", "d3evolution", "d3pie", "d3", "footable"],
             }
 
             function getRrdSummary(json, scaleFactor) {
-                var xExtents = d3.extent(d3.merge(json), function (d) { return d.x; });
-                var timeInterval = xExtents[1] - xExtents[0];
+                const xExtents = d3.extent(d3.merge(json), function (d) { return d.x; });
+                const timeInterval = xExtents[1] - xExtents[0];
 
-                var total = 0;
-                var rows = json.map(function (curr, i) {
+                let total = 0;
+                const rows = json.map(function (curr, i) {
                     // Time intervals that don't have data are excluded from average calculation as d3.mean()ignores nulls
-                    var avg = d3.mean(curr, function (d) { return d.y; });
+                    const avg = d3.mean(curr, function (d) { return d.y; });
                     // To find an integral on the whole time interval we need to convert nulls to zeroes
-                    var value = d3.mean(curr, function (d) { return Number(d.y); }) * timeInterval / scaleFactor ^ 0; // eslint-disable-line no-bitwise
-                    var yExtents = d3.extent(curr, function (d) { return d.y; });
+                    const value = d3.mean(curr, function (d) { return Number(d.y); }) * timeInterval / scaleFactor ^ 0; // eslint-disable-line no-bitwise
+                    const yExtents = d3.extent(curr, function (d) { return d.y; });
 
                     total += value;
                     return {
@@ -162,13 +162,13 @@ define(["jquery", "app/rspamd", "d3evolution", "d3pie", "d3", "footable"],
             }
 
             function updateWidgets(data) {
-                var rrd_summary = {rows:[]};
-                var unit = "msg/s";
+                let rrd_summary = {rows:[]};
+                let unit = "msg/s";
 
                 if (data) {
                     // Autoranging
-                    var scaleFactor = 1;
-                    var yMax = d3.max(d3.merge(data), function (d) { return d.y; });
+                    let scaleFactor = 1;
+                    const yMax = d3.max(d3.merge(data), function (d) { return d.y; });
                     if (yMax < 1) {
                         scaleFactor = 60;
                         unit = "msg/min";
@@ -202,15 +202,15 @@ define(["jquery", "app/rspamd", "d3evolution", "d3pie", "d3", "footable"],
 
             rspamd.query("graph", {
                 success: function (req_data) {
-                    var data = null;
-                    var neighbours_data = req_data
+                    let data = null;
+                    const neighbours_data = req_data
                         .filter(function (d) { return d.status; }) // filter out unavailable neighbours
                         .map(function (d) { return d.data; });
 
                     if (neighbours_data.length === 1) {
                         data = neighbours_data[0];
                     } else {
-                        var time_match = true;
+                        let time_match = true;
                         neighbours_data.reduce(function (res, curr, _, arr) {
                             if ((curr[0][0].x !== res[0][0].x) ||
                             (curr[0][curr[0].length - 1].x !== res[0][res[0].length - 1].x)) {
diff --git a/interface/js/app/history.js b/interface/js/app/history.js
index 4118bc61d..30fa06700 100644
--- a/interface/js/app/history.js
+++ b/interface/js/app/history.js
@@ -27,13 +27,13 @@
 define(["jquery", "app/rspamd", "d3", "footable"],
     function ($, rspamd, d3) {
         "use strict";
-        var ui = {};
-        var prevVersion = null;
+        const ui = {};
+        let prevVersion = null;
 
         function process_history_legacy(data) {
-            var items = [];
+            const items = [];
 
-            var compare = function (e1, e2) {
+            const compare = function (e1, e2) {
                 return e1.name.localeCompare(e2.name);
             };
 
@@ -287,20 +287,20 @@ define(["jquery", "app/rspamd", "d3", "footable"],
             }];
         }
 
-        var columns = {
+        const columns = {
             2: columns_v2,
             legacy: columns_legacy
         };
 
         function process_history_data(data) {
-            var process_functions = {
+            const process_functions = {
                 2: rspamd.process_history_v2,
                 legacy: process_history_legacy
             };
-            var pf = process_functions.legacy;
+            let pf = process_functions.legacy;
 
             if (data.version) {
-                var strkey = data.version.toString();
+                const strkey = data.version.toString();
                 if (process_functions[strkey]) {
                     pf = process_functions[strkey];
                 }
@@ -310,10 +310,10 @@ define(["jquery", "app/rspamd", "d3", "footable"],
         }
 
         function get_history_columns(data) {
-            var func = columns.legacy;
+            let func = columns.legacy;
 
             if (data.version) {
-                var strkey = data.version.toString();
+                const strkey = data.version.toString();
                 if (columns[strkey]) {
                     func = columns[strkey];
                 }
@@ -326,7 +326,7 @@ define(["jquery", "app/rspamd", "d3", "footable"],
             rspamd.query("history", {
                 success: function (req_data) {
                     function differentVersions(neighbours_data) {
-                        var dv = neighbours_data.some(function (e) {
+                        const dv = neighbours_data.some(function (e) {
                             return e.version !== neighbours_data[0].version;
                         });
                         if (dv) {
@@ -337,12 +337,12 @@ define(["jquery", "app/rspamd", "d3", "footable"],
                         return false;
                     }
 
-                    var neighbours_data = req_data
+                    const neighbours_data = req_data
                         .filter(function (d) { return d.status; }) // filter out unavailable neighbours
                         .map(function (d) { return d.data; });
                     if (neighbours_data.length && !differentVersions(neighbours_data)) {
-                        var data = {};
-                        var version = neighbours_data[0].version;
+                        let data = {};
+                        const version = neighbours_data[0].version;
                         if (version) {
                             data.rows = [].concat.apply([], neighbours_data
                                 .map(function (e) {
@@ -355,8 +355,8 @@ define(["jquery", "app/rspamd", "d3", "footable"],
                             data = [].concat.apply([], neighbours_data);
                             $("#legacy-history-badge").show();
                         }
-                        var o = process_history_data(data);
-                        var items = o.items;
+                        const o = process_history_data(data);
+                        const items = o.items;
                         rspamd.symbols.history = o.symbols;
 
                         if (Object.prototype.hasOwnProperty.call(rspamd.tables, "history") &&
@@ -418,14 +418,14 @@ define(["jquery", "app/rspamd", "d3", "footable"],
 
             rspamd.query("errors", {
                 success: function (data) {
-                    var neighbours_data = data
+                    const neighbours_data = data
                         .filter(function (d) {
                             return d.status;
                         }) // filter out unavailable neighbours
                         .map(function (d) {
                             return d.data;
                         });
-                    var rows = [].concat.apply([], neighbours_data);
+                    const rows = [].concat.apply([], neighbours_data);
                     $.each(rows, function (i, item) {
                         item.ts = {
                             value: rspamd.unix_time_format(item.ts),
diff --git a/interface/js/app/rspamd.js b/interface/js/app/rspamd.js
index faec47f7f..4ad806d76 100644
--- a/interface/js/app/rspamd.js
+++ b/interface/js/app/rspamd.js
@@ -29,7 +29,7 @@ define(["jquery", "nprogress", "stickytabs", "visibility",
     "bootstrap", "fontawesome"],
 function ($, NProgress) {
     "use strict";
-    var ui = {
+    const ui = {
         chartLegend: [
             {label: "reject", color: "#FF0000"},
             {label: "soft reject", color: "#BF8040"},
@@ -52,14 +52,14 @@ function ($, NProgress) {
     const defaultAjaxTimeout = 20000;
 
     const ajaxTimeoutBox = ".popover #settings-popover #ajax-timeout";
-    var graphs = {};
-    var tables = {};
-    var neighbours = []; // list of clusters
-    var checked_server = "All SERVERS";
-    var timer_id = [];
+    const graphs = {};
+    const tables = {};
+    let neighbours = []; // list of clusters
+    let checked_server = "All SERVERS";
+    const timer_id = [];
     let pageSizeTimerId = null;
     let pageSizeInvocationCounter = 0;
-    var locale = (localStorage.getItem("selected_locale") === "custom") ? localStorage.getItem("custom_locale") : null;
+    let locale = (localStorage.getItem("selected_locale") === "custom") ? localStorage.getItem("custom_locale") : null;
 
     NProgress.configure({
         minimum: 0.01,
@@ -85,7 +85,7 @@ function ($, NProgress) {
     }
 
     function stopTimers() {
-        for (var key in timer_id) {
+        for (const key in timer_id) {
             if (!{}.hasOwnProperty.call(timer_id, key)) continue;
             Visibility.stop(timer_id[key]);
         }
@@ -110,14 +110,14 @@ function ($, NProgress) {
 
     // Get selectors' current state
     function getSelector(id) {
-        var e = document.getElementById(id);
+        const e = document.getElementById(id);
         return e.options[e.selectedIndex].value;
     }
 
     function tabClick(id) {
-        var tab_id = id;
+        let tab_id = id;
         if ($(id).attr("disabled")) return;
-        var navBarControls = $("#selSrv, #navBar li, #navBar a, #navBar button");
+        let navBarControls = $("#selSrv, #navBar li, #navBar a, #navBar button");
         if (id !== "#autoRefresh") navBarControls.attr("disabled", true).addClass("disabled", true);
 
         stopTimers();
@@ -137,7 +137,7 @@ function ($, NProgress) {
                     return;
                 }
 
-                var timeLeft = interval;
+                let timeLeft = interval;
                 $("#countdown").text("00:00");
                 timer_id.countdown = Visibility.every(1000, 1000, function () {
                     timeLeft -= 1000;
@@ -168,7 +168,7 @@ function ($, NProgress) {
         switch (tab_id) {
             case "#status_nav":
                 require(["app/stats"], (module) => {
-                    var refreshInterval = $(".dropdown-menu a.active.preset").data("value");
+                    const refreshInterval = $(".dropdown-menu a.active.preset").data("value");
                     setAutoRefresh(refreshInterval, "status",
                         function () { return module.statWidgets(graphs, checked_server); });
                     if (id !== "#autoRefresh") module.statWidgets(graphs, checked_server);
@@ -181,11 +181,11 @@ function ($, NProgress) {
             case "#throughput_nav":
                 require(["app/graph"], (module) => {
                     const selData = getSelector("selData"); // Graph's dataset selector state
-                    var step = {
+                    const step = {
                         day: 60000,
                         week: 300000
                     };
-                    var refreshInterval = step[selData] || 3600000;
+                    let refreshInterval = step[selData] || 3600000;
                     $("#dynamic-item").text((refreshInterval / 60000) + " min");
 
                     if (!$(".dropdown-menu a.active.dynamic").data("value")) {
@@ -221,7 +221,7 @@ function ($, NProgress) {
                         module.getHistory();
                         module.getErrors();
                     }
-                    var refreshInterval = $(".dropdown-menu a.active.history").data("value");
+                    const refreshInterval = $(".dropdown-menu a.active.history").data("value");
                     setAutoRefresh(refreshInterval, "history",
                         function () { return getHistoryAndErrors(); });
                     if (id !== "#autoRefresh") getHistoryAndErrors();
@@ -250,7 +250,7 @@ function ($, NProgress) {
     }
 
     function get_compare_function(table) {
-        var compare_functions = {
+        const compare_functions = {
             magnitude: function (e1, e2) {
                 return Math.abs(e2.score) - Math.abs(e1.score);
             },
@@ -270,7 +270,7 @@ function ($, NProgress) {
     }
 
     function set_page_size(table, page_size, changeTablePageSize) {
-        var n = parseInt(page_size, 10); // HTML Input elements return string representing a number
+        const n = parseInt(page_size, 10); // HTML Input elements return string representing a number
         if (n > 0) {
             ui.page_size[table] = n;
 
@@ -302,7 +302,7 @@ function ($, NProgress) {
     }
 
     function unix_time_format(tm) {
-        var date = new Date(tm ? tm * 1000 : 0);
+        const date = new Date(tm ? tm * 1000 : 0);
         return (locale)
             ? date.toLocaleString(locale)
             : date.toLocaleString();
@@ -347,7 +347,7 @@ function ($, NProgress) {
     }
 
     function alertMessage(alertClass, alertText) {
-        var a = $("<div class=\"alert " + alertClass + " alert-dismissible fade in show\">" +
+        const a = $("<div class=\"alert " + alertClass + " alert-dismissible fade in show\">" +
                 "<button type=\"button\" class=\"btn-close\" data-bs-dismiss=\"alert\" title=\"Dismiss\"></button>" +
                 "<strong>" + alertText + "</strong>");
         $(".notification-area").append(a);
@@ -363,19 +363,19 @@ function ($, NProgress) {
         neighbours_status[ind].checked = false;
         neighbours_status[ind].data = {};
         neighbours_status[ind].status = false;
-        var req_params = {
+        const req_params = {
             jsonp: false,
             data: o.data,
             headers: $.extend({Password:getPassword()}, o.headers),
             url: neighbours_status[ind].url + req_url,
             xhr: function () {
-                var xhr = $.ajaxSettings.xhr();
+                const xhr = $.ajaxSettings.xhr();
                 // Download progress
                 if (req_url !== "neighbours") {
                     xhr.addEventListener("progress", function (e) {
                         if (e.lengthComputable) {
                             neighbours_status[ind].percentComplete = e.loaded / e.total;
-                            var percentComplete = neighbours_status.reduce(function (prev, curr) {
+                            const percentComplete = neighbours_status.reduce(function (prev, curr) {
                                 return curr.percentComplete ? curr.percentComplete + prev : prev;
                             }, 0);
                             NProgress.set(percentComplete / neighbours_status.length);
@@ -400,7 +400,7 @@ function ($, NProgress) {
                     o.error(neighbours_status[ind],
                         jqXHR, textStatus, errorThrown);
                 } else if (o.errorOnceId) {
-                    var alert_status = o.errorOnceId + neighbours_status[ind].name;
+                    const alert_status = o.errorOnceId + neighbours_status[ind].name;
                     if (!(alert_status in sessionStorage)) {
                         sessionStorage.setItem(alert_status, true);
                         errorMessage();
@@ -473,7 +473,7 @@ function ($, NProgress) {
 
                 $("#connectForm").off("submit").on("submit", function (e) {
                     e.preventDefault();
-                    var password = $("#connectPassword").val();
+                    const password = $("#connectPassword").val();
 
                     function invalidFeedback(tooltip) {
                         $("#connectPassword")
@@ -493,7 +493,7 @@ function ($, NProgress) {
                             Password: password
                         },
                         success: function (json) {
-                            var data = json[0].data;
+                            const data = json[0].data;
                             $("#connectPassword").val("");
                             if (data.auth === "ok") {
                                 sessionStorage.setItem("read_only", data.read_only);
@@ -546,7 +546,7 @@ function ($, NProgress) {
      */
     ui.query = function (url, options) {
         // Force options to be an object
-        var o = options || {};
+        const o = options || {};
         Object.keys(o).forEach(function (option) {
             if (["complete", "data", "error", "errorMessage", "errorOnceId", "headers", "method", "params", "server", "statusCode",
                 "success"]
@@ -555,7 +555,7 @@ function ($, NProgress) {
             }
         });
 
-        var neighbours_status = [{
+        let neighbours_status = [{
             name: "local",
             host: "local",
             url: "",
@@ -564,7 +564,7 @@ function ($, NProgress) {
         if (o.server === "All SERVERS") {
             queryServer(neighbours_status, 0, "neighbours", {
                 success: function (json) {
-                    var data = json[0].data;
+                    const data = json[0].data;
                     if (jQuery.isEmptyObject(data)) {
                         neighbours = {
                             local: {
@@ -610,20 +610,20 @@ function ($, NProgress) {
     ui.bindHistoryTableEventHandlers = function (table, symbolsCol) {
         function change_symbols_order(order) {
             $(".btn-sym-" + table + "-" + order).addClass("active").siblings().removeClass("active");
-            var compare_function = get_compare_function(table);
+            const compare_function = get_compare_function(table);
             $.each(tables[table].rows.all, function (i, row) {
-                var cell_val = sort_symbols(ui.symbols[table][i], compare_function);
+                const cell_val = sort_symbols(ui.symbols[table][i], compare_function);
                 row.cells[symbolsCol].val(cell_val, false, true);
             });
         }
 
         $("#selSymOrder_" + table).unbind().change(function () {
-            var order = this.value;
+            const order = this.value;
             change_symbols_order(order);
         });
         $("#" + table + "_page_size").change((e) => set_page_size(table, e.target.value, true));
         $(document).on("click", ".btn-sym-order-" + table + " input", function () {
-            var order = this.value;
+            const order = this.value;
             $("#selSymOrder_" + table).val(order);
             change_symbols_order(order);
         });
@@ -739,8 +739,8 @@ function ($, NProgress) {
             on: {
                 "expand.ft.row": function (e, ft, row) {
                     setTimeout(function () {
-                        var detail_row = row.$el.next();
-                        var order = getSelector("selSymOrder_" + table);
+                        const detail_row = row.$el.next();
+                        const order = getSelector("selSymOrder_" + table);
                         detail_row.find(".btn-sym-" + table + "-" + order)
                             .addClass("active").siblings().removeClass("active");
                     }, 5);
@@ -750,8 +750,8 @@ function ($, NProgress) {
     };
 
     ui.escapeHTML = function (string) {
-        var htmlEscaper = /[&<>"'/`=]/g;
-        var htmlEscapes = {
+        const htmlEscaper = /[&<>"'/`=]/g;
+        const htmlEscapes = {
             "&": "&",
             "<": "<",
             ">": ">",
@@ -771,7 +771,7 @@ function ($, NProgress) {
             arr.forEach(function (d, i) { arr[i] = ui.escapeHTML(d); });
         }
 
-        for (var prop in item) {
+        for (const prop in item) {
             if (!{}.hasOwnProperty.call(item, prop)) continue;
             switch (prop) {
                 case "rcpt_mime":
@@ -780,7 +780,7 @@ function ($, NProgress) {
                     break;
                 case "symbols":
                     Object.keys(item.symbols).forEach(function (key) {
-                        var sym = item.symbols[key];
+                        const sym = item.symbols[key];
                         if (!sym.name) {
                             sym.name = key;
                         }
@@ -811,7 +811,7 @@ function ($, NProgress) {
             item.action = "<div style='font-size:11px' class='badge text-bg-info'>" + item.action + "</div>";
         }
 
-        var score_content = (item.score < item.required_score)
+        const score_content = (item.score < item.required_score)
             ? "<span class='text-success'>" + item.score.toFixed(2) + " / " + item.required_score + "</span>"
             : "<span class='text-danger'>" + item.score.toFixed(2) + " / " + item.required_score + "</span>";
 
@@ -825,22 +825,22 @@ function ($, NProgress) {
 
     ui.process_history_v2 = function (data, table) {
         // Display no more than rcpt_lim recipients
-        var rcpt_lim = 3;
-        var items = [];
-        var unsorted_symbols = [];
-        var compare_function = get_compare_function(table);
+        const rcpt_lim = 3;
+        const items = [];
+        const unsorted_symbols = [];
+        const compare_function = get_compare_function(table);
 
         $("#selSymOrder_" + table + ", label[for='selSymOrder_" + table + "']").show();
 
         $.each(data.rows,
             function (i, item) {
                 function more(p) {
-                    var l = item[p].length;
+                    const l = item[p].length;
                     return (l > rcpt_lim) ? " … (" + l + ")" : "";
                 }
                 function format_rcpt(smtp, mime) {
-                    var full = "";
-                    var shrt = "";
+                    let full = "";
+                    let shrt = "";
                     if (smtp) {
                         full = "[" + item.rcpt_smtp.join(", ") + "] ";
                         shrt = "[" + item.rcpt_smtp.slice(0, rcpt_lim).join(",​") + more("rcpt_smtp") + "]";
@@ -899,7 +899,7 @@ function ($, NProgress) {
                 item.id = item["message-id"];
 
                 if (table === "history") {
-                    var rcpt = {};
+                    let rcpt = {};
                     if (!item.rcpt_mime.length) {
                         rcpt = format_rcpt(true, false);
                     } else if ($(item.rcpt_mime).not(item.rcpt_smtp).length !== 0 || $(item.rcpt_smtp).not(item.rcpt_mime).length !== 0) {
@@ -921,8 +921,8 @@ function ($, NProgress) {
     };
 
     ui.waitForRowsDisplayed = function (table, rows_total, callback, iteration) {
-        var i = (typeof iteration === "undefined") ? 10 : iteration;
-        var num_rows = $("#historyTable_" + table + " > tbody > tr:not(.footable-detail-row)").length;
+        let i = (typeof iteration === "undefined") ? 10 : iteration;
+        const num_rows = $("#historyTable_" + table + " > tbody > tr:not(.footable-detail-row)").length;
         if (num_rows === ui.page_size[table] ||
             num_rows === rows_total) {
*** OUTPUT TRUNCATED, 488 LINES SKIPPED ***


More information about the Commits mailing list