From 0f4e77364bd6d9604b20a580ea7ae85d040c6907 Mon Sep 17 00:00:00 2001 From: Harvey Tindall Date: Fri, 30 Oct 2020 23:14:29 +0000 Subject: [PATCH] remove hardcoded string from form.ts --- ts/form.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ts/form.ts b/ts/form.ts index 247c46f..b922c07 100644 --- a/ts/form.ts +++ b/ts/form.ts @@ -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 = `Create Account`; + submitButton.innerHTML = ogText ? ogText : `Create Account`; submitButton.disabled = false; + return ""; } else { + let ogText = submitButton.innerHTML; submitButton.innerHTML = ` Creating... `; + return ogText; } }; @@ -84,7 +87,7 @@ 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) { @@ -92,7 +95,7 @@ var code = window.location.href.split('/').pop(); } _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) {