From 1f5869fcfe8c537d223b750754025cb2937d4bad Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 7 Mar 2018 14:53:23 +0300 Subject: drop replies tree --- juick-www/src/main/static/scripts.js | 60 +----------------------------------- 1 file changed, 1 insertion(+), 59 deletions(-) (limited to 'juick-www/src/main/static/scripts.js') diff --git a/juick-www/src/main/static/scripts.js b/juick-www/src/main/static/scripts.js index 588e4fdb..c6293266 100644 --- a/juick-www/src/main/static/scripts.js +++ b/juick-www/src/main/static/scripts.js @@ -187,11 +187,6 @@ function wsShutdown() { } } -function isTreeMode() { - // relies on UserThread.printReplies implementation TODO keep this in cookie or something - return document.querySelector('.title2-right > a').href.match(/\?view=(\w+)/)[1] == 'list'; -} - function wsIncomingReply(msg) { let content = document.getElementById('content'); if (!content) { return; } @@ -234,15 +229,7 @@ function wsIncomingReply(msg) { killy.embedLinksToX(li.querySelector('.msg-cont'), '.msg-links', '.msg-txt a'); - if (isTreeMode() && (msg.replyto > 0)) { - let p = document.getElementById(msg.replyto); - let m = parseInt(p.style.marginLeft) + 20; - while (p.nextElementSibling && (parseInt(p.nextElementSibling.style.marginLeft) >= m)) { p = p.nextElementSibling; } - li.style.marginLeft = m + 'px'; - p.parentNode.insertBefore(li, p.nextSibling); - } else { - document.getElementById('replies').appendChild(li); - } + document.getElementById('replies').appendChild(li); updateRepliesCounter(); } @@ -309,29 +296,6 @@ function newMessage(evt) { } } -function showMoreReplies(el, id) { - var foldedReplies = el.closest('li').querySelector('.msg-comments'); - if (!foldedReplies) { return; } - foldedReplies.style.display = 'none'; - - var replies = document.querySelectorAll('#replies>li'), - flagshow = 0, - i = 0; - for (; i < replies.length; i += 1) { - if (flagshow == 1) { - if (replies[i].style.display == 'none') { - replies[i].style.display = 'block'; - } else { - break; - } - } - if (replies[i].id == id) { - flagshow = 1; - } - } - return false; -} - function showCommentForm(mid, rid) { let reply = document.getElementById(rid); let formTarget = reply.querySelector('div.msg-cont .msg-comment-target'); @@ -422,19 +386,6 @@ function attachMessagePhoto(div) { } } -function unfoldReply() { - var anchor = window.location.hash.substring(1); - if ((0 + anchor) > 0) { - var el = document.getElementById(anchor); - if (!el) { return; } - while (el.style.display === 'none') { - el = el.previousElementSibling; - } - showMoreReplies(el, el.getAttribute('id')); - window.location.replace(window.location.hash); - } -} - function showMessageLinksDialog(mid, rid) { let hlink = window.location.protocol + '//juick.com/' + mid; let mlink = '#' + mid; @@ -667,13 +618,6 @@ ready(function () { var pageMID = content.getAttribute('data-mid'); if (pageMID > 0) { document.querySelectorAll('li.msg').forEach(li => { - let showMoreBtn = li.querySelector('.msg-comments'); - if (showMoreBtn) { - showMoreBtn.addEventListener('click', function (e) { - showMoreReplies(e.target, li.id); - e.preventDefault(); - }); - } let showReplyFormBtn = li.querySelector('.a-thread-comment'); if (showReplyFormBtn) { showReplyFormBtn.addEventListener('click', function (e) { @@ -784,9 +728,7 @@ ready(function () { article.classList.add('nsfw'); } }); - unfoldReply(); initWS(); - window.addEventListener('hashchange', unfoldReply); window.addEventListener('pagehide', wsShutdown); -- cgit v1.2.3