fix duplicate ~new~
indicators being sent (#642)
we also make the JS we're generating about 7% the size it was before.
This commit is contained in:
parent
2541737833
commit
a5a344f084
3 changed files with 54 additions and 36 deletions
|
@ -56,4 +56,22 @@ function expandMarkdown(t,id) {
|
|||
let val = t.getElementsByTagName('span')[0]
|
||||
if (val.innerHTML == 'View source') val.innerHTML = 'Hide source'
|
||||
else val.innerHTML = 'View source'
|
||||
};
|
||||
};
|
||||
|
||||
function commentsAddUnreadIndicator(commentIds) {
|
||||
commentIds.forEach(element => {
|
||||
const commentOnly = document.getElementById(`comment-${element}-only`);
|
||||
if (!commentOnly) {
|
||||
console.warn(`Couldn't find comment (comment ID ${element}) in page while attempting to add an unread indicator.`);
|
||||
return;
|
||||
}
|
||||
if (commentOnly.classList.contains("unread")) return;
|
||||
commentOnly.classList.add("unread");
|
||||
const commentUserInfo = document.getElementById(`comment-${element}`)?.querySelector(".comment-user-info");
|
||||
if (!commentUserInfo) {
|
||||
console.warn(`Couldn't find comment user info (comment ID ${element}) in page while attempting to add an unread indicator.`);
|
||||
return;
|
||||
}
|
||||
commentUserInfo.innerHTML += "<span class=\"new-indicator\">~new~</span>";
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue