1 // Thanks: https://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript
3 import { environment } from '../../../environments/environment'
4 import { AuthService } from '../../core/auth'
6 function getParameterByName (name: string, url: string) {
7 if (!url) url = window.location.href
8 name = name.replace(/[\[\]]/g, '\\$&')
10 const regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)')
11 const results = regex.exec(url)
13 if (!results) return null
14 if (!results[2]) return ''
16 return decodeURIComponent(results[2].replace(/\+/g, ' '))
19 function viewportHeight () {
20 return Math.max(document.documentElement.clientHeight, window.innerHeight || 0)
23 function populateAsyncUserVideoChannels (authService: AuthService, channel: any[]) {
24 return new Promise(res => {
25 authService.userInformationLoaded
28 const user = authService.getUser()
31 const videoChannels = user.videoChannels
32 if (Array.isArray(videoChannels) === false) return
34 videoChannels.forEach(c => channel.push({ id: c.id, label: c.displayName }))
42 function getAbsoluteAPIUrl () {
43 let absoluteAPIUrl = environment.apiUrl
44 if (!absoluteAPIUrl) {
45 // The API is on the same domain
46 absoluteAPIUrl = window.location.origin
55 populateAsyncUserVideoChannels,