Made it get the current username when letting you edit it.

This commit is contained in:
Ajay Ramachandran
2019-08-12 23:32:10 -04:00
parent 5445146b56
commit b9091c3a97

View File

@@ -1013,8 +1013,27 @@ function runThePopup() {
//make the options username setting option visible
function setUsernameButton() {
SB.setUsernameContainer.style.display = "none";
SB.setUsername.style.display = "unset";
//get the userID
chrome.storage.sync.get(["userID"], function(result) {
//get username from the server
sendRequestToServer("GET", "/api/getUsername?userID=" + result.userID, function (xmlhttp, error) {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
SB.usernameInput.value = JSON.parse(xmlhttp.responseText).userName;
SB.submitUsername.style.display = "unset";
SB.usernameInput.style.display = "unset";
SB.setUsernameContainer.style.display = "none";
SB.setUsername.style.display = "unset";
} else {
SB.setUsername.style.display = "unset";
SB.submitUsername.style.display = "none";
SB.usernameInput.style.display = "none";
SB.setUsernameStatus.innerText = "Couldn't connect to server. Error code: " + xmlhttp.status;
}
});
});
}
//submit the new username