diff --git a/files/assets/fistmas/js/darkmode.js b/files/assets/fistmas/js/darkmode.js index ea00206df..76f93995e 100644 --- a/files/assets/fistmas/js/darkmode.js +++ b/files/assets/fistmas/js/darkmode.js @@ -1,6 +1,6 @@ function postToastRoastEventDarkmode(t, url) { const xhr = createXhrWithFormKey(url); - xhr[0].onload = function() { + xhr[0].onload = () => { postToastLoadEventDarkmode(xhr[0]) }; xhr[0].send(xhr[1]); diff --git a/files/assets/js/admin/alts.js b/files/assets/js/admin/alts.js index d3c403306..594f0d517 100644 --- a/files/assets/js/admin/alts.js +++ b/files/assets/js/admin/alts.js @@ -4,7 +4,7 @@ function submitAddAlt(element, username) { const form = new FormData(); form.append('other_username', document.getElementById('link-input-other').value); const xhr = createXhrWithFormKey(`/@${username}/alts/`, 'POST', form); - xhr[0].onload = function() { + xhr[0].onload = () => { let data; try { data = JSON.parse(xhr[0].response); diff --git a/files/assets/js/award_modal.js b/files/assets/js/award_modal.js index 405876f7e..ce207ecc0 100644 --- a/files/assets/js/award_modal.js +++ b/files/assets/js/award_modal.js @@ -136,7 +136,7 @@ function buy(mb) { url = `/buy/${kind}` if (mb) url += "?mb=true" const xhr = createXhrWithFormKey(url); - xhr[0].onload = function() { + xhr[0].onload = () => { let data try {data = JSON.parse(xhr[0].response)} catch(e) {console.log(e)} diff --git a/files/assets/js/ban_modal.js b/files/assets/js/ban_modal.js index 47b698e4d..817504dde 100644 --- a/files/assets/js/ban_modal.js +++ b/files/assets/js/ban_modal.js @@ -3,10 +3,10 @@ function banModal(link, name, fullname, cls) { document.getElementById("ban-modal-link").value = link; document.getElementById("banUserButton").innerHTML = `Ban @${name}`; - document.getElementById("banUserButton").addEventListener('click', function() { + document.getElementById("banUserButton").addEventListener('click', () => { let form = new FormData(document.getElementById("banModalForm")); const xhr = createXhrWithFormKey(`/ban_user/${fullname}?form`, "POST", form); - xhr[0].onload = function() { + xhr[0].onload = () => { let data try {data = JSON.parse(xhr[0].response)} catch(e) {console.log(e)} @@ -25,10 +25,10 @@ function chudModal(link, name, fullname, cls) { document.getElementById("chud-modal-link").value = link; document.getElementById("chudUserButton").innerHTML = `Chud @${name}`; - document.getElementById("chudUserButton").addEventListener('click', function() { + document.getElementById("chudUserButton").addEventListener('click', () => { let form = new FormData(document.getElementById("chudModalForm")); const xhr = createXhrWithFormKey(`/agendaposter/${fullname}?form`, "POST", form); - xhr[0].onload = function() { + xhr[0].onload = () => { let data try {data = JSON.parse(xhr[0].response)} catch(e) {console.log(e)} diff --git a/files/assets/js/chat.js b/files/assets/js/chat.js index 07322bc4e..00bfe7bd7 100644 --- a/files/assets/js/chat.js +++ b/files/assets/js/chat.js @@ -172,7 +172,7 @@ function send() { input.parentElement.nextElementSibling.classList.add('d-none'); box.scrollTo(0, box.scrollHeight); - setTimeout(function () { + setTimeout(() => { box.scrollTo(0, box.scrollHeight) }, 200); } @@ -223,15 +223,15 @@ socket.on('online', function(data){ bs_trigger(document.getElementById('online3')) }) -window.addEventListener('blur', function(){ +window.addEventListener('blur', () =>{ focused=false }) -window.addEventListener('focus', function(){ +window.addEventListener('focus', () =>{ focused=true }) -ta.addEventListener("input", function() { +ta.addEventListener("input", () => { text = ta.value if (!text && is_typing==true){ is_typing=false; @@ -313,18 +313,18 @@ document.onpaste = function(event) { } box.scrollTo(0, box.scrollHeight) -setTimeout(function () { +setTimeout(() => { box.scrollTo(0, box.scrollHeight) }, 200); -setTimeout(function () { +setTimeout(() => { box.scrollTo(0, box.scrollHeight) }, 500); -setTimeout(function () { +setTimeout(() => { box.scrollTo(0, box.scrollHeight) }, 1000); -setTimeout(function () { +setTimeout(() => { box.scrollTo(0, box.scrollHeight) }, 1500); -document.addEventListener('DOMContentLoaded', function () { +document.addEventListener('DOMContentLoaded', () => { box.scrollTo(0, box.scrollHeight) }); diff --git a/files/assets/js/comments_v.js b/files/assets/js/comments_v.js index f1605d2c1..fcb7ee210 100644 --- a/files/assets/js/comments_v.js +++ b/files/assets/js/comments_v.js @@ -25,7 +25,7 @@ function report_commentModal(id, author) { reason_comment.focus() }, 500); - reportCommentButton.addEventListener('click', function() { + reportCommentButton.addEventListener('click', () => { this.innerHTML='Reporting comment'; postToast(this, `/report/comment/${id}`, @@ -86,7 +86,7 @@ function toggleEdit(id){ function delete_commentModal(t, id) { - document.getElementById("deleteCommentButton").addEventListener('click', function() { + document.getElementById("deleteCommentButton").addEventListener('click', () => { postToast(t, `/delete/comment/${id}`, { }, @@ -130,7 +130,7 @@ function post_reply(id){ const upload_prog = document.getElementById(`upload-prog-c_${id}`); xhr[0].upload.onprogress = (e) => {handleUploadProgress(e, upload_prog)}; - xhr[0].onload=function(){ + xhr[0].onload=() =>{ upload_prog.classList.add("d-none") let data @@ -186,7 +186,7 @@ function comment_edit(id){ const upload_prog = document.getElementById(`upload-prog-edit-c_${id}`); xhr[0].upload.onprogress = (e) => {handleUploadProgress(e, upload_prog)}; - xhr[0].onload=function(){ + xhr[0].onload=() =>{ upload_prog.classList.add("d-none") let data @@ -243,7 +243,7 @@ function post_comment(fullname, hide){ xhr.upload.onprogress = (e) => {handleUploadProgress(e, upload_prog)}; xhr.setRequestHeader('xhr', 'xhr'); - xhr.onload=function(){ + xhr.onload=() =>{ upload_prog.classList.add("d-none") let data @@ -306,7 +306,7 @@ function handle_action(type, cid, thing) { - xhr.onload=function(){ + xhr.onload=() =>{ let data try {data = JSON.parse(xhr.response)} catch(e) {console.log(e)} diff --git a/files/assets/js/core.js b/files/assets/js/core.js index e04d88c2c..412565457 100644 --- a/files/assets/js/core.js +++ b/files/assets/js/core.js @@ -48,7 +48,7 @@ function postToast(t, url, data, extraActionsOnSuccess, method="POST") { } } const xhr = createXhrWithFormKey(url, method, form); - xhr[0].onload = function() { + xhr[0].onload = () => { let result let message; let success = xhr[0].status >= 200 && xhr[0].status < 300; @@ -313,7 +313,7 @@ function sendFormXHR(form, extraActionsOnSuccess) { xhr.open("POST", actionPath); xhr.setRequestHeader('xhr', 'xhr'); - xhr.onload = function() { + xhr.onload = () => { if (xhr.status >= 200 && xhr.status < 300) { let data = JSON.parse(xhr.response); showToast(true, getMessageFromJsonData(true, data)); @@ -519,7 +519,7 @@ if (file_upload) { { const fileReader = new FileReader(); fileReader.readAsDataURL(file_upload.files[0]); - fileReader.addEventListener("load", function () { + fileReader.addEventListener("load", () => { document.getElementById('image-preview').setAttribute('src', this.result); document.getElementById('image-preview').classList.remove('d-none'); }); diff --git a/files/assets/js/delete_post_modal.js b/files/assets/js/delete_post_modal.js index 20176437e..7528d8101 100644 --- a/files/assets/js/delete_post_modal.js +++ b/files/assets/js/delete_post_modal.js @@ -1,5 +1,5 @@ function delete_postModal(t, id) { - document.getElementById("deletePostButton").addEventListener('click', function() { + document.getElementById("deletePostButton").addEventListener('click', () => { postToast(t, `/delete_post/${id}`, { }, diff --git a/files/assets/js/emoji_modal.js b/files/assets/js/emoji_modal.js index cf94c61ec..ba8832a76 100644 --- a/files/assets/js/emoji_modal.js +++ b/files/assets/js/emoji_modal.js @@ -295,7 +295,7 @@ function emojiAddToInput(event) // Sir, come out and drink your Chromium complaint web // I HATE CHROME. I HATE CHROME if(window.chrome !== undefined) - setTimeout(function(){ + setTimeout(() =>{ console.warn("Chrome detected, r-slured mode enabled."); // AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA @@ -524,7 +524,7 @@ function loadEmojis(inputTargetIDName) emojiInputTargetDOM = document.getElementById(inputTargetIDName); } -document.getElementById('emojiModal').addEventListener('shown.bs.modal', function () { +document.getElementById('emojiModal').addEventListener('shown.bs.modal', () => { focusSearchBar(emojiSearchBarDOM); setTimeout(() => { focusSearchBar(emojiSearchBarDOM); diff --git a/files/assets/js/gif_modal.js b/files/assets/js/gif_modal.js index 0a10b45b1..7e142da34 100644 --- a/files/assets/js/gif_modal.js +++ b/files/assets/js/gif_modal.js @@ -14,7 +14,7 @@ function insertGIF(url) { if (typeof checkForRequired === "function") checkForRequired(); } -document.getElementById('gifModal').addEventListener('shown.bs.modal', function () { +document.getElementById('gifModal').addEventListener('shown.bs.modal', () => { focusSearchBar(gifSearchBar); setTimeout(() => { focusSearchBar(gifSearchBar); diff --git a/files/assets/js/lottery.js b/files/assets/js/lottery.js index 7ffc7a1c8..ab5bb2f77 100644 --- a/files/assets/js/lottery.js +++ b/files/assets/js/lottery.js @@ -1,5 +1,5 @@ let purchaseQuantity = 1; -const lotteryOnReady = function () { +const lotteryOnReady = () => { checkLotteryStats(); // Show ticket being pulled. diff --git a/files/assets/js/mobile_navigation_bar.js b/files/assets/js/mobile_navigation_bar.js index 992f0b537..4c21b9d93 100644 --- a/files/assets/js/mobile_navigation_bar.js +++ b/files/assets/js/mobile_navigation_bar.js @@ -1,5 +1,5 @@ let prevScrollpos = window.pageYOffset; -window.onscroll = function () { +window.onscroll = () => { const currentScrollPos = window.pageYOffset; const topBar = document.getElementById("fixed-bar-mobile"); diff --git a/files/assets/js/more_comments.js b/files/assets/js/more_comments.js index e0f008b43..0cf92bb42 100644 --- a/files/assets/js/more_comments.js +++ b/files/assets/js/more_comments.js @@ -8,7 +8,7 @@ function more_comments(cid, sort) { const xhr = new XMLHttpRequest(); xhr.open("get", `/more_comments/${cid}`); xhr.setRequestHeader('xhr', 'xhr'); - xhr.onload=function(){ + xhr.onload=() =>{ if (xhr.status==200) { let e = document.getElementById(`replies-of-c_${cid}`) e.innerHTML = xhr.response.replace(/data-src/g, 'src').replace(/data-cfsrc/g, 'src').replace(/style="display:none;visibility:hidden;"/g, '').replace(/data-nonce=".*?"/g, `data-nonce="${nonce}"`); diff --git a/files/assets/js/register_service_worker.js b/files/assets/js/register_service_worker.js index 95db4c377..8113c90b3 100644 --- a/files/assets/js/register_service_worker.js +++ b/files/assets/js/register_service_worker.js @@ -49,7 +49,7 @@ function subscribeUser(swRegistration, applicationServerPublicKey, apiEndpoint) throw new Error('Bad response from server.'); } }) - .catch(function() { + .catch(() => { }); } @@ -62,7 +62,7 @@ function registerServiceWorker(serviceWorkerUrl, applicationServerPublicKey, api swRegistration = swReg; }) - .catch(function() { + .catch(() => { }); } else { } diff --git a/files/assets/js/report_post_modal.js b/files/assets/js/report_post_modal.js index c60ecd71f..7ea97af90 100644 --- a/files/assets/js/report_post_modal.js +++ b/files/assets/js/report_post_modal.js @@ -22,7 +22,7 @@ function report_postModal(id) { reason_post.focus() }, 500); - reportPostButton.addEventListener('click', function() { + reportPostButton.addEventListener('click', () => { this.innerHTML='Reporting post'; this.disabled = true; @@ -35,7 +35,7 @@ function report_postModal(id) { form.append("formkey", formkey()); form.append("reason", reason_post.value); - xhr.onload = function() { + xhr.onload = () => { let data try {data = JSON.parse(xhr.response)} catch(e) {console.log(e)} @@ -43,7 +43,7 @@ function report_postModal(id) { showToast(success, getMessageFromJsonData(success, data)); }; - xhr.onerror=function(){alert(errortext)}; + xhr.onerror=() =>{alert(errortext)}; xhr.send(form); }) }; diff --git a/files/assets/js/settings_profile.js b/files/assets/js/settings_profile.js index 8017f1a79..da66f22fd 100644 --- a/files/assets/js/settings_profile.js +++ b/files/assets/js/settings_profile.js @@ -4,7 +4,7 @@ function post(url) { xhr.setRequestHeader('xhr', 'xhr'); const form = new FormData() form.append("formkey", formkey()); - xhr.onload = function() {location.reload();}; + xhr.onload = () => {location.reload();}; xhr.send(form); }; @@ -103,9 +103,9 @@ const sr_toggle = document.getElementById("slurreplacer"); const sr_link = document.getElementById('slurreplacer-perma-link'); const pr_toggle = document.getElementById("profanityreplacer"); const pr_link = document.getElementById('profanityreplacer-perma-link'); -sr_toggle.addEventListener('change', function () { +sr_toggle.addEventListener('change', () => { sr_link.hidden = !sr_toggle.checked; }); -pr_toggle.addEventListener('change', function () { +pr_toggle.addEventListener('change', () => { pr_link.hidden = !pr_toggle.checked; }); diff --git a/files/assets/js/settings_security.js b/files/assets/js/settings_security.js index 7a32a3e6a..ef136524b 100644 --- a/files/assets/js/settings_security.js +++ b/files/assets/js/settings_security.js @@ -1,4 +1,4 @@ -document.getElementById('new_email').addEventListener('input', function () { +document.getElementById('new_email').addEventListener('input', () => { document.getElementById("email-password").classList.remove("d-none"); document.getElementById("email-password-label").classList.remove("d-none"); document.getElementById("emailpasswordRequired").classList.remove("d-none"); @@ -20,7 +20,7 @@ function block_user() { f=new FormData(); f.append("username", username); f.append("formkey", formkey()); - xhr.onload=function(){ + xhr.onload=() =>{ if (xhr.status<300) { location.reload(); } diff --git a/files/assets/js/signup.js b/files/assets/js/signup.js index bb10053af..9e8b34e49 100644 --- a/files/assets/js/signup.js +++ b/files/assets/js/signup.js @@ -1,4 +1,4 @@ -document.getElementById('password-register').addEventListener('input', function () { +document.getElementById('password-register').addEventListener('input', () => { const charCount = document.getElementById("password-register").value; const id = document.getElementById("passwordHelpRegister"); @@ -13,7 +13,7 @@ document.getElementById('password-register').addEventListener('input', function } }); -document.getElementById('username-register').addEventListener('input', function () { +document.getElementById('username-register').addEventListener('input', () => { const userName = document.getElementById("username-register").value; const id = document.getElementById("usernameHelpRegister"); diff --git a/files/assets/js/submit.js b/files/assets/js/submit.js index 64365a895..e6e6b8d27 100644 --- a/files/assets/js/submit.js +++ b/files/assets/js/submit.js @@ -94,7 +94,7 @@ function autoSuggestTitle() { const x = new XMLHttpRequest(); x.withCredentials=true; - x.onreadystatechange = function() { + x.onreadystatechange = () => { if (x.readyState == 4 && x.status == 200 && !titleField.value) { title=JSON.parse(x.responseText)["title"]; @@ -133,7 +133,7 @@ function checkRepost() { const form = new FormData() form.append("url", url); - xhr.onload=function(){ + xhr.onload=() =>{ try {data = JSON.parse(xhr.response)} catch(e) {console.log(e)} @@ -176,7 +176,7 @@ function submit(form) { xhr.setRequestHeader('xhr', 'xhr'); - xhr.onload = function() { + xhr.onload = () => { upload_prog.classList.add("d-none") if (xhr.status >= 200 && xhr.status < 300) { diff --git a/files/assets/js/view_more.js b/files/assets/js/view_more.js index e7fca62c2..27ef9d28f 100644 --- a/files/assets/js/view_more.js +++ b/files/assets/js/view_more.js @@ -7,7 +7,7 @@ function view_more(t, pid, sort, offset) { ids = t.dataset.ids.toString().replace(/[\[\] ]/g, '') xhr.open("get", `/view_more/${pid}/${sort}/${offset}?ids=${ids}`); xhr.setRequestHeader('xhr', 'xhr'); - xhr.onload=function(){ + xhr.onload=() =>{ if (xhr.status==200) { let e = document.getElementById(`view_more-${offset}`); e.innerHTML = xhr.response.replace(/data-src/g, 'src').replace(/data-cfsrc/g, 'src').replace(/style="display:none;visibility:hidden;"/g, '').replace(/data-nonce=".*?"/g, `data-nonce="${nonce}"`);