|
|
|
@ -45,12 +45,12 @@ function spawnNotification(body, title) {
|
|
|
|
|
*/
|
|
|
|
|
async function submitUsername() {
|
|
|
|
|
let unameInput = document.querySelector('#input-username');
|
|
|
|
|
let username = unameInput.value.replace(/^\s+|\s+$/g, '');
|
|
|
|
|
let username = unameInput.value;
|
|
|
|
|
|
|
|
|
|
if (username.length > 1) {
|
|
|
|
|
if (username.length > 1 && username.length <= 30) {
|
|
|
|
|
return await setUsername(username);
|
|
|
|
|
} else {
|
|
|
|
|
showError('You need to provide a username (minimum 2 characters)!');
|
|
|
|
|
showError('You need to provide a username (min. 2 characters, max. 30)!');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -61,7 +61,8 @@ async function submitUsername() {
|
|
|
|
|
* @returns {Promise<boolean>}
|
|
|
|
|
*/
|
|
|
|
|
async function setUsername(username) {
|
|
|
|
|
let uname = username.substring(0, 30).replace(/[^\w- ;[\]]/g, '');
|
|
|
|
|
username = username.replace(/^\s+|\s+$/g, '');
|
|
|
|
|
let uname = username.replace(/[\n\t👑🌟]|^\s+|\s+$/gu, '');
|
|
|
|
|
if (uname.length === username.length) {
|
|
|
|
|
let response = await postGraphqlQuery(`
|
|
|
|
|
mutation($username:String!) {
|
|
|
|
@ -83,7 +84,7 @@ async function setUsername(username) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
showError('Your username contains illegal characters.');
|
|
|
|
|
showError(`Your username contains illegal characters (${username.replace(uname, '')}).`);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|