aboutsummaryrefslogtreecommitdiff
path: root/web/client.html
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2022-07-27 20:15:50 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2022-07-27 20:15:50 +0200
commitbb17b54478273116e1f48ff53476efb9f01cde7e (patch)
tree17050bfb547a575d4e0c0ad5a5baf96089859800 /web/client.html
parent2fd1af916a333ca2ecaaa01bae2e43b922a4ca2e (diff)
downloadWRMS-bb17b54478273116e1f48ff53476efb9f01cde7e.tar.gz
WRMS-bb17b54478273116e1f48ff53476efb9f01cde7e.zip
intermediate commit
* use more llog * inform clients about their votes when initiating the connection * show song weights
Diffstat (limited to 'web/client.html')
-rw-r--r--web/client.html18
1 files changed, 16 insertions, 2 deletions
diff --git a/web/client.html b/web/client.html
index 3cddb29..2ca1f0d 100644
--- a/web/client.html
+++ b/web/client.html
@@ -77,9 +77,10 @@
let votes = new Map();
function formatSong(song) {
+ let s = song.weight + ' '
if (song.artist)
- return song.artist + ' - ' + song.title
- return song.title
+ return s + song.artist + ' - ' + song.title
+ return s + song.title
}
function renderPlaylist() {
@@ -148,6 +149,13 @@
renderPlaylist();
}
+ function handleVotes(direction, votedSongs) {
+ for (const song of votedSongs) {
+ votes.set(song.uri, direction)
+ }
+ renderPlaylist();
+ }
+
function handleUpdate(updated) {
for (const updated_song of updated) {
songs[songs.findIndex(function(s) {return s.uri == updated_song.uri})] = updated_song;
@@ -203,6 +211,12 @@
case "play":
handlePlay(cmd.songs[0])
break;
+ case "upvoted":
+ handleVotes("up", cmd.songs)
+ break;
+ case "downvoted":
+ handleVotes("down", cmd.songs)
+ break;
}
};