diff --git a/public/app.js b/public/app.js index c58e8b7..ff1cdbc 100644 --- a/public/app.js +++ b/public/app.js @@ -5,6 +5,9 @@ const remoteGrid = document.querySelector("#remote-grid"); const remoteTemplate = document.querySelector("#remote-template"); const nameForm = document.querySelector("#name-form"); const nameInput = document.querySelector("#name-input"); +const nameDialog = document.querySelector("#name-dialog"); +const initialNameForm = document.querySelector("#initial-name-form"); +const initialNameInput = document.querySelector("#initial-name-input"); const statusText = document.querySelector("#status"); const youtubeForm = document.querySelector("#youtube-form"); const youtubeInput = document.querySelector("#youtube-input"); @@ -663,6 +666,20 @@ nameForm.addEventListener("submit", (event) => { }); }); +initialNameForm.addEventListener("submit", (event) => { + event.preventDefault(); + setDisplayName(initialNameInput.value); + nameDialog.close(); + joinCall().catch((error) => { + console.error(error); + setStatus("Could not start camera or join the call."); + }); +}); + +nameDialog.addEventListener("cancel", (event) => { + event.preventDefault(); +}); + nameInput.addEventListener("change", () => { setDisplayName(nameInput.value); if (events) { @@ -765,7 +782,9 @@ if (savedName) { setStatus("Could not start camera or join the call."); }); } else { - nameInput.focus(); + setStatus("Choose your name to join the call."); + nameDialog.showModal(); + initialNameInput.focus(); refreshDeviceLists().catch(console.error); } diff --git a/public/index.html b/public/index.html index c5efbb4..e540bf6 100644 --- a/public/index.html +++ b/public/index.html @@ -15,7 +15,7 @@
@@ -121,6 +121,20 @@ + +