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 = { ...@@ -77,17 +77,13 @@ window.App = {
} }
let username; let username;
// const jwt = getCookie("jwt"); const jwt = getCookie("jwt");
// if (jwt) { if (jwt) {
// const data = parseJwt(jwt); const data = parseJwt(jwt);
// username = data.typ.name; username = data.typ.name;
// alert("Your username is: " + username); }
// } else {
username = qs.name; username = promptForName(username); // promptForName is blocking
if (!username) {
username = promptForName(username); // promptForName is blocking
}
// }
const myNametag = document.querySelector("#player-rig .nametag"); const myNametag = document.querySelector("#player-rig .nametag");
myNametag.setAttribute("text", "value", username); myNametag.setAttribute("text", "value", username);
......
...@@ -166,8 +166,10 @@ export function generateName() { ...@@ -166,8 +166,10 @@ export function generateName() {
return name.replace(/^./, name[0].toUpperCase()); return name.replace(/^./, name[0].toUpperCase());
} }
export function promptForName() { export function promptForName(username) {
var username = generateName(); if (!username)
username = generateName();
do { do {
username = prompt("Choose a username", username); username = prompt("Choose a username", username);
} while (!(username && username.length)); } 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