fix table html & more rigorous formatSeconds variable use

This commit is contained in:
2025-02-07 12:35:52 +01:00
parent 24e977572f
commit 23bc02f180
2 changed files with 26 additions and 24 deletions

View File

@@ -132,12 +132,12 @@
muted = false; muted = false;
} }
function formatSeconds(seconds) { function formatSeconds(totalSeconds) {
if (isNaN(seconds)) return 'No Data'; if (isNaN(totalSeconds)) return 'No Data';
var sec_num = parseInt(seconds, 10); totalSeconds = parseInt(totalSeconds, 10);
var hours = Math.floor(sec_num / 3600); var hours = Math.floor(totalSeconds / 3600);
var minutes = Math.floor(sec_num / 60) % 60; var minutes = Math.floor(totalSeconds / 60) % 60;
var seconds = sec_num % 60; var seconds = totalSeconds % 60;
return [hours, minutes, seconds] return [hours, minutes, seconds]
.map((v) => (v < 10 ? '0' + v : v)) .map((v) => (v < 10 ? '0' + v : v))

View File

@@ -30,6 +30,7 @@
<div id="table-container"> <div id="table-container">
<table> <table>
<tbody>
<tr><th>Timestamp</th><th>Artist</th><th>Title</th></tr> <tr><th>Timestamp</th><th>Artist</th><th>Title</th></tr>
{#each $currentStream.tracks as track, i} {#each $currentStream.tracks as track, i}
<tr class:current={i == $currentSongIndex}> <tr class:current={i == $currentSongIndex}>
@@ -48,6 +49,7 @@
<td class="track-field">{track[2]}</td> <td class="track-field">{track[2]}</td>
</tr> </tr>
{/each} {/each}
</tbody>
</table> </table>
</div> </div>