fix action handler rename
This commit is contained in:
parent
e84f8ee541
commit
27b6ca824d
@ -1,7 +1,7 @@
|
||||
import Debug from './conf/Debug';
|
||||
import ExtensionMode from '../common/enums/ExtensionMode.enum';
|
||||
import Settings from './lib/Settings';
|
||||
import ActionHandler from './lib/ActionHandler';
|
||||
import KbmHandler from './lib/KbmHandler';
|
||||
import Comms from './lib/comms/Comms';
|
||||
import CommsClient from './lib/comms/CommsClient';
|
||||
import PageInfo from './lib/video-data/PageInfo';
|
||||
@ -13,7 +13,7 @@ export default class UWContent {
|
||||
pageInfo: PageInfo;
|
||||
comms: CommsClient;
|
||||
settings: Settings;
|
||||
actionHandler: ActionHandler;
|
||||
kbmHandler: KbmHandler;
|
||||
logger: Logger;
|
||||
eventBus: EventBus;
|
||||
|
||||
@ -133,17 +133,17 @@ export default class UWContent {
|
||||
this.pageInfo = new PageInfo(this.eventBus, this.settings, this.logger, extensionMode, isSiteDisabled);
|
||||
this.logger.log('info', 'debug', "[uw.js::setup] pageInfo initialized.");
|
||||
|
||||
this.logger.log('info', 'debug', "[uw.js::setup] will try to initate ActionHandler.");
|
||||
this.logger.log('info', 'debug', "[uw.js::setup] will try to initate KbmHandler.");
|
||||
|
||||
// start action handler only if extension is enabled for this site
|
||||
if (!isSiteDisabled) {
|
||||
if (this.actionHandler) {
|
||||
this.actionHandler.destroy();
|
||||
if (this.kbmHandler) {
|
||||
this.kbmHandler.destroy();
|
||||
}
|
||||
this.actionHandler = new ActionHandler(this.eventBus, this.settings, this.logger);
|
||||
this.actionHandler.init();
|
||||
this.kbmHandler = new KbmHandler(this.eventBus, this.settings, this.logger);
|
||||
this.kbmHandler.init();
|
||||
|
||||
this.logger.log('info', 'debug', "[uw.js::setup] ActionHandler initiated.");
|
||||
this.logger.log('info', 'debug', "[uw.js::setup] KbmHandler initiated.");
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
@ -156,8 +156,8 @@ export default class UWContent {
|
||||
if (this.pageInfo) {
|
||||
this.pageInfo.destroy();
|
||||
}
|
||||
if (this.actionHandler) {
|
||||
this.actionHandler.destroy();
|
||||
if (this.kbmHandler) {
|
||||
this.kbmHandler.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -150,6 +150,11 @@ const ExtensionConf: SettingsInterface = {
|
||||
maxLogZoom: 3,
|
||||
announceDebounce: 200 // we wait this long before announcing new zoom
|
||||
},
|
||||
kbmHandler: {
|
||||
enabled: true,
|
||||
keyboardEnabled: true,
|
||||
mouseEnabled: true
|
||||
},
|
||||
miscSettings: {
|
||||
mousePan: {
|
||||
enabled: false
|
||||
|
@ -8,11 +8,16 @@ import VideoData from './video-data/VideoData';
|
||||
import EventBus, { EventBusCommand } from './EventBus';
|
||||
|
||||
if(process.env.CHANNEL !== 'stable'){
|
||||
console.info("Loading ActionHandler");
|
||||
console.info("Loading KbmHandler");
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles keypresses and mouse movement
|
||||
* Handles keypresses and mouse movement.
|
||||
*
|
||||
* EventBus commands:
|
||||
* kbm-enable enables keyboard shortcuts and mouse panning
|
||||
* kbm-disable disables keyboard shortcuts and mouse panning
|
||||
* kbm-set-config sets configuration for this module.
|
||||
*/
|
||||
class KbmHandler {
|
||||
logger: Logger;
|
||||
@ -53,7 +58,7 @@ class KbmHandler {
|
||||
}
|
||||
|
||||
init() {
|
||||
this.logger.log('info', 'debug', "[ActionHandler::init] starting init");
|
||||
this.logger.log('info', 'debug', "[KbmHandler::init] starting init");
|
||||
|
||||
// build the action list — but only from actions that have shortcuts assigned
|
||||
for (const key in this.settings.active.commands) {
|
||||
@ -141,7 +146,7 @@ class KbmHandler {
|
||||
|
||||
|
||||
registerHandleMouse(videoData) {
|
||||
this.logger.log('info', ['actionHandler', 'mousemove'], "[ActionHandler::registerHandleMouse] registering handle mouse for videodata:", videoData.id)
|
||||
this.logger.log('info', ['KbmHandler', 'mousemove'], "[KbmHandler::registerHandleMouse] registering handle mouse for videodata:", videoData.id)
|
||||
|
||||
var ths = this;
|
||||
if (videoData.player && videoData.player.element) {
|
||||
@ -173,7 +178,7 @@ class KbmHandler {
|
||||
const preventAction = this.preventAction(event);
|
||||
this.logger.resume(); // undisable
|
||||
|
||||
this.logger.log('info', 'keyboard', "[ActionHandler::preventAction] Testing whether we're in a textbox or something. Detailed rundown of conditions:\n" +
|
||||
this.logger.log('info', 'keyboard', "[KbmHandler::preventAction] Testing whether we're in a textbox or something. Detailed rundown of conditions:\n" +
|
||||
"\nis tag one of defined inputs? (yes->prevent):", this.inputs.indexOf(activeElement.tagName.toLocaleLowerCase()) !== -1,
|
||||
"\nis role = textbox? (yes -> prevent):", activeElement.getAttribute("role") === "textbox",
|
||||
"\nis type === 'text'? (yes -> prevent):", activeElement.getAttribute("type") === "text",
|
||||
@ -263,18 +268,18 @@ class KbmHandler {
|
||||
|
||||
handleKeyup(event) {
|
||||
if (!this.keyboardEnabled) {
|
||||
this.logger.log('info', 'keyboard', "%c[ActionHandler::handleKeyup] kbmHandler.keyboardEnabled is set to false. Doing nothing.");
|
||||
this.logger.log('info', 'keyboard', "%c[KbmHandler::handleKeyup] kbmHandler.keyboardEnabled is set to false. Doing nothing.");
|
||||
return;
|
||||
}
|
||||
this.logger.log('info', 'keyboard', "%c[ActionHandler::handleKeyup] we pressed a key: ", "color: #ff0", event.key , " | keyup: ", event.keyup, "event:", event);
|
||||
this.logger.log('info', 'keyboard', "%c[KbmHandler::handleKeyup] we pressed a key: ", "color: #ff0", event.key , " | keyup: ", event.keyup, "event:", event);
|
||||
|
||||
try {
|
||||
if (this.preventAction(event)) {
|
||||
this.logger.log('info', 'keyboard', "[ActionHandler::handleKeyup] we are in a text box or something. Doing nothing.");
|
||||
this.logger.log('info', 'keyboard', "[KbmHandler::handleKeyup] we are in a text box or something. Doing nothing.");
|
||||
return;
|
||||
}
|
||||
|
||||
this.logger.log('info', 'keyboard', "%c[ActionHandler::handleKeyup] Trying to find and execute action for event. Actions/event: ", "color: #ff0", this.keypressActions, event);
|
||||
this.logger.log('info', 'keyboard', "%c[KbmHandler::handleKeyup] Trying to find and execute action for event. Actions/event: ", "color: #ff0", this.keypressActions, event);
|
||||
|
||||
const isLatin = this.isLatin(event.key);
|
||||
|
||||
@ -284,18 +289,18 @@ class KbmHandler {
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
this.logger.log('info', 'debug', '[ActionHandler::handleKeyup] Failed to handle keyup!', e);
|
||||
this.logger.log('info', 'debug', '[KbmHandler::handleKeyup] Failed to handle keyup!', e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
handleMouseMove(event, videoData?: VideoData) {
|
||||
if (!this.mouseEnabled) {
|
||||
this.logger.log('info', 'keyboard', "%c[ActionHandler::handleKeyup] kbmHandler.keyboardEnabled is set to false. Doing nothing.");
|
||||
this.logger.log('info', 'keyboard', "%c[KbmHandler::handleKeyup] kbmHandler.keyboardEnabled is set to false. Doing nothing.");
|
||||
return;
|
||||
}
|
||||
|
||||
this.logger.log('info', 'keyboard', "[ActionHandler::handleMouseMove] mouse move is being handled.\nevent:", event, "\nvideo data:", videoData);
|
||||
this.logger.log('info', 'keyboard', "[KbmHandler::handleMouseMove] mouse move is being handled.\nevent:", event, "\nvideo data:", videoData);
|
||||
console.info('mousemove must be migrated!');
|
||||
// videoData?.panHandler(event);
|
||||
// this.execAction(this.mouseMoveActions, event, videoData)
|
||||
@ -304,7 +309,7 @@ class KbmHandler {
|
||||
}
|
||||
|
||||
if(process.env.CHANNEL !== 'stable'){
|
||||
console.info("ActionHandler loaded");
|
||||
console.info("KbmHandler loaded");
|
||||
}
|
||||
|
||||
export default KbmHandler;
|
||||
|
@ -22,7 +22,7 @@ export const baseLoggingOptions: LoggerConfig = {
|
||||
"settings": true,
|
||||
"keyboard": true,
|
||||
"mousemove": false,
|
||||
"actionHandler": true,
|
||||
"kbmHandler": true,
|
||||
"comms": true,
|
||||
"playerDetect": true,
|
||||
"resizer": true,
|
||||
@ -47,7 +47,7 @@ export interface LoggingOptions {
|
||||
settings?: boolean;
|
||||
keyboard?: boolean;
|
||||
mousemove?: boolean;
|
||||
actionHandler?: boolean;
|
||||
kbmHandler?: boolean;
|
||||
comms?: boolean;
|
||||
playerDetect?: boolean;
|
||||
resizer?: boolean;
|
||||
|
@ -61,10 +61,10 @@ class PageInfo {
|
||||
extensionMode: ExtensionMode;
|
||||
defaultCrop: any;
|
||||
currentCrop: any;
|
||||
actionHandlerInitQueue: any[] = [];
|
||||
kbmHandlerInitQueue: any[] = [];
|
||||
currentZoomScale: number = 1;
|
||||
|
||||
actionHandler: any;
|
||||
kbmHandler: any;
|
||||
//#endregion
|
||||
|
||||
constructor(eventBus: EventBus, settings: Settings, logger: Logger, extensionMode, readOnly = false){
|
||||
@ -125,10 +125,10 @@ class PageInfo {
|
||||
}
|
||||
|
||||
initMouseActionHandler(videoData) {
|
||||
if (this.actionHandler) {
|
||||
this.actionHandler.registerHandleMouse(videoData);
|
||||
if (this.kbmHandler) {
|
||||
this.kbmHandler.registerHandleMouse(videoData);
|
||||
} else {
|
||||
this.actionHandlerInitQueue.push(videoData);
|
||||
this.kbmHandlerInitQueue.push(videoData);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user