From 6bc7063c68be760a52f621d2e3d77c89af21852b Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Sun, 23 Jul 2023 12:15:20 +0200 Subject: show votes and the time bonus in the song details --- web/client.html | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'web/client.html') diff --git a/web/client.html b/web/client.html index 51ddf3b..bc49369 100644 --- a/web/client.html +++ b/web/client.html @@ -112,8 +112,8 @@ } function appendSongDetails(song, details) { - let possibleDetails = ['upvotes', 'downvotes', 'album', 'year']; - for (const detail of possibleDetails) { + let possibleSimpleDetails = ['album', 'year']; + for (const detail of possibleSimpleDetails) { if (Object.hasOwn(song, detail)) { let value = song[detail]; if (!value) { @@ -123,6 +123,17 @@ details.appendChild(document.createTextNode(label + ': ' + value + ' ')); } } + + if (Object.hasOwn(song, 'upvotes') && Object.hasOwn(song, 'downvotes')) { + let uvs = Object.keys(song['upvotes']).length + details.appendChild(document.createTextNode('Upvotes: ' + uvs + ' ')); + + let dvs = Object.keys(song['downvotes']).length + details.appendChild(document.createTextNode('Downvotes: ' + dvs + ' ')); + + let timeBonus = song.weight - uvs + dvs + details.appendChild(document.createTextNode('TimeBonus: ' + timeBonus.toFixed(1) + ' ')); + } } function newSong(song) { -- cgit v1.2.3