1
0
Fork 0

Allow changing language without reloading page.

This commit is contained in:
Kitteh 2021-05-12 15:32:21 +01:00
parent 6914edbeb7
commit 2d0c1d7689
3 changed files with 8 additions and 8 deletions

View file

@ -5,9 +5,9 @@ import { makeElement } from "../htmlUtils";
import { pageState } from "../globalPageState"; import { pageState } from "../globalPageState";
import i18next from "i18next"; import i18next from "i18next";
export function TitleBar(): HTMLElement { export function NavBar(): HTMLElement {
return makeElement({ return makeElement({
id: "titleBar", id: "navBar",
tag: "nav", tag: "nav",
class: ["uk-navbar", "uk-navbar-container"], class: ["uk-navbar", "uk-navbar-container"],
children: [ children: [
@ -55,7 +55,7 @@ export function TitleBar(): HTMLElement {
}) })
} }
export function reloadTitleBar(): void { export function reloadNavBar(): void {
document.querySelector(".titleBar").replaceWith(TitleBar()); document.querySelector("#navBar").replaceWith(NavBar());
} }

View file

@ -25,7 +25,7 @@ import { getSealStatus } from "./api/sys/getSealStatus";
import { makeElement } from "./htmlUtils"; import { makeElement } from "./htmlUtils";
import { pageState } from "./globalPageState"; import { pageState } from "./globalPageState";
import { playground } from "./playground"; import { playground } from "./playground";
import { TitleBar } from "./elements/TitleBar"; import { NavBar } from "./elements/NavBar";
// Translations // Translations
import { formatDistance } from './formatDistance'; import { formatDistance } from './formatDistance';
@ -41,7 +41,7 @@ declare global {
function onLoad(): void { function onLoad(): void {
document.body.innerHTML = ""; document.body.innerHTML = "";
document.body.appendChild(TitleBar()); document.body.appendChild(NavBar());
document.body.appendChild(makeElement({ document.body.appendChild(makeElement({
tag: "div", tag: "div",
class: ["uk-container", "uk-container-medium", "uk-align-center"], class: ["uk-container", "uk-container-medium", "uk-align-center"],

View file

@ -4,7 +4,7 @@ import { changePage, setPageContent } from "../pageUtils";
import { makeElement } from "../htmlUtils"; import { makeElement } from "../htmlUtils";
import { pageState } from "../globalPageState"; import { pageState } from "../globalPageState";
import i18next from 'i18next'; import i18next from 'i18next';
import { reloadTitleBar } from "../elements/TitleBar"; import { reloadNavBar } from "../elements/NavBar";
// @ts-ignore // @ts-ignore
import translations from "../translations/index.mjs"; import translations from "../translations/index.mjs";
@ -59,7 +59,7 @@ export class SetLanguagePage extends Page {
console.log(pageState.language); console.log(pageState.language);
void i18next.changeLanguage(language).then((t) => { void i18next.changeLanguage(language).then((t) => {
pageState.pageDirection = t("language_direction"); pageState.pageDirection = t("language_direction");
reloadTitleBar(); reloadNavBar();
changePage("HOME"); changePage("HOME");
}); });
}); });