From 902aa3a099638b2198c24c076c61577a8435277b Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 10 Jul 2018 18:02:30 +0200 Subject: Fix player lint --- client/package.json | 2 +- client/src/standalone/player/definitions.ts | 24 +++--- client/src/standalone/player/events.ts | 56 ++++++------- client/src/standalone/player/player.ts | 104 ++++++++++++------------ client/src/standalone/videos/embed.ts | 120 +++++++++++++--------------- client/src/standalone/videos/test-embed.ts | 32 ++++---- 6 files changed, 166 insertions(+), 172 deletions(-) (limited to 'client') diff --git a/client/package.json b/client/package.json index 617c7cb49..7b044dbdd 100644 --- a/client/package.json +++ b/client/package.json @@ -13,7 +13,7 @@ "url": "git://github.com/Chocobozzz/PeerTube.git" }, "scripts": { - "lint": "tslint --project ./tsconfig.json -c ./tslint.json 'src/app/**/*.ts'", + "lint": "tslint --project ./tsconfig.json -c ./tslint.json 'src/app/**/*.ts' 'src/standalone/**/*.ts'", "webpack": "webpack", "tslint": "tslint", "ng": "ng", diff --git a/client/src/standalone/player/definitions.ts b/client/src/standalone/player/definitions.ts index 6920672a7..7f9ef9b6f 100644 --- a/client/src/standalone/player/definitions.ts +++ b/client/src/standalone/player/definitions.ts @@ -1,18 +1,16 @@ - export interface EventHandler { - (ev : T) : void + (ev: T): void } -export type PlayerEventType = - 'pause' | 'play' | - 'playbackStatusUpdate' | - 'playbackStatusChange' | - 'resolutionUpdate' -; +export type PlayerEventType = + 'pause' | 'play' | + 'playbackStatusUpdate' | + 'playbackStatusChange' | + 'resolutionUpdate' export interface PeerTubeResolution { - id : any - label : string - src : string - active : boolean -} \ No newline at end of file + id: any + label: string + src: string + active: boolean +} diff --git a/client/src/standalone/player/events.ts b/client/src/standalone/player/events.ts index c01328352..f1639ef19 100644 --- a/client/src/standalone/player/events.ts +++ b/client/src/standalone/player/events.ts @@ -1,48 +1,48 @@ -import { EventHandler } from "./definitions" +import { EventHandler } from './definitions' interface PlayerEventRegistrar { - registrations : Function[] + registrations: Function[] } interface PlayerEventRegistrationMap { - [name : string] : PlayerEventRegistrar + [ name: string ]: PlayerEventRegistrar } export class EventRegistrar { - private eventRegistrations : PlayerEventRegistrationMap = {} + private eventRegistrations: PlayerEventRegistrationMap = {} - public bindToChannel(channel : Channel.MessagingChannel) { - for (let name of Object.keys(this.eventRegistrations)) - channel.bind(name, (txn, params) => this.fire(name, params)) + public bindToChannel (channel: Channel.MessagingChannel) { + for (let name of Object.keys(this.eventRegistrations)) { + channel.bind(name, (txn, params) => this.fire(name, params)) } + } - public registerTypes(names : string[]) { - for (let name of names) - this.eventRegistrations[name] = { registrations: [] } + public registerTypes (names: string[]) { + for (let name of names) { + this.eventRegistrations[ name ] = { registrations: [] } } + } - public fire(name : string, event : T) { - this.eventRegistrations[name].registrations.forEach(x => x(event)) + public fire (name: string, event: T) { + this.eventRegistrations[ name ].registrations.forEach(x => x(event)) + } + + public addListener (name: string, handler: EventHandler) { + if (!this.eventRegistrations[ name ]) { + console.warn(`PeerTube: addEventListener(): The event '${name}' is not supported`) + return false } - public addListener(name : string, handler : EventHandler) { - if (!this.eventRegistrations[name]) { - console.warn(`PeerTube: addEventListener(): The event '${name}' is not supported`) - return false - } + this.eventRegistrations[ name ].registrations.push(handler) + return true + } - this.eventRegistrations[name].registrations.push(handler) - return true - } + public removeListener (name: string, handler: EventHandler) { + if (!this.eventRegistrations[ name ]) return false - public removeListener(name : string, handler : EventHandler) { - if (!this.eventRegistrations[name]) - return false + this.eventRegistrations[ name ].registrations = this.eventRegistrations[ name ].registrations.filter(x => x === handler) - this.eventRegistrations[name].registrations = - this.eventRegistrations[name].registrations.filter(x => x === handler) - - return true - } + return true + } } diff --git a/client/src/standalone/player/player.ts b/client/src/standalone/player/player.ts index 9fc648d25..91a5e73f3 100644 --- a/client/src/standalone/player/player.ts +++ b/client/src/standalone/player/player.ts @@ -3,29 +3,35 @@ import { EventRegistrar } from './events' import { EventHandler, PlayerEventType, PeerTubeResolution } from './definitions' const PASSTHROUGH_EVENTS = [ - 'pause', 'play', + 'pause', + 'play', 'playbackStatusUpdate', 'playbackStatusChange', 'resolutionUpdate' ] /** - * Allows for programmatic control of a PeerTube embed running in an