aboutsummaryrefslogtreecommitdiff
path: root/src/content/index.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/index.ts')
-rw-r--r--src/content/index.ts35
1 files changed, 33 insertions, 2 deletions
diff --git a/src/content/index.ts b/src/content/index.ts
index d644095..08bdf6b 100644
--- a/src/content/index.ts
+++ b/src/content/index.ts
@@ -6,6 +6,9 @@ import consoleFrameStyle from './site-style';
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 * as messages from '../shared/messages';
import InputDriver from './InputDriver';
import KeymapController from './controllers/KeymapController';
@@ -17,11 +20,14 @@ import AddonEnabledController from './controllers/AddonEnabledController';
// const store = newStore();
+let listener = new MessageListener();
if (window.self === window.top) {
// new TopContentComponent(window, store); // eslint-disable-line no-new
let findController = new FindController();
- new MessageListener().onWebMessage((message: messages.Message) => {
+
+ let followMasterController = new FollowMasterController();
+ listener.onWebMessage((message: messages.Message, sender: Window) => {
switch (message.type) {
case messages.CONSOLE_ENTER_FIND:
return findController.start(message);
@@ -32,6 +38,13 @@ if (window.self === window.top) {
case messages.CONSOLE_UNFOCUS:
window.focus();
consoleFrames.blur(window.document);
+ break;
+ case messages.FOLLOW_START:
+ return followMasterController.followStart(message);
+ case messages.FOLLOW_RESPONSE_COUNT_TARGETS:
+ return followMasterController.responseCountTargets(message, sender);
+ case messages.FOLLOW_KEY_PRESS:
+ return followMasterController.keyPress(message);
}
return undefined;
});
@@ -54,10 +67,28 @@ if (window.self === window.top) {
// new FrameContentComponent(window, store); // eslint-disable-line no-new
}
+let followSlaveController = new FollowSlaveController();
+listener.onWebMessage((message: messages.Message) => {
+ switch (message.type) {
+ case messages.FOLLOW_REQUEST_COUNT_TARGETS:
+ return followSlaveController.countTargets(message);
+ case messages.FOLLOW_CREATE_HINTS:
+ return followSlaveController.createHints(message);
+ case messages.FOLLOW_SHOW_HINTS:
+ return followSlaveController.showHints(message);
+ case messages.FOLLOW_ACTIVATE:
+ return followSlaveController.activate(message);
+ case messages.FOLLOW_REMOVE_HINTS:
+ return followSlaveController.clear(message);
+ }
+ return undefined;
+});
+
let keymapController = new KeymapController();
let markKeyController = new MarkKeyController();
+let followKeyController = new FollowKeyController();
let inputDriver = new InputDriver(document.body);
-// inputDriver.onKey(key => followSlaveController.pressKey(key));
+inputDriver.onKey(key => followKeyController.press(key));
inputDriver.onKey(key => markKeyController.press(key));
inputDriver.onKey(key => keymapController.press(key));