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.

48 lines
1.2 KiB

2 years ago
'use strict';
function socketConnect(){
socket = io("https://" + window.location.hostname + "?game=" + projectName);
}
function createLobby(dom){
if (inputIsValid('create')){
onlineRequestFrontend(dom);
//TODO
}
}
function joinLobby(dom){
if (inputIsValid('join')){
onlineRequestFrontend(dom);
//TODO
}
}
function onlineRequestFrontend(dom){
$(dom).blur();
$(dom).attr('disabled', 'disabled');
if (loader) loader.destroy();
loader = new Loader($('#loader').get(0));
}
function inputIsValid(type){
let valid = true;
$('.error-label').html('');
if (type === 'create'){
if ($('#player-name > input').val() === ''){
valid = false;
$('#player-name > .error-label').html('Please enter a name!');
}
}
if (type === 'join'){
if ($('#player-name > input').val() === ''){
valid = false;
$('#player-name > .error-label').html('Please enter a name!');
}
if ($('#lobby-code > input').val() === ''){
valid = false;
$('#lobby-code > .error-label').html('Please enter your code!');
}
}
return valid;
}