summaryrefslogtreecommitdiff
path: root/ext/bg/js/util.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2017-03-05 15:54:03 -0800
committerAlex Yatskov <alex@foosoft.net>2017-03-05 15:54:03 -0800
commita4dfadaa152d9f102ec692ef70659387148a654b (patch)
tree74304a74d1d38ee58e706c945d6263cc5725a2d3 /ext/bg/js/util.js
parentd4e95c27d2cfe9bb67540e7c868c284735768877 (diff)
wip
Diffstat (limited to 'ext/bg/js/util.js')
-rw-r--r--ext/bg/js/util.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/ext/bg/js/util.js b/ext/bg/js/util.js
index 37fb0843..2fd77130 100644
--- a/ext/bg/js/util.js
+++ b/ext/bg/js/util.js
@@ -248,6 +248,20 @@ function dictEnabled(options) {
return dictionaries;
}
+function dictRowsSort(rows, options) {
+ return rows.sort((ra, rb) => {
+ const pa = options.dictionaries[ra.title].priority || 0;
+ const pb = options.dictionaries[rb.title].priority || 0;
+ if (pa > pb) {
+ return -1;
+ } else if (pa < pb) {
+ return 1;
+ } else {
+ return 0;
+ }
+ });
+}
+
function dictTermsSort(definitions, dictionaries=null) {
return definitions.sort((v1, v2) => {
const sl1 = v1.source.length;