Skip to content

Commit

Permalink
edits made to index_1.html
Browse files Browse the repository at this point in the history
  • Loading branch information
muktar1907 committed Apr 27, 2024
1 parent ba79098 commit 3a4a150
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
9 changes: 6 additions & 3 deletions html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,9 @@ <h2>Timer: <span id="timer">30</span> seconds</h2>
if("grid" in messageData)
{
//store all letters inside grid variable
grid=JSON.parse(messageData.grid);

grid=JSON.parse(messageData.grid);
}


if(nick==="")
{
console.log("Player: "+messageData.player);
Expand All @@ -169,6 +167,11 @@ <h2>Timer: <span id="timer">30</span> seconds</h2>
console.log("GameId: "+ gameId);
}

if("ready" in messageData && messageData.ready==="true")
{
generateGrid();
}


}
else if(type==="UpdateGame")
Expand Down
24 changes: 14 additions & 10 deletions html/index_1.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ <h2>Leaderboard</h2>
</table>
</div>

<!-- Timer section -->
<div id="timerSection">
<h2>Timer: <span id="timer">30</span> seconds</h2>
</div>


<!--Grid table-->

<div>
<input type="button" value="Generate Grid" onclick="generateGrid()"/>
<div id="Game">
<!-- Timer section -->
<div id="timerSection">
<h2>Timer: <span id="timer">30</span> seconds</h2>
</div>
<table id="wordGrid">

</table>
Expand Down Expand Up @@ -158,7 +158,10 @@ <h2>Timer: <span id="timer">30</span> seconds</h2>
console.log("GameId: "+ gameId);
}


if("ready" in messageData && messageData.ready==="true")
{
generateGrid();
}
}
else if(type==="UpdateGame")
{
Expand Down Expand Up @@ -275,7 +278,7 @@ <h2>Timer: <span id="timer">30</span> seconds</h2>
//too big may have to do smaller grid or smaller cells
function generateGrid()
{
const tbl = document.createElement("table");
const tbl = document.getElementById("wordGrid");
const tblBody = document.createElement("tbody");
//create cells

Expand All @@ -300,9 +303,10 @@ <h2>Timer: <span id="timer">30</span> seconds</h2>
tblBody.appendChild(row);
}
tbl.appendChild(tblBody);
document.body.appendChild(tbl);
myDiv=document.getElementById("Game");
myDiv.appendChild(tbl);
tbl.setAttribute("border","1.5");
eventListener();
//eventListener();

}
function eventListener()
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/uta/cse3310/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,12 @@ public void messageHandler(Gson gson, String jsonString, WebSocket conn)
}

jsonObject.addProperty("gameId",G.getGameID());
//if enough players joined, automatically start game
if(G.getPlayersList().size()==G.getGameMode())
{
jsonObject.addProperty("ready","true");
}

//send back to all connections

broadcast(jsonObject.toString());
Expand Down

0 comments on commit 3a4a150

Please sign in to comment.