summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/bg/js/options-form.js2
-rw-r--r--ext/bg/js/options.js1
-rw-r--r--ext/bg/options.html11
-rw-r--r--ext/fg/js/client.js3
4 files changed, 12 insertions, 5 deletions
diff --git a/ext/bg/js/options-form.js b/ext/bg/js/options-form.js
index 712b7243..c72508c6 100644
--- a/ext/bg/js/options-form.js
+++ b/ext/bg/js/options-form.js
@@ -49,6 +49,7 @@ function formToOptions(section, callback) {
break;
case 'anki':
optsNew.ankiCardTags = $('#anki-card-tags').val().split(/[,; ]+/);
+ optsNew.sentenceExtent = parseInt($('#sentence-extent').val());
optsNew.ankiVocabDeck = $('#anki-vocab-deck').val();
optsNew.ankiVocabModel = $('#anki-vocab-model').val();
optsNew.ankiVocabFields = fieldsToDict($('#vocab .anki-field-value'));
@@ -174,6 +175,7 @@ $(document).ready(() => {
$('#enable-anki-connect').prop('checked', opts.enableAnkiConnect);
$('#anki-card-tags').val(opts.ankiCardTags.join(' '));
+ $('#sentence-extent').val(opts.sentenceExtent);
$('.options-general input').change(onOptionsGeneralChanged);
$('.options-anki input').change(onOptionsAnkiChanged);
diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js
index 18707e43..44236e68 100644
--- a/ext/bg/js/options.js
+++ b/ext/bg/js/options.js
@@ -26,6 +26,7 @@ function sanitizeOptions(options) {
enableAudioPlayback: true,
enableAnkiConnect: false,
ankiCardTags: ['yomichan'],
+ sentenceExtent: 200,
ankiVocabDeck: '',
ankiVocabModel: '',
ankiVocabFields: {},
diff --git a/ext/bg/options.html b/ext/bg/options.html
index 17f6874d..7e03ea15 100644
--- a/ext/bg/options.html
+++ b/ext/bg/options.html
@@ -12,9 +12,9 @@
.tab-content {
border-bottom: 1px #ddd solid;
- border-left: 1px #ddd solid;
- border-right: 1px #ddd solid;
- padding: 10px;
+ border-left: 1px #ddd solid;
+ border-right: 1px #ddd solid;
+ padding: 10px;
}
.error-dlg {
@@ -92,6 +92,11 @@
<div class="col-sm-10"><input type="text" id="anki-card-tags" class="form-control"></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">
<li class="active"><a href="#vocab" data-toggle="tab">Vocabulary</a></li>
<li><a href="#kanji" data-toggle="tab">Kanji</a></li>
diff --git a/ext/fg/js/client.js b/ext/fg/js/client.js
index a8fbaa68..e59718d6 100644
--- a/ext/fg/js/client.js
+++ b/ext/fg/js/client.js
@@ -25,7 +25,6 @@ class Client {
this.lastTextSource = null;
this.activateKey = 16;
this.activateBtn = 2;
- this.sentenceExtent = 200;
this.enabled = false;
this.options = {};
this.definitions = null;
@@ -97,7 +96,7 @@ class Client {
} else {
textSource.setEndOffset(length);
- const sentence = Client.extractSentence(textSource, this.sentenceExtent);
+ const sentence = Client.extractSentence(textSource, this.opts.sentenceExtent);
definitions.forEach((definition) => {
definition.url = window.location.href;
definition.sentence = sentence;