cleanup
This commit is contained in:
parent
60e23ab42c
commit
89070c6096
@ -146,13 +146,7 @@ class Driver {
|
|||||||
searchTerms(textSource) {
|
searchTerms(textSource) {
|
||||||
textSource.setEndOffset(this.options.scanLength);
|
textSource.setEndOffset(this.options.scanLength);
|
||||||
|
|
||||||
let findFunc = findTerm;
|
const findFunc = this.options.groupTermResults ? findTermGrouped : findTerm;
|
||||||
let showFunc = this.popup.showTermDefs.bind(this.popup);
|
|
||||||
if (this.options.groupTermResults) {
|
|
||||||
findFunc = findTermGrouped;
|
|
||||||
showFunc = this.popup.showTermGroupedDefs.bind(this.popup);
|
|
||||||
}
|
|
||||||
|
|
||||||
return findFunc(textSource.text()).then(({definitions, length}) => {
|
return findFunc(textSource.text()).then(({definitions, length}) => {
|
||||||
if (definitions.length === 0) {
|
if (definitions.length === 0) {
|
||||||
return false;
|
return false;
|
||||||
@ -166,7 +160,7 @@ class Driver {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.popup.showNextTo(textSource.getRect());
|
this.popup.showNextTo(textSource.getRect());
|
||||||
showFunc(definitions, this.options);
|
this.popup.showTermDefs(definitions, this.options);
|
||||||
this.lastTextSource = textSource;
|
this.lastTextSource = textSource;
|
||||||
if (this.options.selectMatchedText) {
|
if (this.options.selectMatchedText) {
|
||||||
textSource.select();
|
textSource.select();
|
||||||
|
@ -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}) {
|
api_showKanjiDefs({definitions, options}) {
|
||||||
const sequence = ++this.sequence;
|
const sequence = ++this.sequence;
|
||||||
const context = {
|
const context = {
|
||||||
|
@ -74,10 +74,6 @@ class Popup {
|
|||||||
this.invokeApi('showTermDefs', {definitions, options});
|
this.invokeApi('showTermDefs', {definitions, options});
|
||||||
}
|
}
|
||||||
|
|
||||||
showTermGroupedDefs(definitions, options) {
|
|
||||||
this.invokeApi('showTermGroupedDefs', {definitions, options});
|
|
||||||
}
|
|
||||||
|
|
||||||
showKanjiDefs(definitions, options) {
|
showKanjiDefs(definitions, options) {
|
||||||
this.invokeApi('showKanjiDefs', {definitions, options});
|
this.invokeApi('showKanjiDefs', {definitions, options});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user