Skip to content

Commit a16a6d6

Browse files
committed
Fix unicorn/name-replacements errors
Signed-off-by: yubiuser <github@yubiuser.dev>
1 parent c1fdf69 commit a16a6d6

24 files changed

Lines changed: 572 additions & 544 deletions

scripts/js/charts.js

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ globalThis.THEME_COLORS = [
3030

3131
globalThis.htmlLegendPlugin = {
3232
id: "htmlLegend",
33-
afterUpdate(chart, args, options) {
33+
afterUpdate(chart, arguments_, options) {
3434
// Use the built-in legendItems generator
3535
const items = chart.options.plugins.legend.labels.generateLabels(chart);
3636

@@ -39,9 +39,9 @@ globalThis.htmlLegendPlugin = {
3939
options.lastLegendItems &&
4040
items.length === options.lastLegendItems.length &&
4141
items.every(
42-
(item, i) =>
43-
item.text === options.lastLegendItems[i].text &&
44-
item.hidden === options.lastLegendItems[i].hidden
42+
(item, index) =>
43+
item.text === options.lastLegendItems[index].text &&
44+
item.hidden === options.lastLegendItems[index].hidden
4545
);
4646

4747
if (isLegendUnchanged) {
@@ -144,40 +144,40 @@ globalThis.htmlLegendPlugin = {
144144
globalThis.customTooltips = context => {
145145
const tooltip = context.tooltip;
146146
const canvasId = context.chart.canvas.id;
147-
const tooltipEl = getOrCreateTooltipElement(canvasId, tooltip.options, context);
147+
const tooltipElement = getOrCreateTooltipElement(canvasId, tooltip.options, context);
148148

149149
// Hide if no tooltip
150150
if (tooltip.opacity === 0) {
151-
tooltipEl.style.opacity = 0;
151+
tooltipElement.style.opacity = 0;
152152
return;
153153
}
154154

155155
// Set caret position
156-
setTooltipCaretPosition(tooltipEl, tooltip);
156+
setTooltipCaretPosition(tooltipElement, tooltip);
157157

158158
// Set tooltip content
159159
if (tooltip.body) {
160-
setTooltipContent(tooltipEl, tooltip);
160+
setTooltipContent(tooltipElement, tooltip);
161161
}
162162

163163
// Position tooltip
164-
positionTooltip(tooltipEl, tooltip, context);
164+
positionTooltip(tooltipElement, tooltip, context);
165165

166166
// Make tooltip visible
167-
tooltipEl.style.opacity = 1;
167+
tooltipElement.style.opacity = 1;
168168
};
169169

170170
function getOrCreateTooltipElement(canvasId, options, context) {
171-
let tooltipEl = document.getElementById(`${canvasId}-customTooltip`);
172-
if (tooltipEl) {
173-
return tooltipEl;
171+
let tooltipElement = document.getElementById(`${canvasId}-customTooltip`);
172+
if (tooltipElement) {
173+
return tooltipElement;
174174
}
175175

176176
// Create Tooltip Element once per chart
177-
tooltipEl = document.createElement("div");
178-
tooltipEl.id = `${canvasId}-customTooltip`;
179-
tooltipEl.className = "chartjs-tooltip";
180-
tooltipEl.innerHTML = '<div class="arrow"></div> <table></table>';
177+
tooltipElement = document.createElement("div");
178+
tooltipElement.id = `${canvasId}-customTooltip`;
179+
tooltipElement.className = "chartjs-tooltip";
180+
tooltipElement.innerHTML = '<div class="arrow"></div> <table></table>';
181181

182182
// Avoid browser's font-zoom since we know that <body>'s
183183
// font-size was set to 14px by Bootstrap's CSS
@@ -187,7 +187,7 @@ function getOrCreateTooltipElement(canvasId, options, context) {
187187
const fontZoom = Number.parseFloat(getComputedStyle(document.body).fontSize) / 14;
188188

189189
// Set styles and font
190-
tooltipEl.style.cssText = `
190+
tooltipElement.style.cssText = `
191191
padding: ${options.padding}px ${options.padding}px;
192192
border-radius: ${options.cornerRadius}px;
193193
font: ${options.bodyFont.string};
@@ -197,18 +197,18 @@ function getOrCreateTooltipElement(canvasId, options, context) {
197197
`;
198198

199199
// Append Tooltip next to canvas-containing box
200-
tooltipEl.ancestor = context.chart.canvas.closest(".box[id]").parentNode;
201-
tooltipEl.ancestor.append(tooltipEl);
200+
tooltipElement.ancestor = context.chart.canvas.closest(".box[id]").parentNode;
201+
tooltipElement.ancestor.append(tooltipElement);
202202

203-
return tooltipEl;
203+
return tooltipElement;
204204
}
205205

206-
function setTooltipCaretPosition(tooltipEl, tooltip) {
207-
tooltipEl.classList.remove("left", "right", "center", "top", "bottom");
208-
tooltipEl.classList.add(tooltip.xAlign, tooltip.yAlign);
206+
function setTooltipCaretPosition(tooltipElement, tooltip) {
207+
tooltipElement.classList.remove("left", "right", "center", "top", "bottom");
208+
tooltipElement.classList.add(tooltip.xAlign, tooltip.yAlign);
209209
}
210210

211-
function setTooltipContent(tooltipEl, tooltip) {
211+
function setTooltipContent(tooltipElement, tooltip) {
212212
const bodyLines = tooltip.body.map(bodyItem => bodyItem.lines);
213213
if (bodyLines.length === 0) {
214214
return;
@@ -226,18 +226,18 @@ function setTooltipContent(tooltipEl, tooltip) {
226226
const devicePixel = (1 / window.devicePixelRatio).toFixed(1);
227227
let printed = 0;
228228

229-
for (const [i, body] of bodyLines.entries()) {
230-
const labelColors = tooltip.labelColors[i];
229+
for (const [index, body] of bodyLines.entries()) {
230+
const labelColors = tooltip.labelColors[index];
231231
const style =
232232
`background-color: ${labelColors.backgroundColor}; ` +
233233
`outline: 1px solid ${labelColors.backgroundColor}; ` +
234234
`border: ${devicePixel}px solid #fff`;
235235
const span = `<span class="chartjs-tooltip-key" style="${style}"></span>`;
236236

237-
const num = body[0].split(": ");
237+
const number_ = body[0].split(": ");
238238
// Do not display entries with value of 0 in bar chart,
239239
// but pass through entries with "0.0%" (in pie charts)
240-
if (num[1] !== "0") {
240+
if (number_[1] !== "0") {
241241
tooltipHtml += `<tr><td>${span}${body}</td></tr>`;
242242
printed++;
243243
}
@@ -249,21 +249,21 @@ function setTooltipContent(tooltipEl, tooltip) {
249249

250250
tooltipHtml += "</tbody>";
251251

252-
const tableRoot = tooltipEl.querySelector("table");
252+
const tableRoot = tooltipElement.querySelector("table");
253253
tableRoot.innerHTML = tooltipHtml;
254254
}
255255

256-
function positionTooltip(tooltipEl, tooltip, context) {
257-
if (tooltip.opacity === 0 || tooltipEl.style.opacity === 0) {
256+
function positionTooltip(tooltipElement, tooltip, context) {
257+
if (tooltip.opacity === 0 || tooltipElement.style.opacity === 0) {
258258
return;
259259
}
260260

261261
const canvasPos = context.chart.canvas.getBoundingClientRect();
262-
const boxPos = tooltipEl.ancestor.getBoundingClientRect();
262+
const boxPos = tooltipElement.ancestor.getBoundingClientRect();
263263
const offsetX = canvasPos.left - boxPos.left;
264264
const offsetY = canvasPos.top - boxPos.top;
265-
const tooltipWidth = tooltipEl.offsetWidth;
266-
const tooltipHeight = tooltipEl.offsetHeight;
265+
const tooltipWidth = tooltipElement.offsetWidth;
266+
const tooltipHeight = tooltipElement.offsetHeight;
267267
const { caretX, caretY } = tooltip;
268268
const { caretPadding } = tooltip.options;
269269
const arrowMinIndent = 2 * tooltip.options.cornerRadius;
@@ -323,7 +323,7 @@ function positionTooltip(tooltipEl, tooltip, context) {
323323

324324
// Adjust X position if tooltip is centered inside ancestor
325325
if (document.documentElement.clientWidth <= 2 * tooltip.width && tooltip.xAlign === "center") {
326-
tooltipX = (tooltipEl.ancestor.offsetWidth - tooltipWidth) / 2;
326+
tooltipX = (tooltipElement.ancestor.offsetWidth - tooltipWidth) / 2;
327327
tooltipX = Math.max(tooltipX, offsetX + caretX - arrowMinIndent); // Prevent left overflow
328328
tooltipX = Math.min(tooltipX, offsetX + caretX - tooltipWidth + arrowMinIndent); // Prevent right overflow
329329
arrowX = offsetX + caretX - tooltipX;
@@ -367,11 +367,11 @@ function positionTooltip(tooltipEl, tooltip, context) {
367367
}
368368

369369
// Position tooltip and display
370-
tooltipEl.style.top = `${tooltipY.toFixed(1)}px`;
371-
tooltipEl.style.left = `${tooltipX.toFixed(1)}px`;
370+
tooltipElement.style.top = `${tooltipY.toFixed(1)}px`;
371+
tooltipElement.style.left = `${tooltipX.toFixed(1)}px`;
372372

373373
// Set arrow position
374-
const arrowEl = tooltipEl.querySelector(".arrow");
374+
const arrowElement = tooltipElement.querySelector(".arrow");
375375
let arrowLeftPosition = "";
376376

377377
if (arrowX !== undefined) {
@@ -381,7 +381,7 @@ function positionTooltip(tooltipEl, tooltip, context) {
381381
arrowLeftPosition = `${arrowXpercent}%`;
382382
}
383383

384-
arrowEl.style.left = arrowLeftPosition;
384+
arrowElement.style.left = arrowLeftPosition;
385385
}
386386

387387
globalThis.doughnutTooltip = tooltipLabel => {

scripts/js/footer.js

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -124,20 +124,20 @@ function checkBlocking() {
124124
}
125125

126126
function piholeChange(action, duration) {
127-
let btnStatus = null;
127+
let buttonStatus = null;
128128

129129
switch (action) {
130130
case "enable":
131-
btnStatus = $("#flip-status-enable");
131+
buttonStatus = $("#flip-status-enable");
132132
break;
133133
case "disable":
134-
btnStatus = $("#flip-status-disable");
134+
buttonStatus = $("#flip-status-disable");
135135
break;
136136
default: // Do nothing
137137
break;
138138
}
139139

140-
btnStatus.html("<i class='fa fa-spinner fa-spin'> </i>");
140+
buttonStatus.html("<i class='fa fa-spinner fa-spin'> </i>");
141141
$.ajax({
142142
url: document.body.dataset.apiurl + "/dns/blocking",
143143
method: "POST",
@@ -154,7 +154,7 @@ function piholeChange(action, duration) {
154154
return;
155155
}
156156

157-
btnStatus.html("");
157+
buttonStatus.html("");
158158
piholeChanged(data.blocking, data.timer);
159159
})
160160
.fail(data => {
@@ -169,12 +169,12 @@ function testCookies() {
169169

170170
// set and read cookie
171171
document.cookie = "cookietest=1";
172-
const ret = document.cookie.includes("cookietest=");
172+
const returnValue = document.cookie.includes("cookietest=");
173173

174174
// delete cookie
175175
document.cookie = "cookietest=1; expires=Thu, 01-Jan-1970 00:00:01 GMT";
176176

177-
return ret;
177+
return returnValue;
178178
}
179179

180180
function applyCheckboxRadioStyle() {
@@ -426,17 +426,17 @@ function versionCompare(v1, v2) {
426426
}
427427

428428
// loop until both string are processed
429-
for (let i = 0, j = 0; i < v1.length || j < v2.length;) {
429+
for (let index = 0, index_ = 0; index < v1.length || index_ < v2.length;) {
430430
// storing numeric part of version 1 in vnum1
431-
while (i < v1.length && v1[i] !== ".") {
432-
vnum1 = vnum1 * 10 + (v1[i] - "0");
433-
i++;
431+
while (index < v1.length && v1[index] !== ".") {
432+
vnum1 = vnum1 * 10 + (v1[index] - "0");
433+
index++;
434434
}
435435

436436
// storing numeric part of version 2 in vnum2
437-
while (j < v2.length && v2[j] !== ".") {
438-
vnum2 = vnum2 * 10 + (v2[j] - "0");
439-
j++;
437+
while (index_ < v2.length && v2[index_] !== ".") {
438+
vnum2 = vnum2 * 10 + (v2[index_] - "0");
439+
index_++;
440440
}
441441

442442
if (vnum1 > vnum2) {
@@ -450,8 +450,8 @@ function versionCompare(v1, v2) {
450450
// if equal, reset variables and go for next numeric part
451451
vnum1 = 0;
452452
vnum2 = 0;
453-
i++;
454-
j++;
453+
index++;
454+
index_++;
455455
}
456456

457457
return 0;
@@ -639,32 +639,32 @@ $(() => {
639639
});
640640

641641
// Handle Enable/Disable
642-
$("#pihole-enable").on("click", e => {
643-
e.preventDefault();
642+
$("#pihole-enable").on("click", event => {
643+
event.preventDefault();
644644
localStorage.removeItem("countDownTarget");
645645
piholeChange("enable", "");
646646
});
647-
$("#pihole-disable-indefinitely").on("click", e => {
648-
e.preventDefault();
647+
$("#pihole-disable-indefinitely").on("click", event => {
648+
event.preventDefault();
649649
piholeChange("disable", "0");
650650
});
651-
$("#pihole-disable-10s").on("click", e => {
652-
e.preventDefault();
651+
$("#pihole-disable-10s").on("click", event => {
652+
event.preventDefault();
653653
piholeChange("disable", "10");
654654
});
655-
$("#pihole-disable-30s").on("click", e => {
656-
e.preventDefault();
655+
$("#pihole-disable-30s").on("click", event => {
656+
event.preventDefault();
657657
piholeChange("disable", "30");
658658
});
659-
$("#pihole-disable-5m").on("click", e => {
660-
e.preventDefault();
659+
$("#pihole-disable-5m").on("click", event => {
660+
event.preventDefault();
661661
piholeChange("disable", "300");
662662
});
663-
$("#pihole-disable-custom").on("click", e => {
664-
e.preventDefault();
665-
let custVal = $("#customTimeout").val();
666-
custVal = $("#btnMins").hasClass("active") ? custVal * 60 : custVal;
667-
piholeChange("disable", custVal);
663+
$("#pihole-disable-custom").on("click", event => {
664+
event.preventDefault();
665+
let custValue = $("#customTimeout").val();
666+
custValue = $("#btnMins").hasClass("active") ? custValue * 60 : custValue;
667+
piholeChange("disable", custValue);
668668
});
669669

670670
function initSettingsLevel() {

scripts/js/gravity.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function eventsource() {
1313
const $alertInfo = $("#alertInfo");
1414
const $alertSuccess = $("#alertSuccess");
1515
const outputElement = document.getElementById("output");
16-
const gravityBtn = document.getElementById("gravityBtn");
16+
const gravityButton = document.getElementById("gravityBtn");
1717
const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute("content");
1818
const url = `${document.body.dataset.apiurl}/action/gravity?color=true`;
1919

@@ -37,7 +37,7 @@ function eventsource() {
3737
response,
3838
outputElement,
3939
alertInfo: $alertInfo,
40-
gravityBtn,
40+
gravityBtn: gravityButton,
4141
alertSuccess: $alertSuccess,
4242
})
4343
)
@@ -143,10 +143,10 @@ function parseLines(outputElement, text) {
143143
}
144144

145145
document.addEventListener("DOMContentLoaded", () => {
146-
const gravityBtn = document.getElementById("gravityBtn");
146+
const gravityButton = document.getElementById("gravityBtn");
147147

148-
gravityBtn.addEventListener("click", () => {
149-
gravityBtn.disabled = true;
148+
gravityButton.addEventListener("click", () => {
149+
gravityButton.disabled = true;
150150
eventsource();
151151
});
152152

0 commit comments

Comments
 (0)