summaryrefslogtreecommitdiff
path: root/ext/js/display
diff options
context:
space:
mode:
authorDarius Jahandarie <djahandarie@gmail.com>2023-11-09 13:30:31 +0000
committerGitHub <noreply@github.com>2023-11-09 13:30:31 +0000
commit5c5a167b4792af379cdacf633513cebf20728cd2 (patch)
tree5b6be3620a557d0b9177047003f6d742d9d2a32d /ext/js/display
parentb64f51c3b13a46af4dd7f1e43048ac19c781ca7b (diff)
parent0f4d36938fd0d844f548aa5a7f7e7842df8dfb41 (diff)
Merge pull request #307 from themoeway/modernize
Modernize codebase
Diffstat (limited to 'ext/js/display')
-rw-r--r--ext/js/display/display-anki.js12
-rw-r--r--ext/js/display/display-audio.js7
-rw-r--r--ext/js/display/display-content-manager.js8
-rw-r--r--ext/js/display/display-generator.js16
-rw-r--r--ext/js/display/display-history.js4
-rw-r--r--ext/js/display/display-notification.js4
-rw-r--r--ext/js/display/display-profile-selection.js8
-rw-r--r--ext/js/display/display-resizer.js4
-rw-r--r--ext/js/display/display.js40
-rw-r--r--ext/js/display/element-overflow-controller.js4
-rw-r--r--ext/js/display/option-toggle-hotkey-handler.js5
-rw-r--r--ext/js/display/popup-main.js11
-rw-r--r--ext/js/display/query-parser.js8
-rw-r--r--ext/js/display/sandbox/pronunciation-generator.js2
-rw-r--r--ext/js/display/sandbox/structured-content-generator.js2
-rw-r--r--ext/js/display/search-action-popup-controller.js2
-rw-r--r--ext/js/display/search-display-controller.js10
-rw-r--r--ext/js/display/search-main.js24
-rw-r--r--ext/js/display/search-persistent-state-controller.js4
19 files changed, 102 insertions, 73 deletions
diff --git a/ext/js/display/display-anki.js b/ext/js/display/display-anki.js
index 9a1aae23..a25008a2 100644
--- a/ext/js/display/display-anki.js
+++ b/ext/js/display/display-anki.js
@@ -16,13 +16,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-/* global
- * AnkiNoteBuilder
- * AnkiUtil
- * PopupMenu
- */
+import {EventListenerCollection, deferPromise, isObject} from '../core.js';
+import {AnkiNoteBuilder} from '../data/anki-note-builder.js';
+import {AnkiUtil} from '../data/anki-util.js';
+import {PopupMenu} from '../dom/popup-menu.js';
+import {yomichan} from '../yomichan.js';
-class DisplayAnki {
+export class DisplayAnki {
constructor(display, displayAudio, japaneseUtil) {
this._display = display;
this._displayAudio = displayAudio;
diff --git a/ext/js/display/display-audio.js b/ext/js/display/display-audio.js
index c0b3859d..6ab5773f 100644
--- a/ext/js/display/display-audio.js
+++ b/ext/js/display/display-audio.js
@@ -16,12 +16,17 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
+import {EventListenerCollection} from '../core.js';
+import {PopupMenu} from '../dom/popup-menu.js';
+import {AudioSystem} from '../media/audio-system.js';
+import {yomichan} from '../yomichan.js';
+
/* global
* AudioSystem
* PopupMenu
*/
-class DisplayAudio {
+export class DisplayAudio {
constructor(display) {
this._display = display;
this._audioPlaying = null;
diff --git a/ext/js/display/display-content-manager.js b/ext/js/display/display-content-manager.js
index 2abff98a..6cba1783 100644
--- a/ext/js/display/display-content-manager.js
+++ b/ext/js/display/display-content-manager.js
@@ -16,9 +16,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-/* global
- * ArrayBufferUtil
- */
+import {EventListenerCollection} from '../core.js';
+import {ArrayBufferUtil} from '../data/sandbox/array-buffer-util.js';
+import {yomichan} from '../yomichan.js';
/**
* A callback used when a media file has been loaded.
@@ -35,7 +35,7 @@
/**
* The content manager which is used when generating HTML display content.
*/
-class DisplayContentManager {
+export class DisplayContentManager {
/**
* Creates a new instance of the class.
* @param {Display} display The display instance that owns this object.
diff --git a/ext/js/display/display-generator.js b/ext/js/display/display-generator.js
index 293cb725..25df9745 100644
--- a/ext/js/display/display-generator.js
+++ b/ext/js/display/display-generator.js
@@ -16,14 +16,14 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-/* global
- * DictionaryDataUtil
- * HtmlTemplateCollection
- * PronunciationGenerator
- * StructuredContentGenerator
- */
-
-class DisplayGenerator {
+import {isObject} from '../core.js';
+import {HtmlTemplateCollection} from '../dom/html-template-collection.js';
+import {DictionaryDataUtil} from '../language/sandbox/dictionary-data-util.js';
+import {yomichan} from '../yomichan.js';
+import {PronunciationGenerator} from './sandbox/pronunciation-generator.js';
+import {StructuredContentGenerator} from './sandbox/structured-content-generator.js';
+
+export class DisplayGenerator {
constructor({japaneseUtil, contentManager, hotkeyHelpController=null}) {
this._japaneseUtil = japaneseUtil;
this._contentManager = contentManager;
diff --git a/ext/js/display/display-history.js b/ext/js/display/display-history.js
index 71882ca3..a983346c 100644
--- a/ext/js/display/display-history.js
+++ b/ext/js/display/display-history.js
@@ -16,7 +16,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-class DisplayHistory extends EventDispatcher {
+import {EventDispatcher, generateId, isObject} from '../core.js';
+
+export class DisplayHistory extends EventDispatcher {
constructor({clearable=true, useBrowserHistory=false}) {
super();
this._clearable = clearable;
diff --git a/ext/js/display/display-notification.js b/ext/js/display/display-notification.js
index d5c77b04..0c26c613 100644
--- a/ext/js/display/display-notification.js
+++ b/ext/js/display/display-notification.js
@@ -16,7 +16,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-class DisplayNotification {
+import {EventListenerCollection} from '../core.js';
+
+export class DisplayNotification {
constructor(container, node) {
this._container = container;
this._node = node;
diff --git a/ext/js/display/display-profile-selection.js b/ext/js/display/display-profile-selection.js
index b14b4d8b..c0b642e8 100644
--- a/ext/js/display/display-profile-selection.js
+++ b/ext/js/display/display-profile-selection.js
@@ -16,11 +16,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-/* global
- * PanelElement
- */
+import {EventListenerCollection, generateId} from '../core.js';
+import {PanelElement} from '../dom/panel-element.js';
+import {yomichan} from '../yomichan.js';
-class DisplayProfileSelection {
+export class DisplayProfileSelection {
constructor(display) {
this._display = display;
this._profielList = document.querySelector('#profile-list');
diff --git a/ext/js/display/display-resizer.js b/ext/js/display/display-resizer.js
index 1356c0a7..2925561f 100644
--- a/ext/js/display/display-resizer.js
+++ b/ext/js/display/display-resizer.js
@@ -16,7 +16,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-class DisplayResizer {
+import {EventListenerCollection} from '../core.js';
+
+export class DisplayResizer {
constructor(display) {
this._display = display;
this._token = null;
diff --git a/ext/js/display/display.js b/ext/js/display/display.js
index 693bd201..b86b877d 100644
--- a/ext/js/display/display.js
+++ b/ext/js/display/display.js
@@ -16,26 +16,26 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-/* global
- * DisplayContentManager
- * DisplayGenerator
- * DisplayHistory
- * DisplayNotification
- * ElementOverflowController
- * FrameEndpoint
- * Frontend
- * HotkeyHelpController
- * OptionToggleHotkeyHandler
- * PopupFactory
- * PopupMenu
- * QueryParser
- * ScrollElement
- * TextScanner
- * ThemeController
- * dynamicLoader
- */
-
-class Display extends EventDispatcher {
+import {Frontend} from '../app/frontend.js';
+import {PopupFactory} from '../app/popup-factory.js';
+import {ThemeController} from '../app/theme-controller.js';
+import {FrameEndpoint} from '../comm/frame-endpoint.js';
+import {DynamicProperty, EventDispatcher, EventListenerCollection, clone, deepEqual, invokeMessageHandler, isObject, log, promiseTimeout} from '../core.js';
+import {PopupMenu} from '../dom/popup-menu.js';
+import {ScrollElement} from '../dom/scroll-element.js';
+import {HotkeyHelpController} from '../input/hotkey-help-controller.js';
+import {TextScanner} from '../language/text-scanner.js';
+import {dynamicLoader} from '../script/dynamic-loader.js';
+import {yomichan} from '../yomichan.js';
+import {DisplayContentManager} from './display-content-manager.js';
+import {DisplayGenerator} from './display-generator.js';
+import {DisplayHistory} from './display-history.js';
+import {DisplayNotification} from './display-notification.js';
+import {ElementOverflowController} from './element-overflow-controller.js';
+import {OptionToggleHotkeyHandler} from './option-toggle-hotkey-handler.js';
+import {QueryParser} from './query-parser.js';
+
+export class Display extends EventDispatcher {
/**
* Information about how popup content should be shown, specifically related to the inner popup content.
* @typedef {object} ContentDetails
diff --git a/ext/js/display/element-overflow-controller.js b/ext/js/display/element-overflow-controller.js
index 9fb3d26f..0a62906b 100644
--- a/ext/js/display/element-overflow-controller.js
+++ b/ext/js/display/element-overflow-controller.js
@@ -16,7 +16,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-class ElementOverflowController {
+import {EventListenerCollection} from '../core.js';
+
+export class ElementOverflowController {
constructor() {
this._elements = [];
this._checkTimer = null;
diff --git a/ext/js/display/option-toggle-hotkey-handler.js b/ext/js/display/option-toggle-hotkey-handler.js
index 251e03fa..360b0894 100644
--- a/ext/js/display/option-toggle-hotkey-handler.js
+++ b/ext/js/display/option-toggle-hotkey-handler.js
@@ -16,7 +16,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-class OptionToggleHotkeyHandler {
+import {deserializeError} from '../core.js';
+import {yomichan} from '../yomichan.js';
+
+export class OptionToggleHotkeyHandler {
constructor(display) {
this._display = display;
this._notification = null;
diff --git a/ext/js/display/popup-main.js b/ext/js/display/popup-main.js
index 4d7c8c86..0599b736 100644
--- a/ext/js/display/popup-main.js
+++ b/ext/js/display/popup-main.js
@@ -16,6 +16,17 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
+import {log} from '../core.js';
+import {DocumentFocusController} from '../dom/document-focus-controller.js';
+import {HotkeyHandler} from '../input/hotkey-handler.js';
+import {JapaneseUtil} from '../language/sandbox/japanese-util.js';
+import {yomichan} from '../yomichan.js';
+import {DisplayAnki} from './display-anki.js';
+import {DisplayAudio} from './display-audio.js';
+import {DisplayProfileSelection} from './display-profile-selection.js';
+import {DisplayResizer} from './display-resizer.js';
+import {Display} from './display.js';
+
/* global
* Display
* DisplayAnki
diff --git a/ext/js/display/query-parser.js b/ext/js/display/query-parser.js
index 205be579..6eee55b2 100644
--- a/ext/js/display/query-parser.js
+++ b/ext/js/display/query-parser.js
@@ -16,11 +16,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-/* global
- * TextScanner
- */
+import {EventDispatcher, log} from '../core.js';
+import {TextScanner} from '../language/text-scanner.js';
+import {yomichan} from '../yomichan.js';
-class QueryParser extends EventDispatcher {
+export class QueryParser extends EventDispatcher {
constructor({getSearchContext, japaneseUtil}) {
super();
this._getSearchContext = getSearchContext;
diff --git a/ext/js/display/sandbox/pronunciation-generator.js b/ext/js/display/sandbox/pronunciation-generator.js
index 027771f6..76d5e2b1 100644
--- a/ext/js/display/sandbox/pronunciation-generator.js
+++ b/ext/js/display/sandbox/pronunciation-generator.js
@@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-class PronunciationGenerator {
+export class PronunciationGenerator {
constructor(japaneseUtil) {
this._japaneseUtil = japaneseUtil;
}
diff --git a/ext/js/display/sandbox/structured-content-generator.js b/ext/js/display/sandbox/structured-content-generator.js
index 2d3a620d..227892d6 100644
--- a/ext/js/display/sandbox/structured-content-generator.js
+++ b/ext/js/display/sandbox/structured-content-generator.js
@@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-class StructuredContentGenerator {
+export class StructuredContentGenerator {
constructor(contentManager, japaneseUtil, document) {
this._contentManager = contentManager;
this._japaneseUtil = japaneseUtil;
diff --git a/ext/js/display/search-action-popup-controller.js b/ext/js/display/search-action-popup-controller.js
index e29ac0f4..e8fb9f1b 100644
--- a/ext/js/display/search-action-popup-controller.js
+++ b/ext/js/display/search-action-popup-controller.js
@@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-class SearchActionPopupController {
+export class SearchActionPopupController {
constructor(searchPersistentStateController) {
this._searchPersistentStateController = searchPersistentStateController;
}
diff --git a/ext/js/display/search-display-controller.js b/ext/js/display/search-display-controller.js
index 5a271e05..9e190c85 100644
--- a/ext/js/display/search-display-controller.js
+++ b/ext/js/display/search-display-controller.js
@@ -16,12 +16,12 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-/* global
- * ClipboardMonitor
- * wanakana
- */
+import * as wanakana from '../../lib/wanakana.js';
+import {ClipboardMonitor} from '../comm/clipboard-monitor.js';
+import {EventListenerCollection, invokeMessageHandler} from '../core.js';
+import {yomichan} from '../yomichan.js';
-class SearchDisplayController {
+export class SearchDisplayController {
constructor(tabId, frameId, display, displayAudio, japaneseUtil, searchPersistentStateController) {
this._tabId = tabId;
this._frameId = frameId;
diff --git a/ext/js/display/search-main.js b/ext/js/display/search-main.js
index 77b96804..67552229 100644
--- a/ext/js/display/search-main.js
+++ b/ext/js/display/search-main.js
@@ -16,18 +16,18 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-/* global
- * Display
- * DisplayAnki
- * DisplayAudio
- * DocumentFocusController
- * HotkeyHandler
- * JapaneseUtil
- * SearchActionPopupController
- * SearchDisplayController
- * SearchPersistentStateController
- * wanakana
- */
+import * as wanakana from '../../lib/wanakana.js';
+import {log} from '../core.js';
+import {DocumentFocusController} from '../dom/document-focus-controller.js';
+import {HotkeyHandler} from '../input/hotkey-handler.js';
+import {JapaneseUtil} from '../language/sandbox/japanese-util.js';
+import {yomichan} from '../yomichan.js';
+import {DisplayAnki} from './display-anki.js';
+import {DisplayAudio} from './display-audio.js';
+import {Display} from './display.js';
+import {SearchActionPopupController} from './search-action-popup-controller.js';
+import {SearchDisplayController} from './search-display-controller.js';
+import {SearchPersistentStateController} from './search-persistent-state-controller.js';
(async () => {
try {
diff --git a/ext/js/display/search-persistent-state-controller.js b/ext/js/display/search-persistent-state-controller.js
index 2b651ffa..60155143 100644
--- a/ext/js/display/search-persistent-state-controller.js
+++ b/ext/js/display/search-persistent-state-controller.js
@@ -16,7 +16,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-class SearchPersistentStateController extends EventDispatcher {
+import {EventDispatcher} from '../core.js';
+
+export class SearchPersistentStateController extends EventDispatcher {
constructor() {
super();
this._mode = null;