Simplify how option visibility is changed
This commit is contained in:
parent
91c01e0a7e
commit
44638b7ceb
@ -17,9 +17,16 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#anki-spinner, #anki-general, #anki-error,
|
#anki-spinner, #anki-error,
|
||||||
#dict-spinner, #dict-error, #dict-warning, #dict-purge, #dict-import-progress,
|
#dict-spinner, #dict-error, #dict-warning, #dict-purge, #dict-import-progress,
|
||||||
#debug, .options-advanced, .storage-hidden, #storage-spinner {
|
.storage-hidden, #storage-spinner {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
html:root:not([data-options-anki-enable=true]) #anki-general,
|
||||||
|
html:root:not([data-options-general-debug-info=true]) .debug,
|
||||||
|
html:root:not([data-options-general-show-advanced=true]) .options-advanced,
|
||||||
|
html:root:not([data-options-general-result-output-mode=merge]) #dict-main-group {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,36 +171,16 @@ function formSetupEventListeners() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function formUpdateVisibility(options) {
|
function formUpdateVisibility(options) {
|
||||||
const general = $('#anki-general');
|
document.documentElement.dataset.optionsAnkiEnable = `${!!options.anki.enable}`;
|
||||||
if (options.anki.enable) {
|
document.documentElement.dataset.optionsGeneralDebugInfo = `${!!options.general.debugInfo}`;
|
||||||
general.show();
|
document.documentElement.dataset.optionsGeneralShowAdvanced = `${!!options.general.showAdvanced}`;
|
||||||
} else {
|
document.documentElement.dataset.optionsGeneralResultOutputMode = `${options.general.resultOutputMode}`;
|
||||||
general.hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
const advanced = $('.options-advanced');
|
|
||||||
if (options.general.showAdvanced) {
|
|
||||||
advanced.show();
|
|
||||||
} else {
|
|
||||||
advanced.hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
const mainGroup = $('#dict-main-group');
|
|
||||||
if (options.general.resultOutputMode === 'merge') {
|
|
||||||
mainGroup.show();
|
|
||||||
} else {
|
|
||||||
mainGroup.hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
const debug = $('#debug');
|
|
||||||
if (options.general.debugInfo) {
|
if (options.general.debugInfo) {
|
||||||
const temp = utilIsolate(options);
|
const temp = utilIsolate(options);
|
||||||
temp.anki.fieldTemplates = '...';
|
temp.anki.fieldTemplates = '...';
|
||||||
const text = JSON.stringify(temp, null, 4);
|
const text = JSON.stringify(temp, null, 4);
|
||||||
debug.html(handlebarsEscape(text));
|
$('#debug').text(text);
|
||||||
debug.show();
|
|
||||||
} else {
|
|
||||||
debug.hide();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -673,7 +673,7 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<pre id="debug"></pre>
|
<pre id="debug" class="debug"></pre>
|
||||||
|
|
||||||
<div class="pull-right bottom-links">
|
<div class="pull-right bottom-links">
|
||||||
<small><span id="extension-info"></span> • <a href="search.html">Search</a> • <a href="https://foosoft.net/projects/yomichan/" target="_blank" rel="noopener">Homepage</a> • <a href="legal.html">Legal</a></small>
|
<small><span id="extension-info"></span> • <a href="search.html">Search</a> • <a href="https://foosoft.net/projects/yomichan/" target="_blank" rel="noopener">Homepage</a> • <a href="legal.html">Legal</a></small>
|
||||||
|
Loading…
Reference in New Issue
Block a user