Skip to content

Commit

Permalink
Merge pull request #165 from Ragzouken/playing2
Browse files Browse the repository at this point in the history
show playing on splash
  • Loading branch information
Ragzouken authored Nov 17, 2023
2 parents 97f1e0f + 035be7b commit 005a0f3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/client/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ html
#entry-panel
#entry-logo-container
img#entry-logo(src="./zone-logo.png")
#entry-playing ...
#entry-users.user-container ...
form#entry
input#join-name(type="text" placeholder="your name..." minlength="1" maxlength="16" required)
Expand Down
21 changes: 21 additions & 0 deletions src/client/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,8 @@ function setupEntrySplash() {
const entryButton = document.getElementById('entry-button') as HTMLInputElement;
const entryForm = document.getElementById('entry') as HTMLFormElement;

const entryPlaying = document.getElementById("entry-playing") as HTMLElement;

function refreshUsers(users: { name?: string; avatar?: string, userId: string }[]) {
entryUsers.innerHTML = '';
users.forEach((user) => {
Expand Down Expand Up @@ -957,6 +959,25 @@ function setupEntrySplash() {
updateEntryUsers();
setInterval(updateEntryUsers, 5000);

function updateEntryPlaying() {
fetch('./playing')
.then((res) => res.json())
.then(({ item, time }) => {
const playing = document.createElement("div");
entryPlaying.replaceChildren(playing);

if (item) {
const stamp = secondsToTime(time / 1000);
const duration = secondsToTime(item.media.duration / 1000);
playing.replaceChildren(`${item.media.title} (${stamp} / ${duration})`);
} else {
playing.replaceChildren(`nothing playing`);
}
});
}
updateEntryPlaying();
setInterval(updateEntryPlaying, 5000);

entryButton.disabled = !entryForm.checkValidity();
nameInput.addEventListener('input', () => (entryButton.disabled = !entryForm.checkValidity()));
zone.hidden = true;
Expand Down
4 changes: 4 additions & 0 deletions src/client/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,10 @@ button > img {
margin: 1em;
}

#entry-playing {
margin: 1em;
}

.user-dj {
text-decoration: underline 2px #00FFFF;
}
Expand Down

0 comments on commit 005a0f3

Please sign in to comment.