function show(id){ document.getElementById(id).style.display = "block"; } function hide(id){ document.getElementById(id).style.display = "none"; } function getUserName(){ if (userName == "") { userName = document.getElementById("nickname").value; } return userName; } function resetMenu(){ const children = document.getElementById("menu").children; Array.from(children).forEach(child => { if (child.tagName == "DIV") { child.style.display = "none"; } }); } function setText(id, text){ document.getElementById(id).innerHTML = text; } function playLocal(){ location.href = "./local.html"; } function createGame(){ if(getUserName() == ""){ alert("musíš zadat přezdívku"); return; } setText("loaderText", "Zakládám hru"); hide("main-menu"); show("loader"); socket.emit("createGameRequest", {userName}, (response) => { if(response.status == "success"){ hide("loader"); show("lobby"); }else{ alert("fck"); } }); } function joinWithCode(){ if(getUserName() == ""){ alert("musíš zadat přezdívku"); return; } hide("main-menu"); show("code-entry"); } function backToMainMenu(){ resetMenu(); show("main-menu"); } show("main-menu"); hide("game");