Skip to content

Commit

Permalink
Changed color for main page but also added JSON function to stringify…
Browse files Browse the repository at this point in the history
… the user nick
  • Loading branch information
stealthcamaro committed Apr 25, 2024
1 parent f8415f1 commit 9494ed0
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
.content {
text-align: center;
position: relative;
color: #ddd;
}

.lobbyScreen {
Expand Down Expand Up @@ -273,10 +274,9 @@ <h1>TheWordSearchGame</h1>

<p>Enter your user name</p>

<form id="userInfo">
<input type="text" id="nick" name="nick"><br><br>
<button class="enter-button" type="button" onclick="showLobby()">Enter Lobby</button>
</form>
<input type="text" id="nick"><br><br>
<button class="enter-button" type="button" onclick="userName(); showLobby();">Enter Lobby</button>

</div>

<div class="lobbyScreen" id="lobby">
Expand Down Expand Up @@ -384,14 +384,25 @@ <h1>HappySearching!</h1>
// connection.send(JSON.stringify(position));
// }

function userName(){
var username = document.getElementById("nick").value;
if(username == ""){
alert('You must enter a user name to enter the game lobby');
return;
}

connection.send(JSON.stringify({name: username}));
}

function showLobby() {
U = new UserEvent();
U.playerIdx = "userInfo";
// var username =
// U = new UserEvent();
// U.playerIdx = "userInfo";
document.querySelector(".content").style.display = "none";
document.getElementById("lobby").style.display = "flex";

connection.send(JSON.stringify(U));
console.log(JSON.stringify(U));
// connection.send(JSON.stringify(U));
// console.log(JSON.stringify(U));
}

function backToHome() {
Expand Down

0 comments on commit 9494ed0

Please sign in to comment.