Skip to content

Commit

Permalink
remove hardcoded string from form.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
hrfee committed Oct 30, 2020
1 parent d64d5c1 commit 0f4e773
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions ts/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,18 @@ var defaultPwValStrings: pwValStrings = {
}
}

const toggleSpinner = (): void => {
const toggleSpinner = (ogText?: string): string => {
const submitButton = document.getElementById('submitButton') as HTMLButtonElement;
if (document.getElementById('createAccountSpinner')) {
submitButton.innerHTML = `<span>Create Account</span>`;
submitButton.innerHTML = ogText ? ogText : `<span>Create Account</span>`;
submitButton.disabled = false;
return "";
} else {
let ogText = submitButton.innerHTML;
submitButton.innerHTML = `
<span id="createAccountSpinner" class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>Creating...
`;
return ogText;
}
};

Expand Down Expand Up @@ -84,15 +87,15 @@ var code = window.location.href.split('/').pop();
if (el) {
el.remove();
}
toggleSpinner();
const ogText = toggleSpinner();
let send: Object = serializeForm('accountForm');
send["code"] = code;
if (!window.usernameEnabled) {
send["email"] = send["username"];
}
_post("/newUser", send, function (): void {
if (this.readyState == 4) {
toggleSpinner();
toggleSpinner(ogText);
let data: Object = this.response;
const errorGiven = ("error" in data)
if (errorGiven || data["success"] === false) {
Expand Down

0 comments on commit 0f4e773

Please sign in to comment.