summaryrefslogtreecommitdiff
path: root/ext/bg
diff options
context:
space:
mode:
authorsiikamiika <siikamiika@users.noreply.github.com>2017-10-19 19:27:28 +0300
committersiikamiika <siikamiika@users.noreply.github.com>2017-10-19 19:27:28 +0300
commitbc92327d86201b0c36cf910052ab82da7c47ff9f (patch)
tree4de0271f8fbd2d8573975a8ff243026f7df48ec5 /ext/bg
parentf54f909701453bac563c9cb5ec75fde23e087e8e (diff)
Anki: term frequency colors in merged mode
Diffstat (limited to 'ext/bg')
-rw-r--r--ext/bg/js/handlebars.js13
-rw-r--r--ext/bg/js/options.js2
2 files changed, 14 insertions, 1 deletions
diff --git a/ext/bg/js/handlebars.js b/ext/bg/js/handlebars.js
index 66d5fa2b..72908cab 100644
--- a/ext/bg/js/handlebars.js
+++ b/ext/bg/js/handlebars.js
@@ -75,6 +75,18 @@ function handlebarsMultiLine(options) {
return options.fn(this).split('\n').join('<br>');
}
+function handlebarsTermFrequencyColor(options) {
+ const termFrequency = options.fn(this);
+
+ if (termFrequency === 'popular') {
+ return '#0275d8';
+ } else if (termFrequency === 'rare') {
+ return '#999';
+ } else {
+ return 'inherit';
+ }
+}
+
function handlebarsRegisterHelpers() {
if (Handlebars.partials !== Handlebars.templates) {
Handlebars.partials = Handlebars.templates;
@@ -83,6 +95,7 @@ function handlebarsRegisterHelpers() {
Handlebars.registerHelper('furiganaPlain', handlebarsFuriganaPlain);
Handlebars.registerHelper('kanjiLinks', handlebarsKanjiLinks);
Handlebars.registerHelper('multiLine', handlebarsMultiLine);
+ Handlebars.registerHelper('termFrequencyColor', handlebarsTermFrequencyColor);
}
}
diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js
index 5902bc30..475a5e66 100644
--- a/ext/bg/js/options.js
+++ b/ext/bg/js/options.js
@@ -79,7 +79,7 @@ function optionsFieldTemplates() {
{{#*inline "furigana"}}
{{~#if merge~}}
{{~#each definition.expressions~}}
- {{~#furigana}}{{{.}}}{{/furigana~}}
+ <span style="color: {{#termFrequencyColor}}{{termFrequency}}{{/termFrequencyColor}}">{{~#furigana}}{{{.}}}{{/furigana~}}</span>
{{~#unless @last}}、{{/unless~}}
{{~/each~}}
{{~else~}}