diff --git a/ext/bg/js/templates.js b/ext/bg/js/templates.js
index 857bbb9d..29e86c89 100644
--- a/ext/bg/js/templates.js
+++ b/ext/bg/js/templates.js
@@ -89,7 +89,7 @@ templates['kanji-list.html'] = template({"1":function(container,depth0,helpers,p
var stack1;
return ((stack1 = container.invokePartial(partials["header.html"],depth0,{"name":"header.html","data":data,"helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : "")
- + ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.defs : depth0),{"name":"each","hash":{},"fn":container.program(1, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ + ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.definitions : depth0),{"name":"each","hash":{},"fn":container.program(1, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ ((stack1 = container.invokePartial(partials["footer.html"],depth0,{"name":"footer.html","data":data,"helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : "");
},"usePartial":true,"useData":true,"useDepths":true});
templates['term.html'] = template({"1":function(container,depth0,helpers,partials,data,blockParams,depths) {
@@ -101,17 +101,17 @@ templates['term.html'] = template({"1":function(container,depth0,helpers,partial
return "
\n
\n
\n
\n
\n";
+ + "/img/add_vocab_kana.png\">\n \n";
},"4":function(container,depth0,helpers,partials,data) {
var stack1, helper, options, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", buffer =
" ";
@@ -191,7 +191,7 @@ templates['term-list.html'] = template({"1":function(container,depth0,helpers,pa
var stack1;
return ((stack1 = container.invokePartial(partials["header.html"],depth0,{"name":"header.html","data":data,"helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : "")
- + ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.defs : depth0),{"name":"each","hash":{},"fn":container.program(1, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ + ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.definitions : depth0),{"name":"each","hash":{},"fn":container.program(1, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ ((stack1 = container.invokePartial(partials["footer.html"],depth0,{"name":"footer.html","data":data,"helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : "");
},"usePartial":true,"useData":true,"useDepths":true});
})();
\ No newline at end of file
diff --git a/ext/bg/js/yomichan.js b/ext/bg/js/yomichan.js
index f0cbdf79..03f9d082 100644
--- a/ext/bg/js/yomichan.js
+++ b/ext/bg/js/yomichan.js
@@ -99,6 +99,14 @@ class Yomichan {
this.notifyTabs('options', this.options);
}
+ notifyTabs(name, value) {
+ chrome.tabs.query({}, (tabs) => {
+ for (const tab of tabs) {
+ chrome.tabs.sendMessage(tab.id, {name, value}, () => null);
+ }
+ });
+ }
+
ankiInvoke(action, params, pool, callback) {
if (this.options.enableAnkiConnect) {
if (pool !== null && this.asyncPools.hasOwnProperty(pool)) {
@@ -165,26 +173,18 @@ class Yomichan {
}
for (const name in fields) {
- note.fields[name] = this.formatField(fields[name], definition, mode === 'vocabReading');
+ note.fields[name] = this.formatField(fields[name], definition, mode === 'vocab_kana');
}
return note;
}
- notifyTabs(name, value) {
- chrome.tabs.query({}, (tabs) => {
- for (const tab of tabs) {
- chrome.tabs.sendMessage(tab.id, {name, value}, () => null);
- }
- });
- }
-
- api_addNote({definition, mode, callback}) {
+ api_addDefinition({definition, mode, callback}) {
const note = this.formatNote(definition, mode);
this.ankiInvoke('addNote', {note}, null, callback);
}
- api_canAddNotes({definitions, modes, callback}) {
+ api_canAddDefinitions({definitions, modes, callback}) {
let notes = [];
for (const definition of definitions) {
for (const mode of modes) {
@@ -194,13 +194,16 @@ class Yomichan {
this.ankiInvoke('canAddNotes', {notes}, 'notes', (results) => {
const states = [];
- for (let resultBase = 0; resultBase < results.length; resultBase += modes.length) {
- const state = {};
- for (let modeOffset = 0; modeOffset < modes.length; ++modeOffset) {
- state[modes[modeOffset]] = results[resultBase + modeOffset];
- }
- states.push(state);
+ if (results !== null) {
+ for (let resultBase = 0; resultBase < results.length; resultBase += modes.length) {
+ const state = {};
+ for (let modeOffset = 0; modeOffset < modes.length; ++modeOffset) {
+ state[modes[modeOffset]] = results[resultBase + modeOffset];
+ }
+
+ states.push(state);
+ }
}
callback(states);
diff --git a/ext/fg/img/add_reading.png b/ext/fg/img/add_vocab_kana.png
similarity index 100%
rename from ext/fg/img/add_reading.png
rename to ext/fg/img/add_vocab_kana.png
diff --git a/ext/fg/img/add_expression.png b/ext/fg/img/add_vocab_kanji.png
similarity index 100%
rename from ext/fg/img/add_expression.png
rename to ext/fg/img/add_vocab_kanji.png
diff --git a/ext/fg/js/api.js b/ext/fg/js/api.js
index ecd8dd36..5d060311 100644
--- a/ext/fg/js/api.js
+++ b/ext/fg/js/api.js
@@ -41,10 +41,10 @@ function bgGetState(callback) {
bgSendMessage('getState', {}, callback);
}
-function bgCanAddNotes(definitions, modes, callback) {
- bgSendMessage('canAddNotes', {definitions, modes}, callback);
+function bgCanAddDefinitions(definitions, modes, callback) {
+ bgSendMessage('canAddDefinitions', {definitions, modes}, callback);
}
-function bgAddNote(definition, mode, callback) {
- bgSendMessage('addNote', {definition, mode}, callback);
+function bgAddDefinition(definition, mode, callback) {
+ bgSendMessage('addDefinition', {definition, mode}, callback);
}
diff --git a/ext/fg/js/client.js b/ext/fg/js/client.js
index 31cc29cc..ec2ea630 100644
--- a/ext/fg/js/client.js
+++ b/ext/fg/js/client.js
@@ -106,13 +106,13 @@ class Client {
range.setLength(length);
bgRenderText(
- {defs: definitions, root: this.fgRoot, options: this.options, sequence},
+ {definitions, root: this.fgRoot, options: this.options, sequence},
'term-list.html',
(content) => {
this.definitions = definitions;
this.showPopup(range, content);
- bgCanAddNotes(definitions, ['vocabExp', 'vocabReading'], (states) => {
+ bgCanAddDefinitions(definitions, ['vocab_kanji', 'vocab_kana'], (states) => {
if (states !== null) {
states.forEach((state, index) => this.popup.sendMessage('setActionState', {index, state, sequence}));
}
@@ -158,7 +158,7 @@ class Client {
const state = {};
state[mode] = false;
- bgAddNote(this.definitions[index], mode, (success) => {
+ bgAddDefinition(this.definitions[index], mode, (success) => {
if (success) {
this.popup.sendMessage('setActionState', {index, state, sequence: this.sequence});
} else {
@@ -171,13 +171,13 @@ class Client {
bgFindKanji(kanji, (definitions) => {
const sequence = ++this.sequence;
bgRenderText(
- {defs: definitions, root: this.fgRoot, options: this.options, sequence},
+ {definitions, root: this.fgRoot, options: this.options, sequence},
'kanji-list.html',
(content) => {
this.definitions = definitions;
this.popup.setContent(content, definitions);
- bgCanAddNotes(definitions, ['kanji'], (states) => {
+ bgCanAddDefinitions(definitions, ['kanji'], (states) => {
if (states !== null) {
states.forEach((state, index) => this.popup.sendMessage('setActionState', {index, state, sequence}));
}
diff --git a/ext/manifest.json b/ext/manifest.json
index 3da98b9e..ee133e74 100644
--- a/ext/manifest.json
+++ b/ext/manifest.json
@@ -19,9 +19,9 @@
"permissions": ["storage"],
"web_accessible_resources": [
"fg/css/frame.css",
- "fg/img/add_expression.png",
"fg/img/add_kanji.png",
- "fg/img/add_reading.png",
+ "fg/img/add_vocab_kana.png",
+ "fg/img/add_vocab_kanji.png",
"fg/js/frame.js",
"fg/ttf/kanji-stroke-orders.ttf",
"fg/ttf/vl-gothic-regular.ttf"
diff --git a/tmpl/kanji-list.html b/tmpl/kanji-list.html
index b5d0b627..34349862 100644
--- a/tmpl/kanji-list.html
+++ b/tmpl/kanji-list.html
@@ -1,5 +1,5 @@
{{> header.html}}
-{{#each defs}}
+{{#each definitions}}
{{> kanji.html root=../root options=../options sequence=../sequence}}
{{/each}}
{{> footer.html}}
diff --git a/tmpl/term-list.html b/tmpl/term-list.html
index 5581b679..615534f6 100644
--- a/tmpl/term-list.html
+++ b/tmpl/term-list.html
@@ -1,5 +1,5 @@
{{> header.html}}
-{{#each defs}}
+{{#each definitions}}
{{> term.html root=../root options=../options sequence=../sequence}}
{{/each}}
{{> footer.html}}
diff --git a/tmpl/term.html b/tmpl/term.html
index 216ccf0a..3fb75c98 100644
--- a/tmpl/term.html
+++ b/tmpl/term.html
@@ -2,8 +2,8 @@
{{#with options}}
{{#if enableAnkiConnect}}
{{/if}}
{{/with}}