This commit is contained in:
Alex Yatskov 2016-03-26 18:10:22 -07:00
parent c70876c410
commit 8e2134bb56
2 changed files with 12 additions and 6 deletions

View File

@ -22,5 +22,13 @@ function sendMessage(action, data, callback) {
} }
function findTerm(text, 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);
} }

View File

@ -33,14 +33,12 @@ class Yomichan {
chrome.browserAction.onClicked.addListener(this.onBrowserAction.bind(this)); chrome.browserAction.onClicked.addListener(this.onBrowserAction.bind(this));
} }
onFindTerm({term}) {
return this.translator.findTerm(term);
}
onMessage(request, sender, callback) { onMessage(request, sender, callback) {
const {action, data} = request; const {action, data} = request;
const handler = { const handler = {
findTerm: this.onFindTerm findKanji: ({text}) => this.translator.onFindKanji(text),
findTerm: ({text}) => this.translator.findTerm(text),
getState: () => this.state
}[action]; }[action];
if (handler !== null) { if (handler !== null) {