Skip to content

Commit

Permalink
commit1
Browse files Browse the repository at this point in the history
  • Loading branch information
ThiML10 committed Apr 27, 2024
1 parent 981f405 commit 9aae55f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
30 changes: 30 additions & 0 deletions html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>The Word Search Game Lobby</title>
<link rel="stylesheet" href="style_lobby.css">

<style>
#lobbyContainer {
display: none;
}
</style>
</head>



<body>
<!-- welcome -->
<div id="welcomeContainer">
Expand Down Expand Up @@ -99,6 +107,7 @@ <h2>Timer: <span id="timer">30</span> seconds</h2>
</div>
</body>
<script>

var socket = new WebSocket("ws://"+ window.location.hostname+":9105");

class Player
Expand Down Expand Up @@ -426,5 +435,26 @@ <h2>Timer: <span id="timer">30</span> seconds</h2>
}


document.getElementById('nickForm').addEventListener('submit', function(event) {
event.preventDefault(); // Prevent the default form submission
var nickInput = document.getElementById('nickInput').value.trim();

// Simulate a check for nickname uniqueness
if (nickInput && isNickUnique(nickInput)) { // Implement isNickUnique() to check the nickname
document.getElementById('welcomeContainer').style.display = 'none';
document.getElementById('lobbyContainer').style.display = 'block';
} else {
document.getElementById('error').style.display = 'block';
document.getElementById('error').textContent = 'Nickname already taken, please try another one.';
}
});

function isNickUnique(nick) {
// This function should ideally make an AJAX call to the server to check nickname uniqueness
return true; // Placeholder return
}



</script>

4 changes: 4 additions & 0 deletions html/lobby.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,7 @@ document.addEventListener("DOMContentLoaded", function() {
});
}
});




0 comments on commit 9aae55f

Please sign in to comment.