mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
added scroll and highlight to links
This commit is contained in:
@@ -1,9 +1,21 @@
|
||||
function handleQuoteClick(reply) {
|
||||
const cid = reply.shortCid;
|
||||
function handleQuoteClick(reply, parentCid) {
|
||||
const cid = parentCid ? parentCid : reply.shortCid;
|
||||
const targetElement = [...document.querySelectorAll('.post-reply')]
|
||||
.find(el => el.innerHTML.includes(cid));
|
||||
.find(el => {
|
||||
const postNumberElement = el.querySelector('.post-number');
|
||||
return postNumberElement && postNumberElement.innerHTML.includes(cid);
|
||||
});
|
||||
|
||||
if (targetElement) {
|
||||
targetElement.scrollIntoView({ behavior: "instant" });
|
||||
const highlightedElements = document.querySelectorAll('.highlighted');
|
||||
|
||||
highlightedElements.forEach(el => {
|
||||
el.classList.remove('highlighted');
|
||||
});
|
||||
|
||||
targetElement.scrollIntoView({ behavior: "auto", block: "center" });
|
||||
targetElement.classList.add('highlighted');
|
||||
|
||||
} else {
|
||||
console.log('Could not find target element');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user