aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/root-helpers
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/root-helpers')
-rw-r--r--client/src/root-helpers/index.ts3
-rw-r--r--client/src/root-helpers/video.ts33
-rw-r--r--client/src/root-helpers/web-browser.ts24
3 files changed, 59 insertions, 1 deletions
diff --git a/client/src/root-helpers/index.ts b/client/src/root-helpers/index.ts
index aa3b442dd..3b95b4b99 100644
--- a/client/src/root-helpers/index.ts
+++ b/client/src/root-helpers/index.ts
@@ -3,5 +3,6 @@ export * from './bytes'
3export * from './images' 3export * from './images'
4export * from './local-storage-utils' 4export * from './local-storage-utils'
5export * from './peertube-web-storage' 5export * from './peertube-web-storage'
6export * from './utils'
7export * from './plugins-manager' 6export * from './plugins-manager'
7export * from './utils'
8export * from './video'
diff --git a/client/src/root-helpers/video.ts b/client/src/root-helpers/video.ts
new file mode 100644
index 000000000..4290992aa
--- /dev/null
+++ b/client/src/root-helpers/video.ts
@@ -0,0 +1,33 @@
1import { HTMLServerConfig, Video } from '@shared/models'
2
3function buildVideoOrPlaylistEmbed (embedUrl: string, embedTitle: string) {
4 const iframe = document.createElement('iframe')
5
6 iframe.title = embedTitle
7 iframe.width = '560'
8 iframe.height = '315'
9 iframe.src = embedUrl
10 iframe.frameBorder = '0'
11 iframe.allowFullscreen = true
12 iframe.sandbox.add('allow-same-origin', 'allow-scripts', 'allow-popups')
13
14 return iframe.outerHTML
15}
16
17function isP2PEnabled (video: Video, config: HTMLServerConfig, userP2PEnabled: boolean) {
18 if (video.isLocal && config.tracker.enabled === false) return false
19 if (isWebRTCDisabled()) return false
20
21 return userP2PEnabled
22}
23
24export {
25 buildVideoOrPlaylistEmbed,
26 isP2PEnabled
27}
28
29// ---------------------------------------------------------------------------
30
31function isWebRTCDisabled () {
32 return !!((window as any).RTCPeerConnection || (window as any).mozRTCPeerConnection || (window as any).webkitRTCPeerConnection) === false
33}
diff --git a/client/src/root-helpers/web-browser.ts b/client/src/root-helpers/web-browser.ts
new file mode 100644
index 000000000..9dade20e8
--- /dev/null
+++ b/client/src/root-helpers/web-browser.ts
@@ -0,0 +1,24 @@
1function isIOS () {
2 if (/iPad|iPhone|iPod/.test(navigator.platform)) {
3 return true
4 }
5
6 // Detect iPad Desktop mode
7 return !!(navigator.maxTouchPoints &&
8 navigator.maxTouchPoints > 2 &&
9 navigator.platform.includes('MacIntel'))
10}
11
12function isSafari () {
13 return /^((?!chrome|android).)*safari/i.test(navigator.userAgent)
14}
15
16function isMobile () {
17 return /iPhone|iPad|iPod|Android/i.test(navigator.userAgent)
18}
19
20export {
21 isIOS,
22 isSafari,
23 isMobile
24}