aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/utils.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-06-07 16:50:33 +0200
committerChocobozzz <me@florianbigard.com>2018-06-07 16:50:33 +0200
commit6cca7360eb9027e1544f7513df7da4684061ef7e (patch)
tree16550f99324234a94cb7cdb098001051400079c9 /client/src/assets/player/utils.ts
parent09f35e2a6fa71d593c9b22f90109e91fc6be89a1 (diff)
downloadPeerTube-6cca7360eb9027e1544f7513df7da4684061ef7e.tar.gz
PeerTube-6cca7360eb9027e1544f7513df7da4684061ef7e.tar.zst
PeerTube-6cca7360eb9027e1544f7513df7da4684061ef7e.zip
Reduce bundle sizes
Diffstat (limited to 'client/src/assets/player/utils.ts')
-rw-r--r--client/src/assets/player/utils.ts25
1 files changed, 25 insertions, 0 deletions
diff --git a/client/src/assets/player/utils.ts b/client/src/assets/player/utils.ts
index ce7aaea2a..4eaf53720 100644
--- a/client/src/assets/player/utils.ts
+++ b/client/src/assets/player/utils.ts
@@ -1,4 +1,5 @@
1import { is18nLocale, isDefaultLocale } from '../../../../shared/models/i18n/i18n' 1import { is18nLocale, isDefaultLocale } from '../../../../shared/models/i18n/i18n'
2import { VideoFile } from '../../../../shared/models/videos'
2 3
3function toTitleCase (str: string) { 4function toTitleCase (str: string) {
4 return str.charAt(0).toUpperCase() + str.slice(1) 5 return str.charAt(0).toUpperCase() + str.slice(1)
@@ -97,6 +98,28 @@ function copyToClipboard (text: string) {
97 document.body.removeChild(el) 98 document.body.removeChild(el)
98} 99}
99 100
101function videoFileMaxByResolution (files: VideoFile[]) {
102 let max = files[0]
103
104 for (let i = 1; i < files.length; i++) {
105 const file = files[i]
106 if (max.resolution.id < file.resolution.id) max = file
107 }
108
109 return max
110}
111
112function videoFileMinByResolution (files: VideoFile[]) {
113 let min = files[0]
114
115 for (let i = 1; i < files.length; i++) {
116 const file = files[i]
117 if (min.resolution.id > file.resolution.id) min = file
118 }
119
120 return min
121}
122
100export { 123export {
101 toTitleCase, 124 toTitleCase,
102 buildVideoLink, 125 buildVideoLink,
@@ -107,6 +130,8 @@ export {
107 saveMuteInStore, 130 saveMuteInStore,
108 buildVideoEmbed, 131 buildVideoEmbed,
109 getStoredMute, 132 getStoredMute,
133 videoFileMaxByResolution,
134 videoFileMinByResolution,
110 copyToClipboard, 135 copyToClipboard,
111 isMobile, 136 isMobile,
112 bytes 137 bytes