diff --git a/html/setup.html b/html/setup.html index 404591a..31bd42b 100644 --- a/html/setup.html +++ b/html/setup.html @@ -557,12 +557,13 @@
{{ .lang.EndPage.finished }} -

{{ .lang.EndPage.restartMessage }} {{ .lang.EndPage.urlChangedNotice }}

+

{{ .lang.EndPage.moreFeatures }} {{ .lang.EndPage.restartReload }} {{ .lang.EndPage.ifFailedLoad }}

diff --git a/lang/common/en-us.json b/lang/common/en-us.json index 34955a7..19f285d 100644 --- a/lang/common/en-us.json +++ b/lang/common/en-us.json @@ -41,7 +41,9 @@ "delete": "Delete", "myAccount": "My Account", "referrals": "Referrals", - "inviteRemainingUses": "Remaining uses" + "inviteRemainingUses": "Remaining uses", + "internal": "Internal", + "external": "External" }, "notifications": { "errorLoginBlank": "The username and/or password were left blank.", diff --git a/lang/setup/en-us.json b/lang/setup/en-us.json index 55c13e7..b2ba28e 100644 --- a/lang/setup/en-us.json +++ b/lang/setup/en-us.json @@ -33,8 +33,9 @@ }, "endPage": { "finished": "Finished!", - "restartMessage": "Features like Discord/Telegram/Matrix bots, custom Markdown messages, and a user-accessible \"My Account\" page can be found in Settings, so make sure to give it a browse. Click below to restart, then refresh the page.", - "urlChangedNotice": "If you've changed the host, port, subfolder etc. that jfa-go is hosted on, check the URL is right.", + "moreFeatures": "Tons more features like Discord/Telegram/Matrix bots and custom Markdown messages can be found in Settings, so make sure to give it a browse.", + "restartReload": "Click below to restart, then access jfa-go at one of the given internal/external URLs.", + "ifFailedLoad": "If it doesn't load, check the application's logs for any clues as to why.", "refreshPage": "Refresh" }, "language": { diff --git a/ts/setup.ts b/ts/setup.ts index d987060..61470b1 100644 --- a/ts/setup.ts +++ b/ts/setup.ts @@ -365,6 +365,33 @@ const checkTheme = () => { settings["ui"]["theme"].onchange = checkTheme; checkTheme(); +const fixFullURL = (v: string): string => { + if (!(v.startsWith("http://")) && !(v.startsWith("https://"))) { + v = "http://" + v; + } + return v; +}; + +const formatSubpath = (v: string): string => { + if (v == "/") return ""; + if (v.charAt(-1) == "/") { v = v.slice(0, -1); } + return v; +} + +const constructNewURLs = (): string[] => { + let local = settings["ui"]["host"].value + ":" + settings["ui"]["port"].value; + if (settings["ui"]["url_base"].value != "") { + local += formatSubpath(settings["ui"]["url_base"].value); + } + local = fixFullURL(local); + let remote = settings["ui"]["jfa_url"].value; + if (remote == "") { + return [local]; + } + remote = fixFullURL(remote); + return [local, remote]; +} + const restartButton = document.getElementById("restart") as HTMLSpanElement; const serialize = () => { toggleLoader(restartButton); @@ -409,12 +436,16 @@ const serialize = () => { } restartButton.parentElement.querySelector("span.back").classList.add("unfocused"); restartButton.classList.add("unfocused"); - const refresh = document.getElementById("refresh") as HTMLSpanElement; - refresh.classList.remove("unfocused"); - refresh.onclick = () => { - let host = window.location.href.split("#")[0].split("?")[0] + settings["ui"]["url_base"].value; - window.location.href = host; - }; + const refreshURLs = constructNewURLs(); + const refreshButtons = [document.getElementById("refresh-internal") as HTMLAnchorElement, document.getElementById("refresh-external") as HTMLAnchorElement]; + ["internal", "external"].forEach((urltype, i) => { + const button = refreshButtons[i]; + button.classList.remove("unfocused"); + button.href = refreshURLs[i]; + button.innerHTML = `${urltype.charAt(0).toUpperCase() + urltype.slice(1)}:${button.href}`; + // skip external if it isn't set + if (refreshURLs.length == 1) return; + }); } }, true, (req: XMLHttpRequest) => { if (req.status == 0) {