added style for select
This commit is contained in:
parent
e975598a40
commit
c0a645b4e5
6 changed files with 268 additions and 24 deletions
|
|
@ -4364,19 +4364,41 @@ async function switchSettingsTab(tabName) {
|
|||
}
|
||||
|
||||
async function populateLanguageDropdown() {
|
||||
let sel = document.getElementById("settings-language");
|
||||
if (!sel) return;
|
||||
let container = document.getElementById("settings-language");
|
||||
let optionsContainer = document.getElementById("settings-language-options");
|
||||
let display = document.getElementById("settings-language-display");
|
||||
if (!container || !optionsContainer || !display) return;
|
||||
try {
|
||||
let path = window.location.pathname.replace("/login/index.html", "/").replace("index.html", "");
|
||||
let res = await fetchAsync(`${path}blah/index.json`);
|
||||
let json = JSON.parse(res);
|
||||
sel.innerHTML = "";
|
||||
optionsContainer.innerHTML = "";
|
||||
|
||||
window._langDropdownListener = window._langDropdownListener || ((e) => {
|
||||
let cont = document.getElementById("settings-language");
|
||||
if (cont && !cont.contains(e.target)) {
|
||||
cont.classList.remove('open');
|
||||
}
|
||||
});
|
||||
document.removeEventListener('click', window._langDropdownListener);
|
||||
document.addEventListener('click', window._langDropdownListener);
|
||||
|
||||
for (let code in json) {
|
||||
let opt = document.createElement("option");
|
||||
opt.value = code;
|
||||
opt.textContent = json[code].native + " (" + json[code].english + ")";
|
||||
if (code === lang) opt.selected = true;
|
||||
sel.appendChild(opt);
|
||||
let opt = document.createElement("div");
|
||||
opt.className = "custom-select-option";
|
||||
let text = json[code].native + " (" + json[code].english + ")";
|
||||
opt.textContent = text;
|
||||
if (code === lang) {
|
||||
opt.classList.add("selected");
|
||||
display.textContent = text;
|
||||
display.classList.remove("blah");
|
||||
}
|
||||
opt.onclick = () => {
|
||||
display.textContent = text;
|
||||
container.classList.remove("open");
|
||||
changeLanguage(code);
|
||||
};
|
||||
optionsContainer.appendChild(opt);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Failed to load languages", e);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue