Updating options page
This commit is contained in:
parent
61993db702
commit
eaa7291683
@ -18,16 +18,18 @@
|
|||||||
|
|
||||||
|
|
||||||
function optionsToForm(opts) {
|
function optionsToForm(opts) {
|
||||||
$('#scanLength').val(opts.scanLength);
|
$('#enableAnkiConnect').prop('checked', opts.ankiConnect);
|
||||||
|
$('#selectMatchedText').prop('checked', opts.selectMatchedText);
|
||||||
$('#loadOnStartup').prop('checked', opts.loadOnStartup);
|
$('#loadOnStartup').prop('checked', opts.loadOnStartup);
|
||||||
$('#highlightText').prop('checked', opts.highlightText);
|
$('#scanLength').val(opts.scanLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
function formToOptions() {
|
function formToOptions() {
|
||||||
return sanitizeOptions({
|
return sanitizeOptions({
|
||||||
scanLength: $('#scanLength').val(),
|
|
||||||
loadOnStartup: $('#loadOnStartup').prop('checked'),
|
loadOnStartup: $('#loadOnStartup').prop('checked'),
|
||||||
highlightText: $('#highlightText').prop('checked')
|
selectMatchedText: $('#selectMatchedText').prop('checked'),
|
||||||
|
ankiConnect: $('#enableAnkiConnect').prop('checked'),
|
||||||
|
scanLength: $('#scanLength').val()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,9 +19,10 @@
|
|||||||
|
|
||||||
function sanitizeOptions(options) {
|
function sanitizeOptions(options) {
|
||||||
const defaults = {
|
const defaults = {
|
||||||
scanLength: 20,
|
|
||||||
loadOnStartup: false,
|
loadOnStartup: false,
|
||||||
highlightText: true
|
selectMatchedText: true,
|
||||||
|
enableAnkiConnect: false,
|
||||||
|
scanLength: 20
|
||||||
};
|
};
|
||||||
|
|
||||||
for (const key in defaults) {
|
for (const key in defaults) {
|
||||||
|
@ -34,7 +34,15 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="col-sm-offset-2 col-sm-10">
|
<div class="col-sm-offset-2 col-sm-10">
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
<label><input type="checkbox" id="highlightText" checked> Highlight text</label>
|
<label><input type="checkbox" id="selectMatchedText" checked> Select matched text</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-offset-2 col-sm-10">
|
||||||
|
<div class="checkbox">
|
||||||
|
<label><input type="checkbox" id="enableAnkiConnect" checked> Enable AnkiConnect</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -126,7 +126,7 @@ class Client {
|
|||||||
showPopup(range, content) {
|
showPopup(range, content) {
|
||||||
this.popup.showNextTo(range.getRect(), content);
|
this.popup.showNextTo(range.getRect(), content);
|
||||||
|
|
||||||
if (this.options.highlightText) {
|
if (this.options.selectMatchedText) {
|
||||||
range.select();
|
range.select();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ class Client {
|
|||||||
hidePopup() {
|
hidePopup() {
|
||||||
this.popup.hide();
|
this.popup.hide();
|
||||||
|
|
||||||
if (this.options.highlightText && this.lastRange !== null) {
|
if (this.options.selectMatchedText && this.lastRange !== null) {
|
||||||
this.lastRange.deselect();
|
this.lastRange.deselect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user