version bump, cloze support

This commit is contained in:
Alex Yatskov 2017-03-28 20:49:26 -07:00
parent 9de0d34af3
commit f15f30019b
7 changed files with 95 additions and 22 deletions

View File

@ -350,8 +350,33 @@ function ankiFieldsPopulate(element, options) {
}
const markers = {
'terms': ['audio', 'dictionary', 'expression', 'furigana', 'glossary', 'reading', 'sentence', 'tags', 'url'],
'kanji': ['character', 'dictionary', 'glossary', 'kunyomi', 'onyomi', 'sentence', 'tags', 'url']
'terms': [
'audio',
'cloze-body',
'cloze-prefix',
'cloze-suffix',
'dictionary',
'expression',
'furigana',
'glossary',
'reading',
'sentence',
'tags',
'url'
],
'kanji': [
'character',
'cloze-body',
'cloze-prefix',
'cloze-suffix',
'dictionary',
'glossary',
'kunyomi',
'onyomi',
'sentence',
'tags',
'url'
]
}[tabId] || {};
return instAnki().getModelFieldNames(modelName).then(names => {

View File

@ -234,16 +234,44 @@ templates['fields.html'] = template({"1":function(container,depth0,helpers,parti
},"72":function(container,depth0,helpers,partials,data) {
var stack1;
return container.escapeExpression(container.lambda(((stack1 = (depth0 != null ? depth0.definition : depth0)) != null ? stack1.sentence : stack1), depth0));
},"74":function(container,depth0,helpers,partials,data) {
return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},((stack1 = (depth0 != null ? depth0.definition : depth0)) != null ? stack1.cloze : stack1),{"name":"if","hash":{},"fn":container.program(73, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"73":function(container,depth0,helpers,partials,data) {
var stack1;
return ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},((stack1 = (depth0 != null ? depth0.definition : depth0)) != null ? stack1.tags : stack1),{"name":"each","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
return container.escapeExpression(container.lambda(((stack1 = ((stack1 = (depth0 != null ? depth0.definition : depth0)) != null ? stack1.cloze : stack1)) != null ? stack1.sentence : stack1), depth0));
},"75":function(container,depth0,helpers,partials,data) {
var stack1;
return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},((stack1 = (depth0 != null ? depth0.definition : depth0)) != null ? stack1.cloze : stack1),{"name":"if","hash":{},"fn":container.program(76, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"76":function(container,depth0,helpers,partials,data) {
var stack1;
return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.html : depth0),{"name":"if","hash":{},"fn":container.program(77, data, 0),"inverse":container.program(79, data, 0),"data":data})) != null ? stack1 : "");
},"77":function(container,depth0,helpers,partials,data) {
return container.escapeExpression(container.lambda(((stack1 = ((stack1 = (depth0 != null ? depth0.definition : depth0)) != null ? stack1.cloze : stack1)) != null ? stack1.prefix : stack1), depth0));
},"78":function(container,depth0,helpers,partials,data) {
var stack1;
return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},((stack1 = (depth0 != null ? depth0.definition : depth0)) != null ? stack1.cloze : stack1),{"name":"if","hash":{},"fn":container.program(79, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"79":function(container,depth0,helpers,partials,data) {
var stack1;
return container.escapeExpression(container.lambda(((stack1 = ((stack1 = (depth0 != null ? depth0.definition : depth0)) != null ? stack1.cloze : stack1)) != null ? stack1.body : stack1), depth0));
},"81":function(container,depth0,helpers,partials,data) {
var stack1;
return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},((stack1 = (depth0 != null ? depth0.definition : depth0)) != null ? stack1.cloze : stack1),{"name":"if","hash":{},"fn":container.program(82, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"82":function(container,depth0,helpers,partials,data) {
var stack1;
return container.escapeExpression(container.lambda(((stack1 = ((stack1 = (depth0 != null ? depth0.definition : depth0)) != null ? stack1.cloze : stack1)) != null ? stack1.suffix : stack1), depth0));
},"84":function(container,depth0,helpers,partials,data) {
var stack1;
return ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},((stack1 = (depth0 != null ? depth0.definition : depth0)) != null ? stack1.tags : stack1),{"name":"each","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "");
},"86":function(container,depth0,helpers,partials,data) {
var stack1;
return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.html : depth0),{"name":"if","hash":{},"fn":container.program(87, data, 0),"inverse":container.program(89, data, 0),"data":data})) != null ? stack1 : "");
},"87":function(container,depth0,helpers,partials,data) {
var stack1, alias1=container.lambda, alias2=container.escapeExpression;
return "<a href=\""
@ -251,14 +279,14 @@ templates['fields.html'] = template({"1":function(container,depth0,helpers,parti
+ "\">"
+ alias2(alias1(((stack1 = (depth0 != null ? depth0.definition : depth0)) != null ? stack1.url : stack1), depth0))
+ "</a>";
},"79":function(container,depth0,helpers,partials,data) {
},"89":function(container,depth0,helpers,partials,data) {
var stack1;
return container.escapeExpression(container.lambda(((stack1 = (depth0 != null ? depth0.definition : depth0)) != null ? stack1.url : stack1), depth0));
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data,blockParams,depths) {
var stack1;
return "\n\n\n\n\n\n\n\n\n\n\n\n\n"
return "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
+ ((stack1 = container.invokePartial(helpers.lookup.call(depth0 != null ? depth0 : {},depth0,"marker",{"name":"lookup","hash":{},"data":data}),depth0,{"data":data,"helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : "");
},"main_d": function(fn, props, container, depth0, data, blockParams, depths) {
@ -275,8 +303,11 @@ templates['fields.html'] = template({"1":function(container,depth0,helpers,parti
fn = decorators.inline(fn,props,container,{"name":"inline","hash":{},"fn":container.program(68, data, 0, blockParams, depths),"inverse":container.noop,"args":["onyomi"],"data":data}) || fn;
fn = decorators.inline(fn,props,container,{"name":"inline","hash":{},"fn":container.program(70, data, 0, blockParams, depths),"inverse":container.noop,"args":["reading"],"data":data}) || fn;
fn = decorators.inline(fn,props,container,{"name":"inline","hash":{},"fn":container.program(72, data, 0, blockParams, depths),"inverse":container.noop,"args":["sentence"],"data":data}) || fn;
fn = decorators.inline(fn,props,container,{"name":"inline","hash":{},"fn":container.program(74, data, 0, blockParams, depths),"inverse":container.noop,"args":["tags"],"data":data}) || fn;
fn = decorators.inline(fn,props,container,{"name":"inline","hash":{},"fn":container.program(76, data, 0, blockParams, depths),"inverse":container.noop,"args":["url"],"data":data}) || fn;
fn = decorators.inline(fn,props,container,{"name":"inline","hash":{},"fn":container.program(75, data, 0, blockParams, depths),"inverse":container.noop,"args":["cloze-prefix"],"data":data}) || fn;
fn = decorators.inline(fn,props,container,{"name":"inline","hash":{},"fn":container.program(78, data, 0, blockParams, depths),"inverse":container.noop,"args":["cloze-body"],"data":data}) || fn;
fn = decorators.inline(fn,props,container,{"name":"inline","hash":{},"fn":container.program(81, data, 0, blockParams, depths),"inverse":container.noop,"args":["cloze-suffix"],"data":data}) || fn;
fn = decorators.inline(fn,props,container,{"name":"inline","hash":{},"fn":container.program(84, data, 0, blockParams, depths),"inverse":container.noop,"args":["tags"],"data":data}) || fn;
fn = decorators.inline(fn,props,container,{"name":"inline","hash":{},"fn":container.program(86, data, 0, blockParams, depths),"inverse":container.noop,"args":["url"],"data":data}) || fn;
return fn;
}

View File

@ -435,6 +435,9 @@ function dictFieldFormat(field, definition, mode, options) {
const markers = [
'audio',
'character',
'cloze-body',
'cloze-prefix',
'cloze-suffix',
'dictionary',
'expression',
'furigana',

View File

@ -213,6 +213,6 @@ function docClozeExtract(source, extent) {
sentence: sentence.trim(),
prefix: clozePrefix.trim(),
body: clozeBody.trim(),
sufix: clozeSuffix.trim()
suffix: clozeSuffix.trim()
};
}

View File

@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "Yomichan",
"version": "1.1.8",
"version": "1.1.9",
"description": "Japanese dictionary with Anki integration",
"icons": {"16": "mixed/img/icon16.png", "48": "mixed/img/icon48.png", "128": "mixed/img/icon128.png"},

View File

@ -22,10 +22,12 @@ class Display {
this.spinner = spinner;
this.container = container;
this.definitions = [];
this.audioCache = {};
this.responseCache = {};
this.options = null;
this.context = null;
this.sequence = 0;
this.index = 0;
this.audioCache = {};
this.responseCache = {};
$(document).keydown(this.onKeyDown.bind(this));
}
@ -72,8 +74,8 @@ class Display {
if (context) {
for (const definition of definitions) {
definition.sentence = context.sentence || '';
definition.url = context.url || '';
definition.cloze = context.cloze;
definition.url = context.url;
}
}
@ -106,8 +108,8 @@ class Display {
if (context) {
for (const definition of definitions) {
definition.sentence = context.sentence || '';
definition.url = context.url || '';
definition.cloze = context.cloze;
definition.url = context.url;
}
}
@ -179,7 +181,7 @@ class Display {
};
if (this.context) {
context.sentence = this.context.sentence;
context.cloze = this.context.cloze;
context.url = this.context.url;
}
@ -306,7 +308,7 @@ class Display {
if (this.context && this.context.source) {
const context = {
url: this.context.source.url,
sentence: this.context.source.sentence,
cloze: this.context.source.cloze,
index: this.context.source.index
};

View File

@ -83,7 +83,19 @@
{{/inline}}
{{#*inline "sentence"}}
{{~definition.sentence~}}
{{~#if definition.cloze}}{{definition.cloze.sentence}}{{/if~}}
{{/inline}}
{{#*inline "cloze-prefix"}}
{{~#if definition.cloze}}{{definition.cloze.prefix}}{{/if~}}
{{/inline}}
{{#*inline "cloze-body"}}
{{~#if definition.cloze}}{{definition.cloze.body}}{{/if~}}
{{/inline}}
{{#*inline "cloze-suffix"}}
{{~#if definition.cloze}}{{definition.cloze.suffix}}{{/if~}}
{{/inline}}
{{#*inline "tags"}}