aboutsummaryrefslogtreecommitdiff
path: root/ext/js/display
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/display')
-rw-r--r--ext/js/display/popup-main.js51
-rw-r--r--ext/js/display/search-main.js56
2 files changed, 40 insertions, 67 deletions
diff --git a/ext/js/display/popup-main.js b/ext/js/display/popup-main.js
index 2ca2fcd3..a244c2e0 100644
--- a/ext/js/display/popup-main.js
+++ b/ext/js/display/popup-main.js
@@ -17,7 +17,6 @@
*/
import {Application} from '../application.js';
-import {log} from '../core/logger.js';
import {DocumentFocusController} from '../dom/document-focus-controller.js';
import {HotkeyHandler} from '../input/hotkey-handler.js';
import {DisplayAnki} from './display-anki.js';
@@ -26,43 +25,31 @@ import {DisplayProfileSelection} from './display-profile-selection.js';
import {DisplayResizer} from './display-resizer.js';
import {Display} from './display.js';
-/** Entry point. */
-async function main() {
- try {
- const documentFocusController = new DocumentFocusController();
- documentFocusController.prepare();
+await Application.main(async (application) => {
+ const documentFocusController = new DocumentFocusController();
+ documentFocusController.prepare();
- const application = new Application();
- await application.prepare();
+ const {tabId, frameId} = await application.api.frameInformationGet();
- const {tabId, frameId} = await application.api.frameInformationGet();
+ const hotkeyHandler = new HotkeyHandler();
+ hotkeyHandler.prepare(application.crossFrame);
- const hotkeyHandler = new HotkeyHandler();
- hotkeyHandler.prepare(application.crossFrame);
+ const display = new Display(application, tabId, frameId, 'popup', documentFocusController, hotkeyHandler);
+ await display.prepare();
- const display = new Display(application, tabId, frameId, 'popup', documentFocusController, hotkeyHandler);
- await display.prepare();
+ const displayAudio = new DisplayAudio(display);
+ displayAudio.prepare();
- const displayAudio = new DisplayAudio(display);
- displayAudio.prepare();
+ const displayAnki = new DisplayAnki(display, displayAudio);
+ displayAnki.prepare();
- const displayAnki = new DisplayAnki(display, displayAudio);
- displayAnki.prepare();
+ const displayProfileSelection = new DisplayProfileSelection(display);
+ displayProfileSelection.prepare();
- const displayProfileSelection = new DisplayProfileSelection(display);
- displayProfileSelection.prepare();
+ const displayResizer = new DisplayResizer(display);
+ displayResizer.prepare();
- const displayResizer = new DisplayResizer(display);
- displayResizer.prepare();
+ display.initializeState();
- display.initializeState();
-
- document.documentElement.dataset.loaded = 'true';
-
- application.ready();
- } catch (e) {
- log.error(e);
- }
-}
-
-await main();
+ document.documentElement.dataset.loaded = 'true';
+});
diff --git a/ext/js/display/search-main.js b/ext/js/display/search-main.js
index dc4f1b7e..5c6a31ca 100644
--- a/ext/js/display/search-main.js
+++ b/ext/js/display/search-main.js
@@ -17,7 +17,6 @@
*/
import {Application} from '../application.js';
-import {log} from '../core/logger.js';
import {DocumentFocusController} from '../dom/document-focus-controller.js';
import {HotkeyHandler} from '../input/hotkey-handler.js';
import {DisplayAnki} from './display-anki.js';
@@ -27,47 +26,34 @@ import {SearchActionPopupController} from './search-action-popup-controller.js';
import {SearchDisplayController} from './search-display-controller.js';
import {SearchPersistentStateController} from './search-persistent-state-controller.js';
-/** Entry point. */
-async function main() {
- try {
- const application = new Application();
+await Application.main(async (application) => {
+ const documentFocusController = new DocumentFocusController('#search-textbox');
+ documentFocusController.prepare();
- const documentFocusController = new DocumentFocusController('#search-textbox');
- documentFocusController.prepare();
+ const searchPersistentStateController = new SearchPersistentStateController();
+ searchPersistentStateController.prepare();
- const searchPersistentStateController = new SearchPersistentStateController();
- searchPersistentStateController.prepare();
+ const searchActionPopupController = new SearchActionPopupController(searchPersistentStateController);
+ searchActionPopupController.prepare();
- const searchActionPopupController = new SearchActionPopupController(searchPersistentStateController);
- searchActionPopupController.prepare();
+ const {tabId, frameId} = await application.api.frameInformationGet();
- await application.prepare();
+ const hotkeyHandler = new HotkeyHandler();
+ hotkeyHandler.prepare(application.crossFrame);
- const {tabId, frameId} = await application.api.frameInformationGet();
+ const display = new Display(application, tabId, frameId, 'search', documentFocusController, hotkeyHandler);
+ await display.prepare();
- const hotkeyHandler = new HotkeyHandler();
- hotkeyHandler.prepare(application.crossFrame);
+ const displayAudio = new DisplayAudio(display);
+ displayAudio.prepare();
- const display = new Display(application, tabId, frameId, 'search', documentFocusController, hotkeyHandler);
- await display.prepare();
+ const displayAnki = new DisplayAnki(display, displayAudio);
+ displayAnki.prepare();
- const displayAudio = new DisplayAudio(display);
- displayAudio.prepare();
+ const searchDisplayController = new SearchDisplayController(tabId, frameId, display, displayAudio, searchPersistentStateController);
+ await searchDisplayController.prepare();
- const displayAnki = new DisplayAnki(display, displayAudio);
- displayAnki.prepare();
+ display.initializeState();
- const searchDisplayController = new SearchDisplayController(tabId, frameId, display, displayAudio, searchPersistentStateController);
- await searchDisplayController.prepare();
-
- display.initializeState();
-
- document.documentElement.dataset.loaded = 'true';
-
- application.ready();
- } catch (e) {
- log.error(e);
- }
-}
-
-await main();
+ document.documentElement.dataset.loaded = 'true';
+});