From a493263f72ba6ca93e9d7c7f554bcb58fe861b1b Mon Sep 17 00:00:00 2001 From: Bingus_Violet Date: Thu, 25 Jan 2024 22:24:09 -0600 Subject: [PATCH] Song durations! --- index.js | 41 +++++++++++++++++++++++++++++++---------- resources/mainPage.html | 13 +++++++++++++ static/style.css | 20 ++++++++++++++++++++ 3 files changed, 64 insertions(+), 10 deletions(-) diff --git a/index.js b/index.js index cb725f3..45574ce 100644 --- a/index.js +++ b/index.js @@ -170,15 +170,37 @@ function pageUpdate() { return html } if (activity.type == 2) { - addedHTML += ` -
- -

- Listening to ${activity.name} -
Song: ${activity.details || " "} - ${songStats()} -

+ var timeLeft = Math.round((activity.timestamps.end - Date.now()) / 1000) + var currentPercent = (Date.now() - activity.timestamps.start) / (activity.timestamps.end - activity.timestamps.start) * 100 + addedHTML += ` +
+ +

+ Listening to ${activity.name} +
Song: ${activity.details || " "} + ${songStats()} +
+ +

+ + ` } else if (activity.type == 0) { var time = activity.created_at @@ -284,5 +306,4 @@ app.use((req, res, next) => {

404

Uh oh... I think your lost? There's nothing here :P

`) -}) - \ No newline at end of file +}) \ No newline at end of file diff --git a/resources/mainPage.html b/resources/mainPage.html index f9e6695..8d8c499 100644 --- a/resources/mainPage.html +++ b/resources/mainPage.html @@ -58,6 +58,19 @@ {MASTODON_FEED} {SEASONAL_EFFECT} + +
+ +

+ Listening to Spotify +
Song: Here With Me + +
Album: Petals to Thorns +
Artist: d4vd +
+ +

+
\ No newline at end of file diff --git a/static/style.css b/static/style.css index 325b3dc..a7a95a4 100644 --- a/static/style.css +++ b/static/style.css @@ -271,6 +271,26 @@ hr { border-radius: 5px; } +.lengthBar { + background-color: rgb(50, 40, 60); + display: inline-block; + width: 80%; + height: 10px; + padding: 0; + overflow: hidden; + border-radius: 5px; +} + +.lengthBar > span { + margin: 0; + padding: 0; + width: 100%; + background-color: white; + height: 20px; + display: inline-block; + position: relative; +} + @keyframes fade-in { 0% { opacity: 0;