mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-06 03:50:26 +02:00
Migrate client to eslint
This commit is contained in:
parent
adb8809d43
commit
9df52d660f
215 changed files with 2052 additions and 1196 deletions
|
@ -64,17 +64,11 @@ export class PeerTubeEmbed {
|
|||
private playlistElements: VideoPlaylistElement[]
|
||||
private currentPlaylistElement: VideoPlaylistElement
|
||||
|
||||
private wrapperElement: HTMLElement
|
||||
private readonly wrapperElement: HTMLElement
|
||||
|
||||
private pluginsManager: PluginsManager
|
||||
|
||||
static async main () {
|
||||
const videoContainerId = 'video-wrapper'
|
||||
const embed = new PeerTubeEmbed(videoContainerId)
|
||||
await embed.init()
|
||||
}
|
||||
|
||||
constructor (private videoWrapperId: string) {
|
||||
constructor (private readonly videoWrapperId: string) {
|
||||
this.wrapperElement = document.getElementById(this.videoWrapperId)
|
||||
|
||||
try {
|
||||
|
@ -84,6 +78,12 @@ export class PeerTubeEmbed {
|
|||
}
|
||||
}
|
||||
|
||||
static async main () {
|
||||
const videoContainerId = 'video-wrapper'
|
||||
const embed = new PeerTubeEmbed(videoContainerId)
|
||||
await embed.init()
|
||||
}
|
||||
|
||||
getVideoUrl (id: string) {
|
||||
return window.location.origin + '/api/v1/videos/' + id
|
||||
}
|
||||
|
@ -316,7 +316,7 @@ export class PeerTubeEmbed {
|
|||
while (total > elements.length && i < 10) {
|
||||
const result = await this.loadPlaylistElements(playlistId, elements.length)
|
||||
|
||||
const json = await result.json() as ResultList<VideoPlaylistElement>
|
||||
const json = await result.json()
|
||||
total = json.total
|
||||
|
||||
elements = elements.concat(json.data)
|
||||
|
@ -469,7 +469,7 @@ export class PeerTubeEmbed {
|
|||
// Issue when we parsed config from HTML, fallback to API
|
||||
if (!this.config) {
|
||||
this.config = await this.refreshFetch('/api/v1/config')
|
||||
.then(res => res.json())
|
||||
.then(res => res.json())
|
||||
}
|
||||
|
||||
const videoInfoPromise = videoResponse.json()
|
||||
|
@ -506,7 +506,7 @@ export class PeerTubeEmbed {
|
|||
this.currentPlaylistElement = videoPlaylistElement
|
||||
|
||||
this.loadVideoAndBuildPlayer(this.currentPlaylistElement.video.uuid)
|
||||
.catch(err => console.error(err))
|
||||
.catch(err => console.error(err))
|
||||
}
|
||||
}
|
||||
: undefined
|
||||
|
@ -542,7 +542,9 @@ export class PeerTubeEmbed {
|
|||
isLive: videoInfo.isLive,
|
||||
|
||||
playerElement: this.playerElement,
|
||||
onPlayerElementChange: (element: HTMLVideoElement) => this.playerElement = element,
|
||||
onPlayerElementChange: (element: HTMLVideoElement) => {
|
||||
this.playerElement = element
|
||||
},
|
||||
|
||||
videoDuration: videoInfo.duration,
|
||||
enableHotkeys: true,
|
||||
|
@ -577,10 +579,13 @@ export class PeerTubeEmbed {
|
|||
})
|
||||
}
|
||||
|
||||
this.player = await PeertubePlayerManager.initialize(this.mode, options, (player: videojs.Player) => this.player = player)
|
||||
this.player = await PeertubePlayerManager.initialize(this.mode, options, (player: videojs.Player) => {
|
||||
this.player = player
|
||||
})
|
||||
|
||||
this.player.on('customError', (event: any, data: any) => this.handleError(data.err, serverTranslations))
|
||||
|
||||
window[ 'videojsPlayer' ] = this.player
|
||||
window['videojsPlayer'] = this.player
|
||||
|
||||
this.buildCSS()
|
||||
|
||||
|
@ -656,7 +661,7 @@ export class PeerTubeEmbed {
|
|||
this.player.dispose()
|
||||
this.playerElement = null
|
||||
this.displayError('This video is not available because the remote instance is not responding.', translations)
|
||||
return
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -694,9 +699,9 @@ export class PeerTubeEmbed {
|
|||
|
||||
private async buildCaptions (serverTranslations: any, captionsResponse: Response): Promise<VideoJSCaption[]> {
|
||||
if (captionsResponse.ok) {
|
||||
const { data } = (await captionsResponse.json()) as ResultList<VideoCaption>
|
||||
const { data } = await captionsResponse.json()
|
||||
|
||||
return data.map(c => ({
|
||||
return data.map((c: VideoCaption) => ({
|
||||
label: peertubeTranslate(c.language.label, serverTranslations),
|
||||
language: c.language.id,
|
||||
src: window.location.origin + c.captionPath
|
||||
|
@ -733,7 +738,7 @@ export class PeerTubeEmbed {
|
|||
|
||||
private getResourceId () {
|
||||
const urlParts = window.location.pathname.split('/')
|
||||
return urlParts[ urlParts.length - 1 ]
|
||||
return urlParts[urlParts.length - 1]
|
||||
}
|
||||
|
||||
private isPlaylistEmbed () {
|
||||
|
@ -751,7 +756,7 @@ export class PeerTubeEmbed {
|
|||
}
|
||||
|
||||
private buildPeerTubeHelpers (translations?: { [ id: string ]: string }): RegisterClientHelpers {
|
||||
function unimplemented (): any {
|
||||
const unimplemented = () => {
|
||||
throw new Error('This helper is not implemented in embed.')
|
||||
}
|
||||
|
||||
|
@ -780,9 +785,7 @@ export class PeerTubeEmbed {
|
|||
enhancedMarkdownToHTML: unimplemented
|
||||
},
|
||||
|
||||
translate: (value: string) => {
|
||||
return Promise.resolve(peertubeTranslate(value, translations))
|
||||
}
|
||||
translate: (value: string) => Promise.resolve(peertubeTranslate(value, translations))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue