1
0
mirror of https://github.com/hrfee/jfa-go.git synced 2024-12-22 17:10:10 +00:00

lang: make loadLangSelector respect existing params

This commit is contained in:
Harvey Tindall 2022-01-01 02:54:02 +00:00
parent dd5eecf9f9
commit a3a22d353c
Signed by: hrfee
GPG Key ID: BBC65952848FB1A2

View File

@ -68,6 +68,8 @@ export const loadLangSelector = (page: string) => {
t12.checked = false;
}
}
let queryString = new URLSearchParams(window.location.search);
if (queryString.has("lang")) queryString.delete("lang");
_get("/lang/" + page, null, (req: XMLHttpRequest) => {
if (req.readyState == 4) {
if (req.status != 200) {
@ -77,7 +79,9 @@ export const loadLangSelector = (page: string) => {
const list = document.getElementById("lang-list") as HTMLDivElement;
let innerHTML = '';
for (let code in req.response) {
innerHTML += `<a href="?lang=${code}" class="button w-100 al justify-start ~neutral mb-2 lang-link">${req.response[code]}</a>`;
queryString.set("lang", code);
innerHTML += `<a href="?${queryString.toString()}" class="button w-100 al justify-start ~neutral mb-2 lang-link">${req.response[code]}</a>`;
queryString.delete("lang");
}
list.innerHTML = innerHTML;
}