From 4da4827bcbcdd1ef163f635d9b29416ff272b0bb Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Mon, 27 Nov 2023 12:48:14 -0500 Subject: Add JSDoc type annotations to project (rebased) --- ext/js/pages/settings/profile-conditions-ui.js | 395 +++++++++++++++++++++---- 1 file changed, 336 insertions(+), 59 deletions(-) (limited to 'ext/js/pages/settings/profile-conditions-ui.js') diff --git a/ext/js/pages/settings/profile-conditions-ui.js b/ext/js/pages/settings/profile-conditions-ui.js index bd790b1b..5ebd9011 100644 --- a/ext/js/pages/settings/profile-conditions-ui.js +++ b/ext/js/pages/settings/profile-conditions-ui.js @@ -19,21 +19,41 @@ import {EventDispatcher, EventListenerCollection} from '../../core.js'; import {KeyboardMouseInputField} from './keyboard-mouse-input-field.js'; +/* global + * DocumentUtil + * KeyboardMouseInputField + */ + +/** + * @augments EventDispatcher + */ export class ProfileConditionsUI extends EventDispatcher { + /** + * @param {SettingsController} settingsController + */ constructor(settingsController) { super(); + /** @type {SettingsController} */ this._settingsController = settingsController; + /** @type {?import('environment').OperatingSystem} */ this._os = null; + /** @type {?HTMLElement} */ this._conditionGroupsContainer = null; + /** @type {?HTMLElement} */ this._addConditionGroupButton = null; + /** @type {ProfileConditionGroupUI[]} */ this._children = []; + /** @type {EventListenerCollection} */ this._eventListeners = new EventListenerCollection(); + /** @type {import('profile-conditions-ui').DescriptorType} */ this._defaultType = 'popupLevel'; + /** @type {number} */ this._profileIndex = 0; const validateInteger = this._validateInteger.bind(this); const normalizeInteger = this._normalizeInteger.bind(this); const validateFlags = this._validateFlags.bind(this); const normalizeFlags = this._normalizeFlags.bind(this); + /** @type {Map} */ this._descriptors = new Map([ [ 'popupLevel', @@ -88,19 +108,23 @@ export class ProfileConditionsUI extends EventDispatcher { } ] ]); + /** @type {Set} */ this._validFlags = new Set([ 'clipboard' ]); } + /** @type {SettingsController} */ get settingsController() { return this._settingsController; } + /** @type {number} */ get profileIndex() { return this._profileIndex; } + /** @type {?import('environment').OperatingSystem} */ get os() { return this._os; } @@ -109,6 +133,9 @@ export class ProfileConditionsUI extends EventDispatcher { this._os = value; } + /** + * @param {number} profileIndex + */ async prepare(profileIndex) { const options = await this._settingsController.getOptionsFull(); const {profiles} = options; @@ -116,8 +143,8 @@ export class ProfileConditionsUI extends EventDispatcher { const {conditionGroups} = profiles[profileIndex]; this._profileIndex = profileIndex; - this._conditionGroupsContainer = document.querySelector('#profile-condition-groups'); - this._addConditionGroupButton = document.querySelector('#profile-add-condition-group'); + this._conditionGroupsContainer = /** @type {HTMLElement} */ (document.querySelector('#profile-condition-groups')); + this._addConditionGroupButton = /** @type {HTMLElement} */ (document.querySelector('#profile-add-condition-group')); for (let i = 0, ii = conditionGroups.length; i < ii; ++i) { this._addConditionGroup(conditionGroups[i], i); @@ -126,6 +153,7 @@ export class ProfileConditionsUI extends EventDispatcher { this._eventListeners.addEventListener(this._addConditionGroupButton, 'click', this._onAddConditionGroupButtonClick.bind(this), false); } + /** */ cleanup() { this._eventListeners.removeAllEventListeners(); @@ -138,10 +166,17 @@ export class ProfileConditionsUI extends EventDispatcher { this._addConditionGroupButton = null; } - instantiateTemplate(names) { - return this._settingsController.instantiateTemplate(names); + /** + * @param {string} name + * @returns {HTMLElement} + */ + instantiateTemplate(name) { + return /** @type {HTMLElement} */ (this._settingsController.instantiateTemplate(name)); } + /** + * @returns {import('profile-conditions-ui').DescriptorInfo[]} + */ getDescriptorTypes() { const results = []; for (const [name, {displayName}] of this._descriptors.entries()) { @@ -150,6 +185,10 @@ export class ProfileConditionsUI extends EventDispatcher { return results; } + /** + * @param {import('profile-conditions-ui').DescriptorType} type + * @returns {import('profile-conditions-ui').OperatorInfo[]} + */ getDescriptorOperators(type) { const info = this._descriptors.get(type); const results = []; @@ -161,15 +200,27 @@ export class ProfileConditionsUI extends EventDispatcher { return results; } + /** + * @returns {import('profile-conditions-ui').DescriptorType} + */ getDefaultType() { return this._defaultType; } + /** + * @param {import('profile-conditions-ui').DescriptorType} type + * @returns {string} + */ getDefaultOperator(type) { const info = this._descriptors.get(type); return (typeof info !== 'undefined' ? info.defaultOperator : ''); } + /** + * @param {import('profile-conditions-ui').DescriptorType} type + * @param {string} operator + * @returns {import('profile-conditions-ui').Operator} + */ getOperatorDetails(type, operator) { const info = this._getOperatorDetails(type, operator); @@ -192,6 +243,9 @@ export class ProfileConditionsUI extends EventDispatcher { }; } + /** + * @returns {import('settings').ProfileCondition} + */ getDefaultCondition() { const type = this.getDefaultType(); const operator = this.getDefaultOperator(type); @@ -199,6 +253,10 @@ export class ProfileConditionsUI extends EventDispatcher { return {type, operator, value}; } + /** + * @param {ProfileConditionGroupUI} child + * @returns {boolean} + */ removeConditionGroup(child) { const index = child.index; if (index < 0 || index >= this._children.length) { return false; } @@ -226,22 +284,53 @@ export class ProfileConditionsUI extends EventDispatcher { return true; } + /** + * @param {string} value + * @returns {string[]} + */ splitValue(value) { return value.split(/[,;\s]+/).map((v) => v.trim().toLowerCase()).filter((v) => v.length > 0); } + /** + * @param {string} property + * @returns {string} + */ getPath(property) { property = (typeof property === 'string' ? `.${property}` : ''); return `profiles[${this.profileIndex}]${property}`; } + /** + * @param {HTMLInputElement} inputNode + * @param {?HTMLButtonElement} mouseButton + * @returns {KeyboardMouseInputField} + */ createKeyboardMouseInputField(inputNode, mouseButton) { return new KeyboardMouseInputField(inputNode, mouseButton, this._os); } + /** + * @param {string} value + * @returns {?import('settings').ProfileConditionType} + */ + static normalizeProfileConditionType(value) { + switch (value) { + case 'popupLevel': + case 'url': + case 'modifierKeys': + case 'flags': + return value; + default: + return null; + } + } + // Private + /** */ _onAddConditionGroupButtonClick() { + /** @type {import('settings').ProfileConditionGroup} */ const conditionGroup = { conditions: [this.getDefaultCondition()] }; @@ -260,28 +349,50 @@ export class ProfileConditionsUI extends EventDispatcher { this._triggerConditionGroupCountChanged(this._children.length); } + /** + * @param {import('settings').ProfileConditionGroup} conditionGroup + * @param {number} index + * @returns {ProfileConditionGroupUI} + */ _addConditionGroup(conditionGroup, index) { const child = new ProfileConditionGroupUI(this, index); child.prepare(conditionGroup); this._children.push(child); - this._conditionGroupsContainer.appendChild(child.node); + /** @type {HTMLElement} */ (this._conditionGroupsContainer).appendChild(child.node); return child; } + /** + * @param {import('profile-conditions-ui').DescriptorType} type + * @param {string} operator + * @returns {import('profile-conditions-ui').OperatorInternal|undefined} + */ _getOperatorDetails(type, operator) { const info = this._descriptors.get(type); return (typeof info !== 'undefined' ? info.operators.get(operator) : void 0); } + /** + * @param {string} value + * @returns {boolean} + */ _validateInteger(value) { const number = Number.parseFloat(value); return Number.isFinite(number) && Math.floor(number) === number; } + /** + * @param {string} value + * @returns {boolean} + */ _validateDomains(value) { return this.splitValue(value).length > 0; } + /** + * @param {string} value + * @returns {boolean} + */ _validateRegExp(value) { try { new RegExp(value, 'i'); @@ -291,15 +402,27 @@ export class ProfileConditionsUI extends EventDispatcher { } } + /** + * @param {string} value + * @returns {string} + */ _normalizeInteger(value) { const number = Number.parseFloat(value); return `${number}`; } + /** + * @param {string} value + * @returns {string} + */ _normalizeDomains(value) { return this.splitValue(value).join(', '); } + /** + * @param {string} value + * @returns {boolean} + */ _validateFlags(value) { const flags = this.splitValue(value); for (const flag of flags) { @@ -310,34 +433,57 @@ export class ProfileConditionsUI extends EventDispatcher { return flags.length > 0; } + /** + * @param {string} value + * @returns {string} + */ _normalizeFlags(value) { return [...new Set(this.splitValue(value))].join(', '); } + /** + * @param {number} count + */ _triggerConditionGroupCountChanged(count) { - this.trigger('conditionGroupCountChanged', {count, profileIndex: this._profileIndex}); + /** @type {import('profile-conditions-ui').ConditionGroupCountChangedEvent} */ + const event = {count, profileIndex: this._profileIndex}; + this.trigger('conditionGroupCountChanged', event); } } class ProfileConditionGroupUI { + /** + * @param {ProfileConditionsUI} parent + * @param {number} index + */ constructor(parent, index) { + /** @type {ProfileConditionsUI} */ this._parent = parent; + /** @type {number} */ this._index = index; - this._node = null; - this._conditionContainer = null; - this._addConditionButton = null; + /** @type {HTMLElement} */ + this._node = /** @type {HTMLElement} */ (this._parent.instantiateTemplate('profile-condition-group')); + /** @type {HTMLElement} */ + this._conditionContainer = /** @type {HTMLElement} */ (this._node.querySelector('.profile-condition-list')); + /** @type {HTMLElement} */ + this._addConditionButton = /** @type {HTMLElement} */ (this._node.querySelector('.profile-condition-add-button')); + /** @type {ProfileConditionUI[]} */ this._children = []; + /** @type {EventListenerCollection} */ this._eventListeners = new EventListenerCollection(); } + /** @type {SettingsController} */ get settingsController() { return this._parent.settingsController; } + /** @type {ProfileConditionsUI} */ get parent() { return this._parent; } + /** @type {number} */ get index() { return this._index; } @@ -346,19 +492,20 @@ class ProfileConditionGroupUI { this._index = value; } + /** @type {HTMLElement} */ get node() { return this._node; } + /** @type {number} */ get childCount() { return this._children.length; } + /** + * @param {import('settings').ProfileConditionGroup} conditionGroup + */ prepare(conditionGroup) { - this._node = this._parent.instantiateTemplate('profile-condition-group'); - this._conditionContainer = this._node.querySelector('.profile-condition-list'); - this._addConditionButton = this._node.querySelector('.profile-condition-add-button'); - const conditions = conditionGroup.conditions; for (let i = 0, ii = conditions.length; i < ii; ++i) { this._addCondition(conditions[i], i); @@ -367,6 +514,7 @@ class ProfileConditionGroupUI { this._eventListeners.addEventListener(this._addConditionButton, 'click', this._onAddConditionButtonClick.bind(this), false); } + /** */ cleanup() { this._eventListeners.removeAllEventListeners(); @@ -378,15 +526,15 @@ class ProfileConditionGroupUI { if (this._node === null) { return; } const node = this._node; - this._node = null; - this._conditionContainer = null; - this._addConditionButton = null; - if (node.parentNode !== null) { node.parentNode.removeChild(node); } } + /** + * @param {ProfileConditionUI} child + * @returns {boolean} + */ removeCondition(child) { const index = child.index; if (index < 0 || index >= this._children.length) { return false; } @@ -416,17 +564,23 @@ class ProfileConditionGroupUI { return true; } + /** + * @param {string} property + * @returns {string} + */ getPath(property) { property = (typeof property === 'string' ? `.${property}` : ''); return this._parent.getPath(`conditionGroups[${this._index}]${property}`); } + /** */ removeSelf() { this._parent.removeConditionGroup(this); } // Private + /** */ _onAddConditionButtonClick() { const condition = this._parent.getDefaultCondition(); const index = this._children.length; @@ -442,41 +596,73 @@ class ProfileConditionGroupUI { }]); } + /** + * @param {import('settings').ProfileCondition} condition + * @param {number} index + * @returns {ProfileConditionUI} + */ _addCondition(condition, index) { const child = new ProfileConditionUI(this, index); child.prepare(condition); this._children.push(child); - this._conditionContainer.appendChild(child.node); + if (this._conditionContainer !== null) { + this._conditionContainer.appendChild(child.node); + } return child; } } class ProfileConditionUI { + /** + * @param {ProfileConditionGroupUI} parent + * @param {number} index + */ constructor(parent, index) { + /** @type {ProfileConditionGroupUI} */ this._parent = parent; + /** @type {number} */ this._index = index; - this._node = null; - this._typeInput = null; - this._operatorInput = null; - this._valueInputContainer = null; - this._removeButton = null; - this._mouseButton = null; - this._mouseButtonContainer = null; - this._menuButton = null; + /** @type {HTMLElement} */ + this._node = this._parent.parent.instantiateTemplate('profile-condition'); + /** @type {HTMLSelectElement} */ + this._typeInput = /** @type {HTMLSelectElement} */ (this._node.querySelector('.profile-condition-type')); + /** @type {HTMLSelectElement} */ + this._operatorInput = /** @type {HTMLSelectElement} */ (this._node.querySelector('.profile-condition-operator')); + /** @type {HTMLButtonElement} */ + this._removeButton = /** @type {HTMLButtonElement} */ (this._node.querySelector('.profile-condition-remove')); + /** @type {HTMLButtonElement} */ + this._mouseButton = /** @type {HTMLButtonElement} */ (this._node.querySelector('.mouse-button')); + /** @type {HTMLElement} */ + this._mouseButtonContainer = /** @type {HTMLElement} */ (this._node.querySelector('.mouse-button-container')); + /** @type {HTMLButtonElement} */ + this._menuButton = /** @type {HTMLButtonElement} */ (this._node.querySelector('.profile-condition-menu-button')); + /** @type {HTMLElement} */ + this._typeOptionContainer = /** @type {HTMLElement} */ (this._typeInput.querySelector('optgroup')); + /** @type {HTMLElement} */ + this._operatorOptionContainer = /** @type {HTMLElement} */ (this._operatorInput.querySelector('optgroup')); + /** @type {HTMLInputElement} */ + this._valueInput = /** @type {HTMLInputElement} */ (this._node.querySelector('.profile-condition-input')); + /** @type {string} */ this._value = ''; + /** @type {?KeyboardMouseInputField} */ this._kbmInputField = null; + /** @type {EventListenerCollection} */ this._eventListeners = new EventListenerCollection(); + /** @type {EventListenerCollection} */ this._inputEventListeners = new EventListenerCollection(); } + /** @type {SettingsController} */ get settingsController() { return this._parent.parent.settingsController; } + /** @type {ProfileConditionGroupUI} */ get parent() { return this._parent; } + /** @type {number} */ get index() { return this._index; } @@ -485,24 +671,17 @@ class ProfileConditionUI { this._index = value; } + /** @type {HTMLElement} */ get node() { return this._node; } + /** + * @param {import('settings').ProfileCondition} condition + */ prepare(condition) { const {type, operator, value} = condition; - this._node = this._parent.parent.instantiateTemplate('profile-condition'); - this._typeInput = this._node.querySelector('.profile-condition-type'); - this._typeOptionContainer = this._typeInput.querySelector('optgroup'); - this._operatorInput = this._node.querySelector('.profile-condition-operator'); - this._operatorOptionContainer = this._operatorInput.querySelector('optgroup'); - this._valueInput = this._node.querySelector('.profile-condition-input'); - this._removeButton = this._node.querySelector('.profile-condition-remove'); - this._mouseButton = this._node.querySelector('.mouse-button'); - this._mouseButtonContainer = this._node.querySelector('.mouse-button-container'); - this._menuButton = this._node.querySelector('.profile-condition-menu-button'); - const operatorDetails = this._getOperatorDetails(type, operator); this._updateTypes(type); this._updateOperators(type, operator); @@ -517,6 +696,7 @@ class ProfileConditionUI { } } + /** */ cleanup() { this._eventListeners.removeAllEventListeners(); this._value = ''; @@ -524,17 +704,15 @@ class ProfileConditionUI { if (this._node === null) { return; } const node = this._node; - this._node = null; - this._typeInput = null; - this._operatorInput = null; - this._valueInputContainer = null; - this._removeButton = null; - if (node.parentNode !== null) { node.parentNode.removeChild(node); } } + /** + * @param {string} property + * @returns {string} + */ getPath(property) { property = (typeof property === 'string' ? `.${property}` : ''); return this._parent.getPath(`conditions[${this._index}]${property}`); @@ -542,19 +720,33 @@ class ProfileConditionUI { // Private + /** + * @param {Event} e + */ _onTypeChange(e) { - const type = e.currentTarget.value; + const element = /** @type {HTMLSelectElement} */ (e.currentTarget); + const type = ProfileConditionsUI.normalizeProfileConditionType(element.value); + if (type === null) { return; } this._setType(type); } + /** + * @param {Event} e + */ _onOperatorChange(e) { - const type = this._typeInput.value; - const operator = e.currentTarget.value; + const element = /** @type {HTMLSelectElement} */ (e.currentTarget); + const type = ProfileConditionsUI.normalizeProfileConditionType(this._typeInput.value); + if (type === null) { return; } + const operator = element.value; this._setOperator(type, operator); } + /** + * @param {import('profile-conditions-ui').InputData} details + * @param {Event} e + */ _onValueInputChange({validate, normalize}, e) { - const node = e.currentTarget; + const node = /** @type {HTMLInputElement} */ (e.currentTarget); const value = node.value; const okay = this._validateValue(value, validate); this._value = value; @@ -565,8 +757,12 @@ class ProfileConditionUI { } } - _onModifierInputChange({validate, normalize}, {modifiers}) { - modifiers = this._joinModifiers(modifiers); + /** + * @param {import('profile-conditions-ui').InputData} details + * @param {import('keyboard-mouse-input-field').ChangeEvent} event + */ + _onModifierInputChange({validate, normalize}, event) { + const modifiers = this._joinModifiers(event.modifiers); const okay = this._validateValue(modifiers, validate); this._value = modifiers; if (okay) { @@ -575,18 +771,25 @@ class ProfileConditionUI { } } + /** */ _onRemoveButtonClick() { this._removeSelf(); } + /** + * @param {import('popup-menu').MenuOpenEvent} e + */ _onMenuOpen(e) { const bodyNode = e.detail.menu.bodyNode; - const deleteGroup = bodyNode.querySelector('.popup-menu-item[data-menu-action="deleteGroup"]'); + const deleteGroup = /** @type {HTMLElement} */ (bodyNode.querySelector('.popup-menu-item[data-menu-action="deleteGroup"]')); if (deleteGroup !== null) { deleteGroup.hidden = (this._parent.childCount <= 1); } } + /** + * @param {import('popup-menu').MenuCloseEvent} e + */ _onMenuClose(e) { switch (e.detail.action) { case 'delete': @@ -601,28 +804,53 @@ class ProfileConditionUI { } } + /** + * @returns {import('profile-conditions-ui').DescriptorInfo[]} + */ _getDescriptorTypes() { return this._parent.parent.getDescriptorTypes(); } + /** + * @param {import('profile-conditions-ui').DescriptorType} type + * @returns {import('profile-conditions-ui').OperatorInfo[]} + */ _getDescriptorOperators(type) { return this._parent.parent.getDescriptorOperators(type); } + /** + * @param {import('profile-conditions-ui').DescriptorType} type + * @param {string} operator + * @returns {import('profile-conditions-ui').Operator} + */ _getOperatorDetails(type, operator) { return this._parent.parent.getOperatorDetails(type, operator); } + /** + * @param {import('profile-conditions-ui').DescriptorType} type + */ _updateTypes(type) { const types = this._getDescriptorTypes(); this._updateSelect(this._typeInput, this._typeOptionContainer, types, type); } + /** + * @param {import('profile-conditions-ui').DescriptorType} type + * @param {string} operator + */ _updateOperators(type, operator) { const operators = this._getDescriptorOperators(type); this._updateSelect(this._operatorInput, this._operatorOptionContainer, operators, operator); } + /** + * @param {HTMLSelectElement} select + * @param {HTMLElement} optionContainer + * @param {import('profile-conditions-ui').DescriptorInfo[]|import('profile-conditions-ui').OperatorInfo[]} values + * @param {string} value + */ _updateSelect(select, optionContainer, values, value) { optionContainer.textContent = ''; for (const {name, displayName} of values) { @@ -634,6 +862,11 @@ class ProfileConditionUI { select.value = value; } + /** + * @param {string} value + * @param {import('profile-conditions-ui').Operator} operator + * @returns {boolean} + */ _updateValueInput(value, {type, validate, normalize}) { this._inputEventListeners.removeAllEventListeners(); if (this._kbmInputField !== null) { @@ -642,10 +875,15 @@ class ProfileConditionUI { } let inputType = 'text'; + /** @type {?string} */ let inputValue = value; let inputStep = null; let showMouseButton = false; - const events = []; + /** @type {import('event-listener-collection').AddEventListenerArgs[]} */ + const events1 = []; + /** @type {import('event-listener-collection').OnArgs[]} */ + const events2 = []; + /** @type {import('profile-conditions-ui').InputData} */ const inputData = {validate, normalize}; const node = this._valueInput; @@ -653,7 +891,7 @@ class ProfileConditionUI { case 'integer': inputType = 'number'; inputStep = '1'; - events.push(['addEventListener', node, 'change', this._onValueInputChange.bind(this, inputData), false]); + events1.push([node, 'change', this._onValueInputChange.bind(this, inputData), false]); break; case 'modifierKeys': case 'modifierInputs': @@ -661,10 +899,10 @@ class ProfileConditionUI { showMouseButton = (type === 'modifierInputs'); this._kbmInputField = this._parent.parent.createKeyboardMouseInputField(node, this._mouseButton); this._kbmInputField.prepare(null, this._splitModifiers(value), showMouseButton, false); - events.push(['on', this._kbmInputField, 'change', this._onModifierInputChange.bind(this, inputData), false]); + events2.push([this._kbmInputField, 'change', this._onModifierInputChange.bind(this, inputData)]); break; default: // 'string' - events.push(['addEventListener', node, 'change', this._onValueInputChange.bind(this, inputData), false]); + events1.push([node, 'change', this._onValueInputChange.bind(this, inputData), false]); break; } @@ -680,35 +918,67 @@ class ProfileConditionUI { node.removeAttribute('step'); } this._mouseButtonContainer.hidden = !showMouseButton; - for (const args of events) { - this._inputEventListeners.addGeneric(...args); + for (const args of events1) { + this._inputEventListeners.addEventListener(...args); + } + for (const args of events2) { + this._inputEventListeners.on(...args); } - this._validateValue(value, validate); + return this._validateValue(value, validate); } + /** + * @param {string} value + * @param {?import('profile-conditions-ui').ValidateFunction} validate + * @returns {boolean} + */ _validateValue(value, validate) { const okay = (validate === null || validate(value)); this._valueInput.dataset.invalid = `${!okay}`; return okay; } + /** + * @param {string} value + * @param {?import('profile-conditions-ui').NormalizeFunction} normalize + * @returns {value} + */ _normalizeValue(value, normalize) { return (normalize !== null ? normalize(value) : value); } + /** */ _removeSelf() { this._parent.removeCondition(this); } + /** + * @param {string} modifiersString + * @returns {import('input').Modifier[]} + */ _splitModifiers(modifiersString) { - return modifiersString.split(/[,;\s]+/).map((v) => v.trim().toLowerCase()).filter((v) => v.length > 0); + /** @type {import('input').Modifier[]} */ + const results = []; + for (const item of modifiersString.split(/[,;\s]+/)) { + const modifier = DocumentUtil.normalizeModifier(item.trim().toLowerCase()); + if (modifier !== null) { results.push(modifier); } + } + return results; } + /** + * @param {import('input').Modifier[]} modifiersArray + * @returns {string} + */ _joinModifiers(modifiersArray) { return modifiersArray.join(', '); } + /** + * @param {import('profile-conditions-ui').DescriptorType} type + * @param {string} [operator] + */ async _setType(type, operator) { const operators = this._getDescriptorOperators(type); if (typeof operator === 'undefined') { @@ -725,8 +995,13 @@ class ProfileConditionUI { ]); } + /** + * @param {import('profile-conditions-ui').DescriptorType} type + * @param {string} operator + */ async _setOperator(type, operator) { const operatorDetails = this._getOperatorDetails(type, operator); + /** @type {import('settings-modifications').Modification[]} */ const settingsModifications = [{action: 'set', path: this.getPath('operator'), value: operator}]; if (operatorDetails.resetDefaultOnChange) { const {defaultValue} = operatorDetails; @@ -738,8 +1013,10 @@ class ProfileConditionUI { await this.settingsController.modifyGlobalSettings(settingsModifications); } + /** */ async _resetValue() { - const type = this._typeInput.value; + const type = ProfileConditionsUI.normalizeProfileConditionType(this._typeInput.value); + if (type === null) { return; } const operator = this._operatorInput.value; await this._setType(type, operator); } -- cgit v1.2.3 From 208c43edbd714041b7f956d288e29172f1c0ce78 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Mon, 27 Nov 2023 14:11:31 -0500 Subject: Update some common types --- .vscode/settings.json | 2 +- ext/js/pages/settings/anki-controller.js | 10 +++++----- ext/js/pages/settings/anki-templates-controller.js | 4 ++-- ext/js/pages/settings/audio-controller.js | 6 +++--- ext/js/pages/settings/backup-controller.js | 4 ++-- ext/js/pages/settings/collapsible-dictionary-controller.js | 4 ++-- ext/js/pages/settings/dictionary-controller.js | 6 +++--- ext/js/pages/settings/dictionary-import-controller.js | 4 ++-- .../pages/settings/extension-keyboard-shortcuts-controller.js | 4 ++-- ext/js/pages/settings/generic-setting-controller.js | 4 ++-- ext/js/pages/settings/keyboard-shortcuts-controller.js | 6 +++--- ext/js/pages/settings/nested-popups-controller.js | 4 ++-- ext/js/pages/settings/permissions-origin-controller.js | 4 ++-- ext/js/pages/settings/permissions-toggle-controller.js | 4 ++-- ext/js/pages/settings/popup-preview-controller.js | 4 ++-- ext/js/pages/settings/profile-conditions-ui.js | 10 +++++----- ext/js/pages/settings/profile-controller.js | 4 ++-- ext/js/pages/settings/scan-inputs-controller.js | 4 ++-- ext/js/pages/settings/scan-inputs-simple-controller.js | 4 ++-- .../pages/settings/secondary-search-dictionary-controller.js | 4 ++-- .../settings/sentence-termination-characters-controller.js | 6 +++--- ext/js/pages/settings/settings-display-controller.js | 4 ++-- ext/js/pages/settings/sort-frequency-dictionary-controller.js | 4 ++-- .../pages/settings/translation-text-replacements-controller.js | 4 ++-- 24 files changed, 57 insertions(+), 57 deletions(-) (limited to 'ext/js/pages/settings/profile-conditions-ui.js') diff --git a/.vscode/settings.json b/.vscode/settings.json index 81cd7b9c..734f6360 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,7 +2,7 @@ "markdown.extension.toc.levels": "1..3", "editor.codeActionsOnSave": { "source.addMissingImports": false, - "source.organizeImports": true, + "source.organizeImports": false, "source.fixAll.eslint": false }, "eslint.format.enable": true, diff --git a/ext/js/pages/settings/anki-controller.js b/ext/js/pages/settings/anki-controller.js index 722459df..05bfdadc 100644 --- a/ext/js/pages/settings/anki-controller.js +++ b/ext/js/pages/settings/anki-controller.js @@ -26,10 +26,10 @@ import {yomitan} from '../../yomitan.js'; export class AnkiController { /** - * @param {SettingsController} settingsController + * @param {import('./settings-controller.js').SettingsController} settingsController */ constructor(settingsController) { - /** @type {SettingsController} */ + /** @type {import('./settings-controller.js').SettingsController} */ this._settingsController = settingsController; /** @type {AnkiConnect} */ this._ankiConnect = new AnkiConnect(); @@ -67,7 +67,7 @@ export class AnkiController { this._validateFieldsToken = null; } - /** @type {SettingsController} */ + /** @type {import('./settings-controller.js').SettingsController} */ get settingsController() { return this._settingsController; } @@ -562,12 +562,12 @@ export class AnkiController { class AnkiCardController { /** - * @param {SettingsController} settingsController + * @param {import('./settings-controller.js').SettingsController} settingsController * @param {AnkiController} ankiController * @param {HTMLElement} node */ constructor(settingsController, ankiController, node) { - /** @type {SettingsController} */ + /** @type {import('./settings-controller.js').SettingsController} */ this._settingsController = settingsController; /** @type {AnkiController} */ this._ankiController = ankiController; diff --git a/ext/js/pages/settings/anki-templates-controller.js b/ext/js/pages/settings/anki-templates-controller.js index a0ff96b2..875ade3c 100644 --- a/ext/js/pages/settings/anki-templates-controller.js +++ b/ext/js/pages/settings/anki-templates-controller.js @@ -23,12 +23,12 @@ import {yomitan} from '../../yomitan.js'; export class AnkiTemplatesController { /** - * @param {SettingsController} settingsController + * @param {import('./settings-controller.js').SettingsController} settingsController * @param {ModalController} modalController * @param {AnkiController} ankiController */ constructor(settingsController, modalController, ankiController) { - /** @type {SettingsController} */ + /** @type {import('./settings-controller.js').SettingsController} */ this._settingsController = settingsController; /** @type {ModalController} */ this._modalController = modalController; diff --git a/ext/js/pages/settings/audio-controller.js b/ext/js/pages/settings/audio-controller.js index 480597af..0bd56ff0 100644 --- a/ext/js/pages/settings/audio-controller.js +++ b/ext/js/pages/settings/audio-controller.js @@ -24,12 +24,12 @@ import {AudioSystem} from '../../media/audio-system.js'; */ export class AudioController extends EventDispatcher { /** - * @param {SettingsController} settingsController + * @param {import('./settings-controller.js').SettingsController} settingsController * @param {ModalController} modalController */ constructor(settingsController, modalController) { super(); - /** @type {SettingsController} */ + /** @type {import('./settings-controller.js').SettingsController} */ this._settingsController = settingsController; /** @type {ModalController} */ this._modalController = modalController; @@ -47,7 +47,7 @@ export class AudioController extends EventDispatcher { this._voices = []; } - /** @type {SettingsController} */ + /** @type {import('./settings-controller.js').SettingsController} */ get settingsController() { return this._settingsController; } diff --git a/ext/js/pages/settings/backup-controller.js b/ext/js/pages/settings/backup-controller.js index a05d0056..c701b975 100644 --- a/ext/js/pages/settings/backup-controller.js +++ b/ext/js/pages/settings/backup-controller.js @@ -25,11 +25,11 @@ import {DictionaryController} from './dictionary-controller.js'; export class BackupController { /** - * @param {SettingsController} settingsController + * @param {import('./settings-controller.js').SettingsController} settingsController * @param {?ModalController} modalController */ constructor(settingsController, modalController) { - /** @type {SettingsController} */ + /** @type {import('./settings-controller.js').SettingsController} */ this._settingsController = settingsController; /** @type {?ModalController} */ this._modalController = modalController; diff --git a/ext/js/pages/settings/collapsible-dictionary-controller.js b/ext/js/pages/settings/collapsible-dictionary-controller.js index a508bae4..355292ad 100644 --- a/ext/js/pages/settings/collapsible-dictionary-controller.js +++ b/ext/js/pages/settings/collapsible-dictionary-controller.js @@ -21,10 +21,10 @@ import {yomitan} from '../../yomitan.js'; export class CollapsibleDictionaryController { /** - * @param {SettingsController} settingsController + * @param {import('./settings-controller.js').SettingsController} settingsController */ constructor(settingsController) { - /** @type {SettingsController} */ + /** @type {import('./settings-controller.js').SettingsController} */ this._settingsController = settingsController; /** @type {?import('core').TokenObject} */ this._getDictionaryInfoToken = null; diff --git a/ext/js/pages/settings/dictionary-controller.js b/ext/js/pages/settings/dictionary-controller.js index 85f7493f..aa59bb97 100644 --- a/ext/js/pages/settings/dictionary-controller.js +++ b/ext/js/pages/settings/dictionary-controller.js @@ -335,12 +335,12 @@ class DictionaryExtraInfo { export class DictionaryController { /** - * @param {SettingsController} settingsController + * @param {import('./settings-controller.js').SettingsController} settingsController * @param {ModalController} modalController * @param {StatusFooter} statusFooter */ constructor(settingsController, modalController, statusFooter) { - /** @type {SettingsController} */ + /** @type {import('./settings-controller.js').SettingsController} */ this._settingsController = settingsController; /** @type {ModalController} */ this._modalController = modalController; @@ -494,7 +494,7 @@ export class DictionaryController { } /** - * @param {SettingsController} settingsController + * @param {import('./settings-controller.js').SettingsController} settingsController * @param {import('dictionary-importer').Summary[]|undefined} dictionaries * @param {import('settings').Options|undefined} optionsFull * @param {boolean} modifyGlobalSettings diff --git a/ext/js/pages/settings/dictionary-import-controller.js b/ext/js/pages/settings/dictionary-import-controller.js index af8c2fcd..04128b1a 100644 --- a/ext/js/pages/settings/dictionary-import-controller.js +++ b/ext/js/pages/settings/dictionary-import-controller.js @@ -24,12 +24,12 @@ import {DictionaryController} from './dictionary-controller.js'; export class DictionaryImportController { /** - * @param {SettingsController} settingsController + * @param {import('./settings-controller.js').SettingsController} settingsController * @param {ModalController} modalController * @param {StatusFooter} statusFooter */ constructor(settingsController, modalController, statusFooter) { - /** @type {SettingsController} */ + /** @type {import('./settings-controller.js').SettingsController} */ this._settingsController = settingsController; /** @type {ModalController} */ this._modalController = modalController; diff --git a/ext/js/pages/settings/extension-keyboard-shortcuts-controller.js b/ext/js/pages/settings/extension-keyboard-shortcuts-controller.js index 6c9a3864..d36d965a 100644 --- a/ext/js/pages/settings/extension-keyboard-shortcuts-controller.js +++ b/ext/js/pages/settings/extension-keyboard-shortcuts-controller.js @@ -23,10 +23,10 @@ import {KeyboardMouseInputField} from './keyboard-mouse-input-field.js'; export class ExtensionKeyboardShortcutController { /** - * @param {SettingsController} settingsController + * @param {import('./settings-controller.js').SettingsController} settingsController */ constructor(settingsController) { - /** @type {SettingsController} */ + /** @type {import('./settings-controller.js').SettingsController} */ this._settingsController = settingsController; /** @type {?HTMLButtonElement} */ this._resetButton = null; diff --git a/ext/js/pages/settings/generic-setting-controller.js b/ext/js/pages/settings/generic-setting-controller.js index 47c0d6fe..8666614b 100644 --- a/ext/js/pages/settings/generic-setting-controller.js +++ b/ext/js/pages/settings/generic-setting-controller.js @@ -22,10 +22,10 @@ import {DOMDataBinder} from '../../dom/dom-data-binder.js'; export class GenericSettingController { /** - * @param {SettingsController} settingsController + * @param {import('./settings-controller.js').SettingsController} settingsController */ constructor(settingsController) { - /** @type {SettingsController} */ + /** @type {import('./settings-controller.js').SettingsController} */ this._settingsController = settingsController; /** @type {import('settings-modifications').OptionsScopeType} */ this._defaultScope = 'profile'; diff --git a/ext/js/pages/settings/keyboard-shortcuts-controller.js b/ext/js/pages/settings/keyboard-shortcuts-controller.js index 2fb1ff8a..32f22499 100644 --- a/ext/js/pages/settings/keyboard-shortcuts-controller.js +++ b/ext/js/pages/settings/keyboard-shortcuts-controller.js @@ -24,10 +24,10 @@ import {KeyboardMouseInputField} from './keyboard-mouse-input-field.js'; export class KeyboardShortcutController { /** - * @param {SettingsController} settingsController + * @param {import('./settings-controller.js').SettingsController} settingsController */ constructor(settingsController) { - /** @type {SettingsController} */ + /** @type {import('./settings-controller.js').SettingsController} */ this._settingsController = settingsController; /** @type {KeyboardShortcutHotkeyEntry[]} */ this._entries = []; @@ -71,7 +71,7 @@ export class KeyboardShortcutController { ]); } - /** @type {SettingsController} */ + /** @type {import('./settings-controller.js').SettingsController} */ get settingsController() { return this._settingsController; } diff --git a/ext/js/pages/settings/nested-popups-controller.js b/ext/js/pages/settings/nested-popups-controller.js index ac078a0c..c01986ab 100644 --- a/ext/js/pages/settings/nested-popups-controller.js +++ b/ext/js/pages/settings/nested-popups-controller.js @@ -20,10 +20,10 @@ import {DocumentUtil} from '../../dom/document-util.js'; export class NestedPopupsController { /** - * @param {SettingsController} settingsController + * @param {import('./settings-controller.js').SettingsController} settingsController */ constructor(settingsController) { - /** @type {SettingsController} */ + /** @type {import('./settings-controller.js').SettingsController} */ this._settingsController = settingsController; /** @type {number} */ this._popupNestingMaxDepth = 0; diff --git a/ext/js/pages/settings/permissions-origin-controller.js b/ext/js/pages/settings/permissions-origin-controller.js index 9cad2fb2..a4271f92 100644 --- a/ext/js/pages/settings/permissions-origin-controller.js +++ b/ext/js/pages/settings/permissions-origin-controller.js @@ -20,10 +20,10 @@ import {EventListenerCollection} from '../../core.js'; export class PermissionsOriginController { /** - * @param {SettingsController} settingsController + * @param {import('./settings-controller.js').SettingsController} settingsController */ constructor(settingsController) { - /** @type {SettingsController} */ + /** @type {import('./settings-controller.js').SettingsController} */ this._settingsController = settingsController; /** @type {?HTMLElement} */ this._originContainer = null; diff --git a/ext/js/pages/settings/permissions-toggle-controller.js b/ext/js/pages/settings/permissions-toggle-controller.js index ed4f7a8c..85752a7e 100644 --- a/ext/js/pages/settings/permissions-toggle-controller.js +++ b/ext/js/pages/settings/permissions-toggle-controller.js @@ -20,10 +20,10 @@ import {ObjectPropertyAccessor} from '../../general/object-property-accessor.js' export class PermissionsToggleController { /** - * @param {SettingsController} settingsController + * @param {import('./settings-controller.js').SettingsController} settingsController */ constructor(settingsController) { - /** @type {SettingsController} */ + /** @type {import('./settings-controller.js').SettingsController} */ this._settingsController = settingsController; /** @type {?NodeListOf} */ this._toggles = null; diff --git a/ext/js/pages/settings/popup-preview-controller.js b/ext/js/pages/settings/popup-preview-controller.js index c555f9cf..7239ca17 100644 --- a/ext/js/pages/settings/popup-preview-controller.js +++ b/ext/js/pages/settings/popup-preview-controller.js @@ -18,10 +18,10 @@ export class PopupPreviewController { /** - * @param {SettingsController} settingsController + * @param {import('./settings-controller.js').SettingsController} settingsController */ constructor(settingsController) { - /** @type {SettingsController} */ + /** @type {import('./settings-controller.js').SettingsController} */ this._settingsController = settingsController; /** @type {string} */ this._targetOrigin = chrome.runtime.getURL('/').replace(/\/$/, ''); diff --git a/ext/js/pages/settings/profile-conditions-ui.js b/ext/js/pages/settings/profile-conditions-ui.js index 5ebd9011..8711518f 100644 --- a/ext/js/pages/settings/profile-conditions-ui.js +++ b/ext/js/pages/settings/profile-conditions-ui.js @@ -29,11 +29,11 @@ import {KeyboardMouseInputField} from './keyboard-mouse-input-field.js'; */ export class ProfileConditionsUI extends EventDispatcher { /** - * @param {SettingsController} settingsController + * @param {import('./settings-controller.js').SettingsController} settingsController */ constructor(settingsController) { super(); - /** @type {SettingsController} */ + /** @type {import('./settings-controller.js').SettingsController} */ this._settingsController = settingsController; /** @type {?import('environment').OperatingSystem} */ this._os = null; @@ -114,7 +114,7 @@ export class ProfileConditionsUI extends EventDispatcher { ]); } - /** @type {SettingsController} */ + /** @type {import('./settings-controller.js').SettingsController} */ get settingsController() { return this._settingsController; } @@ -473,7 +473,7 @@ class ProfileConditionGroupUI { this._eventListeners = new EventListenerCollection(); } - /** @type {SettingsController} */ + /** @type {import('./settings-controller.js').SettingsController} */ get settingsController() { return this._parent.settingsController; } @@ -652,7 +652,7 @@ class ProfileConditionUI { this._inputEventListeners = new EventListenerCollection(); } - /** @type {SettingsController} */ + /** @type {import('./settings-controller.js').SettingsController} */ get settingsController() { return this._parent.parent.settingsController; } diff --git a/ext/js/pages/settings/profile-controller.js b/ext/js/pages/settings/profile-controller.js index a74a7567..64c2e2fd 100644 --- a/ext/js/pages/settings/profile-controller.js +++ b/ext/js/pages/settings/profile-controller.js @@ -22,11 +22,11 @@ import {ProfileConditionsUI} from './profile-conditions-ui.js'; export class ProfileController { /** - * @param {SettingsController} settingsController + * @param {import('./settings-controller.js').SettingsController} settingsController * @param {ModalController} modalController */ constructor(settingsController, modalController) { - /** @type {SettingsController} */ + /** @type {import('./settings-controller.js').SettingsController} */ this._settingsController = settingsController; /** @type {ModalController} */ this._modalController = modalController; diff --git a/ext/js/pages/settings/scan-inputs-controller.js b/ext/js/pages/settings/scan-inputs-controller.js index f294050b..0686540a 100644 --- a/ext/js/pages/settings/scan-inputs-controller.js +++ b/ext/js/pages/settings/scan-inputs-controller.js @@ -27,10 +27,10 @@ import {KeyboardMouseInputField} from './keyboard-mouse-input-field.js'; export class ScanInputsController { /** - * @param {SettingsController} settingsController + * @param {import('./settings-controller.js').SettingsController} settingsController */ constructor(settingsController) { - /** @type {SettingsController} */ + /** @type {import('./settings-controller.js').SettingsController} */ this._settingsController = settingsController; /** @type {?import('environment').OperatingSystem} */ this._os = null; diff --git a/ext/js/pages/settings/scan-inputs-simple-controller.js b/ext/js/pages/settings/scan-inputs-simple-controller.js index 1e422c5b..8d52af61 100644 --- a/ext/js/pages/settings/scan-inputs-simple-controller.js +++ b/ext/js/pages/settings/scan-inputs-simple-controller.js @@ -22,10 +22,10 @@ import {ScanInputsController} from './scan-inputs-controller.js'; export class ScanInputsSimpleController { /** - * @param {SettingsController} settingsController + * @param {import('./settings-controller.js').SettingsController} settingsController */ constructor(settingsController) { - /** @type {SettingsController} */ + /** @type {import('./settings-controller.js').SettingsController} */ this._settingsController = settingsController; /** @type {?HTMLInputElement} */ this._middleMouseButtonScan = null; diff --git a/ext/js/pages/settings/secondary-search-dictionary-controller.js b/ext/js/pages/settings/secondary-search-dictionary-controller.js index 7c2d3907..b20bd475 100644 --- a/ext/js/pages/settings/secondary-search-dictionary-controller.js +++ b/ext/js/pages/settings/secondary-search-dictionary-controller.js @@ -21,10 +21,10 @@ import {yomitan} from '../../yomitan.js'; export class SecondarySearchDictionaryController { /** - * @param {SettingsController} settingsController + * @param {import('./settings-controller.js').SettingsController} settingsController */ constructor(settingsController) { - /** @type {SettingsController} */ + /** @type {import('./settings-controller.js').SettingsController} */ this._settingsController = settingsController; /** @type {?import('core').TokenObject} */ this._getDictionaryInfoToken = null; diff --git a/ext/js/pages/settings/sentence-termination-characters-controller.js b/ext/js/pages/settings/sentence-termination-characters-controller.js index 3edabb67..80c4cdbe 100644 --- a/ext/js/pages/settings/sentence-termination-characters-controller.js +++ b/ext/js/pages/settings/sentence-termination-characters-controller.js @@ -20,10 +20,10 @@ import {EventListenerCollection} from '../../core.js'; export class SentenceTerminationCharactersController { /** - * @param {SettingsController} settingsController + * @param {import('./settings-controller.js').SettingsController} settingsController */ constructor(settingsController) { - /** @type {SettingsController} */ + /** @type {import('./settings-controller.js').SettingsController} */ this._settingsController = settingsController; /** @type {SentenceTerminationCharacterEntry[]} */ this._entries = []; @@ -39,7 +39,7 @@ export class SentenceTerminationCharactersController { this._emptyIndicator = null; } - /** @type {SettingsController} */ + /** @type {import('./settings-controller.js').SettingsController} */ get settingsController() { return this._settingsController; } diff --git a/ext/js/pages/settings/settings-display-controller.js b/ext/js/pages/settings/settings-display-controller.js index bcbd6a44..ca4fc32e 100644 --- a/ext/js/pages/settings/settings-display-controller.js +++ b/ext/js/pages/settings/settings-display-controller.js @@ -22,11 +22,11 @@ import {SelectorObserver} from '../../dom/selector-observer.js'; export class SettingsDisplayController { /** - * @param {SettingsController} settingsController + * @param {import('./settings-controller.js').SettingsController} settingsController * @param {ModalController} modalController */ constructor(settingsController, modalController) { - /** @type {SettingsController} */ + /** @type {import('./settings-controller.js').SettingsController} */ this._settingsController = settingsController; /** @type {ModalController} */ this._modalController = modalController; diff --git a/ext/js/pages/settings/sort-frequency-dictionary-controller.js b/ext/js/pages/settings/sort-frequency-dictionary-controller.js index 5c5841b1..e7759d95 100644 --- a/ext/js/pages/settings/sort-frequency-dictionary-controller.js +++ b/ext/js/pages/settings/sort-frequency-dictionary-controller.js @@ -20,10 +20,10 @@ import {yomitan} from '../../yomitan.js'; export class SortFrequencyDictionaryController { /** - * @param {SettingsController} settingsController + * @param {import('./settings-controller.js').SettingsController} settingsController */ constructor(settingsController) { - /** @type {SettingsController} */ + /** @type {import('./settings-controller.js').SettingsController} */ this._settingsController = settingsController; /** @type {?HTMLSelectElement} */ this._sortFrequencyDictionarySelect = null; diff --git a/ext/js/pages/settings/translation-text-replacements-controller.js b/ext/js/pages/settings/translation-text-replacements-controller.js index 690ccfe8..050db8d1 100644 --- a/ext/js/pages/settings/translation-text-replacements-controller.js +++ b/ext/js/pages/settings/translation-text-replacements-controller.js @@ -20,10 +20,10 @@ import {EventListenerCollection} from '../../core.js'; export class TranslationTextReplacementsController { /** - * @param {SettingsController} settingsController + * @param {import('./settings-controller.js').SettingsController} settingsController */ constructor(settingsController) { - /** @type {SettingsController} */ + /** @type {import('./settings-controller.js').SettingsController} */ this._settingsController = settingsController; /** @type {?HTMLElement} */ this._entryContainer = null; -- cgit v1.2.3 From 5dc16745468c229e7c31f6cddaad83fb9c36b98f Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Mon, 27 Nov 2023 14:19:50 -0500 Subject: Update types --- .vscode/settings.json | 2 +- ext/js/pages/settings/anki-templates-controller.js | 10 +++++----- ext/js/pages/settings/audio-controller.js | 6 +++--- ext/js/pages/settings/backup-controller.js | 10 +++++----- ext/js/pages/settings/dictionary-controller.js | 18 +++++++++--------- .../pages/settings/dictionary-import-controller.js | 14 +++++++------- .../settings/keyboard-shortcuts-controller.js | 4 ++-- ext/js/pages/settings/popup-preview-frame.js | 8 ++++---- ext/js/pages/settings/profile-conditions-ui.js | 6 +----- ext/js/pages/settings/profile-controller.js | 22 +++++++++++----------- ext/js/pages/settings/scan-inputs-controller.js | 6 +----- .../pages/settings/settings-display-controller.js | 4 ++-- ext/js/pages/settings/storage-controller.js | 4 ++-- 13 files changed, 53 insertions(+), 61 deletions(-) (limited to 'ext/js/pages/settings/profile-conditions-ui.js') diff --git a/.vscode/settings.json b/.vscode/settings.json index 734f6360..81cd7b9c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,7 +2,7 @@ "markdown.extension.toc.levels": "1..3", "editor.codeActionsOnSave": { "source.addMissingImports": false, - "source.organizeImports": false, + "source.organizeImports": true, "source.fixAll.eslint": false }, "eslint.format.enable": true, diff --git a/ext/js/pages/settings/anki-templates-controller.js b/ext/js/pages/settings/anki-templates-controller.js index 875ade3c..89848ef3 100644 --- a/ext/js/pages/settings/anki-templates-controller.js +++ b/ext/js/pages/settings/anki-templates-controller.js @@ -24,15 +24,15 @@ import {yomitan} from '../../yomitan.js'; export class AnkiTemplatesController { /** * @param {import('./settings-controller.js').SettingsController} settingsController - * @param {ModalController} modalController - * @param {AnkiController} ankiController + * @param {import('./modal-controller.js').ModalController} modalController + * @param {import('./anki-controller.js').AnkiController} ankiController */ constructor(settingsController, modalController, ankiController) { /** @type {import('./settings-controller.js').SettingsController} */ this._settingsController = settingsController; - /** @type {ModalController} */ + /** @type {import('./modal-controller.js').ModalController} */ this._modalController = modalController; - /** @type {AnkiController} */ + /** @type {import('./anki-controller.js').AnkiController} */ this._ankiController = ankiController; /** @type {?import('dictionary').TermDictionaryEntry} */ this._cachedDictionaryEntryValue = null; @@ -48,7 +48,7 @@ export class AnkiTemplatesController { this._renderFieldInput = null; /** @type {?HTMLElement} */ this._renderResult = null; - /** @type {?Modal} */ + /** @type {?import('./modal.js').Modal} */ this._fieldTemplateResetModal = null; /** @type {AnkiNoteBuilder} */ this._ankiNoteBuilder = new AnkiNoteBuilder({japaneseUtil: new JapaneseUtil(null)}); diff --git a/ext/js/pages/settings/audio-controller.js b/ext/js/pages/settings/audio-controller.js index 0bd56ff0..0a3f9454 100644 --- a/ext/js/pages/settings/audio-controller.js +++ b/ext/js/pages/settings/audio-controller.js @@ -25,13 +25,13 @@ import {AudioSystem} from '../../media/audio-system.js'; export class AudioController extends EventDispatcher { /** * @param {import('./settings-controller.js').SettingsController} settingsController - * @param {ModalController} modalController + * @param {import('./modal-controller.js').ModalController} modalController */ constructor(settingsController, modalController) { super(); /** @type {import('./settings-controller.js').SettingsController} */ this._settingsController = settingsController; - /** @type {ModalController} */ + /** @type {import('./modal-controller.js').ModalController} */ this._modalController = modalController; /** @type {AudioSystem} */ this._audioSystem = new AudioSystem(); @@ -52,7 +52,7 @@ export class AudioController extends EventDispatcher { return this._settingsController; } - /** @type {ModalController} */ + /** @type {import('./modal-controller.js').ModalController} */ get modalController() { return this._modalController; } diff --git a/ext/js/pages/settings/backup-controller.js b/ext/js/pages/settings/backup-controller.js index c701b975..50a50b1a 100644 --- a/ext/js/pages/settings/backup-controller.js +++ b/ext/js/pages/settings/backup-controller.js @@ -26,12 +26,12 @@ import {DictionaryController} from './dictionary-controller.js'; export class BackupController { /** * @param {import('./settings-controller.js').SettingsController} settingsController - * @param {?ModalController} modalController + * @param {?import('./modal-controller.js').ModalController} modalController */ constructor(settingsController, modalController) { /** @type {import('./settings-controller.js').SettingsController} */ this._settingsController = settingsController; - /** @type {?ModalController} */ + /** @type {?import('./modal-controller.js').ModalController} */ this._modalController = modalController; /** @type {?import('core').TokenObject} */ this._settingsExportToken = null; @@ -39,11 +39,11 @@ export class BackupController { this._settingsExportRevoke = null; /** @type {number} */ this._currentVersion = 0; - /** @type {?Modal} */ + /** @type {?import('./modal.js').Modal} */ this._settingsResetModal = null; - /** @type {?Modal} */ + /** @type {?import('./modal.js').Modal} */ this._settingsImportErrorModal = null; - /** @type {?Modal} */ + /** @type {?import('./modal.js').Modal} */ this._settingsImportWarningModal = null; /** @type {?OptionsUtil} */ this._optionsUtil = null; diff --git a/ext/js/pages/settings/dictionary-controller.js b/ext/js/pages/settings/dictionary-controller.js index aa59bb97..de63b200 100644 --- a/ext/js/pages/settings/dictionary-controller.js +++ b/ext/js/pages/settings/dictionary-controller.js @@ -336,15 +336,15 @@ class DictionaryExtraInfo { export class DictionaryController { /** * @param {import('./settings-controller.js').SettingsController} settingsController - * @param {ModalController} modalController - * @param {StatusFooter} statusFooter + * @param {import('./modal-controller.js').ModalController} modalController + * @param {import('./status-footer.js').StatusFooter} statusFooter */ constructor(settingsController, modalController, statusFooter) { /** @type {import('./settings-controller.js').SettingsController} */ this._settingsController = settingsController; - /** @type {ModalController} */ + /** @type {import('./modal-controller.js').ModalController} */ this._modalController = modalController; - /** @type {StatusFooter} */ + /** @type {import('./status-footer.js').StatusFooter} */ this._statusFooter = statusFooter; /** @type {?import('dictionary-importer').Summary[]} */ this._dictionaries = null; @@ -366,7 +366,7 @@ export class DictionaryController { this._noDictionariesInstalledWarnings = null; /** @type {?NodeListOf} */ this._noDictionariesEnabledWarnings = null; - /** @type {?Modal} */ + /** @type {?import('./modal.js').Modal} */ this._deleteDictionaryModal = null; /** @type {?HTMLInputElement} */ this._allCheckbox = null; @@ -376,7 +376,7 @@ export class DictionaryController { this._isDeleting = false; } - /** @type {ModalController} */ + /** @type {import('./modal-controller.js').ModalController} */ get modalController() { return this._modalController; } @@ -418,7 +418,7 @@ export class DictionaryController { */ deleteDictionary(dictionaryTitle) { if (this._isDeleting) { return; } - const modal = /** @type {Modal} */ (this._deleteDictionaryModal); + const modal = /** @type {import('./modal.js').Modal} */ (this._deleteDictionaryModal); modal.node.dataset.dictionaryTitle = dictionaryTitle; const nameElement = /** @type {Element} */ (modal.node.querySelector('#dictionary-confirm-delete-name')); nameElement.textContent = dictionaryTitle; @@ -671,7 +671,7 @@ export class DictionaryController { _onDictionaryConfirmDelete(e) { e.preventDefault(); - const modal = /** @type {Modal} */ (this._deleteDictionaryModal); + const modal = /** @type {import('./modal.js').Modal} */ (this._deleteDictionaryModal); modal.setVisible(false); const title = modal.node.dataset.dictionaryTitle; @@ -691,7 +691,7 @@ export class DictionaryController { /** */ _onDictionaryMoveButtonClick() { - const modal = /** @type {Modal} */ (this._modalController.getModal('dictionary-move-location')); + const modal = /** @type {import('./modal.js').Modal} */ (this._modalController.getModal('dictionary-move-location')); const {index} = modal.node.dataset; if (typeof index !== 'number') { return; } const indexNumber = Number.parseInt(index, 10); diff --git a/ext/js/pages/settings/dictionary-import-controller.js b/ext/js/pages/settings/dictionary-import-controller.js index 04128b1a..d1255e11 100644 --- a/ext/js/pages/settings/dictionary-import-controller.js +++ b/ext/js/pages/settings/dictionary-import-controller.js @@ -25,15 +25,15 @@ import {DictionaryController} from './dictionary-controller.js'; export class DictionaryImportController { /** * @param {import('./settings-controller.js').SettingsController} settingsController - * @param {ModalController} modalController - * @param {StatusFooter} statusFooter + * @param {import('./modal-controller.js').ModalController} modalController + * @param {import('./status-footer.js').StatusFooter} statusFooter */ constructor(settingsController, modalController, statusFooter) { /** @type {import('./settings-controller.js').SettingsController} */ this._settingsController = settingsController; - /** @type {ModalController} */ + /** @type {import('./modal-controller.js').ModalController} */ this._modalController = modalController; - /** @type {StatusFooter} */ + /** @type {import('./status-footer.js').StatusFooter} */ this._statusFooter = statusFooter; /** @type {boolean} */ this._modifying = false; @@ -45,7 +45,7 @@ export class DictionaryImportController { this._importFileButton = null; /** @type {?HTMLInputElement} */ this._importFileInput = null; - /** @type {?Modal} */ + /** @type {?import('./modal.js').Modal} */ this._purgeConfirmModal = null; /** @type {?HTMLElement} */ this._errorContainer = null; @@ -95,7 +95,7 @@ export class DictionaryImportController { */ _onPurgeButtonClick(e) { e.preventDefault(); - /** @type {Modal} */ (this._purgeConfirmModal).setVisible(true); + /** @type {import('./modal.js').Modal} */ (this._purgeConfirmModal).setVisible(true); } /** @@ -103,7 +103,7 @@ export class DictionaryImportController { */ _onPurgeConfirmButtonClick(e) { e.preventDefault(); - /** @type {Modal} */ (this._purgeConfirmModal).setVisible(false); + /** @type {import('./modal.js').Modal} */ (this._purgeConfirmModal).setVisible(false); this._purgeDatabase(); } diff --git a/ext/js/pages/settings/keyboard-shortcuts-controller.js b/ext/js/pages/settings/keyboard-shortcuts-controller.js index 32f22499..ad16b0e9 100644 --- a/ext/js/pages/settings/keyboard-shortcuts-controller.js +++ b/ext/js/pages/settings/keyboard-shortcuts-controller.js @@ -267,7 +267,7 @@ class KeyboardShortcutHotkeyEntry { this._stringComparer = stringComparer; /** @type {?HTMLButtonElement} */ this._enabledButton = null; - /** @type {?PopupMenu} */ + /** @type {?import('../../dom/popup-menu.js').PopupMenu} */ this._scopeMenu = null; /** @type {EventListenerCollection} */ this._scopeMenuEventListeners = new EventListenerCollection(); @@ -629,7 +629,7 @@ class KeyboardShortcutHotkeyEntry { } /** - * @param {PopupMenu} menu + * @param {import('../../dom/popup-menu.js').PopupMenu} menu */ _updateScopeMenuItems(menu) { this._scopeMenuEventListeners.removeAllEventListeners(); diff --git a/ext/js/pages/settings/popup-preview-frame.js b/ext/js/pages/settings/popup-preview-frame.js index acf4e0de..c1a0d706 100644 --- a/ext/js/pages/settings/popup-preview-frame.js +++ b/ext/js/pages/settings/popup-preview-frame.js @@ -25,17 +25,17 @@ export class PopupPreviewFrame { /** * @param {number} tabId * @param {number} frameId - * @param {PopupFactory} popupFactory - * @param {HotkeyHandler} hotkeyHandler + * @param {import('../../app/popup-factory.js').PopupFactory} popupFactory + * @param {import('../../input/hotkey-handler.js').HotkeyHandler} hotkeyHandler */ constructor(tabId, frameId, popupFactory, hotkeyHandler) { /** @type {number} */ this._tabId = tabId; /** @type {number} */ this._frameId = frameId; - /** @type {PopupFactory} */ + /** @type {import('../../app/popup-factory.js').PopupFactory} */ this._popupFactory = popupFactory; - /** @type {HotkeyHandler} */ + /** @type {import('../../input/hotkey-handler.js').HotkeyHandler} */ this._hotkeyHandler = hotkeyHandler; /** @type {?Frontend} */ this._frontend = null; diff --git a/ext/js/pages/settings/profile-conditions-ui.js b/ext/js/pages/settings/profile-conditions-ui.js index 8711518f..96aef83f 100644 --- a/ext/js/pages/settings/profile-conditions-ui.js +++ b/ext/js/pages/settings/profile-conditions-ui.js @@ -17,13 +17,9 @@ */ import {EventDispatcher, EventListenerCollection} from '../../core.js'; +import {DocumentUtil} from '../../dom/document-util.js'; import {KeyboardMouseInputField} from './keyboard-mouse-input-field.js'; -/* global - * DocumentUtil - * KeyboardMouseInputField - */ - /** * @augments EventDispatcher */ diff --git a/ext/js/pages/settings/profile-controller.js b/ext/js/pages/settings/profile-controller.js index 64c2e2fd..c82223b8 100644 --- a/ext/js/pages/settings/profile-controller.js +++ b/ext/js/pages/settings/profile-controller.js @@ -23,12 +23,12 @@ import {ProfileConditionsUI} from './profile-conditions-ui.js'; export class ProfileController { /** * @param {import('./settings-controller.js').SettingsController} settingsController - * @param {ModalController} modalController + * @param {import('./modal-controller.js').ModalController} modalController */ constructor(settingsController, modalController) { /** @type {import('./settings-controller.js').SettingsController} */ this._settingsController = settingsController; - /** @type {ModalController} */ + /** @type {import('./modal-controller.js').ModalController} */ this._modalController = modalController; /** @type {ProfileConditionsUI} */ this._profileConditionsUI = new ProfileConditionsUI(settingsController); @@ -52,11 +52,11 @@ export class ProfileController { this._profileEntryListContainer = null; /** @type {?HTMLElement} */ this._profileConditionsProfileName = null; - /** @type {?Modal} */ + /** @type {?import('./modal.js').Modal} */ this._profileRemoveModal = null; - /** @type {?Modal} */ + /** @type {?import('./modal.js').Modal} */ this._profileCopyModal = null; - /** @type {?Modal} */ + /** @type {?import('./modal.js').Modal} */ this._profileConditionsModal = null; /** @type {boolean} */ this._profileEntriesSupported = false; @@ -340,8 +340,8 @@ export class ProfileController { if (profile === null || this.profileCount <= 1) { return; } /** @type {HTMLElement} */ (this._removeProfileNameElement).textContent = profile.name; - /** @type {Modal} */ (this._profileRemoveModal).node.dataset.profileIndex = `${profileIndex}`; - /** @type {Modal} */ (this._profileRemoveModal).setVisible(true); + /** @type {import('./modal.js').Modal} */ (this._profileRemoveModal).node.dataset.profileIndex = `${profileIndex}`; + /** @type {import('./modal.js').Modal} */ (this._profileRemoveModal).setVisible(true); } /** @@ -368,8 +368,8 @@ export class ProfileController { } select.value = `${copyFromIndex}`; - /** @type {Modal} */ (this._profileCopyModal).node.dataset.profileIndex = `${profileIndex}`; - /** @type {Modal} */ (this._profileCopyModal).setVisible(true); + /** @type {import('./modal.js').Modal} */ (this._profileCopyModal).node.dataset.profileIndex = `${profileIndex}`; + /** @type {import('./modal.js').Modal} */ (this._profileCopyModal).setVisible(true); } /** @@ -453,7 +453,7 @@ export class ProfileController { /** */ _onDeleteConfirm() { - const modal = /** @type {Modal} */ (this._profileRemoveModal); + const modal = /** @type {import('./modal.js').Modal} */ (this._profileRemoveModal); modal.setVisible(false); const {node} = modal; const profileIndex = node.dataset.profileIndex; @@ -467,7 +467,7 @@ export class ProfileController { /** */ _onCopyConfirm() { - const modal = /** @type {Modal} */ (this._profileCopyModal); + const modal = /** @type {import('./modal.js').Modal} */ (this._profileCopyModal); modal.setVisible(false); const {node} = modal; const destinationProfileIndex = node.dataset.profileIndex; diff --git a/ext/js/pages/settings/scan-inputs-controller.js b/ext/js/pages/settings/scan-inputs-controller.js index 0686540a..53423bdc 100644 --- a/ext/js/pages/settings/scan-inputs-controller.js +++ b/ext/js/pages/settings/scan-inputs-controller.js @@ -17,14 +17,10 @@ */ import {EventListenerCollection} from '../../core.js'; +import {DocumentUtil} from '../../dom/document-util.js'; import {yomitan} from '../../yomitan.js'; import {KeyboardMouseInputField} from './keyboard-mouse-input-field.js'; -/* global - * DocumentUtil - * KeyboardMouseInputField - */ - export class ScanInputsController { /** * @param {import('./settings-controller.js').SettingsController} settingsController diff --git a/ext/js/pages/settings/settings-display-controller.js b/ext/js/pages/settings/settings-display-controller.js index ca4fc32e..16e6cfae 100644 --- a/ext/js/pages/settings/settings-display-controller.js +++ b/ext/js/pages/settings/settings-display-controller.js @@ -23,12 +23,12 @@ import {SelectorObserver} from '../../dom/selector-observer.js'; export class SettingsDisplayController { /** * @param {import('./settings-controller.js').SettingsController} settingsController - * @param {ModalController} modalController + * @param {import('./modal-controller.js').ModalController} modalController */ constructor(settingsController, modalController) { /** @type {import('./settings-controller.js').SettingsController} */ this._settingsController = settingsController; - /** @type {ModalController} */ + /** @type {import('./modal-controller.js').ModalController} */ this._modalController = modalController; /** @type {?HTMLElement} */ this._contentNode = null; diff --git a/ext/js/pages/settings/storage-controller.js b/ext/js/pages/settings/storage-controller.js index 8af44b33..7f323b48 100644 --- a/ext/js/pages/settings/storage-controller.js +++ b/ext/js/pages/settings/storage-controller.js @@ -20,10 +20,10 @@ import {yomitan} from '../../yomitan.js'; export class StorageController { /** - * @param {PersistentStorageController} persistentStorageController + * @param {import('./persistent-storage-controller.js').PersistentStorageController} persistentStorageController */ constructor(persistentStorageController) { - /** @type {PersistentStorageController} */ + /** @type {import('./persistent-storage-controller.js').PersistentStorageController} */ this._persistentStorageController = persistentStorageController; /** @type {?StorageEstimate} */ this._mostRecentStorageEstimate = null; -- cgit v1.2.3