diff --git a/src/index.js b/src/index.js index 2a1aa283c10cc44361feb1e88cedc8219b1d16f9..bf03ae3699aca7668ed6352c3d166ebf0a8fe535 100644 --- a/src/index.js +++ b/src/index.js @@ -77,17 +77,13 @@ window.App = { } let username; - // const jwt = getCookie("jwt"); - // if (jwt) { - // const data = parseJwt(jwt); - // username = data.typ.name; - // alert("Your username is: " + username); - // } else { - username = qs.name; - if (!username) { - username = promptForName(username); // promptForName is blocking - } - // } + const jwt = getCookie("jwt"); + if (jwt) { + const data = parseJwt(jwt); + username = data.typ.name; + } + + username = promptForName(username); // promptForName is blocking const myNametag = document.querySelector("#player-rig .nametag"); myNametag.setAttribute("text", "value", username); diff --git a/src/utils.js b/src/utils.js index 1363efe6ca91374d4183fe3c554a70c6549f66d2..b37764120a388120c89392fb6b9b97f31dd59578 100644 --- a/src/utils.js +++ b/src/utils.js @@ -166,8 +166,10 @@ export function generateName() { return name.replace(/^./, name[0].toUpperCase()); } -export function promptForName() { - var username = generateName(); +export function promptForName(username) { + if (!username) + username = generateName(); + do { username = prompt("Choose a username", username); } while (!(username && username.length));