aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/misc/utils.ts
blob: df9e0381a32c7ab2a1254104d2421b84ffd925c6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Thanks: https://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript

function getParameterByName (name: string, url: string) {
  if (!url) url = window.location.href
  name = name.replace(/[\[\]]/g, '\\$&')

  const regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)')
  const results = regex.exec(url)

  if (!results) return null
  if (!results[2]) return ''

  return decodeURIComponent(results[2].replace(/\+/g, ' '))
}

function viewportHeight () {
  return Math.max(document.documentElement.clientHeight, window.innerHeight || 0)
}

export {
  viewportHeight,
  getParameterByName
}