summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2017-03-28 20:49:26 -0700
committerAlex Yatskov <alex@foosoft.net>2017-03-28 20:49:26 -0700
commitf15f30019b50e84844375e98dc3734d6463ee2c5 (patch)
treeb4e6f8fe1da154edb8804c501c86c1006008162f
parent9de0d34af398b385e140a365a500ff20dda45a7a (diff)
version bump, cloze support1.1.9
-rw-r--r--ext/bg/js/options.js29
-rw-r--r--ext/bg/js/templates.js49
-rw-r--r--ext/bg/js/util.js3
-rw-r--r--ext/fg/js/util.js2
-rw-r--r--ext/manifest.json2
-rw-r--r--ext/mixed/js/display.js18
-rw-r--r--tmpl/fields.html14
7 files changed, 95 insertions, 22 deletions
diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js
index ad5d47b6..2089cc53 100644
--- a/ext/bg/js/options.js
+++ b/ext/bg/js/options.js
@@ -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 => {
diff --git a/ext/bg/js/templates.js b/ext/bg/js/templates.js
index 0346e4c7..d093b177 100644
--- a/ext/bg/js/templates.js
+++ b/ext/bg/js/templates.js
@@ -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;
}
diff --git a/ext/bg/js/util.js b/ext/bg/js/util.js
index bde174c8..d1099262 100644
--- a/ext/bg/js/util.js
+++ b/ext/bg/js/util.js
@@ -435,6 +435,9 @@ function dictFieldFormat(field, definition, mode, options) {
const markers = [
'audio',
'character',
+ 'cloze-body',
+ 'cloze-prefix',
+ 'cloze-suffix',
'dictionary',
'expression',
'furigana',
diff --git a/ext/fg/js/util.js b/ext/fg/js/util.js
index 0a95b24d..a1bce660 100644
--- a/ext/fg/js/util.js
+++ b/ext/fg/js/util.js
@@ -213,6 +213,6 @@ function docClozeExtract(source, extent) {
sentence: sentence.trim(),
prefix: clozePrefix.trim(),
body: clozeBody.trim(),
- sufix: clozeSuffix.trim()
+ suffix: clozeSuffix.trim()
};
}
diff --git a/ext/manifest.json b/ext/manifest.json
index c897345c..c23b1db8 100644
--- a/ext/manifest.json
+++ b/ext/manifest.json
@@ -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"},
diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js
index db14a43c..9738319a 100644
--- a/ext/mixed/js/display.js
+++ b/ext/mixed/js/display.js
@@ -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
};
diff --git a/tmpl/fields.html b/tmpl/fields.html
index 33fbff44..ab1a9722 100644
--- a/tmpl/fields.html
+++ b/tmpl/fields.html
@@ -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"}}