diff options
-rw-r--r-- | ext/bg/js/handlebars.js | 13 | ||||
-rw-r--r-- | ext/bg/js/options.js | 2 |
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~}} |