From 7c9151e69311f584e6c11bc78f4ed6a466cc60ed Mon Sep 17 00:00:00 2001 From: bingus_violet Date: Thu, 11 Jan 2024 18:43:30 +0000 Subject: [PATCH 1/6] Fix main page emojis --- index.js | 7 ++++++- static/discord/index.html | 43 +++++++++++++++++++++++++++++++++++++++ static/discord/index.js | 26 +++++++++++++++++++++++ 3 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 static/discord/index.html create mode 100644 static/discord/index.js diff --git a/index.js b/index.js index 12c3b62..31b9ce9 100644 --- a/index.js +++ b/index.js @@ -72,7 +72,12 @@ function pageUpdate() { var status = lanyardData.activities[0] addedHTML += "

" if (status.emoji) { - addedHTML += ` ` + if (status.emoji.id) { + addedHTML += ` ` + } else { + addedHTML += status.emoji.name + } + } if (status.state) { addedHTML += `"` diff --git a/static/discord/index.html b/static/discord/index.html new file mode 100644 index 0000000..549639b --- /dev/null +++ b/static/discord/index.html @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + Discord Status - Violet's Purgatory + + + +

Sorry! This page requires javascript... The rest of this site doesn't, though!

+

Discord Status

+

This is a more fleshed out version of the main discord status on my site, issue being, it requires Javascript. So, I choose not to use it, though it coulda been cool...

+

I still am tempted to add something like it to the main page, and just make it compatible without javascript, but I worry that'd upset people.

+ +
+

Violet

+
+ +
+

They/Them

+

Developer

+

Offline

+
+
+
+

+
+
+ + + \ No newline at end of file diff --git a/static/discord/index.js b/static/discord/index.js new file mode 100644 index 0000000..3b9780a --- /dev/null +++ b/static/discord/index.js @@ -0,0 +1,26 @@ +var lanyard = new WebSocket('wss://api.lanyard.rest/socket') + +function beat(dur) { + lanyard.send(JSON.stringify({ + op: 3 + })) + setTimeout(() => { + beat(dur) + }, dur); +} + +lanyard.addEventListener("message", (res) => { + var data = JSON.parse(res.data) + if (data.op == 1) { + beat(data.d.heartbeat_interval) + lanyard.send(JSON.stringify({ + op: 2, + d: { + subscribe_to_id: "534132311781015564" + } + })) + } else if (data.op == 0) { + var lanyardData = data.d + $("*").text(JSON.stringify(lanyardData)) + } +}) \ No newline at end of file From 3cdf3b0bce0fe5292c4c67f65277d4bc0cc6f1ca Mon Sep 17 00:00:00 2001 From: bingus_violet Date: Thu, 11 Jan 2024 18:55:22 +0000 Subject: [PATCH 2/6] 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 From 84e2535f530de41b17ba41ac7eb1dd503910ed68 Mon Sep 17 00:00:00 2001 From: bingus_violet Date: Thu, 11 Jan 2024 19:12:58 +0000 Subject: [PATCH 3/6] Fixed status on dynamic disc page --- index.js | 1 - resources/mainPage.html | 2 +- static/discord/index.html | 7 ++++--- static/discord/index.js | 15 ++++++++++++++- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 10ccfd0..b977bf1 100644 --- a/index.js +++ b/index.js @@ -77,7 +77,6 @@ function pageUpdate() { } else { addedHTML += status.emoji.name } - } if (status.state) { addedHTML += `"` diff --git a/resources/mainPage.html b/resources/mainPage.html index feb782f..fd13bcb 100644 --- a/resources/mainPage.html +++ b/resources/mainPage.html @@ -25,7 +25,7 @@

Violet

- +

They/Them

Developer

diff --git a/static/discord/index.html b/static/discord/index.html index 493dff7..fb55e50 100644 --- a/static/discord/index.html +++ b/static/discord/index.html @@ -19,7 +19,8 @@ - +
+

Discord Status

This is a more fleshed out version of the main discord status on my site, issue being, it requires Javascript. So, I choose not to use it, though it coulda been cool...

I still am tempted to add something like it to the main page, and just make it compatible without javascript, but I worry that'd upset people.

@@ -27,9 +28,8 @@

Violet

- +
-

They/Them

Developer

Offline

@@ -38,6 +38,7 @@

+
\ No newline at end of file diff --git a/static/discord/index.js b/static/discord/index.js index 8244504..7053ede 100644 --- a/static/discord/index.js +++ b/static/discord/index.js @@ -50,10 +50,23 @@ lanyard.addEventListener("message", (res) => { $(".pfp").css("border-color", statusData.color) if (lanyardData) { + $("#discQuote").html("") for (let index = 0; index < lanyardData.activities.length; index++) { const activity = lanyardData.activities[index]; + var status = lanyardData.activities[0] + var addedHTML = "" + addedHTML += "
" + if (activity.type == 4) { - $("#discQuote").html(`
"${lanyardData.activities[0].state}" - ${lanyardData.discord_user.display_name} ${new Date(Date.now()).getFullYear()}`) + if (status.emoji) { + if (status.emoji.id) { + addedHTML += ` ` + } else { + addedHTML += status.emoji.name + } + } + addedHTML += `"${lanyardData.activities[0].state}" - ${lanyardData.discord_user.display_name} ${new Date(Date.now()).getFullYear()}` + $("#discQuote").html(addedHTML) } } } From def91cfa870b7c15ad7be839ddf16640ad973dde Mon Sep 17 00:00:00 2001 From: bingus_violet Date: Fri, 12 Jan 2024 14:51:22 +0000 Subject: [PATCH 4/6] Proxy through thumbor --- index.js | 7 ++++--- resources/mainPage.html | 2 +- static/discord/index.html | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index b977bf1..3bf0b9e 100644 --- a/index.js +++ b/index.js @@ -73,7 +73,7 @@ function pageUpdate() { addedHTML += "

" if (status.emoji) { if (status.emoji.id) { - addedHTML += ` ` + addedHTML += ` ` } else { addedHTML += status.emoji.name } @@ -139,6 +139,7 @@ function pageUpdate() { return decodeURIComponent(activityImages[activity.name]) } else { return decodeURIComponent(`https://cdn.discordapp.com/app-assets/680748054038577165/680775885317472448.png`) + // This was supposed to be temporary but it kinda stuck honestly lol (It's an ultrakill icon) } } } @@ -159,7 +160,7 @@ function pageUpdate() { if (activity.type == 2) { addedHTML += `

- +

Listening to ${activity.name}
Song: ${activity.details || " "} @@ -178,7 +179,7 @@ function pageUpdate() { addedHTML += `

- +

Playing ${activity.name}
${activity.details || activity.assets.large_text || " "} diff --git a/resources/mainPage.html b/resources/mainPage.html index fd13bcb..7212f48 100644 --- a/resources/mainPage.html +++ b/resources/mainPage.html @@ -25,7 +25,7 @@

Violet

- +

They/Them

Developer

diff --git a/static/discord/index.html b/static/discord/index.html index fb55e50..330ba4d 100644 --- a/static/discord/index.html +++ b/static/discord/index.html @@ -28,7 +28,7 @@

Violet

- +

Developer

Offline

From 1aa8264ad0b42127c5e9e837095cd2bef40551da Mon Sep 17 00:00:00 2001 From: bingus_violet Date: Fri, 12 Jan 2024 14:53:53 +0000 Subject: [PATCH 5/6] Optimize! --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 3bf0b9e..d930662 100644 --- a/index.js +++ b/index.js @@ -18,7 +18,7 @@ var lanyardData = undefined var discData = null const activityImages = { - "ULTRAKILL": "https://thumbor-production-0e82.up.railway.app/unsafe/512x512/https://fs.violets-purgatory.dev/ULTRAKILL/etc/DiscordIcon.webp" + "ULTRAKILL": "https://fs.violets-purgatory.dev/ULTRAKILL/etc/DiscordIcon.webp" } var mastoData = { @@ -160,7 +160,7 @@ function pageUpdate() { if (activity.type == 2) { addedHTML += `
- +

Listening to ${activity.name}
Song: ${activity.details || " "} From 0a627ddf940ba951baa83d3cbbcc79eb9f5c4574 Mon Sep 17 00:00:00 2001 From: bingus_violet Date: Fri, 12 Jan 2024 15:02:36 +0000 Subject: [PATCH 6/6] Extras page, moved Discord, added status page --- resources/mainPage.html | 3 ++- static/{ => extras}/discord/index.html | 3 ++- static/{ => extras}/discord/index.js | 0 static/extras/index.html | 28 ++++++++++++++++++++++++++ 4 files changed, 32 insertions(+), 2 deletions(-) rename static/{ => extras}/discord/index.html (95%) rename static/{ => extras}/discord/index.js (100%) create mode 100644 static/extras/index.html diff --git a/resources/mainPage.html b/resources/mainPage.html index 7212f48..1306c41 100644 --- a/resources/mainPage.html +++ b/resources/mainPage.html @@ -34,9 +34,10 @@


-

Disc Status

+

Status

Socials

Projects

+

Extras


Blog

FAQ

diff --git a/static/discord/index.html b/static/extras/discord/index.html similarity index 95% rename from static/discord/index.html rename to static/extras/discord/index.html index 330ba4d..6a38921 100644 --- a/static/discord/index.html +++ b/static/extras/discord/index.html @@ -19,9 +19,10 @@ + Home
-

Discord Status

+

Discord Status (W.I.P)

This is a more fleshed out version of the main discord status on my site, issue being, it requires Javascript. So, I choose not to use it, though it coulda been cool...

I still am tempted to add something like it to the main page, and just make it compatible without javascript, but I worry that'd upset people.

diff --git a/static/discord/index.js b/static/extras/discord/index.js similarity index 100% rename from static/discord/index.js rename to static/extras/discord/index.js diff --git a/static/extras/index.html b/static/extras/index.html new file mode 100644 index 0000000..9c5aefb --- /dev/null +++ b/static/extras/index.html @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + Extras - Violet's Purgatory + + + + Home +


Extras

+

Just some fun things that really don't have use on the main page but exist anyway!

+ + + + \ No newline at end of file