impr: update title on page change

This commit is contained in:
Miodec 2023-09-27 11:16:34 +01:00
parent bebf7b6f52
commit cf1c93f551
4 changed files with 20 additions and 2 deletions

View file

@ -74,6 +74,14 @@ export async function change(
AdController.reinstate();
},
async () => {
if (nextPage.name === "test") {
Misc.updateTitle();
} else {
Misc.updateTitle(
Misc.capitalizeFirstLetterOfEachWord(nextPage.name) +
" | Monkeytype"
);
}
Focus.set(false);
ActivePage.set(nextPage.name);
previousPage?.afterHide();

View file

@ -14,7 +14,6 @@ import * as FunboxList from "./test/funbox/funbox-list";
import Konami from "konami";
if (Misc.isLocalhost()) {
$("head title").text("localhost");
$("footer .currentVersion .text").text("localhost");
$("body").prepend(
`<a class='button configureAPI' href='http://localhost:5005/configure/' target='_blank' aria-label="Configure API" data-balloon-pos="right"><i class="fas fa-fw fa-server"></i></a>`

View file

@ -1668,4 +1668,15 @@ export function reloadAfter(seconds: number): void {
}, seconds * 1000);
}
export function updateTitle(title?: string): void {
const local = isLocalhost() ? "localhost - " : "";
if (!title) {
document.title =
local + "Monkeytype | A minimalistic, customizable typing test";
} else {
document.title = local + title;
}
}
// DO NOT ALTER GLOBAL OBJECTSONSTRUCTOR, IT WILL BREAK RESULT HASHES

View file

@ -33,12 +33,12 @@
<%= compilation.assets["html/header.html"].source() %>
<main style="height: 100%">
<%= compilation.assets["html/pages/loading.html"].source() %> <%=
compilation.assets["html/pages/test.html"].source() %> <%=
compilation.assets["html/pages/about.html"].source() %> <%=
compilation.assets["html/pages/settings.html"].source() %> <%=
compilation.assets["html/pages/login.html"].source() %> <%=
compilation.assets["html/pages/account.html"].source() %> <%=
compilation.assets["html/pages/profile.html"].source() %> <%=
compilation.assets["html/pages/test.html"].source() %> <%=
compilation.assets["html/pages/404.html"].source() %>
</main>