aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/settings/main.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-05-29 20:25:22 -0400
committerGitHub <noreply@github.com>2020-05-29 20:25:22 -0400
commit418e8a57bf7ea1def3e7b83270742d466e98e8cf (patch)
tree196c7522b3b1d7469024b783fb9c0dd144f247dc /ext/bg/js/settings/main.js
parentc62f980f37007743bed004ff43a82a8d7664dac6 (diff)
Convert dictionaries.js and storage.js to classes (#570)
* Convert dictionaries.js to a class * Remove storage spinner * Convert storage.js to a class * Move dataset assignments into main.js
Diffstat (limited to 'ext/bg/js/settings/main.js')
-rw-r--r--ext/bg/js/settings/main.js25
1 files changed, 18 insertions, 7 deletions
diff --git a/ext/bg/js/settings/main.js b/ext/bg/js/settings/main.js
index dddaef6c..1d387749 100644
--- a/ext/bg/js/settings/main.js
+++ b/ext/bg/js/settings/main.js
@@ -19,14 +19,13 @@
* AnkiController
* AnkiTemplatesController
* AudioController
+ * DictionaryController
* ProfileController
* SettingsBackup
* SettingsController
+ * StorageController
* api
* appearanceInitialize
- * dictSettingsInitialize
- * onDictionaryOptionsChanged
- * storageInfoInitialize
* utilBackend
* utilBackgroundIsolate
*/
@@ -270,7 +269,9 @@ async function onOptionsUpdated({source}) {
if (ankiTemplatesController !== null) {
ankiTemplatesController.updateValue();
}
- onDictionaryOptionsChanged();
+ if (dictionaryController !== null) {
+ dictionaryController.optionsChanged();
+ }
if (ankiController !== null) {
ankiController.optionsChanged();
}
@@ -304,8 +305,15 @@ async function settingsPopulateModifierKeys() {
}
}
+async function setupEnvironmentInfo() {
+ const {browser, platform} = await api.getEnvironmentInfo();
+ document.documentElement.dataset.browser = browser;
+ document.documentElement.dataset.operatingSystem = platform.os;
+}
+
let ankiController = null;
let ankiTemplatesController = null;
+let dictionaryController = null;
async function onReady() {
api.forwardLogsToBackend();
@@ -314,22 +322,25 @@ async function onReady() {
const settingsController = new SettingsController();
settingsController.prepare();
+ setupEnvironmentInfo();
showExtensionInformation();
+ const storageController = new StorageController();
+ storageController.prepare();
+
await settingsPopulateModifierKeys();
formSetupEventListeners();
appearanceInitialize();
new AudioController().prepare();
await (new ProfileController()).prepare();
- await dictSettingsInitialize();
+ dictionaryController = new DictionaryController(storageController);
+ dictionaryController.prepare();
ankiController = new AnkiController();
ankiController.prepare();
ankiTemplatesController = new AnkiTemplatesController(ankiController);
ankiTemplatesController.prepare();
new SettingsBackup().prepare();
- storageInfoInitialize();
-
yomichan.on('optionsUpdated', onOptionsUpdated);
}