fix navigation with URL base set

This commit is contained in:
Harvey Tindall 2021-02-05 13:31:56 +00:00
parent 23fecb16b2
commit 6691ae27f4
Signed by: hrfee
GPG Key ID: BBC65952848FB1A2
4 changed files with 11 additions and 10 deletions

View File

@ -292,6 +292,6 @@
</div>
</div>
</div>
<script src="js/admin.js" type="module"></script>
<script src="{{ .urlBase }}/js/admin.js" type="module"></script>
</body>
</html>

View File

@ -84,23 +84,24 @@ window.tabs.addTab("accounts", null, accounts.reload);
window.tabs.addTab("settings", null, settings.reload);
for (let tab of ["invites", "accounts", "settings"]) {
if (window.location.pathname == "/" + tab) {
if (window.location.pathname == window.URLBase + "/" + tab) {
window.tabs.switch(tab, true);
}
}
if (window.location.pathname == "/") {
if (window.location.pathname == window.URLBase + "/") {
window.tabs.switch("invites", true);
}
document.addEventListener("tab-change", (event: CustomEvent) => {
const urlParams = new URLSearchParams(window.location.search);
const lang = urlParams.get('lang');
let tab = "/" + event.detail;
if (tab == "/invites") {
if (window.location.pathname == "/") {
tab = "/";
} else { tab = "../"; }
let tab = window.URLBase + "/" + event.detail;
if (tab == window.URLBase + "/invites") {
if (window.location.pathname == window.URLBase + "/") {
tab = window.URLBase + "/";
} else if (window.URLBase) { tab = window.URLBase; }
else { tab = "../"; }
}
if (lang) {
tab += "?lang=" + lang

View File

@ -45,7 +45,7 @@ export class DOMInvite implements Invite {
for (let split of ["#", "?"]) {
codeLink = codeLink.split(split)[0];
}
this._codeLink = codeLink + "invite/" + code;
this._codeLink = codeLink + window.URLBase + "invite/" + code;
const linkEl = this._codeArea.querySelector("a") as HTMLAnchorElement;
if (this.label == "") {
linkEl.textContent = code.replace(/-/g, '-');

View File

@ -36,7 +36,7 @@ func (app *appContext) pushResources(gc *gin.Context, admin bool) {
if admin {
toPush := []string{"/js/admin.js", "/js/theme.js", "/js/lang.js", "/js/modal.js", "/js/tabs.js", "/js/invites.js", "/js/accounts.js", "/js/settings.js", "/js/profiles.js", "/js/common.js"}
for _, f := range toPush {
if err := pusher.Push(f, nil); err != nil {
if err := pusher.Push(app.URLBase+f, nil); err != nil {
app.debug.Printf("Failed HTTP2 ServerPush of \"%s\": %+v", f, err)
}
}