added updater for the items post time
This commit is contained in:
parent
2d4c60d3d1
commit
8d533d3f6a
|
@ -143,7 +143,13 @@ function makeItemListing(itemObj) {
|
||||||
`
|
`
|
||||||
const item = document.createElement('a')
|
const item = document.createElement('a')
|
||||||
item.href = "index.html?id=" + id
|
item.href = "index.html?id=" + id
|
||||||
|
|
||||||
|
// i got lazy
|
||||||
item.time = time
|
item.time = time
|
||||||
|
item.points = points
|
||||||
|
item.comments = comments
|
||||||
|
item.author = author
|
||||||
|
|
||||||
item.innerHTML = element_string
|
item.innerHTML = element_string
|
||||||
|
|
||||||
if (url === undefined || hostname === undefined) {
|
if (url === undefined || hostname === undefined) {
|
||||||
|
@ -431,7 +437,7 @@ async function loadFresh() {
|
||||||
|
|
||||||
const newEnd = newMax
|
const newEnd = newMax
|
||||||
|
|
||||||
if (newMax == endItem) {
|
if (newMax <= endItem) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -440,7 +446,7 @@ async function loadFresh() {
|
||||||
|
|
||||||
let intervalId = setInterval(async () => {
|
let intervalId = setInterval(async () => {
|
||||||
|
|
||||||
if (newMax == endItem) {
|
if (newMax <= endItem) {
|
||||||
endItem = newEnd
|
endItem = newEnd
|
||||||
notify(count)
|
notify(count)
|
||||||
return clearInterval(intervalId)
|
return clearInterval(intervalId)
|
||||||
|
@ -471,3 +477,31 @@ if (newMode) {
|
||||||
setTimeout(setInterval, 5e3, loadFresh, 5e3)
|
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)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue