Skip to content
Snippets Groups Projects
Commit 01dab2cb authored by Kevin Lee's avatar Kevin Lee
Browse files

suggest name from ret jwt first (if it exists), but allow user to change it

parent c1239854
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
......@@ -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));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment