Skip to content

Commit

Permalink
Clean up targetbars code to use cleaner for loops
Browse files Browse the repository at this point in the history
  • Loading branch information
quisquous committed Jul 25, 2020
1 parent 232e077 commit cdc4454
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions OverlayPlugin.Core/resources/targetbars/targetbars.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ const validKeys = ['None', ...rawKeys, ...otherKeys, ...targetOnlyKeys];
// Remove enmity from non-target keys.
const textOptionsNonTarget = (() => {
let options = {};
for (const lang in textOptionsAll) {
for (const [lang, perLang] of Object.entries(textOptionsAll)) {
options[lang] = {};
let perLang = textOptionsAll[lang];
for (const key in perLang) {
const value = perLang[key];
if (targetOnlyKeys.includes(value))
Expand Down Expand Up @@ -407,8 +406,7 @@ class BarUI {
right: this.options.rightText,
};

for (const justifyKey in textMap) {
let text = textMap[justifyKey];
for (const [justifyKey, text] of Object.entries(textMap)) {
if (!validKeys.includes(text)) {
console.error(`Invalid key: ${text}`);
continue;
Expand Down Expand Up @@ -727,11 +725,11 @@ class SettingsUI {

const optionsByType = opt.optionsByType ? opt.optionsByType[this.target] : opt.options;
const innerOptions = this.translate(optionsByType);
for (const key in innerOptions) {
for (const [key, value] of Object.entries(innerOptions)) {
let elem = document.createElement('option');
elem.value = innerOptions[key];
elem.value = value;
elem.innerHTML = key;
if (innerOptions[key] == defaultValue)
if (value === defaultValue)
elem.selected = true;
input.appendChild(elem);
}
Expand Down

0 comments on commit cdc4454

Please sign in to comment.