diff options
Diffstat (limited to 'ext/js')
-rw-r--r-- | ext/js/pages/settings/anki-controller.js | 15 | ||||
-rw-r--r-- | ext/js/pages/settings/anki-templates-controller.js | 19 | ||||
-rw-r--r-- | ext/js/pages/settings/dictionary-controller.js | 25 | ||||
-rw-r--r-- | ext/js/pages/settings/persistent-storage-controller.js | 13 | ||||
-rw-r--r-- | ext/js/pages/settings/popup-preview-controller.js | 27 | ||||
-rw-r--r-- | ext/js/pages/settings/profile-controller.js | 44 |
6 files changed, 11 insertions, 132 deletions
diff --git a/ext/js/pages/settings/anki-controller.js b/ext/js/pages/settings/anki-controller.js index 4e56594a..f324f2f4 100644 --- a/ext/js/pages/settings/anki-controller.js +++ b/ext/js/pages/settings/anki-controller.js @@ -60,16 +60,12 @@ class AnkiController { this._ankiErrorInvalidResponseInfo = document.querySelector('#anki-error-invalid-response-info'); this._ankiEnableCheckbox = document.querySelector('[data-setting="anki.enable"]'); 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]'); this._setupFieldMenus(); this._ankiErrorMessageDetailsToggle.addEventListener('click', this._onAnkiErrorMessageDetailsToggleClick.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) { 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) { const node = e.currentTarget; if (!node.checked) { return; } diff --git a/ext/js/pages/settings/anki-templates-controller.js b/ext/js/pages/settings/anki-templates-controller.js index 90e88f57..685c80d0 100644 --- a/ext/js/pages/settings/anki-templates-controller.js +++ b/ext/js/pages/settings/anki-templates-controller.js @@ -47,22 +47,8 @@ class AnkiTemplatesController { const testRenderButton = document.querySelector('#anki-card-templates-test-render-button'); const resetButton = document.querySelector('#anki-card-templates-reset-button'); 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'); - 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); testRenderButton.addEventListener('click', this._onRender.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); } - _onMarkerClicked(e) { - e.preventDefault(); - this._renderFieldInput.value = `{${e.target.textContent}}`; - } - _onRender(e) { e.preventDefault(); diff --git a/ext/js/pages/settings/dictionary-controller.js b/ext/js/pages/settings/dictionary-controller.js index 23a47f9a..f000aa62 100644 --- a/ext/js/pages/settings/dictionary-controller.js +++ b/ext/js/pages/settings/dictionary-controller.js @@ -47,12 +47,9 @@ class DictionaryEntry { this._detailsContainer = node.querySelector('.dictionary-details'); const enabledCheckbox = node.querySelector('.dictionary-enabled'); - const allowSecondarySearchesCheckbox = node.querySelector('.dictionary-allow-secondary-searches'); const priorityInput = node.querySelector('.dictionary-priority'); - const deleteButton = node.querySelector('.dictionary-delete-button'); const menuButton = node.querySelector('.dictionary-menu-button'); const detailsTable = node.querySelector('.dictionary-details-table'); - const detailsToggleLink = node.querySelector('.dictionary-details-toggle-link'); const outdatedContainer = node.querySelector('.dictionary-outdated-notification'); const titleNode = node.querySelector('.dictionary-title'); const versionNode = node.querySelector('.dictionary-version'); @@ -69,9 +66,6 @@ class DictionaryEntry { if (outdatedContainer !== null) { outdatedContainer.hidden = (version >= 3); } - if (detailsToggleLink !== null) { - detailsToggleLink.hidden = !hasDetails; - } if (enabledCheckbox !== null) { enabledCheckbox.dataset.setting = `dictionaries[${index}].enabled`; this._eventListeners.addEventListener(enabledCheckbox, 'settingChanged', this._onEnabledChanged.bind(this), false); @@ -79,19 +73,10 @@ class DictionaryEntry { if (priorityInput !== null) { 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) { this._eventListeners.addEventListener(menuButton, 'menuOpen', this._onMenuOpen.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() { @@ -111,11 +96,6 @@ class DictionaryEntry { // Private - _onDeleteButtonClicked(e) { - e.preventDefault(); - this._delete(); - } - _onMenuOpen(e) { const bodyNode = e.detail.menu.bodyNode; 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) { const {detail: {value}} = e; this._node.dataset.enabled = `${value}`; diff --git a/ext/js/pages/settings/persistent-storage-controller.js b/ext/js/pages/settings/persistent-storage-controller.js index e46dbe87..d4d38eda 100644 --- a/ext/js/pages/settings/persistent-storage-controller.js +++ b/ext/js/pages/settings/persistent-storage-controller.js @@ -24,12 +24,6 @@ class PersistentStorageController { this._persistentStorageCheckbox = document.querySelector('#storage-persistent-checkbox'); 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; } 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() { let isStoragePeristent = false; try { diff --git a/ext/js/pages/settings/popup-preview-controller.js b/ext/js/pages/settings/popup-preview-controller.js index f98b0679..b2ffbb3a 100644 --- a/ext/js/pages/settings/popup-preview-controller.js +++ b/ext/js/pages/settings/popup-preview-controller.js @@ -32,22 +32,17 @@ class PopupPreviewController { } 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._customCss = document.querySelector('#custom-popup-css'); - this._customOuterCss = document.querySelector('#custom-popup-outer-css'); - this._previewFrameContainer = document.querySelector('.preview-frame-container'); - - this._customCss.addEventListener('input', this._onCustomCssChange.bind(this), false); - this._customCss.addEventListener('settingChanged', this._onCustomCssChange.bind(this), false); - this._customOuterCss.addEventListener('input', this._onCustomOuterCssChange.bind(this), false); - this._customOuterCss.addEventListener('settingChanged', this._onCustomOuterCssChange.bind(this), false); - this._frame.addEventListener('load', this._onFrameLoad2.bind(this), false); - this._settingsController.on('optionsContextChanged', this._onOptionsContextChange.bind(this)); - } + this._frame = document.querySelector('#popup-preview-frame'); + this._customCss = document.querySelector('#custom-popup-css'); + this._customOuterCss = document.querySelector('#custom-popup-outer-css'); + this._previewFrameContainer = document.querySelector('.preview-frame-container'); + + this._customCss.addEventListener('input', this._onCustomCssChange.bind(this), false); + this._customCss.addEventListener('settingChanged', this._onCustomCssChange.bind(this), false); + this._customOuterCss.addEventListener('input', this._onCustomOuterCssChange.bind(this), false); + this._customOuterCss.addEventListener('settingChanged', this._onCustomOuterCssChange.bind(this), false); + this._frame.addEventListener('load', this._onFrameLoad2.bind(this), false); + this._settingsController.on('optionsContextChanged', this._onOptionsContextChange.bind(this)); } // Private diff --git a/ext/js/pages/settings/profile-controller.js b/ext/js/pages/settings/profile-controller.js index 3883e80a..802a5146 100644 --- a/ext/js/pages/settings/profile-controller.js +++ b/ext/js/pages/settings/profile-controller.js @@ -28,15 +28,10 @@ class ProfileController { this._profileActiveSelect = null; this._profileTargetSelect = null; this._profileCopySourceSelect = null; - this._profileNameInput = null; this._removeProfileNameElement = null; this._profileAddButton = null; - this._profileRemoveButton = null; this._profileRemoveConfirmButton = null; - this._profileCopyButton = null; this._profileCopyConfirmButton = null; - this._profileMoveUpButton = null; - this._profileMoveDownButton = null; this._profileEntryListContainer = null; this._profileConditionsProfileName = null; this._profileRemoveModal = null; @@ -63,15 +58,10 @@ class ProfileController { this._profileActiveSelect = document.querySelector('#profile-active-select'); this._profileTargetSelect = document.querySelector('#profile-target-select'); this._profileCopySourceSelect = document.querySelector('#profile-copy-source-select'); - this._profileNameInput = document.querySelector('#profile-name-input'); this._removeProfileNameElement = document.querySelector('#profile-remove-name'); this._profileAddButton = document.querySelector('#profile-add-button'); - this._profileRemoveButton = document.querySelector('#profile-remove-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._profileMoveUpButton = document.querySelector('#profile-move-up-button'); - this._profileMoveDownButton = document.querySelector('#profile-move-down-button'); this._profileEntryListContainer = document.querySelector('#profile-entry-list'); this._profileConditionsProfileName = document.querySelector('#profile-conditions-profile-name'); 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._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._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._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._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._settingsController.on('optionsChanged', this._onOptionsChanged.bind(this)); @@ -349,7 +334,6 @@ class ProfileController { this._profileCurrent = profileCurrent; const settingsProfileIndex = this._settingsController.profileIndex; - const settingsProfile = this._getProfile(settingsProfileIndex); // Udpate UI this._updateProfileSelectOptions(); @@ -357,13 +341,6 @@ class ProfileController { this._profileActiveSelect.value = `${profileCurrent}`; 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 this._profileConditionsUI.cleanup(); const conditionsProfile = this._getProfile(this._profileConditionsIndex !== null ? this._profileConditionsIndex : settingsProfileIndex); @@ -395,23 +372,10 @@ class ProfileController { this._settingsController.profileIndex = value; } - _onNameChanged(e) { - this.setProfileName(this._settingsController.profileIndex, e.currentTarget.value); - } - _onAdd() { this.duplicateProfile(this._settingsController.profileIndex); } - _onDelete(e) { - const profileIndex = this._settingsController.profileIndex; - if (e.shiftKey) { - this.deleteProfile(profileIndex); - } else { - this.openDeleteProfileModal(profileIndex); - } - } - _onDeleteConfirm() { const modal = this._profileRemoveModal; modal.setVisible(false); @@ -425,10 +389,6 @@ class ProfileController { this.deleteProfile(profileIndex); } - _onCopy() { - this.openCopyProfileModal(this._settingsController.profileIndex); - } - _onCopyConfirm() { const modal = this._profileCopyModal; modal.setVisible(false); @@ -445,10 +405,6 @@ class ProfileController { this.copyProfile(sourceProfileIndex, destinationProfileIndex); } - _onMove(offset) { - this.moveProfile(this._settingsController.profileIndex, offset); - } - _onConditionGroupCountChanged({count, profileIndex}) { if (profileIndex >= 0 && profileIndex < this._profileEntryList.length) { const profileEntry = this._profileEntryList[profileIndex]; |