wip
This commit is contained in:
parent
b8d0788144
commit
bc2bf51a07
@ -19,8 +19,8 @@
|
|||||||
|
|
||||||
$(document).ready(() => {
|
$(document).ready(() => {
|
||||||
$('#open-search').click(() => commandExec('search'));
|
$('#open-search').click(() => commandExec('search'));
|
||||||
$('#open-options').click(() => chrome.runtime.openOptionsPage());
|
$('#open-options').click(() => commandExec('options'));
|
||||||
$('#open-help').click(() => window.open('http://foosoft.net/projects/yomichan'));
|
$('#open-help').click(() => commandExec('help'));
|
||||||
|
|
||||||
optionsLoad().then(options => {
|
optionsLoad().then(options => {
|
||||||
const toggle = $('#enable-search');
|
const toggle = $('#enable-search');
|
||||||
|
@ -165,11 +165,28 @@ window.yomichan = new class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onCommand(command) {
|
onCommand(command) {
|
||||||
if (command === 'search') {
|
const handlers = {
|
||||||
window.open(chrome.extension.getURL('/bg/search.html'));
|
search: () => {
|
||||||
} else if (command === 'toggle') {
|
chrome.tabs.create({url: chrome.extension.getURL('/bg/search.html')});
|
||||||
this.options.general.enable = !this.options.general.enable;
|
},
|
||||||
optionsSave(this.options).then(() => this.optionsSet(this.options));
|
|
||||||
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user