From 55129404d12156e12810a4bd9e54c84d1dc6d741 Mon Sep 17 00:00:00 2001 From: Laurent Mazet Date: Thu, 7 May 2020 00:42:45 +0200 Subject: [PATCH] remove arrow function and useless variable newLangName --- public/trivabble.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) 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; } -- 2.30.2