aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/assets/player/utils.ts')
-rw-r--r--client/src/assets/player/utils.ts34
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
67function 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
79function buildVideoEmbed (embedUrl: string) {
80 return '<iframe width="560" height="315" ' +
81 'src="' + embedUrl + '" ' +
82 'frameborder="0" allowfullscreen>' +
83 '</iframe>'
84}
85
86function 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
67export { 98export {
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}