diff options
Diffstat (limited to 'src/main/assets/scripts.js')
-rw-r--r-- | src/main/assets/scripts.js | 52 |
1 files changed, 23 insertions, 29 deletions
diff --git a/src/main/assets/scripts.js b/src/main/assets/scripts.js index 677efeac..2c56fe7f 100644 --- a/src/main/assets/scripts.js +++ b/src/main/assets/scripts.js @@ -14,12 +14,6 @@ if (!('remove' in Element.prototype)) { // Firefox <23 }; } -NodeList.prototype.forEach = Array.prototype.forEach; -HTMLCollection.prototype.forEach = Array.prototype.forEach; - -NodeList.prototype.filter = Array.prototype.filter; -HTMLCollection.prototype.filter = Array.prototype.filter; - Element.prototype.selectText = function() { let d = document; if (d.body.createTextRange) { @@ -227,7 +221,7 @@ function nextReply() { } function updateRepliesCounter() { - var replies = document.querySelectorAll('#replies>li.reply-new').length; + var replies = Array.from(document.querySelectorAll('#replies>li.reply-new')).length; var wsthread = document.getElementById('wsthread'); if (replies) { wsthread.textContent = replies; @@ -259,7 +253,7 @@ function closeDialogListener(ev) { } function newMessage(evt) { - document.querySelectorAll('#newmessage .dialogtxt').forEach(t => { + Array.from(document.querySelectorAll('#newmessage .dialogtxt')).forEach(t => { t.remove(); }); if (document.querySelector('#newmessage textarea').value.length == 0 @@ -642,7 +636,7 @@ function ready(fn) { } ready(function() { - document.querySelectorAll('textarea').forEach((ta) => { + Array.from(document.querySelectorAll('textarea')).forEach((ta) => { autosize(ta); }); svg4everybody(); @@ -653,13 +647,13 @@ ready(function() { e.target.removeEventListener('click', insertPMButtons); e.preventDefault(); }; - document.querySelectorAll('textarea.replypm').forEach(function(e) { + Array.from(document.querySelectorAll('textarea.replypm')).forEach(function(e) { e.addEventListener('click', insertPMButtons); e.addEventListener('keypress', function(e) { postformListener(e.target, e); }); }); - document.querySelectorAll('#postmsg textarea').forEach(function(e) { + Array.from(document.querySelectorAll('#postmsg textarea')).forEach(function(e) { e.addEventListener('keypress', function(e) { postformListener(e.target, e); }); @@ -669,7 +663,7 @@ ready(function() { if (content) { var pageMID = content.getAttribute('data-mid'); if (pageMID > 0) { - document.querySelectorAll('li.msg').forEach(li => { + Array.from(document.querySelectorAll('li.msg')).forEach(li => { let showReplyFormBtn = li.querySelector('.a-thread-comment'); if (showReplyFormBtn) { showReplyFormBtn.addEventListener('click', function(e) { @@ -694,7 +688,7 @@ ready(function() { var postmsg = document.getElementById('postmsg'); if (postmsg) { - document.querySelectorAll('a').filter(t => t.href.indexOf('?') >= 0).forEach(t => { + Array.from(document.querySelectorAll('a')).filter(t => t.href.indexOf('?') >= 0).forEach(t => { t.addEventListener('click', e => { let params = new URLSearchParams(t.href.slice(t.href.indexOf('?') + 1)); if (params.has('tag')) { @@ -728,7 +722,7 @@ ready(function() { e.preventDefault(); }); } - document.querySelectorAll('.pmmsg').forEach(pmmsg => { + Array.from(document.querySelectorAll('.pmmsg')).forEach(pmmsg => { pmmsg.addEventListener('submit', e => { let formData = new FormData(pmmsg); fetch('/api/pm' + '?hash=' + document.getElementById('body').getAttribute('data-hash'), { @@ -755,7 +749,7 @@ ready(function() { }); }); - document.querySelectorAll('.msg-menu').forEach(function(el) { + Array.from(document.querySelectorAll('.msg-menu')).forEach(function(el) { el.addEventListener('click', function(e) { var reply = e.target.closest('li'); var rid = reply ? parseInt(reply.id) : 0; @@ -765,7 +759,7 @@ ready(function() { e.preventDefault(); }); }); - document.querySelectorAll('.l .a-privacy').forEach(function(e) { + Array.from(document.querySelectorAll('.l .a-privacy')).forEach(function(e) { e.addEventListener('click', function(e) { setPrivacy( e.target, @@ -773,7 +767,7 @@ ready(function() { e.preventDefault(); }); }); - document.querySelectorAll('.ir a[data-fname], .msg-media a[data-fname]').forEach(function(el) { + Array.from(document.querySelectorAll('.ir a[data-fname], .msg-media a[data-fname]')).forEach(function(el) { el.addEventListener('click', function(e) { let fname = e.target.closest('[data-fname]').getAttribute('data-fname'); if (!showPhotoDialog(fname)) { @@ -781,7 +775,7 @@ ready(function() { } }); }); - document.querySelectorAll('.social a').forEach(function(e) { + Array.from(document.querySelectorAll('.social a')).forEach(function(e) { e.addEventListener('click', function(e) { openSocialWindow(e.target); e.preventDefault(); @@ -794,7 +788,7 @@ ready(function() { }); } - document.querySelectorAll('.l .a-like').forEach(function(e) { + Array.from(document.querySelectorAll('.l .a-like')).forEach(function(e) { e.addEventListener('click', function(e) { likeMessage( e.target, @@ -802,7 +796,7 @@ ready(function() { e.preventDefault(); }); }); - document.querySelectorAll('.l .a-sub').forEach(function(e) { + Array.from(document.querySelectorAll('.l .a-sub')).forEach(function(e) { e.addEventListener('click', function(e) { subscribeMessage( e.target, @@ -810,7 +804,7 @@ ready(function() { e.preventDefault(); }); }); - document.querySelectorAll('.a-login').forEach(function(el) { + Array.from(document.querySelectorAll('.a-login')).forEach(function(el) { el.addEventListener('click', function(e) { openDialogLogin(); e.preventDefault(); @@ -819,18 +813,18 @@ ready(function() { var unfoldall = document.getElementById('unfoldall'); if (unfoldall) { unfoldall.addEventListener('click', function(e) { - document.querySelectorAll('#replies>li').forEach(function(e) { + Array.from(document.querySelectorAll('#replies>li')).forEach(function(e) { e.style.display = 'block'; }); - document.querySelectorAll('#replies .msg-comments').forEach(function(e) { + Array.from(document.querySelectorAll('#replies .msg-comments')).forEach(function(e) { e.style.display = 'none'; }); e.preventDefault(); }); } - document.querySelectorAll('article').forEach(function(article) { + Array.from(document.querySelectorAll('article')).forEach(function(article) { if (Array.prototype.some.call( - article.querySelectorAll('.msg-tags a'), + Array.from(article.querySelectorAll('.msg-tags a')), function(a) { return a.textContent === 'NSFW'; } @@ -838,12 +832,12 @@ ready(function() { article.classList.add('nsfw'); } }); - document.querySelectorAll('[data-uri]').forEach(el => { + Array.from(document.querySelectorAll('[data-uri]')).forEach(el => { let dataUri = el.getAttribute('data-uri'); if (dataUri) { setTimeout(() => fetchUserUri(dataUri, user => { let header = el.closest('.msg-header'); - header.querySelectorAll('.a-username').forEach(a => { + Array.from(header.querySelectorAll('.a-username')).forEach(a => { a.setAttribute('href', user.uri); let img = a.querySelector('img'); if (img && user.avatar) { @@ -859,7 +853,7 @@ ready(function() { }), 100); } }); - document.querySelectorAll('[data-user-uri]').forEach(el => { + Array.from(document.querySelectorAll('[data-user-uri]')).forEach(el => { let dataUri = el.getAttribute('href'); if (dataUri) { setTimeout(() => fetchUserUri(dataUri, user => { @@ -872,7 +866,7 @@ ready(function() { } }); let location = window.location.href; - document.querySelectorAll('#header_wrapper a').forEach(el => { + Array.from(document.querySelectorAll('#header_wrapper a')).forEach(el => { if (el.href === location) { el.classList.add('active'); el.setAttribute('disabled', 'disabled'); |