aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/dictionary.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2017-09-23 12:42:02 -0700
committerAlex Yatskov <alex@foosoft.net>2017-09-23 12:42:02 -0700
commit327027d820759c62f50454822c11c0b8859c1d04 (patch)
tree3a13a25634b7eaf702634a3d6baeb8806c48ab02 /ext/bg/js/dictionary.js
parent2eb85cb835a4aece7839eba25c0030e9eb186f85 (diff)
parentd13cb09fae53834baaac254d7b55d02a26f4a5c0 (diff)
Merge branch 'dev'
Diffstat (limited to 'ext/bg/js/dictionary.js')
-rw-r--r--ext/bg/js/dictionary.js34
1 files changed, 12 insertions, 22 deletions
diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js
index e749390f..57acbe5e 100644
--- a/ext/bg/js/dictionary.js
+++ b/ext/bg/js/dictionary.js
@@ -55,14 +55,6 @@ function dictRowsSort(rows, options) {
function dictTermsSort(definitions, dictionaries=null) {
return definitions.sort((v1, v2) => {
- const sl1 = v1.source.length;
- const sl2 = v2.source.length;
- if (sl1 > sl2) {
- return -1;
- } else if (sl1 < sl2) {
- return 1;
- }
-
if (dictionaries !== null) {
const p1 = (dictionaries[v1.dictionary] || {}).priority || 0;
const p2 = (dictionaries[v2.dictionary] || {}).priority || 0;
@@ -73,11 +65,11 @@ function dictTermsSort(definitions, dictionaries=null) {
}
}
- const s1 = v1.score;
- const s2 = v2.score;
- if (s1 > s2) {
+ const sl1 = v1.source.length;
+ const sl2 = v2.source.length;
+ if (sl1 > sl2) {
return -1;
- } else if (s1 < s2) {
+ } else if (sl1 < sl2) {
return 1;
}
@@ -89,6 +81,14 @@ function dictTermsSort(definitions, dictionaries=null) {
return 1;
}
+ const s1 = v1.score;
+ const s2 = v2.score;
+ if (s1 > s2) {
+ return -1;
+ } else if (s1 < s2) {
+ return 1;
+ }
+
return v2.expression.localeCompare(v1.expression);
});
}
@@ -148,16 +148,6 @@ function dictTagBuildSource(name) {
return dictTagSanitize({name, category: 'dictionary', order: 100});
}
-function dictTagBuild(name, meta) {
- const tag = {name};
- const symbol = name.split(':')[0];
- for (const prop in meta[symbol] || {}) {
- tag[prop] = meta[symbol][prop];
- }
-
- return dictTagSanitize(tag);
-}
-
function dictTagSanitize(tag) {
tag.name = tag.name || 'untitled';
tag.category = tag.category || 'default';