From 04f05e07c0c96322834ce2926b2fef06cd692d36 Mon Sep 17 00:00:00 2001 From: Alexander Moisseev Date: Wed, 11 Jul 2018 10:36:59 +0300 Subject: [PATCH] [WebUI] Use type-safe equality operators --- interface/js/app/graph.js | 2 +- interface/js/app/history.js | 2 +- interface/js/app/stats.js | 22 +++++++++++----------- interface/js/app/symbols.js | 4 ++-- interface/js/app/upload.js | 8 ++++---- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/interface/js/app/graph.js b/interface/js/app/graph.js index 6a63500fc..cce3c028c 100644 --- a/interface/js/app/graph.js +++ b/interface/js/app/graph.js @@ -189,7 +189,7 @@ define(["jquery", "d3evolution", "footable"], } graphs.graph.data(data); - if (unit != prevUnit) { + if (unit !== prevUnit) { graphs.graph.yAxisLabel("Message rate, " + unit); prevUnit = unit; } diff --git a/interface/js/app/history.js b/interface/js/app/history.js index 8147c39a1..6ee62c0ac 100644 --- a/interface/js/app/history.js +++ b/interface/js/app/history.js @@ -80,7 +80,7 @@ define(["jquery", "footable", "humanize"], }); break; default: - if (typeof (item[prop]) == "string") { + if (typeof (item[prop]) === "string") { item[prop] = EscapeHTML(item[prop]); } } diff --git a/interface/js/app/stats.js b/interface/js/app/stats.js index a074d47f8..25e061783 100644 --- a/interface/js/app/stats.js +++ b/interface/js/app/stats.js @@ -66,13 +66,13 @@ 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") {} + else if (i === "error") {} + else if (i === "version") { widget = "
" + item + "" + i + "
"; $(widget).appendTo(widgets); - } else if (i == "uptime") { + } else if (i === "uptime") { widget = "
" + msToTime(item) + "" + i + "
"; $(widget).appendTo(widgets); @@ -80,17 +80,17 @@ define(["jquery", "d3pie", "humanize"], var titleAtt = Humanize.intComma(item) + " " + i; widget = "
  • " + Humanize.compactInteger(item) + "" + i + "
  • "; - if (i == "scanned") { + if (i === "scanned") { stat_w[0] = widget; - } else if (i == "clean") { + } else if (i === "clean") { stat_w[1] = widget; - } else if (i == "greylist") { + } else if (i === "greylist") { stat_w[2] = widget; - } else if (i == "probable") { + } else if (i === "probable") { stat_w[3] = widget; - } else if (i == "reject") { + } else if (i === "reject") { stat_w[4] = widget; - } else if (i == "learned") { + } else if (i === "learned") { stat_w[5] = widget; } } @@ -127,7 +127,7 @@ define(["jquery", "d3pie", "humanize"], $("#selSrv").append($("")); - if (checked_server == key) { + if (checked_server === key) { $("#clusterTable tbody [value=\"" + key + "\"]").prop("checked", true); $("#selSrv [value=\"" + key + "\"]").prop("selected", true); } diff --git a/interface/js/app/symbols.js b/interface/js/app/symbols.js index a639127f4..039983534 100644 --- a/interface/js/app/symbols.js +++ b/interface/js/app/symbols.js @@ -132,7 +132,7 @@ define(["jquery", "footable"], return Number(a) < Number(b); }).reduce(function (f1, acc) { return f1 + acc; - }) / (freqs.length != 0 ? freqs.length : 1.0); + }) / (freqs.length !== 0 ? freqs.length : 1.0); var mult = 1.0; var exp = 0.0; @@ -258,7 +258,7 @@ define(["jquery", "footable"], $(document).on("click", "#symbolsTable :button", function () { var value = $(this).data("save"); if (!value) return; - saveSymbols(rspamd, "./savesymbols", "symbolsTable", value == "cluster"); + saveSymbols(rspamd, "./savesymbols", "symbolsTable", value === "cluster"); }); }; diff --git a/interface/js/app/upload.js b/interface/js/app/upload.js index 648ee3620..2926e62e2 100644 --- a/interface/js/app/upload.js +++ b/interface/js/app/upload.js @@ -37,7 +37,7 @@ define(["jquery"], url = "learnspam"; } else if (source === "ham") { url = "learnham"; - } else if (source == "fuzzy") { + } else if (source === "fuzzy") { url = "fuzzyadd"; } else if (source === "scan") { url = "scan"; @@ -120,7 +120,7 @@ define(["jquery"], var nsym = 0; $.each(data.symbols, function (i, item) { - if (typeof item == "object") { + if (typeof item === "object") { var sym_id = "sym_" + nsym; if (item.description) { sym_desc[sym_id] = item.description; @@ -191,7 +191,7 @@ define(["jquery"], var data; var headers = {}; data = $("#" + source + "TextSource").val(); - if (source == "fuzzy") { + if (source === "fuzzy") { // To access the proper headers.flag = $("#fuzzyFlagText").val(); headers.weight = $("#fuzzyWeightText").val(); @@ -199,7 +199,7 @@ define(["jquery"], data = $("#" + source + "TextSource").val(); } if (data.length > 0) { - if (source == "scan") { + if (source === "scan") { scanText(rspamd, data); } else { uploadText(rspamd, data, source, headers); -- 2.39.5