Deleting dead options
This commit is contained in:
parent
07a1f94806
commit
0eb54e24c6
@ -68,7 +68,6 @@ function formToOptions(section) {
|
|||||||
case 'general':
|
case 'general':
|
||||||
optsNew.scanLength = parseInt($('#scan-length').val(), 10);
|
optsNew.scanLength = parseInt($('#scan-length').val(), 10);
|
||||||
optsNew.activateOnStartup = $('#activate-on-startup').prop('checked');
|
optsNew.activateOnStartup = $('#activate-on-startup').prop('checked');
|
||||||
optsNew.loadEnamDict = $('#load-enamdict').prop('checked');
|
|
||||||
optsNew.selectMatchedText = $('#select-matched-text').prop('checked');
|
optsNew.selectMatchedText = $('#select-matched-text').prop('checked');
|
||||||
optsNew.showAdvancedOptions = $('#show-advanced-options').prop('checked');
|
optsNew.showAdvancedOptions = $('#show-advanced-options').prop('checked');
|
||||||
optsNew.enableAudioPlayback = $('#enable-audio-playback').prop('checked');
|
optsNew.enableAudioPlayback = $('#enable-audio-playback').prop('checked');
|
||||||
@ -98,9 +97,9 @@ function populateAnkiDeckAndModel(opts) {
|
|||||||
|
|
||||||
const ankiDeck = $('.anki-deck');
|
const ankiDeck = $('.anki-deck');
|
||||||
ankiDeck.find('option').remove();
|
ankiDeck.find('option').remove();
|
||||||
yomi.api_getDeckNames({callback: (names) => {
|
yomi.api_getDeckNames({callback: names => {
|
||||||
if (names !== null) {
|
if (names !== null) {
|
||||||
names.forEach((name) => ankiDeck.append($('<option/>', {value: name, text: name})));
|
names.forEach(name => ankiDeck.append($('<option/>', {value: name, text: name})));
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#anki-term-deck').val(opts.ankiTermDeck);
|
$('#anki-term-deck').val(opts.ankiTermDeck);
|
||||||
@ -109,9 +108,9 @@ function populateAnkiDeckAndModel(opts) {
|
|||||||
|
|
||||||
const ankiModel = $('.anki-model');
|
const ankiModel = $('.anki-model');
|
||||||
ankiModel.find('option').remove();
|
ankiModel.find('option').remove();
|
||||||
yomi.api_getModelNames({callback: (names) => {
|
yomi.api_getModelNames({callback: names => {
|
||||||
if (names !== null) {
|
if (names !== null) {
|
||||||
names.forEach((name) => ankiModel.append($('<option/>', {value: name, text: name})));
|
names.forEach(name => ankiModel.append($('<option/>', {value: name, text: name})));
|
||||||
}
|
}
|
||||||
|
|
||||||
populateAnkiFields($('#anki-term-model').val(opts.ankiTermModel), opts);
|
populateAnkiFields($('#anki-term-model').val(opts.ankiTermModel), opts);
|
||||||
@ -122,7 +121,7 @@ function populateAnkiDeckAndModel(opts) {
|
|||||||
function updateAnkiStatus() {
|
function updateAnkiStatus() {
|
||||||
$('.error-dlg').hide();
|
$('.error-dlg').hide();
|
||||||
|
|
||||||
yomichan().api_getVersion({callback: (version) => {
|
yomichan().api_getVersion({callback: version => {
|
||||||
if (version === null) {
|
if (version === null) {
|
||||||
$('.error-dlg-connection').show();
|
$('.error-dlg-connection').show();
|
||||||
$('.options-anki-controls').hide();
|
$('.options-anki-controls').hide();
|
||||||
@ -145,19 +144,19 @@ function populateAnkiFields(element, opts) {
|
|||||||
const optKey = modelIdToFieldOptKey(modelId);
|
const optKey = modelIdToFieldOptKey(modelId);
|
||||||
const markers = modelIdToMarkers(modelId);
|
const markers = modelIdToMarkers(modelId);
|
||||||
|
|
||||||
yomichan().api_getModelFieldNames({modelName, callback: (names) => {
|
yomichan().api_getModelFieldNames({modelName, callback: names => {
|
||||||
const table = element.closest('.tab-pane').find('.anki-fields');
|
const table = element.closest('.tab-pane').find('.anki-fields');
|
||||||
table.find('tbody').remove();
|
table.find('tbody').remove();
|
||||||
|
|
||||||
const tbody = $('<tbody>');
|
const tbody = $('<tbody>');
|
||||||
names.forEach((name) => {
|
names.forEach(name => {
|
||||||
const button = $('<button>', {type: 'button', class: 'btn btn-default dropdown-toggle'});
|
const button = $('<button>', {type: 'button', class: 'btn btn-default dropdown-toggle'});
|
||||||
button.attr('data-toggle', 'dropdown').dropdown();
|
button.attr('data-toggle', 'dropdown').dropdown();
|
||||||
|
|
||||||
const markerItems = $('<ul>', {class: 'dropdown-menu dropdown-menu-right'});
|
const markerItems = $('<ul>', {class: 'dropdown-menu dropdown-menu-right'});
|
||||||
for (const marker of markers) {
|
for (const marker of markers) {
|
||||||
const link = $('<a>', {href: '#'}).text(`{${marker}}`);
|
const link = $('<a>', {href: '#'}).text(`{${marker}}`);
|
||||||
link.click((e) => {
|
link.click(e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
link.closest('.input-group').find('.anki-field-value').val(link.text()).trigger('change');
|
link.closest('.input-group').find('.anki-field-value').val(link.text()).trigger('change');
|
||||||
});
|
});
|
||||||
@ -232,7 +231,6 @@ $(document).ready(() => {
|
|||||||
loadOptions().then(opts => {
|
loadOptions().then(opts => {
|
||||||
$('#scan-length').val(opts.scanLength);
|
$('#scan-length').val(opts.scanLength);
|
||||||
$('#activate-on-startup').prop('checked', opts.activateOnStartup);
|
$('#activate-on-startup').prop('checked', opts.activateOnStartup);
|
||||||
$('#load-enamdict').prop('checked', opts.loadEnamDict);
|
|
||||||
$('#select-matched-text').prop('checked', opts.selectMatchedText);
|
$('#select-matched-text').prop('checked', opts.selectMatchedText);
|
||||||
$('#show-advanced-options').prop('checked', opts.showAdvancedOptions);
|
$('#show-advanced-options').prop('checked', opts.showAdvancedOptions);
|
||||||
$('#enable-audio-playback').prop('checked', opts.enableAudioPlayback);
|
$('#enable-audio-playback').prop('checked', opts.enableAudioPlayback);
|
||||||
|
@ -23,7 +23,6 @@ function sanitizeOptions(options) {
|
|||||||
activateOnStartup: false,
|
activateOnStartup: false,
|
||||||
selectMatchedText: true,
|
selectMatchedText: true,
|
||||||
showAdvancedOptions: false,
|
showAdvancedOptions: false,
|
||||||
loadEnamDict: false,
|
|
||||||
enableAudioPlayback: true,
|
enableAudioPlayback: true,
|
||||||
enableAnkiConnect: false,
|
enableAnkiConnect: false,
|
||||||
ankiCardTags: ['yomichan'],
|
ankiCardTags: ['yomichan'],
|
||||||
|
@ -28,11 +28,6 @@
|
|||||||
<h3>General Options</h3>
|
<h3>General Options</h3>
|
||||||
|
|
||||||
<form class="form-horizontal">
|
<form class="form-horizontal">
|
||||||
<div class="form-group options-advanced">
|
|
||||||
<label for="scan-length" class="control-label col-sm-2">Scan length</label>
|
|
||||||
<div class="col-sm-10"><input type="number" min="1" id="scan-length" class="form-control"></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<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">
|
||||||
@ -41,14 +36,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<div class="col-sm-offset-2 col-sm-10">
|
|
||||||
<div class="checkbox">
|
|
||||||
<label class="control-label"><input type="checkbox" id="load-enamdict"> Load <a href="http://www.edrdg.org/enamdict/enamdict_doc.html">ENAMDICT</a> (requires restart)</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<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">
|
||||||
@ -73,7 +60,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<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">
|
||||||
@ -81,6 +67,11 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group options-advanced">
|
||||||
|
<label for="scan-length" class="control-label col-sm-2">Scan length</label>
|
||||||
|
<div class="col-sm-10"><input type="number" min="1" id="scan-length" class="form-control"></div>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -46,19 +46,6 @@ function registerAudioLinks() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onDomContentLoaded() {
|
|
||||||
registerKanjiLinks();
|
|
||||||
registerAddNoteLinks();
|
|
||||||
registerAudioLinks();
|
|
||||||
}
|
|
||||||
|
|
||||||
function onMessage(e) {
|
|
||||||
const {action, params} = e.data, method = window['api_' + action];
|
|
||||||
if (typeof(method) === 'function') {
|
|
||||||
method(params);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function api_setActionState({index, state, sequence}) {
|
function api_setActionState({index, state, sequence}) {
|
||||||
for (const mode in state) {
|
for (const mode in state) {
|
||||||
const matches = document.querySelectorAll(`.action-bar[data-sequence="${sequence}"] .action-add-note[data-index="${index}"][data-mode="${mode}"]`);
|
const matches = document.querySelectorAll(`.action-bar[data-sequence="${sequence}"] .action-add-note[data-index="${index}"][data-mode="${mode}"]`);
|
||||||
@ -75,5 +62,15 @@ function api_setActionState({index, state, sequence}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', onDomContentLoaded, false);
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
window.addEventListener('message', onMessage);
|
registerKanjiLinks();
|
||||||
|
registerAddNoteLinks();
|
||||||
|
registerAudioLinks();
|
||||||
|
});
|
||||||
|
|
||||||
|
window.addEventListener('message', () => {
|
||||||
|
const {action, params} = e.data, method = window['api_' + action];
|
||||||
|
if (typeof(method) === 'function') {
|
||||||
|
method(params);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user