From d08ac02c6a36d06bfc525b4839fce8736731cfd5 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Wed, 26 Feb 2020 19:52:12 -0500 Subject: Move event handler definitions --- ext/fg/js/frontend.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'ext/fg/js') diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js index 67045241..71ca7c9e 100644 --- a/ext/fg/js/frontend.js +++ b/ext/fg/js/frontend.js @@ -39,6 +39,15 @@ class Frontend extends TextScanner { this._contentScale = 1.0; this._orphaned = true; this._lastShowPromise = Promise.resolve(); + + this._windowMessageHandlers = new Map([ + ['popupClose', () => this.onSearchClear(true)], + ['selectionCopy', () => document.execCommand('copy')] + ]); + + this._runtimeMessageHandlers = new Map([ + ['popupSetVisibleOverride', ({visible}) => { this.popup.setVisibleOverride(visible); }] + ]); } async prepare() { @@ -72,17 +81,17 @@ class Frontend extends TextScanner { onWindowMessage(e) { const action = e.data; - const handler = Frontend._windowMessageHandlers.get(action); + const handler = this._windowMessageHandlers.get(action); if (typeof handler !== 'function') { return false; } - handler(this); + handler(); } onRuntimeMessage({action, params}, sender, callback) { - const handler = Frontend._runtimeMessageHandlers.get(action); + const handler = this._runtimeMessageHandlers.get(action); if (typeof handler !== 'function') { return false; } - const result = handler(this, params, sender); + const result = handler(params, sender); callback(result); return false; } @@ -237,12 +246,3 @@ class Frontend extends TextScanner { return visualViewport !== null && typeof visualViewport === 'object' ? visualViewport.scale : 1.0; } } - -Frontend._windowMessageHandlers = new Map([ - ['popupClose', (self) => self.onSearchClear(true)], - ['selectionCopy', () => document.execCommand('copy')] -]); - -Frontend._runtimeMessageHandlers = new Map([ - ['popupSetVisibleOverride', (self, {visible}) => { self.popup.setVisibleOverride(visible); }] -]); -- cgit v1.2.3 From 03ba1b633e2230435f6baeeaa4b6009de2932452 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Wed, 26 Feb 2020 20:02:50 -0500 Subject: Move event handler definitions --- ext/fg/js/float.js | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'ext/fg/js') diff --git a/ext/fg/js/float.js b/ext/fg/js/float.js index 8f21a9c5..7cc9c367 100644 --- a/ext/fg/js/float.js +++ b/ext/fg/js/float.js @@ -33,6 +33,24 @@ class DisplayFloat extends Display { this._messageToken = null; this._messageTokenPromise = null; + this._onKeyDownHandlers = new Map([ + ['C', (e) => { + if (e.ctrlKey && !window.getSelection().toString()) { + this.onSelectionCopy(); + return true; + } + return false; + }] + ]); + + this._windowMessageHandlers = new Map([ + ['setContent', ({type, details}) => this.setContent(type, details)], + ['clearAutoPlayTimer', () => this.clearAutoPlayTimer()], + ['setCustomCss', ({css}) => this.setCustomCss(css)], + ['prepare', ({options, popupInfo, url, childrenSupported, scale, uniqueId}) => this.prepare(options, popupInfo, url, childrenSupported, scale, uniqueId)], + ['setContentScale', ({scale}) => this.setContentScale(scale)] + ]); + yomichan.on('orphaned', () => this.onOrphaned()); window.addEventListener('message', (e) => this.onMessage(e), false); } @@ -98,9 +116,9 @@ class DisplayFloat extends Display { onKeyDown(e) { const key = Display.getKeyFromEvent(e); - const handler = DisplayFloat._onKeyDownHandlers.get(key); + const handler = this._onKeyDownHandlers.get(key); if (typeof handler === 'function') { - if (handler(this, e)) { + if (handler(e)) { e.preventDefault(); return true; } @@ -126,10 +144,10 @@ class DisplayFloat extends Display { return; } - const handler = DisplayFloat._messageHandlers.get(action); + const handler = this._windowMessageHandlers.get(action); if (typeof handler !== 'function') { return; } - handler(this, params); + handler(params); } getOptionsContext() { @@ -153,22 +171,4 @@ class DisplayFloat extends Display { } } -DisplayFloat._onKeyDownHandlers = new Map([ - ['C', (self, e) => { - if (e.ctrlKey && !window.getSelection().toString()) { - self.onSelectionCopy(); - return true; - } - return false; - }] -]); - -DisplayFloat._messageHandlers = new Map([ - ['setContent', (self, {type, details}) => self.setContent(type, details)], - ['clearAutoPlayTimer', (self) => self.clearAutoPlayTimer()], - ['setCustomCss', (self, {css}) => self.setCustomCss(css)], - ['prepare', (self, {options, popupInfo, url, childrenSupported, scale, uniqueId}) => self.prepare(options, popupInfo, url, childrenSupported, scale, uniqueId)], - ['setContentScale', (self, {scale}) => self.setContentScale(scale)] -]); - DisplayFloat.instance = new DisplayFloat(); -- cgit v1.2.3 From fc08cd74fe030ced6840a51ebe093f924cdd87e0 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Wed, 26 Feb 2020 20:35:37 -0500 Subject: Use .bind instead of () => {} --- ext/fg/js/popup-proxy-host.js | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'ext/fg/js') diff --git a/ext/fg/js/popup-proxy-host.js b/ext/fg/js/popup-proxy-host.js index e55801ff..bef2cb16 100644 --- a/ext/fg/js/popup-proxy-host.js +++ b/ext/fg/js/popup-proxy-host.js @@ -34,16 +34,16 @@ class PopupProxyHost { if (typeof frameId !== 'number') { return; } this._apiReceiver = new FrontendApiReceiver(`popup-proxy-host#${frameId}`, new Map([ - ['getOrCreatePopup', ({id, parentId}) => this._onApiGetOrCreatePopup(id, parentId)], - ['setOptions', ({id, options}) => this._onApiSetOptions(id, options)], - ['hide', ({id, changeFocus}) => this._onApiHide(id, changeFocus)], - ['isVisible', ({id}) => this._onApiIsVisibleAsync(id)], - ['setVisibleOverride', ({id, visible}) => this._onApiSetVisibleOverride(id, visible)], - ['containsPoint', ({id, x, y}) => this._onApiContainsPoint(id, x, y)], - ['showContent', ({id, elementRect, writingMode, type, details}) => this._onApiShowContent(id, elementRect, writingMode, type, details)], - ['setCustomCss', ({id, css}) => this._onApiSetCustomCss(id, css)], - ['clearAutoPlayTimer', ({id}) => this._onApiClearAutoPlayTimer(id)], - ['setContentScale', ({id, scale}) => this._onApiSetContentScale(id, scale)] + ['getOrCreatePopup', this._onApiGetOrCreatePopup.bind(this)], + ['setOptions', this._onApiSetOptions.bind(this)], + ['hide', this._onApiHide.bind(this)], + ['isVisible', this._onApiIsVisibleAsync.bind(this)], + ['setVisibleOverride', this._onApiSetVisibleOverride.bind(this)], + ['containsPoint', this._onApiContainsPoint.bind(this)], + ['showContent', this._onApiShowContent.bind(this)], + ['setCustomCss', this._onApiSetCustomCss.bind(this)], + ['clearAutoPlayTimer', this._onApiClearAutoPlayTimer.bind(this)], + ['setContentScale', this._onApiSetContentScale.bind(this)] ])); } @@ -87,56 +87,56 @@ class PopupProxyHost { // Message handlers - async _onApiGetOrCreatePopup(id, parentId) { + async _onApiGetOrCreatePopup({id, parentId}) { const popup = this.getOrCreatePopup(id, parentId); return { id: popup.id }; } - async _onApiSetOptions(id, options) { + async _onApiSetOptions({id, options}) { const popup = this._getPopup(id); return await popup.setOptions(options); } - async _onApiHide(id, changeFocus) { + async _onApiHide({id, changeFocus}) { const popup = this._getPopup(id); return popup.hide(changeFocus); } - async _onApiIsVisibleAsync(id) { + async _onApiIsVisibleAsync({id}) { const popup = this._getPopup(id); return await popup.isVisible(); } - async _onApiSetVisibleOverride(id, visible) { + async _onApiSetVisibleOverride({id, visible}) { const popup = this._getPopup(id); return await popup.setVisibleOverride(visible); } - async _onApiContainsPoint(id, x, y) { + async _onApiContainsPoint({id, x, y}) { const popup = this._getPopup(id); return await popup.containsPoint(x, y); } - async _onApiShowContent(id, elementRect, writingMode, type, details) { + async _onApiShowContent({id, elementRect, writingMode, type, details}) { const popup = this._getPopup(id); elementRect = PopupProxyHost._convertJsonRectToDOMRect(popup, elementRect); if (!PopupProxyHost._popupCanShow(popup)) { return; } return await popup.showContent(elementRect, writingMode, type, details); } - async _onApiSetCustomCss(id, css) { + async _onApiSetCustomCss({id, css}) { const popup = this._getPopup(id); return popup.setCustomCss(css); } - async _onApiClearAutoPlayTimer(id) { + async _onApiClearAutoPlayTimer({id}) { const popup = this._getPopup(id); return popup.clearAutoPlayTimer(); } - async _onApiSetContentScale(id, scale) { + async _onApiSetContentScale({id, scale}) { const popup = this._getPopup(id); return popup.setContentScale(scale); } -- cgit v1.2.3 From 8bc1a409144898124386ef03e921efb2a6e73a8f Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Wed, 26 Feb 2020 21:01:40 -0500 Subject: Use .bind instead of () => {} --- ext/bg/js/backend.js | 6 +++--- ext/bg/js/search.js | 14 +++++++------- ext/bg/js/settings/audio-ui.js | 6 +++--- ext/bg/js/settings/conditions-ui.js | 12 ++++++------ ext/bg/js/settings/dictionaries.js | 10 +++++----- ext/bg/js/settings/popup-preview-frame.js | 6 +++--- ext/fg/js/float.js | 4 ++-- ext/fg/js/frontend.js | 6 +++--- ext/fg/js/popup.js | 2 +- ext/mixed/js/scroll.js | 2 +- 10 files changed, 34 insertions(+), 34 deletions(-) (limited to 'ext/fg/js') diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js index 25537e55..238ac52c 100644 --- a/ext/bg/js/backend.js +++ b/ext/bg/js/backend.js @@ -100,10 +100,10 @@ class Backend { this.onOptionsUpdated('background'); if (isObject(chrome.commands) && isObject(chrome.commands.onCommand)) { - chrome.commands.onCommand.addListener((command) => this._runCommand(command)); + chrome.commands.onCommand.addListener(this._runCommand.bind(this)); } if (isObject(chrome.tabs) && isObject(chrome.tabs.onZoomChange)) { - chrome.tabs.onZoomChange.addListener((info) => this._onZoomChange(info)); + chrome.tabs.onZoomChange.addListener(this._onZoomChange.bind(this)); } chrome.runtime.onMessage.addListener(this.onMessage.bind(this)); @@ -116,7 +116,7 @@ class Backend { this.isPreparedResolve = null; this.isPreparedPromise = null; - this.clipboardMonitor.onClipboardText = (text) => this._onClipboardText(text); + this.clipboardMonitor.onClipboardText = this._onClipboardText.bind(this); } onOptionsUpdated(source) { diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js index c692a859..e9b1918b 100644 --- a/ext/bg/js/search.js +++ b/ext/bg/js/search.js @@ -93,18 +93,18 @@ class DisplaySearch extends Display { } else { this.clipboardMonitorEnable.checked = false; } - this.clipboardMonitorEnable.addEventListener('change', (e) => this.onClipboardMonitorEnableChange(e)); + this.clipboardMonitorEnable.addEventListener('change', this.onClipboardMonitorEnableChange.bind(this)); } chrome.runtime.onMessage.addListener(this.onRuntimeMessage.bind(this)); - this.search.addEventListener('click', (e) => this.onSearch(e), false); - this.query.addEventListener('input', () => this.onSearchInput(), false); - this.wanakanaEnable.addEventListener('change', (e) => this.onWanakanaEnableChange(e)); - window.addEventListener('popstate', (e) => this.onPopState(e)); - window.addEventListener('copy', (e) => this.onCopy(e)); + this.search.addEventListener('click', this.onSearch.bind(this), false); + this.query.addEventListener('input', this.onSearchInput.bind(this), false); + this.wanakanaEnable.addEventListener('change', this.onWanakanaEnableChange.bind(this)); + window.addEventListener('popstate', this.onPopState.bind(this)); + window.addEventListener('copy', this.onCopy.bind(this)); - this.clipboardMonitor.onClipboardText = (text) => this.onExternalSearchUpdate(text); + this.clipboardMonitor.onClipboardText = this.onExternalSearchUpdate.bind(this); this.updateSearchButton(); } catch (e) { diff --git a/ext/bg/js/settings/audio-ui.js b/ext/bg/js/settings/audio-ui.js index 555380b4..206539a4 100644 --- a/ext/bg/js/settings/audio-ui.js +++ b/ext/bg/js/settings/audio-ui.js @@ -37,7 +37,7 @@ AudioSourceUI.Container = class Container { this.children.push(new AudioSourceUI.AudioSource(this, audioSource, this.children.length)); } - this._clickListener = () => this.onAddAudioSource(); + this._clickListener = this.onAddAudioSource.bind(this); this.addButton.addEventListener('click', this._clickListener, false); } @@ -105,8 +105,8 @@ AudioSourceUI.AudioSource = class AudioSource { this.select.value = audioSource; - this._selectChangeListener = () => this.onSelectChanged(); - this._removeClickListener = () => this.onRemoveClicked(); + this._selectChangeListener = this.onSelectChanged.bind(this); + this._removeClickListener = this.onRemoveClicked.bind(this); this.select.addEventListener('change', this._selectChangeListener, false); this.removeButton.addEventListener('click', this._removeClickListener, false); diff --git a/ext/bg/js/settings/conditions-ui.js b/ext/bg/js/settings/conditions-ui.js index 63e01861..4ca86b07 100644 --- a/ext/bg/js/settings/conditions-ui.js +++ b/ext/bg/js/settings/conditions-ui.js @@ -41,7 +41,7 @@ ConditionsUI.Container = class Container { this.children.push(new ConditionsUI.ConditionGroup(this, conditionGroup)); } - this.addButton.on('click', () => this.onAddConditionGroup()); + this.addButton.on('click', this.onAddConditionGroup.bind(this)); } cleanup() { @@ -127,7 +127,7 @@ ConditionsUI.ConditionGroup = class ConditionGroup { this.children.push(new ConditionsUI.Condition(this, condition)); } - this.addButton.on('click', () => this.onAddCondition()); + this.addButton.on('click', this.onAddCondition.bind(this)); } cleanup() { @@ -185,10 +185,10 @@ ConditionsUI.Condition = class Condition { this.updateOperators(); this.updateInput(); - this.input.on('change', () => this.onInputChanged()); - this.typeSelect.on('change', () => this.onConditionTypeChanged()); - this.operatorSelect.on('change', () => this.onConditionOperatorChanged()); - this.removeButton.on('click', () => this.onRemoveClicked()); + this.input.on('change', this.onInputChanged.bind(this)); + this.typeSelect.on('change', this.onConditionTypeChanged.bind(this)); + this.operatorSelect.on('change', this.onConditionOperatorChanged.bind(this)); + this.removeButton.on('click', this.onRemoveClicked.bind(this)); } cleanup() { diff --git a/ext/bg/js/settings/dictionaries.js b/ext/bg/js/settings/dictionaries.js index 70a22a16..3ceb12fa 100644 --- a/ext/bg/js/settings/dictionaries.js +++ b/ext/bg/js/settings/dictionaries.js @@ -36,7 +36,7 @@ class SettingsDictionaryListUI { this.dictionaryEntries = []; this.extra = null; - document.querySelector('#dict-delete-confirm').addEventListener('click', (e) => this.onDictionaryConfirmDelete(e), false); + document.querySelector('#dict-delete-confirm').addEventListener('click', this.onDictionaryConfirmDelete.bind(this), false); } setOptionsDictionaries(optionsDictionaries) { @@ -198,10 +198,10 @@ class SettingsDictionaryEntryUI { this.applyValues(); - this.eventListeners.addEventListener(this.enabledCheckbox, 'change', (e) => this.onEnabledChanged(e), false); - this.eventListeners.addEventListener(this.allowSecondarySearchesCheckbox, 'change', (e) => this.onAllowSecondarySearchesChanged(e), false); - this.eventListeners.addEventListener(this.priorityInput, 'change', (e) => this.onPriorityChanged(e), false); - this.eventListeners.addEventListener(this.deleteButton, 'click', (e) => this.onDeleteButtonClicked(e), false); + this.eventListeners.addEventListener(this.enabledCheckbox, 'change', this.onEnabledChanged.bind(this), false); + this.eventListeners.addEventListener(this.allowSecondarySearchesCheckbox, 'change', this.onAllowSecondarySearchesChanged.bind(this), false); + this.eventListeners.addEventListener(this.priorityInput, 'change', this.onPriorityChanged.bind(this), false); + this.eventListeners.addEventListener(this.deleteButton, 'click', this.onDeleteButtonClicked.bind(this), false); } cleanup() { diff --git a/ext/bg/js/settings/popup-preview-frame.js b/ext/bg/js/settings/popup-preview-frame.js index d0336b5e..4c086bcd 100644 --- a/ext/bg/js/settings/popup-preview-frame.js +++ b/ext/bg/js/settings/popup-preview-frame.js @@ -44,7 +44,7 @@ class SettingsPopupPreview { async prepare() { // Setup events - window.addEventListener('message', (e) => this.onMessage(e), false); + window.addEventListener('message', this.onMessage.bind(this), false); const themeDarkCheckbox = document.querySelector('#theme-dark-checkbox'); if (themeDarkCheckbox !== null) { @@ -52,7 +52,7 @@ class SettingsPopupPreview { } // Overwrite API functions - window.apiOptionsGet = (...args) => this.apiOptionsGet(...args); + window.apiOptionsGet = this.apiOptionsGet.bind(this); // Overwrite frontend const popupHost = new PopupProxyHost(); @@ -62,7 +62,7 @@ class SettingsPopupPreview { this.popup.setChildrenSupported(false); this.popupSetCustomOuterCssOld = this.popup.setCustomOuterCss; - this.popup.setCustomOuterCss = (...args) => this.popupSetCustomOuterCss(...args); + this.popup.setCustomOuterCss = this.popupSetCustomOuterCss.bind(this); this.frontend = new Frontend(this.popup); diff --git a/ext/fg/js/float.js b/ext/fg/js/float.js index 7cc9c367..aef0367e 100644 --- a/ext/fg/js/float.js +++ b/ext/fg/js/float.js @@ -51,8 +51,8 @@ class DisplayFloat extends Display { ['setContentScale', ({scale}) => this.setContentScale(scale)] ]); - yomichan.on('orphaned', () => this.onOrphaned()); - window.addEventListener('message', (e) => this.onMessage(e), false); + yomichan.on('orphaned', this.onOrphaned.bind(this)); + window.addEventListener('message', this.onMessage.bind(this), false); } async prepare(options, popupInfo, url, childrenSupported, scale, uniqueId) { diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js index 71ca7c9e..929ab56a 100644 --- a/ext/fg/js/frontend.js +++ b/ext/fg/js/frontend.js @@ -64,9 +64,9 @@ class Frontend extends TextScanner { window.visualViewport.addEventListener('resize', this.onVisualViewportResize.bind(this)); } - yomichan.on('orphaned', () => this.onOrphaned()); - yomichan.on('optionsUpdated', () => this.updateOptions()); - yomichan.on('zoomChanged', (e) => this.onZoomChanged(e)); + yomichan.on('orphaned', this.onOrphaned.bind(this)); + yomichan.on('optionsUpdated', this.updateOptions.bind(this)); + yomichan.on('zoomChanged', this.onZoomChanged.bind(this)); chrome.runtime.onMessage.addListener(this.onRuntimeMessage.bind(this)); this._updateContentScale(); diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js index 4927f4bd..bc40a8c4 100644 --- a/ext/fg/js/popup.js +++ b/ext/fg/js/popup.js @@ -260,7 +260,7 @@ class Popup { 'mozfullscreenchange', 'webkitfullscreenchange' ]; - const onFullscreenChanged = () => this._onFullscreenChanged(); + const onFullscreenChanged = this._onFullscreenChanged.bind(this); for (const eventName of fullscreenEvents) { this._fullscreenEventListeners.addEventListener(document, eventName, onFullscreenChanged, false); } diff --git a/ext/mixed/js/scroll.js b/ext/mixed/js/scroll.js index 5829d294..72da8b65 100644 --- a/ext/mixed/js/scroll.js +++ b/ext/mixed/js/scroll.js @@ -26,7 +26,7 @@ class WindowScroll { this.animationEndTime = 0; this.animationEndX = 0; this.animationEndY = 0; - this.requestAnimationFrameCallback = (t) => this.onAnimationFrame(t); + this.requestAnimationFrameCallback = this.onAnimationFrame.bind(this); } toY(y) { -- cgit v1.2.3 From 314c567a47cd07dee7d6cda785257b2109afcad5 Mon Sep 17 00:00:00 2001 From: siikamiika Date: Sun, 1 Mar 2020 19:02:43 +0200 Subject: fix hotkeys in popup --- ext/fg/js/float.js | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'ext/fg/js') diff --git a/ext/fg/js/float.js b/ext/fg/js/float.js index aef0367e..bc459d23 100644 --- a/ext/fg/js/float.js +++ b/ext/fg/js/float.js @@ -40,7 +40,8 @@ class DisplayFloat extends Display { return true; } return false; - }] + }], + ...this._onKeyDownHandlers ]); this._windowMessageHandlers = new Map([ @@ -114,18 +115,6 @@ class DisplayFloat extends Display { } } - onKeyDown(e) { - const key = Display.getKeyFromEvent(e); - const handler = this._onKeyDownHandlers.get(key); - if (typeof handler === 'function') { - if (handler(e)) { - e.preventDefault(); - return true; - } - } - return super.onKeyDown(e); - } - async getMessageToken() { // this._messageTokenPromise is used to ensure that only one call to apiGetMessageToken is made. if (this._messageTokenPromise === null) { -- cgit v1.2.3 From 967e99b7f69d24fc76999675cef44b919602dd31 Mon Sep 17 00:00:00 2001 From: siikamiika Date: Mon, 2 Mar 2020 04:51:45 +0200 Subject: ensure Backend prepare in other places --- ext/bg/js/backend.js | 22 +++++++++++++++------- ext/bg/js/search-frontend.js | 2 ++ ext/bg/js/search.js | 5 ++--- ext/fg/js/frontend.js | 1 + ext/mixed/js/api.js | 28 ---------------------------- ext/mixed/js/core.js | 13 +++++++++++++ ext/mixed/js/display.js | 1 + 7 files changed, 34 insertions(+), 38 deletions(-) (limited to 'ext/fg/js') diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js index e849bc69..81578462 100644 --- a/ext/bg/js/backend.js +++ b/ext/bg/js/backend.js @@ -48,7 +48,7 @@ class Backend { this.messageToken = yomichan.generateId(16); this._messageHandlers = new Map([ - ['isBackendReady', this._onApiIsBackendReady.bind(this)], + ['yomichanOnline', this._onApiYomichanOnline.bind(this)], ['optionsSchemaGet', this._onApiOptionsSchemaGet.bind(this)], ['optionsGet', this._onApiOptionsGet.bind(this)], ['optionsGetFull', this._onApiOptionsGetFull.bind(this)], @@ -114,19 +114,24 @@ class Backend { } this.clipboardMonitor.onClipboardText = this._onClipboardText.bind(this); - } - onOptionsUpdated(source) { - this.applyOptions(); + this._sendMessageAllTabs('backendPrepared'); + } + _sendMessageAllTabs(action, params={}) { const callback = () => this.checkLastError(chrome.runtime.lastError); chrome.tabs.query({}, (tabs) => { for (const tab of tabs) { - chrome.tabs.sendMessage(tab.id, {action: 'optionsUpdated', params: {source}}, callback); + chrome.tabs.sendMessage(tab.id, {action, params}, callback); } }); } + onOptionsUpdated(source) { + this.applyOptions(); + this._sendMessageAllTabs('optionsUpdated', {source}); + } + onMessage({action, params}, sender, callback) { const handler = this._messageHandlers.get(action); if (typeof handler !== 'function') { return false; } @@ -268,8 +273,11 @@ class Backend { // Message handlers - async _onApiIsBackendReady() { - return true; + async _onApiYomichanOnline(_params, sender) { + const tabId = sender.tab.id; + return new Promise((resolve) => { + chrome.tabs.sendMessage(tabId, {action: 'backendPrepared'}, resolve); + }); } async _onApiOptionsSchemaGet() { diff --git a/ext/bg/js/search-frontend.js b/ext/bg/js/search-frontend.js index 509c4009..453a0b79 100644 --- a/ext/bg/js/search-frontend.js +++ b/ext/bg/js/search-frontend.js @@ -19,6 +19,8 @@ /*global apiOptionsGet*/ async function searchFrontendSetup() { + await yomichan.prepare(); + const optionsContext = { depth: 0, url: window.location.href diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js index 0a7a5fe1..f3cba7ae 100644 --- a/ext/bg/js/search.js +++ b/ext/bg/js/search.js @@ -68,9 +68,8 @@ class DisplaySearch extends Display { async prepare() { try { - const superPromise = super.prepare(); - const queryParserPromise = this.queryParser.prepare(); - await Promise.all([superPromise, queryParserPromise]); + await super.prepare(); + await this.queryParser.prepare(); const {queryParams: {query='', mode=''}} = parseUrl(window.location.href); diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js index 929ab56a..203366c3 100644 --- a/ext/fg/js/frontend.js +++ b/ext/fg/js/frontend.js @@ -52,6 +52,7 @@ class Frontend extends TextScanner { async prepare() { try { + await yomichan.prepare(); await this.updateOptions(); const {zoomFactor} = await apiGetZoom(); this._pageZoomFactor = zoomFactor; diff --git a/ext/mixed/js/api.js b/ext/mixed/js/api.js index fa61a1e2..26f4389d 100644 --- a/ext/mixed/js/api.js +++ b/ext/mixed/js/api.js @@ -122,30 +122,6 @@ function apiGetDefaultAnkiFieldTemplates() { } function _apiInvoke(action, params={}) { - if (!_isBackendReady) { - if (_isBackendReadyPromise === null) { - _isBackendReadyPromise = new Promise((resolve) => (_isBackendReadyResolve = resolve)); - const checkBackendReady = async () => { - try { - if (await _apiInvokeRaw('isBackendReady')) { - _isBackendReady = true; - _isBackendReadyResolve(); - } - } catch (e) { - // NOP - } - setTimeout(checkBackendReady, 100); // poll Backend until it responds - }; - checkBackendReady(); - } - return _isBackendReadyPromise.then( - () => _apiInvokeRaw(action, params) - ); - } - return _apiInvokeRaw(action, params); -} - -function _apiInvokeRaw(action, params={}) { const data = {action, params}; return new Promise((resolve, reject) => { try { @@ -172,7 +148,3 @@ function _apiInvokeRaw(action, params={}) { function _apiCheckLastError() { // NOP } - -let _isBackendReady = false; -let _isBackendReadyResolve = null; -let _isBackendReadyPromise = null; diff --git a/ext/mixed/js/core.js b/ext/mixed/js/core.js index 83813796..a3cb2459 100644 --- a/ext/mixed/js/core.js +++ b/ext/mixed/js/core.js @@ -269,17 +269,26 @@ const yomichan = (() => { constructor() { super(); + this._isBackendPreparedResolve = null; + this._isBackendPreparedPromise = new Promise((resolve) => (this._isBackendPreparedResolve = resolve)); + this._messageHandlers = new Map([ + ['backendPrepared', this._onBackendPrepared.bind(this)], ['getUrl', this._onMessageGetUrl.bind(this)], ['optionsUpdated', this._onMessageOptionsUpdated.bind(this)], ['zoomChanged', this._onMessageZoomChanged.bind(this)] ]); chrome.runtime.onMessage.addListener(this._onMessage.bind(this)); + chrome.runtime.sendMessage({action: 'yomichanOnline'}); } // Public + prepare() { + return this._isBackendPreparedPromise; + } + generateId(length) { const array = new Uint8Array(length); window.crypto.getRandomValues(array); @@ -305,6 +314,10 @@ const yomichan = (() => { return false; } + _onBackendPrepared() { + this._isBackendPreparedResolve(); + } + _onMessageGetUrl() { return {url: window.location.href}; } diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js index e3e5e7df..6a762a65 100644 --- a/ext/mixed/js/display.js +++ b/ext/mixed/js/display.js @@ -153,6 +153,7 @@ class Display { } async prepare(options=null) { + await yomichan.prepare(); const displayGeneratorPromise = this.displayGenerator.prepare(); const updateOptionsPromise = this.updateOptions(options); await Promise.all([displayGeneratorPromise, updateOptionsPromise]); -- cgit v1.2.3 From a05a05c4f49d97f44dc3e1599906047c4a346512 Mon Sep 17 00:00:00 2001 From: siikamiika Date: Mon, 2 Mar 2020 12:01:53 +0200 Subject: fix content script entry point Yomichan prepare Covers Popup stuff in addition to Frontend --- ext/fg/js/frontend-initialize.js | 2 ++ ext/fg/js/frontend.js | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'ext/fg/js') diff --git a/ext/fg/js/frontend-initialize.js b/ext/fg/js/frontend-initialize.js index 54b874f2..bbb789cc 100644 --- a/ext/fg/js/frontend-initialize.js +++ b/ext/fg/js/frontend-initialize.js @@ -19,6 +19,8 @@ /*global PopupProxyHost, PopupProxy, Frontend*/ async function main() { + await yomichan.prepare(); + const data = window.frontendInitializationData || {}; const {id, depth=0, parentFrameId, ignoreNodes, url, proxy=false} = data; diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js index 203366c3..929ab56a 100644 --- a/ext/fg/js/frontend.js +++ b/ext/fg/js/frontend.js @@ -52,7 +52,6 @@ class Frontend extends TextScanner { async prepare() { try { - await yomichan.prepare(); await this.updateOptions(); const {zoomFactor} = await apiGetZoom(); this._pageZoomFactor = zoomFactor; -- cgit v1.2.3 From 8b76761744ca36d9b0c9523d3d7a80430d21abcb Mon Sep 17 00:00:00 2001 From: siikamiika Date: Sat, 7 Mar 2020 00:32:45 +0200 Subject: reconnect FrontendApiSender after disconnecting --- ext/fg/js/frontend-api-sender.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'ext/fg/js') diff --git a/ext/fg/js/frontend-api-sender.js b/ext/fg/js/frontend-api-sender.js index 8dc6aaf3..4431df61 100644 --- a/ext/fg/js/frontend-api-sender.js +++ b/ext/fg/js/frontend-api-sender.js @@ -31,6 +31,8 @@ class FrontendApiSender { invoke(action, params, target) { if (this.disconnected) { + // attempt to reconnect the next time + this.disconnected = false; return Promise.reject(new Error('Disconnected')); } @@ -70,6 +72,7 @@ class FrontendApiSender { onDisconnect() { this.disconnected = true; + this.port = null; for (const id of this.callbacks.keys()) { this.onError(id, 'Disconnected'); -- cgit v1.2.3 From 86be737508d3148c90ea04d702fab30fdfb464d2 Mon Sep 17 00:00:00 2001 From: siikamiika Date: Sat, 7 Mar 2020 03:52:36 +0200 Subject: fix popup containsPoint offset --- ext/fg/js/popup-proxy-host.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'ext/fg/js') diff --git a/ext/fg/js/popup-proxy-host.js b/ext/fg/js/popup-proxy-host.js index bef2cb16..b9a5617c 100644 --- a/ext/fg/js/popup-proxy-host.js +++ b/ext/fg/js/popup-proxy-host.js @@ -116,7 +116,8 @@ class PopupProxyHost { async _onApiContainsPoint({id, x, y}) { const popup = this._getPopup(id); - return await popup.containsPoint(x, y); + const rootPagePoint = PopupProxyHost._convertPopupPointToRootPagePoint(popup, x, y); + return await popup.containsPoint(...rootPagePoint); } async _onApiShowContent({id, elementRect, writingMode, type, details}) { @@ -152,14 +153,17 @@ class PopupProxyHost { } static _convertJsonRectToDOMRect(popup, jsonRect) { - let x = jsonRect.x; - let y = jsonRect.y; + const [x, y] = PopupProxyHost._convertPopupPointToRootPagePoint(popup, jsonRect.x, jsonRect.y); + return new DOMRect(x, y, jsonRect.width, jsonRect.height); + } + + static _convertPopupPointToRootPagePoint(popup, x, y) { if (popup.parent !== null) { const popupRect = popup.parent.getContainerRect(); x += popupRect.x; y += popupRect.y; } - return new DOMRect(x, y, jsonRect.width, jsonRect.height); + return [x, y]; } static _popupCanShow(popup) { -- cgit v1.2.3 From 9fef0751f3dc7f213f158a50124371f0c6fb5a17 Mon Sep 17 00:00:00 2001 From: siikamiika Date: Sat, 7 Mar 2020 04:11:18 +0200 Subject: replace spread with destructuring --- ext/fg/js/popup-proxy-host.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ext/fg/js') diff --git a/ext/fg/js/popup-proxy-host.js b/ext/fg/js/popup-proxy-host.js index b9a5617c..7d86aa67 100644 --- a/ext/fg/js/popup-proxy-host.js +++ b/ext/fg/js/popup-proxy-host.js @@ -116,8 +116,8 @@ class PopupProxyHost { async _onApiContainsPoint({id, x, y}) { const popup = this._getPopup(id); - const rootPagePoint = PopupProxyHost._convertPopupPointToRootPagePoint(popup, x, y); - return await popup.containsPoint(...rootPagePoint); + [x, y] = PopupProxyHost._convertPopupPointToRootPagePoint(popup, x, y); + return await popup.containsPoint(x, y); } async _onApiShowContent({id, elementRect, writingMode, type, details}) { -- cgit v1.2.3 From e2bf22831ab9aa26a6f30ff75c584202f79dc523 Mon Sep 17 00:00:00 2001 From: siikamiika Date: Mon, 9 Mar 2020 02:10:28 +0200 Subject: start popup depth from 1 on search page --- ext/fg/js/frontend-initialize.js | 2 +- ext/fg/js/popup-proxy-host.js | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'ext/fg/js') diff --git a/ext/fg/js/frontend-initialize.js b/ext/fg/js/frontend-initialize.js index bbb789cc..e674724e 100644 --- a/ext/fg/js/frontend-initialize.js +++ b/ext/fg/js/frontend-initialize.js @@ -31,7 +31,7 @@ async function main() { const popupHost = new PopupProxyHost(); await popupHost.prepare(); - popup = popupHost.getOrCreatePopup(); + popup = popupHost.getOrCreatePopup(null, null, depth); } const frontend = new Frontend(popup, ignoreNodes); diff --git a/ext/fg/js/popup-proxy-host.js b/ext/fg/js/popup-proxy-host.js index 7d86aa67..fdb54cdd 100644 --- a/ext/fg/js/popup-proxy-host.js +++ b/ext/fg/js/popup-proxy-host.js @@ -47,7 +47,7 @@ class PopupProxyHost { ])); } - getOrCreatePopup(id=null, parentId=null) { + getOrCreatePopup(id=null, parentId=null, depth=0) { // Find by existing id if (id !== null) { const popup = this._popups.get(id); @@ -76,7 +76,12 @@ class PopupProxyHost { } // Create new popup - const depth = (parent !== null ? parent.depth + 1 : 0); + if (parent !== null) { + if (depth !== 0) { + throw new Error('Depth cannot be set when parent exists'); + } + depth = parent.depth + 1; + } const popup = new Popup(id, depth, this._frameIdPromise); if (parent !== null) { popup.setParent(parent); -- cgit v1.2.3 From 2ca88b9b9f2a6152e8e953cac284f31c8a285446 Mon Sep 17 00:00:00 2001 From: siikamiika Date: Mon, 9 Mar 2020 11:56:06 +0200 Subject: strict check if popup depth has been set --- ext/fg/js/popup-proxy-host.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'ext/fg/js') diff --git a/ext/fg/js/popup-proxy-host.js b/ext/fg/js/popup-proxy-host.js index fdb54cdd..49123ee1 100644 --- a/ext/fg/js/popup-proxy-host.js +++ b/ext/fg/js/popup-proxy-host.js @@ -47,7 +47,7 @@ class PopupProxyHost { ])); } - getOrCreatePopup(id=null, parentId=null, depth=0) { + getOrCreatePopup(id=null, parentId=null, depth=null) { // Find by existing id if (id !== null) { const popup = this._popups.get(id); @@ -77,10 +77,12 @@ class PopupProxyHost { // Create new popup if (parent !== null) { - if (depth !== 0) { + if (depth !== null) { throw new Error('Depth cannot be set when parent exists'); } depth = parent.depth + 1; + } else if (depth === null) { + depth = 0; } const popup = new Popup(id, depth, this._frameIdPromise); if (parent !== null) { -- cgit v1.2.3 From 64fc0349a17c16355491fac4fc6830b7e68a0e58 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Tue, 10 Mar 2020 22:30:36 -0400 Subject: Update global declarations --- .eslintrc.json | 2 +- ext/bg/js/anki.js | 4 +++- ext/bg/js/audio-uri-builder.js | 4 +++- ext/bg/js/backend.js | 33 +++++++++++++++++++++++------- ext/bg/js/clipboard-monitor.js | 4 +++- ext/bg/js/context.js | 6 +++++- ext/bg/js/database.js | 7 ++++++- ext/bg/js/handlebars.js | 6 +++++- ext/bg/js/japanese.js | 4 +++- ext/bg/js/options.js | 4 +++- ext/bg/js/search-frontend.js | 4 +++- ext/bg/js/search-query-parser-generator.js | 5 ++++- ext/bg/js/search-query-parser.js | 10 ++++++++- ext/bg/js/search.js | 9 +++++++- ext/bg/js/settings/anki-templates.js | 16 +++++++++++---- ext/bg/js/settings/anki.js | 13 +++++++++--- ext/bg/js/settings/audio.js | 10 +++++++-- ext/bg/js/settings/backup.js | 14 ++++++++++--- ext/bg/js/settings/conditions-ui.js | 4 +++- ext/bg/js/settings/dictionaries.js | 22 +++++++++++++++----- ext/bg/js/settings/main.js | 27 +++++++++++++++++------- ext/bg/js/settings/popup-preview-frame.js | 8 +++++++- ext/bg/js/settings/profiles.js | 14 ++++++++++--- ext/bg/js/settings/storage.js | 4 +++- ext/bg/js/translator.js | 28 +++++++++++++++++++------ ext/fg/js/document.js | 6 +++++- ext/fg/js/float.js | 7 ++++++- ext/fg/js/frontend-initialize.js | 6 +++++- ext/fg/js/frontend.js | 9 +++++++- ext/fg/js/popup-nested.js | 4 +++- ext/fg/js/popup-proxy-host.js | 6 +++++- ext/fg/js/popup-proxy.js | 4 +++- ext/fg/js/popup.js | 5 ++++- ext/mixed/js/display-generator.js | 5 ++++- ext/mixed/js/display.js | 22 ++++++++++++++++---- ext/mixed/js/text-scanner.js | 6 +++++- 36 files changed, 272 insertions(+), 70 deletions(-) (limited to 'ext/fg/js') diff --git a/.eslintrc.json b/.eslintrc.json index 2730acb5..db8ff1fa 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -63,7 +63,7 @@ "semi-spacing": ["error", {"before": false, "after": true}], "space-in-parens": ["error", "never"], "space-unary-ops": "error", - "spaced-comment": ["error", "always", {"markers": ["global"]}], + "spaced-comment": ["error", "always"], "switch-colon-spacing": ["error", {"after": true, "before": false}], "template-curly-spacing": ["error", "never"], "template-tag-spacing": ["error", "never"], diff --git a/ext/bg/js/anki.js b/ext/bg/js/anki.js index 39c6ad51..a70388bd 100644 --- a/ext/bg/js/anki.js +++ b/ext/bg/js/anki.js @@ -16,7 +16,9 @@ * along with this program. If not, see . */ -/*global requestJson*/ +/* global + * requestJson + */ /* * AnkiConnect diff --git a/ext/bg/js/audio-uri-builder.js b/ext/bg/js/audio-uri-builder.js index 15cea995..499c3441 100644 --- a/ext/bg/js/audio-uri-builder.js +++ b/ext/bg/js/audio-uri-builder.js @@ -16,7 +16,9 @@ * along with this program. If not, see . */ -/*global jpIsStringEntirelyKana*/ +/* global + * jpIsStringEntirelyKana + */ class AudioUriBuilder { constructor() { diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js index 349fb4eb..978c5a4a 100644 --- a/ext/bg/js/backend.js +++ b/ext/bg/js/backend.js @@ -16,13 +16,32 @@ * along with this program. If not, see . */ -/*global optionsSave, utilIsolate -conditionsTestValue, profileConditionsDescriptor -handlebarsRenderDynamic -requestText, requestJson, optionsLoad -dictConfigured, dictTermsSort, dictEnabledSet -jpConvertReading, jpDistributeFuriganaInflected, jpKatakanaToHiragana -AnkiNoteBuilder, AudioSystem, AudioUriBuilder, Translator, AnkiConnect, AnkiNull, Mecab, BackendApiForwarder, JsonSchema, ClipboardMonitor*/ +/* global + * AnkiConnect + * AnkiNoteBuilder + * AnkiNull + * AudioSystem + * AudioUriBuilder + * BackendApiForwarder + * ClipboardMonitor + * JsonSchema + * Mecab + * Translator + * conditionsTestValue + * dictConfigured + * dictEnabledSet + * dictTermsSort + * handlebarsRenderDynamic + * jpConvertReading + * jpDistributeFuriganaInflected + * jpKatakanaToHiragana + * optionsLoad + * optionsSave + * profileConditionsDescriptor + * requestJson + * requestText + * utilIsolate + */ class Backend { constructor() { diff --git a/ext/bg/js/clipboard-monitor.js b/ext/bg/js/clipboard-monitor.js index a6d73c79..9a881f57 100644 --- a/ext/bg/js/clipboard-monitor.js +++ b/ext/bg/js/clipboard-monitor.js @@ -16,7 +16,9 @@ * along with this program. If not, see . */ -/*global jpIsStringPartiallyJapanese*/ +/* global + * jpIsStringPartiallyJapanese + */ class ClipboardMonitor extends EventDispatcher { constructor({getClipboard}) { diff --git a/ext/bg/js/context.js b/ext/bg/js/context.js index 1095c7e0..c3e74656 100644 --- a/ext/bg/js/context.js +++ b/ext/bg/js/context.js @@ -16,7 +16,11 @@ * along with this program. If not, see . */ -/*global apiCommandExec, apiGetEnvironmentInfo, apiOptionsGet*/ +/* global + * apiCommandExec + * apiGetEnvironmentInfo + * apiOptionsGet + */ function showExtensionInfo() { const node = document.getElementById('extension-info'); diff --git a/ext/bg/js/database.js b/ext/bg/js/database.js index 558f3ceb..08a2a39f 100644 --- a/ext/bg/js/database.js +++ b/ext/bg/js/database.js @@ -16,7 +16,12 @@ * along with this program. If not, see . */ -/*global dictFieldSplit, requestJson, JsonSchema, JSZip*/ +/* global + * JSZip + * JsonSchema + * dictFieldSplit + * requestJson + */ class Database { constructor() { diff --git a/ext/bg/js/handlebars.js b/ext/bg/js/handlebars.js index 3ee4e7fa..e3ce6bd0 100644 --- a/ext/bg/js/handlebars.js +++ b/ext/bg/js/handlebars.js @@ -16,7 +16,11 @@ * along with this program. If not, see . */ -/*global jpIsCodePointKanji, jpDistributeFurigana, Handlebars*/ +/* global + * Handlebars + * jpDistributeFurigana + * jpIsCodePointKanji + */ function handlebarsEscape(text) { return Handlebars.Utils.escapeExpression(text); diff --git a/ext/bg/js/japanese.js b/ext/bg/js/japanese.js index fc69dbba..3b37754d 100644 --- a/ext/bg/js/japanese.js +++ b/ext/bg/js/japanese.js @@ -16,7 +16,9 @@ * along with this program. If not, see . */ -/*global wanakana*/ +/* global + * wanakana + */ const JP_HALFWIDTH_KATAKANA_MAPPING = new Map([ ['ヲ', 'ヲヺ-'], diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js index 879b4a59..bd0bbe0e 100644 --- a/ext/bg/js/options.js +++ b/ext/bg/js/options.js @@ -16,7 +16,9 @@ * along with this program. If not, see . */ -/*global utilStringHashCode*/ +/* global + * utilStringHashCode + */ /* * Generic options functions diff --git a/ext/bg/js/search-frontend.js b/ext/bg/js/search-frontend.js index 453a0b79..a470e873 100644 --- a/ext/bg/js/search-frontend.js +++ b/ext/bg/js/search-frontend.js @@ -16,7 +16,9 @@ * along with this program. If not, see . */ -/*global apiOptionsGet*/ +/* global + * apiOptionsGet + */ async function searchFrontendSetup() { await yomichan.prepare(); diff --git a/ext/bg/js/search-query-parser-generator.js b/ext/bg/js/search-query-parser-generator.js index 1ab23a82..664858a4 100644 --- a/ext/bg/js/search-query-parser-generator.js +++ b/ext/bg/js/search-query-parser-generator.js @@ -16,7 +16,10 @@ * along with this program. If not, see . */ -/*global apiGetQueryParserTemplatesHtml, TemplateHandler*/ +/* global + * TemplateHandler + * apiGetQueryParserTemplatesHtml + */ class QueryParserGenerator { constructor() { diff --git a/ext/bg/js/search-query-parser.js b/ext/bg/js/search-query-parser.js index c64d0fea..06316ce2 100644 --- a/ext/bg/js/search-query-parser.js +++ b/ext/bg/js/search-query-parser.js @@ -16,7 +16,15 @@ * along with this program. If not, see . */ -/*global apiTermsFind, apiOptionsSet, apiTextParse, apiTextParseMecab, TextScanner, QueryParserGenerator, docSentenceExtract*/ +/* global + * QueryParserGenerator + * TextScanner + * apiOptionsSet + * apiTermsFind + * apiTextParse + * apiTextParseMecab + * docSentenceExtract + */ class QueryParser extends TextScanner { constructor(search) { diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js index 5881f6f8..e2bdff73 100644 --- a/ext/bg/js/search.js +++ b/ext/bg/js/search.js @@ -16,7 +16,14 @@ * along with this program. If not, see . */ -/*global apiOptionsSet, apiTermsFind, apiClipboardGet, Display, QueryParser, ClipboardMonitor*/ +/* global + * ClipboardMonitor + * Display + * QueryParser + * apiClipboardGet + * apiOptionsSet + * apiTermsFind + */ class DisplaySearch extends Display { constructor() { diff --git a/ext/bg/js/settings/anki-templates.js b/ext/bg/js/settings/anki-templates.js index b1665048..c5222d30 100644 --- a/ext/bg/js/settings/anki-templates.js +++ b/ext/bg/js/settings/anki-templates.js @@ -16,10 +16,18 @@ * along with this program. If not, see . */ -/*global getOptionsContext, getOptionsMutable, settingsSaveOptions -ankiGetFieldMarkers, ankiGetFieldMarkersHtml -apiOptionsGet, apiTermsFind, apiGetDefaultAnkiFieldTemplates, apiTemplateRender -AnkiNoteBuilder*/ +/* global + * AnkiNoteBuilder + * ankiGetFieldMarkers + * ankiGetFieldMarkersHtml + * apiGetDefaultAnkiFieldTemplates + * apiOptionsGet + * apiTemplateRender + * apiTermsFind + * getOptionsContext + * getOptionsMutable + * settingsSaveOptions + */ function onAnkiFieldTemplatesReset(e) { e.preventDefault(); diff --git a/ext/bg/js/settings/anki.js b/ext/bg/js/settings/anki.js index 782691ab..b706cd1b 100644 --- a/ext/bg/js/settings/anki.js +++ b/ext/bg/js/settings/anki.js @@ -16,9 +16,16 @@ * along with this program. If not, see . */ -/*global getOptionsContext, getOptionsMutable, settingsSaveOptions -utilBackgroundIsolate, utilAnkiGetDeckNames, utilAnkiGetModelNames, utilAnkiGetModelFieldNames -onFormOptionsChanged*/ +/* global + * getOptionsContext + * getOptionsMutable + * onFormOptionsChanged + * settingsSaveOptions + * utilAnkiGetDeckNames + * utilAnkiGetModelFieldNames + * utilAnkiGetModelNames + * utilBackgroundIsolate + */ // Private diff --git a/ext/bg/js/settings/audio.js b/ext/bg/js/settings/audio.js index c825be6b..38dd6349 100644 --- a/ext/bg/js/settings/audio.js +++ b/ext/bg/js/settings/audio.js @@ -16,8 +16,14 @@ * along with this program. If not, see . */ -/*global getOptionsContext, getOptionsMutable, settingsSaveOptions, apiAudioGetUri -AudioSystem, AudioSourceUI*/ +/* global + * AudioSourceUI + * AudioSystem + * apiAudioGetUri + * getOptionsContext + * getOptionsMutable + * settingsSaveOptions + */ let audioSourceUI = null; let audioSystem = null; diff --git a/ext/bg/js/settings/backup.js b/ext/bg/js/settings/backup.js index daa08c61..21417dfb 100644 --- a/ext/bg/js/settings/backup.js +++ b/ext/bg/js/settings/backup.js @@ -16,9 +16,17 @@ * along with this program. If not, see . */ -/*global apiOptionsGetFull, apiGetEnvironmentInfo, apiGetDefaultAnkiFieldTemplates -utilBackend, utilIsolate, utilBackgroundIsolate, utilReadFileArrayBuffer -optionsGetDefault, optionsUpdateVersion*/ +/* global + * apiGetDefaultAnkiFieldTemplates + * apiGetEnvironmentInfo + * apiOptionsGetFull + * optionsGetDefault + * optionsUpdateVersion + * utilBackend + * utilBackgroundIsolate + * utilIsolate + * utilReadFileArrayBuffer + */ // Exporting diff --git a/ext/bg/js/settings/conditions-ui.js b/ext/bg/js/settings/conditions-ui.js index 4ca86b07..9d61d25e 100644 --- a/ext/bg/js/settings/conditions-ui.js +++ b/ext/bg/js/settings/conditions-ui.js @@ -16,7 +16,9 @@ * along with this program. If not, see . */ -/*global conditionsNormalizeOptionValue*/ +/* global + * conditionsNormalizeOptionValue + */ class ConditionsUI { static instantiateTemplate(templateSelector) { diff --git a/ext/bg/js/settings/dictionaries.js b/ext/bg/js/settings/dictionaries.js index b9551073..5e59cc3d 100644 --- a/ext/bg/js/settings/dictionaries.js +++ b/ext/bg/js/settings/dictionaries.js @@ -16,11 +16,23 @@ * along with this program. If not, see . */ -/*global getOptionsContext, getOptionsMutable, getOptionsFullMutable, settingsSaveOptions, apiOptionsGetFull, apiOptionsGet -utilBackgroundIsolate, utilDatabaseDeleteDictionary, utilDatabaseGetDictionaryInfo, utilDatabaseGetDictionaryCounts -utilDatabasePurge, utilDatabaseImport -storageUpdateStats, storageEstimate -PageExitPrevention*/ +/* global + * PageExitPrevention + * apiOptionsGet + * apiOptionsGetFull + * getOptionsContext + * getOptionsFullMutable + * getOptionsMutable + * settingsSaveOptions + * storageEstimate + * storageUpdateStats + * utilBackgroundIsolate + * utilDatabaseDeleteDictionary + * utilDatabaseGetDictionaryCounts + * utilDatabaseGetDictionaryInfo + * utilDatabaseImport + * utilDatabasePurge + */ let dictionaryUI = null; diff --git a/ext/bg/js/settings/main.js b/ext/bg/js/settings/main.js index 1bf1444c..ebc443df 100644 --- a/ext/bg/js/settings/main.js +++ b/ext/bg/js/settings/main.js @@ -16,13 +16,26 @@ * along with this program. If not, see . */ -/*global getOptionsContext, apiOptionsSave -utilBackend, utilIsolate, utilBackgroundIsolate -ankiErrorShown, ankiFieldsToDict -ankiTemplatesUpdateValue, onAnkiOptionsChanged, onDictionaryOptionsChanged -appearanceInitialize, audioSettingsInitialize, profileOptionsSetup, dictSettingsInitialize -ankiInitialize, ankiTemplatesInitialize, storageInfoInitialize, backupInitialize -*/ +/* global + * ankiErrorShown + * ankiFieldsToDict + * ankiInitialize + * ankiTemplatesInitialize + * ankiTemplatesUpdateValue + * apiOptionsSave + * appearanceInitialize + * audioSettingsInitialize + * backupInitialize + * dictSettingsInitialize + * getOptionsContext + * onAnkiOptionsChanged + * onDictionaryOptionsChanged + * profileOptionsSetup + * storageInfoInitialize + * utilBackend + * utilBackgroundIsolate + * utilIsolate + */ function getOptionsMutable(optionsContext) { return utilBackend().getOptions( diff --git a/ext/bg/js/settings/popup-preview-frame.js b/ext/bg/js/settings/popup-preview-frame.js index 1ceac177..6a149841 100644 --- a/ext/bg/js/settings/popup-preview-frame.js +++ b/ext/bg/js/settings/popup-preview-frame.js @@ -16,7 +16,13 @@ * along with this program. If not, see . */ -/*global apiOptionsGet, Popup, PopupProxyHost, Frontend, TextSourceRange*/ +/* global + * Frontend + * Popup + * PopupProxyHost + * TextSourceRange + * apiOptionsGet + */ class SettingsPopupPreview { constructor() { diff --git a/ext/bg/js/settings/profiles.js b/ext/bg/js/settings/profiles.js index f946a33a..b35b6309 100644 --- a/ext/bg/js/settings/profiles.js +++ b/ext/bg/js/settings/profiles.js @@ -16,9 +16,17 @@ * along with this program. If not, see . */ -/*global getOptionsMutable, getOptionsFullMutable, settingsSaveOptions, apiOptionsGetFull -utilBackgroundIsolate, formWrite -conditionsClearCaches, ConditionsUI, profileConditionsDescriptor*/ +/* global + * ConditionsUI + * apiOptionsGetFull + * conditionsClearCaches + * formWrite + * getOptionsFullMutable + * getOptionsMutable + * profileConditionsDescriptor + * settingsSaveOptions + * utilBackgroundIsolate + */ let currentProfileIndex = 0; let profileConditionsContainer = null; diff --git a/ext/bg/js/settings/storage.js b/ext/bg/js/settings/storage.js index 8978414e..ae305e22 100644 --- a/ext/bg/js/settings/storage.js +++ b/ext/bg/js/settings/storage.js @@ -16,7 +16,9 @@ * along with this program. If not, see . */ -/*global apiGetEnvironmentInfo*/ +/* global + * apiGetEnvironmentInfo + */ function storageBytesToLabeledString(size) { const base = 1000; diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js index c01a7124..25da9bf0 100644 --- a/ext/bg/js/translator.js +++ b/ext/bg/js/translator.js @@ -16,12 +16,28 @@ * along with this program. If not, see . */ -/*global requestJson -dictTermsMergeBySequence, dictTagBuildSource, dictTermsMergeByGloss, dictTermsSort, dictTagsSort -dictEnabledSet, dictTermsGroup, dictTermsCompressTags, dictTermsUndupe, dictTagSanitize -jpDistributeFurigana, jpConvertHalfWidthKanaToFullWidth, jpConvertNumericTofullWidth -jpConvertAlphabeticToKana, jpHiraganaToKatakana, jpKatakanaToHiragana, jpIsCodePointJapanese -Database, Deinflector*/ +/* global + * Database + * Deinflector + * dictEnabledSet + * dictTagBuildSource + * dictTagSanitize + * dictTagsSort + * dictTermsCompressTags + * dictTermsGroup + * dictTermsMergeByGloss + * dictTermsMergeBySequence + * dictTermsSort + * dictTermsUndupe + * jpConvertAlphabeticToKana + * jpConvertHalfWidthKanaToFullWidth + * jpConvertNumericTofullWidth + * jpDistributeFurigana + * jpHiraganaToKatakana + * jpIsCodePointJapanese + * jpKatakanaToHiragana + * requestJson + */ class Translator { constructor() { diff --git a/ext/fg/js/document.js b/ext/fg/js/document.js index 35861475..490f61bb 100644 --- a/ext/fg/js/document.js +++ b/ext/fg/js/document.js @@ -16,7 +16,11 @@ * along with this program. If not, see . */ -/*global TextSourceElement, TextSourceRange, DOM*/ +/* global + * DOM + * TextSourceElement + * TextSourceRange + */ const REGEX_TRANSPARENT_COLOR = /rgba\s*\([^)]*,\s*0(?:\.0+)?\s*\)/; diff --git a/ext/fg/js/float.js b/ext/fg/js/float.js index bc459d23..393c2719 100644 --- a/ext/fg/js/float.js +++ b/ext/fg/js/float.js @@ -16,7 +16,12 @@ * along with this program. If not, see . */ -/*global popupNestedInitialize, apiForward, apiGetMessageToken, Display*/ +/* global + * Display + * apiForward + * apiGetMessageToken + * popupNestedInitialize + */ class DisplayFloat extends Display { constructor() { diff --git a/ext/fg/js/frontend-initialize.js b/ext/fg/js/frontend-initialize.js index e674724e..8424b21d 100644 --- a/ext/fg/js/frontend-initialize.js +++ b/ext/fg/js/frontend-initialize.js @@ -16,7 +16,11 @@ * along with this program. If not, see . */ -/*global PopupProxyHost, PopupProxy, Frontend*/ +/* global + * Frontend + * PopupProxy + * PopupProxyHost + */ async function main() { await yomichan.prepare(); diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js index 929ab56a..768b9326 100644 --- a/ext/fg/js/frontend.js +++ b/ext/fg/js/frontend.js @@ -16,7 +16,14 @@ * along with this program. If not, see . */ -/*global apiGetZoom, apiOptionsGet, apiTermsFind, apiKanjiFind, docSentenceExtract, TextScanner*/ +/* global + * TextScanner + * apiGetZoom + * apiKanjiFind + * apiOptionsGet + * apiTermsFind + * docSentenceExtract + */ class Frontend extends TextScanner { constructor(popup, ignoreNodes) { diff --git a/ext/fg/js/popup-nested.js b/ext/fg/js/popup-nested.js index 3e5f5b80..06f8fc4b 100644 --- a/ext/fg/js/popup-nested.js +++ b/ext/fg/js/popup-nested.js @@ -16,7 +16,9 @@ * along with this program. If not, see . */ -/*global apiOptionsGet*/ +/* global + * apiOptionsGet + */ let popupNestedInitialized = false; diff --git a/ext/fg/js/popup-proxy-host.js b/ext/fg/js/popup-proxy-host.js index 49123ee1..793d3949 100644 --- a/ext/fg/js/popup-proxy-host.js +++ b/ext/fg/js/popup-proxy-host.js @@ -16,7 +16,11 @@ * along with this program. If not, see . */ -/*global apiFrameInformationGet, FrontendApiReceiver, Popup*/ +/* global + * FrontendApiReceiver + * Popup + * apiFrameInformationGet + */ class PopupProxyHost { constructor() { diff --git a/ext/fg/js/popup-proxy.js b/ext/fg/js/popup-proxy.js index 093cdd2e..f7cef214 100644 --- a/ext/fg/js/popup-proxy.js +++ b/ext/fg/js/popup-proxy.js @@ -16,7 +16,9 @@ * along with this program. If not, see . */ -/*global FrontendApiSender*/ +/* global + * FrontendApiSender + */ class PopupProxy { constructor(id, depth, parentId, parentFrameId, url) { diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js index bc40a8c4..d752812e 100644 --- a/ext/fg/js/popup.js +++ b/ext/fg/js/popup.js @@ -16,7 +16,10 @@ * along with this program. If not, see . */ -/*global apiInjectStylesheet, apiGetMessageToken*/ +/* global + * apiGetMessageToken + * apiInjectStylesheet + */ class Popup { constructor(id, depth, frameIdPromise) { diff --git a/ext/mixed/js/display-generator.js b/ext/mixed/js/display-generator.js index 470e2a15..49afc44b 100644 --- a/ext/mixed/js/display-generator.js +++ b/ext/mixed/js/display-generator.js @@ -16,7 +16,10 @@ * along with this program. If not, see . */ -/*global apiGetDisplayTemplatesHtml, TemplateHandler*/ +/* global + * TemplateHandler + * apiGetDisplayTemplatesHtml + */ class DisplayGenerator { constructor() { diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js index a220c1f7..515e28a7 100644 --- a/ext/mixed/js/display.js +++ b/ext/mixed/js/display.js @@ -16,10 +16,24 @@ * along with this program. If not, see . */ -/*global docRangeFromPoint, docSentenceExtract -apiKanjiFind, apiTermsFind, apiNoteView, apiOptionsGet, apiDefinitionsAddable, apiDefinitionAdd -apiScreenshotGet, apiForward, apiAudioGetUri -AudioSystem, DisplayGenerator, WindowScroll, DisplayContext, DOM*/ +/* global + * AudioSystem + * DOM + * DisplayContext + * DisplayGenerator + * WindowScroll + * apiAudioGetUri + * apiDefinitionAdd + * apiDefinitionsAddable + * apiForward + * apiKanjiFind + * apiNoteView + * apiOptionsGet + * apiScreenshotGet + * apiTermsFind + * docRangeFromPoint + * docSentenceExtract + */ class Display { constructor(spinner, container) { diff --git a/ext/mixed/js/text-scanner.js b/ext/mixed/js/text-scanner.js index ff0eac8b..a08e09fb 100644 --- a/ext/mixed/js/text-scanner.js +++ b/ext/mixed/js/text-scanner.js @@ -16,7 +16,11 @@ * along with this program. If not, see . */ -/*global docRangeFromPoint, TextSourceRange, DOM*/ +/* global + * DOM + * TextSourceRange + * docRangeFromPoint + */ class TextScanner { constructor(node, ignoreNodes, ignoreElements, ignorePoints) { -- cgit v1.2.3