From 02a34bb4bc81471934e54b5440a20585527d76f5 Mon Sep 17 00:00:00 2001 From: siikamiika Date: Thu, 5 Dec 2019 03:58:35 +0200 Subject: initial text scanner extract --- ext/mixed/js/text-scanner.js | 341 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 341 insertions(+) create mode 100644 ext/mixed/js/text-scanner.js (limited to 'ext/mixed') diff --git a/ext/mixed/js/text-scanner.js b/ext/mixed/js/text-scanner.js new file mode 100644 index 00000000..cf6e5397 --- /dev/null +++ b/ext/mixed/js/text-scanner.js @@ -0,0 +1,341 @@ +/* + * Copyright (C) 2019 Alex Yatskov + * Author: Alex Yatskov + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + + +class TextScanner { + constructor(node, ignoreNodes, popup, onTextSearch) { + this.node = node; + this.ignoreNodes = (Array.isArray(ignoreNodes) && ignoreNodes.length > 0 ? ignoreNodes.join(',') : null); + this.popup = popup; + this.onTextSearch = onTextSearch; + + this.popupTimerPromise = null; + this.textSourceCurrent = null; + this.pendingLookup = false; + this.options = null; + + this.enabled = false; + this.eventListeners = []; + + this.primaryTouchIdentifier = null; + this.preventNextContextMenu = false; + this.preventNextMouseDown = false; + this.preventNextClick = false; + this.preventScroll = false; + } + + onMouseOver(e) { + if (this.popup && e.target === this.popup.container) { + this.popupTimerClear(); + } + } + + onMouseMove(e) { + this.popupTimerClear(); + + if (this.pendingLookup || DOM.isMouseButtonDown(e, 'primary')) { + return; + } + + const scanningOptions = this.options.scanning; + const scanningModifier = scanningOptions.modifier; + if (!( + TextScanner.isScanningModifierPressed(scanningModifier, e) || + (scanningOptions.middleMouse && DOM.isMouseButtonDown(e, 'auxiliary')) + )) { + return; + } + + const search = async () => { + if (scanningModifier === 'none') { + if (!await this.popupTimerWait()) { + // Aborted + return; + } + } + + await this.searchAt(e.clientX, e.clientY, 'mouse'); + }; + + search(); + } + + onMouseDown(e) { + if (this.preventNextMouseDown) { + this.preventNextMouseDown = false; + this.preventNextClick = true; + e.preventDefault(); + e.stopPropagation(); + return false; + } + + if (DOM.isMouseButtonPressed(e, 'primary')) { + this.popupTimerClear(); + this.searchClear(); + } + } + + onMouseOut() { + this.popupTimerClear(); + } + + onClick(e) { + if (this.preventNextClick) { + this.preventNextClick = false; + e.preventDefault(); + e.stopPropagation(); + return false; + } + } + + onAuxClick() { + this.preventNextContextMenu = false; + } + + onContextMenu(e) { + if (this.preventNextContextMenu) { + this.preventNextContextMenu = false; + e.preventDefault(); + e.stopPropagation(); + return false; + } + } + + onTouchStart(e) { + if (this.primaryTouchIdentifier !== null || e.changedTouches.length === 0) { + return; + } + + this.preventScroll = false; + this.preventNextContextMenu = false; + this.preventNextMouseDown = false; + this.preventNextClick = false; + + const primaryTouch = e.changedTouches[0]; + if (DOM.isPointInSelection(primaryTouch.clientX, primaryTouch.clientY, this.node.getSelection())) { + return; + } + + this.primaryTouchIdentifier = primaryTouch.identifier; + + if (this.pendingLookup) { + return; + } + + const textSourceCurrentPrevious = this.textSourceCurrent !== null ? this.textSourceCurrent.clone() : null; + + this.searchAt(primaryTouch.clientX, primaryTouch.clientY, 'touchStart') + .then(() => { + if ( + this.textSourceCurrent === null || + this.textSourceCurrent.equals(textSourceCurrentPrevious) + ) { + return; + } + + this.preventScroll = true; + this.preventNextContextMenu = true; + this.preventNextMouseDown = true; + }); + } + + onTouchEnd(e) { + if ( + this.primaryTouchIdentifier === null || + TextScanner.getIndexOfTouch(e.changedTouches, this.primaryTouchIdentifier) < 0 + ) { + return; + } + + this.primaryTouchIdentifier = null; + this.preventScroll = false; + this.preventNextClick = false; + // Don't revert context menu and mouse down prevention, + // since these events can occur after the touch has ended. + // this.preventNextContextMenu = false; + // this.preventNextMouseDown = false; + } + + onTouchCancel(e) { + this.onTouchEnd(e); + } + + onTouchMove(e) { + if (!this.preventScroll || !e.cancelable || this.primaryTouchIdentifier === null) { + return; + } + + const touches = e.changedTouches; + const index = TextScanner.getIndexOfTouch(touches, this.primaryTouchIdentifier); + if (index < 0) { + return; + } + + const primaryTouch = touches[index]; + this.searchAt(primaryTouch.clientX, primaryTouch.clientY, 'touchMove'); + + e.preventDefault(); // Disable scroll + } + + async popupTimerWait() { + const delay = this.options.scanning.delay; + const promise = promiseTimeout(delay, true); + this.popupTimerPromise = promise; + try { + return await promise; + } finally { + if (this.popupTimerPromise === promise) { + this.popupTimerPromise = null; + } + } + } + + popupTimerClear() { + if (this.popupTimerPromise !== null) { + this.popupTimerPromise.resolve(false); + this.popupTimerPromise = null; + } + } + + setEnabled(enabled) { + if (enabled) { + if (!this.enabled) { + this.hookEvents(); + this.enabled = true; + } + } else { + if (this.enabled) { + this.clearEventListeners(); + this.enabled = false; + } + this.searchClear(); + } + } + + hookEvents() { + this.addEventListener('mousedown', this.onMouseDown.bind(this)); + this.addEventListener('mousemove', this.onMouseMove.bind(this)); + this.addEventListener('mouseover', this.onMouseOver.bind(this)); + this.addEventListener('mouseout', this.onMouseOut.bind(this)); + + if (this.options.scanning.touchInputEnabled) { + this.addEventListener('click', this.onClick.bind(this)); + this.addEventListener('auxclick', this.onAuxClick.bind(this)); + this.addEventListener('touchstart', this.onTouchStart.bind(this)); + this.addEventListener('touchend', this.onTouchEnd.bind(this)); + this.addEventListener('touchcancel', this.onTouchCancel.bind(this)); + this.addEventListener('touchmove', this.onTouchMove.bind(this), {passive: false}); + this.addEventListener('contextmenu', this.onContextMenu.bind(this)); + } + } + + addEventListener(type, listener, options) { + this.node.addEventListener(type, listener, options); + this.eventListeners.push([type, listener, options]); + } + + clearEventListeners() { + for (const [type, listener, options] of this.eventListeners) { + this.node.removeEventListener(type, listener, options); + } + this.eventListeners = []; + } + + setOptions(options) { + this.options = options; + } + + async searchAt(x, y, cause) { + try { + this.popupTimerClear(); + + if (this.pendingLookup || (this.popup && await this.popup.containsPoint(x, y))) { + return; + } + + const textSource = docRangeFromPoint(x, y, this.options); + if (this.textSourceCurrent !== null && this.textSourceCurrent.equals(textSource)) { + return; + } + + try { + await this.onTextSearch(textSource, cause); + } finally { + if (textSource !== null) { + textSource.cleanup(); + } + } + } catch (e) { + this.onError(e); + } + } + + setTextSourceScanLength(textSource, length) { + textSource.setEndOffset(length); + if (this.ignoreNodes === null || !textSource.range) { + return; + } + + length = textSource.text().length; + while (textSource.range && length > 0) { + const nodes = TextSourceRange.getNodesInRange(textSource.range); + if (!TextSourceRange.anyNodeMatchesSelector(nodes, this.ignoreNodes)) { + break; + } + --length; + textSource.setEndOffset(length); + } + } + + searchClear() { + if (this.textSourceCurrent !== null) { + if (this.options.scanning.selectText) { + this.textSourceCurrent.deselect(); + } + this.textSourceCurrent = null; + } + } + + getCurrentTextSource() { + return this.textSourceCurrent; + } + + setCurrentTextSource(textSource) { + return this.textSourceCurrent = textSource; + } + + static isScanningModifierPressed(scanningModifier, mouseEvent) { + switch (scanningModifier) { + case 'alt': return mouseEvent.altKey; + case 'ctrl': return mouseEvent.ctrlKey; + case 'shift': return mouseEvent.shiftKey; + case 'none': return true; + default: return false; + } + } + + static getIndexOfTouch(touchList, identifier) { + for (const i in touchList) { + const t = touchList[i]; + if (t.identifier === identifier) { + return i; + } + } + return -1; + } +} -- cgit v1.2.3 From e5be42d3de14be48c6ef4ef47d06ba130d16fcaf Mon Sep 17 00:00:00 2001 From: siikamiika Date: Thu, 5 Dec 2019 22:12:43 +0200 Subject: scan decoupling --- ext/fg/js/frontend.js | 13 ++++--- ext/mixed/js/text-scanner.js | 88 ++++++++++++++++++++++++++++++++------------ 2 files changed, 73 insertions(+), 28 deletions(-) (limited to 'ext/mixed') diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js index 43a4830f..2adbde36 100644 --- a/ext/fg/js/frontend.js +++ b/ext/fg/js/frontend.js @@ -20,7 +20,14 @@ class Frontend { constructor(popup, ignoreNodes) { this.popup = popup; - this.textScanner = new TextScanner(window, ignoreNodes, this.popup, this.searchSource.bind(this)); + this.textScanner = new TextScanner( + window, + ignoreNodes, + [this.popup.container], + [(x, y) => this.popup.containsPoint(x, y)] + ); + this.textScanner.subscribe('textSearch', ({textSource, cause}) => this.searchSource(textSource, cause)); + this.textScanner.subscribe('searchClear', () => this.searchClear(true)); this.options = null; this.optionsContext = { @@ -138,7 +145,6 @@ class Frontend { let results = null; try { - this.textScanner.pendingLookup = true; if (textSource !== null) { results = ( await this.findTerms(textSource) || @@ -165,8 +171,6 @@ class Frontend { if (results === null && this.options.scanning.autoHideResults) { this.searchClear(true); } - - this.textScanner.pendingLookup = false; } return results; @@ -182,7 +186,6 @@ class Frontend { {definitions, context: {sentence, url, focus, disableHistory: true}} ); - this.textScanner.setCurrentTextSource(textSource); if (this.options.scanning.selectText) { textSource.select(); } diff --git a/ext/mixed/js/text-scanner.js b/ext/mixed/js/text-scanner.js index cf6e5397..fc57d6c3 100644 --- a/ext/mixed/js/text-scanner.js +++ b/ext/mixed/js/text-scanner.js @@ -18,19 +18,23 @@ class TextScanner { - constructor(node, ignoreNodes, popup, onTextSearch) { + constructor(node, ignoreNodes, ignoreElements, ignorePoints) { this.node = node; this.ignoreNodes = (Array.isArray(ignoreNodes) && ignoreNodes.length > 0 ? ignoreNodes.join(',') : null); - this.popup = popup; - this.onTextSearch = onTextSearch; + this.ignoreElements = ignoreElements; + this.ignorePoints = ignorePoints; - this.popupTimerPromise = null; + this.scanTimerPromise = null; this.textSourceCurrent = null; this.pendingLookup = false; this.options = null; this.enabled = false; this.eventListeners = []; + this.subscribers = { + searchClear: [], + textSearch: [] + }; this.primaryTouchIdentifier = null; this.preventNextContextMenu = false; @@ -40,13 +44,13 @@ class TextScanner { } onMouseOver(e) { - if (this.popup && e.target === this.popup.container) { - this.popupTimerClear(); + if (this.ignoreElements.includes(e.target)) { + this.scanTimerClear(); } } onMouseMove(e) { - this.popupTimerClear(); + this.scanTimerClear(); if (this.pendingLookup || DOM.isMouseButtonDown(e, 'primary')) { return; @@ -63,7 +67,7 @@ class TextScanner { const search = async () => { if (scanningModifier === 'none') { - if (!await this.popupTimerWait()) { + if (!await this.scanTimerWait()) { // Aborted return; } @@ -84,14 +88,14 @@ class TextScanner { return false; } - if (DOM.isMouseButtonPressed(e, 'primary')) { - this.popupTimerClear(); - this.searchClear(); + if (DOM.isMouseButtonDown(e, 'primary')) { + this.scanTimerClear(); + this.onSearchClear(); } } onMouseOut() { - this.popupTimerClear(); + this.scanTimerClear(); } onClick(e) { @@ -192,23 +196,55 @@ class TextScanner { e.preventDefault(); // Disable scroll } - async popupTimerWait() { + async onSearchClear() { + this.searchClear(); + await this.publish('searchClear', {}); + } + + async onTextSearch(textSource, cause) { + this.pendingLookup = true; + const results = await this.publish('textSearch', {textSource, cause}); + if (results.some((r) => r)) { + this.textSourceCurrent = textSource; + } + this.pendingLookup = false; + } + + onError(error) { + logError(error, false); + } + + subscribe(eventName, subscriber) { + if (this.subscribers[eventName].includes(subscriber)) { return; } + this.subscribers[eventName].push(subscriber); + } + + async publish(eventName, data) { + const results = []; + for (const subscriber of this.subscribers[eventName]) { + const result = await subscriber(data); + results.push(result); + } + return results; + } + + async scanTimerWait() { const delay = this.options.scanning.delay; const promise = promiseTimeout(delay, true); - this.popupTimerPromise = promise; + this.scanTimerPromise = promise; try { return await promise; } finally { - if (this.popupTimerPromise === promise) { - this.popupTimerPromise = null; + if (this.scanTimerPromise === promise) { + this.scanTimerPromise = null; } } } - popupTimerClear() { - if (this.popupTimerPromise !== null) { - this.popupTimerPromise.resolve(false); - this.popupTimerPromise = null; + scanTimerClear() { + if (this.scanTimerPromise !== null) { + this.scanTimerPromise.resolve(false); + this.scanTimerPromise = null; } } @@ -223,7 +259,7 @@ class TextScanner { this.clearEventListeners(); this.enabled = false; } - this.searchClear(); + this.onSearchClear(); } } @@ -262,12 +298,18 @@ class TextScanner { async searchAt(x, y, cause) { try { - this.popupTimerClear(); + this.scanTimerClear(); - if (this.pendingLookup || (this.popup && await this.popup.containsPoint(x, y))) { + if (this.pendingLookup) { return; } + for (const ignorePointFn of this.ignorePoints) { + if (await ignorePointFn(x, y)) { + return; + } + } + const textSource = docRangeFromPoint(x, y, this.options); if (this.textSourceCurrent !== null && this.textSourceCurrent.equals(textSource)) { return; -- cgit v1.2.3 From 595636c40bdc344ee34fee55c951e62ba0a24505 Mon Sep 17 00:00:00 2001 From: siikamiika Date: Thu, 5 Dec 2019 22:48:05 +0200 Subject: move text selection to TextScanner --- ext/fg/js/frontend.js | 4 ---- ext/mixed/js/text-scanner.js | 3 +++ 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'ext/mixed') diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js index 2adbde36..9ec66fb1 100644 --- a/ext/fg/js/frontend.js +++ b/ext/fg/js/frontend.js @@ -185,10 +185,6 @@ class Frontend { type, {definitions, context: {sentence, url, focus, disableHistory: true}} ); - - if (this.options.scanning.selectText) { - textSource.select(); - } } async findTerms(textSource) { diff --git a/ext/mixed/js/text-scanner.js b/ext/mixed/js/text-scanner.js index fc57d6c3..0adcc0bd 100644 --- a/ext/mixed/js/text-scanner.js +++ b/ext/mixed/js/text-scanner.js @@ -206,6 +206,9 @@ class TextScanner { const results = await this.publish('textSearch', {textSource, cause}); if (results.some((r) => r)) { this.textSourceCurrent = textSource; + if (this.options.scanning.selectText) { + textSource.select(); + } } this.pendingLookup = false; } -- cgit v1.2.3 From f6d0503604e66ef89578332f6adb477606dc81f9 Mon Sep 17 00:00:00 2001 From: siikamiika Date: Fri, 6 Dec 2019 21:39:29 +0200 Subject: simplify with inheritance --- ext/fg/js/frontend.js | 72 ++++++++----------------------- ext/mixed/js/text-scanner.js | 100 ++++++++++++++++++++----------------------- 2 files changed, 65 insertions(+), 107 deletions(-) (limited to 'ext/mixed') diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js index 9ec66fb1..01f5c13d 100644 --- a/ext/fg/js/frontend.js +++ b/ext/fg/js/frontend.js @@ -17,17 +17,16 @@ */ -class Frontend { +class Frontend extends TextScanner { constructor(popup, ignoreNodes) { - this.popup = popup; - this.textScanner = new TextScanner( + super( window, ignoreNodes, - [this.popup.container], + [popup.container], [(x, y) => this.popup.containsPoint(x, y)] ); - this.textScanner.subscribe('textSearch', ({textSource, cause}) => this.searchSource(textSource, cause)); - this.textScanner.subscribe('searchClear', () => this.searchClear(true)); + + this.popup = popup; this.options = null; this.optionsContext = { @@ -35,9 +34,6 @@ class Frontend { url: popup.url }; - this.enabled = false; - this.eventListeners = []; - this.isPreparedPromiseResolve = null; this.isPreparedPromise = new Promise((resolve) => { this.isPreparedPromiseResolve = resolve; }); @@ -70,7 +66,7 @@ class Frontend { } async onResize() { - const textSource = this.textScanner.getCurrentTextSource(); + const textSource = this.textSourceCurrent; if (textSource !== null && await this.popup.isVisibleAsync()) { this.lastShowPromise = this.popup.showContent( textSource.getRect(), @@ -97,51 +93,21 @@ class Frontend { } } - onError(error) { - logError(error, false); - } - - setEnabled(enabled) { - this.textScanner.setEnabled(enabled); - if (enabled) { - if (!this.enabled) { - this.hookEvents(); - this.enabled = true; - } - } else { - if (this.enabled) { - this.clearEventListeners(); - this.enabled = false; - } - this.searchClear(false); - } - } - - hookEvents() { - this.addEventListener(window, 'message', this.onWindowMessage.bind(this)); - this.addEventListener(window, 'resize', this.onResize.bind(this)); - } - - addEventListener(node, type, listener, options) { - node.addEventListener(type, listener, options); - this.eventListeners.push([node, type, listener, options]); - } - - clearEventListeners() { - for (const [node, type, listener, options] of this.eventListeners) { - node.removeEventListener(type, listener, options); - } - this.eventListeners = []; + getMouseEventListeners() { + return [ + ...super.getMouseEventListeners(), + [window, 'message', this.onWindowMessage.bind(this)], + [window, 'resize', this.onResize.bind(this)] + ]; } async updateOptions() { this.options = await apiOptionsGet(this.getOptionsContext()); - this.textScanner.setOptions(this.options); await this.popup.setOptions(this.options); this.setEnabled(this.options.general.enable); } - async searchSource(textSource, cause) { + async onSearchSource(textSource, cause) { let results = null; try { @@ -169,7 +135,7 @@ class Frontend { } } finally { if (results === null && this.options.scanning.autoHideResults) { - this.searchClear(true); + this.onSearchClear(true); } } @@ -188,7 +154,7 @@ class Frontend { } async findTerms(textSource) { - this.textScanner.setTextSourceScanLength(textSource, this.options.scanning.length); + this.setTextSourceScanLength(textSource, this.options.scanning.length); const searchText = textSource.text(); if (searchText.length === 0) { return null; } @@ -202,7 +168,7 @@ class Frontend { } async findKanji(textSource) { - this.textScanner.setTextSourceScanLength(textSource, 1); + this.setTextSourceScanLength(textSource, 1); const searchText = textSource.text(); if (searchText.length === 0) { return null; } @@ -213,10 +179,10 @@ class Frontend { return {definitions, type: 'kanji'}; } - searchClear(changeFocus) { + onSearchClear(changeFocus) { this.popup.hide(changeFocus); this.popup.clearAutoPlayTimer(); - this.textScanner.searchClear(); + super.onSearchClear(changeFocus); } getOptionsContext() { @@ -227,7 +193,7 @@ class Frontend { Frontend.windowMessageHandlers = { popupClose: (self) => { - self.searchClear(true); + self.onSearchClear(true); }, selectionCopy: () => { diff --git a/ext/mixed/js/text-scanner.js b/ext/mixed/js/text-scanner.js index 0adcc0bd..ac5d68d1 100644 --- a/ext/mixed/js/text-scanner.js +++ b/ext/mixed/js/text-scanner.js @@ -31,10 +31,6 @@ class TextScanner { this.enabled = false; this.eventListeners = []; - this.subscribers = { - searchClear: [], - textSearch: [] - }; this.primaryTouchIdentifier = null; this.preventNextContextMenu = false; @@ -90,7 +86,7 @@ class TextScanner { if (DOM.isMouseButtonDown(e, 'primary')) { this.scanTimerClear(); - this.onSearchClear(); + this.onSearchClear(true); } } @@ -196,41 +192,14 @@ class TextScanner { e.preventDefault(); // Disable scroll } - async onSearchClear() { - this.searchClear(); - await this.publish('searchClear', {}); - } - - async onTextSearch(textSource, cause) { - this.pendingLookup = true; - const results = await this.publish('textSearch', {textSource, cause}); - if (results.some((r) => r)) { - this.textSourceCurrent = textSource; - if (this.options.scanning.selectText) { - textSource.select(); - } - } - this.pendingLookup = false; + async onSearchSource(_textSource, _cause) { + throw new Error('Override me'); } onError(error) { logError(error, false); } - subscribe(eventName, subscriber) { - if (this.subscribers[eventName].includes(subscriber)) { return; } - this.subscribers[eventName].push(subscriber); - } - - async publish(eventName, data) { - const results = []; - for (const subscriber of this.subscribers[eventName]) { - const result = await subscriber(data); - results.push(result); - } - return results; - } - async scanTimerWait() { const delay = this.options.scanning.delay; const promise = promiseTimeout(delay, true); @@ -262,35 +231,50 @@ class TextScanner { this.clearEventListeners(); this.enabled = false; } - this.onSearchClear(); + this.onSearchClear(false); } } hookEvents() { - this.addEventListener('mousedown', this.onMouseDown.bind(this)); - this.addEventListener('mousemove', this.onMouseMove.bind(this)); - this.addEventListener('mouseover', this.onMouseOver.bind(this)); - this.addEventListener('mouseout', this.onMouseOut.bind(this)); - + let eventListeners = this.getMouseEventListeners(); if (this.options.scanning.touchInputEnabled) { - this.addEventListener('click', this.onClick.bind(this)); - this.addEventListener('auxclick', this.onAuxClick.bind(this)); - this.addEventListener('touchstart', this.onTouchStart.bind(this)); - this.addEventListener('touchend', this.onTouchEnd.bind(this)); - this.addEventListener('touchcancel', this.onTouchCancel.bind(this)); - this.addEventListener('touchmove', this.onTouchMove.bind(this), {passive: false}); - this.addEventListener('contextmenu', this.onContextMenu.bind(this)); + eventListeners = eventListeners.concat(this.getTouchEventListeners()); + } + + for (const [node, type, listener, options] of eventListeners) { + this.addEventListener(node, type, listener, options); } } - addEventListener(type, listener, options) { - this.node.addEventListener(type, listener, options); - this.eventListeners.push([type, listener, options]); + getMouseEventListeners() { + return [ + [this.node, 'mousedown', this.onMouseDown.bind(this)], + [this.node, 'mousemove', this.onMouseMove.bind(this)], + [this.node, 'mouseover', this.onMouseOver.bind(this)], + [this.node, 'mouseout', this.onMouseOut.bind(this)] + ]; + } + + getTouchEventListeners() { + return [ + [this.node, 'click', this.onClick.bind(this)], + [this.node, 'auxclick', this.onAuxClick.bind(this)], + [this.node, 'touchstart', this.onTouchStart.bind(this)], + [this.node, 'touchend', this.onTouchEnd.bind(this)], + [this.node, 'touchcancel', this.onTouchCancel.bind(this)], + [this.node, 'touchmove', this.onTouchMove.bind(this), {passive: false}], + [this.node, 'contextmenu', this.onContextMenu.bind(this)] + ]; + } + + addEventListener(node, type, listener, options) { + node.addEventListener(type, listener, options); + this.eventListeners.push([node, type, listener, options]); } clearEventListeners() { - for (const [type, listener, options] of this.eventListeners) { - this.node.removeEventListener(type, listener, options); + for (const [node, type, listener, options] of this.eventListeners) { + node.removeEventListener(type, listener, options); } this.eventListeners = []; } @@ -319,7 +303,15 @@ class TextScanner { } try { - await this.onTextSearch(textSource, cause); + this.pendingLookup = true; + const result = await this.onSearchSource(textSource, cause); + if (result !== null) { + this.textSourceCurrent = textSource; + if (this.options.scanning.selectText) { + textSource.select(); + } + } + this.pendingLookup = false; } finally { if (textSource !== null) { textSource.cleanup(); @@ -347,7 +339,7 @@ class TextScanner { } } - searchClear() { + onSearchClear(_) { if (this.textSourceCurrent !== null) { if (this.options.scanning.selectText) { this.textSourceCurrent.deselect(); -- cgit v1.2.3 From e99c8c40a1b87e307d5365fe619fa1a71996b500 Mon Sep 17 00:00:00 2001 From: siikamiika Date: Sat, 7 Dec 2019 17:41:14 +0200 Subject: navigate history with wheel only over buttons --- ext/mixed/js/display.js | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'ext/mixed') diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js index 7d5e4e7d..6e2c8e6a 100644 --- a/ext/mixed/js/display.js +++ b/ext/mixed/js/display.js @@ -211,14 +211,18 @@ class Display { e.preventDefault(); } } else if (e.shiftKey) { - const delta = -e.deltaX || e.deltaY; - if (delta > 0) { - this.sourceTermView(); - e.preventDefault(); - } else if (delta < 0) { - this.nextTermView(); - e.preventDefault(); - } + this.onHistoryWheel(e); + } + } + + onHistoryWheel(e) { + const delta = -e.deltaX || e.deltaY; + if (delta > 0) { + this.sourceTermView(); + e.preventDefault(); + } else if (delta < 0) { + this.nextTermView(); + e.preventDefault(); } } @@ -301,6 +305,7 @@ class Display { this.addEventListeners('.kanji-link', 'click', this.onKanjiLookup.bind(this)); this.addEventListeners('.source-term', 'click', this.onSourceTermView.bind(this)); this.addEventListeners('.next-term', 'click', this.onNextTermView.bind(this)); + this.addEventListeners('.term-navigation', 'wheel', this.onHistoryWheel.bind(this), {passive: false}); if (this.options.scanning.enablePopupSearch) { this.addEventListeners('.glossary-item', 'mouseup', this.onGlossaryMouseUp.bind(this)); this.addEventListeners('.glossary-item', 'mousedown', this.onGlossaryMouseDown.bind(this)); -- cgit v1.2.3 From 20679255b070eb4569107e6e107ec1a1e7c1ab3c Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Wed, 27 Nov 2019 12:00:42 -0500 Subject: Add class for dispatching custom events --- ext/mixed/js/core.js | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'ext/mixed') diff --git a/ext/mixed/js/core.js b/ext/mixed/js/core.js index b5911535..f0c04457 100644 --- a/ext/mixed/js/core.js +++ b/ext/mixed/js/core.js @@ -175,3 +175,49 @@ function stringReplaceAsync(str, regex, replacer) { parts.push(str.substring(index)); return Promise.all(parts).then((v) => v.join('')); } + + +/* + * Common events + */ + +class EventDispatcher { + constructor() { + this._eventMap = new Map(); + } + + trigger(eventName, details) { + const callbacks = this._eventMap.get(eventName); + if (typeof callbacks === 'undefined') { return false; } + + for (const callback of callbacks) { + callback(details); + } + } + + on(eventName, callback) { + let callbacks = this._eventMap.get(eventName); + if (typeof callbacks === 'undefined') { + callbacks = []; + this._eventMap.set(eventName, callbacks); + } + callbacks.push(callback); + } + + off(eventName, callback) { + const callbacks = this._eventMap.get(eventName); + if (typeof callbacks === 'undefined') { return true; } + + const ii = callbacks.length; + for (let i = 0; i < ii; ++i) { + if (callbacks[i] === callback) { + callbacks.splice(i, 1); + if (callbacks.length === 0) { + this._eventMap.delete(eventName); + } + return true; + } + } + return false; + } +} -- cgit v1.2.3 From 16593408981d59e1bd3ad4de14071f45a8116d81 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 23 Nov 2019 21:48:24 -0500 Subject: Add support for prefix wildcards --- ext/bg/js/database.js | 30 +++++++++++++++++++++++------- ext/bg/js/search.js | 10 +++++++--- ext/bg/js/translator.js | 8 ++++---- ext/mixed/js/core.js | 4 ++++ 4 files changed, 38 insertions(+), 14 deletions(-) (limited to 'ext/mixed') diff --git a/ext/bg/js/database.js b/ext/bg/js/database.js index a20d5f15..2d309f85 100644 --- a/ext/bg/js/database.js +++ b/ext/bg/js/database.js @@ -28,7 +28,7 @@ class Database { } try { - this.db = await Database.open('dict', 4, (db, transaction, oldVersion) => { + this.db = await Database.open('dict', 5, (db, transaction, oldVersion) => { Database.upgrade(db, transaction, oldVersion, [ { version: 2, @@ -76,6 +76,15 @@ class Database { indices: ['dictionary', 'expression', 'reading', 'sequence'] } } + }, + { + version: 5, + stores: { + terms: { + primaryKey: {keyPath: 'id', autoIncrement: true}, + indices: ['dictionary', 'expression', 'reading', 'sequence', 'expressionReverse', 'readingReverse'] + } + } } ]); }); @@ -143,14 +152,17 @@ class Database { } }; + const useWildcard = !!wildcard; + const prefixWildcard = wildcard === 'prefix'; + const dbTransaction = this.db.transaction(['terms'], 'readonly'); const dbTerms = dbTransaction.objectStore('terms'); - const dbIndex1 = dbTerms.index('expression'); - const dbIndex2 = dbTerms.index('reading'); + const dbIndex1 = dbTerms.index(prefixWildcard ? 'expressionReverse' : 'expression'); + const dbIndex2 = dbTerms.index(prefixWildcard ? 'readingReverse' : 'reading'); for (let i = 0; i < termList.length; ++i) { - const term = termList[i]; - const query = wildcard ? IDBKeyRange.bound(term, `${term}\uffff`, false, false) : IDBKeyRange.only(term); + const term = prefixWildcard ? stringReverse(termList[i]) : termList[i]; + const query = useWildcard ? IDBKeyRange.bound(term, `${term}\uffff`, false, false) : IDBKeyRange.only(term); promises.push( Database.getAll(dbIndex1, query, i, processRow), Database.getAll(dbIndex2, query, i, processRow) @@ -377,7 +389,9 @@ class Database { rules, score, glossary, - dictionary: summary.title + dictionary: summary.title, + expressionReverse: stringReverse(expression), + readingReverse: stringReverse(reading) }); } } else { @@ -391,7 +405,9 @@ class Database { glossary, sequence, termTags, - dictionary: summary.title + dictionary: summary.title, + expressionReverse: stringReverse(expression), + readingReverse: stringReverse(reading) }); } } diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js index d2e0fd56..67a78075 100644 --- a/ext/bg/js/search.js +++ b/ext/bg/js/search.js @@ -207,10 +207,14 @@ class DisplaySearch extends Display { async onSearchQueryUpdated(query, animate) { try { const details = {}; - const match = /[*\uff0a]+$/.exec(query); + const match = /^([*\uff0a]*)([\w\W]*?)([*\uff0a]*)$/.exec(query); if (match !== null) { - details.wildcard = true; - query = query.substring(0, query.length - match[0].length); + if (match[1]) { + details.wildcard = 'prefix'; + } else if (match[3]) { + details.wildcard = 'suffix'; + } + query = match[2]; } const valid = (query.length > 0); diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js index 202014c9..0f3d0aa0 100644 --- a/ext/bg/js/translator.js +++ b/ext/bg/js/translator.js @@ -230,7 +230,7 @@ class Translator { const titles = Object.keys(dictionaries); const deinflections = ( details.wildcard ? - await this.findTermWildcard(text, titles) : + await this.findTermWildcard(text, titles, details.wildcard) : await this.findTermDeinflections(text, titles) ); @@ -268,8 +268,8 @@ class Translator { return [definitions, length]; } - async findTermWildcard(text, titles) { - const definitions = await this.database.findTermsBulk([text], titles, true); + async findTermWildcard(text, titles, wildcard) { + const definitions = await this.database.findTermsBulk([text], titles, wildcard); if (definitions.length === 0) { return []; } @@ -308,7 +308,7 @@ class Translator { deinflectionArray.push(deinflection); } - const definitions = await this.database.findTermsBulk(uniqueDeinflectionTerms, titles, false); + const definitions = await this.database.findTermsBulk(uniqueDeinflectionTerms, titles, null); for (const definition of definitions) { const definitionRules = Deinflector.rulesToRuleFlags(definition.rules); diff --git a/ext/mixed/js/core.js b/ext/mixed/js/core.js index f0c04457..b9536391 100644 --- a/ext/mixed/js/core.js +++ b/ext/mixed/js/core.js @@ -118,6 +118,10 @@ function toIterable(value) { throw new Error('Could not convert to iterable'); } +function stringReverse(string) { + return string.split('').reverse().join('').replace(/([\uDC00-\uDFFF])([\uD800-\uDBFF])/g, '$2$1'); +} + /* * Async utilities -- cgit v1.2.3 From f23771d9236df540cdc645bb577863ace4ca0bac Mon Sep 17 00:00:00 2001 From: siikamiika Date: Sun, 8 Dec 2019 12:00:24 +0200 Subject: move term navigation to top right --- ext/mixed/css/display.css | 1 + 1 file changed, 1 insertion(+) (limited to 'ext/mixed') diff --git a/ext/mixed/css/display.css b/ext/mixed/css/display.css index 9152216f..195acadf 100644 --- a/ext/mixed/css/display.css +++ b/ext/mixed/css/display.css @@ -79,6 +79,7 @@ ol, ul { .term-navigation { position: fixed; top: 0px; + right: 0px; } .term-button-fade { -- cgit v1.2.3 From 3c749f87053fea88221453f4a6fe4f194726bb6e Mon Sep 17 00:00:00 2001 From: siikamiika Date: Sun, 8 Dec 2019 22:59:36 +0200 Subject: hide inactive history buttons instead of fading --- ext/bg/js/templates.js | 8 ++++---- ext/mixed/css/display.css | 4 ---- tmpl/kanji.html | 4 ++-- tmpl/terms.html | 4 ++-- 4 files changed, 8 insertions(+), 12 deletions(-) (limited to 'ext/mixed') diff --git a/ext/bg/js/templates.js b/ext/bg/js/templates.js index 9320477f..eae4e014 100644 --- a/ext/bg/js/templates.js +++ b/ext/bg/js/templates.js @@ -143,11 +143,11 @@ templates['kanji.html'] = template({"1":function(container,depth0,helpers,partia },"33":function(container,depth0,helpers,partials,data) { return "class=\"source-term\""; },"35":function(container,depth0,helpers,partials,data) { - return "class=\"source-term term-button-fade\""; + return "class=\"source-term invisible\""; },"37":function(container,depth0,helpers,partials,data) { return "class=\"next-term\""; },"39":function(container,depth0,helpers,partials,data) { - return "class=\"next-term term-button-fade\""; + return "class=\"next-term invisible\""; },"41":function(container,depth0,helpers,partials,data,blockParams,depths) { var stack1; @@ -491,11 +491,11 @@ templates['terms.html'] = template({"1":function(container,depth0,helpers,partia },"67":function(container,depth0,helpers,partials,data) { return "class=\"source-term\""; },"69":function(container,depth0,helpers,partials,data) { - return "class=\"source-term term-button-fade\""; + return "class=\"source-term invisible\""; },"71":function(container,depth0,helpers,partials,data) { return "class=\"next-term\""; },"73":function(container,depth0,helpers,partials,data) { - return "class=\"next-term term-button-fade\""; + return "class=\"next-term invisible\""; },"75":function(container,depth0,helpers,partials,data,blockParams,depths) { var stack1; diff --git a/ext/mixed/css/display.css b/ext/mixed/css/display.css index 195acadf..70fffdc1 100644 --- a/ext/mixed/css/display.css +++ b/ext/mixed/css/display.css @@ -82,10 +82,6 @@ ol, ul { right: 0px; } -.term-button-fade { - opacity: 0.4; -} - /* * Search page diff --git a/tmpl/kanji.html b/tmpl/kanji.html index bbc0fc9d..d205cda5 100644 --- a/tmpl/kanji.html +++ b/tmpl/kanji.html @@ -89,8 +89,8 @@ No data found {{#if definitions}}
- - + +
{{#each definitions}} {{#unless @first}}
{{/unless}} diff --git a/tmpl/terms.html b/tmpl/terms.html index 9cfabc58..d0c142d9 100644 --- a/tmpl/terms.html +++ b/tmpl/terms.html @@ -127,8 +127,8 @@ {{#if definitions}}
- - + +
{{#each definitions}} {{#unless @first}}
{{/unless}} -- cgit v1.2.3 From bb334acab65ae194d749ac2da5bd1ba6b02413ec Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 8 Dec 2019 15:13:22 -0500 Subject: Use substring instead of slice --- ext/bg/js/api.js | 8 ++++---- ext/bg/js/search-query-parser.js | 7 +++---- ext/mixed/js/japanese.js | 9 +++++---- 3 files changed, 12 insertions(+), 12 deletions(-) (limited to 'ext/mixed') diff --git a/ext/bg/js/api.js b/ext/bg/js/api.js index b489b8d2..c43a6dd7 100644 --- a/ext/bg/js/api.js +++ b/ext/bg/js/api.js @@ -87,7 +87,7 @@ async function apiTextParse(text, optionsContext) { while (text.length > 0) { const term = []; const [definitions, sourceLength] = await translator.findTermsInternal( - text.slice(0, options.scanning.length), + text.substring(0, options.scanning.length), dictEnabledSet(options), options.scanning.alphanumeric, {} @@ -95,16 +95,16 @@ async function apiTextParse(text, optionsContext) { if (definitions.length > 0) { dictTermsSort(definitions); const {expression, reading} = definitions[0]; - const source = text.slice(0, sourceLength); + const source = text.substring(0, sourceLength); for (const {text, furigana} of jpDistributeFuriganaInflected(expression, reading, source)) { const reading = jpConvertReading(text, furigana, options.parsing.readingMode); term.push({text, reading}); } - text = text.slice(source.length); + text = text.substring(source.length); } else { const reading = jpConvertReading(text[0], null, options.parsing.readingMode); term.push({text: text[0], reading}); - text = text.slice(1); + text = text.substring(1); } results.push(term); } diff --git a/ext/bg/js/search-query-parser.js b/ext/bg/js/search-query-parser.js index 1c583bf1..1632b561 100644 --- a/ext/bg/js/search-query-parser.js +++ b/ext/bg/js/search-query-parser.js @@ -148,10 +148,9 @@ class QueryParser { async setPreview(text) { const previewTerms = []; - while (text.length > 0) { - const tempText = text.slice(0, 2); - previewTerms.push([{text: Array.from(tempText)}]); - text = text.slice(2); + for (let i = 0, ii = text.length; i < ii; i += 2) { + const tempText = text.substring(i, i + 2); + previewTerms.push([{text: tempText.split('')}]); } this.queryParser.innerHTML = await apiTemplateRender('query-parser.html', { terms: previewTerms, diff --git a/ext/mixed/js/japanese.js b/ext/mixed/js/japanese.js index 8b841b2e..ea1c0065 100644 --- a/ext/mixed/js/japanese.js +++ b/ext/mixed/js/japanese.js @@ -160,16 +160,17 @@ function jpDistributeFuriganaInflected(expression, reading, source) { } const offset = source.length - stemLength; - const stemExpression = source.slice(0, source.length - offset); - const stemReading = reading.slice( - 0, offset === 0 ? reading.length : reading.length - expression.length + stemLength + const stemExpression = source.substring(0, source.length - offset); + const stemReading = reading.substring( + 0, + offset === 0 ? reading.length : reading.length - expression.length + stemLength ); for (const segment of jpDistributeFurigana(stemExpression, stemReading)) { output.push(segment); } if (stemLength !== source.length) { - output.push({text: source.slice(stemLength)}); + output.push({text: source.substring(stemLength)}); } return output; -- cgit v1.2.3 From 47feb95842eac8e2fb4571a5ec493454cc0c422e Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Tue, 10 Dec 2019 19:40:40 -0500 Subject: Add timer class for debugging --- ext/mixed/js/timer.js | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 ext/mixed/js/timer.js (limited to 'ext/mixed') diff --git a/ext/mixed/js/timer.js b/ext/mixed/js/timer.js new file mode 100644 index 00000000..87ab62a7 --- /dev/null +++ b/ext/mixed/js/timer.js @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2019 Alex Yatskov + * Author: Alex Yatskov + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + + +class Timer { + constructor(name) { + this.samples = []; + this.parent = null; + + this.sample(name); + const current = Timer._current; + if (current !== null) { + current.samples[current.samples.length - 1].children.push(this); + this.parent = current; + } + Timer._current = this; + } + + sample(name) { + const time = window.performance.now(); + this.samples.push({ + name, + time, + children: [] + }); + } + + complete(skip) { + this.sample('complete'); + + Timer._current = this.parent; + if (this.parent === null) { + if (!skip) { + console.log(this.toString()); + } + } else { + if (skip) { + const sample = this.parent.samples[this.parent.samples.length - 1]; + sample.children.splice(sample.children.length - 1, 1); + } + } + } + + duration(sampleIndex) { + const sampleIndexIsValid = (typeof sampleIndex === 'number'); + const startIndex = (sampleIndexIsValid ? sampleIndex : 0); + const endIndex = (sampleIndexIsValid ? sampleIndex + 1 : this.times.length - 1); + return (this.times[endIndex].time - this.times[startIndex].time); + } + + toString() { + const indent = ' '; + const name = this.samples[0].name; + const duration = this.samples[this.samples.length - 1].time - this.samples[0].time; + const extensionName = chrome.runtime.getManifest().name; + return `${name} took ${duration.toFixed(8)}ms [${extensionName}]` + Timer._indentString(this.getSampleString(), indent); + } + + getSampleString() { + const indent = ' '; + const duration = this.samples[this.samples.length - 1].time - this.samples[0].time; + let message = ''; + + for (let i = 0, ii = this.samples.length - 1; i < ii; ++i) { + const sample = this.samples[i]; + const sampleDuration = this.samples[i + 1].time - sample.time; + message += `\nSample[${i}] took ${sampleDuration.toFixed(8)}ms (${((sampleDuration / duration) * 100.0).toFixed(1)}%) [${sample.name}]`; + for (const child of sample.children) { + message += Timer._indentString(child.getSampleString(), indent); + } + } + + return message; + } + + static _indentString(message, indent) { + return message.replace(/\n/g, `\n${indent}`); + } +} + +Timer._current = null; -- cgit v1.2.3 From a2263e57292b7b6822c37c951b40b355a277fecd Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 8 Dec 2019 22:23:23 -0500 Subject: Update display message handlers --- ext/mixed/js/display.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'ext/mixed') diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js index 6e2c8e6a..9d3dc51b 100644 --- a/ext/mixed/js/display.js +++ b/ext/mixed/js/display.js @@ -227,12 +227,12 @@ class Display { } onRuntimeMessage({action, params}, sender, callback) { - const handlers = Display.runtimeMessageHandlers; - if (hasOwn(handlers, action)) { - const handler = handlers[action]; - const result = handler(this, params); - callback(result); - } + const handler = Display._runtimeMessageHandlers.get(action); + if (typeof handler !== 'function') { return false; } + + const result = handler(this, params, sender); + callback(result); + return false; } getOptionsContext() { @@ -880,6 +880,6 @@ Display.onKeyDownHandlers = { } }; -Display.runtimeMessageHandlers = { - optionsUpdate: (self) => self.updateOptions(null) -}; +Display._runtimeMessageHandlers = new Map([ + ['optionsUpdate', (self) => self.updateOptions(null)] +]); -- cgit v1.2.3 From a9c4ce724caf4824b8bb6f6fffe3db4c9dbb7bf6 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Wed, 11 Dec 2019 21:51:31 -0500 Subject: Update display key handlers --- ext/mixed/js/display.js | 65 ++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 33 deletions(-) (limited to 'ext/mixed') diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js index 9d3dc51b..ab0674a9 100644 --- a/ext/mixed/js/display.js +++ b/ext/mixed/js/display.js @@ -193,9 +193,8 @@ class Display { onKeyDown(e) { const key = Display.getKeyFromEvent(e); - const handlers = Display.onKeyDownHandlers; - if (hasOwn(handlers, key)) { - const handler = handlers[key]; + const handler = Display._onKeyDownHandlers.get(key); + if (typeof handler === 'function') { if (handler(this, e)) { e.preventDefault(); return true; @@ -766,101 +765,101 @@ class Display { } } -Display.onKeyDownHandlers = { - 'Escape': (self) => { +Display._onKeyDownHandlers = new Map([ + ['Escape', (self) => { self.onSearchClear(); return true; - }, + }], - 'PageUp': (self, e) => { + ['PageUp', (self, e) => { if (e.altKey) { self.entryScrollIntoView(self.index - 3, null, true); return true; } return false; - }, + }], - 'PageDown': (self, e) => { + ['PageDown', (self, e) => { if (e.altKey) { self.entryScrollIntoView(self.index + 3, null, true); return true; } return false; - }, + }], - 'End': (self, e) => { + ['End', (self, e) => { if (e.altKey) { self.entryScrollIntoView(self.definitions.length - 1, null, true); return true; } return false; - }, + }], - 'Home': (self, e) => { + ['Home', (self, e) => { if (e.altKey) { self.entryScrollIntoView(0, null, true); return true; } return false; - }, + }], - 'ArrowUp': (self, e) => { + ['ArrowUp', (self, e) => { if (e.altKey) { self.entryScrollIntoView(self.index - 1, null, true); return true; } return false; - }, + }], - 'ArrowDown': (self, e) => { + ['ArrowDown', (self, e) => { if (e.altKey) { self.entryScrollIntoView(self.index + 1, null, true); return true; } return false; - }, + }], - 'B': (self, e) => { + ['B', (self, e) => { if (e.altKey) { self.sourceTermView(); return true; } return false; - }, + }], - 'F': (self, e) => { + ['F', (self, e) => { if (e.altKey) { self.nextTermView(); return true; } return false; - }, + }], - 'E': (self, e) => { + ['E', (self, e) => { if (e.altKey) { self.noteTryAdd('term-kanji'); return true; } return false; - }, + }], - 'K': (self, e) => { + ['K', (self, e) => { if (e.altKey) { self.noteTryAdd('kanji'); return true; } return false; - }, + }], - 'R': (self, e) => { + ['R', (self, e) => { if (e.altKey) { self.noteTryAdd('term-kana'); return true; } return false; - }, + }], - 'P': (self, e) => { + ['P', (self, e) => { if (e.altKey) { const entry = self.getEntry(self.index); if (entry !== null && entry.dataset.type === 'term') { @@ -869,16 +868,16 @@ Display.onKeyDownHandlers = { return true; } return false; - }, + }], - 'V': (self, e) => { + ['V', (self, e) => { if (e.altKey) { self.noteTryView(); return true; } return false; - } -}; + }] +]); Display._runtimeMessageHandlers = new Map([ ['optionsUpdate', (self) => self.updateOptions(null)] -- cgit v1.2.3 From 4177b6372696d9b424857fedd1be988cc7eb0095 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 8 Dec 2019 22:29:23 -0500 Subject: Remove redundant getUrl handlers --- ext/bg/js/search.js | 17 ----------------- ext/bg/js/settings/main.js | 5 +---- ext/fg/js/frontend.js | 3 +-- ext/mixed/js/core.js | 18 ++++++++++++++++++ 4 files changed, 20 insertions(+), 23 deletions(-) (limited to 'ext/mixed') diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js index 67a78075..540b809b 100644 --- a/ext/bg/js/search.js +++ b/ext/bg/js/search.js @@ -238,17 +238,6 @@ class DisplaySearch extends Display { } } - onRuntimeMessage({action, params}, sender, callback) { - const handlers = DisplaySearch.runtimeMessageHandlers; - if (hasOwn(handlers, action)) { - const handler = handlers[action]; - const result = handler(this, params); - callback(result); - } else { - return super.onRuntimeMessage({action, params}, sender, callback); - } - } - initClipboardMonitor() { // ignore copy from search page window.addEventListener('copy', () => { @@ -380,12 +369,6 @@ class DisplaySearch extends Display { } } -DisplaySearch.runtimeMessageHandlers = { - getUrl: () => { - return {url: window.location.href}; - } -}; - DisplaySearch.onKeyDownIgnoreKeys = { 'ANY_MOD': [ 'Tab', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'PageDown', 'PageUp', 'Home', 'End', diff --git a/ext/bg/js/settings/main.js b/ext/bg/js/settings/main.js index 7456e7a4..0fd9cb23 100644 --- a/ext/bg/js/settings/main.js +++ b/ext/bg/js/settings/main.js @@ -199,14 +199,11 @@ async function onOptionsUpdate({source}) { await formWrite(options); } -function onMessage({action, params}, sender, callback) { +function onMessage({action, params}) { switch (action) { case 'optionsUpdate': onOptionsUpdate(params); break; - case 'getUrl': - callback({url: window.location.href}); - break; } } diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js index 6c1dafe5..43b64bb0 100644 --- a/ext/fg/js/frontend.js +++ b/ext/fg/js/frontend.js @@ -201,6 +201,5 @@ Frontend._windowMessageHandlers = new Map([ Frontend._runtimeMessageHandlers = new Map([ ['optionsUpdate', (self) => self.updateOptions()], - ['popupSetVisibleOverride', (self, {visible}) => self.popup.setVisibleOverride(visible)], - ['getUrl', () => ({url: window.location.href})] + ['popupSetVisibleOverride', (self, {visible}) => self.popup.setVisibleOverride(visible)] ]); diff --git a/ext/mixed/js/core.js b/ext/mixed/js/core.js index b9536391..36056c36 100644 --- a/ext/mixed/js/core.js +++ b/ext/mixed/js/core.js @@ -225,3 +225,21 @@ class EventDispatcher { return false; } } + + +/* + * Default message handlers + */ + +(() => { + function onMessage({action}, sender, callback) { + switch (action) { + case 'getUrl': + callback({url: window.location.href}); + break; + } + return false; + } + + chrome.runtime.onMessage.addListener(onMessage); +})(); -- cgit v1.2.3 From ce51fe7eca2e893c8631c62ccb39ce3921ad1b6b Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Mon, 9 Dec 2019 22:45:28 -0500 Subject: Use a single api.js --- ext/bg/background.html | 2 +- ext/bg/context.html | 2 +- ext/bg/js/api.js | 98 ----------------------------- ext/bg/search.html | 2 +- ext/bg/settings-popup-preview.html | 2 +- ext/bg/settings.html | 2 +- ext/fg/float.html | 2 +- ext/fg/js/api.js | 126 ------------------------------------- ext/manifest.json | 2 +- ext/mixed/js/api.js | 126 +++++++++++++++++++++++++++++++++++++ 10 files changed, 133 insertions(+), 231 deletions(-) delete mode 100644 ext/bg/js/api.js delete mode 100644 ext/fg/js/api.js create mode 100644 ext/mixed/js/api.js (limited to 'ext/mixed') diff --git a/ext/bg/background.html b/ext/bg/background.html index 5a6970c3..11838d14 100644 --- a/ext/bg/background.html +++ b/ext/bg/background.html @@ -20,10 +20,10 @@ + - diff --git a/ext/bg/context.html b/ext/bg/context.html index eda09a68..0e50ed7c 100644 --- a/ext/bg/context.html +++ b/ext/bg/context.html @@ -180,8 +180,8 @@ + - diff --git a/ext/bg/js/api.js b/ext/bg/js/api.js deleted file mode 100644 index 095734fb..00000000 --- a/ext/bg/js/api.js +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (C) 2016-2017 Alex Yatskov - * Author: Alex Yatskov - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - - -function apiOptionsGet(optionsContext) { - return utilBackend()._onApiOptionsGet({optionsContext}); -} - -function apiOptionsSet(changedOptions, optionsContext, source) { - return utilBackend()._onApiOptionsSet({changedOptions, optionsContext, source}); -} - -function apiOptionsGetFull() { - return utilBackend()._onApiOptionsGetFull(); -} - -function apiOptionsSave(source) { - return utilBackend()._onApiOptionsSave({source}); -} - -function apiTermsFind(text, details, optionsContext) { - return utilBackend()._onApiTermsFind({text, details, optionsContext}); -} - -function apiTextParse(text, optionsContext) { - return utilBackend()._onApiTextParse({text, optionsContext}); -} - -function apiTextParseMecab(text, optionsContext) { - return utilBackend()._onApiTextParseMecab({text, optionsContext}); -} - -function apiKanjiFind(text, optionsContext) { - return utilBackend()._onApiKanjiFind({text, optionsContext}); -} - -function apiDefinitionAdd(definition, mode, context, optionsContext) { - return utilBackend()._onApiDefinitionAdd({definition, mode, context, optionsContext}); -} - -function apiDefinitionsAddable(definitions, modes, optionsContext) { - return utilBackend()._onApiDefinitionsAddable({definitions, modes, optionsContext}); -} - -function apiNoteView(noteId) { - return utilBackend()._onApiNoteView({noteId}); -} - -function apiTemplateRender(template, data, dynamic) { - return utilBackend()._onApiTemplateRender({template, data, dynamic}); -} - -function apiCommandExec(command, params) { - return utilBackend()._onApiCommandExec({command, params}); -} - -function apiAudioGetUrl(definition, source, optionsContext) { - return utilBackend()._onApiAudioGetUrl({definition, source, optionsContext}); -} - -function apiScreenshotGet(options, sender) { - return utilBackend()._onApiScreenshotGet({options}, sender); -} - -function apiForward(action, params, sender) { - return utilBackend()._onApiForward({action, params}, sender); -} - -function apiFrameInformationGet(sender) { - return utilBackend()._onApiFrameInformationGet(null, sender); -} - -function apiInjectStylesheet(css, sender) { - return utilBackend()._onApiInjectStylesheet({css}, sender); -} - -function apiGetEnvironmentInfo() { - return utilBackend()._onApiGetEnvironmentInfo(); -} - -function apiClipboardGet() { - return utilBackend()._onApiClipboardGet(); -} diff --git a/ext/bg/search.html b/ext/bg/search.html index 7b4616da..409243dd 100644 --- a/ext/bg/search.html +++ b/ext/bg/search.html @@ -62,11 +62,11 @@ + - diff --git a/ext/bg/settings-popup-preview.html b/ext/bg/settings-popup-preview.html index 9b92b4e2..f33ecedf 100644 --- a/ext/bg/settings-popup-preview.html +++ b/ext/bg/settings-popup-preview.html @@ -119,9 +119,9 @@ + - diff --git a/ext/bg/settings.html b/ext/bg/settings.html index ea34b208..a3d8cb0c 100644 --- a/ext/bg/settings.html +++ b/ext/bg/settings.html @@ -881,10 +881,10 @@ + - diff --git a/ext/fg/float.html b/ext/fg/float.html index 67ee50b4..886e5e8b 100644 --- a/ext/fg/float.html +++ b/ext/fg/float.html @@ -33,8 +33,8 @@ + - diff --git a/ext/fg/js/api.js b/ext/fg/js/api.js deleted file mode 100644 index ae74b8dc..00000000 --- a/ext/fg/js/api.js +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (C) 2016-2017 Alex Yatskov - * Author: Alex Yatskov - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - - -function apiOptionsGet(optionsContext) { - return _apiInvoke('optionsGet', {optionsContext}); -} - -function apiOptionsGetFull() { - return _apiInvoke('optionsGetFull'); -} - -function apiOptionsSet(changedOptions, optionsContext, source) { - return _apiInvoke('optionsSet', {changedOptions, optionsContext, source}); -} - -function apiOptionsSave(source) { - return _apiInvoke('optionsSave', {source}); -} - -function apiTermsFind(text, details, optionsContext) { - return _apiInvoke('termsFind', {text, details, optionsContext}); -} - -function apiTextParse(text, optionsContext) { - return _apiInvoke('textParse', {text, optionsContext}); -} - -function apiTextParseMecab(text, optionsContext) { - return _apiInvoke('textParseMecab', {text, optionsContext}); -} - -function apiKanjiFind(text, optionsContext) { - return _apiInvoke('kanjiFind', {text, optionsContext}); -} - -function apiDefinitionAdd(definition, mode, context, optionsContext) { - return _apiInvoke('definitionAdd', {definition, mode, context, optionsContext}); -} - -function apiDefinitionsAddable(definitions, modes, optionsContext) { - return _apiInvoke('definitionsAddable', {definitions, modes, optionsContext}).catch(() => null); -} - -function apiNoteView(noteId) { - return _apiInvoke('noteView', {noteId}); -} - -function apiTemplateRender(template, data, dynamic) { - return _apiInvoke('templateRender', {data, template, dynamic}); -} - -function apiAudioGetUrl(definition, source, optionsContext) { - return _apiInvoke('audioGetUrl', {definition, source, optionsContext}); -} - -function apiCommandExec(command, params) { - return _apiInvoke('commandExec', {command, params}); -} - -function apiScreenshotGet(options) { - return _apiInvoke('screenshotGet', {options}); -} - -function apiForward(action, params) { - return _apiInvoke('forward', {action, params}); -} - -function apiFrameInformationGet() { - return _apiInvoke('frameInformationGet'); -} - -function apiInjectStylesheet(css) { - return _apiInvoke('injectStylesheet', {css}); -} - -function apiGetEnvironmentInfo() { - return _apiInvoke('getEnvironmentInfo'); -} - -function apiClipboardGet() { - return _apiInvoke('clipboardGet'); -} - -function _apiInvoke(action, params={}) { - const data = {action, params}; - return new Promise((resolve, reject) => { - try { - chrome.runtime.sendMessage(data, (response) => { - _apiCheckLastError(chrome.runtime.lastError); - if (response !== null && typeof response === 'object') { - if (typeof response.error !== 'undefined') { - reject(jsonToError(response.error)); - } else { - resolve(response.result); - } - } else { - const message = response === null ? 'Unexpected null response' : `Unexpected response of type ${typeof response}`; - reject(new Error(`${message} (${JSON.stringify(data)})`)); - } - }); - } catch (e) { - window.yomichan_orphaned = true; - reject(e); - } - }); -} - -function _apiCheckLastError() { - // NOP -} diff --git a/ext/manifest.json b/ext/manifest.json index 225ca441..1e819328 100644 --- a/ext/manifest.json +++ b/ext/manifest.json @@ -20,8 +20,8 @@ "js": [ "mixed/js/core.js", "mixed/js/dom.js", + "mixed/js/api.js", "mixed/js/text-scanner.js", - "fg/js/api.js", "fg/js/document.js", "fg/js/frontend-api-receiver.js", "fg/js/popup.js", diff --git a/ext/mixed/js/api.js b/ext/mixed/js/api.js new file mode 100644 index 00000000..ae74b8dc --- /dev/null +++ b/ext/mixed/js/api.js @@ -0,0 +1,126 @@ +/* + * Copyright (C) 2016-2017 Alex Yatskov + * Author: Alex Yatskov + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + + +function apiOptionsGet(optionsContext) { + return _apiInvoke('optionsGet', {optionsContext}); +} + +function apiOptionsGetFull() { + return _apiInvoke('optionsGetFull'); +} + +function apiOptionsSet(changedOptions, optionsContext, source) { + return _apiInvoke('optionsSet', {changedOptions, optionsContext, source}); +} + +function apiOptionsSave(source) { + return _apiInvoke('optionsSave', {source}); +} + +function apiTermsFind(text, details, optionsContext) { + return _apiInvoke('termsFind', {text, details, optionsContext}); +} + +function apiTextParse(text, optionsContext) { + return _apiInvoke('textParse', {text, optionsContext}); +} + +function apiTextParseMecab(text, optionsContext) { + return _apiInvoke('textParseMecab', {text, optionsContext}); +} + +function apiKanjiFind(text, optionsContext) { + return _apiInvoke('kanjiFind', {text, optionsContext}); +} + +function apiDefinitionAdd(definition, mode, context, optionsContext) { + return _apiInvoke('definitionAdd', {definition, mode, context, optionsContext}); +} + +function apiDefinitionsAddable(definitions, modes, optionsContext) { + return _apiInvoke('definitionsAddable', {definitions, modes, optionsContext}).catch(() => null); +} + +function apiNoteView(noteId) { + return _apiInvoke('noteView', {noteId}); +} + +function apiTemplateRender(template, data, dynamic) { + return _apiInvoke('templateRender', {data, template, dynamic}); +} + +function apiAudioGetUrl(definition, source, optionsContext) { + return _apiInvoke('audioGetUrl', {definition, source, optionsContext}); +} + +function apiCommandExec(command, params) { + return _apiInvoke('commandExec', {command, params}); +} + +function apiScreenshotGet(options) { + return _apiInvoke('screenshotGet', {options}); +} + +function apiForward(action, params) { + return _apiInvoke('forward', {action, params}); +} + +function apiFrameInformationGet() { + return _apiInvoke('frameInformationGet'); +} + +function apiInjectStylesheet(css) { + return _apiInvoke('injectStylesheet', {css}); +} + +function apiGetEnvironmentInfo() { + return _apiInvoke('getEnvironmentInfo'); +} + +function apiClipboardGet() { + return _apiInvoke('clipboardGet'); +} + +function _apiInvoke(action, params={}) { + const data = {action, params}; + return new Promise((resolve, reject) => { + try { + chrome.runtime.sendMessage(data, (response) => { + _apiCheckLastError(chrome.runtime.lastError); + if (response !== null && typeof response === 'object') { + if (typeof response.error !== 'undefined') { + reject(jsonToError(response.error)); + } else { + resolve(response.result); + } + } else { + const message = response === null ? 'Unexpected null response' : `Unexpected response of type ${typeof response}`; + reject(new Error(`${message} (${JSON.stringify(data)})`)); + } + }); + } catch (e) { + window.yomichan_orphaned = true; + reject(e); + } + }); +} + +function _apiCheckLastError() { + // NOP +} -- cgit v1.2.3 From cab2a3998169040a6a6d5bda828d4a8af5592cd6 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Tue, 17 Dec 2019 20:56:32 -0500 Subject: Simplify options passed to docRangeFromPoint --- ext/fg/js/document.js | 3 +-- ext/mixed/js/display.js | 2 +- ext/mixed/js/text-scanner.js | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) (limited to 'ext/mixed') diff --git a/ext/fg/js/document.js b/ext/fg/js/document.js index d54a2e44..fa7e7cbc 100644 --- a/ext/fg/js/document.js +++ b/ext/fg/js/document.js @@ -106,8 +106,7 @@ function docElementsFromPoint(x, y, all) { return e !== null ? [e] : []; } -function docRangeFromPoint(x, y, options) { - const deepDomScan = options.scanning.deepDomScan; +function docRangeFromPoint(x, y, deepDomScan) { const elements = docElementsFromPoint(x, y, deepDomScan); let imposter = null; let imposterContainer = null; diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js index ab0674a9..f3b5dd2a 100644 --- a/ext/mixed/js/display.js +++ b/ext/mixed/js/display.js @@ -144,7 +144,7 @@ class Display { try { e.preventDefault(); - const textSource = docRangeFromPoint(e.clientX, e.clientY, this.options); + const textSource = docRangeFromPoint(e.clientX, e.clientY, this.options.scanning.deepDomScan); if (textSource === null) { return false; } diff --git a/ext/mixed/js/text-scanner.js b/ext/mixed/js/text-scanner.js index ac5d68d1..9a739c7e 100644 --- a/ext/mixed/js/text-scanner.js +++ b/ext/mixed/js/text-scanner.js @@ -297,7 +297,7 @@ class TextScanner { } } - const textSource = docRangeFromPoint(x, y, this.options); + const textSource = docRangeFromPoint(x, y, this.options.scanning.deepDomScan); if (this.textSourceCurrent !== null && this.textSourceCurrent.equals(textSource)) { return; } -- cgit v1.2.3 From e14bd75a4f2f25c8fc36ee801d952960987e76ad Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Fri, 20 Dec 2019 13:15:26 -0500 Subject: Change how getUrl message is handled --- ext/mixed/js/core.js | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'ext/mixed') diff --git a/ext/mixed/js/core.js b/ext/mixed/js/core.js index 36056c36..edb1f913 100644 --- a/ext/mixed/js/core.js +++ b/ext/mixed/js/core.js @@ -231,15 +231,29 @@ class EventDispatcher { * Default message handlers */ -(() => { - function onMessage({action}, sender, callback) { - switch (action) { - case 'getUrl': - callback({url: window.location.href}); - break; +const yomichan = (() => { + class Yomichan { + constructor() { + this._messageHandlers = new Map([ + ['getUrl', this._onMessageGetUrl.bind(this)] + ]); + + chrome.runtime.onMessage.addListener(this._onMessage.bind(this)); + } + + _onMessage({action, params}, sender, callback) { + const handler = this._messageHandlers.get(action); + if (typeof handler !== 'function') { return false; } + + const result = handler(params, sender); + callback(result); + return false; + } + + _onMessageGetUrl() { + return {url: window.location.href}; } - return false; } - chrome.runtime.onMessage.addListener(onMessage); + return new Yomichan(); })(); -- cgit v1.2.3 From 2a95f1420f08b034ae8e12ecffed86aa6f33e53a Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Fri, 20 Dec 2019 13:36:54 -0500 Subject: Move optionsUpdate message handler into Yomichan class --- ext/bg/js/settings/main.js | 10 +--------- ext/fg/js/frontend.js | 2 +- ext/mixed/js/core.js | 11 +++++++++-- ext/mixed/js/display.js | 15 +-------------- 4 files changed, 12 insertions(+), 26 deletions(-) (limited to 'ext/mixed') diff --git a/ext/bg/js/settings/main.js b/ext/bg/js/settings/main.js index 78a5870c..870769e5 100644 --- a/ext/bg/js/settings/main.js +++ b/ext/bg/js/settings/main.js @@ -204,14 +204,6 @@ async function onOptionsUpdate({source}) { await formWrite(options); } -function onMessage({action, params}) { - switch (action) { - case 'optionsUpdate': - onOptionsUpdate(params); - break; - } -} - function showExtensionInformation() { const node = document.getElementById('extension-info'); @@ -235,7 +227,7 @@ async function onReady() { storageInfoInitialize(); - chrome.runtime.onMessage.addListener(onMessage); + yomichan.on('optionsUpdate', onOptionsUpdate); } $(document).ready(() => onReady()); diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js index c8e112a7..1d63d928 100644 --- a/ext/fg/js/frontend.js +++ b/ext/fg/js/frontend.js @@ -54,6 +54,7 @@ class Frontend extends TextScanner { try { await this.updateOptions(); + yomichan.on('optionsUpdate', () => this.updateOptions()); chrome.runtime.onMessage.addListener(this.onRuntimeMessage.bind(this)); this.isPreparedPromiseResolve(); } catch (e) { @@ -200,6 +201,5 @@ Frontend._windowMessageHandlers = new Map([ ]); Frontend._runtimeMessageHandlers = new Map([ - ['optionsUpdate', (self) => { self.updateOptions(); }], ['popupSetVisibleOverride', (self, {visible}) => { self.popup.setVisibleOverride(visible); }] ]); diff --git a/ext/mixed/js/core.js b/ext/mixed/js/core.js index edb1f913..a3c8c0b0 100644 --- a/ext/mixed/js/core.js +++ b/ext/mixed/js/core.js @@ -232,10 +232,13 @@ class EventDispatcher { */ const yomichan = (() => { - class Yomichan { + class Yomichan extends EventDispatcher { constructor() { + super(); + this._messageHandlers = new Map([ - ['getUrl', this._onMessageGetUrl.bind(this)] + ['getUrl', this._onMessageGetUrl.bind(this)], + ['optionsUpdate', this._onMessageOptionsUpdate.bind(this)] ]); chrome.runtime.onMessage.addListener(this._onMessage.bind(this)); @@ -253,6 +256,10 @@ const yomichan = (() => { _onMessageGetUrl() { return {url: window.location.href}; } + + _onMessageOptionsUpdate({source}) { + this.trigger('optionsUpdate', {source}); + } } return new Yomichan(); diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js index f3b5dd2a..089941a9 100644 --- a/ext/mixed/js/display.js +++ b/ext/mixed/js/display.js @@ -225,15 +225,6 @@ class Display { } } - onRuntimeMessage({action, params}, sender, callback) { - const handler = Display._runtimeMessageHandlers.get(action); - if (typeof handler !== 'function') { return false; } - - const result = handler(this, params, sender); - callback(result); - return false; - } - getOptionsContext() { throw new Error('Override me'); } @@ -244,7 +235,7 @@ class Display { async initialize(options=null) { await this.updateOptions(options); - chrome.runtime.onMessage.addListener(this.onRuntimeMessage.bind(this)); + yomichan.on('optionsUpdate', () => this.updateOptions(null)); } async updateOptions(options) { @@ -878,7 +869,3 @@ Display._onKeyDownHandlers = new Map([ return false; }] ]); - -Display._runtimeMessageHandlers = new Map([ - ['optionsUpdate', (self) => self.updateOptions(null)] -]); -- cgit v1.2.3 From 2519f99f54412933beed8b2c753c76662099f8e0 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Fri, 20 Dec 2019 13:44:33 -0500 Subject: Update how orphan state is observed --- ext/fg/js/float.js | 9 ++++++++- ext/fg/js/frontend.js | 8 +++++++- ext/mixed/js/api.js | 2 +- ext/mixed/js/core.js | 8 ++++++++ 4 files changed, 24 insertions(+), 3 deletions(-) (limited to 'ext/mixed') diff --git a/ext/fg/js/float.js b/ext/fg/js/float.js index 74bc58b0..8c7de906 100644 --- a/ext/fg/js/float.js +++ b/ext/fg/js/float.js @@ -27,17 +27,24 @@ class DisplayFloat extends Display { url: window.location.href }; + this._orphaned = false; + + yomichan.on('orphaned', () => this.onOrphaned()); window.addEventListener('message', (e) => this.onMessage(e), false); } onError(error) { - if (window.yomichan_orphaned) { + if (this._orphaned) { this.setContentOrphaned(); } else { logError(error, true); } } + onOrphaned() { + this._orphaned = true; + } + onSearchClear() { window.parent.postMessage('popupClose', '*'); } diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js index 1d63d928..6b41138f 100644 --- a/ext/fg/js/frontend.js +++ b/ext/fg/js/frontend.js @@ -37,6 +37,7 @@ class Frontend extends TextScanner { this.isPreparedPromiseResolve = null; this.isPreparedPromise = new Promise((resolve) => { this.isPreparedPromiseResolve = resolve; }); + this._orphaned = true; this._lastShowPromise = Promise.resolve(); } @@ -54,6 +55,7 @@ class Frontend extends TextScanner { try { await this.updateOptions(); + yomichan.on('orphaned', () => this.onOrphaned()); yomichan.on('optionsUpdate', () => this.updateOptions()); chrome.runtime.onMessage.addListener(this.onRuntimeMessage.bind(this)); this.isPreparedPromiseResolve(); @@ -93,6 +95,10 @@ class Frontend extends TextScanner { return false; } + onOrphaned() { + this._orphaned = true; + } + getMouseEventListeners() { return [ ...super.getMouseEventListeners(), @@ -122,7 +128,7 @@ class Frontend extends TextScanner { } } } catch (e) { - if (window.yomichan_orphaned) { + if (this._orphaned) { if (textSource !== null && this.options.scanning.modifier !== 'none') { this._lastShowPromise = this.popup.showContent( textSource.getRect(), diff --git a/ext/mixed/js/api.js b/ext/mixed/js/api.js index ae74b8dc..18b360a3 100644 --- a/ext/mixed/js/api.js +++ b/ext/mixed/js/api.js @@ -115,8 +115,8 @@ function _apiInvoke(action, params={}) { } }); } catch (e) { - window.yomichan_orphaned = true; reject(e); + yomichan.triggerOrphaned(e); } }); } diff --git a/ext/mixed/js/core.js b/ext/mixed/js/core.js index a3c8c0b0..5e560a58 100644 --- a/ext/mixed/js/core.js +++ b/ext/mixed/js/core.js @@ -244,6 +244,14 @@ const yomichan = (() => { chrome.runtime.onMessage.addListener(this._onMessage.bind(this)); } + // Public + + triggerOrphaned(error) { + this.trigger('orphaned', {error}); + } + + // Private + _onMessage({action, params}, sender, callback) { const handler = this._messageHandlers.get(action); if (typeof handler !== 'function') { return false; } -- cgit v1.2.3 From d2da4f7e62c42ed7f9fd82c8af2f1d9968bec2ce Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 14 Dec 2019 16:40:05 -0500 Subject: Add apiOptionsSchemaGet --- ext/bg/js/backend.js | 12 ++++++++++++ ext/mixed/js/api.js | 4 ++++ 2 files changed, 16 insertions(+) (limited to 'ext/mixed') diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js index 55841cd6..245e3de2 100644 --- a/ext/bg/js/backend.js +++ b/ext/bg/js/backend.js @@ -115,6 +115,13 @@ class Backend { } } + async getOptionsSchema() { + if (this.isPreparedPromise !== null) { + await this.isPreparedPromise; + } + return this.optionsSchema; + } + async getFullOptions() { if (this.isPreparedPromise !== null) { await this.isPreparedPromise; @@ -200,6 +207,10 @@ class Backend { // Message handlers + _onApiOptionsSchemaGet() { + return this.getOptionsSchema(); + } + _onApiOptionsGet({optionsContext}) { return this.getOptions(optionsContext); } @@ -692,6 +703,7 @@ class Backend { } Backend._messageHandlers = new Map([ + ['optionsSchemaGet', (self, ...args) => self._onApiOptionsSchemaGet(...args)], ['optionsGet', (self, ...args) => self._onApiOptionsGet(...args)], ['optionsGetFull', (self, ...args) => self._onApiOptionsGetFull(...args)], ['optionsSet', (self, ...args) => self._onApiOptionsSet(...args)], diff --git a/ext/mixed/js/api.js b/ext/mixed/js/api.js index 18b360a3..dc901efc 100644 --- a/ext/mixed/js/api.js +++ b/ext/mixed/js/api.js @@ -17,6 +17,10 @@ */ +function apiOptionsSchemaGet() { + return _apiInvoke('optionsSchemaGet'); +} + function apiOptionsGet(optionsContext) { return _apiInvoke('optionsGet', {optionsContext}); } -- cgit v1.2.3 From 899ef167d184fedb072b727e0dc04f2579b08e1f Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Wed, 1 Jan 2020 12:00:00 -0500 Subject: Update copyright --- LICENSE | 2 +- ext/bg/css/settings.css | 2 +- ext/bg/js/anki.js | 2 +- ext/bg/js/api.js | 2 +- ext/bg/js/audio.js | 2 +- ext/bg/js/backend-api-forwarder.js | 2 +- ext/bg/js/backend.js | 2 +- ext/bg/js/conditions.js | 2 +- ext/bg/js/context.js | 2 +- ext/bg/js/database.js | 2 +- ext/bg/js/deinflector.js | 2 +- ext/bg/js/dictionary.js | 2 +- ext/bg/js/handlebars.js | 2 +- ext/bg/js/json-schema.js | 2 +- ext/bg/js/mecab.js | 2 +- ext/bg/js/options.js | 2 +- ext/bg/js/page-exit-prevention.js | 2 +- ext/bg/js/profile-conditions.js | 2 +- ext/bg/js/request.js | 2 +- ext/bg/js/search-frontend.js | 2 +- ext/bg/js/search-query-parser.js | 2 +- ext/bg/js/search.js | 2 +- ext/bg/js/settings/anki-templates.js | 2 +- ext/bg/js/settings/anki.js | 2 +- ext/bg/js/settings/audio-ui.js | 2 +- ext/bg/js/settings/audio.js | 2 +- ext/bg/js/settings/backup.js | 2 +- ext/bg/js/settings/conditions-ui.js | 2 +- ext/bg/js/settings/dictionaries.js | 2 +- ext/bg/js/settings/main.js | 2 +- ext/bg/js/settings/popup-preview-frame.js | 2 +- ext/bg/js/settings/popup-preview.js | 2 +- ext/bg/js/settings/profiles.js | 2 +- ext/bg/js/settings/storage.js | 2 +- ext/bg/js/translator.js | 2 +- ext/bg/js/util.js | 2 +- ext/bg/legal.html | 2 +- ext/fg/css/client.css | 2 +- ext/fg/js/document.js | 2 +- ext/fg/js/float.js | 2 +- ext/fg/js/frontend-api-receiver.js | 2 +- ext/fg/js/frontend-api-sender.js | 2 +- ext/fg/js/frontend-initialize.js | 2 +- ext/fg/js/frontend.js | 2 +- ext/fg/js/popup-nested.js | 2 +- ext/fg/js/popup-proxy-host.js | 2 +- ext/fg/js/popup-proxy.js | 2 +- ext/fg/js/popup.js | 2 +- ext/fg/js/source.js | 2 +- ext/mixed/css/display-dark.css | 2 +- ext/mixed/css/display-default.css | 2 +- ext/mixed/css/display.css | 2 +- ext/mixed/js/api.js | 2 +- ext/mixed/js/audio.js | 2 +- ext/mixed/js/core.js | 2 +- ext/mixed/js/display-context.js | 2 +- ext/mixed/js/display.js | 2 +- ext/mixed/js/dom.js | 2 +- ext/mixed/js/japanese.js | 2 +- ext/mixed/js/scroll.js | 2 +- ext/mixed/js/text-scanner.js | 2 +- ext/mixed/js/timer.js | 2 +- 62 files changed, 62 insertions(+), 62 deletions(-) (limited to 'ext/mixed') diff --git a/LICENSE b/LICENSE index 811a6915..266e6069 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright 2016-2019 Alex Yatskov +Copyright 2016-2020 Alex Yatskov This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/ext/bg/css/settings.css b/ext/bg/css/settings.css index 8adae47c..ee9d18a1 100644 --- a/ext/bg/css/settings.css +++ b/ext/bg/css/settings.css @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Alex Yatskov + * Copyright (C) 2019-2020 Alex Yatskov * Author: Alex Yatskov * * This program is free software: you can redistribute it and/or modify diff --git a/ext/bg/js/anki.js b/ext/bg/js/anki.js index 17b93620..48ed66bf 100644 --- a/ext/bg/js/anki.js +++ b/ext/bg/js/anki.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 Alex Yatskov + * Copyright (C) 2016-2020 Alex Yatskov * Author: Alex Yatskov * * This program is free software: you can redistribute it and/or modify diff --git a/ext/bg/js/api.js b/ext/bg/js/api.js index 9f37ccd8..8ad8d0bb 100644 --- a/ext/bg/js/api.js +++ b/ext/bg/js/api.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Alex Yatskov + * Copyright (C) 2019-2020 Alex Yatskov * Author: Alex Yatskov * * This program is free software: you can redistribute it and/or modify diff --git a/ext/bg/js/audio.js b/ext/bg/js/audio.js index b39b6c9d..0fc2148d 100644 --- a/ext/bg/js/audio.js +++ b/ext/bg/js/audio.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Alex Yatskov + * Copyright (C) 2017-2020 Alex Yatskov * Author: Alex Yatskov * * This program is free software: you can redistribute it and/or modify diff --git a/ext/bg/js/backend-api-forwarder.js b/ext/bg/js/backend-api-forwarder.js index db4d30b9..0a387e08 100644 --- a/ext/bg/js/backend-api-forwarder.js +++ b/ext/bg/js/backend-api-forwarder.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Alex Yatskov + * Copyright (C) 2019-2020 Alex Yatskov * Author: Alex Yatskov * * This program is free software: you can redistribute it and/or modify diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js index 3c8a068b..2060f414 100644 --- a/ext/bg/js/backend.js +++ b/ext/bg/js/backend.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016-2017 Alex Yatskov + * Copyright (C) 2016-2020 Alex Yatskov * Author: Alex Yatskov * * This program is free software: you can redistribute it and/or modify diff --git a/ext/bg/js/conditions.js b/ext/bg/js/conditions.js index c0f0f301..d3d0b465 100644 --- a/ext/bg/js/conditions.js +++ b/ext/bg/js/conditions.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Alex Yatskov + * Copyright (C) 2019-2020 Alex Yatskov * Author: Alex Yatskov * * This program is free software: you can redistribute it and/or modify diff --git a/ext/bg/js/context.js b/ext/bg/js/context.js index 0b21f662..84368256 100644 --- a/ext/bg/js/context.js +++ b/ext/bg/js/context.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Alex Yatskov + * Copyright (C) 2017-2020 Alex Yatskov * Author: Alex Yatskov * * This program is free software: you can redistribute it and/or modify diff --git a/ext/bg/js/database.js b/ext/bg/js/database.js index 5aee2311..9c44f240 100644 --- a/ext/bg/js/database.js +++ b/ext/bg/js/database.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016-2017 Alex Yatskov + * Copyright (C) 2016-2020 Alex Yatskov * Author: Alex Yatskov * * This program is free software: you can redistribute it and/or modify diff --git a/ext/bg/js/deinflector.js b/ext/bg/js/deinflector.js index 51f4723c..752a0959 100644 --- a/ext/bg/js/deinflector.js +++ b/ext/bg/js/deinflector.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016-2017 Alex Yatskov + * Copyright (C) 2016-2020 Alex Yatskov * Author: Alex Yatskov * * This program is free software: you can redistribute it and/or modify diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js index 28705513..43971f8a 100644 --- a/ext/bg/js/dictionary.js +++ b/ext/bg/js/dictionary.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016-2017 Alex Yatskov + * Copyright (C) 2016-2020 Alex Yatskov * Author: Alex Yatskov * * This program is free software: you can redistribute it and/or modify diff --git a/ext/bg/js/handlebars.js b/ext/bg/js/handlebars.js index b57ba738..7e4b7b8d 100644 --- a/ext/bg/js/handlebars.js +++ b/ext/bg/js/handlebars.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016-2017 Alex Yatskov + * Copyright (C) 2016-2020 Alex Yatskov * Author: Alex Yatskov * * This program is free software: you can redistribute it and/or modify diff --git a/ext/bg/js/json-schema.js b/ext/bg/js/json-schema.js index 3238bc3e..d56f8ef9 100644 --- a/ext/bg/js/json-schema.js +++ b/ext/bg/js/json-schema.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Alex Yatskov + * Copyright (C) 2019-2020 Alex Yatskov * Author: Alex Yatskov * * This program is free software: you can redistribute it and/or modify diff --git a/ext/bg/js/mecab.js b/ext/bg/js/mecab.js index 62111f73..33f9949e 100644 --- a/ext/bg/js/mecab.js +++ b/ext/bg/js/mecab.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Alex Yatskov + * Copyright (C) 2019-2020 Alex Yatskov * Author: Alex Yatskov * * This program is free software: you can redistribute it and/or modify diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js index 84e74bd8..63e7c023 100644 --- a/ext/bg/js/options.js +++ b/ext/bg/js/options.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 Alex Yatskov + * Copyright (C) 2016-2020 Alex Yatskov * Author: Alex Yatskov * * This program is free software: you can redistribute it and/or modify diff --git a/ext/bg/js/page-exit-prevention.js b/ext/bg/js/page-exit-prevention.js index aee4e3c2..4143a835 100644 --- a/ext/bg/js/page-exit-prevention.js +++ b/ext/bg/js/page-exit-prevention.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Alex Yatskov + * Copyright (C) 2019-2020 Alex Yatskov * Author: Alex Yatskov * * This program is free software: you can redistribute it and/or modify diff --git a/ext/bg/js/profile-conditions.js b/ext/bg/js/profile-conditions.js index ebc6680a..20350f4b 100644 --- a/ext/bg/js/profile-conditions.js +++ b/ext/bg/js/profile-conditions.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Alex Yatskov + * Copyright (C) 2019-2020 Alex Yatskov * Author: Alex Yatskov * * This program is free software: you can redistribute it and/or modify diff --git a/ext/bg/js/request.js b/ext/bg/js/request.js index 7d73d49b..6d05f66e 100644 --- a/ext/bg/js/request.js +++ b/ext/bg/js/request.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Alex Yatskov + * Copyright (C) 2017-2020 Alex Yatskov * Author: Alex Yatskov * * This program is free software: you can redistribute it and/or modify diff --git a/ext/bg/js/search-frontend.js b/ext/bg/js/search-frontend.js index fdf7219c..2cf7f5a7 100644 --- a/ext/bg/js/search-frontend.js +++ b/ext/bg/js/search-frontend.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Alex Yatskov + * Copyright (C) 2019-2020 Alex Yatskov * Author: Alex Yatskov * * This program is free software: you can redistribute it and/or modify diff --git a/ext/bg/js/search-query-parser.js b/ext/bg/js/search-query-parser.js index fc95ddff..fec21d3b 100644 --- a/ext/bg/js/search-query-parser.js +++ b/ext/bg/js/search-query-parser.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Alex Yatskov + * Copyright (C) 2019-2020 Alex Yatskov * Author: Alex Yatskov * * This program is free software: you can redistribute it and/or modify diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js index cbfce6a5..439cde40 100644 --- a/ext/bg/js/search.js +++ b/ext/bg/js/search.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016-2017 Alex Yatskov + * Copyright (C) 2016-2020 Alex Yatskov * Author: Alex Yatskov * * This program is free software: you can redistribute it and/or modify diff --git a/ext/bg/js/settings/anki-templates.js b/ext/bg/js/settings/anki-templates.js index 281383a7..4644214b 100644 --- a/ext/bg/js/settings/anki-templates.js +++ b/ext/bg/js/settings/anki-templates.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Alex Yatskov + * Copyright (C) 2019-2020 Alex Yatskov * Author: Alex Yatskov * * This program is free software: you can redistribute it and/or modify diff --git a/ext/bg/js/settings/anki.js b/ext/bg/js/settings/anki.js index 25096531..ccce16fe 100644 --- a/ext/bg/js/settings/anki.js +++ b/ext/bg/js/settings/anki.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Alex Yatskov + * Copyright (C) 2019-2020 Alex Yatskov * Author: Alex Yatskov * * This program is free software: you can redistribute it and/or modify diff --git a/ext/bg/js/settings/audio-ui.js b/ext/bg/js/settings/audio-ui.js index de3be083..dc968628 100644 --- a/ext/bg/js/settings/audio-ui.js +++ b/ext/bg/js/settings/audio-ui.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Alex Yatskov + * Copyright (C) 2019-2020 Alex Yatskov * Author: Alex Yatskov * * This program is free software: you can redistribute it and/or modify diff --git a/ext/bg/js/settings/audio.js b/ext/bg/js/settings/audio.js index d36876df..5809375c 100644 --- a/ext/bg/js/settings/audio.js +++ b/ext/bg/js/settings/audio.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Alex Yatskov + * Copyright (C) 2019-2020 Alex Yatskov * Author: Alex Yatskov * * This program is free software: you can redistribute it and/or modify diff --git a/ext/bg/js/settings/backup.js b/ext/bg/js/settings/backup.js index d278b718..3a4d1fd2 100644 --- a/ext/bg/js/settings/backup.js +++ b/ext/bg/js/settings/backup.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Alex Yatskov + * Copyright (C) 2019-2020 Alex Yatskov * Author: Alex Yatskov * * This program is free software: you can redistribute it and/or modify diff --git a/ext/bg/js/settings/conditions-ui.js b/ext/bg/js/settings/conditions-ui.js index cc9db087..a186a5be 100644 --- a/ext/bg/js/settings/conditions-ui.js +++ b/ext/bg/js/settings/conditions-ui.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Alex Yatskov + * Copyright (C) 2019-2020 Alex Yatskov * Author: Alex Yatskov * * This program is free software: you can redistribute it and/or modify diff --git a/ext/bg/js/settings/dictionaries.js b/ext/bg/js/settings/dictionaries.js index 717d02cb..330e935a 100644 --- a/ext/bg/js/settings/dictionaries.js +++ b/ext/bg/js/settings/dictionaries.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Alex Yatskov + * Copyright (C) 2019-2020 Alex Yatskov * Author: Alex Yatskov * * This program is free software: you can redistribute it and/or modify diff --git a/ext/bg/js/settings/main.js b/ext/bg/js/settings/main.js index 3c7d6fce..70650d8b 100644 --- a/ext/bg/js/settings/main.js +++ b/ext/bg/js/settings/main.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016-2017 Alex Yatskov + * Copyright (C) 2016-2020 Alex Yatskov * Author: Alex Yatskov * * This program is free software: you can redistribute it and/or modify diff --git a/ext/bg/js/settings/popup-preview-frame.js b/ext/bg/js/settings/popup-preview-frame.js index 6d017275..7be3466d 100644 --- a/ext/bg/js/settings/popup-preview-frame.js +++ b/ext/bg/js/settings/popup-preview-frame.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Alex Yatskov + * Copyright (C) 2019-2020 Alex Yatskov * Author: Alex Yatskov * * This program is free software: you can redistribute it and/or modify diff --git a/ext/bg/js/settings/popup-preview.js b/ext/bg/js/settings/popup-preview.js index d8579eb1..ba0c979d 100644 --- a/ext/bg/js/settings/popup-preview.js +++ b/ext/bg/js/settings/popup-preview.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Alex Yatskov + * Copyright (C) 2019-2020 Alex Yatskov * Author: Alex Yatskov * * This program is free software: you can redistribute it and/or modify diff --git a/ext/bg/js/settings/profiles.js b/ext/bg/js/settings/profiles.js index 946d6944..61fe9bff 100644 --- a/ext/bg/js/settings/profiles.js +++ b/ext/bg/js/settings/profiles.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Alex Yatskov + * Copyright (C) 2019-2020 Alex Yatskov * Author: Alex Yatskov * * This program is free software: you can redistribute it and/or modify diff --git a/ext/bg/js/settings/storage.js b/ext/bg/js/settings/storage.js index 51ca6855..c040a041 100644 --- a/ext/bg/js/settings/storage.js +++ b/ext/bg/js/settings/storage.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 Alex Yatskov + * Copyright (C) 2019-2020 Alex Yatskov * Author: Alex Yatskov * * This program is free software: you can redistribute it and/or modify diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js index 0f3d0aa0..d6f62fd8 100644 --- a/ext/bg/js/translator.js +++ b/ext/bg/js/translator.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 Alex Yatskov + * Copyright (C) 2016-2020 Alex Yatskov * Author: Alex Yatskov * * This program is free software: you can redistribute it and/or modify diff --git a/ext/bg/js/util.js b/ext/bg/js/util.js index 4c989642..09c45c08 100644 --- a/ext/bg/js/util.js +++ b/ext/bg/js/util.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016-2017 Alex Yatskov + * Copyright (C) 2016-2020 Alex Yatskov * Author: Alex Yatskov * * This program is free software: you can redistribute it and/or modify diff --git a/ext/bg/legal.html b/ext/bg/legal.html index 082239d7..4c9029a0 100644 --- a/ext/bg/legal.html +++ b/ext/bg/legal.html @@ -17,7 +17,7 @@

Yomichan License

-Copyright (C) 2016-2019  Alex Yatskov
+Copyright (C) 2016-2020  Alex Yatskov
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
diff --git a/ext/fg/css/client.css b/ext/fg/css/client.css
index 633c88ef..6f52b676 100644
--- a/ext/fg/css/client.css
+++ b/ext/fg/css/client.css
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016  Alex Yatskov 
+ * Copyright (C) 2016-2020  Alex Yatskov 
  * Author: Alex Yatskov 
  *
  * This program is free software: you can redistribute it and/or modify
diff --git a/ext/fg/js/document.js b/ext/fg/js/document.js
index fa7e7cbc..d6ef5f29 100644
--- a/ext/fg/js/document.js
+++ b/ext/fg/js/document.js
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016-2017  Alex Yatskov 
+ * Copyright (C) 2016-2020  Alex Yatskov 
  * Author: Alex Yatskov 
  *
  * This program is free software: you can redistribute it and/or modify
diff --git a/ext/fg/js/float.js b/ext/fg/js/float.js
index 7375b68f..302bcda1 100644
--- a/ext/fg/js/float.js
+++ b/ext/fg/js/float.js
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016-2017  Alex Yatskov 
+ * Copyright (C) 2016-2020  Alex Yatskov 
  * Author: Alex Yatskov 
  *
  * This program is free software: you can redistribute it and/or modify
diff --git a/ext/fg/js/frontend-api-receiver.js b/ext/fg/js/frontend-api-receiver.js
index 8d5e52ee..72490f2c 100644
--- a/ext/fg/js/frontend-api-receiver.js
+++ b/ext/fg/js/frontend-api-receiver.js
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2019 Alex Yatskov 
+ * Copyright (C) 2019-2020  Alex Yatskov 
  * Author: Alex Yatskov 
  *
  * This program is free software: you can redistribute it and/or modify
diff --git a/ext/fg/js/frontend-api-sender.js b/ext/fg/js/frontend-api-sender.js
index b7c2c57c..b90310d6 100644
--- a/ext/fg/js/frontend-api-sender.js
+++ b/ext/fg/js/frontend-api-sender.js
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2019 Alex Yatskov 
+ * Copyright (C) 2019-2020  Alex Yatskov 
  * Author: Alex Yatskov 
  *
  * This program is free software: you can redistribute it and/or modify
diff --git a/ext/fg/js/frontend-initialize.js b/ext/fg/js/frontend-initialize.js
index c153b5b6..d819688f 100644
--- a/ext/fg/js/frontend-initialize.js
+++ b/ext/fg/js/frontend-initialize.js
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2019  Alex Yatskov 
+ * Copyright (C) 2019-2020  Alex Yatskov 
  * Author: Alex Yatskov 
  *
  * This program is free software: you can redistribute it and/or modify
diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js
index 6239a057..0ddcecf1 100644
--- a/ext/fg/js/frontend.js
+++ b/ext/fg/js/frontend.js
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016-2017  Alex Yatskov 
+ * Copyright (C) 2016-2020  Alex Yatskov 
  * Author: Alex Yatskov 
  *
  * This program is free software: you can redistribute it and/or modify
diff --git a/ext/fg/js/popup-nested.js b/ext/fg/js/popup-nested.js
index 3df469fe..df619141 100644
--- a/ext/fg/js/popup-nested.js
+++ b/ext/fg/js/popup-nested.js
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2019 Alex Yatskov 
+ * Copyright (C) 2019-2020  Alex Yatskov 
  * Author: Alex Yatskov 
  *
  * This program is free software: you can redistribute it and/or modify
diff --git a/ext/fg/js/popup-proxy-host.js b/ext/fg/js/popup-proxy-host.js
index e13d6f05..3cc8a132 100644
--- a/ext/fg/js/popup-proxy-host.js
+++ b/ext/fg/js/popup-proxy-host.js
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2019 Alex Yatskov 
+ * Copyright (C) 2019-2020  Alex Yatskov 
  * Author: Alex Yatskov 
  *
  * This program is free software: you can redistribute it and/or modify
diff --git a/ext/fg/js/popup-proxy.js b/ext/fg/js/popup-proxy.js
index 0e6a88a7..c29e9e55 100644
--- a/ext/fg/js/popup-proxy.js
+++ b/ext/fg/js/popup-proxy.js
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2019 Alex Yatskov 
+ * Copyright (C) 2019-2020  Alex Yatskov 
  * Author: Alex Yatskov 
  *
  * This program is free software: you can redistribute it and/or modify
diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js
index 4d00f629..5d445dba 100644
--- a/ext/fg/js/popup.js
+++ b/ext/fg/js/popup.js
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016-2017  Alex Yatskov 
+ * Copyright (C) 2016-2020  Alex Yatskov 
  * Author: Alex Yatskov 
  *
  * This program is free software: you can redistribute it and/or modify
diff --git a/ext/fg/js/source.js b/ext/fg/js/source.js
index a84feed4..cea6623d 100644
--- a/ext/fg/js/source.js
+++ b/ext/fg/js/source.js
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016-2017  Alex Yatskov 
+ * Copyright (C) 2016-2020  Alex Yatskov 
  * Author: Alex Yatskov 
  *
  * This program is free software: you can redistribute it and/or modify
diff --git a/ext/mixed/css/display-dark.css b/ext/mixed/css/display-dark.css
index 681d248c..236f36c4 100644
--- a/ext/mixed/css/display-dark.css
+++ b/ext/mixed/css/display-dark.css
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2019  Alex Yatskov 
+ * Copyright (C) 2019-2020  Alex Yatskov 
  * Author: Alex Yatskov 
  *
  * This program is free software: you can redistribute it and/or modify
diff --git a/ext/mixed/css/display-default.css b/ext/mixed/css/display-default.css
index add0a9c8..b563d831 100644
--- a/ext/mixed/css/display-default.css
+++ b/ext/mixed/css/display-default.css
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2019  Alex Yatskov 
+ * Copyright (C) 2019-2020  Alex Yatskov 
  * Author: Alex Yatskov 
  *
  * This program is free software: you can redistribute it and/or modify
diff --git a/ext/mixed/css/display.css b/ext/mixed/css/display.css
index 70fffdc1..5a7cbf5d 100644
--- a/ext/mixed/css/display.css
+++ b/ext/mixed/css/display.css
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016  Alex Yatskov 
+ * Copyright (C) 2016-2020  Alex Yatskov 
  * Author: Alex Yatskov 
  *
  * This program is free software: you can redistribute it and/or modify
diff --git a/ext/mixed/js/api.js b/ext/mixed/js/api.js
index dc901efc..c801baa3 100644
--- a/ext/mixed/js/api.js
+++ b/ext/mixed/js/api.js
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016-2017  Alex Yatskov 
+ * Copyright (C) 2016-2020  Alex Yatskov 
  * Author: Alex Yatskov 
  *
  * This program is free software: you can redistribute it and/or modify
diff --git a/ext/mixed/js/audio.js b/ext/mixed/js/audio.js
index 35f283a4..d9a72a12 100644
--- a/ext/mixed/js/audio.js
+++ b/ext/mixed/js/audio.js
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2019  Alex Yatskov 
+ * Copyright (C) 2019-2020  Alex Yatskov 
  * Author: Alex Yatskov 
  *
  * This program is free software: you can redistribute it and/or modify
diff --git a/ext/mixed/js/core.js b/ext/mixed/js/core.js
index 5e560a58..9e2b419e 100644
--- a/ext/mixed/js/core.js
+++ b/ext/mixed/js/core.js
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2019  Alex Yatskov 
+ * Copyright (C) 2019-2020  Alex Yatskov 
  * Author: Alex Yatskov 
  *
  * This program is free software: you can redistribute it and/or modify
diff --git a/ext/mixed/js/display-context.js b/ext/mixed/js/display-context.js
index 4b399881..45c2a823 100644
--- a/ext/mixed/js/display-context.js
+++ b/ext/mixed/js/display-context.js
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2019  Alex Yatskov 
+ * Copyright (C) 2019-2020  Alex Yatskov 
  * Author: Alex Yatskov 
  *
  * This program is free software: you can redistribute it and/or modify
diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js
index 089941a9..513d2596 100644
--- a/ext/mixed/js/display.js
+++ b/ext/mixed/js/display.js
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017  Alex Yatskov 
+ * Copyright (C) 2017-2020  Alex Yatskov 
  * Author: Alex Yatskov 
  *
  * This program is free software: you can redistribute it and/or modify
diff --git a/ext/mixed/js/dom.js b/ext/mixed/js/dom.js
index 4e4d49e3..87448b89 100644
--- a/ext/mixed/js/dom.js
+++ b/ext/mixed/js/dom.js
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2019  Alex Yatskov 
+ * Copyright (C) 2019-2020  Alex Yatskov 
  * Author: Alex Yatskov 
  *
  * This program is free software: you can redistribute it and/or modify
diff --git a/ext/mixed/js/japanese.js b/ext/mixed/js/japanese.js
index ea1c0065..b046019c 100644
--- a/ext/mixed/js/japanese.js
+++ b/ext/mixed/js/japanese.js
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016  Alex Yatskov 
+ * Copyright (C) 2016-2020  Alex Yatskov 
  * Author: Alex Yatskov 
  *
  * This program is free software: you can redistribute it and/or modify
diff --git a/ext/mixed/js/scroll.js b/ext/mixed/js/scroll.js
index 824fd92b..869f0945 100644
--- a/ext/mixed/js/scroll.js
+++ b/ext/mixed/js/scroll.js
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2019  Alex Yatskov 
+ * Copyright (C) 2019-2020  Alex Yatskov 
  * Author: Alex Yatskov 
  *
  * This program is free software: you can redistribute it and/or modify
diff --git a/ext/mixed/js/text-scanner.js b/ext/mixed/js/text-scanner.js
index 9a739c7e..455c756f 100644
--- a/ext/mixed/js/text-scanner.js
+++ b/ext/mixed/js/text-scanner.js
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2019  Alex Yatskov 
+ * Copyright (C) 2019-2020  Alex Yatskov 
  * Author: Alex Yatskov 
  *
  * This program is free software: you can redistribute it and/or modify
diff --git a/ext/mixed/js/timer.js b/ext/mixed/js/timer.js
index 87ab62a7..bfa2e087 100644
--- a/ext/mixed/js/timer.js
+++ b/ext/mixed/js/timer.js
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2019  Alex Yatskov 
+ * Copyright (C) 2019-2020  Alex Yatskov 
  * Author: Alex Yatskov 
  *
  * This program is free software: you can redistribute it and/or modify
-- 
cgit v1.2.3


From 0d7ccf25b88abc414358e7cb435a227d43ba548f Mon Sep 17 00:00:00 2001
From: toasted-nutbread 
Date: Wed, 1 Jan 2020 12:00:31 -0500
Subject: Update license info URL

---
 LICENSE                                   | 2 +-
 ext/bg/css/settings.css                   | 2 +-
 ext/bg/js/anki.js                         | 2 +-
 ext/bg/js/api.js                          | 2 +-
 ext/bg/js/audio.js                        | 2 +-
 ext/bg/js/backend-api-forwarder.js        | 2 +-
 ext/bg/js/backend.js                      | 2 +-
 ext/bg/js/conditions.js                   | 2 +-
 ext/bg/js/context.js                      | 2 +-
 ext/bg/js/database.js                     | 2 +-
 ext/bg/js/deinflector.js                  | 2 +-
 ext/bg/js/dictionary.js                   | 2 +-
 ext/bg/js/handlebars.js                   | 2 +-
 ext/bg/js/json-schema.js                  | 2 +-
 ext/bg/js/mecab.js                        | 2 +-
 ext/bg/js/options.js                      | 2 +-
 ext/bg/js/page-exit-prevention.js         | 2 +-
 ext/bg/js/profile-conditions.js           | 2 +-
 ext/bg/js/request.js                      | 2 +-
 ext/bg/js/search-frontend.js              | 2 +-
 ext/bg/js/search-query-parser.js          | 2 +-
 ext/bg/js/search.js                       | 2 +-
 ext/bg/js/settings/anki-templates.js      | 2 +-
 ext/bg/js/settings/anki.js                | 2 +-
 ext/bg/js/settings/audio-ui.js            | 2 +-
 ext/bg/js/settings/audio.js               | 2 +-
 ext/bg/js/settings/backup.js              | 2 +-
 ext/bg/js/settings/conditions-ui.js       | 2 +-
 ext/bg/js/settings/dictionaries.js        | 2 +-
 ext/bg/js/settings/main.js                | 2 +-
 ext/bg/js/settings/popup-preview-frame.js | 2 +-
 ext/bg/js/settings/popup-preview.js       | 2 +-
 ext/bg/js/settings/profiles.js            | 2 +-
 ext/bg/js/settings/storage.js             | 2 +-
 ext/bg/js/translator.js                   | 2 +-
 ext/bg/js/util.js                         | 2 +-
 ext/bg/legal.html                         | 2 +-
 ext/fg/css/client.css                     | 2 +-
 ext/fg/js/document.js                     | 2 +-
 ext/fg/js/float.js                        | 2 +-
 ext/fg/js/frontend-api-receiver.js        | 2 +-
 ext/fg/js/frontend-api-sender.js          | 2 +-
 ext/fg/js/frontend-initialize.js          | 2 +-
 ext/fg/js/frontend.js                     | 2 +-
 ext/fg/js/popup-nested.js                 | 2 +-
 ext/fg/js/popup-proxy-host.js             | 2 +-
 ext/fg/js/popup-proxy.js                  | 2 +-
 ext/fg/js/popup.js                        | 2 +-
 ext/fg/js/source.js                       | 2 +-
 ext/mixed/css/display-dark.css            | 2 +-
 ext/mixed/css/display-default.css         | 2 +-
 ext/mixed/css/display.css                 | 2 +-
 ext/mixed/js/api.js                       | 2 +-
 ext/mixed/js/audio.js                     | 2 +-
 ext/mixed/js/core.js                      | 2 +-
 ext/mixed/js/display-context.js           | 2 +-
 ext/mixed/js/display.js                   | 2 +-
 ext/mixed/js/dom.js                       | 2 +-
 ext/mixed/js/japanese.js                  | 2 +-
 ext/mixed/js/scroll.js                    | 2 +-
 ext/mixed/js/text-scanner.js              | 2 +-
 ext/mixed/js/timer.js                     | 2 +-
 62 files changed, 62 insertions(+), 62 deletions(-)

(limited to 'ext/mixed')

diff --git a/LICENSE b/LICENSE
index 266e6069..f8531a9f 100644
--- a/LICENSE
+++ b/LICENSE
@@ -11,4 +11,4 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
-along with this program.  If not, see .
+along with this program.  If not, see .
diff --git a/ext/bg/css/settings.css b/ext/bg/css/settings.css
index ee9d18a1..63cead6b 100644
--- a/ext/bg/css/settings.css
+++ b/ext/bg/css/settings.css
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/bg/js/anki.js b/ext/bg/js/anki.js
index 48ed66bf..10a07061 100644
--- a/ext/bg/js/anki.js
+++ b/ext/bg/js/anki.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/bg/js/api.js b/ext/bg/js/api.js
index 8ad8d0bb..906aaa30 100644
--- a/ext/bg/js/api.js
+++ b/ext/bg/js/api.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/bg/js/audio.js b/ext/bg/js/audio.js
index 0fc2148d..36ac413b 100644
--- a/ext/bg/js/audio.js
+++ b/ext/bg/js/audio.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/bg/js/backend-api-forwarder.js b/ext/bg/js/backend-api-forwarder.js
index 0a387e08..170a6b32 100644
--- a/ext/bg/js/backend-api-forwarder.js
+++ b/ext/bg/js/backend-api-forwarder.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js
index 2060f414..28b0201e 100644
--- a/ext/bg/js/backend.js
+++ b/ext/bg/js/backend.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/bg/js/conditions.js b/ext/bg/js/conditions.js
index d3d0b465..d4d1c0e0 100644
--- a/ext/bg/js/conditions.js
+++ b/ext/bg/js/conditions.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/bg/js/context.js b/ext/bg/js/context.js
index 84368256..834174bf 100644
--- a/ext/bg/js/context.js
+++ b/ext/bg/js/context.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/bg/js/database.js b/ext/bg/js/database.js
index 9c44f240..42a143f3 100644
--- a/ext/bg/js/database.js
+++ b/ext/bg/js/database.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/bg/js/deinflector.js b/ext/bg/js/deinflector.js
index 752a0959..33b2a8b3 100644
--- a/ext/bg/js/deinflector.js
+++ b/ext/bg/js/deinflector.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js
index 43971f8a..92adc532 100644
--- a/ext/bg/js/dictionary.js
+++ b/ext/bg/js/dictionary.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/bg/js/handlebars.js b/ext/bg/js/handlebars.js
index 7e4b7b8d..6d1581be 100644
--- a/ext/bg/js/handlebars.js
+++ b/ext/bg/js/handlebars.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/bg/js/json-schema.js b/ext/bg/js/json-schema.js
index d56f8ef9..5d596a8b 100644
--- a/ext/bg/js/json-schema.js
+++ b/ext/bg/js/json-schema.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/bg/js/mecab.js b/ext/bg/js/mecab.js
index 33f9949e..8bcbb91c 100644
--- a/ext/bg/js/mecab.js
+++ b/ext/bg/js/mecab.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js
index 63e7c023..8021672b 100644
--- a/ext/bg/js/options.js
+++ b/ext/bg/js/options.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/bg/js/page-exit-prevention.js b/ext/bg/js/page-exit-prevention.js
index 4143a835..3a320db3 100644
--- a/ext/bg/js/page-exit-prevention.js
+++ b/ext/bg/js/page-exit-prevention.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/bg/js/profile-conditions.js b/ext/bg/js/profile-conditions.js
index 20350f4b..1fd78e5d 100644
--- a/ext/bg/js/profile-conditions.js
+++ b/ext/bg/js/profile-conditions.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/bg/js/request.js b/ext/bg/js/request.js
index 6d05f66e..b584c9a9 100644
--- a/ext/bg/js/request.js
+++ b/ext/bg/js/request.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/bg/js/search-frontend.js b/ext/bg/js/search-frontend.js
index 2cf7f5a7..2fe50a13 100644
--- a/ext/bg/js/search-frontend.js
+++ b/ext/bg/js/search-frontend.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/bg/js/search-query-parser.js b/ext/bg/js/search-query-parser.js
index fec21d3b..0b3eccbd 100644
--- a/ext/bg/js/search-query-parser.js
+++ b/ext/bg/js/search-query-parser.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js
index 439cde40..a4103ef2 100644
--- a/ext/bg/js/search.js
+++ b/ext/bg/js/search.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 class DisplaySearch extends Display {
diff --git a/ext/bg/js/settings/anki-templates.js b/ext/bg/js/settings/anki-templates.js
index 4644214b..5e74358f 100644
--- a/ext/bg/js/settings/anki-templates.js
+++ b/ext/bg/js/settings/anki-templates.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/bg/js/settings/anki.js b/ext/bg/js/settings/anki.js
index ccce16fe..5f7989b8 100644
--- a/ext/bg/js/settings/anki.js
+++ b/ext/bg/js/settings/anki.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/bg/js/settings/audio-ui.js b/ext/bg/js/settings/audio-ui.js
index dc968628..711c2291 100644
--- a/ext/bg/js/settings/audio-ui.js
+++ b/ext/bg/js/settings/audio-ui.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/bg/js/settings/audio.js b/ext/bg/js/settings/audio.js
index 5809375c..cff3f521 100644
--- a/ext/bg/js/settings/audio.js
+++ b/ext/bg/js/settings/audio.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/bg/js/settings/backup.js b/ext/bg/js/settings/backup.js
index 3a4d1fd2..becdc568 100644
--- a/ext/bg/js/settings/backup.js
+++ b/ext/bg/js/settings/backup.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/bg/js/settings/conditions-ui.js b/ext/bg/js/settings/conditions-ui.js
index a186a5be..4d041451 100644
--- a/ext/bg/js/settings/conditions-ui.js
+++ b/ext/bg/js/settings/conditions-ui.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/bg/js/settings/dictionaries.js b/ext/bg/js/settings/dictionaries.js
index 330e935a..ed171ae9 100644
--- a/ext/bg/js/settings/dictionaries.js
+++ b/ext/bg/js/settings/dictionaries.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/bg/js/settings/main.js b/ext/bg/js/settings/main.js
index 70650d8b..56828a15 100644
--- a/ext/bg/js/settings/main.js
+++ b/ext/bg/js/settings/main.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 function getOptionsMutable(optionsContext) {
diff --git a/ext/bg/js/settings/popup-preview-frame.js b/ext/bg/js/settings/popup-preview-frame.js
index 7be3466d..2b727cbd 100644
--- a/ext/bg/js/settings/popup-preview-frame.js
+++ b/ext/bg/js/settings/popup-preview-frame.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/bg/js/settings/popup-preview.js b/ext/bg/js/settings/popup-preview.js
index ba0c979d..0d20471e 100644
--- a/ext/bg/js/settings/popup-preview.js
+++ b/ext/bg/js/settings/popup-preview.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/bg/js/settings/profiles.js b/ext/bg/js/settings/profiles.js
index 61fe9bff..c4e68b53 100644
--- a/ext/bg/js/settings/profiles.js
+++ b/ext/bg/js/settings/profiles.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 let currentProfileIndex = 0;
diff --git a/ext/bg/js/settings/storage.js b/ext/bg/js/settings/storage.js
index c040a041..6c10f665 100644
--- a/ext/bg/js/settings/storage.js
+++ b/ext/bg/js/settings/storage.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js
index d6f62fd8..7473c6ad 100644
--- a/ext/bg/js/translator.js
+++ b/ext/bg/js/translator.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/bg/js/util.js b/ext/bg/js/util.js
index 09c45c08..333e814b 100644
--- a/ext/bg/js/util.js
+++ b/ext/bg/js/util.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 function utilIsolate(value) {
diff --git a/ext/bg/legal.html b/ext/bg/legal.html
index 4c9029a0..c1e606d7 100644
--- a/ext/bg/legal.html
+++ b/ext/bg/legal.html
@@ -30,7 +30,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
+along with this program.  If not, see <https://www.gnu.org/licenses/>.
 

EDRDG License

diff --git a/ext/fg/css/client.css b/ext/fg/css/client.css
index 6f52b676..b9c59da7 100644
--- a/ext/fg/css/client.css
+++ b/ext/fg/css/client.css
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/fg/js/document.js b/ext/fg/js/document.js
index d6ef5f29..e068e3ba 100644
--- a/ext/fg/js/document.js
+++ b/ext/fg/js/document.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/fg/js/float.js b/ext/fg/js/float.js
index 302bcda1..513d246b 100644
--- a/ext/fg/js/float.js
+++ b/ext/fg/js/float.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/fg/js/frontend-api-receiver.js b/ext/fg/js/frontend-api-receiver.js
index 72490f2c..642d96df 100644
--- a/ext/fg/js/frontend-api-receiver.js
+++ b/ext/fg/js/frontend-api-receiver.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/fg/js/frontend-api-sender.js b/ext/fg/js/frontend-api-sender.js
index b90310d6..93c2e593 100644
--- a/ext/fg/js/frontend-api-sender.js
+++ b/ext/fg/js/frontend-api-sender.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/fg/js/frontend-initialize.js b/ext/fg/js/frontend-initialize.js
index d819688f..9c923fea 100644
--- a/ext/fg/js/frontend-initialize.js
+++ b/ext/fg/js/frontend-initialize.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js
index 0ddcecf1..034d9075 100644
--- a/ext/fg/js/frontend.js
+++ b/ext/fg/js/frontend.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/fg/js/popup-nested.js b/ext/fg/js/popup-nested.js
index df619141..bacf3b93 100644
--- a/ext/fg/js/popup-nested.js
+++ b/ext/fg/js/popup-nested.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/fg/js/popup-proxy-host.js b/ext/fg/js/popup-proxy-host.js
index 3cc8a132..c4f0c6ff 100644
--- a/ext/fg/js/popup-proxy-host.js
+++ b/ext/fg/js/popup-proxy-host.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/fg/js/popup-proxy.js b/ext/fg/js/popup-proxy.js
index c29e9e55..ae0cffad 100644
--- a/ext/fg/js/popup-proxy.js
+++ b/ext/fg/js/popup-proxy.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js
index 5d445dba..7a0c6133 100644
--- a/ext/fg/js/popup.js
+++ b/ext/fg/js/popup.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/fg/js/source.js b/ext/fg/js/source.js
index cea6623d..5cdf47b5 100644
--- a/ext/fg/js/source.js
+++ b/ext/fg/js/source.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 // \u200c (Zero-width non-joiner) appears on Google Docs from Chrome 76 onwards
diff --git a/ext/mixed/css/display-dark.css b/ext/mixed/css/display-dark.css
index 236f36c4..e26c72aa 100644
--- a/ext/mixed/css/display-dark.css
+++ b/ext/mixed/css/display-dark.css
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/mixed/css/display-default.css b/ext/mixed/css/display-default.css
index b563d831..ac237e79 100644
--- a/ext/mixed/css/display-default.css
+++ b/ext/mixed/css/display-default.css
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/mixed/css/display.css b/ext/mixed/css/display.css
index 5a7cbf5d..7a00bccb 100644
--- a/ext/mixed/css/display.css
+++ b/ext/mixed/css/display.css
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/mixed/js/api.js b/ext/mixed/js/api.js
index c801baa3..8ed1d996 100644
--- a/ext/mixed/js/api.js
+++ b/ext/mixed/js/api.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/mixed/js/audio.js b/ext/mixed/js/audio.js
index d9a72a12..b0c5fa82 100644
--- a/ext/mixed/js/audio.js
+++ b/ext/mixed/js/audio.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/mixed/js/core.js b/ext/mixed/js/core.js
index 9e2b419e..54e8a9d2 100644
--- a/ext/mixed/js/core.js
+++ b/ext/mixed/js/core.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/mixed/js/display-context.js b/ext/mixed/js/display-context.js
index 45c2a823..c11c2342 100644
--- a/ext/mixed/js/display-context.js
+++ b/ext/mixed/js/display-context.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js
index 513d2596..e756f948 100644
--- a/ext/mixed/js/display.js
+++ b/ext/mixed/js/display.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/mixed/js/dom.js b/ext/mixed/js/dom.js
index 87448b89..807a48e1 100644
--- a/ext/mixed/js/dom.js
+++ b/ext/mixed/js/dom.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/mixed/js/japanese.js b/ext/mixed/js/japanese.js
index b046019c..23b2bd36 100644
--- a/ext/mixed/js/japanese.js
+++ b/ext/mixed/js/japanese.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/mixed/js/scroll.js b/ext/mixed/js/scroll.js
index 869f0945..5829d294 100644
--- a/ext/mixed/js/scroll.js
+++ b/ext/mixed/js/scroll.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/mixed/js/text-scanner.js b/ext/mixed/js/text-scanner.js
index 455c756f..a05dd2ee 100644
--- a/ext/mixed/js/text-scanner.js
+++ b/ext/mixed/js/text-scanner.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
diff --git a/ext/mixed/js/timer.js b/ext/mixed/js/timer.js
index bfa2e087..1caf7a05 100644
--- a/ext/mixed/js/timer.js
+++ b/ext/mixed/js/timer.js
@@ -13,7 +13,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see .
+ * along with this program.  If not, see .
  */
 
 
-- 
cgit v1.2.3