mirror of
https://github.com/pi-hole/web.git
synced 2025-12-20 10:48:26 +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", () => {
|
||||
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") {
|
||||
// Encode the forward destination as it may contain an "#" character
|
||||
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) {
|
||||
if (data.status === 401) {
|
||||
// Unauthorized, reload page
|
||||
window.location.reload();
|
||||
globalThis.location.reload();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -596,7 +596,7 @@ function updateVersionInfo() {
|
||||
}
|
||||
|
||||
$(function () {
|
||||
if (window.location.pathname !== "/admin/login") updateInfo();
|
||||
if (globalThis.location.pathname !== "/admin/login") updateInfo();
|
||||
var enaT = $("#enableTimer");
|
||||
var target = new Date(parseInt(enaT.html(), 10));
|
||||
var seconds = Math.round((target.getTime() - Date.now()) / 1000);
|
||||
@@ -611,7 +611,7 @@ $(function () {
|
||||
// Apply per-browser styling settings
|
||||
initCheckboxRadioStyle();
|
||||
|
||||
if (window.location.pathname !== "/admin/login") {
|
||||
if (globalThis.location.pathname !== "/admin/login") {
|
||||
// Run check immediately after page loading ...
|
||||
utils.checkMessages();
|
||||
// ... and then periodically
|
||||
@@ -705,7 +705,7 @@ function applyExpertSettings() {
|
||||
// functionality there), and
|
||||
// - there are no visible boxes (the page is empty)
|
||||
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 isTLS = advancedInfoSource.data("tls");
|
||||
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 endtime = parseFloat(advancedInfoSource.data("endtime"));
|
||||
const totaltime = 1e3 * (endtime - starttime);
|
||||
|
||||
@@ -77,7 +77,7 @@ $(function () {
|
||||
|
||||
// Do we want to start updating immediately?
|
||||
// gravity.lp?go
|
||||
var searchString = window.location.search.substring(1);
|
||||
var searchString = globalThis.location.search.substring(1);
|
||||
if (searchString.indexOf("go") !== -1) {
|
||||
$("#gravityBtn").prop("disabled", true);
|
||||
eventsource();
|
||||
|
||||
@@ -190,7 +190,7 @@ function initTable() {
|
||||
selectEl
|
||||
// fix dropdown if it would stick out right of the viewport
|
||||
.on("show.bs.select", function () {
|
||||
var winWidth = $(window).width();
|
||||
var winWidth = $(globalThis).width();
|
||||
var dropdownEl = $("body > .bootstrap-select.dropdown");
|
||||
if (dropdownEl.length > 0) {
|
||||
dropdownEl.removeClass("align-right");
|
||||
|
||||
@@ -236,7 +236,7 @@ function initTable() {
|
||||
selectEl
|
||||
// fix dropdown if it would stick out right of the viewport
|
||||
.on("show.bs.select", function () {
|
||||
var winWidth = $(window).width();
|
||||
var winWidth = $(globalThis).width();
|
||||
var dropdownEl = $("body > .bootstrap-select.dropdown");
|
||||
if (dropdownEl.length > 0) {
|
||||
dropdownEl.removeClass("align-right");
|
||||
|
||||
@@ -298,7 +298,7 @@ function initTable() {
|
||||
selectEl
|
||||
// fix dropdown if it would stick out right of the viewport
|
||||
.on("show.bs.select", function () {
|
||||
var winWidth = $(window).width();
|
||||
var winWidth = $(globalThis).width();
|
||||
var dropdownEl = $("body > .bootstrap-select.dropdown");
|
||||
if (dropdownEl.length > 0) {
|
||||
dropdownEl.removeClass("align-right");
|
||||
|
||||
@@ -790,7 +790,7 @@ $(function () {
|
||||
//get value by index
|
||||
var from = 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;
|
||||
@@ -813,7 +813,7 @@ $(function () {
|
||||
//get value by index
|
||||
var from = 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;
|
||||
|
||||
@@ -18,7 +18,7 @@ function redirect() {
|
||||
}
|
||||
|
||||
// Redirect to target
|
||||
window.location.replace(target);
|
||||
globalThis.location.replace(target);
|
||||
}
|
||||
|
||||
function wrongPassword(isError = false, isSuccess = false, data = null) {
|
||||
|
||||
@@ -677,7 +677,7 @@ $(function () {
|
||||
var tr = $(this);
|
||||
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
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -94,14 +94,14 @@ $("#GETTeleporter").on("click", function () {
|
||||
success: function (data, status, xhr) {
|
||||
var a = document.createElement("a");
|
||||
// eslint-disable-next-line compat/compat
|
||||
var url = window.URL.createObjectURL(data);
|
||||
var url = globalThis.URL.createObjectURL(data);
|
||||
a.href = url;
|
||||
a.download = xhr.getResponseHeader("Content-Disposition").match(/filename="([^"]*)"/)[1];
|
||||
document.body.append(a);
|
||||
a.click();
|
||||
a.remove();
|
||||
// eslint-disable-next-line compat/compat
|
||||
window.URL.revokeObjectURL(url);
|
||||
globalThis.URL.revokeObjectURL(url);
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -79,7 +79,7 @@ function getData() {
|
||||
|
||||
var GETDict = utils.parseQueryString();
|
||||
if (!("file" in GETDict)) {
|
||||
window.location.href += "?file=dnsmasq";
|
||||
globalThis.location.href += "?file=dnsmasq";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -530,7 +530,7 @@ function getCSSval(cssclass, cssproperty) {
|
||||
return val;
|
||||
}
|
||||
|
||||
function parseQueryString(queryString = window.location.search) {
|
||||
function parseQueryString(queryString = globalThis.location.search) {
|
||||
const GETDict = {};
|
||||
queryString
|
||||
.substr(1)
|
||||
@@ -688,7 +688,7 @@ function loadingOverlay(reloadAfterTimeout = false) {
|
||||
function callIfVisible(func) {
|
||||
if (document.hidden) {
|
||||
// Page is not visible, try again in 1 second
|
||||
window.setTimeout(callIfVisible, 1000, func);
|
||||
globalThis.setTimeout(callIfVisible, 1000, func);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -703,22 +703,22 @@ function callIfVisible(func) {
|
||||
// visible again.
|
||||
function setTimer(func, interval) {
|
||||
// Cancel possibly running timer
|
||||
window.clearTimeout(func.timer);
|
||||
globalThis.clearTimeout(func.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
|
||||
function setInter(func, interval) {
|
||||
// Cancel possibly running timer
|
||||
window.clearTimeout(func.timer);
|
||||
globalThis.clearTimeout(func.timer);
|
||||
// Start new timer
|
||||
func.timer = window.setTimeout(callIfVisible, interval, func);
|
||||
func.timer = globalThis.setTimeout(callIfVisible, interval, func);
|
||||
// Restart timer
|
||||
window.setTimeout(setInter, interval, func, interval);
|
||||
globalThis.setTimeout(setInter, interval, func, interval);
|
||||
}
|
||||
|
||||
window.utils = (function () {
|
||||
globalThis.utils = (function () {
|
||||
return {
|
||||
escapeHtml: escapeHtml,
|
||||
unescapeHtml: unescapeHtml,
|
||||
|
||||
Reference in New Issue
Block a user