summaryrefslogtreecommitdiff
path: root/ext/bg/js/options.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-09-18 19:50:32 -0700
committerAlex Yatskov <alex@foosoft.net>2016-09-18 19:50:32 -0700
commitb44d19b35e120133a4bb751e176aec4d14b6cbc5 (patch)
tree05b23ef7e70e57f2cf38584a20c864ff0d7e4853 /ext/bg/js/options.js
parent7bd642e53868e0a3154b285be969cc2e6068f46f (diff)
parent4e2d7327c5b1aa8eed035dc4c177a3b9b49c5ab7 (diff)
Merge branch 'dev'
Diffstat (limited to 'ext/bg/js/options.js')
-rw-r--r--ext/bg/js/options.js43
1 files changed, 25 insertions, 18 deletions
diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js
index 831bb817..915164c7 100644
--- a/ext/bg/js/options.js
+++ b/ext/bg/js/options.js
@@ -19,21 +19,22 @@
function sanitizeOptions(options) {
const defaults = {
- scanLength: 20,
- activateOnStartup: false,
- selectMatchedText: true,
- showAdvancedOptions: false,
- loadEnamDict: false,
+ activateOnStartup: true,
+ selectMatchedText: true,
enableAudioPlayback: true,
- enableAnkiConnect: false,
- ankiCardTags: ['yomichan'],
- sentenceExtent: 200,
- ankiTermDeck: '',
- ankiTermModel: '',
- ankiTermFields: {},
- ankiKanjiDeck: '',
- ankiKanjiModel: '',
- ankiKanjiFields: {}
+ enableAnkiConnect: false,
+ showAdvancedOptions: false,
+ scanLength: 20,
+
+ ankiCardTags: ['yomichan'],
+ sentenceExtent: 200,
+
+ ankiTermDeck: '',
+ ankiTermModel: '',
+ ankiTermFields: {},
+ ankiKanjiDeck: '',
+ ankiKanjiModel: '',
+ ankiKanjiFields: {}
};
for (const key in defaults) {
@@ -45,10 +46,16 @@ function sanitizeOptions(options) {
return options;
}
-function loadOptions(callback) {
- chrome.storage.sync.get(null, (items) => callback(sanitizeOptions(items)));
+function loadOptions() {
+ return new Promise((resolve, reject) => {
+ chrome.storage.sync.get(null, opts => {
+ resolve(sanitizeOptions(opts));
+ });
+ });
}
-function saveOptions(opts, callback) {
- chrome.storage.sync.set(sanitizeOptions(opts), callback);
+function saveOptions(opts) {
+ return new Promise((resolve, reject) => {
+ chrome.storage.sync.set(sanitizeOptions(opts), resolve);
+ });
}