summaryrefslogtreecommitdiff
path: root/ext/bg/js/settings
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg/js/settings')
-rw-r--r--ext/bg/js/settings/anki.js26
-rw-r--r--ext/bg/js/settings/main.js20
-rw-r--r--ext/bg/js/settings/popup-preview-frame.js14
3 files changed, 46 insertions, 14 deletions
diff --git a/ext/bg/js/settings/anki.js b/ext/bg/js/settings/anki.js
index 5f7989b8..9adb2f2a 100644
--- a/ext/bg/js/settings/anki.js
+++ b/ext/bg/js/settings/anki.js
@@ -37,13 +37,35 @@ function _ankiSetError(error) {
if (error) {
node.hidden = false;
node.textContent = `${error}`;
- }
- else {
+ _ankiSetErrorData(node, error);
+ } else {
node.hidden = true;
node.textContent = '';
}
}
+function _ankiSetErrorData(node, error) {
+ const data = error.data;
+ let message = '';
+ if (typeof data !== 'undefined') {
+ message += `${JSON.stringify(data, null, 4)}\n\n`;
+ }
+ message += `${error.stack}`.trimRight();
+
+ const button = document.createElement('a');
+ button.className = 'error-data-show-button';
+
+ const content = document.createElement('div');
+ content.className = 'error-data-container';
+ content.textContent = message;
+ content.hidden = true;
+
+ button.addEventListener('click', () => content.hidden = !content.hidden, false);
+
+ node.appendChild(button);
+ node.appendChild(content);
+}
+
function _ankiSetDropdownOptions(dropdown, optionValues) {
const fragment = document.createDocumentFragment();
for (const optionValue of optionValues) {
diff --git a/ext/bg/js/settings/main.js b/ext/bg/js/settings/main.js
index 56828a15..3bf65eda 100644
--- a/ext/bg/js/settings/main.js
+++ b/ext/bg/js/settings/main.js
@@ -44,6 +44,9 @@ async function formRead(options) {
options.general.popupVerticalOffset = parseInt($('#popup-vertical-offset').val(), 10);
options.general.popupHorizontalOffset2 = parseInt($('#popup-horizontal-offset2').val(), 0);
options.general.popupVerticalOffset2 = parseInt($('#popup-vertical-offset2').val(), 10);
+ options.general.popupScalingFactor = parseInt($('#popup-scaling-factor').val(), 10);
+ options.general.popupScaleRelativeToPageZoom = $('#popup-scale-relative-to-page-zoom').prop('checked');
+ options.general.popupScaleRelativeToVisualViewport = $('#popup-scale-relative-to-visual-viewport').prop('checked');
options.general.popupTheme = $('#popup-theme').val();
options.general.popupOuterTheme = $('#popup-outer-theme').val();
options.general.customPopupCss = $('#custom-popup-css').val();
@@ -69,8 +72,15 @@ async function formRead(options) {
options.scanning.modifier = $('#scan-modifier-key').val();
options.scanning.popupNestingMaxDepth = parseInt($('#popup-nesting-max-depth').val(), 10);
+ options.translation.convertHalfWidthCharacters = $('#translation-convert-half-width-characters').val();
+ options.translation.convertNumericCharacters = $('#translation-convert-numeric-characters').val();
+ options.translation.convertAlphabeticCharacters = $('#translation-convert-alphabetic-characters').val();
+ options.translation.convertHiraganaToKatakana = $('#translation-convert-hiragana-to-katakana').val();
+ options.translation.convertKatakanaToHiragana = $('#translation-convert-katakana-to-hiragana').val();
+
options.parsing.enableScanningParser = $('#parsing-scan-enable').prop('checked');
options.parsing.enableMecabParser = $('#parsing-mecab-enable').prop('checked');
+ options.parsing.termSpacing = $('#parsing-term-spacing').prop('checked');
options.parsing.readingMode = $('#parsing-reading-mode').val();
const optionsAnkiEnableOld = options.anki.enable;
@@ -109,6 +119,9 @@ async function formWrite(options) {
$('#popup-vertical-offset').val(options.general.popupVerticalOffset);
$('#popup-horizontal-offset2').val(options.general.popupHorizontalOffset2);
$('#popup-vertical-offset2').val(options.general.popupVerticalOffset2);
+ $('#popup-scaling-factor').val(options.general.popupScalingFactor);
+ $('#popup-scale-relative-to-page-zoom').prop('checked', options.general.popupScaleRelativeToPageZoom);
+ $('#popup-scale-relative-to-visual-viewport').prop('checked', options.general.popupScaleRelativeToVisualViewport);
$('#popup-theme').val(options.general.popupTheme);
$('#popup-outer-theme').val(options.general.popupOuterTheme);
$('#custom-popup-css').val(options.general.customPopupCss);
@@ -134,8 +147,15 @@ async function formWrite(options) {
$('#scan-modifier-key').val(options.scanning.modifier);
$('#popup-nesting-max-depth').val(options.scanning.popupNestingMaxDepth);
+ $('#translation-convert-half-width-characters').val(options.translation.convertHalfWidthCharacters);
+ $('#translation-convert-numeric-characters').val(options.translation.convertNumericCharacters);
+ $('#translation-convert-alphabetic-characters').val(options.translation.convertAlphabeticCharacters);
+ $('#translation-convert-hiragana-to-katakana').val(options.translation.convertHiraganaToKatakana);
+ $('#translation-convert-katakana-to-hiragana').val(options.translation.convertKatakanaToHiragana);
+
$('#parsing-scan-enable').prop('checked', options.parsing.enableScanningParser);
$('#parsing-mecab-enable').prop('checked', options.parsing.enableMecabParser);
+ $('#parsing-term-spacing').prop('checked', options.parsing.termSpacing);
$('#parsing-reading-mode').val(options.parsing.readingMode);
$('#anki-enable').prop('checked', options.anki.enable);
diff --git a/ext/bg/js/settings/popup-preview-frame.js b/ext/bg/js/settings/popup-preview-frame.js
index 2b727cbd..37a4b416 100644
--- a/ext/bg/js/settings/popup-preview-frame.js
+++ b/ext/bg/js/settings/popup-preview-frame.js
@@ -35,7 +35,6 @@ class SettingsPopupPreview {
async prepare() {
// Setup events
- window.addEventListener('resize', (e) => this.onWindowResize(e), false);
window.addEventListener('message', (e) => this.onMessage(e), false);
const themeDarkCheckbox = document.querySelector('#theme-dark-checkbox');
@@ -96,16 +95,6 @@ class SettingsPopupPreview {
return result;
}
- onWindowResize() {
- if (this.frontend === null) { return; }
- const textSource = this.textSource;
- if (textSource === null) { return; }
-
- const elementRect = textSource.getRect();
- const writingMode = textSource.getWritingMode();
- this.frontend.popup.showContent(elementRect, writingMode);
- }
-
onMessage(e) {
const {action, params} = e.data;
const handler = SettingsPopupPreview._messageHandlers.get(action);
@@ -159,10 +148,11 @@ class SettingsPopupPreview {
const range = document.createRange();
range.selectNode(textNode);
- const source = new TextSourceRange(range, range.toString(), null);
+ const source = new TextSourceRange(range, range.toString(), null, null);
try {
await this.frontend.onSearchSource(source, 'script');
+ this.frontend.setCurrentTextSource(source);
} finally {
source.cleanup();
}