tweaks for the notification message

This commit is contained in:
kapypara 2023-12-16 20:39:46 +03:00
parent 85a1bb76b5
commit e327e6acc9
1 changed files with 21 additions and 23 deletions

View File

@ -82,7 +82,7 @@ function getItem(id) {
try { try {
return fetch(url).then(response => response.json().then(obj => obj)) return fetch(url).then(response => response.json().then(obj => obj))
} catch (e) { } catch (e) {
console.log(`[getItem]: failed to fetch item ${id}`) console.log(`[getItem] failed to fetch item ${id}`)
return return
} }
} }
@ -91,13 +91,13 @@ function getItem(id) {
function makeItemListing(itemObj) { function makeItemListing(itemObj) {
if (itemObj === null || itemObj === undefined) { if (itemObj === null || itemObj === undefined) {
console.log(`[makeItemListing]: null or undefined object`) console.log(`[makeItemListing] null or undefined object`)
clearInterval(loader_id) clearInterval(loader_id)
return return
} }
if (itemObj.deleted || itemObj.dead || itemObj.title == "[deleted]") { if (itemObj.deleted || itemObj.dead || itemObj.title == "[deleted]") {
console.log(`[makeItemListing]: bad item: ${itemObj.id}`) console.log(`[makeItemListing] bad item: ${itemObj.id}`)
return return
} }
@ -123,7 +123,7 @@ function makeItemListing(itemObj) {
if (itemObj.type != itemType.job) { if (itemObj.type != itemType.job) {
subtitle += ` | ${comments} comments` subtitle += ` | ${comments} comments`
} else { } else {
console.log(`[makeItemListing]: job item ${title}`) console.log(`[makeItemListing] job item ${title}`)
} }
const element_string =` const element_string =`
@ -416,7 +416,7 @@ async function notify(count) {
return return
} }
new Notification("Clone Wars", { body: `${count} new Post`}) new Notification("Clone Wars", { body: "new Posts"})
} }
async function loadFresh() { async function loadFresh() {
@ -435,7 +435,7 @@ async function loadFresh() {
return return
} }
console.log(`[loadFresh]: new items ${newMax - endItem}`) console.log(`[loadFresh] new items ${newMax - endItem}`)
let count = 0 let count = 0
let intervalId = setInterval(async () => { let intervalId = setInterval(async () => {
@ -473,27 +473,25 @@ if (newMode) {
if (!isQuery) { if (!isQuery) {
setInterval(() => { setInterval(() => Array.from(pageItemBox.getElementsByTagName('a')).map(c => {
Array.from(pageItemBox.getElementsByTagName('a')).map(c => {
if (!c.time) { if (!c.time) {
return return
} }
const sub = c.getElementsByClassName('subtitle')[0] const sub = c.getElementsByClassName('subtitle')[0]
const date = timeSince(c.time) const date = timeSince(c.time)
const points = c.points const points = c.points
const author = c.author const author = c.author
const comments = c.comments const comments = c.comments
let subtitle = `${points} points by ${author} ${date} ago` let subtitle = `${points} points by ${author} ${date} ago`
if (comments !== undefined) { if (comments !== undefined) {
subtitle += ` | ${comments} comments` subtitle += ` | ${comments} comments`
} }
sub.innerHTML = subtitle sub.innerHTML = subtitle
}) }), 1e3)
}, 1e3)
} }