MarseyWorld/files/assets/js/post.js

35 lines
1.0 KiB
JavaScript
Raw Normal View History

function highlight_unread(localstoragevar) {
const comments = JSON.parse(localStorage.getItem(localstoragevar)) || {}
lastCount = comments[pid]
if (lastCount)
{
2022-12-30 14:20:09 +00:00
const comms = document.getElementById("comms").value.slice(0, -1).split(',')
for (let c of comms) {
c = c.split(':')
if (c[1]*1000 > lastCount.t) {
try {document.getElementById(`comment-${c[0]}-only`).classList.add('unread')}
catch(e) {}
}
}
2023-01-01 11:36:20 +00:00
}
}
highlight_unread("comment-counts")
if (!location.href.includes("#context")) {
2023-05-05 21:46:24 +00:00
localStorage.setItem("old-comment-counts", localStorage.getItem("comment-counts"))
const comments = JSON.parse(localStorage.getItem("comment-counts")) || {}
2023-05-05 21:46:24 +00:00
const newTotal = pcc || ((comments[pid] || {c: 0}).c + 1)
comments[pid] = {c: newTotal, t: Date.now()}
localStorage.setItem("comment-counts", JSON.stringify(comments))
}
2023-01-28 10:38:14 +00:00
const fake_textarea = document.querySelector('[data-href]')
if (fake_textarea) {
fake_textarea.addEventListener('click', () => {
2023-01-28 10:38:14 +00:00
location.href = fake_textarea.dataset.href;
});
2023-01-28 10:38:14 +00:00
}