diff options
| author | Alex Yatskov <alex@foosoft.net> | 2019-10-05 10:14:07 -0700 | 
|---|---|---|
| committer | Alex Yatskov <alex@foosoft.net> | 2019-10-05 10:14:07 -0700 | 
| commit | 7f5f3951f057b84864f7f37825804f9049ddab10 (patch) | |
| tree | 1a724bbd4d8cf2b053f3e2b99b46ba41008508b8 /ext/bg/js/api.js | |
| parent | f4b6527ed6ed1f0f4f5a63b94766b20f3b90e6ec (diff) | |
| parent | 46ab36180f486a19332c538401b4db12ffe1bda1 (diff) | |
Merge branch 'master' into testing
Diffstat (limited to 'ext/bg/js/api.js')
| -rw-r--r-- | ext/bg/js/api.js | 52 | 
1 files changed, 26 insertions, 26 deletions
| diff --git a/ext/bg/js/api.js b/ext/bg/js/api.js index 474fe604..222e7ffe 100644 --- a/ext/bg/js/api.js +++ b/ext/bg/js/api.js @@ -126,35 +126,35 @@ async function apiTemplateRender(template, data, dynamic) {  }  async function apiCommandExec(command) { -    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: async () => { -            const optionsContext = { -                depth: 0, -                url: window.location.href -            }; -            const options = await apiOptionsGet(optionsContext); -            options.general.enable = !options.general.enable; -            await apiOptionsSave('popup'); -        } -    }; - -    const handler = handlers[command]; -    if (handler) { +    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')}); +    }, + +    help: () => { +        chrome.tabs.create({url: 'https://foosoft.net/projects/yomichan/'}); +    }, + +    options: () => { +        chrome.runtime.openOptionsPage(); +    }, + +    toggle: async () => { +        const optionsContext = { +            depth: 0, +            url: window.location.href +        }; +        const options = await apiOptionsGet(optionsContext); +        options.general.enable = !options.general.enable; +        await apiOptionsSave('popup'); +    } +};  async function apiAudioGetUrl(definition, source) {      return audioBuildUrl(definition, source); |