You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
1.4 KiB
70 lines
1.4 KiB
|
|
|
|
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");
|
|
|
|
|