ui.setup = function (rspamd) {
// Modal form for maps
$(document).on("click", "[data-toggle=\"modal\"]", function () {
- function getSelector(id) {
- var e = document.getElementById(id);
- return e.options[e.selectedIndex].value;
- }
- var checked_server = getSelector("selSrv");
+ var checked_server = rspamd.getSelector("selSrv");
var item = $(this).data("item");
rspamd.query("getmap", {
headers: {
}
};
- // Get selectors' current state
- function getSelector(id) {
- var e = document.getElementById(id);
- return e.options[e.selectedIndex].value;
- }
-
- function initGraph() {
+ function initGraph(rspamd) {
var graph = new D3Evolution("graph", $.extend({}, graph_options, {
- yScale: getSelector("selYScale"),
- type: getSelector("selType"),
- interpolate: getSelector("selInterpolate"),
- convert: getSelector("selConvert"),
+ yScale: rspamd.getSelector("selYScale"),
+ type: rspamd.getSelector("selType"),
+ interpolate: rspamd.getSelector("selInterpolate"),
+ convert: rspamd.getSelector("selConvert"),
}));
$("#selYScale").change(function () {
graph.yScale(this.value);
}
if (!graphs.graph) {
- graphs.graph = initGraph();
+ graphs.graph = initGraph(rspamd);
}
rspamd.query("graph", {
});
};
- ui.setup = function () {
+ ui.setup = function (rspamd) {
// Handling mouse events on overlapping elements
$("#rrd-pie").mouseover(function () {
$("#rrd-pie").css("z-index", "200");
$("#rrd-table_toggle").css("z-index", "0");
});
- return getSelector("selData");
+ return rspamd.getSelector("selData");
};
return ui;
return sessionStorage.getItem("Password");
}
+ // Get selectors' current state
function getSelector(id) {
var e = document.getElementById(id);
return e.options[e.selectedIndex].value;
tab_history.setup(ui, tables);
tab_symbols.setup(ui, tables);
tab_upload.setup(ui, tables);
- selData = tab_graph.setup();
+ selData = tab_graph.setup(ui);
};
ui.connect = function () {
"use strict";
var ui = {};
- function getSelector(id) {
- var e = document.getElementById(id);
- return e.options[e.selectedIndex].value;
- }
-
function saveSymbols(rspamd, action, id, server) {
var inputs = $("#" + id + " :input[data-role=\"numerictextbox\"]");
var url = action;
var digits = Number(number).toFixed(20).replace(/^-?\d*\.?|0+$/g, "").length;
return (digits === 0 || digits > 4) ? 0.1 : 1.0 / Math.pow(10, digits);
}
- function process_symbols_data(data) {
+ function process_symbols_data(rspamd, data) {
var items = [];
var lookup = {};
var freqs = [];
var distinct_groups = [];
- var selected_server = getSelector("selSrv");
+ var selected_server = rspamd.getSelector("selSrv");
data.forEach(function (group) {
group.rules.forEach(function (item) {
rspamd.query("symbols", {
success: function (json) {
var data = json[0].data;
- var items = process_symbols_data(data);
+ var items = process_symbols_data(rspamd, data);
/* eslint-disable consistent-this, no-underscore-dangle, one-var-declaration-per-line */
FooTable.groupFilter = FooTable.Filtering.extend({
ui.setup = function (rspamd, tables) {
$("#updateSymbols").on("click", function (e) {
e.preventDefault();
- var checked_server = getSelector("selSrv");
+ var checked_server = rspamd.getSelector("selSrv");
rspamd.query("symbols", {
success: function (data) {
- var items = process_symbols_data(data[0].data)[0];
+ var items = process_symbols_data(rspamd, data[0].data)[0];
tables.symbols.rows.load(items);
},
server: (checked_server === "All SERVERS") ? "local" : checked_server