aboutsummaryrefslogtreecommitdiff
path: root/public/javascripts/featureDetect.js
blob: af3ada2b0c6e26814849ee1324a4d05675c874c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* global FLAGS */

const self = {}

self._nodes = {
  input: document.querySelector('input[type="search"]'),
  overflowButton: document.querySelector('#overflow-button')
}

self._shouldCheck = function () {
  return FLAGS.indexOf('NO_FEATURE_DETECT') === -1
}

self._redirect = function () {
  if (process.env.SCHOOL_LEVEL === 'mavo') {
    window.location.href = 'http://www.meetingpointmco.nl/Roosters-AL/TOSweb/'
  } else {
    window.location.href = 'http://www.meetingpointmco.nl/Roosters-AL/doc/'
  }
}

self.check = function () {
  if (!self._shouldCheck()) return

  window.onerror = self._redirect

  if (self._nodes.input.getClientRects()[0].top !==
      self._nodes.overflowButton.getClientRects()[0].top) {
    self._redirect()
  }
}

module.exports = self