From e327e6acc99c8210a6605c1b2df7c30217fe9d45 Mon Sep 17 00:00:00 2001 From: kapypara Date: Sat, 16 Dec 2023 20:39:46 +0300 Subject: [PATCH] tweaks for the notification message --- static/index.js | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/static/index.js b/static/index.js index 215d20a..0712f67 100644 --- a/static/index.js +++ b/static/index.js @@ -82,7 +82,7 @@ function getItem(id) { try { return fetch(url).then(response => response.json().then(obj => obj)) } catch (e) { - console.log(`[getItem]: failed to fetch item ${id}`) + console.log(`[getItem] failed to fetch item ${id}`) return } } @@ -91,13 +91,13 @@ function getItem(id) { function makeItemListing(itemObj) { if (itemObj === null || itemObj === undefined) { - console.log(`[makeItemListing]: null or undefined object`) + console.log(`[makeItemListing] null or undefined object`) clearInterval(loader_id) return } if (itemObj.deleted || itemObj.dead || itemObj.title == "[deleted]") { - console.log(`[makeItemListing]: bad item: ${itemObj.id}`) + console.log(`[makeItemListing] bad item: ${itemObj.id}`) return } @@ -123,7 +123,7 @@ function makeItemListing(itemObj) { if (itemObj.type != itemType.job) { subtitle += ` | ${comments} comments` } else { - console.log(`[makeItemListing]: job item ${title}`) + console.log(`[makeItemListing] job item ${title}`) } const element_string =` @@ -416,7 +416,7 @@ async function notify(count) { return } - new Notification("Clone Wars", { body: `${count} new Post`}) + new Notification("Clone Wars", { body: "new Posts"}) } async function loadFresh() { @@ -435,7 +435,7 @@ async function loadFresh() { return } - console.log(`[loadFresh]: new items ${newMax - endItem}`) + console.log(`[loadFresh] new items ${newMax - endItem}`) let count = 0 let intervalId = setInterval(async () => { @@ -473,27 +473,25 @@ if (newMode) { if (!isQuery) { - setInterval(() => { - Array.from(pageItemBox.getElementsByTagName('a')).map(c => { + setInterval(() => Array.from(pageItemBox.getElementsByTagName('a')).map(c => { - if (!c.time) { - return - } + if (!c.time) { + return + } - const sub = c.getElementsByClassName('subtitle')[0] + const sub = c.getElementsByClassName('subtitle')[0] - const date = timeSince(c.time) - const points = c.points - const author = c.author - const comments = c.comments + 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` + let subtitle = `${points} points by ${author} ${date} ago` - if (comments !== undefined) { - subtitle += ` | ${comments} comments` - } + if (comments !== undefined) { + subtitle += ` | ${comments} comments` + } - sub.innerHTML = subtitle - }) - }, 1e3) + sub.innerHTML = subtitle + }), 1e3) }