Skip to content

Commit

Permalink
feat: Implement JavaScript for Join/Create Room functionality
Browse files Browse the repository at this point in the history
- Added JavaScript to handle joining and creating custom rooms.
- Implemented event listeners for "Join Room" and "Create Room" buttons.
  - "Join Room" redirects to the game page with the entered room ID.
  - "Create Room" redirects to the game page with selected game mode and player count.
  • Loading branch information
TKanX committed Jul 31, 2024
1 parent 04b91be commit 7f8904b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions views/pages/home.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
</div>
</main>
<script>
// Handle Start Game Classic
document.getElementById('start-game-classic').addEventListener('click', () => {
const playerCount = document.getElementById('player-count').value;
window.location.href = `/game/classic/${playerCount}`;
Expand Down
14 changes: 14 additions & 0 deletions views/pages/rooms.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@
</div>
</div>
</main>
<script>
// Handle Join Room
document.getElementById('join-room').addEventListener('click', () => {
const roomId = document.getElementById('room-id').value;
window.location.href = `/game/custom/${roomId}`;
});
// Handle Create Room
document.getElementById('create-room').addEventListener('click', () => {
const gameMode = document.getElementById('game-mode').value;
const playerCount = document.getElementById('player-count').value;
window.location.href = `/game/custom/${gameMode}/${playerCount}`;
});
</script>
</body>

</html>

0 comments on commit 7f8904b

Please sign in to comment.