Browse Source

[Minor] JS: Add space before parentheses

of anonymous functions
tags/1.7.8
Alexander Moisseev 5 years ago
parent
commit
61308eaca2

+ 6
- 6
interface/js/app/config.js View File

@@ -23,7 +23,7 @@
*/

define(["jquery"],
function($) {
function ($) {
var interface = {};

function save_map_success(rspamd) {
@@ -51,7 +51,7 @@ define(["jquery"],
error: function (data) {
save_map_error(rspamd, "local", null, null, data.statusText);
},
success: function() { save_map_success(rspamd); },
success: function () { save_map_success(rspamd); },
});
}

@@ -222,10 +222,10 @@ define(["jquery"],
}
}

$("#saveActionsBtn").on("click", function() {
$("#saveActionsBtn").on("click", function () {
saveActions(rspamd.queryLocal);
});
$("#saveActionsClusterBtn").on("click", function() {
$("#saveActionsClusterBtn").on("click", function () {
saveActions(rspamd.queryNeighbours);
});
},
@@ -233,11 +233,11 @@ define(["jquery"],
}

// @upload edited actions
interface.setup = function(rspamd) {
interface.setup = function (rspamd) {
// Modal form for maps
$(document).on("click", "[data-toggle=\"modal\"]", function () {
var item = $(this).data("item");
getMapById(rspamd, item).done(function() {
getMapById(rspamd, item).done(function () {
$("#modalTitle").html(item.uri);
$("#" + item.map).first().show();
$("#modalDialog .progress").hide();

+ 4
- 4
interface/js/app/graph.js View File

@@ -24,7 +24,7 @@
*/

define(["jquery", "d3evolution", "footable"],
function($, D3Evolution, unused) {
function ($, D3Evolution, unused) {
var rrd_pie_config = {
header: {},
size: {
@@ -95,7 +95,7 @@ define(["jquery", "d3evolution", "footable"],
interpolate: getSelector("selInterpolate"),
convert: getSelector("selConvert"),
}));
$("#selYScale").change(function() {
$("#selYScale").change(function () {
graph.yScale(this.value);
});
$("#selConvert").change(function () {
@@ -169,7 +169,7 @@ define(["jquery", "d3evolution", "footable"],
var interface = {};
var prevUnit = "msg/s";

interface.draw = function(rspamd, graphs, neighbours, checked_server, type) {
interface.draw = function (rspamd, graphs, neighbours, checked_server, type) {

function updateWidgets(data) {
// Autoranging
@@ -278,7 +278,7 @@ define(["jquery", "d3evolution", "footable"],
});
};

interface.setup = function() {
interface.setup = function () {
// Handling mouse events on overlapping elements
$("#rrd-pie").mouseover(function () {
$("#rrd-pie").css("z-index", "200");

+ 22
- 22
interface/js/app/history.js View File

@@ -23,7 +23,7 @@
*/

define(["jquery", "footable", "humanize"],
function($, _, Humanize) {
function ($, _, Humanize) {
var interface = {};
var ft = {};
var htmlEscapes = {
@@ -39,8 +39,8 @@ define(["jquery", "footable", "humanize"],
var htmlEscaper = /[&<>"'/`=]/g;
var symbolDescriptions = {};

EscapeHTML = function(string) {
return ("" + string).replace(htmlEscaper, function(match) {
EscapeHTML = function (string) {
return ("" + string).replace(htmlEscaper, function (match) {
return htmlEscapes[match];
});
};
@@ -62,7 +62,7 @@ define(["jquery", "footable", "humanize"],
escape_HTML_array(item[prop]);
break;
case "symbols":
Object.keys(item.symbols).map(function(key) {
Object.keys(item.symbols).map(function (key) {
var sym = item.symbols[key];
if (!sym.name) {
sym.name = key;
@@ -154,7 +154,7 @@ define(["jquery", "footable", "humanize"],
}

preprocess_item(item);
Object.keys(item.symbols).map(function(key) {
Object.keys(item.symbols).map(function (key) {
var sym = item.symbols[key];

if (sym.description) {
@@ -172,11 +172,11 @@ define(["jquery", "footable", "humanize"],
item.symbols[key].str = str;
});
item.symbols = Object.keys(item.symbols)
.map(function(key) {
.map(function (key) {
return item.symbols[key];
})
.sort(compare)
.map(function(e) { return e.str; })
.map(function (e) { return e.str; })
.join("<br>\n");
item.time = {
"value": unix_time_format(item.unix_time),
@@ -310,7 +310,7 @@ define(["jquery", "footable", "humanize"],
"font-size": "11px",
"maxWidth": 110
},
"sortValue": function(val) { return Number(val.options.sortValue); }
"sortValue": function (val) { return Number(val.options.sortValue); }
}, {
"name": "symbols",
"title": "Symbols",
@@ -337,7 +337,7 @@ define(["jquery", "footable", "humanize"],
"font-size": "11px",
"maxWidth": 72
},
"sortValue": function(val) { return Number(val.options.sortValue); }
"sortValue": function (val) { return Number(val.options.sortValue); }
}, {
"sorted": true,
"direction": "DESC",
@@ -346,7 +346,7 @@ define(["jquery", "footable", "humanize"],
"style": {
"font-size": "11px"
},
"sortValue": function(val) { return Number(val.options.sortValue); }
"sortValue": function (val) { return Number(val.options.sortValue); }
}, {
"name": "user",
"title": "Authenticated user",
@@ -397,7 +397,7 @@ define(["jquery", "footable", "humanize"],
"font-size": "11px",
"maxWidth": 110
},
"sortValue": function(val) { return Number(val.options.sortValue); }
"sortValue": function (val) { return Number(val.options.sortValue); }
}, {
"name": "symbols",
"title": "Symbols",
@@ -425,7 +425,7 @@ define(["jquery", "footable", "humanize"],
"font-size": "11px",
"maxWidth": 80
},
"sortValue": function(val) { return Number(val.options.sortValue); }
"sortValue": function (val) { return Number(val.options.sortValue); }
}, {
"sorted": true,
"direction": "DESC",
@@ -434,7 +434,7 @@ define(["jquery", "footable", "humanize"],
"style": {
"font-size": "11px"
},
"sortValue": function(val) { return Number(val.options.sortValue); }
"sortValue": function (val) { return Number(val.options.sortValue); }
}, {
"name": "user",
"title": "Authenticated user",
@@ -485,14 +485,14 @@ define(["jquery", "footable", "humanize"],

interface.getHistory = function (rspamd, tables, neighbours, checked_server) {
FooTable.actionFilter = FooTable.Filtering.extend({
construct : function(instance) {
construct : function (instance) {
this._super(instance);
this.actions = ["reject", "add header", "greylist",
"no action", "soft reject", "rewrite subject"];
this.def = "Any action";
this.$action = null;
},
$create : function() {
$create : function () {
this._super();
var self = this, $form_grp = $("<div/>", {
"class" : "form-group"
@@ -510,11 +510,11 @@ define(["jquery", "footable", "humanize"],
text : self.def
})).appendTo($form_grp);

$.each(self.actions, function(i, action) {
$.each(self.actions, function (i, action) {
self.$action.append($("<option/>").text(action));
});
},
_onStatusDropdownChanged : function(e) {
_onStatusDropdownChanged : function (e) {
var self = e.data.self, selected = $(this).val();
if (selected !== self.def) {
if (selected === "reject") {
@@ -527,7 +527,7 @@ define(["jquery", "footable", "humanize"],
}
self.filter();
},
draw : function() {
draw : function () {
this._super();
var action = this.find("action");
if (action instanceof FooTable.Filter) {
@@ -542,7 +542,7 @@ define(["jquery", "footable", "humanize"],
}
});

var drawTooltips = function() {
var drawTooltips = function () {
// Update symbol description tooltips
$.each(symbolDescriptions, function (key, description) {
$("abbr[data-sym-key=" + key + "]").tooltip({
@@ -663,7 +663,7 @@ define(["jquery", "footable", "humanize"],
e.preventDefault();
interface.getHistory(rspamd, tables, neighbours, checked_server);
});
$("#selSymOrder").unbind().change(function() {
$("#selSymOrder").unbind().change(function () {
interface.getHistory(rspamd, tables, neighbours, checked_server);
});

@@ -742,7 +742,7 @@ define(["jquery", "footable", "humanize"],
});
}

interface.getErrors = function(rspamd, tables, neighbours, checked_server) {
interface.getErrors = function (rspamd, tables, neighbours, checked_server) {
if (rspamd.read_only) return;

if (checked_server !== "All SERVERS") {
@@ -779,7 +779,7 @@ define(["jquery", "footable", "humanize"],
});
};

interface.setup = function(rspamd, tables) {
interface.setup = function (rspamd, tables) {
};
return interface;
});

+ 11
- 11
interface/js/app/rspamd.js View File

@@ -179,7 +179,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,

// Public functions
interface.alertMessage = alertMessage;
interface.setup = function() {
interface.setup = function () {
$("#selData").change(function () {
selData = this.value;
tabClick("#throughput_nav");
@@ -236,7 +236,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
selData = tab_graph.setup();
};

interface.connect = function() {
interface.connect = function () {
if (isLogged()) {
var data = JSON.parse(sessionStorage.getItem("Credentials"));

@@ -314,7 +314,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
});
};

interface.queryLocal = function(req_url, on_success, on_error, method, headers, params) {
interface.queryLocal = function (req_url, on_success, on_error, method, headers, params) {
var req_params = {
type: method,
jsonp: false,
@@ -322,7 +322,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
xhr.setRequestHeader("Password", getPassword());

if (headers) {
$.each(headers, function(hname, hvalue) {
$.each(headers, function (hname, hvalue) {
xhr.setRequestHeader(hname, hvalue);
});
}
@@ -336,7 +336,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
alertMessage("alert-success", "Data saved");
}
},
error: function(jqXHR, textStatus, errorThrown) {
error: function (jqXHR, textStatus, errorThrown) {
if (on_error) {
on_error("local", jqXHR, textStatus, errorThrown);
}
@@ -346,14 +346,14 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
}
};
if (params) {
$.each(params, function(k, v) {
$.each(params, function (k, v) {
req_params[k] = v;
});
}
$.ajax(req_params);
};

interface.queryNeighbours = function(req_url, on_success, on_error, method, headers, params, req_data) {
interface.queryNeighbours = function (req_url, on_success, on_error, method, headers, params, req_data) {
$.ajax({
dataType: "json",
type: "GET",
@@ -395,7 +395,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
xhr.setRequestHeader("Password", getPassword());

if (headers) {
$.each(headers, function(hname, hvalue) {
$.each(headers, function (hname, hvalue) {
xhr.setRequestHeader(hname, hvalue);
});
}
@@ -419,7 +419,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
}
}
},
error: function(jqXHR, textStatus, errorThrown) {
error: function (jqXHR, textStatus, errorThrown) {
neighbours_status[ind].status = false;
neighbours_status[ind].checked = true;
if (on_error) {
@@ -443,7 +443,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
// error display
};
if (params) {
$.each(params, function(k, v) {
$.each(params, function (k, v) {
req_params[k] = v;
});
}
@@ -456,7 +456,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config,
});
};

interface.drawPie = function(obj, id, data, conf) {
interface.drawPie = function (obj, id, data, conf) {
if (obj) {
obj.updateProp("data.content",
data.filter(function (elt) {

+ 3
- 3
interface/js/app/stats.js View File

@@ -23,7 +23,7 @@
*/

define(["jquery", "d3pie", "humanize"],
function($, d3pie, Humanize) {
function ($, d3pie, Humanize) {
// @ ms to date
function msToTime(seconds) {
/* eslint-disable no-bitwise */
@@ -174,8 +174,8 @@ define(["jquery", "d3pie", "humanize"],
}
// Public API
var interface = {
statWidgets: function(rspamd, graphs, checked_server) {
rspamd.queryNeighbours("/auth", function(neighbours_status) {
statWidgets: function (rspamd, graphs, checked_server) {
rspamd.queryNeighbours("/auth", function (neighbours_status) {
var neighbours_sum = {
version: neighbours_status[0].data.version,
auth: "ok",

+ 12
- 12
interface/js/app/symbols.js View File

@@ -23,7 +23,7 @@
*/

define(["jquery", "footable"],
function($) {
function ($) {
var interface = {};
var ft = {};

@@ -126,9 +126,9 @@ define(["jquery", "footable"],
});

// For better mean calculations
var avg_freq = freqs.sort(function(a, b) {
var avg_freq = freqs.sort(function (a, b) {
return Number(a) < Number(b);
}).reduce(function(f1, acc) {
}).reduce(function (f1, acc) {
return f1 + acc;
}) / (freqs.length != 0 ? freqs.length : 1.0);
var mult = 1.0;
@@ -153,7 +153,7 @@ define(["jquery", "footable"],
return [items, distinct_groups];
}
// @get symbols into modal form
interface.getSymbols = function(rspamd, tables, checked_server) {
interface.getSymbols = function (rspamd, tables, checked_server) {

$.ajax({
dataType: "json",
@@ -166,13 +166,13 @@ define(["jquery", "footable"],
success: function (data) {
var items = process_symbols_data(data);
FooTable.groupFilter = FooTable.Filtering.extend({
construct : function(instance) {
construct : function (instance) {
this._super(instance);
this.groups = items[1];
this.def = "Any group";
this.$group = null;
},
$create : function() {
$create : function () {
this._super();
var self = this, $form_grp = $("<div/>", {
"class" : "form-group"
@@ -190,11 +190,11 @@ define(["jquery", "footable"],
text : self.def
})).appendTo($form_grp);

$.each(self.groups, function(i, group) {
$.each(self.groups, function (i, group) {
self.$group.append($("<option/>").text(group));
});
},
_onStatusDropdownChanged : function(e) {
_onStatusDropdownChanged : function (e) {
var self = e.data.self, selected = $(this).val();
if (selected !== self.def) {
self.addFilter("group", selected, ["group"]);
@@ -203,7 +203,7 @@ define(["jquery", "footable"],
}
self.filter();
},
draw : function() {
draw : function () {
this._super();
var group = this.find("group");
if (group instanceof FooTable.Filter) {
@@ -219,7 +219,7 @@ define(["jquery", "footable"],
{"name":"symbol", "title":"Symbol", "style":{"font-size":"11px"}},
{"name":"description", "title":"Description", "breakpoints":"xs sm", "style":{"font-size":"11px"}},
{"name":"weight", "title":"Score", "style":{"font-size":"11px"}},
{"name":"frequency", "title":"Frequency", "breakpoints":"xs sm", "style":{"font-size":"11px"}, "sortValue": function(value) { return Number(value).toFixed(2); }},
{"name":"frequency", "title":"Frequency", "breakpoints":"xs sm", "style":{"font-size":"11px"}, "sortValue": function (value) { return Number(value).toFixed(2); }},
{"name":"time", "title":"Avg. time", "breakpoints":"xs sm", "style":{"font-size":"11px"}},
{"name":"save", "title":"Save", "style":{"font-size":"11px"}},
],
@@ -253,14 +253,14 @@ define(["jquery", "footable"],
rspamd.alertMessage("alert-modal alert-error", data.statusText);
}
});
$(document).on("click", "#symbolsTable :button", function(event) {
$(document).on("click", "#symbolsTable :button", function (event) {
var value = $(this).data("save");
if (!value) return;
saveSymbols(rspamd, "./savesymbols", "symbolsTable", value == "cluster");
});
};

interface.setup = function(rspamd, tables) {
interface.setup = function (rspamd, tables) {
$("#updateSymbols").on("click", function (e) {
e.preventDefault();
$.ajax({

+ 2
- 2
interface/js/app/upload.js View File

@@ -23,7 +23,7 @@
*/

define(["jquery"],
function($) {
function ($) {
var interface = {};

function cleanTextUpload(source) {
@@ -169,7 +169,7 @@ define(["jquery"],
});
}

interface.setup = function(rspamd) {
interface.setup = function (rspamd) {
$("textarea").change(function () {
if ($(this).val().length !== "") {
$(this).closest("form").find("button").removeAttr("disabled").removeClass("disabled");

+ 2
- 2
interface/js/main.js View File

@@ -25,13 +25,13 @@ document.title = window.location.hostname +
(window.location.pathname !== "/" ? window.location.pathname : "") +
" - Rspamd Web Interface";

define("d3.global", ["d3"], function(_) {
define("d3.global", ["d3"], function (_) {
d3 = _;
});

// Load main UI
require(["domReady"],
function(domReady) {
function (domReady) {
domReady(function () {
require(["jquery", "d3", "app/rspamd"],
function ($, d3, rspamd) {

Loading…
Cancel
Save