mirror of
https://github.com/pi-hole/web.git
synced 2025-12-20 02:38:28 +00:00
Fix prefer-global-this error
Signed-off-by: yubiuser <github@yubiuser.dev>
This commit is contained in:
@@ -97,11 +97,11 @@ const htmlLegendPlugin = {
|
|||||||
|
|
||||||
textLink.addEventListener("click", () => {
|
textLink.addEventListener("click", () => {
|
||||||
if (chart.canvas.id === "queryTypePieChart") {
|
if (chart.canvas.id === "queryTypePieChart") {
|
||||||
window.location.href = "queries.lp?type=" + item.text;
|
globalThis.location.href = "queries.lp?type=" + item.text;
|
||||||
} else if (chart.canvas.id === "forwardDestinationPieChart") {
|
} else if (chart.canvas.id === "forwardDestinationPieChart") {
|
||||||
// Encode the forward destination as it may contain an "#" character
|
// Encode the forward destination as it may contain an "#" character
|
||||||
const upstream = encodeURIComponent(upstreams[item.text]);
|
const upstream = encodeURIComponent(upstreams[item.text]);
|
||||||
window.location.href = "queries.lp?upstream=" + upstream;
|
globalThis.location.href = "queries.lp?upstream=" + upstream;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -424,7 +424,7 @@ function updateSystemInfo() {
|
|||||||
function apiFailure(data) {
|
function apiFailure(data) {
|
||||||
if (data.status === 401) {
|
if (data.status === 401) {
|
||||||
// Unauthorized, reload page
|
// Unauthorized, reload page
|
||||||
window.location.reload();
|
globalThis.location.reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -596,7 +596,7 @@ function updateVersionInfo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
if (window.location.pathname !== "/admin/login") updateInfo();
|
if (globalThis.location.pathname !== "/admin/login") updateInfo();
|
||||||
var enaT = $("#enableTimer");
|
var enaT = $("#enableTimer");
|
||||||
var target = new Date(parseInt(enaT.html(), 10));
|
var target = new Date(parseInt(enaT.html(), 10));
|
||||||
var seconds = Math.round((target.getTime() - Date.now()) / 1000);
|
var seconds = Math.round((target.getTime() - Date.now()) / 1000);
|
||||||
@@ -611,7 +611,7 @@ $(function () {
|
|||||||
// Apply per-browser styling settings
|
// Apply per-browser styling settings
|
||||||
initCheckboxRadioStyle();
|
initCheckboxRadioStyle();
|
||||||
|
|
||||||
if (window.location.pathname !== "/admin/login") {
|
if (globalThis.location.pathname !== "/admin/login") {
|
||||||
// Run check immediately after page loading ...
|
// Run check immediately after page loading ...
|
||||||
utils.checkMessages();
|
utils.checkMessages();
|
||||||
// ... and then periodically
|
// ... and then periodically
|
||||||
@@ -705,7 +705,7 @@ function applyExpertSettings() {
|
|||||||
// functionality there), and
|
// functionality there), and
|
||||||
// - there are no visible boxes (the page is empty)
|
// - there are no visible boxes (the page is empty)
|
||||||
if ($(".settings-selector").length > 0 && $(".box:visible").length === 0) {
|
if ($(".settings-selector").length > 0 && $(".box:visible").length === 0) {
|
||||||
window.location.href = "/admin/settings/system";
|
globalThis.location.href = "/admin/settings/system";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -715,7 +715,7 @@ function addAdvancedInfo() {
|
|||||||
const advancedInfoTarget = $("#advanced-info");
|
const advancedInfoTarget = $("#advanced-info");
|
||||||
const isTLS = advancedInfoSource.data("tls");
|
const isTLS = advancedInfoSource.data("tls");
|
||||||
const clientIP = advancedInfoSource.data("client-ip");
|
const clientIP = advancedInfoSource.data("client-ip");
|
||||||
const XForwardedFor = window.atob(advancedInfoSource.data("xff") ?? "");
|
const XForwardedFor = globalThis.atob(advancedInfoSource.data("xff") ?? "");
|
||||||
const starttime = parseFloat(advancedInfoSource.data("starttime"));
|
const starttime = parseFloat(advancedInfoSource.data("starttime"));
|
||||||
const endtime = parseFloat(advancedInfoSource.data("endtime"));
|
const endtime = parseFloat(advancedInfoSource.data("endtime"));
|
||||||
const totaltime = 1e3 * (endtime - starttime);
|
const totaltime = 1e3 * (endtime - starttime);
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ $(function () {
|
|||||||
|
|
||||||
// Do we want to start updating immediately?
|
// Do we want to start updating immediately?
|
||||||
// gravity.lp?go
|
// gravity.lp?go
|
||||||
var searchString = window.location.search.substring(1);
|
var searchString = globalThis.location.search.substring(1);
|
||||||
if (searchString.indexOf("go") !== -1) {
|
if (searchString.indexOf("go") !== -1) {
|
||||||
$("#gravityBtn").prop("disabled", true);
|
$("#gravityBtn").prop("disabled", true);
|
||||||
eventsource();
|
eventsource();
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ function initTable() {
|
|||||||
selectEl
|
selectEl
|
||||||
// fix dropdown if it would stick out right of the viewport
|
// 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 winWidth = $(globalThis).width();
|
||||||
var dropdownEl = $("body > .bootstrap-select.dropdown");
|
var dropdownEl = $("body > .bootstrap-select.dropdown");
|
||||||
if (dropdownEl.length > 0) {
|
if (dropdownEl.length > 0) {
|
||||||
dropdownEl.removeClass("align-right");
|
dropdownEl.removeClass("align-right");
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ function initTable() {
|
|||||||
selectEl
|
selectEl
|
||||||
// fix dropdown if it would stick out right of the viewport
|
// 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 winWidth = $(globalThis).width();
|
||||||
var dropdownEl = $("body > .bootstrap-select.dropdown");
|
var dropdownEl = $("body > .bootstrap-select.dropdown");
|
||||||
if (dropdownEl.length > 0) {
|
if (dropdownEl.length > 0) {
|
||||||
dropdownEl.removeClass("align-right");
|
dropdownEl.removeClass("align-right");
|
||||||
|
|||||||
@@ -298,7 +298,7 @@ function initTable() {
|
|||||||
selectEl
|
selectEl
|
||||||
// fix dropdown if it would stick out right of the viewport
|
// 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 winWidth = $(globalThis).width();
|
||||||
var dropdownEl = $("body > .bootstrap-select.dropdown");
|
var dropdownEl = $("body > .bootstrap-select.dropdown");
|
||||||
if (dropdownEl.length > 0) {
|
if (dropdownEl.length > 0) {
|
||||||
dropdownEl.removeClass("align-right");
|
dropdownEl.removeClass("align-right");
|
||||||
|
|||||||
@@ -790,7 +790,7 @@ $(function () {
|
|||||||
//get value by index
|
//get value by index
|
||||||
var from = label / 1000 - 300;
|
var from = label / 1000 - 300;
|
||||||
var until = label / 1000 + 300;
|
var until = label / 1000 + 300;
|
||||||
window.location.href = "queries.lp?from=" + from + "&until=" + until;
|
globalThis.location.href = "queries.lp?from=" + from + "&until=" + until;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -813,7 +813,7 @@ $(function () {
|
|||||||
//get value by index
|
//get value by index
|
||||||
var from = label / 1000 - 300;
|
var from = label / 1000 - 300;
|
||||||
var until = label / 1000 + 300;
|
var until = label / 1000 + 300;
|
||||||
window.location.href = "queries.lp?from=" + from + "&until=" + until;
|
globalThis.location.href = "queries.lp?from=" + from + "&until=" + until;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ function redirect() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Redirect to target
|
// Redirect to target
|
||||||
window.location.replace(target);
|
globalThis.location.replace(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
function wrongPassword(isError = false, isSuccess = false, data = null) {
|
function wrongPassword(isError = false, isSuccess = false, data = null) {
|
||||||
|
|||||||
@@ -677,7 +677,7 @@ $(function () {
|
|||||||
var tr = $(this);
|
var tr = $(this);
|
||||||
var row = table.row(tr);
|
var row = table.row(tr);
|
||||||
|
|
||||||
if (window.getSelection().toString().length > 0) {
|
if (globalThis.getSelection().toString().length > 0) {
|
||||||
// This event was triggered by a selection, so don't open the row
|
// This event was triggered by a selection, so don't open the row
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,14 +94,14 @@ $("#GETTeleporter").on("click", function () {
|
|||||||
success: function (data, status, xhr) {
|
success: function (data, status, xhr) {
|
||||||
var a = document.createElement("a");
|
var a = document.createElement("a");
|
||||||
// eslint-disable-next-line compat/compat
|
// eslint-disable-next-line compat/compat
|
||||||
var url = window.URL.createObjectURL(data);
|
var url = globalThis.URL.createObjectURL(data);
|
||||||
a.href = url;
|
a.href = url;
|
||||||
a.download = xhr.getResponseHeader("Content-Disposition").match(/filename="([^"]*)"/)[1];
|
a.download = xhr.getResponseHeader("Content-Disposition").match(/filename="([^"]*)"/)[1];
|
||||||
document.body.append(a);
|
document.body.append(a);
|
||||||
a.click();
|
a.click();
|
||||||
a.remove();
|
a.remove();
|
||||||
// eslint-disable-next-line compat/compat
|
// eslint-disable-next-line compat/compat
|
||||||
window.URL.revokeObjectURL(url);
|
globalThis.URL.revokeObjectURL(url);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ function getData() {
|
|||||||
|
|
||||||
var GETDict = utils.parseQueryString();
|
var GETDict = utils.parseQueryString();
|
||||||
if (!("file" in GETDict)) {
|
if (!("file" in GETDict)) {
|
||||||
window.location.href += "?file=dnsmasq";
|
globalThis.location.href += "?file=dnsmasq";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -530,7 +530,7 @@ function getCSSval(cssclass, cssproperty) {
|
|||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseQueryString(queryString = window.location.search) {
|
function parseQueryString(queryString = globalThis.location.search) {
|
||||||
const GETDict = {};
|
const GETDict = {};
|
||||||
queryString
|
queryString
|
||||||
.substr(1)
|
.substr(1)
|
||||||
@@ -688,7 +688,7 @@ function loadingOverlay(reloadAfterTimeout = false) {
|
|||||||
function callIfVisible(func) {
|
function callIfVisible(func) {
|
||||||
if (document.hidden) {
|
if (document.hidden) {
|
||||||
// Page is not visible, try again in 1 second
|
// Page is not visible, try again in 1 second
|
||||||
window.setTimeout(callIfVisible, 1000, func);
|
globalThis.setTimeout(callIfVisible, 1000, func);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -703,22 +703,22 @@ function callIfVisible(func) {
|
|||||||
// visible again.
|
// visible again.
|
||||||
function setTimer(func, interval) {
|
function setTimer(func, interval) {
|
||||||
// Cancel possibly running timer
|
// Cancel possibly running timer
|
||||||
window.clearTimeout(func.timer);
|
globalThis.clearTimeout(func.timer);
|
||||||
// Start new timer
|
// Start new timer
|
||||||
func.timer = window.setTimeout(callIfVisible, interval, func);
|
func.timer = globalThis.setTimeout(callIfVisible, interval, func);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Same as setTimer() but calls the function every <interval> milliseconds
|
// Same as setTimer() but calls the function every <interval> milliseconds
|
||||||
function setInter(func, interval) {
|
function setInter(func, interval) {
|
||||||
// Cancel possibly running timer
|
// Cancel possibly running timer
|
||||||
window.clearTimeout(func.timer);
|
globalThis.clearTimeout(func.timer);
|
||||||
// Start new timer
|
// Start new timer
|
||||||
func.timer = window.setTimeout(callIfVisible, interval, func);
|
func.timer = globalThis.setTimeout(callIfVisible, interval, func);
|
||||||
// Restart timer
|
// Restart timer
|
||||||
window.setTimeout(setInter, interval, func, interval);
|
globalThis.setTimeout(setInter, interval, func, interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.utils = (function () {
|
globalThis.utils = (function () {
|
||||||
return {
|
return {
|
||||||
escapeHtml: escapeHtml,
|
escapeHtml: escapeHtml,
|
||||||
unescapeHtml: unescapeHtml,
|
unescapeHtml: unescapeHtml,
|
||||||
|
|||||||
Reference in New Issue
Block a user