feat: Add spotify page
This commit is contained in:
2
templates/assets/css/styles.min.css
vendored
2
templates/assets/css/styles.min.css
vendored
@@ -1 +1 @@
|
||||
:root,[data-bs-theme=light]{--bs-primary:#6E0E9C;--bs-primary-rgb:110,14,156;--bs-primary-text-emphasis:#2C063E;--bs-primary-bg-subtle:#E2CFEB;--bs-primary-border-subtle:#C59FD7;--bs-link-color:#6E0E9C;--bs-link-color-rgb:110,14,156;--bs-link-hover-color:#a41685;--bs-link-hover-color-rgb:164,22,133}.btn-primary{--bs-btn-color:#fff;--bs-btn-bg:#6E0E9C;--bs-btn-border-color:#6E0E9C;--bs-btn-hover-color:#fff;--bs-btn-hover-bg:#5E0C85;--bs-btn-hover-border-color:#580B7D;--bs-btn-focus-shadow-rgb:233,219,240;--bs-btn-active-color:#fff;--bs-btn-active-bg:#580B7D;--bs-btn-active-border-color:#530B75;--bs-btn-disabled-color:#fff;--bs-btn-disabled-bg:#6E0E9C;--bs-btn-disabled-border-color:#6E0E9C}.btn-outline-primary{--bs-btn-color:#6E0E9C;--bs-btn-border-color:#6E0E9C;--bs-btn-focus-shadow-rgb:110,14,156;--bs-btn-hover-color:#fff;--bs-btn-hover-bg:#6E0E9C;--bs-btn-hover-border-color:#6E0E9C;--bs-btn-active-color:#fff;--bs-btn-active-bg:#6E0E9C;--bs-btn-active-border-color:#6E0E9C;--bs-btn-disabled-color:#6E0E9C;--bs-btn-disabled-bg:transparent;--bs-btn-disabled-border-color:#6E0E9C}
|
||||
:root,[data-bs-theme=light]{--bs-primary:#6E0E9C;--bs-primary-rgb:110,14,156;--bs-primary-text-emphasis:#2C063E;--bs-primary-bg-subtle:#E2CFEB;--bs-primary-border-subtle:#C59FD7;--bs-link-color:#6E0E9C;--bs-link-color-rgb:110,14,156;--bs-link-hover-color:#a41685;--bs-link-hover-color-rgb:164,22,133}.btn-primary{--bs-btn-color:#fff;--bs-btn-bg:#6E0E9C;--bs-btn-border-color:#6E0E9C;--bs-btn-hover-color:#fff;--bs-btn-hover-bg:#5E0C85;--bs-btn-hover-border-color:#580B7D;--bs-btn-focus-shadow-rgb:233,219,240;--bs-btn-active-color:#fff;--bs-btn-active-bg:#580B7D;--bs-btn-active-border-color:#530B75;--bs-btn-disabled-color:#fff;--bs-btn-disabled-bg:#6E0E9C;--bs-btn-disabled-border-color:#6E0E9C}.btn-outline-primary{--bs-btn-color:#6E0E9C;--bs-btn-border-color:#6E0E9C;--bs-btn-focus-shadow-rgb:110,14,156;--bs-btn-hover-color:#fff;--bs-btn-hover-bg:#6E0E9C;--bs-btn-hover-border-color:#6E0E9C;--bs-btn-active-color:#fff;--bs-btn-active-bg:#6E0E9C;--bs-btn-active-border-color:#6E0E9C;--bs-btn-disabled-color:#6E0E9C;--bs-btn-disabled-bg:transparent;--bs-btn-disabled-border-color:#6E0E9C}.no-title{text-transform:none!important}.spotify-icon{cursor:pointer}
|
||||
1
templates/assets/js/spotify.min.js
vendored
Normal file
1
templates/assets/js/spotify.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
let progressInterval=null,progressSpeed=0,lastUpdateTime=Date.now(),currentProgress=0,targetProgress=0,trackDuration=0,currentTrackId=null,trackurl=null;async function updateSpotifyWidget(){try{const e=await fetch("/api/v1/playing");if(!e.ok)return;const n=await e.json();if(n.error||n.message){if(document.getElementById("spotify-song").textContent)return;return document.getElementById("spotify-album-art").src="/assets/img/external/spotify.png",document.getElementById("spotify-album-art").style.cursor="default",document.getElementById("spotify-song").textContent="Not Playing",document.getElementById("spotify-artist").textContent="",document.getElementById("spotify-album").textContent="",document.getElementById("spotify-icon-playing").style.display="none",document.getElementById("spotify-icon-paused").style.display="none",document.getElementById("spotify-icon-stopped").style.display="inline",updateProgressBar(0,1),clearInterval(progressInterval),progressInterval=null,currentProgress=0,currentTrackId=null,void(trackurl=null)}const r=n.spotify;var t=!1;document.getElementById("spotify-song").textContent||(t=!0);const o=r.song_name+r.artist;null!==currentTrackId&¤tTrackId!==o&&(currentProgress=0,document.getElementById("spotify-progress").style.transition="none",document.getElementById("spotify-progress").style.width="0%",document.getElementById("spotify-progress").offsetHeight,document.getElementById("spotify-progress").style.transition="width 0.1s linear"),currentTrackId=o,trackurl=r.url,document.getElementById("spotify-album-art").src=r.album_art,document.getElementById("spotify-album-art").style.cursor="pointer",document.getElementById("spotify-song").textContent=r.song_name,document.getElementById("spotify-artist").textContent=r.artist,document.getElementById("spotify-album").textContent=r.album_name,r.is_playing?(currentProgress=r.progress_ms,trackDuration=r.duration_ms,lastUpdateTime=Date.now(),updateProgressBar(r.progress_ms,r.duration_ms),progressInterval&&clearInterval(progressInterval),progressInterval=setInterval(animateProgressBar,10),document.getElementById("spotify-icon-playing").style.display="inline",document.getElementById("spotify-icon-paused").style.display="none",document.getElementById("spotify-icon-stopped").style.display="none"):(updateProgressBar(r.progress_ms,r.duration_ms),clearInterval(progressInterval),progressInterval=null,currentProgress=r.progress_ms,trackDuration=r.duration_ms,document.getElementById("spotify-icon-playing").style.display="none",document.getElementById("spotify-icon-paused").style.display="inline",document.getElementById("spotify-icon-stopped").style.display="none"),t&&updateVisibility()}catch(t){console.error("Failed to fetch Spotify data",t)}}function updateProgressBar(t,e){if(0===e)return;const n=t/e*100,r=document.getElementById("spotify-progress");r.style.width=n+"%",r.setAttribute("aria-valuenow",t),r.setAttribute("aria-valuemax",e),r.setAttribute("aria-valuemin",0)}function animateProgressBar(){if(!trackDuration)return;const t=Date.now(),e=t-lastUpdateTime;if(lastUpdateTime=t,currentProgress+=e,currentProgress>trackDuration)return clearInterval(progressInterval),void updateSpotifyWidget();updateProgressBar(currentProgress,trackDuration)}updateSpotifyWidget(),setInterval(updateSpotifyWidget,5e3),document.getElementById("spotify-album-art").onclick=()=>{trackurl&&window.open(trackurl,"_blank")},document.getElementById("spotify-icon-playing").onclick=()=>{trackurl&&window.open(trackurl,"_blank")},document.getElementById("spotify-icon-paused").onclick=()=>{trackurl&&window.open(trackurl,"_blank")},document.getElementById("spotify-icon-stopped").onclick=()=>{trackurl&&window.open(trackurl,"_blank")};
|
||||
Reference in New Issue
Block a user