scroll to top when adding to queue

This commit is contained in:
Firepup Sixfifty 2025-03-24 14:32:02 -05:00
parent fc8205aade
commit c9d4f68b6b
Signed by: Firepup650
SSH key fingerprint: SHA256:in03N+Byhi/nMAIIKKMxbNMskVXULLrovhGkPNFEsdg

View file

@ -157,7 +157,7 @@ async def dashboard():
if playlist_id:
playlistElement = f'<iframe style="border-radius:12px" src="https://open.spotify.com/embed/playlist/{playlist_id}" width="100%" height="500" frameborder="0" allow="encrypted-media; fullscreen; picture-in-picture" loading="lazy"></iframe>'
return (
f'<!DOCTYPE html><html><head><title>Queue Adder For Spotify</title><style>*{{color-scheme:dark}}</style><script>function add_playlist(){{document.getElementById("add").disabled=true;document.getElementById("status").innerText="Adding songs to queue, please be patient...";fetch("add/",{{method:"POST"}}).then(response=>response.json()).then(data=>{{if(data.ok){{document.getElementById("status").innerText=`Idle - ${{data.fail_count}} tracks failed to add to the queue`;document.getElementById("add").disabled=false}}else{{document.getElementById("status").innerText=`An error occured: ${{data.error}}`}}}}).catch(error=>document.getElementById("status").innerText="An Unknown Fatal Error Occured");}}</script></head><body><h1>Queue Adder For Spotify Dashboard</h1><h3>Current Status: <span id=status>Idle</span><h2>Hi {userData["display_name"]}!</h2></h3><p>Configured Playlist:</p>{playlistElement}<button {"disabled=true " if not playlist_id else ""}onclick="add_playlist();" id=add>Add configured playlist to queue</button><br/><button onclick="location.href = \'logout/\';">Logout</button><h2>Settings</h2><p id="form-error" style="color:red"></p><form action="settings/" method="post"><label for="playlist_id">Playlist ID (or URL): </label><input name="playlist_id" id="playlist_id" value="{playlist_id}"><br/><label for="display_name">Display Name: </label><input name="display_name" id="display_name" value="{userData["display_name"]}"><br/><button>Submit</button><br/><p style="color:yellow">Warning! Display name will be overwritten with the value from spotify if you log out and back in!</p></form></body></html>',
f'<!DOCTYPE html><html><head><title>Queue Adder For Spotify</title><style>*{{color-scheme:dark}}</style><script>function add_playlist(){{window.scrollTo(0,0);document.getElementById("add").disabled=true;document.getElementById("status").innerText="Adding songs to queue, please be patient...";fetch("add/",{{method:"POST"}}).then(response=>response.json()).then(data=>{{if(data.ok){{document.getElementById("status").innerText=`Idle - ${{data.fail_count}} tracks failed to add to the queue`;document.getElementById("add").disabled=false}}else{{document.getElementById("status").innerText=`An error occured: ${{data.error}}`}}}}).catch(error=>document.getElementById("status").innerText="An Unknown Fatal Error Occured");}}</script></head><body><h1>Queue Adder For Spotify Dashboard</h1><h3>Current Status: <span id=status>Idle</span><h2>Hi {userData["display_name"]}!</h2></h3><p>Configured Playlist:</p>{playlistElement}<button {"disabled=true " if not playlist_id else ""}onclick="add_playlist();" id=add>Add configured playlist to queue</button><br/><button onclick="location.href = \'logout/\';">Logout</button><h2>Settings</h2><p id="form-error" style="color:red"></p><form action="settings/" method="post"><label for="playlist_id">Playlist ID (or URL): </label><input name="playlist_id" id="playlist_id" value="{playlist_id}"><br/><label for="display_name">Display Name: </label><input name="display_name" id="display_name" value="{userData["display_name"]}"><br/><button>Submit</button><br/><p style="color:yellow">Warning! Display name will be overwritten with the value from spotify if you log out and back in!</p></form></body></html>',
200,
)