From: Laurent Mazet Date: Wed, 6 May 2020 22:42:45 +0000 (+0200) Subject: remove arrow function and useless variable newLangName X-Git-Url: https://secure.softndesign.org/git/?a=commitdiff_plain;h=55129404d12156e12810a4bd9e54c84d1dc6d741;p=trivabble.git remove arrow function and useless variable newLangName --- diff --git a/public/trivabble.js b/public/trivabble.js index d03ece0..2ece85b 100644 --- a/public/trivabble.js +++ b/public/trivabble.js @@ -1525,22 +1525,21 @@ 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; }