From f8a0a1d4ecf604743ba236bc8fe9cffc9a0b007d Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Sat, 22 Feb 2025 18:25:56 +0200 Subject: [PATCH 1/4] Tighten xo rules Signed-off-by: XhmikosR --- package.json | 27 +-- scripts/js/charts.js | 104 ++++++----- scripts/js/footer.js | 145 +++++++-------- scripts/js/gravity.js | 20 +- scripts/js/groups-clients.js | 114 ++++++------ scripts/js/groups-common.js | 43 ++--- scripts/js/groups-domains.js | 159 ++++++++-------- scripts/js/groups-lists.js | 185 ++++++++++--------- scripts/js/groups.js | 77 ++++---- scripts/js/index.js | 286 +++++++++++++++-------------- scripts/js/interfaces.js | 20 +- scripts/js/ip-address-sorting.js | 25 +-- scripts/js/login.js | 30 +-- scripts/js/messages.js | 42 ++--- scripts/js/network.js | 60 +++--- scripts/js/queries.js | 170 ++++++++--------- scripts/js/search.js | 22 +-- scripts/js/settings-advanced.js | 45 +++-- scripts/js/settings-api.js | 106 +++++------ scripts/js/settings-dhcp.js | 42 ++--- scripts/js/settings-dns-records.js | 58 +++--- scripts/js/settings-dns.js | 30 +-- scripts/js/settings-privacy.js | 6 +- scripts/js/settings-system.js | 103 ++++++----- scripts/js/settings-teleporter.js | 22 +-- scripts/js/settings.js | 46 ++--- scripts/js/taillog.js | 22 +-- scripts/js/utils.js | 273 +++++++++++++-------------- 28 files changed, 1152 insertions(+), 1130 deletions(-) diff --git a/package.json b/package.json index 9ef16675..be7f153a 100644 --- a/package.json +++ b/package.json @@ -107,37 +107,16 @@ ], "no-alert": "off", "no-console": "error", - "no-else-return": "off", - "no-negated-condition": "off", - "no-var": "off", - "object-shorthand": "off", - "one-var": "off", - "prefer-arrow-callback": "off", + "prefer-arrow-callback": "error", "spaced-comment": "off", - "unicorn/explicit-length-check": [ - "error", - { - "non-zero": "greater-than" - } - ], - "unicorn/filename-case": "off", "unicorn/no-anonymous-default-export": "off", - "unicorn/no-array-for-each": "off", - "unicorn/no-for-loop": "off", "unicorn/no-document-cookie": "off", - "unicorn/numeric-separators-style": "off", - "unicorn/prefer-includes": "off", + "unicorn/no-negated-condition": "off", "unicorn/prefer-module": "off", - "unicorn/prefer-node-append": "off", - "unicorn/prefer-number-properties": "off", "unicorn/prefer-query-selector": "off", "unicorn/prefer-string-slice": "off", "unicorn/prevent-abbreviations": "off", - "unicorn/prefer-logical-operator-over-ternary": "off", - "unicorn/switch-case-braces": "off", - "unicorn/no-negated-condition": "off", - "logical-assignment-operators": "off", - "prefer-object-has-own": "off" + "unicorn/switch-case-braces": "off" } } } diff --git a/scripts/js/charts.js b/scripts/js/charts.js index bbbbe9df..b1e61671 100644 --- a/scripts/js/charts.js +++ b/scripts/js/charts.js @@ -8,7 +8,7 @@ /* global upstreams:false */ // eslint-disable-next-line no-unused-vars -var THEME_COLORS = [ +const THEME_COLORS = [ "#f56954", "#3c8dbc", "#00a65a", @@ -57,7 +57,7 @@ const htmlLegendPlugin = { ul.firstChild.remove(); } - items.forEach(item => { + for (const item of items) { const li = document.createElement("li"); li.style.alignItems = "center"; li.style.cursor = "pointer"; @@ -114,14 +114,14 @@ const htmlLegendPlugin = { li.append(boxSpan, textLink); ul.append(li); - }); + } }, }; // eslint-disable-next-line no-unused-vars -var customTooltips = function (context) { - var tooltip = context.tooltip; - var tooltipEl = document.getElementById(this.chart.canvas.id + "-customTooltip"); +const customTooltips = function (context) { + const tooltip = context.tooltip; + let tooltipEl = document.getElementById(this.chart.canvas.id + "-customTooltip"); if (!tooltipEl) { // Create Tooltip Element once per chart tooltipEl = document.createElement("div"); @@ -130,7 +130,7 @@ var customTooltips = function (context) { tooltipEl.innerHTML = "
"; // avoid browser's font-zoom since we know that 's // font-size was set to 14px by bootstrap's css - var fontZoom = parseFloat($("body").css("font-size")) / 14; + const fontZoom = Number.parseFloat($("body").css("font-size")) / 14; // set styles and font tooltipEl.style.padding = tooltip.options.padding + "px " + tooltip.options.padding + "px"; tooltipEl.style.borderRadius = tooltip.options.cornerRadius + "px"; @@ -155,56 +155,60 @@ var customTooltips = function (context) { // Set Text if (tooltip.body) { - var titleLines = tooltip.title || []; - var bodyLines = tooltip.body.map(function (bodyItem) { + const titleLines = tooltip.title || []; + const bodyLines = tooltip.body.map(bodyItem => { return bodyItem.lines; }); - var innerHtml = ""; + let innerHtml = ""; - titleLines.forEach(function (title) { + for (const title of titleLines) { innerHtml += "" + title + ""; - }); - innerHtml += ""; - var printed = 0; + } - var devicePixel = (1 / window.devicePixelRatio).toFixed(1); - bodyLines.forEach(function (body, i) { - var labelColors = tooltip.labelColors[i]; - var style = "background-color: " + labelColors.backgroundColor; + innerHtml += ""; + let printed = 0; + + const devicePixel = (1 / window.devicePixelRatio).toFixed(1); + for (const [i, body] of bodyLines.entries()) { + const labelColors = tooltip.labelColors[i]; + let style = "background-color: " + labelColors.backgroundColor; style += "; outline: 1px solid " + labelColors.backgroundColor; style += "; border: " + devicePixel + "px solid #fff"; - var span = ""; + const span = ""; - var num = body[0].split(": "); + const num = body[0].split(": "); // do not display entries with value of 0 (in bar chart), // but pass through entries with "0.0% (in pie charts) if (num[1] !== "0") { innerHtml += "" + span + body + ""; printed++; } - }); + } + if (printed < 1) { innerHtml += "No activity recorded"; } innerHtml += ""; - var tableRoot = tooltipEl.querySelector("table"); + const tableRoot = tooltipEl.querySelector("table"); tableRoot.innerHTML = innerHtml; } - var canvasPos = this.chart.canvas.getBoundingClientRect(); - var boxPos = tooltipEl.ancestor.getBoundingClientRect(); - var offsetX = canvasPos.left - boxPos.left; - var offsetY = canvasPos.top - boxPos.top; - var tooltipWidth = tooltipEl.offsetWidth; - var tooltipHeight = tooltipEl.offsetHeight; - var caretX = tooltip.caretX; - var caretY = tooltip.caretY; - var caretPadding = tooltip.options.caretPadding; - var tooltipX, tooltipY, arrowX; - var arrowMinIndent = 2 * tooltip.options.cornerRadius; - var arrowSize = 5; + const canvasPos = this.chart.canvas.getBoundingClientRect(); + const boxPos = tooltipEl.ancestor.getBoundingClientRect(); + const offsetX = canvasPos.left - boxPos.left; + const offsetY = canvasPos.top - boxPos.top; + const tooltipWidth = tooltipEl.offsetWidth; + const tooltipHeight = tooltipEl.offsetHeight; + const caretX = tooltip.caretX; + const caretY = tooltip.caretY; + const caretPadding = tooltip.options.caretPadding; + let tooltipX; + let tooltipY; + let arrowX; + const arrowMinIndent = 2 * tooltip.options.cornerRadius; + const arrowSize = 5; // Compute X position if ($(document).width() > 2 * tooltip.width || tooltip.xAlign !== "center") { @@ -295,7 +299,7 @@ var customTooltips = function (context) { } else { // Calculate percentage X value depending on the tooltip's // width to avoid hanging arrow out on tooltip width changes - var arrowXpercent = ((100 / tooltipWidth) * arrowX).toFixed(1); + const arrowXpercent = ((100 / tooltipWidth) * arrowX).toFixed(1); tooltipEl.querySelector(".arrow").style.left = arrowXpercent + "%"; } @@ -304,12 +308,12 @@ var customTooltips = function (context) { // eslint-disable-next-line no-unused-vars function doughnutTooltip(tooltipLabel) { - var percentageTotalShown = tooltipLabel.chart._metasets[0].total.toFixed(1); + let percentageTotalShown = tooltipLabel.chart._metasets[0].total.toFixed(1); // tooltipLabel.chart._metasets[0].total returns the total percentage of the shown slices // to compensate rounding errors we round to one decimal - var label = " " + tooltipLabel.label; - var itemPercentage; + const label = " " + tooltipLabel.label; + let itemPercentage; // if we only show < 1% percent of all, show each item with two decimals if (percentageTotalShown < 1) { @@ -326,19 +330,19 @@ function doughnutTooltip(tooltipLabel) { if (percentageTotalShown > 99.9) { // All items shown return label + ": " + itemPercentage + "%"; - } else { - // set percentageTotalShown again without rounding to account - // for cases where the total shown percentage would be <0.1% of all - percentageTotalShown = tooltipLabel.chart._metasets[0].total; - return ( - label + - ":
• " + - itemPercentage + - "% of all data
• " + - ((tooltipLabel.parsed * 100) / percentageTotalShown).toFixed(1) + - "% of shown items" - ); } + + // set percentageTotalShown again without rounding to account + // for cases where the total shown percentage would be <0.1% of all + percentageTotalShown = tooltipLabel.chart._metasets[0].total; + return ( + label + + ":
• " + + itemPercentage + + "% of all data
• " + + ((tooltipLabel.parsed * 100) / percentageTotalShown).toFixed(1) + + "% of shown items" + ); } // chartjs plugin used by the custom doughnut legend diff --git a/scripts/js/footer.js b/scripts/js/footer.js index c3d68184..eefec54c 100644 --- a/scripts/js/footer.js +++ b/scripts/js/footer.js @@ -7,30 +7,30 @@ /* global utils:false, moment:false */ -var _isLoginPage = false; +const _isLoginPage = false; const REFRESH_INTERVAL = { logs: 500, // 0.5 sec (logs page) summary: 1000, // 1 sec (dashboard) query_log: 2000, // 2 sec (Query Log) - blocking: 10000, // 10 sec (all pages, sidebar) - metrics: 10000, // 10 sec (settings page) - system: 20000, // 20 sec (all pages, sidebar) - query_types: 60000, // 1 min (dashboard) - upstreams: 60000, // 1 min (dashboard) - top_lists: 60000, // 1 min (dashboard) - messages: 60000, // 1 min (all pages) - version: 120000, // 2 min (all pages, footer) - ftl: 120000, // 2 min (all pages, sidebar) - hosts: 120000, // 2 min (settings page) - history: 600000, // 10 min (dashboard) - clients: 600000, // 10 min (dashboard) + blocking: 10_000, // 10 sec (all pages, sidebar) + metrics: 10_000, // 10 sec (settings page) + system: 20_000, // 20 sec (all pages, sidebar) + query_types: 60_000, // 1 min (dashboard) + upstreams: 60_000, // 1 min (dashboard) + top_lists: 60_000, // 1 min (dashboard) + messages: 60_000, // 1 min (all pages) + version: 120_000, // 2 min (all pages, footer) + ftl: 120_000, // 2 min (all pages, sidebar) + hosts: 120_000, // 2 min (settings page) + history: 600_000, // 10 min (dashboard) + clients: 600_000, // 10 min (dashboard) }; function secondsTimeSpanToHMS(s) { - var h = Math.floor(s / 3600); //Get whole hours + const h = Math.floor(s / 3600); //Get whole hours s -= h * 3600; - var m = Math.floor(s / 60); //Get remaining minutes + const m = Math.floor(s / 60); //Get remaining minutes s -= m * 60; return h + ":" + (m < 10 ? "0" + m : m) + ":" + (s < 10 ? "0" + s : s); //zero padding on minutes and seconds } @@ -41,8 +41,8 @@ function piholeChanged(blocking, timer = null) { const dis = $("#pihole-disable"); const enaT = $("#enableTimer"); - if (timer !== null && parseFloat(timer) > 0) { - enaT.html(Date.now() + parseFloat(timer) * 1000); + if (timer !== null && Number.parseFloat(timer) > 0) { + enaT.html(Date.now() + Number.parseFloat(timer) * 1000); setTimeout(countDown, 100); } @@ -83,10 +83,10 @@ function piholeChanged(blocking, timer = null) { } function countDown() { - var ena = $("#enableLabel"); - var enaT = $("#enableTimer"); - var target = new Date(parseInt(enaT.text(), 10)); - var seconds = Math.round((target.getTime() - Date.now()) / 1000); + const ena = $("#enableLabel"); + const enaT = $("#enableTimer"); + const target = new Date(Number.parseInt(enaT.text(), 10)); + const seconds = Math.round((target.getTime() - Date.now()) / 1000); //Stop and remove timer when user enabled early if ($("#pihole-enable").is(":hidden")) { @@ -117,11 +117,11 @@ function checkBlocking() { url: document.body.dataset.apiurl + "/dns/blocking", method: "GET", }) - .done(function (data) { + .done(data => { piholeChanged(data.blocking, data.timer); utils.setTimer(checkBlocking, REFRESH_INTERVAL.blocking); }) - .fail(function (data) { + .fail(data => { apiFailure(data); utils.setTimer(checkBlocking, 3 * REFRESH_INTERVAL.blocking); }); @@ -150,16 +150,16 @@ function piholeChange(action, duration) { contentType: "application/json; charset=utf-8", data: JSON.stringify({ blocking: action === "enable", - timer: parseInt(duration, 10) > 0 ? parseInt(duration, 10) : null, + timer: Number.parseInt(duration, 10) > 0 ? Number.parseInt(duration, 10) : null, }), }) - .done(function (data) { + .done(data => { if (data.blocking === action + "d") { btnStatus.html(""); piholeChanged(data.blocking, data.timer); } }) - .fail(function (data) { + .fail(data => { apiFailure(data); }); } @@ -171,7 +171,7 @@ function testCookies() { // set and read cookie document.cookie = "cookietest=1"; - var ret = document.cookie.indexOf("cookietest=") !== -1; + const ret = document.cookie.includes("cookietest="); // delete cookie document.cookie = "cookietest=1; expires=Thu, 01-Jan-1970 00:00:01 GMT"; @@ -182,7 +182,7 @@ function testCookies() { function applyCheckboxRadioStyle() { // Get all radio/checkboxes for theming, with the exception of the two radio buttons on the custom disable timer, // as well as every element with an id that starts with "status_" - var sel = $("input[type='radio'],input[type='checkbox']") + const sel = $("input[type='radio'],input[type='checkbox']") .not("#selSec") .not("#selMin") .not("#expert-settings") @@ -192,7 +192,8 @@ function applyCheckboxRadioStyle() { sel.parent().addClass("icheck-primary"); } -var systemTimer, versionTimer; +let systemTimer; +let versionTimer; function updateInfo() { updateSystemInfo(); updateVersionInfo(); @@ -201,7 +202,7 @@ function updateInfo() { } function updateQueryFrequency(intl, frequency) { - let freq = parseFloat(frequency) * 60; + let freq = Number.parseFloat(frequency) * 60; let unit = "q/min"; let title = "Queries per minute"; if (freq > 100) { @@ -231,15 +232,15 @@ function updateQueryFrequency(intl, frequency) { .attr("title", title); } -var ftlinfoTimer = null; +let ftlinfoTimer = null; function updateFtlInfo() { $.ajax({ url: document.body.dataset.apiurl + "/info/ftl", }) - .done(function (data) { - var ftl = data.ftl; - var database = ftl.database; - var intl = new Intl.NumberFormat(); + .done(data => { + const ftl = data.ftl; + const database = ftl.database; + const intl = new Intl.NumberFormat(); $("#num_groups").text(intl.format(database.groups)); $("#num_clients").text(intl.format(database.clients)); $("#num_lists").text(intl.format(database.lists)); @@ -268,7 +269,7 @@ function updateFtlInfo() { $("#sysinfo-cpu-ftl").text("(" + ftl["%cpu"].toFixed(1) + "% used by FTL)"); $("#sysinfo-ram-ftl").text("(" + ftl["%mem"].toFixed(1) + "% used by FTL)"); $("#sysinfo-pid-ftl").text(ftl.pid); - var startdate = moment() + const startdate = moment() .subtract(ftl.uptime, "milliseconds") .format("dddd, MMMM Do YYYY, HH:mm:ss"); $("#sysinfo-uptime-ftl").text(startdate); @@ -284,7 +285,7 @@ function updateFtlInfo() { clearTimeout(ftlinfoTimer); ftlinfoTimer = utils.setTimer(updateFtlInfo, REFRESH_INTERVAL.ftl); }) - .fail(function (data) { + .fail(data => { apiFailure(data); }); } @@ -293,10 +294,10 @@ function updateSystemInfo() { $.ajax({ url: document.body.dataset.apiurl + "/info/system", }) - .done(function (data) { - var system = data.system; - var percentRAM = system.memory.ram["%used"]; - var percentSwap = system.memory.swap["%used"]; + .done(data => { + const system = data.system; + const percentRAM = system.memory.ram["%used"]; + const percentSwap = system.memory.swap["%used"]; let totalRAM = system.memory.ram.total / 1024; let totalRAMUnit = "MB"; if (totalRAM > 1024) { @@ -311,11 +312,11 @@ function updateSystemInfo() { totalSwapUnit = "GB"; } - var swap = + const swap = system.memory.swap.total > 0 ? ((1e2 * system.memory.swap.used) / system.memory.swap.total).toFixed(1) + " %" : "N/A"; - var color; + let color; color = percentRAM > 75 ? "text-red" : "text-green-light"; $("#memory").html( ' { apiFailure(data); }); } @@ -410,8 +411,8 @@ function apiFailure(data) { // Credits: https://www.geeksforgeeks.org/compare-two-version-numbers/ function versionCompare(v1, v2) { // vnum stores each numeric part of version - var vnum1 = 0, - vnum2 = 0; + let vnum1 = 0; + let vnum2 = 0; // Remove possible leading "v" in v1 and v2 if (v1[0] === "v") { @@ -423,7 +424,7 @@ function versionCompare(v1, v2) { } // loop until both string are processed - for (var i = 0, j = 0; i < v1.length || j < v2.length; ) { + for (let i = 0, j = 0; i < v1.length || j < v2.length; ) { // storing numeric part of version 1 in vnum1 while (i < v1.length && v1[i] !== ".") { vnum1 = vnum1 * 10 + (v1[i] - "0"); @@ -452,14 +453,14 @@ function versionCompare(v1, v2) { function updateVersionInfo() { $.ajax({ url: document.body.dataset.apiurl + "/info/version", - }).done(function (data) { - var version = data.version; - var updateAvailable = false; - var dockerUpdate = false; - var isDocker = false; + }).done(data => { + const version = data.version; + let updateAvailable = false; + let dockerUpdate = false; + let isDocker = false; $("#versions").empty(); - var versions = [ + const versions = [ { name: "Docker Tag", local: version.docker.local, @@ -502,11 +503,11 @@ function updateVersionInfo() { isDocker = true; } - versions.forEach(function (v) { + for (const v of versions) { if (v.local !== null) { // reset update status for each component - var updateComponentAvailable = false; - var localVersion = v.local; + let updateComponentAvailable = false; + let localVersion = v.local; if (v.branch !== null && v.hash !== null) { if (v.branch === "master") { localVersion = v.local.split("-")[0]; @@ -569,7 +570,7 @@ function updateVersionInfo() { $("#versions").append("
  • " + v.name + " " + localVersion + "
  • "); } } - }); + } if (dockerUpdate) $("#update-hint").html( @@ -585,11 +586,11 @@ function updateVersionInfo() { }); } -$(function () { +$(() => { if (!_isLoginPage) updateInfo(); - var enaT = $("#enableTimer"); - var target = new Date(parseInt(enaT.html(), 10)); - var seconds = Math.round((target.getTime() - Date.now()) / 1000); + const enaT = $("#enableTimer"); + const target = new Date(Number.parseInt(enaT.html(), 10)); + const seconds = Math.round((target.getTime() - Date.now()) / 1000); if (seconds > 0) { setTimeout(countDown, 100); } @@ -610,30 +611,30 @@ $(function () { }); // Handle Enable/Disable -$("#pihole-enable").on("click", function (e) { +$("#pihole-enable").on("click", e => { e.preventDefault(); localStorage.removeItem("countDownTarget"); piholeChange("enable", ""); }); -$("#pihole-disable-indefinitely").on("click", function (e) { +$("#pihole-disable-indefinitely").on("click", e => { e.preventDefault(); piholeChange("disable", "0"); }); -$("#pihole-disable-10s").on("click", function (e) { +$("#pihole-disable-10s").on("click", e => { e.preventDefault(); piholeChange("disable", "10"); }); -$("#pihole-disable-30s").on("click", function (e) { +$("#pihole-disable-30s").on("click", e => { e.preventDefault(); piholeChange("disable", "30"); }); -$("#pihole-disable-5m").on("click", function (e) { +$("#pihole-disable-5m").on("click", e => { e.preventDefault(); piholeChange("disable", "300"); }); -$("#pihole-disable-custom").on("click", function (e) { +$("#pihole-disable-custom").on("click", e => { e.preventDefault(); - var custVal = $("#customTimeout").val(); + let custVal = $("#customTimeout").val(); custVal = $("#btnMins").hasClass("active") ? custVal * 60 : custVal; piholeChange("disable", custVal); }); @@ -707,8 +708,8 @@ function addAdvancedInfo() { const isTLS = location.protocol === "https:"; const clientIP = advancedInfoSource.data("client-ip"); const XForwardedFor = globalThis.atob(advancedInfoSource.data("xff") ?? ""); - const starttime = parseFloat(advancedInfoSource.data("starttime")); - const endtime = parseFloat(advancedInfoSource.data("endtime")); + const starttime = Number.parseFloat(advancedInfoSource.data("starttime")); + const endtime = Number.parseFloat(advancedInfoSource.data("endtime")); const totaltime = 1e3 * (endtime - starttime); // Show advanced info @@ -741,7 +742,7 @@ function addAdvancedInfo() { advancedInfoTarget.show(); } -$(function () { +$(() => { initSettingsLevel(); addAdvancedInfo(); }); diff --git a/scripts/js/gravity.js b/scripts/js/gravity.js index aca729a8..d1c5d3e5 100644 --- a/scripts/js/gravity.js +++ b/scripts/js/gravity.js @@ -6,9 +6,9 @@ * Please see LICENSE file for your rights under this license. */ function eventsource() { - var alInfo = $("#alInfo"); - var alSuccess = $("#alSuccess"); - var ta = $("#output"); + const alInfo = $("#alInfo"); + const alSuccess = $("#alSuccess"); + const ta = $("#output"); ta.html(""); ta.show(); @@ -37,10 +37,10 @@ function eventsource() { // Enqueue the next data chunk into our target stream controller.enqueue(value); - var string = new TextDecoder().decode(value); + const string = new TextDecoder().decode(value); parseLines(ta, string); - if (string.indexOf("Done.") !== -1) { + if (string.includes("Done.")) { alSuccess.show(); } @@ -53,13 +53,13 @@ function eventsource() { .catch(error => console.error(error)); // eslint-disable-line no-console } -$("#gravityBtn").on("click", function () { +$("#gravityBtn").on("click", () => { $("#gravityBtn").prop("disabled", true); eventsource(); }); // Handle hiding of alerts -$(function () { +$(() => { $("[data-hide]").on("click", function () { $(this) .closest("." + $(this).attr("data-hide")) @@ -68,8 +68,8 @@ $(function () { // Do we want to start updating immediately? // gravity?go - var searchString = globalThis.location.search.substring(1); - if (searchString.indexOf("go") !== -1) { + const searchString = globalThis.location.search.substring(1); + if (searchString.includes("go")) { $("#gravityBtn").prop("disabled", true); eventsource(); } @@ -80,7 +80,7 @@ function parseLines(ta, str) { // We want to split the text before an "OVER" escape sequence to allow overwriting previous line when needed // Splitting the text on "\r" - var lines = str.split(/(?=\r)/g); + const lines = str.split(/(?=\r)/g); for (let i = 0; i < lines.length; i++) { if (lines[i][0] === "\r") { diff --git a/scripts/js/groups-clients.js b/scripts/js/groups-clients.js index b09b9406..0ba8241b 100644 --- a/scripts/js/groups-clients.js +++ b/scripts/js/groups-clients.js @@ -8,15 +8,15 @@ /* global utils:false, groups:false, apiFailure:false, updateFtlInfo:false, getGroups:false, processGroupResult:false, delGroupItems:false */ /* exported initTable */ -var table; +let table; function reloadClientSuggestions() { $.ajax({ url: document.body.dataset.apiurl + "/clients/_suggestions", type: "GET", dataType: "json", - success: function (data) { - var sel = $("#select"); + success(data) { + const sel = $("#select"); sel.empty(); // In order for the placeholder value to appear, we have to have a blank @@ -27,11 +27,11 @@ function reloadClientSuggestions() { sel.append($("