summaryrefslogtreecommitdiff
path: root/ext/bg/js/dictionary.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg/js/dictionary.js')
-rw-r--r--ext/bg/js/dictionary.js40
1 files changed, 23 insertions, 17 deletions
diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js
index 4645189d..90a40ee5 100644
--- a/ext/bg/js/dictionary.js
+++ b/ext/bg/js/dictionary.js
@@ -41,8 +41,29 @@ class Dictionary {
results = results.concat(
indices.map(index => {
const [e, r, t, ...g] = dict.defs[index];
- const tags = Dictionary.fixupTags(t.split(' '));
- return {id: index, expression: e, reading: r, glossary: g, tags: tags};
+ const addons = [];
+ const tags = t.split(' ');
+
+ //
+ // TODO: Handle addons through data.
+ //
+
+ for (const tag of tags) {
+ if (tag.startsWith('v5') && tag !== 'v5') {
+ addons.push('v5');
+ } else if (tag.startsWith('vs-')) {
+ addons.push('vs');
+ }
+ }
+
+ return {
+ id: index,
+ expression: e,
+ reading: r,
+ glossary: g,
+ tags: tags.concat(addons),
+ addons: addons
+ };
})
);
}
@@ -63,19 +84,4 @@ class Dictionary {
return results;
}
-
- static fixupTags(tags) {
- const results = [];
- for (const tag of tags) {
- if (tag.startsWith('v5') && tag !== 'v5') {
- results.push('v5');
- } else if (tag.startsWith('vs-')) {
- results.push('vs');
- }
-
- results.push(tag);
- }
-
- return results;
- }
}