fixed copy clipboard

This commit is contained in:
Djalim Simaila 2023-01-11 09:20:47 +01:00
parent 6059172c95
commit 3728b2986f
3 changed files with 8 additions and 4 deletions

View File

@ -127,7 +127,8 @@ function joinRoom() {
*/ */
function copyCode() { function copyCode() {
// Get the room code from the displayed text to avoid an extra API call // Get the room code from the displayed text to avoid an extra API call
let roomCode = document.getElementsByClassName("room_code")[0].textContent; let roomCode = getRoomCode();
console.log(roomCode);
if (roomCode == "") { if (roomCode == "") {
alert("Veuillez patientez, le code d'équipe est en cours de génération."); alert("Veuillez patientez, le code d'équipe est en cours de génération.");
} }
@ -295,7 +296,8 @@ function getChallengeModeRoundsCount() {
* @returns the code of the room * @returns the code of the room
*/ */
function getRoomCode() { function getRoomCode() {
gameid = document.getElementById("gameid") gameid = document.getElementById("game_id").value;
console.log(gameid);
return gameid; return gameid;
} }
@ -331,6 +333,8 @@ function initLobby() {
socket.on("playersjoin", (err) => { socket.on("playersjoin", (err) => {
console.log(`Failed to connect to socket: ${err.message}`); console.log(`Failed to connect to socket: ${err.message}`);
}); });
if (hasJoinedRoom()) { if (hasJoinedRoom()) {
displayRoomView(); displayRoomView();
if (isRoomOwner()) { if (isRoomOwner()) {

View File

@ -238,7 +238,7 @@ async function joinGame(){
//alert(value["msg"]); //alert(value["msg"]);
} }
else{ else{
//window.location.href = "/lobby/" + gameid; window.location.href = "/lobby/" + gameid;
} }
}) })
} }

View File

@ -8,6 +8,7 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
</head> </head>
<body class="game_app"> <body class="game_app">
<input type="hidden" id="game_id" name="game_id" value={{gameid}} />
<div class="join_room_view hidden"> <div class="join_room_view hidden">
<h1 class="room_title">Salon</h1> <h1 class="room_title">Salon</h1>
<input type="text" id="game_username" placeholder="Entrez un pseudo" value="" required="required" maxlength="20"> <input type="text" id="game_username" placeholder="Entrez un pseudo" value="" required="required" maxlength="20">
@ -65,6 +66,5 @@
<script src="/static/js/api.js"></script> <script src="/static/js/api.js"></script>
<script src="/static/js/game_common.js"></script> <script src="/static/js/game_common.js"></script>
<script src="/static/js/game_lobby.js"></script> <script src="/static/js/game_lobby.js"></script>
<input type="hidden" id="game_id" name="game_id" value={{gameid}} />
</body> </body>
</html> </html>