Hook up sentence search extent to options
This commit is contained in:
parent
2b2e6cba3f
commit
80fedc4f7a
@ -49,6 +49,7 @@ function formToOptions(section, callback) {
|
|||||||
break;
|
break;
|
||||||
case 'anki':
|
case 'anki':
|
||||||
optsNew.ankiCardTags = $('#anki-card-tags').val().split(/[,; ]+/);
|
optsNew.ankiCardTags = $('#anki-card-tags').val().split(/[,; ]+/);
|
||||||
|
optsNew.sentenceExtent = parseInt($('#sentence-extent').val());
|
||||||
optsNew.ankiVocabDeck = $('#anki-vocab-deck').val();
|
optsNew.ankiVocabDeck = $('#anki-vocab-deck').val();
|
||||||
optsNew.ankiVocabModel = $('#anki-vocab-model').val();
|
optsNew.ankiVocabModel = $('#anki-vocab-model').val();
|
||||||
optsNew.ankiVocabFields = fieldsToDict($('#vocab .anki-field-value'));
|
optsNew.ankiVocabFields = fieldsToDict($('#vocab .anki-field-value'));
|
||||||
@ -174,6 +175,7 @@ $(document).ready(() => {
|
|||||||
$('#enable-anki-connect').prop('checked', opts.enableAnkiConnect);
|
$('#enable-anki-connect').prop('checked', opts.enableAnkiConnect);
|
||||||
|
|
||||||
$('#anki-card-tags').val(opts.ankiCardTags.join(' '));
|
$('#anki-card-tags').val(opts.ankiCardTags.join(' '));
|
||||||
|
$('#sentence-extent').val(opts.sentenceExtent);
|
||||||
|
|
||||||
$('.options-general input').change(onOptionsGeneralChanged);
|
$('.options-general input').change(onOptionsGeneralChanged);
|
||||||
$('.options-anki input').change(onOptionsAnkiChanged);
|
$('.options-anki input').change(onOptionsAnkiChanged);
|
||||||
|
@ -26,6 +26,7 @@ function sanitizeOptions(options) {
|
|||||||
enableAudioPlayback: true,
|
enableAudioPlayback: true,
|
||||||
enableAnkiConnect: false,
|
enableAnkiConnect: false,
|
||||||
ankiCardTags: ['yomichan'],
|
ankiCardTags: ['yomichan'],
|
||||||
|
sentenceExtent: 200,
|
||||||
ankiVocabDeck: '',
|
ankiVocabDeck: '',
|
||||||
ankiVocabModel: '',
|
ankiVocabModel: '',
|
||||||
ankiVocabFields: {},
|
ankiVocabFields: {},
|
||||||
|
@ -92,6 +92,11 @@
|
|||||||
<div class="col-sm-10"><input type="text" id="anki-card-tags" class="form-control"></div>
|
<div class="col-sm-10"><input type="text" id="anki-card-tags" class="form-control"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="sentence-extent" class="control-label col-sm-2">Sentence extent</label>
|
||||||
|
<div class="col-sm-10"><input type="number" min="1" id="sentence-extent" class="form-control"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<ul class="nav nav-tabs col-sm-offset-2 col-sm-10">
|
<ul class="nav nav-tabs col-sm-offset-2 col-sm-10">
|
||||||
<li class="active"><a href="#vocab" data-toggle="tab">Vocabulary</a></li>
|
<li class="active"><a href="#vocab" data-toggle="tab">Vocabulary</a></li>
|
||||||
<li><a href="#kanji" data-toggle="tab">Kanji</a></li>
|
<li><a href="#kanji" data-toggle="tab">Kanji</a></li>
|
||||||
|
@ -25,7 +25,6 @@ class Client {
|
|||||||
this.lastTextSource = null;
|
this.lastTextSource = null;
|
||||||
this.activateKey = 16;
|
this.activateKey = 16;
|
||||||
this.activateBtn = 2;
|
this.activateBtn = 2;
|
||||||
this.sentenceExtent = 200;
|
|
||||||
this.enabled = false;
|
this.enabled = false;
|
||||||
this.options = {};
|
this.options = {};
|
||||||
this.definitions = null;
|
this.definitions = null;
|
||||||
@ -97,7 +96,7 @@ class Client {
|
|||||||
} else {
|
} else {
|
||||||
textSource.setEndOffset(length);
|
textSource.setEndOffset(length);
|
||||||
|
|
||||||
const sentence = Client.extractSentence(textSource, this.sentenceExtent);
|
const sentence = Client.extractSentence(textSource, this.opts.sentenceExtent);
|
||||||
definitions.forEach((definition) => {
|
definitions.forEach((definition) => {
|
||||||
definition.url = window.location.href;
|
definition.url = window.location.href;
|
||||||
definition.sentence = sentence;
|
definition.sentence = sentence;
|
||||||
|
Loading…
Reference in New Issue
Block a user