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) {
|
async function apiCommandExec(command) {
|
||||||
const handlers = {
|
const handlers = apiCommandExec.handlers;
|
||||||
|
if (handlers.hasOwnProperty(command)) {
|
||||||
|
const handler = handlers[command];
|
||||||
|
handler();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
apiCommandExec.handlers = {
|
||||||
search: () => {
|
search: () => {
|
||||||
chrome.tabs.create({url: chrome.extension.getURL('/bg/search.html')});
|
chrome.tabs.create({url: chrome.extension.getURL('/bg/search.html')});
|
||||||
},
|
},
|
||||||
@ -150,12 +156,6 @@ async function apiCommandExec(command) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handler = handlers[command];
|
|
||||||
if (handler) {
|
|
||||||
handler();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function apiAudioGetUrl(definition, source) {
|
async function apiAudioGetUrl(definition, source) {
|
||||||
return audioBuildUrl(definition, source);
|
return audioBuildUrl(definition, source);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user