From bb17b54478273116e1f48ff53476efb9f01cde7e Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Wed, 27 Jul 2022 20:15:50 +0200 Subject: intermediate commit * use more llog * inform clients about their votes when initiating the connection * show song weights --- web/client.html | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'web') 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; } }; -- cgit v1.2.3