added updater for the items post time

This commit is contained in:
kapypara 2023-12-16 20:26:41 +03:00
parent 2d4c60d3d1
commit 8d533d3f6a
1 changed files with 36 additions and 2 deletions

View File

@ -143,7 +143,13 @@ function makeItemListing(itemObj) {
`
const item = document.createElement('a')
item.href = "index.html?id=" + id
// i got lazy
item.time = time
item.points = points
item.comments = comments
item.author = author
item.innerHTML = element_string
if (url === undefined || hostname === undefined) {
@ -431,7 +437,7 @@ async function loadFresh() {
const newEnd = newMax
if (newMax == endItem) {
if (newMax <= endItem) {
return
}
@ -440,7 +446,7 @@ async function loadFresh() {
let intervalId = setInterval(async () => {
if (newMax == endItem) {
if (newMax <= endItem) {
endItem = newEnd
notify(count)
return clearInterval(intervalId)
@ -471,3 +477,31 @@ if (newMode) {
setTimeout(setInterval, 5e3, loadFresh, 5e3)
}
if (!isQuery) {
setInterval(() => {
Array.from(pageItemBox.getElementsByTagName('a')).map(c => {
if (!c.time) {
return
}
const sub = c.getElementsByClassName('subtitle')[0]
const date = timeSince(c.time)
const points = c.points
const author = c.author
const comments = c.comments
let subtitle = `${points} points by ${author} ${date} ago`
console.log(comments)
if (comments !== undefined) {
subtitle += ` | ${comments} comments`
}
sub.innerHTML = subtitle
})
}, 1e3)
}