diff options
author | Alex Yatskov <alex@foosoft.net> | 2016-08-14 12:08:06 -0700 |
---|---|---|
committer | Alex Yatskov <alex@foosoft.net> | 2016-08-14 12:08:06 -0700 |
commit | d0654e2cf6ab1138049484af109fc848998c2f5a (patch) | |
tree | 737256f5cbc375632660b7293c4cc9a2b703ada4 /ext/bg/js | |
parent | 8f8d8d3f513517fdca941bc3fb0bc88722229db5 (diff) |
Adding stub for usage guide
Diffstat (limited to 'ext/bg/js')
-rw-r--r-- | ext/bg/js/options-form.js | 16 | ||||
-rw-r--r-- | ext/bg/js/options.js | 1 | ||||
-rw-r--r-- | ext/bg/js/yomichan.js | 26 |
3 files changed, 28 insertions, 15 deletions
diff --git a/ext/bg/js/options-form.js b/ext/bg/js/options-form.js index 979f5377..cd0c1ab8 100644 --- a/ext/bg/js/options-form.js +++ b/ext/bg/js/options-form.js @@ -54,6 +54,7 @@ function formToOptions(section, callback) { optsNew.activateOnStartup = $('#activate-on-startup').prop('checked'); optsNew.loadEnamDict = $('#load-enamdict').prop('checked'); optsNew.selectMatchedText = $('#select-matched-text').prop('checked'); + optsNew.showAdvancedOptions = $('#show-advanced-options').prop('checked'); optsNew.enableAudioPlayback = $('#enable-audio-playback').prop('checked'); optsNew.enableAnkiConnect = $('#enable-anki-connect').prop('checked'); break; @@ -174,9 +175,15 @@ function onOptionsGeneralChanged(e) { if (!optsOld.enableAnkiConnect && optsNew.enableAnkiConnect) { updateAnkiStatus(); populateAnkiDeckAndModel(optsNew); - $('.options-anki').fadeIn(); + $('.options-anki').show(); } else if (optsOld.enableAnkiConnect && !optsNew.enableAnkiConnect) { - $('.options-anki').fadeOut(); + $('.options-anki').hide(); + } + + if (optsNew.showAdvancedOptions) { + $('.options-advanced').show(); + } else { + $('.options-advanced').hide(); } }); }); @@ -208,6 +215,7 @@ $(document).ready(() => { $('#activate-on-startup').prop('checked', opts.activateOnStartup); $('#load-enamdict').prop('checked', opts.loadEnamDict); $('#select-matched-text').prop('checked', opts.selectMatchedText); + $('#show-advanced-options').prop('checked', opts.showAdvancedOptions); $('#enable-audio-playback').prop('checked', opts.enableAudioPlayback); $('#enable-anki-connect').prop('checked', opts.enableAnkiConnect); @@ -219,6 +227,10 @@ $(document).ready(() => { $('.anki-deck').change(onOptionsAnkiChanged); $('.anki-model').change(onAnkiModelChanged); + if (opts.showAdvancedOptions) { + $('.options-advanced').show(); + } + if (opts.enableAnkiConnect) { updateAnkiStatus(); populateAnkiDeckAndModel(opts); diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js index 167a7bb6..a1c169a7 100644 --- a/ext/bg/js/options.js +++ b/ext/bg/js/options.js @@ -22,6 +22,7 @@ function sanitizeOptions(options) { scanLength: 20, activateOnStartup: false, selectMatchedText: true, + showAdvancedOptions: false, loadEnamDict: false, enableAudioPlayback: true, enableAnkiConnect: false, diff --git a/ext/bg/js/yomichan.js b/ext/bg/js/yomichan.js index c6288e57..e54f9e4f 100644 --- a/ext/bg/js/yomichan.js +++ b/ext/bg/js/yomichan.js @@ -22,7 +22,7 @@ class Yomichan { Handlebars.partials = Handlebars.templates; Handlebars.registerHelper('kanjiLinks', function(options) { let result = ''; - for (let c of options.fn(this)) { + for (const c of options.fn(this)) { if (Translator.isKanji(c)) { result += Handlebars.templates['kanji-link.html']({kanji: c}).trim(); } else { @@ -53,7 +53,7 @@ class Yomichan { onInstalled(details) { if (details.reason === 'install') { - chrome.runtime.openOptionsPage(); + chrome.tabs.create({url: chrome.extension.getURL('bg/guide.html')}); } } @@ -118,7 +118,7 @@ class Yomichan { tabInvokeAll(action, params) { chrome.tabs.query({}, (tabs) => { - for (let tab of tabs) { + for (const tab of tabs) { this.tabInvoke(tab.id, action, params); } }); @@ -176,7 +176,7 @@ class Yomichan { 'url', ]; - for (let tag of tags) { + for (const tag of tags) { let value = definition[tag] || null; switch (tag) { case 'audio': @@ -195,7 +195,7 @@ class Yomichan { case 'glossary-list': if (definition.glossary) { value = '<ol>'; - for (let gloss of definition.glossary) { + for (const gloss of definition.glossary) { value += `<li>${gloss}</li>`; } value += '</ol>'; @@ -223,12 +223,12 @@ class Yomichan { let fields = []; if (mode === 'kanji') { - fields = this.options.ankiKanjiFields; - note.deckName = this.options.ankiKanjiDeck; + fields = this.options.ankiKanjiFields; + note.deckName = this.options.ankiKanjiDeck; note.modelName = this.options.ankiKanjiModel; } else { - fields = this.options.ankiTermFields; - note.deckName = this.options.ankiTermDeck; + fields = this.options.ankiTermFields; + note.deckName = this.options.ankiTermDeck; note.modelName = this.options.ankiTermModel; const audio = { @@ -237,7 +237,7 @@ class Yomichan { fields: [] }; - for (let name in fields) { + for (const name in fields) { if (fields[name].indexOf('{audio}') !== -1) { audio.fields.push(name); } @@ -261,9 +261,9 @@ class Yomichan { } api_canAddDefinitions({definitions, modes, callback}) { - let notes = []; - for (let definition of definitions) { - for (let mode of modes) { + const notes = []; + for (const definition of definitions) { + for (const mode of modes) { notes.push(this.formatNote(definition, mode)); } } |