use addEventListener instead of onclick
parent
47fdc8e870
commit
010f424756
|
@ -176,7 +176,7 @@ for (const element of data_url) {
|
||||||
console.log("Nonce check failed!")
|
console.log("Nonce check failed!")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
element.onclick = () => {
|
element.addEventListener('click', () => {
|
||||||
document.getElementById('giveaward').dataset.action = element.dataset.url
|
document.getElementById('giveaward').dataset.action = element.dataset.url
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ for (const element of onclick_submit) {
|
||||||
console.log("Nonce check failed!")
|
console.log("Nonce check failed!")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
element.onclick = () => {element.form.submit()};
|
element.addEventListener('click', () => {element.form.submit()});
|
||||||
}
|
}
|
||||||
|
|
||||||
const onchange_submit = document.querySelectorAll('[onchange_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')
|
const reload_page = document.getElementById('reload_page')
|
||||||
if (reload_page) {
|
if (reload_page) {
|
||||||
reload_page.onclick = () => {location.reload()};
|
reload_page.addEventListener('click', () => {location.reload()});
|
||||||
}
|
}
|
||||||
|
|
||||||
const TH = document.getElementsByTagName('th')
|
const TH = document.getElementsByTagName('th')
|
||||||
for (const element of TH) {
|
for (const element of TH) {
|
||||||
element.onclick = () => {sort_table(element)};
|
element.addEventListener('click', () => {sort_table(element)});
|
||||||
}
|
}
|
||||||
|
|
||||||
const toggleelement = document.querySelectorAll('[data-toggleelement]');
|
const toggleelement = document.querySelectorAll('[data-toggleelement]');
|
||||||
for (const element of toggleelement) {
|
for (const element of toggleelement) {
|
||||||
element.onclick = () => {
|
element.addEventListener('click', () => {
|
||||||
document.getElementById(element.dataset.toggleelement).classList.toggle(element.dataset.toggleattr);
|
document.getElementById(element.dataset.toggleelement).classList.toggle(element.dataset.toggleattr);
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function register_new_elements(e) {
|
function register_new_elements(e) {
|
||||||
const showmores = document.getElementsByClassName('showmore')
|
const showmores = document.getElementsByClassName('showmore')
|
||||||
for (const element of showmores) {
|
for (const element of showmores) {
|
||||||
element.onclick = () => {showmore(element)};
|
element.addEventListener('click', () => {showmore(element)});
|
||||||
}
|
}
|
||||||
|
|
||||||
const onclick = e.querySelectorAll('[data-onclick]');
|
const onclick = e.querySelectorAll('[data-onclick]');
|
||||||
for (const element of onclick) {
|
for (const element of onclick) {
|
||||||
element.onclick = () => {execute(element, 'onclick')};
|
element.addEventListener('click', () => {execute(element, 'onclick')});
|
||||||
}
|
}
|
||||||
|
|
||||||
const oninput = e.querySelectorAll('[data-oninput]');
|
const oninput = e.querySelectorAll('[data-oninput]');
|
||||||
|
@ -133,12 +133,12 @@ function register_new_elements(e) {
|
||||||
|
|
||||||
const popover_triggers = document.getElementsByClassName('user-name');
|
const popover_triggers = document.getElementsByClassName('user-name');
|
||||||
for (const element of popover_triggers) {
|
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^="![]("]');
|
const expandable = document.querySelectorAll('.in-comment-image, img[alt^="![]("]');
|
||||||
for (const element of expandable) {
|
for (const element of expandable) {
|
||||||
element.onclick = () => {expandImage()};
|
element.addEventListener('click', () => {expandImage()});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ function report_commentModal(id, author) {
|
||||||
reason_comment.focus()
|
reason_comment.focus()
|
||||||
}, 500);
|
}, 500);
|
||||||
|
|
||||||
reportCommentButton.onclick = function() {
|
reportCommentButton.addEventListener('click', function() {
|
||||||
this.innerHTML='Reporting comment';
|
this.innerHTML='Reporting comment';
|
||||||
|
|
||||||
postToast(this, `/report/comment/${id}`,
|
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
|
// Returns the selection text based on the range with the HTML
|
||||||
|
@ -87,7 +86,7 @@ function toggleEdit(id){
|
||||||
|
|
||||||
|
|
||||||
function delete_commentModal(t, id) {
|
function delete_commentModal(t, id) {
|
||||||
document.getElementById("deleteCommentButton").onclick = function() {
|
document.getElementById("deleteCommentButton").addEventListener('click', function() {
|
||||||
postToast(t, `/delete/comment/${id}`,
|
postToast(t, `/delete/comment/${id}`,
|
||||||
{
|
{
|
||||||
},
|
},
|
||||||
|
@ -107,7 +106,7 @@ function delete_commentModal(t, id) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function post_reply(id){
|
function post_reply(id){
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
function delete_postModal(t, id) {
|
function delete_postModal(t, id) {
|
||||||
document.getElementById("deletePostButton").onclick = function() {
|
document.getElementById("deletePostButton").addEventListener('click', function() {
|
||||||
postToast(t, `/delete_post/${id}`,
|
postToast(t, `/delete_post/${id}`,
|
||||||
{
|
{
|
||||||
},
|
},
|
||||||
|
@ -19,5 +19,5 @@ function delete_postModal(t, id) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -443,13 +443,13 @@ function populate_speed_emoji_modal(results, textbox)
|
||||||
if (current_word.includes("#")) result = `#${result}`
|
if (current_word.includes("#")) result = `#${result}`
|
||||||
if (current_word.includes("!")) result = `!${result}`
|
if (current_word.includes("!")) result = `!${result}`
|
||||||
|
|
||||||
emoji_option.onclick = (e) => {
|
emoji_option.addEventListener('click', () => {
|
||||||
selecting = false;
|
selecting = false;
|
||||||
speed_carot_modal.style.display = "none";
|
speed_carot_modal.style.display = "none";
|
||||||
textbox.value = textbox.value.replace(new RegExp(current_word+"(?=\\s|$)", "g"), `:${result}:`)
|
textbox.value = textbox.value.replace(new RegExp(current_word+"(?=\\s|$)", "g"), `:${result}:`)
|
||||||
textbox.focus()
|
textbox.focus()
|
||||||
markdown(textbox)
|
markdown(textbox)
|
||||||
};
|
});
|
||||||
// Pack
|
// Pack
|
||||||
emoji_option.appendChild(emoji_option_img);
|
emoji_option.appendChild(emoji_option_img);
|
||||||
emoji_option.appendChild(emoji_option_text);
|
emoji_option.appendChild(emoji_option_text);
|
||||||
|
|
|
@ -106,7 +106,7 @@ async function getGifs(form) {
|
||||||
|
|
||||||
const overlays = document.getElementsByClassName('gif-cat-overlay')
|
const overlays = document.getElementsByClassName('gif-cat-overlay')
|
||||||
for (const element of overlays) {
|
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')
|
const giphy = document.getElementsByClassName('giphy')
|
||||||
for (const element of giphy) {
|
for (const element of giphy) {
|
||||||
element.onclick = () => {insertGIF(element.src)};
|
element.addEventListener('click', () => {insertGIF(element.src)});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -2,7 +2,7 @@ if (!window.matchMedia('(display-mode: minimal-ui)')['matches']) {
|
||||||
if (window.innerWidth <= 737) {
|
if (window.innerWidth <= 737) {
|
||||||
const tt = bootstrap.Tooltip.getOrCreateInstance(document.getElementById('mobile-prompt'))
|
const tt = bootstrap.Tooltip.getOrCreateInstance(document.getElementById('mobile-prompt'))
|
||||||
tt.show()
|
tt.show()
|
||||||
document.getElementsByClassName('tooltip')[0].onclick = function(e) {
|
document.getElementsByClassName('tooltip')[0].addEventListener('click', function(e) {
|
||||||
tt.hide()
|
tt.hide()
|
||||||
const xhr = new XMLHttpRequest();
|
const xhr = new XMLHttpRequest();
|
||||||
xhr.withCredentials=true;
|
xhr.withCredentials=true;
|
||||||
|
@ -11,6 +11,6 @@ if (!window.matchMedia('(display-mode: minimal-ui)')['matches']) {
|
||||||
xhr.send();
|
xhr.send();
|
||||||
if (!e.target.classList.contains('dismiss-beg'))
|
if (!e.target.classList.contains('dismiss-beg'))
|
||||||
location.href = "/app"
|
location.href = "/app"
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
const reload_page = document.getElementById('reload_page')
|
const reload_page = document.getElementById('reload_page')
|
||||||
if (reload_page)
|
if (reload_page)
|
||||||
reload_page.onclick = () => {location.reload()};
|
reload_page.addEventListener('click', () => {location.reload()});
|
||||||
|
|
|
@ -22,7 +22,7 @@ function report_postModal(id) {
|
||||||
reason_post.focus()
|
reason_post.focus()
|
||||||
}, 500);
|
}, 500);
|
||||||
|
|
||||||
reportPostButton.onclick = function() {
|
reportPostButton.addEventListener('click', function() {
|
||||||
|
|
||||||
this.innerHTML='Reporting post';
|
this.innerHTML='Reporting post';
|
||||||
this.disabled = true;
|
this.disabled = true;
|
||||||
|
@ -45,6 +45,5 @@ function report_postModal(id) {
|
||||||
|
|
||||||
xhr.onerror=function(){alert(errortext)};
|
xhr.onerror=function(){alert(errortext)};
|
||||||
xhr.send(form);
|
xhr.send(form);
|
||||||
|
})
|
||||||
}
|
};
|
||||||
};
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ if (!location.href.includes("?context")) {
|
||||||
|
|
||||||
const fake_textarea = document.querySelector('[data-href]')
|
const fake_textarea = document.querySelector('[data-href]')
|
||||||
if (fake_textarea) {
|
if (fake_textarea) {
|
||||||
fake_textarea.onclick = () => {
|
fake_textarea.addEventListener('click', () => {
|
||||||
location.href = fake_textarea.dataset.href;
|
location.href = fake_textarea.dataset.href;
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue