diff --git a/files/assets/js/award_modal.js b/files/assets/js/award_modal.js index 88e975c8a..d3d13fd6a 100644 --- a/files/assets/js/award_modal.js +++ b/files/assets/js/award_modal.js @@ -176,7 +176,7 @@ for (const element of data_url) { console.log("Nonce check failed!") continue } - element.onclick = () => { + element.addEventListener('click', () => { document.getElementById('giveaward').dataset.action = element.dataset.url - }; + }); } diff --git a/files/assets/js/bottom.js b/files/assets/js/bottom.js index 49cae19f9..e928e66bf 100644 --- a/files/assets/js/bottom.js +++ b/files/assets/js/bottom.js @@ -40,7 +40,7 @@ for (const element of onclick_submit) { console.log("Nonce check failed!") continue } - element.onclick = () => {element.form.submit()}; + element.addEventListener('click', () => {element.form.submit()}); } const onchange_submit = document.querySelectorAll('[onchange_submit]'); @@ -90,30 +90,30 @@ for (const element of setting_selects) { const reload_page = document.getElementById('reload_page') if (reload_page) { - reload_page.onclick = () => {location.reload()}; + reload_page.addEventListener('click', () => {location.reload()}); } const TH = document.getElementsByTagName('th') for (const element of TH) { - element.onclick = () => {sort_table(element)}; + element.addEventListener('click', () => {sort_table(element)}); } const toggleelement = document.querySelectorAll('[data-toggleelement]'); for (const element of toggleelement) { - element.onclick = () => { + element.addEventListener('click', () => { document.getElementById(element.dataset.toggleelement).classList.toggle(element.dataset.toggleattr); - }; + }); } function register_new_elements(e) { const showmores = document.getElementsByClassName('showmore') for (const element of showmores) { - element.onclick = () => {showmore(element)}; + element.addEventListener('click', () => {showmore(element)}); } const onclick = e.querySelectorAll('[data-onclick]'); for (const element of onclick) { - element.onclick = () => {execute(element, 'onclick')}; + element.addEventListener('click', () => {execute(element, 'onclick')}); } const oninput = e.querySelectorAll('[data-oninput]'); @@ -133,12 +133,12 @@ function register_new_elements(e) { const popover_triggers = document.getElementsByClassName('user-name'); for (const element of popover_triggers) { - element.onclick = (e) => {popclick(e)}; + element.addEventListener('click', (e) => {popclick(e)}); } const expandable = document.querySelectorAll('.in-comment-image, img[alt^="![]("]'); for (const element of expandable) { - element.onclick = () => {expandImage()}; + element.addEventListener('click', () => {expandImage()}); } } diff --git a/files/assets/js/comments_v.js b/files/assets/js/comments_v.js index cca075a37..e9cf04d19 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.onclick = function() { + reportCommentButton.addEventListener('click', function() { this.innerHTML='Reporting comment'; postToast(this, `/report/comment/${id}`, @@ -34,8 +34,7 @@ function report_commentModal(id, author) { }, () => {} ); - } - + }) }; // Returns the selection text based on the range with the HTML @@ -87,7 +86,7 @@ function toggleEdit(id){ function delete_commentModal(t, id) { - document.getElementById("deleteCommentButton").onclick = function() { + document.getElementById("deleteCommentButton").addEventListener('click', function() { postToast(t, `/delete/comment/${id}`, { }, @@ -107,7 +106,7 @@ function delete_commentModal(t, id) { } } ); - }; + }); } function post_reply(id){ diff --git a/files/assets/js/delete_post_modal.js b/files/assets/js/delete_post_modal.js index 6b5d1e215..20176437e 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").onclick = function() { + document.getElementById("deletePostButton").addEventListener('click', function() { postToast(t, `/delete_post/${id}`, { }, @@ -19,5 +19,5 @@ function delete_postModal(t, id) { } } ); - }; + }); } diff --git a/files/assets/js/emoji_modal.js b/files/assets/js/emoji_modal.js index 869393bca..4c6ac8795 100644 --- a/files/assets/js/emoji_modal.js +++ b/files/assets/js/emoji_modal.js @@ -443,13 +443,13 @@ function populate_speed_emoji_modal(results, textbox) if (current_word.includes("#")) result = `#${result}` if (current_word.includes("!")) result = `!${result}` - emoji_option.onclick = (e) => { + emoji_option.addEventListener('click', () => { selecting = false; speed_carot_modal.style.display = "none"; textbox.value = textbox.value.replace(new RegExp(current_word+"(?=\\s|$)", "g"), `:${result}:`) textbox.focus() markdown(textbox) - }; + }); // Pack emoji_option.appendChild(emoji_option_img); emoji_option.appendChild(emoji_option_text); diff --git a/files/assets/js/gif_modal.js b/files/assets/js/gif_modal.js index 81eb57f05..50613ad92 100644 --- a/files/assets/js/gif_modal.js +++ b/files/assets/js/gif_modal.js @@ -106,7 +106,7 @@ async function getGifs(form) { const overlays = document.getElementsByClassName('gif-cat-overlay') for (const element of overlays) { - element.onclick = () => {searchGifs(element.firstElementChild.innerHTML)}; + element.addEventListener('click', () => {searchGifs(element.firstElementChild.innerHTML)}); } } @@ -131,7 +131,7 @@ async function searchGifs(searchTerm) { const giphy = document.getElementsByClassName('giphy') for (const element of giphy) { - element.onclick = () => {insertGIF(element.src)}; + element.addEventListener('click', () => {insertGIF(element.src)}); } } else { diff --git a/files/assets/js/mobile_prompt.js b/files/assets/js/mobile_prompt.js index 68dedf90e..7d77539bc 100644 --- a/files/assets/js/mobile_prompt.js +++ b/files/assets/js/mobile_prompt.js @@ -2,7 +2,7 @@ if (!window.matchMedia('(display-mode: minimal-ui)')['matches']) { if (window.innerWidth <= 737) { const tt = bootstrap.Tooltip.getOrCreateInstance(document.getElementById('mobile-prompt')) tt.show() - document.getElementsByClassName('tooltip')[0].onclick = function(e) { + document.getElementsByClassName('tooltip')[0].addEventListener('click', function(e) { tt.hide() const xhr = new XMLHttpRequest(); xhr.withCredentials=true; @@ -11,6 +11,6 @@ if (!window.matchMedia('(display-mode: minimal-ui)')['matches']) { xhr.send(); if (!e.target.classList.contains('dismiss-beg')) location.href = "/app" - } + }) } } diff --git a/files/assets/js/offline.js b/files/assets/js/offline.js index ae60f803a..bf0f60dd3 100644 --- a/files/assets/js/offline.js +++ b/files/assets/js/offline.js @@ -1,3 +1,3 @@ const reload_page = document.getElementById('reload_page') if (reload_page) - reload_page.onclick = () => {location.reload()}; + reload_page.addEventListener('click', () => {location.reload()}); diff --git a/files/assets/js/report_post_modal.js b/files/assets/js/report_post_modal.js index ebb51bff3..c60ecd71f 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.onclick = function() { + reportPostButton.addEventListener('click', function() { this.innerHTML='Reporting post'; this.disabled = true; @@ -45,6 +45,5 @@ function report_postModal(id) { xhr.onerror=function(){alert(errortext)}; xhr.send(form); - - } -}; \ No newline at end of file + }) +}; diff --git a/files/assets/js/submission.js b/files/assets/js/submission.js index 1b5dd434f..20a0b46d8 100644 --- a/files/assets/js/submission.js +++ b/files/assets/js/submission.js @@ -28,7 +28,7 @@ if (!location.href.includes("?context")) { const fake_textarea = document.querySelector('[data-href]') if (fake_textarea) { - fake_textarea.onclick = () => { + fake_textarea.addEventListener('click', () => { location.href = fake_textarea.dataset.href; - }; + }); }