From bc2bf51a072af45ddc61a7f6b1c5cc3b94f8ad3e Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sat, 25 Mar 2017 16:28:15 -0700 Subject: wip --- ext/bg/js/yomichan.js | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'ext/bg/js/yomichan.js') diff --git a/ext/bg/js/yomichan.js b/ext/bg/js/yomichan.js index e2deb2cd..1a34aba4 100644 --- a/ext/bg/js/yomichan.js +++ b/ext/bg/js/yomichan.js @@ -165,11 +165,28 @@ window.yomichan = new class { } onCommand(command) { - if (command === 'search') { - window.open(chrome.extension.getURL('/bg/search.html')); - } else if (command === 'toggle') { - this.options.general.enable = !this.options.general.enable; - optionsSave(this.options).then(() => this.optionsSet(this.options)); + const handlers = { + search: () => { + chrome.tabs.create({url: chrome.extension.getURL('/bg/search.html')}); + }, + + help: () => { + chrome.tabs.create({url: 'https://foosoft.net/projects/yomichan/'}); + }, + + options: () => { + chrome.runtime.openOptionsPage(); + }, + + toggle: () => { + this.options.general.enable = !this.options.general.enable; + optionsSave(this.options).then(() => this.optionsSet(this.options)); + } + }; + + const handler = handlers[command]; + if (handler) { + handler(); } } -- cgit v1.2.3