aboutsummaryrefslogtreecommitdiff
path: root/src/content/Application.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/Application.ts')
-rw-r--r--src/content/Application.ts126
1 files changed, 62 insertions, 64 deletions
diff --git a/src/content/Application.ts b/src/content/Application.ts
index fbfeb6d..996bbbc 100644
--- a/src/content/Application.ts
+++ b/src/content/Application.ts
@@ -1,25 +1,24 @@
-import { injectable } from 'tsyringe';
-import MessageListener from './MessageListener';
-import FindController from './controllers/FindController';
-import MarkController from './controllers/MarkController';
-import FollowMasterController from './controllers/FollowMasterController';
-import FollowSlaveController from './controllers/FollowSlaveController';
-import FollowKeyController from './controllers/FollowKeyController';
-import InputDriver from './InputDriver';
-import KeymapController from './controllers/KeymapController';
-import AddonEnabledUseCase from './usecases/AddonEnabledUseCase';
-import MarkKeyController from './controllers/MarkKeyController';
-import AddonEnabledController from './controllers/AddonEnabledController';
-import SettingController from './controllers/SettingController';
-import ConsoleFrameController from './controllers/ConsoleFrameController';
-import NavigateController from './controllers/NavigateController';
-import * as messages from '../shared/messages';
+import { injectable } from "tsyringe";
+import MessageListener from "./MessageListener";
+import FindController from "./controllers/FindController";
+import MarkController from "./controllers/MarkController";
+import FollowMasterController from "./controllers/FollowMasterController";
+import FollowSlaveController from "./controllers/FollowSlaveController";
+import FollowKeyController from "./controllers/FollowKeyController";
+import InputDriver from "./InputDriver";
+import KeymapController from "./controllers/KeymapController";
+import AddonEnabledUseCase from "./usecases/AddonEnabledUseCase";
+import MarkKeyController from "./controllers/MarkKeyController";
+import AddonEnabledController from "./controllers/AddonEnabledController";
+import SettingController from "./controllers/SettingController";
+import ConsoleFrameController from "./controllers/ConsoleFrameController";
+import NavigateController from "./controllers/NavigateController";
+import * as messages from "../shared/messages";
type Message = messages.Message;
@injectable()
export default class Application {
-
// eslint-disable-next-line max-params
constructor(
private messageListener: MessageListener,
@@ -34,9 +33,8 @@ export default class Application {
private addonEnabledController: AddonEnabledController,
private settingController: SettingController,
private consoleFrameController: ConsoleFrameController,
- private navigateController: NavigateController,
- ) {
- }
+ private navigateController: NavigateController
+ ) {}
run() {
this.routeCommonComponents();
@@ -49,30 +47,30 @@ export default class Application {
private routeMasterComponents() {
this.messageListener.onWebMessage((msg: Message, sender: Window) => {
switch (msg.type) {
- case messages.CONSOLE_ENTER_FIND:
- return this.findController.start(msg);
- case messages.FIND_NEXT:
- return this.findController.next(msg);
- case messages.FIND_PREV:
- return this.findController.prev(msg);
- case messages.CONSOLE_UNFOCUS:
- return this.consoleFrameController.unfocus(msg);
- case messages.FOLLOW_START:
- return this.followMasterController.followStart(msg);
- case messages.FOLLOW_RESPONSE_COUNT_TARGETS:
- return this.followMasterController.responseCountTargets(msg, sender);
- case messages.FOLLOW_KEY_PRESS:
- return this.followMasterController.keyPress(msg);
+ case messages.CONSOLE_ENTER_FIND:
+ return this.findController.start(msg);
+ case messages.FIND_NEXT:
+ return this.findController.next(msg);
+ case messages.FIND_PREV:
+ return this.findController.prev(msg);
+ case messages.CONSOLE_UNFOCUS:
+ return this.consoleFrameController.unfocus(msg);
+ case messages.FOLLOW_START:
+ return this.followMasterController.followStart(msg);
+ case messages.FOLLOW_RESPONSE_COUNT_TARGETS:
+ return this.followMasterController.responseCountTargets(msg, sender);
+ case messages.FOLLOW_KEY_PRESS:
+ return this.followMasterController.keyPress(msg);
}
return undefined;
});
this.messageListener.onBackgroundMessage((msg: Message) => {
switch (msg.type) {
- case messages.ADDON_ENABLED_QUERY:
- return this.addonEnabledController.getAddonEnabled(msg);
- case messages.TAB_SCROLL_TO:
- return this.markController.scrollTo(msg);
+ case messages.ADDON_ENABLED_QUERY:
+ return this.addonEnabledController.getAddonEnabled(msg);
+ case messages.TAB_SCROLL_TO:
+ return this.markController.scrollTo(msg);
}
return undefined;
});
@@ -81,47 +79,47 @@ export default class Application {
private routeCommonComponents() {
this.messageListener.onWebMessage((msg: Message) => {
switch (msg.type) {
- case messages.FOLLOW_REQUEST_COUNT_TARGETS:
- return this.followSlaveController.countTargets(msg);
- case messages.FOLLOW_CREATE_HINTS:
- return this.followSlaveController.createHints(msg);
- case messages.FOLLOW_SHOW_HINTS:
- return this.followSlaveController.showHints(msg);
- case messages.FOLLOW_ACTIVATE:
- return this.followSlaveController.activate(msg);
- case messages.FOLLOW_REMOVE_HINTS:
- return this.followSlaveController.clear(msg);
+ case messages.FOLLOW_REQUEST_COUNT_TARGETS:
+ return this.followSlaveController.countTargets(msg);
+ case messages.FOLLOW_CREATE_HINTS:
+ return this.followSlaveController.createHints(msg);
+ case messages.FOLLOW_SHOW_HINTS:
+ return this.followSlaveController.showHints(msg);
+ case messages.FOLLOW_ACTIVATE:
+ return this.followSlaveController.activate(msg);
+ case messages.FOLLOW_REMOVE_HINTS:
+ return this.followSlaveController.clear(msg);
}
return undefined;
});
this.messageListener.onBackgroundMessage((msg: Message): any => {
switch (msg.type) {
- case messages.SETTINGS_CHANGED:
- return this.settingController.reloadSettings(msg);
- case messages.ADDON_TOGGLE_ENABLED:
- return this.addonEnabledUseCase.toggle();
- case messages.NAVIGATE_HISTORY_NEXT:
- return this.navigateController.openHistoryNext(msg);
- case messages.NAVIGATE_HISTORY_PREV:
- return this.navigateController.openHistoryPrev(msg);
- case messages.NAVIGATE_LINK_NEXT:
- return this.navigateController.openLinkNext(msg);
- case messages.NAVIGATE_LINK_PREV:
- return this.navigateController.openLinkPrev(msg);
+ case messages.SETTINGS_CHANGED:
+ return this.settingController.reloadSettings(msg);
+ case messages.ADDON_TOGGLE_ENABLED:
+ return this.addonEnabledUseCase.toggle();
+ case messages.NAVIGATE_HISTORY_NEXT:
+ return this.navigateController.openHistoryNext(msg);
+ case messages.NAVIGATE_HISTORY_PREV:
+ return this.navigateController.openHistoryPrev(msg);
+ case messages.NAVIGATE_LINK_NEXT:
+ return this.navigateController.openLinkNext(msg);
+ case messages.NAVIGATE_LINK_PREV:
+ return this.navigateController.openLinkPrev(msg);
}
});
const inputDriver = new InputDriver(window.document.body);
- inputDriver.onKey(key => this.followKeyController.press(key));
- inputDriver.onKey(key => this.markKeyController.press(key));
- inputDriver.onKey(key => this.keymapController.press(key));
+ inputDriver.onKey((key) => this.followKeyController.press(key));
+ inputDriver.onKey((key) => this.markKeyController.press(key));
+ inputDriver.onKey((key) => this.keymapController.press(key));
this.settingController.initSettings();
}
private routeFocusEvents() {
- window.addEventListener('blur', () => {
+ window.addEventListener("blur", () => {
this.keymapController.onBlurWindow();
});
}