lang: improved, Home view translation

This commit is contained in:
AdrienLSH
2024-01-29 10:50:18 +01:00
parent a8f1cccae3
commit 18c4ca719b
5 changed files with 64 additions and 23 deletions

View File

@ -48,9 +48,11 @@ const navigateTo = async (uri) => {
}
};
const reloadView = async _ => renderView(lastView);
async function renderView(view)
{
let content = await view.getHtml();
let content = await view?.getHtml();
if (content == null)
return 1;
@ -141,12 +143,19 @@ document.addEventListener("DOMContentLoaded", async () => {
//Languages
Array.from(document.getElementById('languageSelector').children).forEach(el => {
el.onclick = _ => client.lang.changeLanguage(el.value);
el.onclick = async _ => {
if (await client.lang.changeLanguage(el.value))
return;
document.querySelector('#languageSelector > .active')?.classList.remove('active');
el.classList.add('active');
};
});
document.querySelector(`#languageSelector > [value=${client.lang.chosenLang}]`)
?.classList.add('active');
await client.isAuthentificate();
router(location.pathname);
document.querySelector('a[href=\'' + location.pathname + '\']')?.classList.add('active');
});
export { client, navigateTo }
export { client, navigateTo, reloadView }