${playerHTML}
@@ -72,6 +73,17 @@ class LobbyHandler {
`;
});
+ const codeText = document.getElementById("code");
+ codeText.addEventListener("click", () => {
+ codeText.innerText = "Kopiert!"
+
+ setTimeout(() => {
+ codeText.innerText = this.code;
+ }, 1500);
+
+ navigator.clipboard.writeText(this.code);
+ })
+
this.errorMsg.style.display = "none";
}
diff --git a/frontend/dashboard/lobby/scripts/index.js b/frontend/dashboard/lobby/scripts/index.js
index 85be967..3f80909 100644
--- a/frontend/dashboard/lobby/scripts/index.js
+++ b/frontend/dashboard/lobby/scripts/index.js
@@ -1,12 +1,13 @@
import LobbyHandler from "./Handler/LobbyHandler.js";
-class ServerConnectionManager{
- constructor(){
+class ServerConnectionManager {
+ constructor() {
/**@type {import("../../../../backend/node_modules/socket.io-client".Socket} für Autocompletions VSC*/
this.socket = io(`http://${window.location.hostname}:${window.location.port}`);
+ this.lobbyContainer = document.getElementById("mainDiv");
this.createBtn = document.getElementById("createBtn");
- this.joinBtn = document.getElementById("joinBtn");
+ this.joinOverlayBtn = document.getElementById("joinOverlayBtn");
this.leaveBtn = document.getElementById("leaveBtn");
this.lobbyHandler = new LobbyHandler(this.socket);
@@ -15,7 +16,7 @@ class ServerConnectionManager{
this.addButtonHandler();
}
- basicSetup(){
+ basicSetup() {
this.socket.emit("hereForLobby");
this.socket.on("connect", () => {
@@ -33,15 +34,40 @@ class ServerConnectionManager{
})
}
- addButtonHandler(){
+ addButtonHandler() {
this.createBtn.addEventListener("click", () => {
this.lobbyHandler.handleCreateClick();
});
- this.joinBtn.addEventListener("click", () => {
- this.lobbyHandler.handleJoinClick();
- });
-
+ this.joinOverlayBtn.addEventListener("click", () => {
+ this.lobbyContainer.innerHTML = `
+
+
+
Der Spiel-Code:
+
+
+
+
+ `
+
+ document.getElementById("joinBtn").addEventListener("click", () => {
+ const code = document.getElementById("codeInp").value;
+ this.lobbyHandler.handleJoinClick(code);
+ })
+ })
+
this.leaveBtn.addEventListener("click", () => {
this.socket.disconnect();
window.location.pathname = "/dashboard";
diff --git a/frontend/dashboard/lobby/style.css b/frontend/dashboard/lobby/style.css
index f71b1fe..3652f1d 100644
--- a/frontend/dashboard/lobby/style.css
+++ b/frontend/dashboard/lobby/style.css
@@ -2,7 +2,7 @@ button {
width: 350px;
}
-#joinBtn{
+#joinOverlayBtn{
background-color: rgb(0, 119, 255);
}
@@ -63,4 +63,13 @@ button {
#player2{
background-color: rgba(0, 89, 255, 0.377);
border-radius: 0 0 10px 10px;
+}
+
+.formSection h2{
+ text-align: center;
+
+}
+
+#codeInp{
+ text-align: center;
}
\ No newline at end of file