diff options
author | Alex Yatskov <alex@foosoft.net> | 2017-01-09 09:30:56 -0800 |
---|---|---|
committer | Alex Yatskov <alex@foosoft.net> | 2017-01-09 09:30:56 -0800 |
commit | 89070c609645455ac307bd0de918f2b76726dd3a (patch) | |
tree | 266b2586a03968404ef95ac80d284aa5aa0026a7 /ext/fg/js | |
parent | 60e23ab42c86fbc74a6e16d6fd29fcc6761bfb36 (diff) |
cleanup
Diffstat (limited to 'ext/fg/js')
-rw-r--r-- | ext/fg/js/driver.js | 10 | ||||
-rw-r--r-- | ext/fg/js/frame.js | 32 | ||||
-rw-r--r-- | ext/fg/js/popup.js | 4 |
3 files changed, 2 insertions, 44 deletions
diff --git a/ext/fg/js/driver.js b/ext/fg/js/driver.js index 12003d55..ef7db481 100644 --- a/ext/fg/js/driver.js +++ b/ext/fg/js/driver.js @@ -146,13 +146,7 @@ class Driver { searchTerms(textSource) { textSource.setEndOffset(this.options.scanLength); - let findFunc = findTerm; - let showFunc = this.popup.showTermDefs.bind(this.popup); - if (this.options.groupTermResults) { - findFunc = findTermGrouped; - showFunc = this.popup.showTermGroupedDefs.bind(this.popup); - } - + const findFunc = this.options.groupTermResults ? findTermGrouped : findTerm; return findFunc(textSource.text()).then(({definitions, length}) => { if (definitions.length === 0) { return false; @@ -166,7 +160,7 @@ class Driver { }); this.popup.showNextTo(textSource.getRect()); - showFunc(definitions, this.options); + this.popup.showTermDefs(definitions, this.options); this.lastTextSource = textSource; if (this.options.selectMatchedText) { textSource.select(); diff --git a/ext/fg/js/frame.js b/ext/fg/js/frame.js index 2cf32e3e..4295dbb3 100644 --- a/ext/fg/js/frame.js +++ b/ext/fg/js/frame.js @@ -62,38 +62,6 @@ class Frame { }); } - api_showTermGroupedDefs({definitions, options}) { - const sequence = ++this.sequence; - const context = { - definitions, - grouped: options.groupTermResults, - addable: options.ankiMethod !== 'disabled', - playback: options.enableAudioPlayback - }; - - this.definitions = definitions; - this.showSpinner(false); - window.scrollTo(0, 0); - - renderText(context, 'term-list.html').then(content => { - $('.content').html(content); - $('.action-add-note').click(this.onAddNote.bind(this)); - - $('.kanji-link').click(e => { - e.preventDefault(); - findKanji($(e.target).text()).then(kdefs => this.api_showKanjiDefs({options, definitions: kdefs})); - }); - - $('.action-play-audio').click(e => { - e.preventDefault(); - const index = $(e.currentTarget).data('index'); - this.playAudio(this.definitions[index]); - }); - - this.updateAddNoteButtons(['term_kanji', 'term_kana'], sequence); - }); - } - api_showKanjiDefs({definitions, options}) { const sequence = ++this.sequence; const context = { diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js index d2c78081..21f4a9d7 100644 --- a/ext/fg/js/popup.js +++ b/ext/fg/js/popup.js @@ -74,10 +74,6 @@ class Popup { this.invokeApi('showTermDefs', {definitions, options}); } - showTermGroupedDefs(definitions, options) { - this.invokeApi('showTermGroupedDefs', {definitions, options}); - } - showKanjiDefs(definitions, options) { this.invokeApi('showKanjiDefs', {definitions, options}); } |