summaryrefslogtreecommitdiff
path: root/ext/bg/js/settings/backup-controller.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-12-12 14:57:24 -0500
committerGitHub <noreply@github.com>2020-12-12 14:57:24 -0500
commit5948229176d9a23f1a8fe9f7125c32bece34f100 (patch)
tree23b24b78bd5427680fd0ffca2a509f44eb2f6bfb /ext/bg/js/settings/backup-controller.js
parent92cfd31c0faf333c3affb2c9a7b14c4960cf156a (diff)
Add info page (#1102)
* Add api.getAnkiConnectVersion * Enable basic functionality when certain features/elements aren't present * Add info page * Update information links * Update info link on the settings v2 page
Diffstat (limited to 'ext/bg/js/settings/backup-controller.js')
-rw-r--r--ext/bg/js/settings/backup-controller.js36
1 files changed, 26 insertions, 10 deletions
diff --git a/ext/bg/js/settings/backup-controller.js b/ext/bg/js/settings/backup-controller.js
index b37dd91d..50a145ff 100644
--- a/ext/bg/js/settings/backup-controller.js
+++ b/ext/bg/js/settings/backup-controller.js
@@ -31,25 +31,41 @@ class BackupController {
this._settingsResetModal = null;
this._settingsImportErrorModal = null;
this._settingsImportWarningModal = null;
- this._optionsUtil = new OptionsUtil();
+ this._optionsUtil = null;
+ try {
+ this._optionsUtil = new OptionsUtil();
+ } catch (e) {
+ // NOP
+ }
}
async prepare() {
- await this._optionsUtil.prepare();
+ if (this._optionsUtil !== null) {
+ await this._optionsUtil.prepare();
+ }
- this._settingsResetModal = this._modalController.getModal('settings-reset');
- this._settingsImportErrorModal = this._modalController.getModal('settings-import-error');
- this._settingsImportWarningModal = this._modalController.getModal('settings-import-warning');
+ if (this._modalController !== null) {
+ this._settingsResetModal = this._modalController.getModal('settings-reset');
+ this._settingsImportErrorModal = this._modalController.getModal('settings-import-error');
+ this._settingsImportWarningModal = this._modalController.getModal('settings-import-warning');
+ }
- document.querySelector('#settings-export-button').addEventListener('click', this._onSettingsExportClick.bind(this), false);
- document.querySelector('#settings-import-button').addEventListener('click', this._onSettingsImportClick.bind(this), false);
- document.querySelector('#settings-import-file').addEventListener('change', this._onSettingsImportFileChange.bind(this), false);
- document.querySelector('#settings-reset-button').addEventListener('click', this._onSettingsResetClick.bind(this), false);
- document.querySelector('#settings-reset-confirm-button').addEventListener('click', this._onSettingsResetConfirmClick.bind(this), false);
+ this._addNodeEventListener('#settings-export-button', 'click', this._onSettingsExportClick.bind(this), false);
+ this._addNodeEventListener('#settings-import-button', 'click', this._onSettingsImportClick.bind(this), false);
+ this._addNodeEventListener('#settings-import-file', 'change', this._onSettingsImportFileChange.bind(this), false);
+ this._addNodeEventListener('#settings-reset-button', 'click', this._onSettingsResetClick.bind(this), false);
+ this._addNodeEventListener('#settings-reset-confirm-button', 'click', this._onSettingsResetConfirmClick.bind(this), false);
}
// Private
+ _addNodeEventListener(selector, ...args) {
+ const node = document.querySelector(selector);
+ if (node === null) { return; }
+
+ node.addEventListener(...args);
+ }
+
_getSettingsExportDateString(date, dateSeparator, dateTimeSeparator, timeSeparator, resolution) {
const values = [
date.getUTCFullYear().toString(),