Add screenshot settings

This commit is contained in:
toasted-nutbread 2019-08-15 19:56:14 -04:00
parent 0f0adf750c
commit 3a5b06bd10
4 changed files with 20 additions and 2 deletions

View File

@ -224,6 +224,7 @@ function optionsSetDefaults(options) {
server: 'http://127.0.0.1:8765',
tags: ['yomichan'],
sentenceExt: 200,
screenshot: {format: 'png', quality: 92},
terms: {deck: '', model: '', fields: {}},
kanji: {deck: '', model: '', fields: {}},
fieldTemplates: optionsFieldTemplates()

View File

@ -51,6 +51,8 @@ async function formRead() {
optionsNew.anki.tags = $('#card-tags').val().split(/[,; ]+/);
optionsNew.anki.sentenceExt = parseInt($('#sentence-detection-extent').val(), 10);
optionsNew.anki.server = $('#interface-server').val();
optionsNew.anki.screenshot.format = $('#screenshot-format').val();
optionsNew.anki.screenshot.quality = parseInt($('#screenshot-quality').val(), 10);
optionsNew.anki.fieldTemplates = $('#field-templates').val();
if (optionsOld.anki.enable && !ankiErrorShown()) {
@ -188,6 +190,8 @@ async function onReady() {
$('#card-tags').val(options.anki.tags.join(' '));
$('#sentence-detection-extent').val(options.anki.sentenceExt);
$('#interface-server').val(options.anki.server);
$('#screenshot-format').val(options.anki.screenshot.format);
$('#screenshot-quality').val(options.anki.screenshot.quality);
$('#field-templates').val(options.anki.fieldTemplates);
$('#field-templates-reset').click(utilAsync(onAnkiFieldTemplatesReset));
$('input, select, textarea').not('.anki-model').change(utilAsync(onFormOptionsChanged));

View File

@ -293,6 +293,19 @@
<input type="text" id="interface-server" class="form-control">
</div>
<div class="form-group options-advanced">
<label for="screenshot-format">Screenshot format</label>
<select class="form-control" id="screenshot-format">
<option value="png">PNG</option>
<option value="jpeg">JPEG</option>
</select>
</div>
<div class="form-group options-advanced">
<label for="screenshot-quality">Screenshot quality (JPEG only)</label>
<input type="number" min="0" max="100" step="1" id="screenshot-quality" class="form-control">
</div>
<div id="anki-format">
<p class="help-block">
Specify the information you would like included in your flashcards in the field editor below.

View File

@ -508,8 +508,8 @@ class Display {
await this.setPopupVisible(false);
await Display.delay(1); // Wait for popup to be hidden.
const format = 'png';
const dataUrl = await apiScreenshotGet({format});
const {format, quality} = this.options.anki.screenshot;
const dataUrl = await apiScreenshotGet({format, quality});
if (!dataUrl || dataUrl.error) { return; }
return {dataUrl, format};