diff --git a/scripts/js/charts.js b/scripts/js/charts.js index ffd11968d..83c992704 100644 --- a/scripts/js/charts.js +++ b/scripts/js/charts.js @@ -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; } }); } diff --git a/scripts/js/footer.js b/scripts/js/footer.js index f34abe316..c25d3b4e7 100644 --- a/scripts/js/footer.js +++ b/scripts/js/footer.js @@ -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); diff --git a/scripts/js/gravity.js b/scripts/js/gravity.js index c7129ab71..265732469 100644 --- a/scripts/js/gravity.js +++ b/scripts/js/gravity.js @@ -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(); diff --git a/scripts/js/groups-clients.js b/scripts/js/groups-clients.js index 4213c0ebc..404b03b30 100644 --- a/scripts/js/groups-clients.js +++ b/scripts/js/groups-clients.js @@ -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"); diff --git a/scripts/js/groups-domains.js b/scripts/js/groups-domains.js index 03f6fb476..690e93b8b 100644 --- a/scripts/js/groups-domains.js +++ b/scripts/js/groups-domains.js @@ -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"); diff --git a/scripts/js/groups-lists.js b/scripts/js/groups-lists.js index fac21a40d..d2c33db1d 100644 --- a/scripts/js/groups-lists.js +++ b/scripts/js/groups-lists.js @@ -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"); diff --git a/scripts/js/index.js b/scripts/js/index.js index 5e7f5eabe..749bdb311 100644 --- a/scripts/js/index.js +++ b/scripts/js/index.js @@ -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; diff --git a/scripts/js/login.js b/scripts/js/login.js index fc194ee0e..b30fd5d8a 100644 --- a/scripts/js/login.js +++ b/scripts/js/login.js @@ -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) { diff --git a/scripts/js/queries.js b/scripts/js/queries.js index 4385f3db2..88c2f2039 100644 --- a/scripts/js/queries.js +++ b/scripts/js/queries.js @@ -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; } diff --git a/scripts/js/settings-teleporter.js b/scripts/js/settings-teleporter.js index 03e730d6a..b337fa907 100644 --- a/scripts/js/settings-teleporter.js +++ b/scripts/js/settings-teleporter.js @@ -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); }, }); }); diff --git a/scripts/js/taillog.js b/scripts/js/taillog.js index 2d8f1c79a..01c1e48ed 100644 --- a/scripts/js/taillog.js +++ b/scripts/js/taillog.js @@ -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; } diff --git a/scripts/js/utils.js b/scripts/js/utils.js index ead46577d..d83cdf2c5 100644 --- a/scripts/js/utils.js +++ b/scripts/js/utils.js @@ -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 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,