aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-07-15 15:05:17 +0100
committerGitHub <noreply@github.com>2018-07-15 15:05:17 +0100
commit5771b12d4e02543a2b3e96e095dbcf20f10e7588 (patch)
tree226573dda9f1a810329f6dbcdcb0aeeb83bee90d
parenta9e3f168c149efbaadbe1f8a3113584235194ca3 (diff)
parent8b32cbde5fcffe085864de5dcd3daa35a9b01f7e (diff)
downloadrspamd-5771b12d4e02543a2b3e96e095dbcf20f10e7588.tar.gz
rspamd-5771b12d4e02543a2b3e96e095dbcf20f10e7588.zip
Merge pull request #2341 from moisseev/eslint
[Minor] Do not shadow `data` variable
-rw-r--r--.eslintrc.json7
-rw-r--r--interface/js/app/config.js4
-rw-r--r--interface/js/app/history.js5
-rw-r--r--interface/js/app/rspamd.js51
-rw-r--r--interface/js/app/stats.js5
-rw-r--r--interface/js/app/upload.js25
6 files changed, 43 insertions, 54 deletions
diff --git a/.eslintrc.json b/.eslintrc.json
index 9454f85d8..3e52ed7f8 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -49,7 +49,6 @@
// Temporarily disabled rules
"array-callback-return": "off",
"array-element-newline": "off",
- "block-scoped-var": "off",
"brace-style": "off",
"callback-return": "off",
"consistent-return": "off",
@@ -68,16 +67,10 @@
"max-statements-per-line": "off",
"new-cap": "off",
"no-else-return": "off",
- "no-empty": "off",
- "no-empty-function": "off",
"no-inline-comments": "off",
"no-invalid-this": "off",
- "no-loop-func": "off",
"no-negated-condition": "off",
- "no-param-reassign": "off",
- "no-shadow": "off",
"no-underscore-dangle": "off",
- "no-use-before-define": "off",
"one-var-declaration-per-line": "off",
"prefer-spread": "off",
"sort-keys": "off",
diff --git a/interface/js/app/config.js b/interface/js/app/config.js
index 293fd7842..b3f99b9c0 100644
--- a/interface/js/app/config.js
+++ b/interface/js/app/config.js
@@ -49,8 +49,8 @@ define(["jquery"],
xhr.setRequestHeader("Map", id);
xhr.setRequestHeader("Debug", true);
},
- error: function (data) {
- save_map_error(rspamd, "local", null, null, data.statusText);
+ error: function (jqXHR) {
+ save_map_error(rspamd, "local", null, null, jqXHR.statusText);
},
success: function () { save_map_success(rspamd); },
});
diff --git a/interface/js/app/history.js b/interface/js/app/history.js
index 8e34dff24..def170334 100644
--- a/interface/js/app/history.js
+++ b/interface/js/app/history.js
@@ -556,7 +556,7 @@ define(["jquery", "footable", "humanize"],
if (checked_server === "All SERVERS") {
rspamd.queryNeighbours("history", function (req_data) {
- function differentVersions() {
+ function differentVersions(neighbours_data) {
var dv = neighbours_data.some(function (e) {
return e.version !== neighbours_data[0].version;
});
@@ -570,7 +570,7 @@ define(["jquery", "footable", "humanize"],
var 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()) {
+ if (neighbours_data.length && !differentVersions(neighbours_data)) {
var data = {};
if (neighbours_data[0].version) {
data.rows = [].concat.apply([], neighbours_data
@@ -780,6 +780,5 @@ define(["jquery", "footable", "humanize"],
});
};
- ui.setup = function () {};
return ui;
});
diff --git a/interface/js/app/rspamd.js b/interface/js/app/rspamd.js
index a07d4ac03..97fd4ebb7 100644
--- a/interface/js/app/rspamd.js
+++ b/interface/js/app/rspamd.js
@@ -42,6 +42,16 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
var timer_id = [];
var selData; // Graph's dataset selector state
+ function cleanCredentials() {
+ sessionStorage.clear();
+ $("#statWidgets").empty();
+ $("#listMaps").empty();
+ $("#modalBody").empty();
+ $("#historyLog tbody").remove();
+ $("#errorsLog tbody").remove();
+ $("#symbolsTable tbody").remove();
+ }
+
function stopTimers() {
for (var key in timer_id) {
Visibility.stop(timer_id[key]);
@@ -79,7 +89,8 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
ui.connect();
}
- function tabClick(tab_id) {
+ function tabClick(id) {
+ var tab_id = id;
if ($(tab_id).attr("disabled")) return;
$(tab_id).attr("disabled", true);
@@ -139,17 +150,6 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
sessionStorage.setItem("Password", password);
}
- // @clean credentials
- function cleanCredentials() {
- sessionStorage.clear();
- $("#statWidgets").empty();
- $("#listMaps").empty();
- $("#modalBody").empty();
- $("#historyLog tbody").remove();
- $("#errorsLog tbody").remove();
- $("#symbolsTable tbody").remove();
- }
-
function isLogged() {
if (sessionStorage.getItem("Credentials") !== null) {
return true;
@@ -159,10 +159,10 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
function displayUI() {
// @toggle auth and main
- var disconnect = $("#navBar .pull-right");
+ var buttons = $("#navBar .pull-right");
$("#mainUI").show();
$("#progress").show();
- $(disconnect).show();
+ $(buttons).show();
tabClick("#refresh");
$("#progress").hide();
}
@@ -234,7 +234,6 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
});
tab_config.setup(ui);
tab_symbols.setup(ui, tables);
- tab_history.setup(ui, tables);
tab_upload.setup(ui);
selData = tab_graph.setup();
};
@@ -284,12 +283,12 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
beforeSend: function (xhr) {
xhr.setRequestHeader("Password", password);
},
- success: function (data) {
+ success: function (json) {
$("#connectPassword").val("");
- if (data.auth === "failed") {
+ if (json.auth === "failed") {
// Is actually never returned by Rspamd
} else {
- if (data.read_only) {
+ if (json.read_only) {
ui.read_only = true;
$("#learning_nav").hide();
$("#resetHistory").attr("disabled", true);
@@ -307,8 +306,8 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
displayUI();
}
},
- error: function (data) {
- ui.alertMessage("alert-modal alert-error", data.statusText);
+ error: function (jqXHR) {
+ ui.alertMessage("alert-modal alert-error", jqXHR.statusText);
$("#connectPassword").val("");
$("#connectPassword").focus();
}
@@ -387,9 +386,8 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
});
});
$.each(neighbours_status, function (ind) {
- method = typeof method !== "undefined" ? method : "GET";
var req_params = {
- type: method,
+ type: typeof method !== "undefined" ? method : "GET",
jsonp: false,
data: req_data,
beforeSend: function (xhr) {
@@ -402,14 +400,14 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
}
},
url: neighbours_status[ind].url + req_url,
- success: function (data) {
+ success: function (json) {
neighbours_status[ind].checked = true;
- if (jQuery.isEmptyObject(data)) {
+ if (jQuery.isEmptyObject(json)) {
neighbours_status[ind].status = false; // serv does not work
} else {
neighbours_status[ind].status = true; // serv does not work
- neighbours_status[ind].data = data;
+ neighbours_status[ind].data = json;
}
if (neighbours_status.every(function (elt) { return elt.checked; })) {
if (on_success) {
@@ -457,7 +455,8 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
});
};
- ui.drawPie = function (obj, id, data, conf) {
+ ui.drawPie = function (object, id, data, conf) {
+ var obj = object;
if (obj) {
obj.updateProp("data.content",
data.filter(function (elt) {
diff --git a/interface/js/app/stats.js b/interface/js/app/stats.js
index 56f3e7101..65e6f2772 100644
--- a/interface/js/app/stats.js
+++ b/interface/js/app/stats.js
@@ -67,9 +67,8 @@ define(["jquery", "d3pie", "humanize"],
$.each(data, function (i, item) {
var widget = "";
- if (i === "auth") {}
- else if (i === "error") {}
- else if (i === "version") {
+ if (i === "auth" || i === "error") { return true; } // Skip to the next iteration
+ if (i === "version") {
widget = "<div class=\"left\"><strong>" + item + "</strong>" +
i + "</div>";
$(widget).appendTo(widgets);
diff --git a/interface/js/app/upload.js b/interface/js/app/upload.js
index fad074668..3fcfc3aad 100644
--- a/interface/js/app/upload.js
+++ b/interface/js/app/upload.js
@@ -56,9 +56,9 @@ define(["jquery"],
xhr.setRequestHeader(name, value);
});
},
- success: function (data) {
+ success: function (json) {
cleanTextUpload(source);
- if (data.success) {
+ if (json.success) {
rspamd.alertMessage("alert-success", "Data successfully uploaded");
}
},
@@ -89,38 +89,37 @@ define(["jquery"],
beforeSend: function (xhr) {
xhr.setRequestHeader("Password", rspamd.getPassword());
},
- success: function (input) {
- var data = input;
- if (data.action) {
+ success: function (json) {
+ if (json.action) {
rspamd.alertMessage("alert-success", "Data successfully scanned");
var action = "";
- if (data.action === "clean" || "no action") {
+ if (json.action === "clean" || "no action") {
action = "label-success";
}
- else if (data.action === "rewrite subject" || "add header" || "probable spam") {
+ else if (json.action === "rewrite subject" || "add header" || "probable spam") {
action = "label-warning";
}
- else if (data.action === "spam") {
+ else if (json.action === "spam") {
action = "label-danger";
}
var score = "";
- if (data.score <= data.required_score) {
+ if (json.score <= json.required_score) {
score = "label-success";
}
- else if (data.score >= data.required_score) {
+ else if (json.score >= json.required_score) {
score = "label-danger";
}
$("<tbody id=\"tmpBody\"><tr>" +
- "<td><span class=\"label " + action + "\">" + data.action + "</span></td>" +
- "<td><span class=\"label " + score + "\">" + data.score.toFixed(2) + "/" + data.required_score.toFixed(2) + "</span></td>" +
+ "<td><span class=\"label " + action + "\">" + json.action + "</span></td>" +
+ "<td><span class=\"label " + score + "\">" + json.score.toFixed(2) + "/" + json.required_score.toFixed(2) + "</span></td>" +
"</tr></tbody>")
.insertAfter("#scanOutput thead");
var sym_desc = {};
var nsym = 0;
- $.each(data.symbols, function (i, item) {
+ $.each(json.symbols, function (i, item) {
if (typeof item === "object") {
var sym_id = "sym_" + nsym;
if (item.description) {