summaryrefslogtreecommitdiff
path: root/ext/bg
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-11-03 09:56:49 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-11-07 20:30:55 -0500
commitf7700789fe7888636cb246ba167dbc057cd3288e (patch)
tree9c17a05a4fe42758fa79cb3bbc7de3c7551b7e50 /ext/bg
parentfcb922400add0b9ab5d5b5454c3d6042a2d5b256 (diff)
Update dictionary order based on priority
Diffstat (limited to 'ext/bg')
-rw-r--r--ext/bg/js/settings-dictionaries.js17
1 files changed, 16 insertions, 1 deletions
diff --git a/ext/bg/js/settings-dictionaries.js b/ext/bg/js/settings-dictionaries.js
index 786fcbd5..921e0813 100644
--- a/ext/bg/js/settings-dictionaries.js
+++ b/ext/bg/js/settings-dictionaries.js
@@ -48,6 +48,8 @@ class SettingsDictionaryListUI {
}
}
+ this.updateDictionaryOrder();
+
const titles = this.dictionaryEntries.map(e => e.dictionaryInfo.title);
const removeKeys = Object.keys(this.optionsDictionaries).filter(key => titles.indexOf(key) < 0);
if (removeKeys.length >= 0) {
@@ -76,7 +78,6 @@ class SettingsDictionaryListUI {
}
const content = document.importNode(this.template.content, true).firstChild;
- this.container.appendChild(content);
this.dictionaryEntries.push(new SettingsDictionaryEntryUI(this, dictionaryInfo, content, optionsDictionary));
@@ -125,6 +126,18 @@ class SettingsDictionaryListUI {
}
}
+ updateDictionaryOrder() {
+ const sortInfo = this.dictionaryEntries.map((e, i) => [e, i]);
+ sortInfo.sort((a, b) => {
+ const i = b[0].optionsDictionary.priority - a[0].optionsDictionary.priority;
+ return (i !== 0 ? i : a[1] - b[1]);
+ });
+
+ for (const [e] of sortInfo) {
+ this.container.appendChild(e.content);
+ }
+ }
+
save() {
// Overwrite
}
@@ -268,6 +281,8 @@ class SettingsDictionaryEntryUI {
}
e.target.value = `${value}`;
+
+ this.parent.updateDictionaryOrder();
}
onDeleteButtonClicked(e) {