From 3cdf3b0bce0fe5292c4c67f65277d4bc0cc6f1ca Mon Sep 17 00:00:00 2001 From: bingus_violet Date: Thu, 11 Jan 2024 18:55:22 +0000 Subject: [PATCH] More updates to discord page, removed extra code --- index.js | 13 ------------- resources/mainPage.html | 2 +- static/discord/index.html | 2 +- static/discord/index.js | 37 ++++++++++++++++++++++++++++++++++++- 4 files changed, 38 insertions(+), 16 deletions(-) diff --git a/index.js b/index.js index 31b9ce9..10ccfd0 100644 --- a/index.js +++ b/index.js @@ -92,19 +92,6 @@ function pageUpdate() { addedHTML = "" - if (lanyardData) { - for (let index = 0; index < lanyardData.activities.length; index++) { - const activity = lanyardData.activities[index]; - if (activity.type == 4) { - addedHTML += `

"${lanyardData.activities[0].state}" - ${lanyardData.discord_user.display_name} ${new Date(Date.now()).getFullYear()}

` - } - } - } - - html = html.replace("{LANYARD_SPOTIFY}", addedHTML) - - addedHTML = "" - var debounce = false if (lanyardData && lanyardData.activities.length > 0) { diff --git a/resources/mainPage.html b/resources/mainPage.html index aa2e63f..feb782f 100644 --- a/resources/mainPage.html +++ b/resources/mainPage.html @@ -34,7 +34,7 @@

-

Pronouns

+

Disc Status

Socials

Projects


diff --git a/static/discord/index.html b/static/discord/index.html index 549639b..493dff7 100644 --- a/static/discord/index.html +++ b/static/discord/index.html @@ -31,7 +31,7 @@

They/Them

Developer

-

Offline

+

Offline

diff --git a/static/discord/index.js b/static/discord/index.js index 3b9780a..8244504 100644 --- a/static/discord/index.js +++ b/static/discord/index.js @@ -1,5 +1,24 @@ var lanyard = new WebSocket('wss://api.lanyard.rest/socket') +var statuses = { + "online": { + "text": "Online", + "color": "rgb(100, 255, 100)" + }, + "dnd": { + "text": "DND", + "color": "rgb(255, 100, 100)" + }, + "idle": { + "text": "Idle", + "color": "rgb(255, 255, 75)" + }, + "offline": { + "text": "Offline", + "color": "rgb(125, 125, 125)" + } +} + function beat(dur) { lanyard.send(JSON.stringify({ op: 3 @@ -21,6 +40,22 @@ lanyard.addEventListener("message", (res) => { })) } else if (data.op == 0) { var lanyardData = data.d - $("*").text(JSON.stringify(lanyardData)) + // $("*").text(JSON.stringify(lanyardData)) + + + var statusData = statuses[lanyardData.discord_status] + + $("#discStatus").text(statusData.text) + $("#discStatus").css("color", statusData.color) + $(".pfp").css("border-color", statusData.color) + + if (lanyardData) { + for (let index = 0; index < lanyardData.activities.length; index++) { + const activity = lanyardData.activities[index]; + if (activity.type == 4) { + $("#discQuote").html(`
"${lanyardData.activities[0].state}" - ${lanyardData.discord_user.display_name} ${new Date(Date.now()).getFullYear()}`) + } + } + } } }) \ No newline at end of file