Anki: term frequency colors in merged mode
This commit is contained in:
parent
f54f909701
commit
bc92327d86
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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~}}
|
||||
|
Loading…
Reference in New Issue
Block a user