Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
muktar1907 committed Apr 27, 2024
2 parents e17a416 + 044fc96 commit bd45c42
Show file tree
Hide file tree
Showing 3 changed files with 559 additions and 0 deletions.
50 changes: 50 additions & 0 deletions html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,42 @@
<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">
<h1>Welcome to The Word Search Game</h1>
<form id="nickForm">
<label for="nickInput">Enter your nickname:</label>
<input type="text" id="nickInput" placeholder="Nickname" required>
<button type="submit">Enter Lobby</button>
<p id="error" style="color: red; display: none;">Your nick is already taken, please reenter.</p>
</form>
</div>

<!-- lobby -->

<div id="lobbyContainer">
<div id="userInputSection">
<button id="helpButton">HELP</button>
<button id="standbyButton">PUT ON STANDBY</button>

<!--
<div>
<label for="nickInput">Insert Nick:</label>
<input type="text" id="nickInput" placeholder="Type here">
</div>
-->

<div>
<label for="gameSelect">Game:</label>
<select id="gameSelect">
Expand Down Expand Up @@ -46,6 +72,10 @@ <h1>The Word Search Game</h1>
<div id="gameListSection">

</div>
<script src="lobby.js"></script>




<!-- Leaderboard section -->
<div id="leaderboardContainer">
Expand Down Expand Up @@ -79,6 +109,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 @@ -423,5 +454,24 @@ <h2>Timer: <span id="timer">30</span> seconds</h2>
}


document.getElementById('nickForm').addEventListener('submit', function(event) {
event.preventDefault();
var nickInput = document.getElementById('nickInput').value.trim();

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) {
return true; // Placeholder return
}



</script>

Loading

0 comments on commit bd45c42

Please sign in to comment.