kbm refactoring stuffs
This commit is contained in:
parent
c954f8b984
commit
de9696471a
35
src/ext/lib/kbm/KbmBase.ts
Normal file
35
src/ext/lib/kbm/KbmBase.ts
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
import EventBus, { EventBusCommand } from '../EventBus';
|
||||||
|
import Logger from '../Logger';
|
||||||
|
import Settings from '../Settings';
|
||||||
|
|
||||||
|
export class KbmBase {
|
||||||
|
logger: Logger;
|
||||||
|
settings: Settings;
|
||||||
|
eventBus: EventBus;
|
||||||
|
|
||||||
|
// eventBusCommands: { [x: string]: EventBusCommand } = {
|
||||||
|
// 'kbm-enable': {
|
||||||
|
// function: () => this.enable()
|
||||||
|
// },
|
||||||
|
// 'kbm-disable': {
|
||||||
|
// function: () => this.disable()
|
||||||
|
// },
|
||||||
|
// 'kbm-set-config': {
|
||||||
|
// function: (data: {config: any, temporary?: boolean}) => this.setConfig(data.config, data.temporary),
|
||||||
|
// },
|
||||||
|
// 'uw-enable': {
|
||||||
|
// function: () => this.load()
|
||||||
|
// },
|
||||||
|
// 'uw-disable': {
|
||||||
|
// function: () => this.disable()
|
||||||
|
// },
|
||||||
|
// }
|
||||||
|
|
||||||
|
constructor(eventBus: EventBus, settings: Settings, logger: Logger) {
|
||||||
|
this.logger = logger;
|
||||||
|
this.settings = settings;
|
||||||
|
this.eventBus = eventBus;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default KbmBase;
|
@ -6,6 +6,7 @@ import PageInfo from '../video-data/PageInfo';
|
|||||||
import Settings from '../Settings';
|
import Settings from '../Settings';
|
||||||
import VideoData from '../video-data/VideoData';
|
import VideoData from '../video-data/VideoData';
|
||||||
import EventBus, { EventBusCommand } from '../EventBus';
|
import EventBus, { EventBusCommand } from '../EventBus';
|
||||||
|
import KbmBase from './KbmBase';
|
||||||
|
|
||||||
if(process.env.CHANNEL !== 'stable'){
|
if(process.env.CHANNEL !== 'stable'){
|
||||||
console.info("Loading KeyboardHandler");
|
console.info("Loading KeyboardHandler");
|
||||||
@ -19,7 +20,7 @@ if(process.env.CHANNEL !== 'stable'){
|
|||||||
* kbm-disable disables keyboard shortcuts and mouse panning
|
* kbm-disable disables keyboard shortcuts and mouse panning
|
||||||
* kbm-set-config sets configuration for this module.
|
* kbm-set-config sets configuration for this module.
|
||||||
*/
|
*/
|
||||||
export class KeyboardHandler {
|
export class KeyboardHandler extends KbmBase {
|
||||||
logger: Logger;
|
logger: Logger;
|
||||||
settings: Settings;
|
settings: Settings;
|
||||||
eventBus: EventBus;
|
eventBus: EventBus;
|
||||||
@ -56,9 +57,7 @@ export class KeyboardHandler {
|
|||||||
|
|
||||||
//#region lifecycle
|
//#region lifecycle
|
||||||
constructor(eventBus: EventBus, settings: Settings, logger: Logger) {
|
constructor(eventBus: EventBus, settings: Settings, logger: Logger) {
|
||||||
this.logger = logger;
|
super(eventBus, settings, logger);
|
||||||
this.settings = settings;
|
|
||||||
this.eventBus = eventBus;
|
|
||||||
|
|
||||||
this.init();
|
this.init();
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import EventBus, { EventBusCommand } from '../EventBus';
|
import EventBus, { EventBusCommand } from '../EventBus';
|
||||||
import Logger from '../Logger';
|
import Logger from '../Logger';
|
||||||
import Settings from '../Settings';
|
import Settings from '../Settings';
|
||||||
|
import KbmBase from './KbmBase';
|
||||||
|
|
||||||
if(process.env.CHANNEL !== 'stable'){
|
if(process.env.CHANNEL !== 'stable'){
|
||||||
console.info("Loading PlayerMouseHandler");
|
console.info("Loading PlayerMouseHandler");
|
||||||
@ -10,10 +11,8 @@ if(process.env.CHANNEL !== 'stable'){
|
|||||||
/**
|
/**
|
||||||
* Handles keypress
|
* Handles keypress
|
||||||
*/
|
*/
|
||||||
export class MouseHandler {
|
export class MouseHandler extends KbmBase {
|
||||||
logger: Logger;
|
|
||||||
settings: Settings;
|
|
||||||
eventBus: EventBus;
|
|
||||||
playerElement: HTMLElement;
|
playerElement: HTMLElement;
|
||||||
|
|
||||||
eventBusCommands: { [x: string]: EventBusCommand } = {
|
eventBusCommands: { [x: string]: EventBusCommand } = {
|
||||||
@ -36,12 +35,15 @@ export class MouseHandler {
|
|||||||
|
|
||||||
//#region lifecycle
|
//#region lifecycle
|
||||||
constructor(playerElement: HTMLElement, eventBus: EventBus, settings: Settings, logger: Logger) {
|
constructor(playerElement: HTMLElement, eventBus: EventBus, settings: Settings, logger: Logger) {
|
||||||
|
super(eventBus, settings, logger);
|
||||||
|
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
this.eventBus = eventBus;
|
this.eventBus = eventBus;
|
||||||
this.playerElement = playerElement;
|
this.playerElement = playerElement;
|
||||||
|
|
||||||
this.init();
|
this.init();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
|
Loading…
Reference in New Issue
Block a user