Remove code for old settings page (#1588)

This commit is contained in:
toasted-nutbread 2021-04-03 13:32:53 -04:00 committed by GitHub
parent a9fe2d03b2
commit 0e26d9a667
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 10 additions and 131 deletions

View File

@ -60,16 +60,12 @@ class AnkiController {
this._ankiErrorInvalidResponseInfo = document.querySelector('#anki-error-invalid-response-info'); this._ankiErrorInvalidResponseInfo = document.querySelector('#anki-error-invalid-response-info');
this._ankiEnableCheckbox = document.querySelector('[data-setting="anki.enable"]'); this._ankiEnableCheckbox = document.querySelector('[data-setting="anki.enable"]');
this._ankiCardPrimary = document.querySelector('#anki-card-primary'); this._ankiCardPrimary = document.querySelector('#anki-card-primary');
const ankiCardPrimaryTypeSelect = document.querySelector('#anki-card-primary-type');
const ankiCardPrimaryTypeRadios = document.querySelectorAll('input[type=radio][name=anki-card-primary-type]'); const ankiCardPrimaryTypeRadios = document.querySelectorAll('input[type=radio][name=anki-card-primary-type]');
this._setupFieldMenus(); this._setupFieldMenus();
this._ankiErrorMessageDetailsToggle.addEventListener('click', this._onAnkiErrorMessageDetailsToggleClick.bind(this), false); this._ankiErrorMessageDetailsToggle.addEventListener('click', this._onAnkiErrorMessageDetailsToggleClick.bind(this), false);
if (this._ankiEnableCheckbox !== null) { this._ankiEnableCheckbox.addEventListener('settingChanged', this._onAnkiEnableChanged.bind(this), false); } if (this._ankiEnableCheckbox !== null) { this._ankiEnableCheckbox.addEventListener('settingChanged', this._onAnkiEnableChanged.bind(this), false); }
if (ankiCardPrimaryTypeSelect !== null) {
ankiCardPrimaryTypeSelect.addEventListener('change', this._onAnkiCardPrimaryTypeSelectChange.bind(this), false);
}
for (const input of ankiCardPrimaryTypeRadios) { for (const input of ankiCardPrimaryTypeRadios) {
input.addEventListener('change', this._onAnkiCardPrimaryTypeRadioChange.bind(this), false); input.addEventListener('change', this._onAnkiCardPrimaryTypeRadioChange.bind(this), false);
} }
@ -185,17 +181,6 @@ class AnkiController {
} }
} }
_onAnkiCardPrimaryTypeSelectChange(e) {
const node = e.currentTarget;
let ankiCardMenu;
if (node.selectedIndex >= 0) {
const option = node.options[node.selectedIndex];
ankiCardMenu = option.dataset.ankiCardMenu;
}
this._setAnkiCardPrimaryType(node.value, ankiCardMenu);
}
_onAnkiCardPrimaryTypeRadioChange(e) { _onAnkiCardPrimaryTypeRadioChange(e) {
const node = e.currentTarget; const node = e.currentTarget;
if (!node.checked) { return; } if (!node.checked) { return; }

View File

@ -47,22 +47,8 @@ class AnkiTemplatesController {
const testRenderButton = document.querySelector('#anki-card-templates-test-render-button'); const testRenderButton = document.querySelector('#anki-card-templates-test-render-button');
const resetButton = document.querySelector('#anki-card-templates-reset-button'); const resetButton = document.querySelector('#anki-card-templates-reset-button');
const resetConfirmButton = document.querySelector('#anki-card-templates-reset-button-confirm'); const resetConfirmButton = document.querySelector('#anki-card-templates-reset-button-confirm');
const fieldList = document.querySelector('#anki-card-templates-field-list');
this._fieldTemplateResetModal = this._modalController.getModal('anki-card-templates-reset'); this._fieldTemplateResetModal = this._modalController.getModal('anki-card-templates-reset');
const markers = new Set([
...this._ankiController.getFieldMarkers('terms'),
...this._ankiController.getFieldMarkers('kanji')
]);
if (fieldList !== null) {
const fragment = this._ankiController.getFieldMarkersHtml(markers);
fieldList.appendChild(fragment);
for (const node of fieldList.querySelectorAll('.marker-link')) {
node.addEventListener('click', this._onMarkerClicked.bind(this), false);
}
}
this._fieldTemplatesTextarea.addEventListener('change', this._onChanged.bind(this), false); this._fieldTemplatesTextarea.addEventListener('change', this._onChanged.bind(this), false);
testRenderButton.addEventListener('click', this._onRender.bind(this), false); testRenderButton.addEventListener('click', this._onRender.bind(this), false);
resetButton.addEventListener('click', this._onReset.bind(this), false); resetButton.addEventListener('click', this._onReset.bind(this), false);
@ -122,11 +108,6 @@ class AnkiTemplatesController {
this._validate(this._compileResultInfo, '{expression}', 'term-kanji', false, true); this._validate(this._compileResultInfo, '{expression}', 'term-kanji', false, true);
} }
_onMarkerClicked(e) {
e.preventDefault();
this._renderFieldInput.value = `{${e.target.textContent}}`;
}
_onRender(e) { _onRender(e) {
e.preventDefault(); e.preventDefault();

View File

@ -47,12 +47,9 @@ class DictionaryEntry {
this._detailsContainer = node.querySelector('.dictionary-details'); this._detailsContainer = node.querySelector('.dictionary-details');
const enabledCheckbox = node.querySelector('.dictionary-enabled'); const enabledCheckbox = node.querySelector('.dictionary-enabled');
const allowSecondarySearchesCheckbox = node.querySelector('.dictionary-allow-secondary-searches');
const priorityInput = node.querySelector('.dictionary-priority'); const priorityInput = node.querySelector('.dictionary-priority');
const deleteButton = node.querySelector('.dictionary-delete-button');
const menuButton = node.querySelector('.dictionary-menu-button'); const menuButton = node.querySelector('.dictionary-menu-button');
const detailsTable = node.querySelector('.dictionary-details-table'); const detailsTable = node.querySelector('.dictionary-details-table');
const detailsToggleLink = node.querySelector('.dictionary-details-toggle-link');
const outdatedContainer = node.querySelector('.dictionary-outdated-notification'); const outdatedContainer = node.querySelector('.dictionary-outdated-notification');
const titleNode = node.querySelector('.dictionary-title'); const titleNode = node.querySelector('.dictionary-title');
const versionNode = node.querySelector('.dictionary-version'); const versionNode = node.querySelector('.dictionary-version');
@ -69,9 +66,6 @@ class DictionaryEntry {
if (outdatedContainer !== null) { if (outdatedContainer !== null) {
outdatedContainer.hidden = (version >= 3); outdatedContainer.hidden = (version >= 3);
} }
if (detailsToggleLink !== null) {
detailsToggleLink.hidden = !hasDetails;
}
if (enabledCheckbox !== null) { if (enabledCheckbox !== null) {
enabledCheckbox.dataset.setting = `dictionaries[${index}].enabled`; enabledCheckbox.dataset.setting = `dictionaries[${index}].enabled`;
this._eventListeners.addEventListener(enabledCheckbox, 'settingChanged', this._onEnabledChanged.bind(this), false); this._eventListeners.addEventListener(enabledCheckbox, 'settingChanged', this._onEnabledChanged.bind(this), false);
@ -79,19 +73,10 @@ class DictionaryEntry {
if (priorityInput !== null) { if (priorityInput !== null) {
priorityInput.dataset.setting = `dictionaries[${index}].priority`; priorityInput.dataset.setting = `dictionaries[${index}].priority`;
} }
if (allowSecondarySearchesCheckbox !== null) {
allowSecondarySearchesCheckbox.dataset.setting = `dictionaries[${index}].allowSecondarySearches`;
}
if (deleteButton !== null) {
this._eventListeners.addEventListener(deleteButton, 'click', this._onDeleteButtonClicked.bind(this), false);
}
if (menuButton !== null) { if (menuButton !== null) {
this._eventListeners.addEventListener(menuButton, 'menuOpen', this._onMenuOpen.bind(this), false); this._eventListeners.addEventListener(menuButton, 'menuOpen', this._onMenuOpen.bind(this), false);
this._eventListeners.addEventListener(menuButton, 'menuClose', this._onMenuClose.bind(this), false); this._eventListeners.addEventListener(menuButton, 'menuClose', this._onMenuClose.bind(this), false);
} }
if (detailsToggleLink !== null && this._detailsContainer !== null) {
this._eventListeners.addEventListener(detailsToggleLink, 'click', this._onDetailsToggleLinkClicked.bind(this), false);
}
} }
cleanup() { cleanup() {
@ -111,11 +96,6 @@ class DictionaryEntry {
// Private // Private
_onDeleteButtonClicked(e) {
e.preventDefault();
this._delete();
}
_onMenuOpen(e) { _onMenuOpen(e) {
const bodyNode = e.detail.menu.bodyNode; const bodyNode = e.detail.menu.bodyNode;
const showDetails = bodyNode.querySelector('.popup-menu-item[data-menu-action="showDetails"]'); const showDetails = bodyNode.querySelector('.popup-menu-item[data-menu-action="showDetails"]');
@ -146,11 +126,6 @@ class DictionaryEntry {
} }
} }
_onDetailsToggleLinkClicked(e) {
e.preventDefault();
this._detailsContainer.hidden = !this._detailsContainer.hidden;
}
_onEnabledChanged(e) { _onEnabledChanged(e) {
const {detail: {value}} = e; const {detail: {value}} = e;
this._node.dataset.enabled = `${value}`; this._node.dataset.enabled = `${value}`;

View File

@ -24,12 +24,6 @@ class PersistentStorageController {
this._persistentStorageCheckbox = document.querySelector('#storage-persistent-checkbox'); this._persistentStorageCheckbox = document.querySelector('#storage-persistent-checkbox');
this._persistentStorageCheckbox.addEventListener('change', this._onPersistentStorageCheckboxChange.bind(this), false); this._persistentStorageCheckbox.addEventListener('change', this._onPersistentStorageCheckboxChange.bind(this), false);
const button = document.querySelector('#storage-persistent-button');
if (button !== null) {
button.hidden = false;
button.addEventListener('click', this._onPersistStorageButtonClick.bind(this), false);
}
if (!this._isPersistentStorageSupported()) { return; } if (!this._isPersistentStorageSupported()) { return; }
const info = document.querySelector('#storage-persistent-info'); const info = document.querySelector('#storage-persistent-info');
@ -60,13 +54,6 @@ class PersistentStorageController {
} }
} }
_onPersistStorageButtonClick() {
const {checked} = this._persistentStorageCheckbox;
if (checked) { return; }
this._persistentStorageCheckbox.checked = !checked;
this._persistentStorageCheckbox.dispatchEvent(new Event('change'));
}
async _attemptPersistStorage() { async _attemptPersistStorage() {
let isStoragePeristent = false; let isStoragePeristent = false;
try { try {

View File

@ -32,10 +32,6 @@ class PopupPreviewController {
} }
async prepare() { async prepare() {
const button = document.querySelector('#settings-popup-preview-button');
if (button !== null) {
button.addEventListener('click', this._onShowPopupPreviewButtonClick.bind(this), false);
} else {
this._frame = document.querySelector('#popup-preview-frame'); this._frame = document.querySelector('#popup-preview-frame');
this._customCss = document.querySelector('#custom-popup-css'); this._customCss = document.querySelector('#custom-popup-css');
this._customOuterCss = document.querySelector('#custom-popup-outer-css'); this._customOuterCss = document.querySelector('#custom-popup-outer-css');
@ -48,7 +44,6 @@ class PopupPreviewController {
this._frame.addEventListener('load', this._onFrameLoad2.bind(this), false); this._frame.addEventListener('load', this._onFrameLoad2.bind(this), false);
this._settingsController.on('optionsContextChanged', this._onOptionsContextChange.bind(this)); this._settingsController.on('optionsContextChanged', this._onOptionsContextChange.bind(this));
} }
}
// Private // Private

View File

@ -28,15 +28,10 @@ class ProfileController {
this._profileActiveSelect = null; this._profileActiveSelect = null;
this._profileTargetSelect = null; this._profileTargetSelect = null;
this._profileCopySourceSelect = null; this._profileCopySourceSelect = null;
this._profileNameInput = null;
this._removeProfileNameElement = null; this._removeProfileNameElement = null;
this._profileAddButton = null; this._profileAddButton = null;
this._profileRemoveButton = null;
this._profileRemoveConfirmButton = null; this._profileRemoveConfirmButton = null;
this._profileCopyButton = null;
this._profileCopyConfirmButton = null; this._profileCopyConfirmButton = null;
this._profileMoveUpButton = null;
this._profileMoveDownButton = null;
this._profileEntryListContainer = null; this._profileEntryListContainer = null;
this._profileConditionsProfileName = null; this._profileConditionsProfileName = null;
this._profileRemoveModal = null; this._profileRemoveModal = null;
@ -63,15 +58,10 @@ class ProfileController {
this._profileActiveSelect = document.querySelector('#profile-active-select'); this._profileActiveSelect = document.querySelector('#profile-active-select');
this._profileTargetSelect = document.querySelector('#profile-target-select'); this._profileTargetSelect = document.querySelector('#profile-target-select');
this._profileCopySourceSelect = document.querySelector('#profile-copy-source-select'); this._profileCopySourceSelect = document.querySelector('#profile-copy-source-select');
this._profileNameInput = document.querySelector('#profile-name-input');
this._removeProfileNameElement = document.querySelector('#profile-remove-name'); this._removeProfileNameElement = document.querySelector('#profile-remove-name');
this._profileAddButton = document.querySelector('#profile-add-button'); this._profileAddButton = document.querySelector('#profile-add-button');
this._profileRemoveButton = document.querySelector('#profile-remove-button');
this._profileRemoveConfirmButton = document.querySelector('#profile-remove-confirm-button'); this._profileRemoveConfirmButton = document.querySelector('#profile-remove-confirm-button');
this._profileCopyButton = document.querySelector('#profile-copy-button');
this._profileCopyConfirmButton = document.querySelector('#profile-copy-confirm-button'); this._profileCopyConfirmButton = document.querySelector('#profile-copy-confirm-button');
this._profileMoveUpButton = document.querySelector('#profile-move-up-button');
this._profileMoveDownButton = document.querySelector('#profile-move-down-button');
this._profileEntryListContainer = document.querySelector('#profile-entry-list'); this._profileEntryListContainer = document.querySelector('#profile-entry-list');
this._profileConditionsProfileName = document.querySelector('#profile-conditions-profile-name'); this._profileConditionsProfileName = document.querySelector('#profile-conditions-profile-name');
this._profileRemoveModal = this._modalController.getModal('profile-remove'); this._profileRemoveModal = this._modalController.getModal('profile-remove');
@ -82,14 +72,9 @@ class ProfileController {
if (this._profileActiveSelect !== null) { this._profileActiveSelect.addEventListener('change', this._onProfileActiveChange.bind(this), false); } if (this._profileActiveSelect !== null) { this._profileActiveSelect.addEventListener('change', this._onProfileActiveChange.bind(this), false); }
if (this._profileTargetSelect !== null) { this._profileTargetSelect.addEventListener('change', this._onProfileTargetChange.bind(this), false); } if (this._profileTargetSelect !== null) { this._profileTargetSelect.addEventListener('change', this._onProfileTargetChange.bind(this), false); }
if (this._profileNameInput !== null) { this._profileNameInput.addEventListener('change', this._onNameChanged.bind(this), false); }
if (this._profileAddButton !== null) { this._profileAddButton.addEventListener('click', this._onAdd.bind(this), false); } if (this._profileAddButton !== null) { this._profileAddButton.addEventListener('click', this._onAdd.bind(this), false); }
if (this._profileRemoveButton !== null) { this._profileRemoveButton.addEventListener('click', this._onDelete.bind(this), false); }
if (this._profileRemoveConfirmButton !== null) { this._profileRemoveConfirmButton.addEventListener('click', this._onDeleteConfirm.bind(this), false); } if (this._profileRemoveConfirmButton !== null) { this._profileRemoveConfirmButton.addEventListener('click', this._onDeleteConfirm.bind(this), false); }
if (this._profileCopyButton !== null) { this._profileCopyButton.addEventListener('click', this._onCopy.bind(this), false); }
if (this._profileCopyConfirmButton !== null) { this._profileCopyConfirmButton.addEventListener('click', this._onCopyConfirm.bind(this), false); } if (this._profileCopyConfirmButton !== null) { this._profileCopyConfirmButton.addEventListener('click', this._onCopyConfirm.bind(this), false); }
if (this._profileMoveUpButton !== null) { this._profileMoveUpButton.addEventListener('click', this._onMove.bind(this, -1), false); }
if (this._profileMoveDownButton !== null) { this._profileMoveDownButton.addEventListener('click', this._onMove.bind(this, 1), false); }
this._profileConditionsUI.on('conditionGroupCountChanged', this._onConditionGroupCountChanged.bind(this)); this._profileConditionsUI.on('conditionGroupCountChanged', this._onConditionGroupCountChanged.bind(this));
this._settingsController.on('optionsChanged', this._onOptionsChanged.bind(this)); this._settingsController.on('optionsChanged', this._onOptionsChanged.bind(this));
@ -349,7 +334,6 @@ class ProfileController {
this._profileCurrent = profileCurrent; this._profileCurrent = profileCurrent;
const settingsProfileIndex = this._settingsController.profileIndex; const settingsProfileIndex = this._settingsController.profileIndex;
const settingsProfile = this._getProfile(settingsProfileIndex);
// Udpate UI // Udpate UI
this._updateProfileSelectOptions(); this._updateProfileSelectOptions();
@ -357,13 +341,6 @@ class ProfileController {
this._profileActiveSelect.value = `${profileCurrent}`; this._profileActiveSelect.value = `${profileCurrent}`;
this._profileTargetSelect.value = `${settingsProfileIndex}`; this._profileTargetSelect.value = `${settingsProfileIndex}`;
if (this._profileRemoveButton !== null) { this._profileRemoveButton.disabled = (profiles.length <= 1); }
if (this._profileCopyButton !== null) { this._profileCopyButton.disabled = (profiles.length <= 1); }
if (this._profileMoveUpButton !== null) { this._profileMoveUpButton.disabled = (settingsProfileIndex <= 0); }
if (this._profileMoveDownButton !== null) { this._profileMoveDownButton.disabled = (settingsProfileIndex >= profiles.length - 1); }
if (this._profileNameInput !== null && settingsProfile !== null) { this._profileNameInput.value = settingsProfile.name; }
// Update profile conditions // Update profile conditions
this._profileConditionsUI.cleanup(); this._profileConditionsUI.cleanup();
const conditionsProfile = this._getProfile(this._profileConditionsIndex !== null ? this._profileConditionsIndex : settingsProfileIndex); const conditionsProfile = this._getProfile(this._profileConditionsIndex !== null ? this._profileConditionsIndex : settingsProfileIndex);
@ -395,23 +372,10 @@ class ProfileController {
this._settingsController.profileIndex = value; this._settingsController.profileIndex = value;
} }
_onNameChanged(e) {
this.setProfileName(this._settingsController.profileIndex, e.currentTarget.value);
}
_onAdd() { _onAdd() {
this.duplicateProfile(this._settingsController.profileIndex); this.duplicateProfile(this._settingsController.profileIndex);
} }
_onDelete(e) {
const profileIndex = this._settingsController.profileIndex;
if (e.shiftKey) {
this.deleteProfile(profileIndex);
} else {
this.openDeleteProfileModal(profileIndex);
}
}
_onDeleteConfirm() { _onDeleteConfirm() {
const modal = this._profileRemoveModal; const modal = this._profileRemoveModal;
modal.setVisible(false); modal.setVisible(false);
@ -425,10 +389,6 @@ class ProfileController {
this.deleteProfile(profileIndex); this.deleteProfile(profileIndex);
} }
_onCopy() {
this.openCopyProfileModal(this._settingsController.profileIndex);
}
_onCopyConfirm() { _onCopyConfirm() {
const modal = this._profileCopyModal; const modal = this._profileCopyModal;
modal.setVisible(false); modal.setVisible(false);
@ -445,10 +405,6 @@ class ProfileController {
this.copyProfile(sourceProfileIndex, destinationProfileIndex); this.copyProfile(sourceProfileIndex, destinationProfileIndex);
} }
_onMove(offset) {
this.moveProfile(this._settingsController.profileIndex, offset);
}
_onConditionGroupCountChanged({count, profileIndex}) { _onConditionGroupCountChanged({count, profileIndex}) {
if (profileIndex >= 0 && profileIndex < this._profileEntryList.length) { if (profileIndex >= 0 && profileIndex < this._profileEntryList.length) {
const profileEntry = this._profileEntryList[profileIndex]; const profileEntry = this._profileEntryList[profileIndex];