fix action handler rename
This commit is contained in:
parent
e84f8ee541
commit
27b6ca824d
@ -1,7 +1,7 @@
|
|||||||
import Debug from './conf/Debug';
|
import Debug from './conf/Debug';
|
||||||
import ExtensionMode from '../common/enums/ExtensionMode.enum';
|
import ExtensionMode from '../common/enums/ExtensionMode.enum';
|
||||||
import Settings from './lib/Settings';
|
import Settings from './lib/Settings';
|
||||||
import ActionHandler from './lib/ActionHandler';
|
import KbmHandler from './lib/KbmHandler';
|
||||||
import Comms from './lib/comms/Comms';
|
import Comms from './lib/comms/Comms';
|
||||||
import CommsClient from './lib/comms/CommsClient';
|
import CommsClient from './lib/comms/CommsClient';
|
||||||
import PageInfo from './lib/video-data/PageInfo';
|
import PageInfo from './lib/video-data/PageInfo';
|
||||||
@ -13,7 +13,7 @@ export default class UWContent {
|
|||||||
pageInfo: PageInfo;
|
pageInfo: PageInfo;
|
||||||
comms: CommsClient;
|
comms: CommsClient;
|
||||||
settings: Settings;
|
settings: Settings;
|
||||||
actionHandler: ActionHandler;
|
kbmHandler: KbmHandler;
|
||||||
logger: Logger;
|
logger: Logger;
|
||||||
eventBus: EventBus;
|
eventBus: EventBus;
|
||||||
|
|
||||||
@ -133,17 +133,17 @@ export default class UWContent {
|
|||||||
this.pageInfo = new PageInfo(this.eventBus, this.settings, this.logger, extensionMode, isSiteDisabled);
|
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] 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
|
// start action handler only if extension is enabled for this site
|
||||||
if (!isSiteDisabled) {
|
if (!isSiteDisabled) {
|
||||||
if (this.actionHandler) {
|
if (this.kbmHandler) {
|
||||||
this.actionHandler.destroy();
|
this.kbmHandler.destroy();
|
||||||
}
|
}
|
||||||
this.actionHandler = new ActionHandler(this.eventBus, this.settings, this.logger);
|
this.kbmHandler = new KbmHandler(this.eventBus, this.settings, this.logger);
|
||||||
this.actionHandler.init();
|
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) {
|
} catch (e) {
|
||||||
@ -156,8 +156,8 @@ export default class UWContent {
|
|||||||
if (this.pageInfo) {
|
if (this.pageInfo) {
|
||||||
this.pageInfo.destroy();
|
this.pageInfo.destroy();
|
||||||
}
|
}
|
||||||
if (this.actionHandler) {
|
if (this.kbmHandler) {
|
||||||
this.actionHandler.destroy();
|
this.kbmHandler.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,6 +150,11 @@ const ExtensionConf: SettingsInterface = {
|
|||||||
maxLogZoom: 3,
|
maxLogZoom: 3,
|
||||||
announceDebounce: 200 // we wait this long before announcing new zoom
|
announceDebounce: 200 // we wait this long before announcing new zoom
|
||||||
},
|
},
|
||||||
|
kbmHandler: {
|
||||||
|
enabled: true,
|
||||||
|
keyboardEnabled: true,
|
||||||
|
mouseEnabled: true
|
||||||
|
},
|
||||||
miscSettings: {
|
miscSettings: {
|
||||||
mousePan: {
|
mousePan: {
|
||||||
enabled: false
|
enabled: false
|
||||||
|
@ -8,11 +8,16 @@ import VideoData from './video-data/VideoData';
|
|||||||
import EventBus, { EventBusCommand } from './EventBus';
|
import EventBus, { EventBusCommand } from './EventBus';
|
||||||
|
|
||||||
if(process.env.CHANNEL !== 'stable'){
|
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 {
|
class KbmHandler {
|
||||||
logger: Logger;
|
logger: Logger;
|
||||||
@ -53,7 +58,7 @@ class KbmHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
init() {
|
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
|
// build the action list — but only from actions that have shortcuts assigned
|
||||||
for (const key in this.settings.active.commands) {
|
for (const key in this.settings.active.commands) {
|
||||||
@ -141,7 +146,7 @@ class KbmHandler {
|
|||||||
|
|
||||||
|
|
||||||
registerHandleMouse(videoData) {
|
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;
|
var ths = this;
|
||||||
if (videoData.player && videoData.player.element) {
|
if (videoData.player && videoData.player.element) {
|
||||||
@ -173,7 +178,7 @@ class KbmHandler {
|
|||||||
const preventAction = this.preventAction(event);
|
const preventAction = this.preventAction(event);
|
||||||
this.logger.resume(); // undisable
|
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 tag one of defined inputs? (yes->prevent):", this.inputs.indexOf(activeElement.tagName.toLocaleLowerCase()) !== -1,
|
||||||
"\nis role = textbox? (yes -> prevent):", activeElement.getAttribute("role") === "textbox",
|
"\nis role = textbox? (yes -> prevent):", activeElement.getAttribute("role") === "textbox",
|
||||||
"\nis type === 'text'? (yes -> prevent):", activeElement.getAttribute("type") === "text",
|
"\nis type === 'text'? (yes -> prevent):", activeElement.getAttribute("type") === "text",
|
||||||
@ -263,18 +268,18 @@ class KbmHandler {
|
|||||||
|
|
||||||
handleKeyup(event) {
|
handleKeyup(event) {
|
||||||
if (!this.keyboardEnabled) {
|
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;
|
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 {
|
try {
|
||||||
if (this.preventAction(event)) {
|
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;
|
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);
|
const isLatin = this.isLatin(event.key);
|
||||||
|
|
||||||
@ -284,18 +289,18 @@ class KbmHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} 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) {
|
handleMouseMove(event, videoData?: VideoData) {
|
||||||
if (!this.mouseEnabled) {
|
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;
|
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!');
|
console.info('mousemove must be migrated!');
|
||||||
// videoData?.panHandler(event);
|
// videoData?.panHandler(event);
|
||||||
// this.execAction(this.mouseMoveActions, event, videoData)
|
// this.execAction(this.mouseMoveActions, event, videoData)
|
||||||
@ -304,7 +309,7 @@ class KbmHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(process.env.CHANNEL !== 'stable'){
|
if(process.env.CHANNEL !== 'stable'){
|
||||||
console.info("ActionHandler loaded");
|
console.info("KbmHandler loaded");
|
||||||
}
|
}
|
||||||
|
|
||||||
export default KbmHandler;
|
export default KbmHandler;
|
||||||
|
@ -22,7 +22,7 @@ export const baseLoggingOptions: LoggerConfig = {
|
|||||||
"settings": true,
|
"settings": true,
|
||||||
"keyboard": true,
|
"keyboard": true,
|
||||||
"mousemove": false,
|
"mousemove": false,
|
||||||
"actionHandler": true,
|
"kbmHandler": true,
|
||||||
"comms": true,
|
"comms": true,
|
||||||
"playerDetect": true,
|
"playerDetect": true,
|
||||||
"resizer": true,
|
"resizer": true,
|
||||||
@ -47,7 +47,7 @@ export interface LoggingOptions {
|
|||||||
settings?: boolean;
|
settings?: boolean;
|
||||||
keyboard?: boolean;
|
keyboard?: boolean;
|
||||||
mousemove?: boolean;
|
mousemove?: boolean;
|
||||||
actionHandler?: boolean;
|
kbmHandler?: boolean;
|
||||||
comms?: boolean;
|
comms?: boolean;
|
||||||
playerDetect?: boolean;
|
playerDetect?: boolean;
|
||||||
resizer?: boolean;
|
resizer?: boolean;
|
||||||
|
@ -61,10 +61,10 @@ class PageInfo {
|
|||||||
extensionMode: ExtensionMode;
|
extensionMode: ExtensionMode;
|
||||||
defaultCrop: any;
|
defaultCrop: any;
|
||||||
currentCrop: any;
|
currentCrop: any;
|
||||||
actionHandlerInitQueue: any[] = [];
|
kbmHandlerInitQueue: any[] = [];
|
||||||
currentZoomScale: number = 1;
|
currentZoomScale: number = 1;
|
||||||
|
|
||||||
actionHandler: any;
|
kbmHandler: any;
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
constructor(eventBus: EventBus, settings: Settings, logger: Logger, extensionMode, readOnly = false){
|
constructor(eventBus: EventBus, settings: Settings, logger: Logger, extensionMode, readOnly = false){
|
||||||
@ -125,10 +125,10 @@ class PageInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
initMouseActionHandler(videoData) {
|
initMouseActionHandler(videoData) {
|
||||||
if (this.actionHandler) {
|
if (this.kbmHandler) {
|
||||||
this.actionHandler.registerHandleMouse(videoData);
|
this.kbmHandler.registerHandleMouse(videoData);
|
||||||
} else {
|
} else {
|
||||||
this.actionHandlerInitQueue.push(videoData);
|
this.kbmHandlerInitQueue.push(videoData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user