diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-02-14 15:53:35 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-14 15:53:35 -0500 |
commit | 286534e648af350d24fbf3c7892a7ec81aaeb4bd (patch) | |
tree | 89d88e961c5a0a6f508c66789e30b9ba4a968e73 /ext/js/pages/action-popup-main.js | |
parent | efe8140f103179f50b610f182148b9427af99010 (diff) |
Move api to yomichan object (#1392)
* Move cross frame API from API to Yomichan
* Add API instance to Yomichan
* Move api global to yomichan.api
* Pass yomichan to API
* Remove IIFE
Diffstat (limited to 'ext/js/pages/action-popup-main.js')
-rw-r--r-- | ext/js/pages/action-popup-main.js | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/ext/js/pages/action-popup-main.js b/ext/js/pages/action-popup-main.js index 99a76bdf..75dfb641 100644 --- a/ext/js/pages/action-popup-main.js +++ b/ext/js/pages/action-popup-main.js @@ -18,7 +18,6 @@ /* global * HotkeyHelpController * PermissionsUtil - * api */ class DisplayController { @@ -35,7 +34,7 @@ class DisplayController { this._setupButtonEvents('.action-open-search', 'openSearchPage', chrome.runtime.getURL('/search.html')); this._setupButtonEvents('.action-open-info', 'openInfoPage', chrome.runtime.getURL('/info.html')); - const optionsFull = await api.optionsGetFull(); + const optionsFull = await yomichan.api.optionsGetFull(); this._optionsFull = optionsFull; this._setupHotkeys(); @@ -74,12 +73,12 @@ class DisplayController { if (typeof command === 'string') { node.addEventListener('click', (e) => { if (e.button !== 0) { return; } - api.commandExec(command, {mode: e.ctrlKey ? 'newTab' : 'existingOrNewTab'}); + yomichan.api.commandExec(command, {mode: e.ctrlKey ? 'newTab' : 'existingOrNewTab'}); e.preventDefault(); }, false); node.addEventListener('auxclick', (e) => { if (e.button !== 1) { return; } - api.commandExec(command, {mode: 'newTab'}); + yomichan.api.commandExec(command, {mode: 'newTab'}); e.preventDefault(); }, false); } @@ -130,7 +129,7 @@ class DisplayController { _setupOptions({options}) { const extensionEnabled = options.general.enable; - const onToggleChanged = () => api.commandExec('toggleTextScanning'); + const onToggleChanged = () => yomichan.api.commandExec('toggleTextScanning'); for (const toggle of document.querySelectorAll('#enable-search,#enable-search2')) { toggle.checked = extensionEnabled; toggle.addEventListener('change', onToggleChanged, false); @@ -178,7 +177,7 @@ class DisplayController { } async _setPrimaryProfileIndex(value) { - return await api.modifySettings( + return await yomichan.api.modifySettings( [{ action: 'set', path: 'profileCurrent', @@ -190,7 +189,7 @@ class DisplayController { async _updateDictionariesEnabledWarnings(options) { const noDictionariesEnabledWarnings = document.querySelectorAll('.no-dictionaries-enabled-warning'); - const dictionaries = await api.getDictionaryInfo(); + const dictionaries = await yomichan.api.getDictionaryInfo(); let enabledCount = 0; for (const {title} of dictionaries) { @@ -221,10 +220,9 @@ class DisplayController { } (async () => { - api.prepare(); await yomichan.prepare(); - api.logIndicatorClear(); + yomichan.api.logIndicatorClear(); const displayController = new DisplayController(); displayController.prepare(); |