Use static object for api command handlers
This commit is contained in:
parent
10458c63e7
commit
0d6177398d
@ -126,7 +126,13 @@ async function apiTemplateRender(template, data, dynamic) {
|
||||
}
|
||||
|
||||
async function apiCommandExec(command) {
|
||||
const handlers = {
|
||||
const handlers = apiCommandExec.handlers;
|
||||
if (handlers.hasOwnProperty(command)) {
|
||||
const handler = handlers[command];
|
||||
handler();
|
||||
}
|
||||
}
|
||||
apiCommandExec.handlers = {
|
||||
search: () => {
|
||||
chrome.tabs.create({url: chrome.extension.getURL('/bg/search.html')});
|
||||
},
|
||||
@ -148,13 +154,7 @@ async function apiCommandExec(command) {
|
||||
options.general.enable = !options.general.enable;
|
||||
await apiOptionsSave('popup');
|
||||
}
|
||||
};
|
||||
|
||||
const handler = handlers[command];
|
||||
if (handler) {
|
||||
handler();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
async function apiAudioGetUrl(definition, source) {
|
||||
return audioBuildUrl(definition, source);
|
||||
|
Loading…
Reference in New Issue
Block a user