aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/peertube-link-button.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/assets/player/peertube-link-button.ts')
-rw-r--r--client/src/assets/player/peertube-link-button.ts20
1 files changed, 7 insertions, 13 deletions
diff --git a/client/src/assets/player/peertube-link-button.ts b/client/src/assets/player/peertube-link-button.ts
index 54d802732..a13815d61 100644
--- a/client/src/assets/player/peertube-link-button.ts
+++ b/client/src/assets/player/peertube-link-button.ts
@@ -1,15 +1,19 @@
1import { VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings' 1import { VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings'
2import { buildVideoLink } from './utils'
2 3
3const Button: VideoJSComponentInterface = videojsUntyped.getComponent('Button') 4const Button: VideoJSComponentInterface = videojsUntyped.getComponent('Button')
4class PeerTubeLinkButton extends Button { 5class PeerTubeLinkButton extends Button {
5 6
7 constructor (player: videojs.Player, options) {
8 super(player, options)
9 }
10
6 createEl () { 11 createEl () {
7 return this.buildElement() 12 return this.buildElement()
8 } 13 }
9 14
10 updateHref () { 15 updateHref () {
11 const currentTime = Math.floor(this.player().currentTime()) 16 this.el().setAttribute('href', buildVideoLink(this.player().currentTime()))
12 this.el().setAttribute('href', this.buildHref(currentTime))
13 } 17 }
14 18
15 handleClick () { 19 handleClick () {
@@ -18,7 +22,7 @@ class PeerTubeLinkButton extends Button {
18 22
19 private buildElement () { 23 private buildElement () {
20 const el = videojsUntyped.dom.createEl('a', { 24 const el = videojsUntyped.dom.createEl('a', {
21 href: this.buildHref(), 25 href: buildVideoLink(),
22 innerHTML: 'PeerTube', 26 innerHTML: 'PeerTube',
23 title: 'Go to the video page', 27 title: 'Go to the video page',
24 className: 'vjs-peertube-link', 28 className: 'vjs-peertube-link',
@@ -29,15 +33,5 @@ class PeerTubeLinkButton extends Button {
29 33
30 return el 34 return el
31 } 35 }
32
33 private buildHref (time?: number) {
34 let href = window.location.href.replace('embed', 'watch')
35 if (time) {
36 if (window.location.search) href += '&start=' + time
37 else href += '?start=' + time
38 }
39
40 return href
41 }
42} 36}
43Button.registerComponent('PeerTubeLinkButton', PeerTubeLinkButton) 37Button.registerComponent('PeerTubeLinkButton', PeerTubeLinkButton)