mirror of
https://github.com/pi-hole/web.git
synced 2025-12-24 20:55:28 +00:00
Manual xo fixes and suppressions
Signed-off-by: XhmikosR <xhmikosr@gmail.com>
This commit is contained in:
@@ -156,9 +156,7 @@ const customTooltips = function (context) {
|
||||
// Set Text
|
||||
if (tooltip.body) {
|
||||
const titleLines = tooltip.title || [];
|
||||
const bodyLines = tooltip.body.map(bodyItem => {
|
||||
return bodyItem.lines;
|
||||
});
|
||||
const bodyLines = tooltip.body.map(bodyItem => bodyItem.lines);
|
||||
let innerHtml = "<thead>";
|
||||
|
||||
for (const title of titleLines) {
|
||||
@@ -216,10 +214,10 @@ const customTooltips = function (context) {
|
||||
tooltipX = offsetX + caretX;
|
||||
if (tooltip.yAlign === "top" || tooltip.yAlign === "bottom") {
|
||||
switch (tooltip.xAlign) {
|
||||
case "center":
|
||||
case "center": {
|
||||
// set a minimal X position to 5px to prevent
|
||||
// the tooltip to stick out left of the viewport
|
||||
var minX = 5;
|
||||
const minX = 5;
|
||||
if (2 * tooltipX < tooltipWidth + minX) {
|
||||
arrowX = tooltipX - minX;
|
||||
tooltipX = minX;
|
||||
@@ -228,6 +226,8 @@ const customTooltips = function (context) {
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case "left":
|
||||
tooltipX -= arrowMinIndent;
|
||||
arrowX = arrowMinIndent;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
/* global utils:false, moment:false */
|
||||
|
||||
const _isLoginPage = false;
|
||||
globalThis._isLoginPage = false;
|
||||
|
||||
const REFRESH_INTERVAL = {
|
||||
logs: 500, // 0.5 sec (logs page)
|
||||
@@ -587,7 +587,7 @@ function updateVersionInfo() {
|
||||
}
|
||||
|
||||
$(() => {
|
||||
if (!_isLoginPage) updateInfo();
|
||||
if (!globalThis._isLoginPage) updateInfo();
|
||||
const enaT = $("#enableTimer");
|
||||
const target = new Date(Number.parseInt(enaT.html(), 10));
|
||||
const seconds = Math.round((target.getTime() - Date.now()) / 1000);
|
||||
@@ -602,7 +602,7 @@ $(() => {
|
||||
// Apply icheckbox/iradio style
|
||||
applyCheckboxRadioStyle();
|
||||
|
||||
if (!_isLoginPage) {
|
||||
if (!globalThis._isLoginPage) {
|
||||
// Run check immediately after page loading ...
|
||||
utils.checkMessages();
|
||||
// ... and then periodically
|
||||
@@ -707,7 +707,7 @@ function addAdvancedInfo() {
|
||||
const advancedInfoTarget = $("#advanced-info");
|
||||
const isTLS = location.protocol === "https:";
|
||||
const clientIP = advancedInfoSource.data("client-ip");
|
||||
const XForwardedFor = globalThis.atob(advancedInfoSource.data("xff") ?? "");
|
||||
const XForwardedFor = globalThis.atob(advancedInfoSource.data("xff") || "") || null;
|
||||
const starttime = Number.parseFloat(advancedInfoSource.data("starttime"));
|
||||
const endtime = Number.parseFloat(advancedInfoSource.data("endtime"));
|
||||
const totaltime = 1e3 * (endtime - starttime);
|
||||
@@ -725,7 +725,7 @@ function addAdvancedInfo() {
|
||||
);
|
||||
|
||||
// Add client IP info
|
||||
$("#client-id").text(XForwardedFor ? XForwardedFor : clientIP);
|
||||
$("#client-id").text(XForwardedFor ?? clientIP);
|
||||
if (XForwardedFor) {
|
||||
// If X-Forwarded-For is set, show the X-Forwarded-For in italics and add
|
||||
// the real client IP as tooltip
|
||||
|
||||
@@ -172,10 +172,7 @@ function initTable() {
|
||||
const selectEl = $("#multiselect_" + dataId, row);
|
||||
// Add all known groups
|
||||
for (const group of groups) {
|
||||
let dataSub = "";
|
||||
if (!group.enabled) {
|
||||
dataSub = 'data-subtext="(disabled)"';
|
||||
}
|
||||
const dataSub = group.enabled ? "" : 'data-subtext="(disabled)"';
|
||||
|
||||
selectEl.append(
|
||||
$("<option " + dataSub + "/>")
|
||||
@@ -184,6 +181,8 @@ function initTable() {
|
||||
);
|
||||
}
|
||||
|
||||
const applyBtn = "#btn_apply_" + dataId;
|
||||
|
||||
// Select assigned groups
|
||||
selectEl.val(data.groups);
|
||||
// Initialize bootstrap-select
|
||||
@@ -228,8 +227,6 @@ function initTable() {
|
||||
' class="btn btn-block btn-sm" disabled>Apply</button>'
|
||||
);
|
||||
|
||||
var applyBtn = "#btn_apply_" + dataId;
|
||||
|
||||
const button =
|
||||
'<button type="button" class="btn btn-danger btn-xs" id="deleteClient_' +
|
||||
dataId +
|
||||
@@ -358,14 +355,12 @@ function addClient() {
|
||||
|
||||
// Check if the user wants to add multiple IPs (space or newline separated)
|
||||
// If so, split the input and store it in an array
|
||||
let ips = $("#select")
|
||||
const ips = $("#select")
|
||||
.val()
|
||||
.trim()
|
||||
.split(/[\s,]+/);
|
||||
.split(/[\s,]+/)
|
||||
// Remove empty elements
|
||||
ips = ips.filter(el => {
|
||||
return el !== "";
|
||||
});
|
||||
.filter(el => el !== "");
|
||||
const ipStr = JSON.stringify(ips);
|
||||
|
||||
// Validate input, can be:
|
||||
|
||||
@@ -17,10 +17,7 @@ function populateGroupSelect(selectEl) {
|
||||
|
||||
// Add all known groups
|
||||
for (const group of groups) {
|
||||
let dataSub = "";
|
||||
if (!group.enabled) {
|
||||
dataSub = 'data-subtext="(disabled)"';
|
||||
}
|
||||
const dataSub = group.enabled ? "" : 'data-subtext="(disabled)"';
|
||||
|
||||
selectEl.append(
|
||||
$("<option " + dataSub + "/>")
|
||||
|
||||
@@ -50,6 +50,9 @@ $(() => {
|
||||
|
||||
// Show a list of suggested domains based on the user's input
|
||||
function showSuggestDomains(value) {
|
||||
const newDomainEl = $("#new_domain");
|
||||
const suggestDomainEl = $("#suggest_domains");
|
||||
|
||||
function createButton(hostname) {
|
||||
// Purposefully omit 'btn' class to save space on padding
|
||||
return $('<button type="button" class="btn-link btn-block text-right">')
|
||||
@@ -60,9 +63,6 @@ function showSuggestDomains(value) {
|
||||
});
|
||||
}
|
||||
|
||||
var newDomainEl = $("#new_domain");
|
||||
const suggestDomainEl = $("#suggest_domains");
|
||||
|
||||
try {
|
||||
const parts = new URL(value).hostname.split(".");
|
||||
const table = $("<table>");
|
||||
@@ -228,10 +228,7 @@ function initTable() {
|
||||
const selectEl = $("#multiselect_" + dataId, row);
|
||||
// Add all known groups
|
||||
for (const group of groups) {
|
||||
let dataSub = "";
|
||||
if (!group.enabled) {
|
||||
dataSub = 'data-subtext="(disabled)"';
|
||||
}
|
||||
const dataSub = group.enabled ? "" : 'data-subtext="(disabled)"';
|
||||
|
||||
selectEl.append(
|
||||
$("<option " + dataSub + "/>")
|
||||
@@ -490,9 +487,7 @@ function addDomain() {
|
||||
// If so, split the input and store it in an array
|
||||
let domains = domainEl.val().split(/\s+/);
|
||||
// Remove empty elements
|
||||
domains = domains.filter(el => {
|
||||
return el !== "";
|
||||
});
|
||||
domains = domains.filter(el => el !== "");
|
||||
const domainStr = JSON.stringify(domains);
|
||||
|
||||
utils.disableAll();
|
||||
|
||||
@@ -281,10 +281,7 @@ function initTable() {
|
||||
const selectEl = $("#multiselect_" + dataId, row);
|
||||
// Add all known groups
|
||||
for (const group of groups) {
|
||||
let dataSub = "";
|
||||
if (!group.enabled) {
|
||||
dataSub = 'data-subtext="(disabled)"';
|
||||
}
|
||||
const dataSub = group.enabled ? "" : 'data-subtext="(disabled)"';
|
||||
|
||||
selectEl.append(
|
||||
$("<option " + dataSub + "/>")
|
||||
@@ -506,9 +503,7 @@ function addList(event) {
|
||||
.val()
|
||||
.split(/[\s,]+/);
|
||||
// Remove empty elements
|
||||
addresses = addresses.filter(el => {
|
||||
return el !== "";
|
||||
});
|
||||
addresses = addresses.filter(el => el !== "");
|
||||
const addressestr = JSON.stringify(addresses);
|
||||
|
||||
utils.disableAll();
|
||||
|
||||
@@ -242,13 +242,9 @@ function addGroup() {
|
||||
.escapeHtml($("#new_name"))
|
||||
.val()
|
||||
.match(/(?:[^\s"]+|"[^"]*")+/g)
|
||||
.map(name => {
|
||||
return name.replaceAll(/(^"|"$)/g, "");
|
||||
});
|
||||
.map(name => name.replaceAll(/(^"|"$)/g, ""));
|
||||
// Remove empty elements
|
||||
names = names.filter(el => {
|
||||
return el !== "";
|
||||
});
|
||||
names = names.filter(el => el !== "");
|
||||
const groupStr = JSON.stringify(names);
|
||||
|
||||
utils.disableAll();
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
/* global utils:false, NProgress:false */
|
||||
|
||||
const _isLoginPage = true;
|
||||
globalThis._isLoginPage = true;
|
||||
|
||||
function redirect() {
|
||||
// Login succeeded or not needed (empty password)
|
||||
|
||||
@@ -13,9 +13,7 @@ function addAllowedValues(allowed) {
|
||||
return (
|
||||
"<p>Available options:</p><ul><li>" +
|
||||
allowed
|
||||
.map(option => {
|
||||
return "<code>" + option.item + "</code>: " + utils.escapeHtml(option.description);
|
||||
})
|
||||
.map(option => "<code>" + option.item + "</code>: " + utils.escapeHtml(option.description))
|
||||
.join("</li><li>") +
|
||||
"</li></ul>"
|
||||
);
|
||||
|
||||
@@ -212,13 +212,13 @@ function deleteMultipleSessions(ids) {
|
||||
|
||||
// Exploit prevention: Return early for non-numeric IDs
|
||||
for (const id of ids) {
|
||||
// TODO Fix eslint
|
||||
// eslint-disable-next-line unicorn/prefer-number-properties
|
||||
if (Object.hasOwn(ids, id) && isNaN(ids[id])) return;
|
||||
}
|
||||
|
||||
// Convert all ids to integers
|
||||
ids = ids.map(value => {
|
||||
return Number.parseInt(value, 10);
|
||||
});
|
||||
ids = ids.map(value => Number.parseInt(value, 10));
|
||||
|
||||
// Check if own session is selected and remove it when deleting multiple
|
||||
// We need this only when multiple sessions are removed to ensure we do not
|
||||
@@ -228,9 +228,7 @@ function deleteMultipleSessions(ids) {
|
||||
if (ids.includes(ownSessionID) && ids.length > 1) {
|
||||
ownSessionDelete = true;
|
||||
// Strip own session ID from array
|
||||
ids = ids.filter(value => {
|
||||
return value !== ownSessionID;
|
||||
});
|
||||
ids = ids.filter(value => value !== ownSessionID);
|
||||
}
|
||||
|
||||
// Loop through IDs and delete them
|
||||
|
||||
@@ -241,6 +241,8 @@ $(document).ready(() => {
|
||||
utils.disableAll();
|
||||
let elem = $("#Cdomain").val() + "," + $("#Ctarget").val();
|
||||
const ttlVal = Number.parseInt($("#Cttl").val(), 10);
|
||||
// TODO Fix eslint
|
||||
// eslint-disable-next-line unicorn/prefer-number-properties
|
||||
if (isFinite(ttlVal) && ttlVal >= 0) elem += "," + ttlVal;
|
||||
const url =
|
||||
document.body.dataset.apiurl + "/config/dns/cnameRecords/" + encodeURIComponent(elem);
|
||||
|
||||
@@ -69,6 +69,8 @@ function formatFTL(line, prio) {
|
||||
return `<span class="${prioClass}">${utils.escapeHtml(prio)}</span> ${line}`;
|
||||
}
|
||||
|
||||
let gAutoScrolling;
|
||||
|
||||
// Function that asks the API for new data
|
||||
function getData() {
|
||||
// Only update when spinner is spinning
|
||||
@@ -168,7 +170,7 @@ function getData() {
|
||||
});
|
||||
}
|
||||
|
||||
var gAutoScrolling = true;
|
||||
gAutoScrolling = true;
|
||||
$("#output").on("scroll", () => {
|
||||
// Check if we are at the bottom of the output
|
||||
//
|
||||
|
||||
@@ -30,9 +30,7 @@ function escapeHtml(text) {
|
||||
// Return early when text is not a string
|
||||
if (typeof text !== "string") return text;
|
||||
|
||||
return text.replaceAll(/[&<>"']/g, m => {
|
||||
return map[m];
|
||||
});
|
||||
return text.replaceAll(/[&<>"']/g, m => map[m]);
|
||||
}
|
||||
|
||||
function unescapeHtml(text) {
|
||||
@@ -53,22 +51,19 @@ function unescapeHtml(text) {
|
||||
|
||||
if (text === null) return null;
|
||||
|
||||
return text.replaceAll(/&(?:amp|lt|gt|quot|#039|Uuml|uuml|Auml|auml|Ouml|ouml|szlig);/g, m => {
|
||||
return map[m];
|
||||
});
|
||||
return text.replaceAll(
|
||||
/&(?:amp|lt|gt|quot|#039|Uuml|uuml|Auml|auml|Ouml|ouml|szlig);/g,
|
||||
m => map[m]
|
||||
);
|
||||
}
|
||||
|
||||
// Helper function for converting Objects to Arrays after sorting the keys
|
||||
function objectToArray(obj) {
|
||||
const arr = [];
|
||||
const idx = [];
|
||||
const keys = Object.keys(obj);
|
||||
const sortedKeys = Object.keys(obj).sort((a, b) => a - b);
|
||||
|
||||
keys.sort((a, b) => {
|
||||
return a - b;
|
||||
});
|
||||
|
||||
for (const key of keys) {
|
||||
for (const key of sortedKeys) {
|
||||
arr.push(obj[key]);
|
||||
idx.push(key);
|
||||
}
|
||||
@@ -297,7 +292,8 @@ function stateLoadCallback(itemName) {
|
||||
data = JSON.parse(data);
|
||||
|
||||
// Clear possible filtering settings
|
||||
for (const [index, value] of data.columns.entries()) {
|
||||
// TODO Maybe Object.values() is meant to be used here?
|
||||
for (const [index, _value] of data.columns.entries()) {
|
||||
data.columns[index].search.search = "";
|
||||
}
|
||||
|
||||
@@ -566,7 +562,7 @@ function hexDecode(string) {
|
||||
return back;
|
||||
}
|
||||
|
||||
function listAlert(type, items, data) {
|
||||
function listsAlert(type, items, data) {
|
||||
// Show simple success message if there is no "processed" object in "data" or
|
||||
// if all items were processed successfully
|
||||
if (data.processed === undefined || data.processed.success.length === items.length) {
|
||||
@@ -751,7 +747,7 @@ globalThis.utils = (function () {
|
||||
parseQueryString,
|
||||
hexEncode,
|
||||
hexDecode,
|
||||
listsAlert: listAlert,
|
||||
listsAlert,
|
||||
loadingOverlay,
|
||||
setTimer,
|
||||
setInter,
|
||||
|
||||
Reference in New Issue
Block a user