Skip to content

Commit

Permalink
Fix lint errors.
Browse files Browse the repository at this point in the history
Signed-off-by: XhmikosR <[email protected]>
  • Loading branch information
XhmikosR committed May 11, 2020
1 parent 73ee91a commit e02df54
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 60 deletions.
4 changes: 2 additions & 2 deletions scripts/pi-hole/js/db_graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ $(document).ready(function () {
options: {
tooltips: {
enabled: true,
itemSort: function(a, b) {
itemSort: function (a, b) {
return b.datasetIndex - a.datasetIndex;
},
mode: "x-axis",
Expand Down Expand Up @@ -267,7 +267,7 @@ $(document).ready(function () {
until_time
).split("\n ");
},
label: function(tooltipItems, data) {
label: function (tooltipItems, data) {
if (tooltipItems.datasetIndex === 0) {
var percentage = 0.0;
var permitted = parseInt(data.datasets[1].data[tooltipItems.index]);
Expand Down
23 changes: 7 additions & 16 deletions scripts/pi-hole/js/groups-adlists.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function initTable() {
// Initialize bootstrap-select
selectEl
// fix dropdown if it would stick out right of the viewport
.on("show.bs.select", function() {
.on("show.bs.select", function () {
var winWidth = $(window).width();
var dropdownEl = $("body > .bootstrap-select.dropdown");
if (dropdownEl.length > 0) {
Expand All @@ -125,27 +125,22 @@ function initTable() {
}
}
})
.on("changed.bs.select", function() {
.on("changed.bs.select", function () {
// enable Apply button
if ($(ApplyBtn).prop("disabled")) {
$(ApplyBtn)
.addClass("btn-success")
.prop("disabled", false)
.on("click", function() {
.on("click", function () {
editAdlist.call(selectEl);
});
}
})
.on("hide.bs.select", function() {
.on("hide.bs.select", function () {
// Restore values if drop-down menu is closed without clicking the Apply button
if (!$(ApplyBtn).prop("disabled")) {
$(this)
.val(data.groups)
.selectpicker("refresh");
$(ApplyBtn)
.removeClass("btn-success")
.prop("disabled", true)
.off("click");
$(this).val(data.groups).selectpicker("refresh");
$(ApplyBtn).removeClass("btn-success").prop("disabled", true).off("click");
}
})
.selectpicker()
Expand Down Expand Up @@ -371,11 +366,7 @@ function deleteAdlist() {
"Successfully deleted adlist ",
address
);
table
.row(tr)
.remove()
.draw(false)
.ajax.reload(null, false);
table.row(tr).remove().draw(false).ajax.reload(null, false);
} else {
utils.showAlert("error", "", "Error while deleting adlist with ID " + id, response.message);
}
Expand Down
23 changes: 7 additions & 16 deletions scripts/pi-hole/js/groups-clients.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ function initTable() {
// Initialize bootstrap-select
selectEl
// fix dropdown if it would stick out right of the viewport
.on("show.bs.select", function() {
.on("show.bs.select", function () {
var winWidth = $(window).width();
var dropdownEl = $("body > .bootstrap-select.dropdown");
if (dropdownEl.length > 0) {
Expand All @@ -161,27 +161,22 @@ function initTable() {
}
}
})
.on("changed.bs.select", function() {
.on("changed.bs.select", function () {
// enable Apply button
if ($(ApplyBtn).prop("disabled")) {
$(ApplyBtn)
.addClass("btn-success")
.prop("disabled", false)
.on("click", function() {
.on("click", function () {
editClient.call(selectEl);
});
}
})
.on("hide.bs.select", function() {
.on("hide.bs.select", function () {
// Restore values if drop-down menu is closed without clicking the Apply button
if (!$(ApplyBtn).prop("disabled")) {
$(this)
.val(data.groups)
.selectpicker("refresh");
$(ApplyBtn)
.removeClass("btn-success")
.prop("disabled", true)
.off("click");
$(this).val(data.groups).selectpicker("refresh");
$(ApplyBtn).removeClass("btn-success").prop("disabled", true).off("click");
}
})
.selectpicker()
Expand Down Expand Up @@ -405,11 +400,7 @@ function deleteClient() {
"Successfully deleted client ",
ip_name
);
table
.row(tr)
.remove()
.draw(false)
.ajax.reload(null, false);
table.row(tr).remove().draw(false).ajax.reload(null, false);
reload_client_suggestions();
} else {
utils.showAlert("error", "", "Error while deleting client with ID " + id, response.message);
Expand Down
4 changes: 2 additions & 2 deletions scripts/pi-hole/js/groups-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function bsSelect_defaults() {
pickerDEFAULTS.dropdownAlignRight = "auto";
pickerDEFAULTS.selectAllText = "All";
pickerDEFAULTS.deselectAllText = "None";
pickerDEFAULTS.countSelectedText = function(num, total) {
pickerDEFAULTS.countSelectedText = function (num, total) {
if (num === total) {
return "All selected (" + num + ")";
}
Expand All @@ -149,7 +149,7 @@ function bsSelect_defaults() {
};
}

window.utils = (function() {
window.utils = (function () {
return {
showAlert: showAlert,
datetime: datetime,
Expand Down
23 changes: 7 additions & 16 deletions scripts/pi-hole/js/groups-domains.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ function initTable() {
// Initialize bootstrap-select
selectEl
// fix dropdown if it would stick out right of the viewport
.on("show.bs.select", function() {
.on("show.bs.select", function () {
var winWidth = $(window).width();
var dropdownEl = $("body > .bootstrap-select.dropdown");
if (dropdownEl.length > 0) {
Expand All @@ -196,27 +196,22 @@ function initTable() {
}
}
})
.on("changed.bs.select", function() {
.on("changed.bs.select", function () {
// enable Apply button
if ($(ApplyBtn).prop("disabled")) {
$(ApplyBtn)
.addClass("btn-success")
.prop("disabled", false)
.on("click", function() {
.on("click", function () {
editDomain.call(selectEl);
});
}
})
.on("hide.bs.select", function() {
.on("hide.bs.select", function () {
// Restore values if drop-down menu is closed without clicking the Apply button
if (!$(ApplyBtn).prop("disabled")) {
$(this)
.val(data.groups)
.selectpicker("refresh");
$(ApplyBtn)
.removeClass("btn-success")
.prop("disabled", true)
.off("click");
$(this).val(data.groups).selectpicker("refresh");
$(ApplyBtn).removeClass("btn-success").prop("disabled", true).off("click");
}
})
.selectpicker()
Expand Down Expand Up @@ -518,11 +513,7 @@ function deleteDomain() {
"Successfully deleted " + domain_regex,
domain
);
table
.row(tr)
.remove()
.draw(false)
.ajax.reload(null, false);
table.row(tr).remove().draw(false).ajax.reload(null, false);
} else {
utils.showAlert(
"error",
Expand Down
14 changes: 7 additions & 7 deletions scripts/pi-hole/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function objectToArray(p) {
return [idx, arr];
}

var customTooltips = function(tooltip) {
var customTooltips = function (tooltip) {
var tooltipEl = document.getElementById(this._chart.canvas.id + "-customTooltip");
if (!tooltipEl) {
// Create Tooltip Element once per chart
Expand Down Expand Up @@ -74,14 +74,14 @@ var customTooltips = function(tooltip) {
var bodyLines = tooltip.body.map(getBody);
var innerHtml = "<thead>";

titleLines.forEach(function(title) {
titleLines.forEach(function (title) {
innerHtml += "<tr><th>" + title + "</th></tr>";
});
innerHtml += "</thead><tbody>";
var printed = 0;

var devicePixel = (1 / window.devicePixelRatio).toFixed(1);
bodyLines.forEach(function(body, i) {
bodyLines.forEach(function (body, i) {
var colors = tooltip.labelColors[i];
var style = "background: " + colors.backgroundColor;
style += "; outline: 1px solid " + colors.backgroundColor;
Expand Down Expand Up @@ -856,7 +856,7 @@ $(document).ready(function () {
tooltips: {
enabled: true,
mode: "x-axis",
itemSort: function(a, b) {
itemSort: function (a, b) {
return b.datasetIndex - a.datasetIndex;
},
callbacks: {
Expand All @@ -869,7 +869,7 @@ $(document).ready(function () {
var to = padNumber(h) + ":" + padNumber(m + 4) + ":59";
return "Queries from " + from + " to " + to;
},
label: function(tooltipItems, data) {
label: function (tooltipItems, data) {
if (tooltipItems.datasetIndex === 0) {
var percentage = 0.0;
var permitted = parseInt(data.datasets[1].data[tooltipItems.index]);
Expand Down Expand Up @@ -943,7 +943,7 @@ $(document).ready(function () {
mode: "x-axis",
custom: customTooltips,
yAlign: "top",
itemSort: function(a, b) {
itemSort: function (a, b) {
return b.yLabel - a.yLabel;
},
callbacks: {
Expand Down Expand Up @@ -1102,6 +1102,6 @@ $(document).ready(function () {
});

//destroy all chartjs customTooltips on window resize
window.addEventListener("resize", function() {
window.addEventListener("resize", function () {
$(".chartjs-tooltip").remove();
});
2 changes: 1 addition & 1 deletion scripts/pi-hole/js/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ $(document).ready(function () {
}
);
$("td:eq(4)", row).off(); // Release any possible previous onClick event handlers
$("td:eq(4)", row).click(function() {
$("td:eq(4)", row).click(function () {
var new_tab = window.open("groups-domains.php?domainid=" + data[9], "_blank");
if (new_tab) {
new_tab.focus();
Expand Down

0 comments on commit e02df54

Please sign in to comment.