diff options
Diffstat (limited to 'ext/js/pages/settings/settings-main.js')
-rw-r--r-- | ext/js/pages/settings/settings-main.js | 165 |
1 files changed, 77 insertions, 88 deletions
diff --git a/ext/js/pages/settings/settings-main.js b/ext/js/pages/settings/settings-main.js index c3391173..dc4b36c9 100644 --- a/ext/js/pages/settings/settings-main.js +++ b/ext/js/pages/settings/settings-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 {querySelectorNotNull} from '../../dom/query-selector.js'; import {ExtensionContentController} from '../common/extension-content-controller.js'; @@ -58,124 +57,114 @@ async function setupGenericSettingController(genericSettingController) { await genericSettingController.refresh(); } -/** Entry point. */ -async function main() { - try { - const documentFocusController = new DocumentFocusController(); - documentFocusController.prepare(); +await Application.main(async (application) => { + const documentFocusController = new DocumentFocusController(); + documentFocusController.prepare(); - const extensionContentController = new ExtensionContentController(); - extensionContentController.prepare(); + const extensionContentController = new ExtensionContentController(); + extensionContentController.prepare(); - /** @type {HTMLElement} */ - const statusFooterElement = querySelectorNotNull(document, '.status-footer-container'); - const statusFooter = new StatusFooter(statusFooterElement); - statusFooter.prepare(); + /** @type {HTMLElement} */ + const statusFooterElement = querySelectorNotNull(document, '.status-footer-container'); + const statusFooter = new StatusFooter(statusFooterElement); + statusFooter.prepare(); - /** @type {?number} */ - let prepareTimer = window.setTimeout(() => { - prepareTimer = null; - document.documentElement.dataset.loadingStalled = 'true'; - }, 1000); + /** @type {?number} */ + let prepareTimer = window.setTimeout(() => { + prepareTimer = null; + document.documentElement.dataset.loadingStalled = 'true'; + }, 1000); - const application = new Application(); - await application.prepare(); - - if (prepareTimer !== null) { - clearTimeout(prepareTimer); - prepareTimer = null; - } - delete document.documentElement.dataset.loadingStalled; - - const preparePromises = []; + if (prepareTimer !== null) { + clearTimeout(prepareTimer); + prepareTimer = null; + } + delete document.documentElement.dataset.loadingStalled; - const modalController = new ModalController(); - modalController.prepare(); + const preparePromises = []; - const settingsController = new SettingsController(application); - await settingsController.prepare(); + const modalController = new ModalController(); + modalController.prepare(); - const persistentStorageController = new PersistentStorageController(application); - persistentStorageController.prepare(); + const settingsController = new SettingsController(application); + await settingsController.prepare(); - const storageController = new StorageController(persistentStorageController); - storageController.prepare(); + const persistentStorageController = new PersistentStorageController(application); + persistentStorageController.prepare(); - const dictionaryController = new DictionaryController(settingsController, modalController, statusFooter); - dictionaryController.prepare(); + const storageController = new StorageController(persistentStorageController); + storageController.prepare(); - const dictionaryImportController = new DictionaryImportController(settingsController, modalController, statusFooter); - dictionaryImportController.prepare(); + const dictionaryController = new DictionaryController(settingsController, modalController, statusFooter); + dictionaryController.prepare(); - const genericSettingController = new GenericSettingController(settingsController); - preparePromises.push(setupGenericSettingController(genericSettingController)); + const dictionaryImportController = new DictionaryImportController(settingsController, modalController, statusFooter); + dictionaryImportController.prepare(); - const audioController = new AudioController(settingsController, modalController); - audioController.prepare(); + const genericSettingController = new GenericSettingController(settingsController); + preparePromises.push(setupGenericSettingController(genericSettingController)); - const profileController = new ProfileController(settingsController, modalController); - profileController.prepare(); + const audioController = new AudioController(settingsController, modalController); + audioController.prepare(); - const settingsBackup = new BackupController(settingsController, modalController); - settingsBackup.prepare(); + const profileController = new ProfileController(settingsController, modalController); + profileController.prepare(); - const ankiController = new AnkiController(settingsController); - ankiController.prepare(); + const settingsBackup = new BackupController(settingsController, modalController); + settingsBackup.prepare(); - const ankiTemplatesController = new AnkiTemplatesController(settingsController, modalController, ankiController); - ankiTemplatesController.prepare(); + const ankiController = new AnkiController(settingsController); + ankiController.prepare(); - const popupPreviewController = new PopupPreviewController(settingsController); - popupPreviewController.prepare(); + const ankiTemplatesController = new AnkiTemplatesController(settingsController, modalController, ankiController); + ankiTemplatesController.prepare(); - const scanInputsController = new ScanInputsController(settingsController); - scanInputsController.prepare(); + const popupPreviewController = new PopupPreviewController(settingsController); + popupPreviewController.prepare(); - const simpleScanningInputController = new ScanInputsSimpleController(settingsController); - simpleScanningInputController.prepare(); + const scanInputsController = new ScanInputsController(settingsController); + scanInputsController.prepare(); - const nestedPopupsController = new NestedPopupsController(settingsController); - nestedPopupsController.prepare(); + const simpleScanningInputController = new ScanInputsSimpleController(settingsController); + simpleScanningInputController.prepare(); - const permissionsToggleController = new PermissionsToggleController(settingsController); - permissionsToggleController.prepare(); + const nestedPopupsController = new NestedPopupsController(settingsController); + nestedPopupsController.prepare(); - const secondarySearchDictionaryController = new SecondarySearchDictionaryController(settingsController); - secondarySearchDictionaryController.prepare(); + const permissionsToggleController = new PermissionsToggleController(settingsController); + permissionsToggleController.prepare(); - const translationTextReplacementsController = new TranslationTextReplacementsController(settingsController); - translationTextReplacementsController.prepare(); + const secondarySearchDictionaryController = new SecondarySearchDictionaryController(settingsController); + secondarySearchDictionaryController.prepare(); - const sentenceTerminationCharactersController = new SentenceTerminationCharactersController(settingsController); - sentenceTerminationCharactersController.prepare(); + const translationTextReplacementsController = new TranslationTextReplacementsController(settingsController); + translationTextReplacementsController.prepare(); - const keyboardShortcutController = new KeyboardShortcutController(settingsController); - keyboardShortcutController.prepare(); + const sentenceTerminationCharactersController = new SentenceTerminationCharactersController(settingsController); + sentenceTerminationCharactersController.prepare(); - const extensionKeyboardShortcutController = new ExtensionKeyboardShortcutController(settingsController); - extensionKeyboardShortcutController.prepare(); + const keyboardShortcutController = new KeyboardShortcutController(settingsController); + keyboardShortcutController.prepare(); - const popupWindowController = new PopupWindowController(application.api); - popupWindowController.prepare(); + const extensionKeyboardShortcutController = new ExtensionKeyboardShortcutController(settingsController); + extensionKeyboardShortcutController.prepare(); - const mecabController = new MecabController(application.api); - mecabController.prepare(); + const popupWindowController = new PopupWindowController(application.api); + popupWindowController.prepare(); - const collapsibleDictionaryController = new CollapsibleDictionaryController(settingsController); - collapsibleDictionaryController.prepare(); + const mecabController = new MecabController(application.api); + mecabController.prepare(); - const sortFrequencyDictionaryController = new SortFrequencyDictionaryController(settingsController); - sortFrequencyDictionaryController.prepare(); + const collapsibleDictionaryController = new CollapsibleDictionaryController(settingsController); + collapsibleDictionaryController.prepare(); - await Promise.all(preparePromises); + const sortFrequencyDictionaryController = new SortFrequencyDictionaryController(settingsController); + sortFrequencyDictionaryController.prepare(); - document.documentElement.dataset.loaded = 'true'; + await Promise.all(preparePromises); - const settingsDisplayController = new SettingsDisplayController(settingsController, modalController); - settingsDisplayController.prepare(); - } catch (e) { - log.error(e); - } -} + document.documentElement.dataset.loaded = 'true'; -await main(); + const settingsDisplayController = new SettingsDisplayController(settingsController, modalController); + settingsDisplayController.prepare(); +}); |