summaryrefslogtreecommitdiff
path: root/ext/bg/js/util.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2017-04-02 12:12:21 -0700
committerAlex Yatskov <alex@foosoft.net>2017-04-02 12:12:21 -0700
commitbea50cca462be631dadbd2f5bde1bc0a12ad17bf (patch)
tree73612a4fedc4d1fe9874979c27187b4176a84569 /ext/bg/js/util.js
parent85001208db67027c430b3a4c8d569fb3930aeb27 (diff)
parentccb740da58068633a0ef5bd1c26bd4dd10625dce (diff)
Merge branch 'master' into firefox-amo
Diffstat (limited to 'ext/bg/js/util.js')
-rw-r--r--ext/bg/js/util.js90
1 files changed, 9 insertions, 81 deletions
diff --git a/ext/bg/js/util.js b/ext/bg/js/util.js
index 78258c97..05c7ff27 100644
--- a/ext/bg/js/util.js
+++ b/ext/bg/js/util.js
@@ -25,9 +25,6 @@ function promiseCallback(promise, callback) {
return promise.then(result => {
callback({result});
}).catch(error => {
- /* eslint-disable */
- console.log(error);
- /* eslint-enable */
callback({error});
});
}
@@ -84,7 +81,7 @@ function optionsSetDefaults(options) {
const defaults = {
general: {
enable: true,
- audioPlayback: true,
+ audioSource: 'jpod101',
audioVolume: 100,
groupResults: true,
softKatakana: true,
@@ -137,84 +134,15 @@ function optionsSetDefaults(options) {
function optionsVersion(options) {
const fixups = [
+ () => { },
+ () => { },
+ () => { },
+ () => { },
() => {
- const copy = (targetDict, targetKey, sourceDict, sourceKey) => {
- targetDict[targetKey] = sourceDict.hasOwnProperty(sourceKey) ? sourceDict[sourceKey] : targetDict[targetKey];
- };
-
- copy(options.general, 'autoStart', options, 'activateOnStartup');
- copy(options.general, 'audioPlayback', options, 'enableAudioPlayback');
- copy(options.general, 'softKatakana', options, 'enableSoftKatakanaSearch');
- copy(options.general, 'groupResults', options, 'groupTermResults');
- copy(options.general, 'showAdvanced', options, 'showAdvancedOptions');
-
- copy(options.scanning, 'requireShift', options, 'holdShiftToScan');
- copy(options.scanning, 'selectText', options, 'selectMatchedText');
- copy(options.scanning, 'delay', options, 'scanDelay');
- copy(options.scanning, 'length', options, 'scanLength');
-
- options.anki.enable = options.ankiMethod === 'ankiconnect';
-
- copy(options.anki, 'tags', options, 'ankiCardTags');
- copy(options.anki, 'sentenceExt', options, 'sentenceExtent');
- copy(options.anki.terms, 'deck', options, 'ankiTermDeck');
- copy(options.anki.terms, 'model', options, 'ankiTermModel');
- copy(options.anki.terms, 'fields', options, 'ankiTermFields');
- copy(options.anki.kanji, 'deck', options, 'ankiKanjiDeck');
- copy(options.anki.kanji, 'model', options, 'ankiKanjiModel');
- copy(options.anki.kanji, 'fields', options, 'ankiKanjiFields');
-
- for (const title in options.dictionaries) {
- const dictionary = options.dictionaries[title];
- dictionary.enabled = dictionary.enableTerms || dictionary.enableKanji;
- dictionary.priority = 0;
- }
- },
- () => {
- const fixupFields = fields => {
- const fixups = {
- '{expression-furigana}': '{furigana}',
- '{glossary-list}': '{glossary}'
- };
-
- for (const name in fields) {
- for (const fixup in fixups) {
- fields[name] = fields[name].replace(fixup, fixups[fixup]);
- }
- }
- };
-
- fixupFields(options.anki.terms.fields);
- fixupFields(options.anki.kanji.fields);
- },
- () => {
- let hasEnabledDict = false;
- for (const title in options.dictionaries) {
- if (options.dictionaries[title].enabled) {
- hasEnabledDict = true;
- break;
- }
- }
-
- if (!hasEnabledDict) {
- for (const title in options.dictionaries) {
- options.dictionaries[title].enabled = true;
- }
- }
- },
- () => {
- let hasEnabledDict = false;
- for (const title in options.dictionaries) {
- if (options.dictionaries[title].enabled) {
- hasEnabledDict = true;
- break;
- }
- }
-
- if (!hasEnabledDict) {
- for (const title in options.dictionaries) {
- options.dictionaries[title].enabled = true;
- }
+ if (options.general.audioPlayback) {
+ options.general.audioSource = 'jpod101';
+ } else {
+ options.general.audioSource = 'disabled';
}
}
];