|
|
@ -3,9 +3,12 @@ window.addEventListener('DOMContentLoaded', () => { |
|
|
|
let loading = {}; |
|
|
|
let loading = {}; |
|
|
|
|
|
|
|
|
|
|
|
const hideOmitted = (e) => { |
|
|
|
const hideOmitted = (e) => { |
|
|
|
|
|
|
|
e.target.nextSibling.style.display = 'unset'; |
|
|
|
const thread = e.target.closest('.thread'); |
|
|
|
const thread = e.target.closest('.thread'); |
|
|
|
let replies = Array.from(thread.querySelectorAll('.post-container')); |
|
|
|
let replies = Array.from(thread.querySelectorAll('.post-container:not(.op)')); |
|
|
|
replies = replies.slice(1, replies.length-5); |
|
|
|
if (e.target.dataset.shown > 0) { |
|
|
|
|
|
|
|
replies = replies.slice(0, -parseInt(e.target.dataset.shown)); |
|
|
|
|
|
|
|
} |
|
|
|
replies.forEach(r => { |
|
|
|
replies.forEach(r => { |
|
|
|
r.previousSibling.remove(); |
|
|
|
r.previousSibling.remove(); |
|
|
|
r.remove(); |
|
|
|
r.remove(); |
|
|
@ -18,16 +21,17 @@ window.addEventListener('DOMContentLoaded', () => { |
|
|
|
const threadId = e.target.dataset.thread; |
|
|
|
const threadId = e.target.dataset.thread; |
|
|
|
const board = e.target.dataset.board; |
|
|
|
const board = e.target.dataset.board; |
|
|
|
const parentPost = e.target.closest('.post-container'); |
|
|
|
const parentPost = e.target.closest('.post-container'); |
|
|
|
const firstPreviewReply = parentPost.nextSibling.nextSibling; //the first preview reply
|
|
|
|
const firstPreviewReply = parentPost.nextSibling && parentPost.nextSibling.nextSibling; //the first preview reply
|
|
|
|
const jsonPath = `/${board}/thread/${threadId}.json`; |
|
|
|
const jsonPath = `/${board}/thread/${threadId}.json`; |
|
|
|
let hovercache = localStorage.getItem(`hovercache-${jsonPath}`); |
|
|
|
let hovercache = localStorage.getItem(`hovercache-${jsonPath}`); |
|
|
|
let replies; |
|
|
|
let replies; |
|
|
|
if (hovercache) { |
|
|
|
if (hovercache) { |
|
|
|
hovercache = JSON.parse(hovercache); |
|
|
|
hovercache = JSON.parse(hovercache); |
|
|
|
//if we have the first preview reply in cache, the cache is fresh enough to show the omitted posts
|
|
|
|
//if we have the first preview reply in cache, the cache is fresh enough to show the omitted posts
|
|
|
|
if (hovercache.replies.find(r => r.postId == firstPreviewReply.dataset.postId)) { |
|
|
|
if (firstPreviewReply && hovercache.replies.find(r => r.postId == firstPreviewReply.dataset.postId)) { |
|
|
|
replies = hovercache.replies; |
|
|
|
replies = hovercache.replies; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//note: will always fetch (on new page load) for sticky preview replies = 0
|
|
|
|
} |
|
|
|
} |
|
|
|
if (!replies) { |
|
|
|
if (!replies) { |
|
|
|
e.target.style.cursor = 'wait'; |
|
|
|
e.target.style.cursor = 'wait'; |
|
|
@ -56,15 +60,17 @@ window.addEventListener('DOMContentLoaded', () => { |
|
|
|
if (!replies) { |
|
|
|
if (!replies) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
e.target.nextSibling.style.display = 'none'; |
|
|
|
e.target.src = '/file/minus.png'; |
|
|
|
e.target.src = '/file/minus.png'; |
|
|
|
e.target.dataset.open = true; |
|
|
|
e.target.dataset.open = true; |
|
|
|
replies |
|
|
|
replies = replies.reverse(); |
|
|
|
.reverse() |
|
|
|
if (firstPreviewReply) { |
|
|
|
.filter(r => r.postId < firstPreviewReply.dataset.postId) |
|
|
|
replies = replies.filter(r => r.postId < firstPreviewReply.dataset.postId); |
|
|
|
.forEach(r => { |
|
|
|
} |
|
|
|
|
|
|
|
replies.forEach(r => { |
|
|
|
newPost(r, { |
|
|
|
newPost(r, { |
|
|
|
insertPoint: parentPost.nextSibling, //anchor before first previewreply
|
|
|
|
insertPoint: firstPreviewReply ? parentPost.nextSibling : parentPost, |
|
|
|
insertPosition: 'beforebegin', |
|
|
|
insertPosition: firstPreviewReply ? 'beforebegin' : 'afterend', |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
|
}; |
|
|
|