diff --git a/html/form-base.html b/html/form-base.html index 02ad5a6..cb0bb3c 100644 --- a/html/form-base.html +++ b/html/form-base.html @@ -5,6 +5,7 @@ window.invalidPassword = "{{ .strings.reEnterPasswordInvalid }}"; window.URLBase = "{{ .urlBase }}"; window.code = "{{ .code }}"; + window.language = "{{ .langName }}"; window.messages = JSON.parse({{ .notifications }}); window.confirmation = {{ .confirmation }}; window.userExpiryEnabled = {{ .userExpiry }}; diff --git a/ts/form.ts b/ts/form.ts index db10abd..7cd775d 100644 --- a/ts/form.ts +++ b/ts/form.ts @@ -1,5 +1,5 @@ import { Modal } from "./modules/modal.js"; -import { _get, _post, toggleLoader } from "./modules/common.js"; +import { _get, _post, toggleLoader, toDateString } from "./modules/common.js"; import { loadLangSelector } from "./modules/lang.js"; interface formWindow extends Window { @@ -46,7 +46,7 @@ if (window.userExpiryEnabled) { time.setDate(time.getDate() + window.userExpiryDays); time.setHours(time.getHours() + window.userExpiryHours); time.setMinutes(time.getMinutes() + window.userExpiryMinutes); - messageEl.textContent = window.userExpiryMessage.replace("{date}", time.toDateString() + " " + time.toLocaleTimeString()); + messageEl.textContent = window.userExpiryMessage.replace("{date}", toDateString(time)); setTimeout(calculateTime, 1000); }; calculateTime(); diff --git a/ts/modules/common.ts b/ts/modules/common.ts index d2d5d16..05d20a8 100644 --- a/ts/modules/common.ts +++ b/ts/modules/common.ts @@ -15,12 +15,14 @@ export function toDateString(date: Date): string { hour: "2-digit", minute: "2-digit" }; - if (t12.checked) { - args1["hour12"] = true; - args2["hour12"] = true; - } else if (t24.checked) { - args1["hour12"] = false; - args2["hour12"] = false; + if (t12 && t24) { + if (t12.checked) { + args1["hour12"] = true; + args2["hour12"] = true; + } else if (t24.checked) { + args1["hour12"] = false; + args2["hour12"] = false; + } } return date.toLocaleDateString(locale, args1) + " " + date.toLocaleString(locale, args2); } diff --git a/views.go b/views.go index 3840130..ebeffc0 100644 --- a/views.go +++ b/views.go @@ -221,6 +221,7 @@ func (app *appContext) InviteProxy(gc *gin.Context) { "userExpiryHours": inv.UserHours, "userExpiryMinutes": inv.UserMinutes, "userExpiryMessage": app.storage.lang.Form[lang].Strings.get("yourAccountIsValidUntil"), + "langName": lang, }) }