Skip to content

Commit

Permalink
Fix prefer-global-this error
Browse files Browse the repository at this point in the history
Signed-off-by: yubiuser <[email protected]>
  • Loading branch information
yubiuser committed Dec 7, 2024
1 parent b7b9227 commit e7f97ba
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions scripts/js/charts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
});
}
Expand Down
10 changes: 5 additions & 5 deletions scripts/js/footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ function updateSystemInfo() {
function apiFailure(data) {
if (data.status === 401) {
// Unauthorized, reload page
window.location.reload();
globalThis.location.reload();
}
}

Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand Down Expand Up @@ -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";
}
}
}
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion scripts/js/gravity.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion scripts/js/groups-clients.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion scripts/js/groups-domains.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion scripts/js/groups-lists.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
4 changes: 2 additions & 2 deletions scripts/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion scripts/js/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion scripts/js/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions scripts/js/settings-teleporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
});
});
2 changes: 1 addition & 1 deletion scripts/js/taillog.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
16 changes: 8 additions & 8 deletions scripts/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}

Expand All @@ -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,
Expand Down

0 comments on commit e7f97ba

Please sign in to comment.