From e2a4a46e6006b9a85a3b6e5e26f55076afb16919 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 14 Dec 2019 23:06:44 -0500 Subject: Implement settings reset --- ext/bg/js/options.js | 4 ++++ ext/bg/js/settings/backup.js | 22 ++++++++++++++++++++++ ext/bg/settings.html | 31 +++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) (limited to 'ext/bg') diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js index 1650cea9..84e74bd8 100644 --- a/ext/bg/js/options.js +++ b/ext/bg/js/options.js @@ -488,3 +488,7 @@ function optionsSave(options) { }); }); } + +function optionsGetDefault() { + return optionsUpdateVersion({}, {}); +} diff --git a/ext/bg/js/settings/backup.js b/ext/bg/js/settings/backup.js index 1e099288..d278b718 100644 --- a/ext/bg/js/settings/backup.js +++ b/ext/bg/js/settings/backup.js @@ -339,10 +339,32 @@ function _onSettingsImportFileChange(e) { } +// Resetting + +function _onSettingsResetClick() { + $('#settings-reset-modal').modal('show'); +} + +async function _onSettingsResetConfirmClick() { + $('#settings-reset-modal').modal('hide'); + + // Get default options + const optionsFull = optionsGetDefault(); + + // Assign options + await _settingsImportSetOptionsFull(optionsFull); + + // Reload settings page + window.location.reload(); +} + + // Setup window.addEventListener('DOMContentLoaded', () => { document.querySelector('#settings-export').addEventListener('click', _onSettingsExportClick, false); document.querySelector('#settings-import').addEventListener('click', _onSettingsImportClick, false); document.querySelector('#settings-import-file').addEventListener('change', _onSettingsImportFileChange, false); + document.querySelector('#settings-reset').addEventListener('click', _onSettingsResetClick, false); + document.querySelector('#settings-reset-modal-confirm').addEventListener('click', _onSettingsResetConfirmClick, false); }, false); diff --git a/ext/bg/settings.html b/ext/bg/settings.html index 56b5610e..4c973674 100644 --- a/ext/bg/settings.html +++ b/ext/bg/settings.html @@ -867,6 +867,7 @@
+
@@ -916,6 +917,36 @@ + +
-- cgit v1.2.3