function createLangBoardSelect(langName) {
- let newLangName = [];
- for (const k in langName) {
- newLangName.push({key: k, value: _(langName[k])});
- }
- newLangName = newLangName.sort((a, b) => ((a.value > b.value) ? 1 : ((b.value > a.value) ? -1 : 0)));
-
const select = document.getElementById("board-lang");
for (let i = select.options.length - 1; i >=0; i--) {
select.remove(i);
}
- for (let i = 0; i < newLangName.length; i++) {
- select.add(new Option(newLangName[i].value, newLangName[i].key));
+ for (const key in langName) {
+ if (Object.prototype.isPrototypeOf.call(langName, key)) {
+ select.add(new Option(_(langName[key]), key));
+ }
}
+ Array.prototype.sort.call(select.options,
+ function(a, b) {return (a.textContent > b.textContent) ? 1 : ((b.textContent > a.textContent) ? -1 : 0);});
+
select.value = localStorage.trivabbleBoardLang;
}