From 0fa7de82b08c36255f53ddf88d2bf819cbd4e11a Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Fri, 22 May 2020 10:47:50 +0300 Subject: [PATCH] JS: Enforce camelcase. It's a common convention to use camelcase for variable names. Signed-off-by: XhmikosR --- package.json | 7 +- scripts/pi-hole/js/db_graph.js | 24 +++---- scripts/pi-hole/js/footer.js | 12 ++-- scripts/pi-hole/js/gravity.js | 7 +- scripts/pi-hole/js/groups-adlists.js | 26 ++++---- scripts/pi-hole/js/groups-clients.js | 57 ++++++++-------- scripts/pi-hole/js/groups-common.js | 4 +- scripts/pi-hole/js/groups-domains.js | 98 ++++++++++++++-------------- scripts/pi-hole/js/groups.js | 14 ++-- scripts/pi-hole/js/messages.js | 8 +-- scripts/pi-hole/js/network.js | 16 ++--- scripts/pi-hole/js/queries.js | 34 +++++----- 12 files changed, 154 insertions(+), 153 deletions(-) diff --git a/package.json b/package.json index aa2d0c43..5456ca8f 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,12 @@ "**/vendor/**" ], "rules": { - "camelcase": "off", + "camelcase": [ + "error", + { + "properties": "never" + } + ], "capitalized-comments": "off", "new-cap": "off", "no-alert": "off", diff --git a/scripts/pi-hole/js/db_graph.js b/scripts/pi-hole/js/db_graph.js index ac80360f..c27e58c2 100644 --- a/scripts/pi-hole/js/db_graph.js +++ b/scripts/pi-hole/js/db_graph.js @@ -212,40 +212,40 @@ $(document).ready(function () { title: function (tooltipItem) { var label = tooltipItem[0].xLabel; var time = new Date(label); - var from_date = + var fromDate = time.getFullYear() + "-" + padNumber(time.getMonth() + 1) + "-" + padNumber(time.getDate()); - var from_time = + var fromTime = padNumber(time.getHours()) + ":" + padNumber(time.getMinutes()) + ":" + padNumber(time.getSeconds()); time = new Date(time.valueOf() + 1000 * interval); - var until_date = + var untilDate = time.getFullYear() + "-" + padNumber(time.getMonth() + 1) + "-" + padNumber(time.getDate()); - var until_time = + var untilTime = padNumber(time.getHours()) + ":" + padNumber(time.getMinutes()) + ":" + padNumber(time.getSeconds()); - if (from_date === until_date) { + if (fromDate === untilDate) { // Abbreviated form for intervals on the same day // We split title in two lines on small screens if ($(window).width() < 992) { - until_time += "\n"; + untilTime += "\n"; } - return ("Queries from " + from_time + " to " + until_time + " on " + from_date).split( + return ("Queries from " + fromTime + " to " + untilTime + " on " + fromDate).split( "\n " ); } @@ -253,18 +253,18 @@ $(document).ready(function () { // Full tooltip for intervals spanning more than one day // We split title in two lines on small screens if ($(window).width() < 992) { - from_date += "\n"; + fromDate += "\n"; } return ( "Queries from " + - from_date + + fromDate + " " + - from_time + + fromTime + " to " + - until_date + + untilDate + " " + - until_time + untilTime ).split("\n "); }, label: function (tooltipItems, data) { diff --git a/scripts/pi-hole/js/footer.js b/scripts/pi-hole/js/footer.js index a85fbd1d..3259cf0e 100644 --- a/scripts/pi-hole/js/footer.js +++ b/scripts/pi-hole/js/footer.js @@ -93,7 +93,7 @@ function piholeChange(action, duration) { } } -function check_messages() { +function checkMessages() { $.getJSON("api_db.php?status", function (data) { if ("message_count" in data && data.message_count > 0) { var title; @@ -122,16 +122,16 @@ $(document).ready(function () { $("#cookieInfo").show(); } - var checkbox_theme = $("#checkbox_theme").text(); + var checkboxTheme = $("#checkbox_theme").text(); $("input").icheck({ - checkboxClass: "icheckbox_" + checkbox_theme, - radioClass: "iradio_" + checkbox_theme, + checkboxClass: "icheckbox_" + checkboxTheme, + radioClass: "iradio_" + checkboxTheme, increaseArea: "20%" }); // Run check immediately after page loading ... - check_messages(); + checkMessages(); // ... and once again with five seconds delay - setTimeout(check_messages, 5000); + setTimeout(checkMessages, 5000); }); // Handle Enable/Disable diff --git a/scripts/pi-hole/js/gravity.js b/scripts/pi-hole/js/gravity.js index f2ff1d9a..3c9dbbcc 100644 --- a/scripts/pi-hole/js/gravity.js +++ b/scripts/pi-hole/js/gravity.js @@ -32,10 +32,11 @@ function eventsource() { } // Detect ${OVER} - if (e.data.indexOf("<------") !== -1) { + var newString = "<------"; + + if (e.data.indexOf(newString) !== -1) { ta.text(ta.text().substring(0, ta.text().lastIndexOf("\n")) + "\n"); - var new_string = e.data.replace("<------", ""); - ta.append(new_string); + ta.append(e.data.replace(newString, "")); } else { ta.append(e.data); } diff --git a/scripts/pi-hole/js/groups-adlists.js b/scripts/pi-hole/js/groups-adlists.js index b184e625..c830fd14 100644 --- a/scripts/pi-hole/js/groups-adlists.js +++ b/scripts/pi-hole/js/groups-adlists.js @@ -11,7 +11,7 @@ var table; var groups = []; var token = $("#token").text(); -function get_groups() { +function getGroups() { $.post( "scripts/pi-hole/php/groups.php", { action: "get_groups", token: token }, @@ -26,8 +26,8 @@ function get_groups() { $(document).ready(function () { $("#btnAdd").on("click", addAdlist); - utils.bsSelect_defaults(); - get_groups(); + utils.bsSelectDefaults(); + getGroups(); }); function initTable() { @@ -96,13 +96,13 @@ function initTable() { var selectEl = $("#multiselect_" + data.id, row); // Add all known groups for (var i = 0; i < groups.length; i++) { - var data_sub = ""; + var dataSub = ""; if (!groups[i].enabled) { - data_sub = 'data-subtext="(disabled)"'; + dataSub = 'data-subtext="(disabled)"'; } selectEl.append( - $("" + @@ -111,9 +111,9 @@ function initTable() { ">Regex whitelist"; } - var blacklist_options = ""; + var blacklistOptions = ""; if (showtype === "all" || showtype === "black") { - blacklist_options = + blacklistOptions = '" + @@ -126,8 +126,8 @@ function initTable() { '" ); var typeEl = $("#type_" + data.id, row); @@ -161,13 +161,13 @@ function initTable() { var selectEl = $("#multiselect_" + data.id, row); // Add all known groups for (var i = 0; i < groups.length; i++) { - var data_sub = ""; + var dataSub = ""; if (!groups[i].enabled) { - data_sub = 'data-subtext="(disabled)"'; + dataSub = 'data-subtext="(disabled)"'; } selectEl.append( - $("