disable join button on first click

This commit is contained in:
maia tillie arson crimew 2021-12-03 20:37:16 +01:00
parent 7a035c5a98
commit a69f0f7318
3 changed files with 11 additions and 10 deletions

View file

@ -36,7 +36,7 @@
placeholder="123e4567-e89b-12d3-a456-426614174000" placeholder="123e4567-e89b-12d3-a456-426614174000"
required required
/> />
<button>Join</button> <button id="join-session-button">Join</button>
</form> </form>
<p> <p>
@ -52,6 +52,6 @@
</form> </form>
</div> </div>
<script type="module" src="/main.mjs?v=3"></script> <script type="module" src="/main.mjs?v=4"></script>
</body> </body>
</html> </html>

View file

@ -37,6 +37,7 @@ export const setupJoinSessionForm = () => {
const form = document.querySelector("#join-session-form"); const form = document.querySelector("#join-session-form");
const nickname = form.querySelector("#join-session-nickname"); const nickname = form.querySelector("#join-session-nickname");
const sessionId = form.querySelector("#join-session-id"); const sessionId = form.querySelector("#join-session-id");
const button = form.querySelector("#join-session-button");
loadNickname(nickname); loadNickname(nickname);
@ -44,11 +45,11 @@ export const setupJoinSessionForm = () => {
sessionId.value = window.location.hash.substring(1); sessionId.value = window.location.hash.substring(1);
} }
document form.addEventListener("submit", (event) => {
.querySelector("#join-session-form")
.addEventListener("submit", (event) => {
event.preventDefault(); event.preventDefault();
button.disabled = true;
saveNickname(nickname); saveNickname(nickname);
joinSession(nickname.value, sessionId.value); joinSession(nickname.value, sessionId.value);
}); });

View file

@ -1,4 +1,4 @@
import { setupJoinSessionForm } from "./lib/join-session.mjs?v=3"; import { setupJoinSessionForm } from "./lib/join-session.mjs?v=4";
const main = () => { const main = () => {
setupJoinSessionForm(); setupJoinSessionForm();