Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show playing on splash #165

Merged
merged 1 commit into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading