diff options
author | Chocobozzz <me@florianbigard.com> | 2018-05-30 17:10:00 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-05-30 17:10:00 +0200 |
commit | 960a11e89da4e4a6ad6fbad61c71625f89e267b6 (patch) | |
tree | 0cd370970c3166dd3715e46a5503a3da78f25e37 /client/src/assets/player/utils.ts | |
parent | e10c7d5125c47830bd23ecfed2f1b2d1048e6639 (diff) | |
download | PeerTube-960a11e89da4e4a6ad6fbad61c71625f89e267b6.tar.gz PeerTube-960a11e89da4e4a6ad6fbad61c71625f89e267b6.tar.zst PeerTube-960a11e89da4e4a6ad6fbad61c71625f89e267b6.zip |
Add context menu to player
Diffstat (limited to 'client/src/assets/player/utils.ts')
-rw-r--r-- | client/src/assets/player/utils.ts | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/client/src/assets/player/utils.ts b/client/src/assets/player/utils.ts index 1df39d4e4..487b3a1be 100644 --- a/client/src/assets/player/utils.ts +++ b/client/src/assets/player/utils.ts | |||
@@ -64,14 +64,48 @@ function isMobile () { | |||
64 | return /iPhone|iPad|iPod|Android/i.test(navigator.userAgent) | 64 | return /iPhone|iPad|iPod|Android/i.test(navigator.userAgent) |
65 | } | 65 | } |
66 | 66 | ||
67 | function buildVideoLink (time?: number) { | ||
68 | let href = window.location.href.replace('/embed/', '/watch/') | ||
69 | if (time) { | ||
70 | const timeInt = Math.floor(time) | ||
71 | |||
72 | if (window.location.search) href += '&start=' + timeInt | ||
73 | else href += '?start=' + timeInt | ||
74 | } | ||
75 | |||
76 | return href | ||
77 | } | ||
78 | |||
79 | function buildVideoEmbed (embedUrl: string) { | ||
80 | return '<iframe width="560" height="315" ' + | ||
81 | 'src="' + embedUrl + '" ' + | ||
82 | 'frameborder="0" allowfullscreen>' + | ||
83 | '</iframe>' | ||
84 | } | ||
85 | |||
86 | function copyToClipboard (text: string) { | ||
87 | const el = document.createElement('textarea') | ||
88 | el.value = text | ||
89 | el.setAttribute('readonly', '') | ||
90 | el.style.position = 'absolute' | ||
91 | el.style.left = '-9999px' | ||
92 | document.body.appendChild(el) | ||
93 | el.select() | ||
94 | document.execCommand('copy') | ||
95 | document.body.removeChild(el) | ||
96 | } | ||
97 | |||
67 | export { | 98 | export { |
68 | toTitleCase, | 99 | toTitleCase, |
100 | buildVideoLink, | ||
69 | getStoredVolume, | 101 | getStoredVolume, |
70 | saveVolumeInStore, | 102 | saveVolumeInStore, |
71 | saveAverageBandwidth, | 103 | saveAverageBandwidth, |
72 | getAverageBandwidth, | 104 | getAverageBandwidth, |
73 | saveMuteInStore, | 105 | saveMuteInStore, |
106 | buildVideoEmbed, | ||
74 | getStoredMute, | 107 | getStoredMute, |
108 | copyToClipboard, | ||
75 | isMobile, | 109 | isMobile, |
76 | bytes | 110 | bytes |
77 | } | 111 | } |