From 854693124a8ebc5057359d7e80a5352e285f4ec2 Mon Sep 17 00:00:00 2001 From: Aevann Date: Fri, 29 Sep 2023 03:37:03 +0300 Subject: [PATCH] "window." -> "" --- files/assets/events/homoween/js/bones.js | 2 +- files/assets/events/homoween/js/haunted.js | 2 +- files/assets/events/homoween/js/upsidedown.js | 24 ++++++++--------- files/assets/js/casino/roulette_screen.js | 2 +- files/assets/js/chat.js | 4 +-- files/assets/js/comments.js | 2 +- files/assets/js/core.js | 26 +++++++++---------- files/assets/js/cursormarsey.js | 10 +++---- files/assets/js/emoji_modal.js | 4 +-- files/assets/js/lottery.js | 2 +- files/assets/js/markdown.js | 10 +++---- files/assets/js/mobile_navigation_bar.js | 12 ++++----- files/assets/js/mobile_prompt.js | 2 +- files/assets/js/pwa_pulltorefresh.js | 6 ++--- files/assets/js/submit.js | 2 +- 15 files changed, 55 insertions(+), 55 deletions(-) diff --git a/files/assets/events/homoween/js/bones.js b/files/assets/events/homoween/js/bones.js index 59eb85f5ae..ff80290def 100644 --- a/files/assets/events/homoween/js/bones.js +++ b/files/assets/events/homoween/js/bones.js @@ -52,7 +52,7 @@ function Circle(x, y, v, range) { bones_container.appendChild(this.element); this.update = function() { - if (_this.y > window.innerHeight) { + if (_this.y > innerHeight) { _this.y = 80 + Math.random() * 4; _this.x = _this.range[0] + Math.random() * _this.range[1]; } diff --git a/files/assets/events/homoween/js/haunted.js b/files/assets/events/homoween/js/haunted.js index 5e6d22cf27..55f2e3a2ea 100644 --- a/files/assets/events/homoween/js/haunted.js +++ b/files/assets/events/homoween/js/haunted.js @@ -9,7 +9,7 @@ stylesheet_haunted.setAttribute("href", "/assets/events/homoween/css/haunted2.cs stylesheet_haunted.disabled = true document.head.appendChild(stylesheet_haunted) -window.onload = function(){ +onload = function(){ thunder2.volume = 0.5 lightningStrike("normal") } diff --git a/files/assets/events/homoween/js/upsidedown.js b/files/assets/events/homoween/js/upsidedown.js index 5595889302..3633f6cfbb 100644 --- a/files/assets/events/homoween/js/upsidedown.js +++ b/files/assets/events/homoween/js/upsidedown.js @@ -1,6 +1,6 @@ let st = init("canvas"), // stranger things var w = (canvas.width = innerWidth), -h = (canvas.height = window.innerHeight); +h = (canvas.height = innerHeight); class firefly { constructor() { @@ -45,34 +45,34 @@ function init(elemid) { let canvas = document.getElementById(elemid), st = canvas.getContext("2d"), w = (canvas.width = innerWidth), - h = (canvas.height = window.innerHeight); + h = (canvas.height = innerHeight); st.fillStyle = "rgba(30,30,30,1)"; st.fillRect(0, 0, w, h); return st; } -window.requestAnimFrame = function () { +requestAnimFrame = function () { return ( - window.requestAnimationFrame || - window.webkitRequestAnimationFrame || - window.mozRequestAnimationFrame || - window.oRequestAnimationFrame || - window.msRequestAnimationFrame || + requestAnimationFrame || + webkitRequestAnimationFrame || + mozRequestAnimationFrame || + oRequestAnimationFrame || + msRequestAnimationFrame || function (callback) { - window.setTimeout(callback); + setTimeout(callback); } ); }; function loop() { - window.requestAnimFrame(loop); + requestAnimFrame(loop); st.clearRect(0, 0, w, h); draw(); } -window.addEventListener("resize", function () { +addEventListener("resize", function () { (w = canvas.width = innerWidth), - (h = canvas.height = window.innerHeight); + (h = canvas.height = innerHeight); loop(); }); diff --git a/files/assets/js/casino/roulette_screen.js b/files/assets/js/casino/roulette_screen.js index ed229abbb9..bd8fbbd474 100644 --- a/files/assets/js/casino/roulette_screen.js +++ b/files/assets/js/casino/roulette_screen.js @@ -313,7 +313,7 @@ function placeChip(bet, which) { HIGH_LOW_BET: `Bet ${amount} ${currency} that the number will be ${which === "HIGH" ? "higher than 18" : "lower than 19"}?\nYou could win ${amount} ${currency}.`, } const text = texts[bet] || ""; - const confirmed = window.confirm(text); + const confirmed = confirm(text); if (confirmed) { const xhr = new XMLHttpRequest(); diff --git a/files/assets/js/chat.js b/files/assets/js/chat.js index b9ff2f8b0b..59a10123e0 100644 --- a/files/assets/js/chat.js +++ b/files/assets/js/chat.js @@ -6,7 +6,7 @@ for (const e of timestamps) { e.innerHTML = formatDate(new Date(e.dataset.time*1000)); }; -const ua = window.navigator.userAgent +const ua = navigator.userAgent const socket = io() @@ -50,7 +50,7 @@ socket.on('speak', function(json) { const users = document.getElementsByClassName('user_id'); const last_user = users[users.length-1].value; - const scrolled_down = (box.scrollHeight - box.scrollTop <= window.innerHeight) + const scrolled_down = (box.scrollHeight - box.scrollTop <= innerHeight) if (last_user != json.user_id) { document.getElementsByClassName('avatar-pic')[0].src = '/pp/' + json.user_id diff --git a/files/assets/js/comments.js b/files/assets/js/comments.js index b54c9d9936..16326ca0b4 100644 --- a/files/assets/js/comments.js +++ b/files/assets/js/comments.js @@ -24,7 +24,7 @@ function collapse_comment(id) { if (closed && top < 0) { element.scrollIntoView() - window.scrollBy(0, - 100) + scrollBy(0, - 100) } const reports = document.getElementById(`reports-${id}`) diff --git a/files/assets/js/core.js b/files/assets/js/core.js index 8c78443831..ae6c7915a1 100644 --- a/files/assets/js/core.js +++ b/files/assets/js/core.js @@ -139,12 +139,12 @@ if (!location.pathname.endsWith('/submit')) function autoExpand(field) { - xpos = window.scrollX; - ypos = window.scrollY; + xpos = scrollX; + ypos = scrollY; field.style.height = 'inherit'; - let computed = window.getComputedStyle(field); + let computed = getComputedStyle(field); let height = parseInt(computed.getPropertyValue('border-top-width'), 10) + parseInt(computed.getPropertyValue('padding-top'), 10) @@ -153,13 +153,13 @@ function autoExpand(field) { + parseInt(computed.getPropertyValue('border-bottom-width'), 10); field.style.height = height + 'px'; - if (Math.abs(window.scrollX - xpos) < 1 && Math.abs(window.scrollY - ypos) < 1) return; - window.scrollTo(xpos,ypos); + if (Math.abs(scrollX - xpos) < 1 && Math.abs(scrollY - ypos) < 1) return; + scrollTo(xpos,ypos); }; function smoothScrollTop() { - window.scrollTo({ top: 0, behavior: 'smooth' }); + scrollTo({ top: 0, behavior: 'smooth' }); } // Click navbar to scroll back to top @@ -373,7 +373,7 @@ function sort_table(t) { } } -const is_pwa = window.matchMedia('(display-mode: standalone)')['matches'] || window.matchMedia('(display-mode: minimal-ui)')['matches'] +const is_pwa = matchMedia('(display-mode: standalone)')['matches'] || matchMedia('(display-mode: minimal-ui)')['matches'] if (is_pwa) { const links = document.querySelectorAll('a[data-target="t"]'); for (const link of links) { @@ -400,7 +400,7 @@ if (location.pathname != '/chat' && (gbrowser == 'iphone' || gbrowser == 'mac')) } } -const screen_width = (window.innerWidth > 0) ? window.innerWidth : screen.width; +const screen_width = (innerWidth > 0) ? innerWidth : screen.width; function focusSearchBar(element) { if (screen_width >= 768) { @@ -427,7 +427,7 @@ function insertText(input, text) { const newPos = input.selectionStart + text.length; input.setRangeText(text); - if (window.chrome !== undefined) + if (chrome !== undefined) setTimeout(function(){ input.focus(); for(let i = 0; i < 2; i++) @@ -518,7 +518,7 @@ function handle_files(input, newfiles) { if (input.files.length > 20) { - window.alert("You can't upload more than 20 files at one time!") + alert("You can't upload more than 20 files at one time!") input.value = null oldfiles[ta.id] = new DataTransfer(); return @@ -678,7 +678,7 @@ function urlB64ToUint8Array(base64String) { .replace(/\-/g, '+') .replace(/_/g, '/'); - const rawData = window.atob(base64); + const rawData = atob(base64); const outputArray = new Uint8Array(rawData.length); for (let i = 0; i < rawData.length; ++i) { @@ -712,9 +712,9 @@ function enablePushNotifications() { }) }).then((subscription) => { updateSubscriptionOnServer(subscription, "/push_subscribe") - window.alert("Push notifications are enabled!") + alert("Push notifications are enabled!") }).catch((e) => { - window.alert("Please give the site access to notifications!") + alert("Please give the site access to notifications!") console.error(e) }) } diff --git a/files/assets/js/cursormarsey.js b/files/assets/js/cursormarsey.js index 3ca7b10b2a..1bebc4a25b 100644 --- a/files/assets/js/cursormarsey.js +++ b/files/assets/js/cursormarsey.js @@ -104,10 +104,10 @@ function idle() { if (cursormarseyPosY < 32) { avalibleIdleAnimations.push("scratchWallN"); } - if (cursormarseyPosX > window.innerWidth - 32) { + if (cursormarseyPosX > innerWidth - 32) { avalibleIdleAnimations.push("scratchWallE"); } - if (cursormarseyPosY > window.innerHeight - 32) { + if (cursormarseyPosY > innerHeight - 32) { avalibleIdleAnimations.push("scratchWallS"); } idleAnimation = @@ -175,8 +175,8 @@ function frame() { cursormarseyPosX -= (diffX / distance) * cursormarseySpeed; cursormarseyPosY -= (diffY / distance) * cursormarseySpeed; - cursormarseyPosX = Math.min(Math.max(16, cursormarseyPosX), window.innerWidth - 16); - cursormarseyPosY = Math.min(Math.max(16, cursormarseyPosY), window.innerHeight - 16); + cursormarseyPosX = Math.min(Math.max(16, cursormarseyPosX), innerWidth - 16); + cursormarseyPosY = Math.min(Math.max(16, cursormarseyPosY), innerHeight - 16); cursormarseyEl.style.left = `${cursormarseyPosX}px`; cursormarseyEl.style.top = `${cursormarseyPosY}px`; @@ -188,7 +188,7 @@ document.onmousemove = (event) => { mousePosX = event.clientX; mousePosY = event.clientY; }; -window.marseykoInterval = setInterval(frame, 100); +marseykoInterval = setInterval(frame, 100); document.addEventListener('click', (event) => { cursormarseyEl.style.removeProperty("pointer-events"); diff --git a/files/assets/js/emoji_modal.js b/files/assets/js/emoji_modal.js index e431c49d64..924db6a9ae 100644 --- a/files/assets/js/emoji_modal.js +++ b/files/assets/js/emoji_modal.js @@ -469,8 +469,8 @@ function update_speed_emoji_modal(event) { loadEmojis().then( () => { let modal_pos = event.target.getBoundingClientRect(); - modal_pos.x += window.scrollX; - modal_pos.y += window.scrollY; + modal_pos.x += scrollX; + modal_pos.y += scrollY; speed_carot_modal.style.display = "initial"; speed_carot_modal.style.left = box_coords.x - 30 + "px"; diff --git a/files/assets/js/lottery.js b/files/assets/js/lottery.js index d3086a509e..00c2f61674 100644 --- a/files/assets/js/lottery.js +++ b/files/assets/js/lottery.js @@ -45,7 +45,7 @@ function checkLotteryStats() { // Admin function ensureIntent() { - return window.confirm("Are you sure you want to end the current lottery?"); + return confirm("Are you sure you want to end the current lottery?"); } // Composed diff --git a/files/assets/js/markdown.js b/files/assets/js/markdown.js index c9cefcc472..d979024293 100644 --- a/files/assets/js/markdown.js +++ b/files/assets/js/markdown.js @@ -133,10 +133,10 @@ function markdown(t) { if (!reDisableBeforeUnload.test(location.pathname)) { - if (!window.onbeforeunload) + if (!onbeforeunload) { - window.onbeforeunload = function (e) { - e = e || window.event; + onbeforeunload = function (e) { + e = e || event; if (e) { e.returnValue = 'Any string'; } @@ -144,7 +144,7 @@ function markdown(t) { }; } else if (!input) { - window.onbeforeunload = null + onbeforeunload = null } } @@ -273,5 +273,5 @@ function charLimit(form, text) { } function remove_dialog() { - window.onbeforeunload = null; + onbeforeunload = null; } diff --git a/files/assets/js/mobile_navigation_bar.js b/files/assets/js/mobile_navigation_bar.js index cd3dca56e8..e1506989e7 100644 --- a/files/assets/js/mobile_navigation_bar.js +++ b/files/assets/js/mobile_navigation_bar.js @@ -1,6 +1,6 @@ -let prevScrollpos = window.pageYOffset; -window.onscroll = function () { - const currentScrollPos = window.pageYOffset; +let prevScrollpos = pageYOffset; +onscroll = function () { + const currentScrollPos = pageYOffset; const topBar = document.getElementById("fixed-bar-mobile"); @@ -13,13 +13,13 @@ window.onscroll = function () { const bottomSafeAreaInset = parseInt(getComputedStyle(bottomBar).getPropertyValue("--safe-area-inset-bottom")) || 0; if (bottomBar != null) { - if (prevScrollpos > currentScrollPos && (window.innerHeight + currentScrollPos) < (document.body.offsetHeight - 65)) { + if (prevScrollpos > currentScrollPos && (innerHeight + currentScrollPos) < (document.body.offsetHeight - 65)) { bottomBar.style.bottom = "0px"; } - else if (currentScrollPos <= 125 && (window.innerHeight + currentScrollPos) < (document.body.offsetHeight - 65)) { + else if (currentScrollPos <= 125 && (innerHeight + currentScrollPos) < (document.body.offsetHeight - 65)) { bottomBar.style.bottom = "0px"; } - else if (prevScrollpos > currentScrollPos && (window.innerHeight + currentScrollPos) >= (document.body.offsetHeight - 65)) { + else if (prevScrollpos > currentScrollPos && (innerHeight + currentScrollPos) >= (document.body.offsetHeight - 65)) { bottomBar.style.bottom = `-${50 + bottomSafeAreaInset}px`; } else { diff --git a/files/assets/js/mobile_prompt.js b/files/assets/js/mobile_prompt.js index f9cfd03488..7b0c6cad6d 100644 --- a/files/assets/js/mobile_prompt.js +++ b/files/assets/js/mobile_prompt.js @@ -1,5 +1,5 @@ if (!is_pwa) { - if (window.innerWidth <= 737) { + if (innerWidth <= 737) { const tt = bootstrap.Tooltip.getOrCreateInstance(document.getElementById('mobile-prompt')) tt.show() document.getElementsByClassName('tooltip')[0].addEventListener('click', function(e) { diff --git a/files/assets/js/pwa_pulltorefresh.js b/files/assets/js/pwa_pulltorefresh.js index 248ec83a71..0d32778420 100644 --- a/files/assets/js/pwa_pulltorefresh.js +++ b/files/assets/js/pwa_pulltorefresh.js @@ -1,4 +1,4 @@ -const standalone = navigator.standalone || window.matchMedia("(display-mode: standalone)").matches; +const standalone = navigator.standalone || matchMedia("(display-mode: standalone)").matches; if (standalone) { const img = document.getElementById("pulltorefresh-img"); const defaultImg = "/e/marseythinkorino.webp"; @@ -6,13 +6,13 @@ if (standalone) { const threshold = -100; addEventListener("touchend", () => { - if (window.scrollY < threshold) { + if (scrollY < threshold) { location.reload(); } }); addEventListener("scroll", () => { - img.setAttribute("src", window.scrollY < threshold ? thresholdImg : defaultImg); + img.setAttribute("src", scrollY < threshold ? thresholdImg : defaultImg); }); } else { const pulltorefresh = document.getElementById("pulltorefresh") diff --git a/files/assets/js/submit.js b/files/assets/js/submit.js index 3aae552e31..8210175127 100644 --- a/files/assets/js/submit.js +++ b/files/assets/js/submit.js @@ -223,7 +223,7 @@ function submit(form) { //SAVE FILES -const indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB || window.shimIndexedDB; +const indexedDB = indexedDB || mozIndexedDB || webkitIndexedDB || msIndexedDB || shimIndexedDB; const open = indexedDB.open("files", 1);