diff options
Diffstat (limited to 'ext/js/display')
-rw-r--r-- | ext/js/display/display-anki.js | 2 | ||||
-rw-r--r-- | ext/js/display/display-audio.js | 6 | ||||
-rw-r--r-- | ext/js/display/display.js | 17 | ||||
-rw-r--r-- | ext/js/display/element-overflow-controller.js | 10 | ||||
-rw-r--r-- | ext/js/display/sandbox/structured-content-generator.js | 2 | ||||
-rw-r--r-- | ext/js/display/search-display-controller.js | 5 |
6 files changed, 21 insertions, 21 deletions
diff --git a/ext/js/display/display-anki.js b/ext/js/display/display-anki.js index 4766f1ae..d37efa85 100644 --- a/ext/js/display/display-anki.js +++ b/ext/js/display/display-anki.js @@ -953,6 +953,8 @@ class DisplayAnkiError extends Error { */ constructor(message) { super(message); + /** @type {string} */ + this.name = 'DisplayAnkiError'; /** @type {?import('anki-note-builder').Requirement[]} */ this._requirements = null; /** @type {?import('anki-note-builder').Requirement[]} */ diff --git a/ext/js/display/display-audio.js b/ext/js/display/display-audio.js index 7d75d6b0..5f4131d0 100644 --- a/ext/js/display/display-audio.js +++ b/ext/js/display/display-audio.js @@ -33,7 +33,7 @@ export class DisplayAudio { /** @type {AudioSystem} */ this._audioSystem = new AudioSystem(); /** @type {number} */ - this._playbackVolume = 1.0; + this._playbackVolume = 1; /** @type {boolean} */ this._autoPlay = false; /** @type {?import('core').Timeout} */ @@ -166,7 +166,7 @@ export class DisplayAudio { _onOptionsUpdated({options}) { const {enabled, autoPlay, volume, sources} = options.audio; this._autoPlay = enabled && autoPlay; - this._playbackVolume = Number.isFinite(volume) ? Math.max(0.0, Math.min(1.0, volume / 100.0)) : 1.0; + this._playbackVolume = Number.isFinite(volume) ? Math.max(0, Math.min(1, volume / 100)) : 1; /** @type {Set<import('settings').AudioSourceType>} */ const requiredAudioSources = new Set([ @@ -534,7 +534,7 @@ export class DisplayAudio { if (headwordNode !== null) { const {index} = headwordNode.dataset; if (typeof index === 'string') { - const headwordIndex = parseInt(index, 10); + const headwordIndex = Number.parseInt(index, 10); if (Number.isFinite(headwordIndex)) { return headwordIndex; } } } diff --git a/ext/js/display/display.js b/ext/js/display/display.js index a5dad2d1..d30ed8a0 100644 --- a/ext/js/display/display.js +++ b/ext/js/display/display.js @@ -619,7 +619,7 @@ export class Display extends EventDispatcher { if (node === null) { return -1; } const {index} = node.dataset; if (typeof index !== 'string') { return -1; } - const indexNumber = parseInt(index, 10); + const indexNumber = Number.parseInt(index, 10); return Number.isFinite(indexNumber) ? indexNumber : -1; } @@ -1020,7 +1020,7 @@ export class Display extends EventDispatcher { const node = /** @type {HTMLElement} */ (e.currentTarget); const {index} = node.dataset; if (typeof index !== 'string') { return; } - const indexNumber = parseInt(index, 10); + const indexNumber = Number.parseInt(index, 10); if (!Number.isFinite(indexNumber)) { return; } this._entrySetCurrent(indexNumber); } @@ -1146,8 +1146,7 @@ export class Display extends EventDispatcher { */ async _findDictionaryEntries(isKanji, source, wildcardsEnabled, optionsContext) { if (isKanji) { - const dictionaryEntries = await this._application.api.kanjiFind(source, optionsContext); - return dictionaryEntries; + return await this._application.api.kanjiFind(source, optionsContext); } else { /** @type {import('api').FindTermsDetails} */ const findDetails = {}; @@ -1555,11 +1554,11 @@ export class Display extends EventDispatcher { * @returns {boolean} */ _relativeTermView(next) { - if (next) { - return this._history.hasNext() && this._history.forward(); - } else { - return this._history.hasPrevious() && this._history.back(); - } + return ( + next ? + this._history.hasNext() && this._history.forward() : + this._history.hasPrevious() && this._history.back() + ); } /** diff --git a/ext/js/display/element-overflow-controller.js b/ext/js/display/element-overflow-controller.js index e0b9035e..eb83dda4 100644 --- a/ext/js/display/element-overflow-controller.js +++ b/ext/js/display/element-overflow-controller.js @@ -157,11 +157,11 @@ export class ElementOverflowController { * @returns {number|import('core').Timeout} */ _requestIdleCallback(callback, timeout) { - if (typeof requestIdleCallback === 'function') { - return requestIdleCallback(callback, {timeout}); - } else { - return setTimeout(callback, timeout); - } + return ( + typeof requestIdleCallback === 'function' ? + requestIdleCallback(callback, {timeout}) : + setTimeout(callback, timeout) + ); } /** diff --git a/ext/js/display/sandbox/structured-content-generator.js b/ext/js/display/sandbox/structured-content-generator.js index a04feaf2..1dfde39b 100644 --- a/ext/js/display/sandbox/structured-content-generator.js +++ b/ext/js/display/sandbox/structured-content-generator.js @@ -137,7 +137,7 @@ export class StructuredContentGenerator { imageContainer.title = title; } - aspectRatioSizer.style.paddingTop = `${invAspectRatio * 100.0}%`; + aspectRatioSizer.style.paddingTop = `${invAspectRatio * 100}%`; if (this._contentManager !== null) { this._contentManager.loadMedia( diff --git a/ext/js/display/search-display-controller.js b/ext/js/display/search-display-controller.js index ed2061e2..6767dce7 100644 --- a/ext/js/display/search-display-controller.js +++ b/ext/js/display/search-display-controller.js @@ -322,7 +322,7 @@ export class SearchDisplayController { */ async _onProfileSelectChange(event) { const node = /** @type {HTMLInputElement} */ (event.currentTarget); - const value = parseInt(node.value, 10); + const value = Number.parseInt(node.value, 10); const optionsFull = await this._display.application.api.optionsGetFull(); if (typeof value === 'number' && Number.isFinite(value) && value >= 0 && value <= optionsFull.profiles.length) { this._setPrimaryProfileIndex(value); @@ -574,8 +574,7 @@ export class SearchDisplayController { case 'select': return true; } - if (element instanceof HTMLElement && element.isContentEditable) { return true; } - return false; + return element instanceof HTMLElement && !!element.isContentEditable; } /** |