aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-03-26 18:10:22 -0700
committerAlex Yatskov <alex@foosoft.net>2016-03-26 18:10:22 -0700
commit8e2134bb56ab659f74cb79b399137d83a3457e27 (patch)
tree4316a6f1fde7fc9920390f18954cc5e4ab5df4c9
parentc70876c410e0c2fd5ea5d00fee25282df38e5f8b (diff)
WIP
-rw-r--r--ext/api.js10
-rw-r--r--ext/bg/yomichan.js8
2 files changed, 12 insertions, 6 deletions
diff --git a/ext/api.js b/ext/api.js
index 496f8be3..422a3703 100644
--- a/ext/api.js
+++ b/ext/api.js
@@ -22,5 +22,13 @@ function sendMessage(action, data, callback) {
}
function findTerm(text, callback) {
- sendMessage('findTerm', {term: text}, callback);
+ sendMessage('findTerm', {text: text}, callback);
+}
+
+function findKanji(text, callback) {
+ sendMessage('findKanji', {text: text}, callback);
+}
+
+function getState(callback) {
+ sendMessage('getState', null, callback);
}
diff --git a/ext/bg/yomichan.js b/ext/bg/yomichan.js
index 196785e1..971e739c 100644
--- a/ext/bg/yomichan.js
+++ b/ext/bg/yomichan.js
@@ -33,14 +33,12 @@ class Yomichan {
chrome.browserAction.onClicked.addListener(this.onBrowserAction.bind(this));
}
- onFindTerm({term}) {
- return this.translator.findTerm(term);
- }
-
onMessage(request, sender, callback) {
const {action, data} = request;
const handler = {
- findTerm: this.onFindTerm
+ findKanji: ({text}) => this.translator.onFindKanji(text),
+ findTerm: ({text}) => this.translator.findTerm(text),
+ getState: () => this.state
}[action];
if (handler !== null) {