|
|
|
@ -33,6 +33,19 @@ async function submitUsername() {
|
|
|
|
|
let username = unameInput.value.replace(/^\s+|\s+$/g, '');
|
|
|
|
|
|
|
|
|
|
if (username.length > 1) {
|
|
|
|
|
await setUsername(username);
|
|
|
|
|
} else {
|
|
|
|
|
showError('You need to provide a username (minimum 2 characters)!');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the username for a user
|
|
|
|
|
* @param username {String} - the username
|
|
|
|
|
* @returns {Promise<boolean>}
|
|
|
|
|
*/
|
|
|
|
|
async function setUsername(username) {
|
|
|
|
|
let response = await postGraphqlQuery(`
|
|
|
|
|
mutation($username:String!) {
|
|
|
|
|
bingo {
|
|
|
|
@ -49,10 +62,6 @@ async function submitUsername() {
|
|
|
|
|
console.error(response);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
showError('You need to provide a username (minimum 2 characters)!');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -158,15 +167,19 @@ async function executeCommand(message) {
|
|
|
|
|
addChatMessage({content: content, htmlContent: content, type: 'INFO'});
|
|
|
|
|
}
|
|
|
|
|
let jsStyle = document.querySelector('#js-style');
|
|
|
|
|
message = message.replace(/\s/g, '');
|
|
|
|
|
switch(message) {
|
|
|
|
|
message = message.replace(/\s+$/g, '');
|
|
|
|
|
let command = /(\/\w+) ?(.*)?/g.exec(message);
|
|
|
|
|
if (command && command.length >= 2) {
|
|
|
|
|
switch(command[1]) {
|
|
|
|
|
case '/help':
|
|
|
|
|
reply(`
|
|
|
|
|
<b>Commands: </b><br>
|
|
|
|
|
<br><b>Commands: </b><br>
|
|
|
|
|
/help - shows this help <br>
|
|
|
|
|
/hideinfo - hides all info messages <br>
|
|
|
|
|
/showinfo - shows all info messages <br>
|
|
|
|
|
/ping - shows the current ping <br>
|
|
|
|
|
/username {Username} - sets the username <br><br>
|
|
|
|
|
Admin commands: <br>
|
|
|
|
|
/abortround - aborts the current round <br>
|
|
|
|
|
`);
|
|
|
|
|
break;
|
|
|
|
@ -182,6 +195,14 @@ async function executeCommand(message) {
|
|
|
|
|
case '/abortround':
|
|
|
|
|
reply(await setRoundFinished());
|
|
|
|
|
break;
|
|
|
|
|
case '/username':
|
|
|
|
|
if (command[2]) {
|
|
|
|
|
await setUsername(command[2]);
|
|
|
|
|
reply(`Your username is <b>${command[2]}</b> now.`)
|
|
|
|
|
} else {
|
|
|
|
|
reply('You need to provide a username');
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
reply('Unknown command');
|
|
|
|
|
break;
|
|
|
|
@ -189,6 +210,7 @@ async function executeCommand(message) {
|
|
|
|
|
let chatContent = document.querySelector('#chat-content');
|
|
|
|
|
chatContent.scrollTop = chatContent.scrollHeight;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sends a message to the chat
|
|
|
|
|