WIP
This commit is contained in:
parent
c70876c410
commit
8e2134bb56
10
ext/api.js
10
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);
|
||||
}
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user