aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md9
-rw-r--r--app.js11
-rwxr-xr-xbin/www75
-rw-r--r--lib/getURLOfUser.js8
-rw-r--r--lib/getURLOfUsers.js45
-rw-r--r--lib/getUserIndex.js113
-rw-r--r--package.json8
-rw-r--r--public/javascripts/autocomplete.js46
-rw-r--r--public/javascripts/bundle.js1574
-rw-r--r--public/javascripts/favorite.js2
-rw-r--r--public/javascripts/main.bak.js244
-rw-r--r--public/javascripts/main.js53
-rw-r--r--public/javascripts/schedule.js28
-rw-r--r--public/javascripts/scrollSnap.js14
-rw-r--r--public/javascripts/search.js27
-rw-r--r--public/javascripts/url.js67
-rw-r--r--public/javascripts/zoom.js30
-rw-r--r--public/manifest.beta.webmanifest29
-rw-r--r--public/stylesheets/style.css13
-rw-r--r--routes/getSchedule.js55
-rw-r--r--routes/hello.js9
-rw-r--r--routes/index.js29
-rw-r--r--routes/manifest.js19
-rw-r--r--routes/meetingpointProxy.js19
-rw-r--r--routes/opensearch.js12
-rw-r--r--views/hello.jade9
-rw-r--r--views/index.jade3
-rw-r--r--views/layout.jade10
28 files changed, 2021 insertions, 540 deletions
diff --git a/README.md b/README.md
index cf6bd4a..65a104e 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,7 @@
-<img src="public/icons/res/mipmap-xhdpi/ic_launcher.png" alt="" align="right" height="70px">
-
-# Metis Rooster - [rooster.hetmml.nl](http://rooster.hetmml.nl/)
-The search engine of the MML Schedule page
+<p align="center">
+ <img src="public/icons/res/mipmap-xxxhdpi/ic_launcher.png" alt="" width="192px" height="192px">
+</p>
+<h1 align="center">Metis Rooster - <a href="http://rooster.hetmml.nl/">rooster.hetmml.nl</a></h1>
+<blockquote align="center">The search engine of the MML Schedule page</blockquote>
![Screenshot of page](https://noahloomans.com/assets/projects/rooster.hetmml.nl.png/)
diff --git a/app.js b/app.js
index 58188e4..c0a0b35 100644
--- a/app.js
+++ b/app.js
@@ -6,8 +6,8 @@ const bodyParser = require('body-parser')
const compression = require('compression')
const routes = require('./routes/index')
-const meetingpointProxy = require('./routes/meetingpointProxy')
-const hello = require('./routes/hello')
+const getSchedule = require('./routes/getSchedule')
+const manifest = require('./routes/manifest')
const app = express()
@@ -17,15 +17,16 @@ app.use(compression())
app.set('views', path.join(__dirname, 'views'))
app.set('view engine', 'jade')
-app.use(logger('common'))
+app.use(logger('dev'))
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: false }))
app.use(cookieParser())
+
+app.use('/manifest.webmanifest', manifest)
app.use(express.static(path.join(__dirname, 'public')))
app.use('/', routes)
-app.use('/meetingpointProxy', meetingpointProxy)
-app.use('/hello', hello)
+app.use('/get', getSchedule)
// catch 404 and forward to error handler
app.use(function (req, res, next) {
diff --git a/bin/www b/bin/www
index 4c375d3..545db41 100755
--- a/bin/www
+++ b/bin/www
@@ -1,52 +1,14 @@
#!/usr/bin/env node
-const fs = require('fs')
const app = require('../app')
const http = require('http')
-const https = require('spdy')
-const fileLocations = {
- cert: '/etc/letsencrypt/live/rooster.hetmml.nl/fullchain.pem',
- privkey: '/etc/letsencrypt/live/rooster.hetmml.nl/privkey.pem'
-}
-
-function setupHTTPS () {
- const certificate = fs.readFileSync(fileLocations.cert, 'utf8')
- const privateKey = fs.readFileSync(fileLocations.privkey, 'utf8')
- const credentials = { key: privateKey, cert: certificate }
-
- const httpsPort = normalizePort(process.env.PORT_HTTPS || '3001')
- const httpsServer = https.createServer(credentials, app)
+const port = normalizePort(process.env.PORT || '3000')
+const server = http.createServer(app)
- httpsServer.listen(httpsPort)
- httpsServer.on('error', error => onError(error, httpsPort))
- httpsServer.on('listening', _ => onListening(httpsServer))
-
- app.set('port', httpsPort)
-}
-
-function redirectToHTTPS (req, res) {
- res.writeHead(301, { 'Location': 'https://' + req.headers['host'] + req.url })
- res.end()
-}
-
-function setupHTTPSRedirect () {
- const httpPort = normalizePort(process.env.PORT || '3000')
- const httpServer = http.createServer(redirectToHTTPS)
-
- httpServer.listen(httpPort)
- httpServer.on('error', error => onError(error, httpPort))
- httpServer.on('listening', _ => onListening(httpServer))
-}
-
-function setupHTTP () {
- const httpPort = normalizePort(process.env.PORT || '3000')
- const httpServer = http.createServer(app)
-
- httpServer.listen(httpPort)
- httpServer.on('error', error => onError(error, httpPort))
- httpServer.on('listening', _ => onListening(httpServer))
-}
+server.listen(port)
+server.on('error', error => onError(error, port))
+server.on('listening', _ => onListening(server))
function normalizePort (val) {
const port = parseInt(val, 10)
@@ -90,28 +52,9 @@ function onError (error, port) {
function onListening (server) {
const addr = server.address()
- const bind = typeof addr === 'string'
- ? 'pipe ' + addr
- : 'port ' + addr.port
- console.log('Listening on ' + bind)
-}
-
-let useHTTPS = true
-try {
- fs.accessSync(fileLocations.privkey)
-} catch (e) {
- useHTTPS = false
-}
-
-if (useHTTPS) {
- try {
- setupHTTPS()
- setupHTTPSRedirect()
- } catch (e) {
- console.warn('NOT USING HTTPS! Error occured while setting up HTTPS')
- setupHTTP()
+ if (typeof addr === 'string') {
+ console.log(`Listening on pipe ${addr}`)
+ } else {
+ console.log(`Listening on http://localhost:${addr.port}/`)
}
-} else {
- console.warn(`NOT USING HTTPS! Could not read ${fileLocations.privkey}`)
- setupHTTP()
}
diff --git a/lib/getURLOfUser.js b/lib/getURLOfUser.js
new file mode 100644
index 0000000..2de48e6
--- /dev/null
+++ b/lib/getURLOfUser.js
@@ -0,0 +1,8 @@
+const leftPad = require('left-pad') // I imported this just to piss you off ;)
+
+function getURLOfUser (type, index, week) {
+ return `http://www.meetingpointmco.nl/Roosters-AL/doc/dagroosters/` +
+ `${leftPad(week, 2, '0')}/${type}/${type}${leftPad(index + 1, 5, '0')}.htm`
+}
+
+module.exports = getURLOfUser
diff --git a/lib/getURLOfUsers.js b/lib/getURLOfUsers.js
deleted file mode 100644
index 8590ee4..0000000
--- a/lib/getURLOfUsers.js
+++ /dev/null
@@ -1,45 +0,0 @@
-const leftPad = require('left-pad')
-
-// copied from http://www.meetingpointmco.nl/Roosters-AL/doc/dagroosters/untisscripts.js,
-// were using the same code as they do to be sure that we always get the same
-// week number.
-function getWeek () {
- // Create a copy of this date object
- var target = new Date()
-
- // ISO week date weeks start on monday
- // so correct the day number
- var dayNr = (target.getDay() + 6) % 7
-
- // ISO 8601 states that week 1 is the week
- // with the first thursday of that year.
- // Set the target date to the thursday in the target week
- target.setDate(target.getDate() - dayNr + 3)
-
- // Store the millisecond value of the target date
- var firstThursday = target.valueOf()
-
- // Set the target to the first thursday of the year
- // First set the target to january first
- target.setMonth(0, 1)
- // Not a thursday? Correct the date to the next thursday
- if (target.getDay() !== 4) {
- target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7)
- }
-
- // The weeknumber is the number of weeks between the
- // first thursday of the year and the thursday in the target week
- return 1 + Math.ceil((firstThursday - target) / 604800000) // 604800000 = 7 * 24 * 3600 * 1000
-}
-
-function getURLOfUsers (weekOffset, type, id) {
- return `http://www.meetingpointmco.nl/Roosters-AL/doc/dagroosters/` +
- `${getWeek() + weekOffset}/${type}/${type}${leftPad(id, 5, '0')}.htm`
-}
-
-module.exports = getURLOfUsers
-
-module.exports.CLASS = 'c'
-module.exports.TEACHERS = 't'
-module.exports.ROOMS = 'r'
-module.exports.STUDENTS = 's'
diff --git a/lib/getUserIndex.js b/lib/getUserIndex.js
index d71cb3b..db7daa8 100644
--- a/lib/getUserIndex.js
+++ b/lib/getUserIndex.js
@@ -4,59 +4,82 @@ const Promise = require('bluebird')
const cheerio = require('cheerio')
const request = Promise.promisify(require('request'))
-exports = {}
-module.exports = exports
+let userIndex
+let lastUpdate
-function getStandardUsers () {
+function updateUserIndex () {
return new Promise(function (resolve, reject) {
+ process.stdout.write('Updating user index... ')
request(`http://www.meetingpointmco.nl/Roosters-AL/doc/dagroosters/frames/navbar.htm`)
- .then(function (page) {
- page = page.body
+ .then(function (page) {
+ lastUpdate = new Date()
+ page = page.body
- const $ = cheerio.load(page)
- const $script = $('script').eq(1)
- const scriptText = $script.text()
+ const $ = cheerio.load(page)
+ const $script = $('script').eq(1)
+ const scriptText = $script.text()
- const regexs = [/var classes = \[(.+)\];/, /var teachers = \[(.+)\];/, /var rooms = \[(.+)\];/, /var students = \[(.+)\];/]
- const items = regexs.map(function (regex) {
- return scriptText.match(regex)[1].split(',').map(function (item) {
- return item.replace(/"/g, '')
+ const regexs = [/var classes = \[(.+)];/, /var teachers = \[(.+)];/, /var rooms = \[(.+)];/, /var students = \[(.+)];/]
+ const items = regexs.map(function (regex) {
+ return scriptText.match(regex)[1].split(',').map(function (item) {
+ return item.replace(/"/g, '')
+ })
})
+
+ userIndex = ([]
+ .concat(items[0].map(function (item, index) {
+ return {
+ type: 'c',
+ value: item,
+ index: index
+ }
+ }))
+ .concat(items[1].map(function (item, index) {
+ return {
+ type: 't',
+ value: item,
+ index: index
+ }
+ }))
+ .concat(items[2].map(function (item, index) {
+ return {
+ type: 'r',
+ value: item,
+ index: index
+ }
+ }))
+ .concat(items[3].map(function (item, index) {
+ return {
+ type: 's',
+ value: item,
+ index: index
+ }
+ })))
+
+ process.stdout.write('done.\n')
+
+ resolve(userIndex)
+ })
+ .catch(error => {
+ process.stdout.write('failed.\n')
+ reject(error)
})
+ })
+}
- resolve([]
- .concat(items[0].map(function (item, index) {
- return {
- type: 'c',
- value: item,
- index: index
- }
- }))
- .concat(items[1].map(function (item, index) {
- return {
- type: 't',
- value: item,
- index: index
- }
- }))
- .concat(items[2].map(function (item, index) {
- return {
- type: 'r',
- value: item,
- index: index
- }
- }))
- .concat(items[3].map(function (item, index) {
- return {
- type: 's',
- value: item,
- index: index
- }
- })))
- })
+function getUserIndex () {
+ return new Promise((resolve, reject) => {
+ if (lastUpdate == null) {
+ updateUserIndex().then(resolve, reject)
+ } else if (new Date() - lastUpdate > 10 * 60 * 1000) { // 10 minutes
+ updateUserIndex().then(resolve, function () {
+ console.warn('Unable to update userIndex, using cached.')
+ resolve(userIndex)
+ })
+ } else {
+ resolve(userIndex)
+ }
})
}
-getStandardUsers().then(users => {
- exports.users = users
-})
+module.exports = getUserIndex
diff --git a/package.json b/package.json
index 6bded05..c6052b2 100644
--- a/package.json
+++ b/package.json
@@ -12,12 +12,12 @@
},
"dependencies": {
"bluebird": "^3.4.6",
- "body-parser": "~1.15.1",
+ "body-parser": "^1.16.0",
"browser-request": "^0.3.3",
"cheerio": "^0.22.0",
"compression": "^1.6.2",
"cookie-parser": "~1.4.3",
- "debug": "~2.2.0",
+ "debug": "^2.6.0",
"diacritics": "^1.2.3",
"encoding": "^0.1.12",
"express": "^4.13.4",
@@ -34,10 +34,10 @@
"then-yield": "0.0.1"
},
"devDependencies": {
- "babel-preset-es2016": "^6.16.0",
+ "babel-preset-es2015": "^6.22.0",
"babelify": "^7.3.0",
"bower": "^1.7.9",
- "browserify": "^13.1.0",
+ "browserify": "^14.0.0",
"gulp": "^3.9.1",
"watchify": "^3.7.0"
},
diff --git a/public/javascripts/autocomplete.js b/public/javascripts/autocomplete.js
index 71fb17d..61f400a 100644
--- a/public/javascripts/autocomplete.js
+++ b/public/javascripts/autocomplete.js
@@ -2,8 +2,8 @@ const EventEmitter = require('events')
const self = new EventEmitter()
-self._items = []
-self._selectedItemIndex = -1
+self._users = []
+self._selectedUserIndex = -1
self._nodes = {
search: document.querySelector('#search'),
@@ -11,63 +11,63 @@ self._nodes = {
autocomplete: document.querySelector('.autocomplete')
}
-self.getSelectedItem = function () {
+self.getSelectedUser = function () {
if (self.getItems() === []) return
- if (self.getSelectedItemIndex() === -1) {
+ if (self.getSelectedUserIndex() === -1) {
return self.getItems()[0]
} else {
- return self.getItems()[self.getSelectedItemIndex()]
+ return self.getItems()[self.getSelectedUserIndex()]
}
}
-self.getSelectedItemIndex = function () {
- return self._selectedItemIndex
+self.getSelectedUserIndex = function () {
+ return self._selectedUserIndex
}
self.getItems = function () {
- return self._items
+ return self._users
}
self.removeAllItems = function () {
while (self._nodes.autocomplete.firstChild) {
self._nodes.autocomplete.removeChild(self._nodes.autocomplete.firstChild)
}
- self._items = []
- self._selectedItemIndex = -1
+ self._users = []
+ self._selectedUserIndex = -1
}
-self.addItem = function (item) {
+self.addItem = function (user) {
const listItem = document.createElement('li')
- listItem.textContent = item.value
+ listItem.textContent = user.value
self._nodes.autocomplete.appendChild(listItem)
- self._items.push(item)
+ self._users.push(user)
}
self._moveSelected = function (shift) {
- if (self._selectedItemIndex + shift >= self.getItems().length) {
- self._selectedItemIndex = -1
- } else if (self._selectedItemIndex + shift < -1) {
- self._selectedItemIndex = self.getItems().length - 1
+ if (self._selectedUserIndex + shift >= self.getItems().length) {
+ self._selectedUserIndex = -1
+ } else if (self._selectedUserIndex + shift < -1) {
+ self._selectedUserIndex = self.getItems().length - 1
} else {
- self._selectedItemIndex += shift
+ self._selectedUserIndex += shift
}
for (let i = 0; i < self.getItems().length; i++) {
self._nodes.autocomplete.children[i].classList.remove('selected')
}
- if (self._selectedItemIndex >= 0) {
+ if (self._selectedUserIndex >= 0) {
self._nodes.autocomplete
- .children[self._selectedItemIndex].classList.add('selected')
+ .children[self._selectedUserIndex].classList.add('selected')
}
}
self._handleItemClick = function (event) {
if (!self._nodes.autocomplete.contains(event.target)) return
- const itemIndex = Array.prototype.indexOf
+ const userIndex = Array.prototype.indexOf
.call(self._nodes.autocomplete.children, event.target)
- self._selectedItemIndex = itemIndex
- self.emit('select', self.getSelectedItem())
+ self._selectedUserIndex = userIndex
+ self.emit('select', self.getSelectedUser())
}
self._handleKeydown = function (event) {
diff --git a/public/javascripts/bundle.js b/public/javascripts/bundle.js
index a4f7681..48414ad 100644
--- a/public/javascripts/bundle.js
+++ b/public/javascripts/bundle.js
@@ -1 +1,1573 @@
-!function e(t,n,o){function r(i,l){if(!n[i]){if(!t[i]){var c="function"==typeof require&&require;if(!l&&c)return c(i,!0);if(s)return s(i,!0);var u=new Error("Cannot find module '"+i+"'");throw u.code="MODULE_NOT_FOUND",u}var a=n[i]={exports:{}};t[i][0].call(a.exports,function(e){var n=t[i][1][e];return r(n?n:e)},a,a.exports,e,t,n,o)}return n[i].exports}for(var s="function"==typeof require&&require,i=0;i<o.length;i++)r(o[i]);return r}({1:[function(e,t,n){function o(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function r(e){return"function"==typeof e}function s(e){return"number"==typeof e}function i(e){return"object"==typeof e&&null!==e}function l(e){return void 0===e}t.exports=o,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._maxListeners=void 0,o.defaultMaxListeners=10,o.prototype.setMaxListeners=function(e){if(!s(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},o.prototype.emit=function(e){var t,n,o,s,c,u;if(this._events||(this._events={}),"error"===e&&(!this._events.error||i(this._events.error)&&!this._events.error.length)){if(t=arguments[1],t instanceof Error)throw t;var a=new Error('Uncaught, unspecified "error" event. ('+t+")");throw a.context=t,a}if(n=this._events[e],l(n))return!1;if(r(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:s=Array.prototype.slice.call(arguments,1),n.apply(this,s)}else if(i(n))for(s=Array.prototype.slice.call(arguments,1),u=n.slice(),o=u.length,c=0;c<o;c++)u[c].apply(this,s);return!0},o.prototype.addListener=function(e,t){var n;if(!r(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,r(t.listener)?t.listener:t),this._events[e]?i(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,i(this._events[e])&&!this._events[e].warned&&(n=l(this._maxListeners)?o.defaultMaxListeners:this._maxListeners,n&&n>0&&this._events[e].length>n&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())),this},o.prototype.on=o.prototype.addListener,o.prototype.once=function(e,t){function n(){this.removeListener(e,n),o||(o=!0,t.apply(this,arguments))}if(!r(t))throw TypeError("listener must be a function");var o=!1;return n.listener=t,this.on(e,n),this},o.prototype.removeListener=function(e,t){var n,o,s,l;if(!r(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],s=n.length,o=-1,n===t||r(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(i(n)){for(l=s;l-- >0;)if(n[l]===t||n[l].listener&&n[l].listener===t){o=l;break}if(o<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(o,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},o.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],r(n))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},o.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?r(this._events[e])?[this._events[e]]:this._events[e].slice():[]},o.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(r(t))return 1;if(t)return t.length}return 0},o.listenerCount=function(e,t){return e.listenerCount(t)}},{}],2:[function(e,t,n){!function(){var e=this,o={};"undefined"!=typeof n?t.exports=o:e.fuzzy=o,o.simpleFilter=function(e,t){return t.filter(function(t){return o.test(e,t)})},o.test=function(e,t){return null!==o.match(e,t)},o.match=function(e,t,n){n=n||{};var o,r=0,s=[],i=t.length,l=0,c=0,u=n.pre||"",a=n.post||"",d=n.caseSensitive&&t||t.toLowerCase();e=n.caseSensitive&&e||e.toLowerCase();for(var f=0;f<i;f++)o=t[f],d[f]===e[r]?(o=u+o+a,r+=1,c+=1+c):c=0,l+=c,s[s.length]=o;return r===e.length?{rendered:s.join(""),score:l}:null},o.filter=function(e,t,n){return n=n||{},t.reduce(function(t,r,s,i){var l=r;n.extract&&(l=n.extract(r));var c=o.match(e,l,n);return null!=c&&(t[t.length]={string:c.rendered,score:c.score,index:s,original:r}),t},[]).sort(function(e,t){var n=t.score-e.score;return n?n:e.index-t.index})}}()},{}],3:[function(e,t,n){"use strict";function o(e,t,n){if(e+="",t-=e.length,t<=0)return e;if(n||0===n||(n=" "),n+=""," "===n&&t<10)return r[t]+e;for(var o="";;){if(1&t&&(o+=n),t>>=1,!t)break;n+=n}return o+e}t.exports=o;var r=[""," "," "," "," "," "," "," "," "," "]},{}],4:[function(e,t,n){!function(e,o,r){"use strict";function s(){function t(e,t){this.scrollLeft=e,this.scrollTop=t}function n(e){return.5*(1-Math.cos(Math.PI*e))}function s(e){if("object"!=typeof e||null===e||e.behavior===r||"auto"===e.behavior||"instant"===e.behavior)return!0;if("object"==typeof e&&"smooth"===e.behavior)return!1;throw new TypeError("behavior not valid")}function i(t){var n,r,s;do t=t.parentNode,n=t===o.body,r=t.clientHeight<t.scrollHeight||t.clientWidth<t.scrollWidth,s="visible"===e.getComputedStyle(t,null).overflow;while(!n&&(!r||s));return n=r=s=null,t}function l(t){t.frame=e.requestAnimationFrame(l.bind(e,t));var o,r,s,i=f(),c=(i-t.startTime)/a;if(c=c>1?1:c,o=n(c),r=t.startX+(t.x-t.startX)*o,s=t.startY+(t.y-t.startY)*o,t.method.call(t.scrollable,r,s),r===t.x&&s===t.y)return void e.cancelAnimationFrame(t.frame)}function c(n,r,s){var i,c,u,a,h,v=f();n===o.body?(i=e,c=e.scrollX||e.pageXOffset,u=e.scrollY||e.pageYOffset,a=d.scroll):(i=n,c=n.scrollLeft,u=n.scrollTop,a=t),h&&e.cancelAnimationFrame(h),l({scrollable:i,method:a,startTime:v,startX:c,startY:u,x:r,y:s,frame:h})}if(!("scrollBehavior"in o.documentElement.style)){var u=e.HTMLElement||e.Element,a=468,d={scroll:e.scroll||e.scrollTo,scrollBy:e.scrollBy,scrollIntoView:u.prototype.scrollIntoView},f=e.performance&&e.performance.now?e.performance.now.bind(e.performance):Date.now;e.scroll=e.scrollTo=function(){return s(arguments[0])?void d.scroll.call(e,arguments[0].left||arguments[0],arguments[0].top||arguments[1]):void c.call(e,o.body,~~arguments[0].left,~~arguments[0].top)},e.scrollBy=function(){return s(arguments[0])?void d.scrollBy.call(e,arguments[0].left||arguments[0],arguments[0].top||arguments[1]):void c.call(e,o.body,~~arguments[0].left+(e.scrollX||e.pageXOffset),~~arguments[0].top+(e.scrollY||e.pageYOffset))},u.prototype.scrollIntoView=function(){if(s(arguments[0]))return void d.scrollIntoView.call(this,arguments[0]||!0);var t=i(this),n=t.getBoundingClientRect(),r=this.getBoundingClientRect();t!==o.body?(c.call(this,t,t.scrollLeft+r.left-n.left,t.scrollTop+r.top-n.top),e.scrollBy({left:n.left,top:n.top,behavior:"smooth"})):e.scrollBy({left:r.left,top:r.top,behavior:"smooth"})}}}"object"==typeof n?t.exports={polyfill:s}:s()}(window,document)},{}],5:[function(e,t,n){"use strict";var o={};o.send={},o.send.search=function(e,t){var n="event",o=t?"search fav":"search",r=void 0;switch(e.type){case"c":r="Class";break;case"t":r="Teacher";break;case"r":r="Room";break;case"s":r="Student"}var s=e.value;ga(function(){ga("send",{hitType:n,eventCategory:o,eventAction:r,eventLabel:s})})},t.exports=o},{}],6:[function(e,t,n){"use strict";var o=e("events"),r=new o;r._items=[],r._selectedItemIndex=-1,r._nodes={search:document.querySelector("#search"),input:document.querySelector('input[type="search"]'),autocomplete:document.querySelector(".autocomplete")},r.getSelectedItem=function(){if(r.getItems()!==[])return r.getSelectedItemIndex()===-1?r.getItems()[0]:r.getItems()[r.getSelectedItemIndex()]},r.getSelectedItemIndex=function(){return r._selectedItemIndex},r.getItems=function(){return r._items},r.removeAllItems=function(){for(;r._nodes.autocomplete.firstChild;)r._nodes.autocomplete.removeChild(r._nodes.autocomplete.firstChild);r._items=[],r._selectedItemIndex=-1},r.addItem=function(e){var t=document.createElement("li");t.textContent=e.value,r._nodes.autocomplete.appendChild(t),r._items.push(e)},r._moveSelected=function(e){r._selectedItemIndex+e>=r.getItems().length?r._selectedItemIndex=-1:r._selectedItemIndex+e<-1?r._selectedItemIndex=r.getItems().length-1:r._selectedItemIndex+=e;for(var t=0;t<r.getItems().length;t++)r._nodes.autocomplete.children[t].classList.remove("selected");r._selectedItemIndex>=0&&r._nodes.autocomplete.children[r._selectedItemIndex].classList.add("selected")},r._handleItemClick=function(e){if(r._nodes.autocomplete.contains(e.target)){var t=Array.prototype.indexOf.call(r._nodes.autocomplete.children,e.target);r._selectedItemIndex=t,r.emit("select",r.getSelectedItem())}},r._handleKeydown=function(e){"ArrowDown"!==e.key&&"ArrowUp"!==e.key||(e.preventDefault(),"ArrowDown"===e.key?r._moveSelected(1):"ArrowUp"===e.key&&r._moveSelected(-1))},r._nodes.autocomplete.addEventListener("click",r._handleItemClick),r._nodes.input.addEventListener("keydown",r._handleKeydown),t.exports=r},{events:1}],7:[function(e,t,n){"use strict";var o={};o.isIE=navigator.userAgent.indexOf("MSIE")!==-1||navigator.appVersion.indexOf("Trident/")>0,o.isIE?o.inputEvent="textinput":o.inputEvent="input",t.exports=o},{}],8:[function(e,t,n){"use strict";var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},r=e("events"),s=new r;s._nodes={toggle:document.querySelector(".fav")},s.get=function(){try{var e=function(){var e=JSON.parse(window.localStorage.getItem("fav"));if(null==e)return{v:void 0};var t=USERS.filter(function(t){return t.type===e.type&&t.value===e.value})[0];return{v:t}}();if("object"===("undefined"==typeof e?"undefined":o(e)))return e.v}catch(e){return void s.delete()}},s.set=function(e){window.localStorage.setItem("fav",JSON.stringify(e)),s._nodes.innerHTML="&#xE838;"},s.delete=function(){window.localStorage.removeItem("fav")},s.updateDom=function(e){e?s._nodes.toggle.innerHTML="&#xE838;":s._nodes.toggle.innerHTML="&#xE83A"},s.update=function(e){var t=s.get();if(null==t)return void s.updateDom(!1);var n=t.type===e.type&&t.index===e.index;s.updateDom(n)},s.toggle=function(e){var t=s.get(),n=null!=t&&t.type===e.type&&t.index===e.index;n?(s.delete(),s.updateDom(!1)):(s.set(e),s.updateDom(!0))},s._handleClick=function(){s.emit("click")},s._nodes.toggle.addEventListener("click",s._handleClick),t.exports=s},{events:1}],9:[function(e,t,n){"use strict";var o={};o._nodes={input:document.querySelector('input[type="search"]'),overflowButton:document.querySelector("#overflow-button")},o._shouldCheck=function(){return FLAGS.indexOf("NO_FEATURE_DETECT")===-1},o._redirect=function(){window.location.href="http://www.meetingpointmco.nl/Roosters-AL/doc/"},o.check=function(){o._shouldCheck()&&(window.onerror=o._redirect,o._nodes.input.getClientRects()[0].top!==o._nodes.overflowButton.getClientRects()[0].top&&o._redirect())},t.exports=o},{}],10:[function(e,t,n){"use strict";var o=e("./browserFixToolkit"),r={};r._nodes={input:document.querySelector('input[type="search"]')},r.isShown=!1,r.show=function(){document.body.classList.add("no-input"),r.isShown=!0},r.hide=function(){document.body.classList.remove("no-input"),r.isShown=!1},r._nodes.input.addEventListener(o.inputEvent,r.hide),t.exports=r},{"./browserFixToolkit":7}],11:[function(e,t,n){"use strict";e("./featureDetect").check();var o=e("./frontpage"),r=e("./search"),s=e("./schedule"),i=e("./weekSelector"),l=e("./favorite"),c=e("./scrollSnap"),u=e("./analytics"),a={};window.state=a,window.require=e,o.show(),i.updateCurrentWeek(),c.startListening(),null!=l.get()?(a.selectedItem=l.get(),l.update(a.selectedItem),u.send.search(a.selectedItem,!0),s.viewItem(i.getSelectedWeek(),a.selectedItem)):r.focus(),r.on("search",function(e){a.selectedItem=e,l.update(a.selectedItem),u.send.search(a.selectedItem),s.viewItem(i.getSelectedWeek(),a.selectedItem)}),i.on("weekChanged",function(e){u.send.search(a.selectedItem),s.viewItem(e,a.selectedItem)}),l.on("click",function(){l.toggle(a.selectedItem)}),document.body.style.opacity=1},{"./analytics":5,"./favorite":8,"./featureDetect":9,"./frontpage":10,"./schedule":12,"./scrollSnap":13,"./search":14,"./weekSelector":15}],12:[function(e,t,n){"use strict";var o=e("events"),r=e("left-pad"),s=e("./search"),i=new o;i._nodes={schedule:document.querySelector("#schedule")},i._parseMeetingpointHTML=function(e){var t=document.createElement("html");t.innerHTML=e;var n=t.querySelector("center");return n},i._handleLoad=function(e){var t=e.target;if(t.status<200||t.status>=400)return void i._handleError(e);var n=i._parseMeetingpointHTML(t.response);i._removeChilds(),i._nodes.schedule.appendChild(n),i._nodes.schedule.classList.remove("error"),i.emit("load")},i._handleError=function(e){var t=e.target,n=void 0;n=404===t.status?"Sorry, er is (nog) geen rooster voor deze week.":"Sorry, er is iets mis gegaan tijdens het laden van deze week.",i._removeChilds(),i._nodes.schedule.textContent=n,i._nodes.schedule.classList.add("error"),i.emit("load")},i._getURLOfUsers=function(e,t,n){var o=n+1;return"//"+window.location.host+"/meetingpointProxy/Roosters-AL%2Fdoc%2Fdagroosters%2F"+r(e,2,"0")+"%2F"+t+"%2F"+t+r(o,5,"0")+".htm"},i._removeChilds=function(){for(;i._nodes.schedule.firstChild;)i._nodes.schedule.removeChild(i._nodes.schedule.firstChild)},i.viewItem=function(e,t){var n=i._getURLOfUsers(e,t.type,t.index);i._removeChilds();var o=new window.XMLHttpRequest;o.addEventListener("load",i._handleLoad),o.addEventListener("error",i._handleError),o.open("GET",n,!0),o.send(),s.updateDom(t)},t.exports=i},{"./search":14,events:1,"left-pad":3}],13:[function(e,t,n){"use strict";e("smoothscroll-polyfill").polyfill();var o={},r=e("./schedule");o._nodes={search:document.querySelector("#search"),weekSelector:document.querySelector("#week-selector")},o._timeoutID=null,o._getScrollPosition=function(){return document.documentElement&&document.documentElement.scrollTop||document.body.scrollTop},o._handleDoneScrolling=function(){var e=o._getScrollPosition(),t=o._nodes.weekSelector.clientHeight-o._nodes.search.clientHeight;e<t&&e>0&&window.scroll({top:t,left:0,behavior:"smooth"})},o._handleScroll=function(){null!=o._timeoutID&&window.clearTimeout(o._timeoutID),o._timeoutID=window.setTimeout(o._handleDoneScrolling,500);var e=o._getScrollPosition(),t=o._nodes.weekSelector.clientHeight-o._nodes.search.clientHeight;e>=t?document.body.classList.add("week-selector-not-visible"):document.body.classList.remove("week-selector-not-visible")},o._handleWindowResize=function(){var e=o._nodes.weekSelector.clientHeight-o._nodes.search.clientHeight,t=e-(document.body.clientHeight-window.innerHeight);t>0?document.body.style.marginBottom=t+"px":document.body.style.marginBottom=null},o.startListening=function(){window.addEventListener("scroll",o._handleScroll)},r.on("load",o._handleWindowResize),window.addEventListener("resize",o._handleWindowResize),t.exports=o},{"./schedule":12,"smoothscroll-polyfill":4}],14:[function(e,t,n){"use strict";var o=e("events"),r=e("fuzzy"),s=e("./autocomplete"),i=e("./browserFixToolkit"),l=new o;l._nodes={search:document.querySelector("#search"),input:document.querySelector('input[type="search"]')},l.submit=function(){var e=s.getSelectedItem();null!=e&&(console.log(e),l._nodes.input.blur(),document.body.classList.remove("week-selector-not-visible"),l.emit("search",e))},l.updateDom=function(e){l._nodes.input.value=e.value,s.removeAllItems(),document.body.classList.remove("no-input"),document.body.classList.add("searched")},l.focus=function(){l._nodes.input.focus()},l._handleSubmit=function(e){e.preventDefault(),l.submit()},l._calculate=function(e){var t=r.filter(e,USERS,{extract:function(e){return e.value}}),n=t.slice(0,7),o=n.map(function(e){return e.original});return o},l._handleTextUpdate=function(){var e=l._calculate(l._nodes.input.value);s.removeAllItems();for(var t=0;t<e.length;t++)s.addItem(e[t])},l._handleFocus=function(){l._nodes.input.select()},l._handleBlur=function(){var e=l._nodes.value;l._nodes.value="",l._nodes.value=e,document.activeElement.blur()},s.on("select",l.submit),l._nodes.search.addEventListener("submit",l._handleSubmit),l._nodes.input.addEventListener("focus",l._handleFocus),l._nodes.input.addEventListener("blur",l._handleBlur),l._nodes.input.addEventListener(i.inputEvent,l._handleTextUpdate),t.exports=l},{"./autocomplete":6,"./browserFixToolkit":7,events:1,fuzzy:2}],15:[function(e,t,n){"use strict";var o=e("events"),r=new o;r._nodes={prevButton:document.querySelectorAll("#week-selector button")[0],nextButton:document.querySelectorAll("#week-selector button")[1],currentWeekNode:document.querySelector("#week-selector .current"),currentWeekNormalText:document.querySelector("#week-selector .current .no-print"),currentWeekPrintText:document.querySelector("#week-selector .current .print")},r._weekOffset=0,r.getCurrentWeek=function(e){var t=(e.getDay()+6)%7;e.setDate(e.getDate()-t+3);var n=e.valueOf();return e.setMonth(0,1),4!==e.getDay()&&e.setMonth(0,1+(4-e.getDay()+7)%7),1+Math.ceil((n-e)/6048e5)},r.getSelectedWeek=function(){var e=new Date,t=new Date(e.getTime()+604800*r._weekOffset*1e3+864e5);return r.getCurrentWeek(t)},r.updateCurrentWeek=function(){var e=r.getSelectedWeek();r.getCurrentWeek(new Date)!==e?r._nodes.currentWeekNode.classList.add("changed"):r._nodes.currentWeekNode.classList.remove("changed"),r.updateDom(),r.emit("weekChanged",e)},r.updateDom=function(){var e=r.getSelectedWeek(),t=0===(new Date).getDay(),n=null;if(t)switch(r._weekOffset){case 0:n="Aanstaande week";break;case 1:n="Volgende week";break;case-1:n="Afgelopen week"}else switch(r._weekOffset){case 0:n="Huidige week";break;case 1:n="Volgende week";break;case-1:n="Vorige week"}null!=n?(r._nodes.currentWeekNormalText.textContent=n+" • "+e,r._nodes.currentWeekPrintText.textContent="Week "+e):(r._nodes.currentWeekNormalText.textContent="Week "+e,r._nodes.currentWeekPrintText.textContent="Week "+e)},r._handlePrevButtonClick=function(){r._weekOffset-=1,r.updateCurrentWeek()},r._handleNextButtonClick=function(){r._weekOffset+=1,r.updateCurrentWeek()},r._nodes.prevButton.addEventListener("click",r._handlePrevButtonClick),r._nodes.nextButton.addEventListener("click",r._handleNextButtonClick),t.exports=r},{events:1}]},{},[11]);
+(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+function EventEmitter() {
+ this._events = this._events || {};
+ this._maxListeners = this._maxListeners || undefined;
+}
+module.exports = EventEmitter;
+
+// Backwards-compat with node 0.10.x
+EventEmitter.EventEmitter = EventEmitter;
+
+EventEmitter.prototype._events = undefined;
+EventEmitter.prototype._maxListeners = undefined;
+
+// By default EventEmitters will print a warning if more than 10 listeners are
+// added to it. This is a useful default which helps finding memory leaks.
+EventEmitter.defaultMaxListeners = 10;
+
+// Obviously not all Emitters should be limited to 10. This function allows
+// that to be increased. Set to zero for unlimited.
+EventEmitter.prototype.setMaxListeners = function(n) {
+ if (!isNumber(n) || n < 0 || isNaN(n))
+ throw TypeError('n must be a positive number');
+ this._maxListeners = n;
+ return this;
+};
+
+EventEmitter.prototype.emit = function(type) {
+ var er, handler, len, args, i, listeners;
+
+ if (!this._events)
+ this._events = {};
+
+ // If there is no 'error' event listener then throw.
+ if (type === 'error') {
+ if (!this._events.error ||
+ (isObject(this._events.error) && !this._events.error.length)) {
+ er = arguments[1];
+ if (er instanceof Error) {
+ throw er; // Unhandled 'error' event
+ } else {
+ // At least give some kind of context to the user
+ var err = new Error('Uncaught, unspecified "error" event. (' + er + ')');
+ err.context = er;
+ throw err;
+ }
+ }
+ }
+
+ handler = this._events[type];
+
+ if (isUndefined(handler))
+ return false;
+
+ if (isFunction(handler)) {
+ switch (arguments.length) {
+ // fast cases
+ case 1:
+ handler.call(this);
+ break;
+ case 2:
+ handler.call(this, arguments[1]);
+ break;
+ case 3:
+ handler.call(this, arguments[1], arguments[2]);
+ break;
+ // slower
+ default:
+ args = Array.prototype.slice.call(arguments, 1);
+ handler.apply(this, args);
+ }
+ } else if (isObject(handler)) {
+ args = Array.prototype.slice.call(arguments, 1);
+ listeners = handler.slice();
+ len = listeners.length;
+ for (i = 0; i < len; i++)
+ listeners[i].apply(this, args);
+ }
+
+ return true;
+};
+
+EventEmitter.prototype.addListener = function(type, listener) {
+ var m;
+
+ if (!isFunction(listener))
+ throw TypeError('listener must be a function');
+
+ if (!this._events)
+ this._events = {};
+
+ // To avoid recursion in the case that type === "newListener"! Before
+ // adding it to the listeners, first emit "newListener".
+ if (this._events.newListener)
+ this.emit('newListener', type,
+ isFunction(listener.listener) ?
+ listener.listener : listener);
+
+ if (!this._events[type])
+ // Optimize the case of one listener. Don't need the extra array object.
+ this._events[type] = listener;
+ else if (isObject(this._events[type]))
+ // If we've already got an array, just append.
+ this._events[type].push(listener);
+ else
+ // Adding the second element, need to change to array.
+ this._events[type] = [this._events[type], listener];
+
+ // Check for listener leak
+ if (isObject(this._events[type]) && !this._events[type].warned) {
+ if (!isUndefined(this._maxListeners)) {
+ m = this._maxListeners;
+ } else {
+ m = EventEmitter.defaultMaxListeners;
+ }
+
+ if (m && m > 0 && this._events[type].length > m) {
+ this._events[type].warned = true;
+ console.error('(node) warning: possible EventEmitter memory ' +
+ 'leak detected. %d listeners added. ' +
+ 'Use emitter.setMaxListeners() to increase limit.',
+ this._events[type].length);
+ if (typeof console.trace === 'function') {
+ // not supported in IE 10
+ console.trace();
+ }
+ }
+ }
+
+ return this;
+};
+
+EventEmitter.prototype.on = EventEmitter.prototype.addListener;
+
+EventEmitter.prototype.once = function(type, listener) {
+ if (!isFunction(listener))
+ throw TypeError('listener must be a function');
+
+ var fired = false;
+
+ function g() {
+ this.removeListener(type, g);
+
+ if (!fired) {
+ fired = true;
+ listener.apply(this, arguments);
+ }
+ }
+
+ g.listener = listener;
+ this.on(type, g);
+
+ return this;
+};
+
+// emits a 'removeListener' event iff the listener was removed
+EventEmitter.prototype.removeListener = function(type, listener) {
+ var list, position, length, i;
+
+ if (!isFunction(listener))
+ throw TypeError('listener must be a function');
+
+ if (!this._events || !this._events[type])
+ return this;
+
+ list = this._events[type];
+ length = list.length;
+ position = -1;
+
+ if (list === listener ||
+ (isFunction(list.listener) && list.listener === listener)) {
+ delete this._events[type];
+ if (this._events.removeListener)
+ this.emit('removeListener', type, listener);
+
+ } else if (isObject(list)) {
+ for (i = length; i-- > 0;) {
+ if (list[i] === listener ||
+ (list[i].listener && list[i].listener === listener)) {
+ position = i;
+ break;
+ }
+ }
+
+ if (position < 0)
+ return this;
+
+ if (list.length === 1) {
+ list.length = 0;
+ delete this._events[type];
+ } else {
+ list.splice(position, 1);
+ }
+
+ if (this._events.removeListener)
+ this.emit('removeListener', type, listener);
+ }
+
+ return this;
+};
+
+EventEmitter.prototype.removeAllListeners = function(type) {
+ var key, listeners;
+
+ if (!this._events)
+ return this;
+
+ // not listening for removeListener, no need to emit
+ if (!this._events.removeListener) {
+ if (arguments.length === 0)
+ this._events = {};
+ else if (this._events[type])
+ delete this._events[type];
+ return this;
+ }
+
+ // emit removeListener for all listeners on all events
+ if (arguments.length === 0) {
+ for (key in this._events) {
+ if (key === 'removeListener') continue;
+ this.removeAllListeners(key);
+ }
+ this.removeAllListeners('removeListener');
+ this._events = {};
+ return this;
+ }
+
+ listeners = this._events[type];
+
+ if (isFunction(listeners)) {
+ this.removeListener(type, listeners);
+ } else if (listeners) {
+ // LIFO order
+ while (listeners.length)
+ this.removeListener(type, listeners[listeners.length - 1]);
+ }
+ delete this._events[type];
+
+ return this;
+};
+
+EventEmitter.prototype.listeners = function(type) {
+ var ret;
+ if (!this._events || !this._events[type])
+ ret = [];
+ else if (isFunction(this._events[type]))
+ ret = [this._events[type]];
+ else
+ ret = this._events[type].slice();
+ return ret;
+};
+
+EventEmitter.prototype.listenerCount = function(type) {
+ if (this._events) {
+ var evlistener = this._events[type];
+
+ if (isFunction(evlistener))
+ return 1;
+ else if (evlistener)
+ return evlistener.length;
+ }
+ return 0;
+};
+
+EventEmitter.listenerCount = function(emitter, type) {
+ return emitter.listenerCount(type);
+};
+
+function isFunction(arg) {
+ return typeof arg === 'function';
+}
+
+function isNumber(arg) {
+ return typeof arg === 'number';
+}
+
+function isObject(arg) {
+ return typeof arg === 'object' && arg !== null;
+}
+
+function isUndefined(arg) {
+ return arg === void 0;
+}
+
+},{}],2:[function(require,module,exports){
+/*
+ * Fuzzy
+ * https://github.com/myork/fuzzy
+ *
+ * Copyright (c) 2012 Matt York
+ * Licensed under the MIT license.
+ */
+
+(function() {
+
+var root = this;
+
+var fuzzy = {};
+
+// Use in node or in browser
+if (typeof exports !== 'undefined') {
+ module.exports = fuzzy;
+} else {
+ root.fuzzy = fuzzy;
+}
+
+// Return all elements of `array` that have a fuzzy
+// match against `pattern`.
+fuzzy.simpleFilter = function(pattern, array) {
+ return array.filter(function(str) {
+ return fuzzy.test(pattern, str);
+ });
+};
+
+// Does `pattern` fuzzy match `str`?
+fuzzy.test = function(pattern, str) {
+ return fuzzy.match(pattern, str) !== null;
+};
+
+// If `pattern` matches `str`, wrap each matching character
+// in `opts.pre` and `opts.post`. If no match, return null
+fuzzy.match = function(pattern, str, opts) {
+ opts = opts || {};
+ var patternIdx = 0
+ , result = []
+ , len = str.length
+ , totalScore = 0
+ , currScore = 0
+ // prefix
+ , pre = opts.pre || ''
+ // suffix
+ , post = opts.post || ''
+ // String to compare against. This might be a lowercase version of the
+ // raw string
+ , compareString = opts.caseSensitive && str || str.toLowerCase()
+ , ch;
+
+ pattern = opts.caseSensitive && pattern || pattern.toLowerCase();
+
+ // For each character in the string, either add it to the result
+ // or wrap in template if it's the next string in the pattern
+ for(var idx = 0; idx < len; idx++) {
+ ch = str[idx];
+ if(compareString[idx] === pattern[patternIdx]) {
+ ch = pre + ch + post;
+ patternIdx += 1;
+
+ // consecutive characters should increase the score more than linearly
+ currScore += 1 + currScore;
+ } else {
+ currScore = 0;
+ }
+ totalScore += currScore;
+ result[result.length] = ch;
+ }
+
+ // return rendered string if we have a match for every char
+ if(patternIdx === pattern.length) {
+ // if the string is an exact match with pattern, totalScore should be maxed
+ totalScore = (compareString === pattern) ? Infinity : totalScore;
+ return {rendered: result.join(''), score: totalScore};
+ }
+
+ return null;
+};
+
+// The normal entry point. Filters `arr` for matches against `pattern`.
+// It returns an array with matching values of the type:
+//
+// [{
+// string: '<b>lah' // The rendered string
+// , index: 2 // The index of the element in `arr`
+// , original: 'blah' // The original element in `arr`
+// }]
+//
+// `opts` is an optional argument bag. Details:
+//
+// opts = {
+// // string to put before a matching character
+// pre: '<b>'
+//
+// // string to put after matching character
+// , post: '</b>'
+//
+// // Optional function. Input is an entry in the given arr`,
+// // output should be the string to test `pattern` against.
+// // In this example, if `arr = [{crying: 'koala'}]` we would return
+// // 'koala'.
+// , extract: function(arg) { return arg.crying; }
+// }
+fuzzy.filter = function(pattern, arr, opts) {
+ if(!arr || arr.length === 0) {
+ return [];
+ }
+ if (typeof pattern !== 'string') {
+ return arr;
+ }
+ opts = opts || {};
+ return arr
+ .reduce(function(prev, element, idx, arr) {
+ var str = element;
+ if(opts.extract) {
+ str = opts.extract(element);
+ }
+ var rendered = fuzzy.match(pattern, str, opts);
+ if(rendered != null) {
+ prev[prev.length] = {
+ string: rendered.rendered
+ , score: rendered.score
+ , index: idx
+ , original: element
+ };
+ }
+ return prev;
+ }, [])
+
+ // Sort by score. Browsers are inconsistent wrt stable/unstable
+ // sorting, so force stable by using the index in the case of tie.
+ // See http://ofb.net/~sethml/is-sort-stable.html
+ .sort(function(a,b) {
+ var compare = b.score - a.score;
+ if(compare) return compare;
+ return a.index - b.index;
+ });
+};
+
+
+}());
+
+
+},{}],3:[function(require,module,exports){
+/*
+ * smoothscroll polyfill - v0.3.5
+ * https://iamdustan.github.io/smoothscroll
+ * 2016 (c) Dustan Kasten, Jeremias Menichelli - MIT License
+ */
+
+(function(w, d, undefined) {
+ 'use strict';
+
+ /*
+ * aliases
+ * w: window global object
+ * d: document
+ * undefined: undefined
+ */
+
+ // polyfill
+ function polyfill() {
+ // return when scrollBehavior interface is supported
+ if ('scrollBehavior' in d.documentElement.style) {
+ return;
+ }
+
+ /*
+ * globals
+ */
+ var Element = w.HTMLElement || w.Element;
+ var SCROLL_TIME = 468;
+
+ /*
+ * object gathering original scroll methods
+ */
+ var original = {
+ scroll: w.scroll || w.scrollTo,
+ scrollBy: w.scrollBy,
+ elScroll: Element.prototype.scroll || scrollElement,
+ scrollIntoView: Element.prototype.scrollIntoView
+ };
+
+ /*
+ * define timing method
+ */
+ var now = w.performance && w.performance.now
+ ? w.performance.now.bind(w.performance) : Date.now;
+
+ /**
+ * changes scroll position inside an element
+ * @method scrollElement
+ * @param {Number} x
+ * @param {Number} y
+ */
+ function scrollElement(x, y) {
+ this.scrollLeft = x;
+ this.scrollTop = y;
+ }
+
+ /**
+ * returns result of applying ease math function to a number
+ * @method ease
+ * @param {Number} k
+ * @returns {Number}
+ */
+ function ease(k) {
+ return 0.5 * (1 - Math.cos(Math.PI * k));
+ }
+
+ /**
+ * indicates if a smooth behavior should be applied
+ * @method shouldBailOut
+ * @param {Number|Object} x
+ * @returns {Boolean}
+ */
+ function shouldBailOut(x) {
+ if (typeof x !== 'object'
+ || x === null
+ || x.behavior === undefined
+ || x.behavior === 'auto'
+ || x.behavior === 'instant') {
+ // first arg not an object/null
+ // or behavior is auto, instant or undefined
+ return true;
+ }
+
+ if (typeof x === 'object'
+ && x.behavior === 'smooth') {
+ // first argument is an object and behavior is smooth
+ return false;
+ }
+
+ // throw error when behavior is not supported
+ throw new TypeError('behavior not valid');
+ }
+
+ /**
+ * finds scrollable parent of an element
+ * @method findScrollableParent
+ * @param {Node} el
+ * @returns {Node} el
+ */
+ function findScrollableParent(el) {
+ var isBody;
+ var hasScrollableSpace;
+ var hasVisibleOverflow;
+
+ do {
+ el = el.parentNode;
+
+ // set condition variables
+ isBody = el === d.body;
+ hasScrollableSpace =
+ el.clientHeight < el.scrollHeight ||
+ el.clientWidth < el.scrollWidth;
+ hasVisibleOverflow =
+ w.getComputedStyle(el, null).overflow === 'visible';
+ } while (!isBody && !(hasScrollableSpace && !hasVisibleOverflow));
+
+ isBody = hasScrollableSpace = hasVisibleOverflow = null;
+
+ return el;
+ }
+
+ /**
+ * self invoked function that, given a context, steps through scrolling
+ * @method step
+ * @param {Object} context
+ */
+ function step(context) {
+ var time = now();
+ var value;
+ var currentX;
+ var currentY;
+ var elapsed = (time - context.startTime) / SCROLL_TIME;
+
+ // avoid elapsed times higher than one
+ elapsed = elapsed > 1 ? 1 : elapsed;
+
+ // apply easing to elapsed time
+ value = ease(elapsed);
+
+ currentX = context.startX + (context.x - context.startX) * value;
+ currentY = context.startY + (context.y - context.startY) * value;
+
+ context.method.call(context.scrollable, currentX, currentY);
+
+ // scroll more if we have not reached our destination
+ if (currentX !== context.x || currentY !== context.y) {
+ w.requestAnimationFrame(step.bind(w, context));
+ }
+ }
+
+ /**
+ * scrolls window with a smooth behavior
+ * @method smoothScroll
+ * @param {Object|Node} el
+ * @param {Number} x
+ * @param {Number} y
+ */
+ function smoothScroll(el, x, y) {
+ var scrollable;
+ var startX;
+ var startY;
+ var method;
+ var startTime = now();
+
+ // define scroll context
+ if (el === d.body) {
+ scrollable = w;
+ startX = w.scrollX || w.pageXOffset;
+ startY = w.scrollY || w.pageYOffset;
+ method = original.scroll;
+ } else {
+ scrollable = el;
+ startX = el.scrollLeft;
+ startY = el.scrollTop;
+ method = scrollElement;
+ }
+
+ // scroll looping over a frame
+ step({
+ scrollable: scrollable,
+ method: method,
+ startTime: startTime,
+ startX: startX,
+ startY: startY,
+ x: x,
+ y: y
+ });
+ }
+
+ /*
+ * ORIGINAL METHODS OVERRIDES
+ */
+
+ // w.scroll and w.scrollTo
+ w.scroll = w.scrollTo = function() {
+ // avoid smooth behavior if not required
+ if (shouldBailOut(arguments[0])) {
+ original.scroll.call(
+ w,
+ arguments[0].left || arguments[0],
+ arguments[0].top || arguments[1]
+ );
+ return;
+ }
+
+ // LET THE SMOOTHNESS BEGIN!
+ smoothScroll.call(
+ w,
+ d.body,
+ ~~arguments[0].left,
+ ~~arguments[0].top
+ );
+ };
+
+ // w.scrollBy
+ w.scrollBy = function() {
+ // avoid smooth behavior if not required
+ if (shouldBailOut(arguments[0])) {
+ original.scrollBy.call(
+ w,
+ arguments[0].left || arguments[0],
+ arguments[0].top || arguments[1]
+ );
+ return;
+ }
+
+ // LET THE SMOOTHNESS BEGIN!
+ smoothScroll.call(
+ w,
+ d.body,
+ ~~arguments[0].left + (w.scrollX || w.pageXOffset),
+ ~~arguments[0].top + (w.scrollY || w.pageYOffset)
+ );
+ };
+
+ // Element.prototype.scroll and Element.prototype.scrollTo
+ Element.prototype.scroll = Element.prototype.scrollTo = function() {
+ // avoid smooth behavior if not required
+ if (shouldBailOut(arguments[0])) {
+ original.elScroll.call(
+ this,
+ arguments[0].left || arguments[0],
+ arguments[0].top || arguments[1]
+ );
+ return;
+ }
+
+ // LET THE SMOOTHNESS BEGIN!
+ smoothScroll.call(
+ this,
+ this,
+ arguments[0].left,
+ arguments[0].top
+ );
+ };
+
+ // Element.prototype.scrollBy
+ Element.prototype.scrollBy = function() {
+ var arg0 = arguments[0];
+
+ if (typeof arg0 === 'object') {
+ this.scroll({
+ left: arg0.left + this.scrollLeft,
+ top: arg0.top + this.scrollTop,
+ behavior: arg0.behavior
+ });
+ } else {
+ this.scroll(
+ this.scrollLeft + arg0,
+ this.scrollTop + arguments[1]
+ );
+ }
+ };
+
+ // Element.prototype.scrollIntoView
+ Element.prototype.scrollIntoView = function() {
+ // avoid smooth behavior if not required
+ if (shouldBailOut(arguments[0])) {
+ original.scrollIntoView.call(this, arguments[0] || true);
+ return;
+ }
+
+ // LET THE SMOOTHNESS BEGIN!
+ var scrollableParent = findScrollableParent(this);
+ var parentRects = scrollableParent.getBoundingClientRect();
+ var clientRects = this.getBoundingClientRect();
+
+ if (scrollableParent !== d.body) {
+ // reveal element inside parent
+ smoothScroll.call(
+ this,
+ scrollableParent,
+ scrollableParent.scrollLeft + clientRects.left - parentRects.left,
+ scrollableParent.scrollTop + clientRects.top - parentRects.top
+ );
+ // reveal parent in viewport
+ w.scrollBy({
+ left: parentRects.left,
+ top: parentRects.top,
+ behavior: 'smooth'
+ });
+ } else {
+ // reveal element in viewport
+ w.scrollBy({
+ left: clientRects.left,
+ top: clientRects.top,
+ behavior: 'smooth'
+ });
+ }
+ };
+ }
+
+ if (typeof exports === 'object') {
+ // commonjs
+ module.exports = { polyfill: polyfill };
+ } else {
+ // global
+ polyfill();
+ }
+})(window, document);
+
+},{}],4:[function(require,module,exports){
+'use strict';
+
+/* global ga */
+
+var self = {};
+
+self.send = {};
+
+self.send.search = function (selectedUser, favorite) {
+ var hitType = 'event';
+
+ var eventCategory = favorite ? 'search fav' : 'search';
+
+ var eventAction = void 0;
+ switch (selectedUser.type) {
+ case 'c':
+ eventAction = 'Class';
+ break;
+ case 't':
+ eventAction = 'Teacher';
+ break;
+ case 'r':
+ eventAction = 'Room';
+ break;
+ case 's':
+ eventAction = 'Student';
+ break;
+ }
+
+ var eventLabel = selectedUser.value;
+
+ ga(function () {
+ ga('send', { hitType: hitType, eventCategory: eventCategory, eventAction: eventAction, eventLabel: eventLabel });
+ });
+};
+
+module.exports = self;
+
+},{}],5:[function(require,module,exports){
+'use strict';
+
+var EventEmitter = require('events');
+
+var self = new EventEmitter();
+
+self._users = [];
+self._selectedUserIndex = -1;
+
+self._nodes = {
+ search: document.querySelector('#search'),
+ input: document.querySelector('input[type="search"]'),
+ autocomplete: document.querySelector('.autocomplete')
+};
+
+self.getSelectedUser = function () {
+ if (self.getItems() === []) return;
+
+ if (self.getSelectedUserIndex() === -1) {
+ return self.getItems()[0];
+ } else {
+ return self.getItems()[self.getSelectedUserIndex()];
+ }
+};
+
+self.getSelectedUserIndex = function () {
+ return self._selectedUserIndex;
+};
+
+self.getItems = function () {
+ return self._users;
+};
+
+self.removeAllItems = function () {
+ while (self._nodes.autocomplete.firstChild) {
+ self._nodes.autocomplete.removeChild(self._nodes.autocomplete.firstChild);
+ }
+ self._users = [];
+ self._selectedUserIndex = -1;
+};
+
+self.addItem = function (user) {
+ var listItem = document.createElement('li');
+ listItem.textContent = user.value;
+ self._nodes.autocomplete.appendChild(listItem);
+ self._users.push(user);
+};
+
+self._moveSelected = function (shift) {
+ if (self._selectedUserIndex + shift >= self.getItems().length) {
+ self._selectedUserIndex = -1;
+ } else if (self._selectedUserIndex + shift < -1) {
+ self._selectedUserIndex = self.getItems().length - 1;
+ } else {
+ self._selectedUserIndex += shift;
+ }
+
+ for (var i = 0; i < self.getItems().length; i++) {
+ self._nodes.autocomplete.children[i].classList.remove('selected');
+ }
+ if (self._selectedUserIndex >= 0) {
+ self._nodes.autocomplete.children[self._selectedUserIndex].classList.add('selected');
+ }
+};
+
+self._handleItemClick = function (event) {
+ if (!self._nodes.autocomplete.contains(event.target)) return;
+ var userIndex = Array.prototype.indexOf.call(self._nodes.autocomplete.children, event.target);
+ self._selectedUserIndex = userIndex;
+ self.emit('select', self.getSelectedUser());
+};
+
+self._handleKeydown = function (event) {
+ if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
+ event.preventDefault();
+ if (event.key === 'ArrowDown') {
+ self._moveSelected(1);
+ } else if (event.key === 'ArrowUp') {
+ self._moveSelected(-1);
+ }
+ }
+};
+
+self._nodes.autocomplete.addEventListener('click', self._handleItemClick);
+self._nodes.input.addEventListener('keydown', self._handleKeydown);
+
+module.exports = self;
+
+},{"events":1}],6:[function(require,module,exports){
+'use strict';
+
+var self = {};
+
+self.isIE = navigator.userAgent.indexOf('MSIE') !== -1 || navigator.appVersion.indexOf('Trident/') > 0;
+
+if (self.isIE) {
+ self.inputEvent = 'textinput';
+} else {
+ self.inputEvent = 'input';
+}
+
+module.exports = self;
+
+},{}],7:[function(require,module,exports){
+'use strict';
+
+/* global USERS */
+
+var EventEmitter = require('events');
+
+var self = new EventEmitter();
+
+self._nodes = {
+ toggle: document.querySelector('.fav')
+};
+
+self.get = function () {
+ try {
+ var localStorageUser = JSON.parse(window.localStorage.getItem('fav'));
+ if (localStorageUser == null) return;
+
+ var correctedUser = USERS.filter(function (user) {
+ return user.type === localStorageUser.type && user.value === localStorageUser.value;
+ })[0];
+ return correctedUser;
+ } catch (e) {
+ self.delete();
+ return;
+ }
+};
+
+self.set = function (user) {
+ window.localStorage.setItem('fav', JSON.stringify(user));
+ self._nodes.innerHTML = '&#xE838;';
+};
+
+self.delete = function () {
+ window.localStorage.removeItem('fav');
+};
+
+self.updateDom = function (isFavorite) {
+ if (isFavorite) {
+ self._nodes.toggle.innerHTML = '&#xE838;';
+ } else {
+ self._nodes.toggle.innerHTML = '&#xE83A';
+ }
+};
+
+self.update = function (selectedUser) {
+ var currentUser = self.get();
+
+ if (currentUser == null || selectedUser == null) {
+ self.updateDom(false);
+ return;
+ }
+
+ var isEqual = currentUser.type === selectedUser.type && currentUser.index === selectedUser.index;
+
+ self.updateDom(isEqual);
+};
+
+self.toggle = function (selectedUser) {
+ var currentUser = self.get();
+ var isEqual = currentUser != null && currentUser.type === selectedUser.type && currentUser.index === selectedUser.index;
+
+ if (isEqual) {
+ self.delete();
+ self.updateDom(false);
+ } else {
+ self.set(selectedUser);
+ self.updateDom(true);
+ }
+};
+
+self._handleClick = function () {
+ self.emit('click');
+};
+
+self._nodes.toggle.addEventListener('click', self._handleClick);
+
+module.exports = self;
+
+},{"events":1}],8:[function(require,module,exports){
+'use strict';
+
+/* global FLAGS */
+
+var 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 () {
+ 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;
+
+},{}],9:[function(require,module,exports){
+'use strict';
+
+var browserFixToolkit = require('./browserFixToolkit');
+
+var self = {};
+
+self._nodes = {
+ input: document.querySelector('input[type="search"]')
+};
+
+self.isShown = false;
+
+self.show = function () {
+ document.body.classList.add('no-input');
+ self.isShown = true;
+};
+
+self.hide = function () {
+ document.body.classList.remove('no-input');
+ self.isShown = false;
+};
+
+self._nodes.input.addEventListener(browserFixToolkit.inputEvent, self.hide);
+
+module.exports = self;
+
+},{"./browserFixToolkit":6}],10:[function(require,module,exports){
+'use strict';
+
+require('./featureDetect').check();
+require('./zoom');
+
+var frontpage = require('./frontpage');
+var search = require('./search');
+var schedule = require('./schedule');
+var weekSelector = require('./weekSelector');
+var favorite = require('./favorite');
+var scrollSnap = require('./scrollSnap');
+var analytics = require('./analytics');
+var url = require('./url');
+
+var state = {};
+
+window.state = state;
+window.require = require;
+
+frontpage.show();
+weekSelector.updateCurrentWeek();
+scrollSnap.startListening();
+
+if (url.hasSelectedUser()) {
+ state.selectedUser = url.getSelectedUser();
+
+ favorite.update(state.selectedUser);
+ url.update(state.selectedUser);
+ analytics.send.search(state.selectedUser);
+
+ schedule.viewItem(weekSelector.getSelectedWeek(), state.selectedUser);
+} else if (favorite.get() != null) {
+ state.selectedUser = favorite.get();
+
+ favorite.update(state.selectedUser);
+ url.push(state.selectedUser, false);
+ url.update(state.selectedUser);
+ analytics.send.search(state.selectedUser, true);
+
+ schedule.viewItem(weekSelector.getSelectedWeek(), state.selectedUser);
+} else {
+ search.focus();
+}
+
+search.on('search', function (selectedUser) {
+ state.selectedUser = selectedUser;
+
+ favorite.update(state.selectedUser);
+ url.push(state.selectedUser);
+ url.update(state.selectedUser);
+ analytics.send.search(state.selectedUser);
+
+ schedule.viewItem(weekSelector.getSelectedWeek(), state.selectedUser);
+});
+
+url.on('update', function (selectedUser) {
+ state.selectedUser = selectedUser;
+
+ favorite.update(state.selectedUser);
+ url.update(state.selectedUser);
+
+ schedule.viewItem(weekSelector.getSelectedWeek(), state.selectedUser);
+});
+
+weekSelector.on('weekChanged', function (newWeek) {
+ analytics.send.search(state.selectedUser);
+ schedule.viewItem(newWeek, state.selectedUser);
+});
+
+favorite.on('click', function () {
+ favorite.toggle(state.selectedUser);
+});
+
+document.body.style.opacity = 1;
+
+},{"./analytics":4,"./favorite":7,"./featureDetect":8,"./frontpage":9,"./schedule":11,"./scrollSnap":12,"./search":13,"./url":14,"./weekSelector":15,"./zoom":16}],11:[function(require,module,exports){
+'use strict';
+
+var EventEmitter = require('events');
+var search = require('./search');
+
+var self = new EventEmitter();
+
+self._nodes = {
+ schedule: document.querySelector('#schedule')
+};
+
+self._parseMeetingpointHTML = function (htmlStr) {
+ var html = document.createElement('html');
+ html.innerHTML = htmlStr;
+ var centerNode = html.querySelector('center');
+ return centerNode;
+};
+
+self._handleLoad = function (event) {
+ var request = event.target;
+ if (request.status < 200 || request.status >= 400) {
+ self._handleError(event);
+ return;
+ }
+ var document = self._parseMeetingpointHTML(request.response);
+ self._removeChilds();
+ self._nodes.schedule.appendChild(document);
+ self._nodes.schedule.classList.remove('error');
+ self.emit('load');
+};
+
+self._handleError = function (event) {
+ var request = event.target;
+ var error = void 0;
+ if (request.status === 404) {
+ error = 'Sorry, er is (nog) geen rooster voor deze week.';
+ } else {
+ error = 'Sorry, er is iets mis gegaan tijdens het laden van deze week.';
+ }
+ self._removeChilds();
+ self._nodes.schedule.textContent = error;
+ self._nodes.schedule.classList.add('error');
+ self.emit('load');
+};
+
+self._getURLOfUser = function (week, user) {
+ return '/get/' + user.type + '/' + user.value + '?week=' + week;
+};
+
+self._removeChilds = function () {
+ while (self._nodes.schedule.firstChild) {
+ self._nodes.schedule.removeChild(self._nodes.schedule.firstChild);
+ }
+};
+
+self.viewItem = function (week, selectedUser) {
+ if (selectedUser == null) {
+ self._removeChilds();
+ search.updateDom(selectedUser);
+ } else {
+ var url = self._getURLOfUser(week, selectedUser);
+
+ self._removeChilds();
+
+ var request = new window.XMLHttpRequest();
+ request.addEventListener('load', self._handleLoad);
+ request.addEventListener('error', self._handleError);
+ request.open('GET', url, true);
+ request.send();
+
+ search.updateDom(selectedUser);
+ }
+};
+
+module.exports = self;
+
+},{"./search":13,"events":1}],12:[function(require,module,exports){
+'use strict';
+
+require('smoothscroll-polyfill').polyfill();
+
+var self = {};
+var schedule = require('./schedule');
+
+self._nodes = {
+ search: document.querySelector('#search'),
+ weekSelector: document.querySelector('#week-selector')
+};
+
+self._timeoutID = null;
+
+self._getScrollPosition = function () {
+ return document.documentElement && document.documentElement.scrollTop || document.body.scrollTop;
+};
+
+self._handleDoneScrolling = function () {
+ var scrollPosition = self._getScrollPosition();
+ var weekSelectorHeight = self._nodes.weekSelector.clientHeight - self._nodes.search.clientHeight;
+ if (scrollPosition < weekSelectorHeight && scrollPosition > 0) {
+ window.scroll({ top: weekSelectorHeight, left: 0, behavior: 'smooth' });
+ }
+};
+
+self._handleScroll = function () {
+ if (self._timeoutID != null) window.clearTimeout(self._timeoutID);
+ self._timeoutID = window.setTimeout(self._handleDoneScrolling, 500);
+
+ var scrollPosition = self._getScrollPosition();
+ var weekSelectorHeight = self._nodes.weekSelector.clientHeight - self._nodes.search.clientHeight;
+ if (scrollPosition >= weekSelectorHeight) {
+ document.body.classList.add('week-selector-not-visible');
+ } else {
+ document.body.classList.remove('week-selector-not-visible');
+ }
+};
+
+self._handleWindowResize = function () {
+ var weekSelectorHeight = self._nodes.weekSelector.clientHeight - self._nodes.search.clientHeight;
+ var extraPixelsNeeded = weekSelectorHeight - (document.body.clientHeight - window.innerHeight);
+ if (extraPixelsNeeded > 0) {
+ document.body.style.marginBottom = extraPixelsNeeded + 'px';
+ } else {
+ document.body.style.marginBottom = null;
+ }
+};
+
+self.startListening = function () {
+ window.addEventListener('scroll', self._handleScroll);
+};
+
+schedule.on('load', self._handleWindowResize);
+window.addEventListener('resize', self._handleWindowResize);
+module.exports = self;
+
+},{"./schedule":11,"smoothscroll-polyfill":3}],13:[function(require,module,exports){
+'use strict';
+
+/* global USERS */
+
+var EventEmitter = require('events');
+var fuzzy = require('fuzzy');
+var autocomplete = require('./autocomplete');
+var browserFixToolkit = require('./browserFixToolkit');
+
+var self = new EventEmitter();
+
+self._nodes = {
+ search: document.querySelector('#search'),
+ input: document.querySelector('input[type="search"]')
+};
+
+self.submit = function () {
+ var selectedUser = autocomplete.getSelectedUser();
+ if (selectedUser == null) return;
+
+ console.log(selectedUser);
+
+ self._nodes.input.blur();
+ document.body.classList.remove('week-selector-not-visible'); // Safari bug
+
+ self.emit('search', selectedUser);
+};
+
+self.updateDom = function (selectedUser) {
+ if (selectedUser == null) {
+ self._nodes.input.value = '';
+ autocomplete.removeAllItems();
+ document.body.classList.add('no-input');
+ document.body.classList.remove('searched');
+ } else {
+ self._nodes.input.value = selectedUser.value;
+ autocomplete.removeAllItems();
+ document.body.classList.remove('no-input');
+ document.body.classList.add('searched');
+ }
+};
+
+self.focus = function () {
+ self._nodes.input.focus();
+};
+
+self._handleSubmit = function (event) {
+ event.preventDefault();
+ self.submit();
+};
+
+self._calculate = function (searchTerm) {
+ var allResults = fuzzy.filter(searchTerm, USERS, {
+ extract: function extract(user) {
+ return user.value;
+ }
+ });
+ var firstResults = allResults.slice(0, 7);
+
+ var originalResults = firstResults.map(function (result) {
+ return result.original;
+ });
+
+ return originalResults;
+};
+
+self._handleTextUpdate = function () {
+ var results = self._calculate(self._nodes.input.value);
+
+ autocomplete.removeAllItems();
+ for (var i = 0; i < results.length; i++) {
+ autocomplete.addItem(results[i]);
+ }
+};
+
+self._handleFocus = function () {
+ self._nodes.input.select();
+};
+
+self._handleBlur = function () {
+ // this will removed the selection without drawing focus on it (safari)
+ // this will removed selection even when focusing an iframe (chrome)
+ var oldValue = self._nodes.value;
+ self._nodes.value = '';
+ self._nodes.value = oldValue;
+
+ // this will hide the keyboard (iOS safari)
+ document.activeElement.blur();
+};
+
+autocomplete.on('select', self.submit);
+
+self._nodes.search.addEventListener('submit', self._handleSubmit);
+self._nodes.input.addEventListener('focus', self._handleFocus);
+self._nodes.input.addEventListener('blur', self._handleBlur);
+self._nodes.input.addEventListener(browserFixToolkit.inputEvent, self._handleTextUpdate);
+
+module.exports = self;
+
+},{"./autocomplete":5,"./browserFixToolkit":6,"events":1,"fuzzy":2}],14:[function(require,module,exports){
+'use strict';
+
+/* global USERS FLAGS */
+
+var EventEmitter = require('events');
+
+var self = new EventEmitter();
+
+self._getPageTitle = function (selectedUser) {
+ var ret = void 0;
+
+ if (selectedUser == null) {
+ ret = 'Metis Rooster';
+ } else {
+ ret = 'Metis Rooster - ' + selectedUser.value;
+ }
+
+ if (FLAGS.indexOf('BETA') !== -1) {
+ ret = 'BETA ' + ret;
+ }
+
+ return ret;
+};
+
+self._getPageURL = function (selectedUser) {
+ return '/' + selectedUser.type + '/' + selectedUser.value;
+};
+
+self.push = function (selectedUser, push) {
+ if (push == null) push = true;
+ var pageTitle = self._getPageTitle(selectedUser);
+ var pageURL = self._getPageURL(selectedUser);
+ if (push) {
+ window.history.pushState(selectedUser, pageTitle, pageURL);
+ } else {
+ window.history.replaceState(selectedUser, pageTitle, pageURL);
+ }
+};
+
+self.update = function (selectedUser) {
+ document.title = self._getPageTitle(selectedUser);
+};
+
+self.hasSelectedUser = function () {
+ var pageUrl = window.location.pathname;
+ return (/^\/s\/|^\/t\/|^\/r\/|^\/c\//.test(pageUrl)
+ );
+};
+
+self.getSelectedUser = function () {
+ var pageUrl = window.location.pathname;
+ var pageUrlData = pageUrl.split('/');
+ var type = pageUrlData[1];
+ var value = pageUrlData[2];
+
+ var user = USERS.filter(function (user) {
+ return user.type === type && user.value === value;
+ })[0];
+
+ return user;
+};
+
+self._handleUpdate = function (event) {
+ self.emit('update', event.state);
+};
+
+window.addEventListener('popstate', self._handleUpdate);
+
+module.exports = self;
+
+},{"events":1}],15:[function(require,module,exports){
+'use strict';
+
+var EventEmitter = require('events');
+
+var self = new EventEmitter();
+
+self._nodes = {
+ prevButton: document.querySelectorAll('#week-selector button')[0],
+ nextButton: document.querySelectorAll('#week-selector button')[1],
+ currentWeekNode: document.querySelector('#week-selector .current'),
+ currentWeekNormalText: document.querySelector('#week-selector .current .no-print'),
+ currentWeekPrintText: document.querySelector('#week-selector .current .print')
+};
+
+self._weekOffset = 0;
+
+// copied from http://www.meetingpointmco.nl/Roosters-AL/doc/dagroosters/untisscripts.js,
+// were using the same code as they do to be sure that we always get the same
+// week number.
+self.getCurrentWeek = function (target) {
+ var dayNr = (target.getDay() + 6) % 7;
+ target.setDate(target.getDate() - dayNr + 3);
+ var firstThursday = target.valueOf();
+ target.setMonth(0, 1);
+ if (target.getDay() !== 4) {
+ target.setMonth(0, 1 + (4 - target.getDay() + 7) % 7);
+ }
+
+ return 1 + Math.ceil((firstThursday - target) / 604800000);
+};
+
+self.getSelectedWeek = function () {
+ var now = new Date();
+ var targetDate = new Date(now.getTime() + self._weekOffset * 604800 * 1000 + 86400 * 1000);
+ return self.getCurrentWeek(targetDate);
+};
+
+self.updateCurrentWeek = function () {
+ var selectedWeekNumber = self.getSelectedWeek();
+ if (self.getCurrentWeek(new Date()) !== selectedWeekNumber) {
+ self._nodes.currentWeekNode.classList.add('changed');
+ } else {
+ self._nodes.currentWeekNode.classList.remove('changed');
+ }
+ self.updateDom();
+ self.emit('weekChanged', selectedWeekNumber);
+};
+
+self.updateDom = function () {
+ var selectedWeekNumber = self.getSelectedWeek();
+ var isSunday = new Date().getDay() === 0;
+ var humanReadableWeek = null;
+ if (isSunday) {
+ switch (self._weekOffset) {
+ case 0:
+ humanReadableWeek = 'Aanstaande week';
+ break;
+ case 1:
+ humanReadableWeek = 'Volgende week';
+ break;
+ case -1:
+ humanReadableWeek = 'Afgelopen week';
+ break;
+ }
+ } else {
+ switch (self._weekOffset) {
+ case 0:
+ humanReadableWeek = 'Huidige week';
+ break;
+ case 1:
+ humanReadableWeek = 'Volgende week';
+ break;
+ case -1:
+ humanReadableWeek = 'Vorige week';
+ break;
+ }
+ }
+ if (humanReadableWeek != null) {
+ self._nodes.currentWeekNormalText.textContent = humanReadableWeek + ' • ' + selectedWeekNumber;
+ self._nodes.currentWeekPrintText.textContent = 'Week ' + selectedWeekNumber;
+ } else {
+ self._nodes.currentWeekNormalText.textContent = 'Week ' + selectedWeekNumber;
+ self._nodes.currentWeekPrintText.textContent = 'Week ' + selectedWeekNumber;
+ }
+};
+
+self._handlePrevButtonClick = function () {
+ self._weekOffset -= 1;
+ self.updateCurrentWeek();
+};
+
+self._handleNextButtonClick = function () {
+ self._weekOffset += 1;
+ self.updateCurrentWeek();
+};
+
+self._nodes.prevButton.addEventListener('click', self._handlePrevButtonClick);
+self._nodes.nextButton.addEventListener('click', self._handleNextButtonClick);
+
+module.exports = self;
+
+},{"events":1}],16:[function(require,module,exports){
+'use strict';
+
+var schedule = require('./schedule');
+
+var self = {};
+
+self._nodes = {
+ body: document.body
+};
+
+self._handleResize = function () {
+ // the table node may not exist before this function is called
+ var tableNode = document.querySelector('center > table');
+
+ // infact, it may not even exist when this function is called.
+ if (!tableNode) return;
+
+ var tableWidth = tableNode.getBoundingClientRect().width;
+ var tableGoalWidth = self._nodes.body.getBoundingClientRect().width * 0.9;
+ var zoomFactor = tableGoalWidth / tableWidth;
+
+ if (zoomFactor < 1) {
+ tableNode.style.zoom = '' + zoomFactor;
+ } else {
+ tableNode.style.zoom = '1';
+ }
+};
+
+schedule.on('load', self._handleResize);
+window.addEventListener('resize', self._handleResize);
+
+module.exports = self;
+
+},{"./schedule":11}]},{},[10])
+//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJub2RlX21vZHVsZXMvZXZlbnRzL2V2ZW50cy5qcyIsIm5vZGVfbW9kdWxlcy9mdXp6eS9saWIvZnV6enkuanMiLCJub2RlX21vZHVsZXMvc21vb3Roc2Nyb2xsLXBvbHlmaWxsL2Rpc3Qvc21vb3Roc2Nyb2xsLmpzIiwicHVibGljL2phdmFzY3JpcHRzL2FuYWx5dGljcy5qcyIsInB1YmxpYy9qYXZhc2NyaXB0cy9hdXRvY29tcGxldGUuanMiLCJwdWJsaWMvamF2YXNjcmlwdHMvYnJvd3NlckZpeFRvb2xraXQuanMiLCJwdWJsaWMvamF2YXNjcmlwdHMvZmF2b3JpdGUuanMiLCJwdWJsaWMvamF2YXNjcmlwdHMvZmVhdHVyZURldGVjdC5qcyIsInB1YmxpYy9qYXZhc2NyaXB0cy9mcm9udHBhZ2UuanMiLCJwdWJsaWMvamF2YXNjcmlwdHMvbWFpbi5qcyIsInB1YmxpYy9qYXZhc2NyaXB0cy9zY2hlZHVsZS5qcyIsInB1YmxpYy9qYXZhc2NyaXB0cy9zY3JvbGxTbmFwLmpzIiwicHVibGljL2phdmFzY3JpcHRzL3NlYXJjaC5qcyIsInB1YmxpYy9qYXZhc2NyaXB0cy91cmwuanMiLCJwdWJsaWMvamF2YXNjcmlwdHMvd2Vla1NlbGVjdG9yLmpzIiwicHVibGljL2phdmFzY3JpcHRzL3pvb20uanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7QUNBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FB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vcyhNYXRoLlBJICogaykpO1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIGluZGljYXRlcyBpZiBhIHNtb290aCBiZWhhdmlvciBzaG91bGQgYmUgYXBwbGllZFxuICAgICAqIEBtZXRob2Qgc2hvdWxkQmFpbE91dFxuICAgICAqIEBwYXJhbSB7TnVtYmVyfE9iamVjdH0geFxuICAgICAqIEByZXR1cm5zIHtCb29sZWFufVxuICAgICAqL1xuICAgIGZ1bmN0aW9uIHNob3VsZEJhaWxPdXQoeCkge1xuICAgICAgaWYgKHR5cGVvZiB4ICE9PSAnb2JqZWN0J1xuICAgICAgICAgICAgfHwgeCA9PT0gbnVsbFxuICAgICAgICAgICAgfHwgeC5iZWhhdmlvciA9PT0gdW5kZWZpbmVkXG4gICAgICAgICAgICB8fCB4LmJlaGF2aW9yID09PSAnYXV0bydcbiAgICAgICAgICAgIHx8IHguYmVoYXZpb3IgPT09ICdpbnN0YW50Jykge1xuICAgICAgICAvLyBmaXJzdCBhcmcgbm90IGFuIG9iamVjdC9udWxsXG4gICAgICAgIC8vIG9yIGJlaGF2aW9yIGlzIGF1dG8sIGluc3RhbnQgb3IgdW5kZWZpbmVkXG4gICAgICAgIHJldHVybiB0cnVlO1xuICAgICAgfVxuXG4gICAgICBpZiAodHlwZW9mIHggPT09ICdvYmplY3QnXG4gICAgICAgICAgICAmJiB4LmJlaGF2aW9yID09PSAnc21vb3RoJykge1xuICAgICAgICAvLyBmaXJzdCBhcmd1bWVudCBpcyBhbiBvYmplY3QgYW5kIGJlaGF2aW9yIGlzIHNtb290aFxuICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICB9XG5cbiAgICAgIC8vIHRocm93IGVycm9yIHdoZW4gYmVoYXZpb3IgaXMgbm90IHN1cHBvcnRlZFxuICAgICAgdGhyb3cgbmV3IFR5cGVFcnJvcignYmVoYXZpb3Igbm90IHZhbGlkJyk7XG4gICAgfVxuXG4gICAgLyoqXG4gICAgICogZmluZHMgc2Nyb2xsYWJsZ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IHtcbiAgYm9keTogZG9jdW1lbnQuYm9keVxufVxuXG5zZWxmLl9oYW5kbGVSZXNpemUgPSBmdW5jdGlvbiAoKSB7XG4gIC8vIHRoZSB0YWJsZSBub2RlIG1heSBub3QgZXhpc3QgYmVmb3JlIHRoaXMgZnVuY3Rpb24gaXMgY2FsbGVkXG4gIGNvbnN0IHRhYmxlTm9kZSA9IGRvY3VtZW50LnF1ZXJ5U2VsZWN0b3IoJ2NlbnRlciA+IHRhYmxlJylcblxuICAvLyBpbmZhY3QsIGl0IG1heSBub3QgZXZlbiBleGlzdCB3aGVuIHRoaXMgZnVuY3Rpb24gaXMgY2FsbGVkLlxuICBpZiAoIXRhYmxlTm9kZSkgcmV0dXJuXG5cbiAgY29uc3QgdGFibGVXaWR0aCA9IHRhYmxlTm9kZS5nZXRCb3VuZGluZ0NsaWVudFJlY3QoKS53aWR0aFxuICBjb25zdCB0YWJsZUdvYWxXaWR0aCA9IHNlbGYuX25vZGVzLmJvZHkuZ2V0Qm91bmRpbmdDbGllbnRSZWN0KCkud2lkdGggKiAwLjlcbiAgY29uc3Qgem9vbUZhY3RvciA9IHRhYmxlR29hbFdpZHRoIC8gdGFibGVXaWR0aFxuXG4gIGlmICh6b29tRmFjdG9yIDwgMSkge1xuICAgIHRhYmxlTm9kZS5zdHlsZS56b29tID0gYCR7em9vbUZhY3Rvcn1gXG4gIH0gZWxzZSB7XG4gICAgdGFibGVOb2RlLnN0eWxlLnpvb20gPSBgMWBcbiAgfVxufVxuXG5zY2hlZHVsZS5vbignbG9hZCcsIHNlbGYuX2hhbmRsZVJlc2l6ZSlcbndpbmRvdy5hZGRFdmVudExpc3RlbmVyKCdyZXNpemUnLCBzZWxmLl9oYW5kbGVSZXNpemUpXG5cbm1vZHVsZS5leHBvcnRzID0gc2VsZlxuIl19
diff --git a/public/javascripts/favorite.js b/public/javascripts/favorite.js
index 9edc248..92c87f7 100644
--- a/public/javascripts/favorite.js
+++ b/public/javascripts/favorite.js
@@ -44,7 +44,7 @@ self.updateDom = function (isFavorite) {
self.update = function (selectedUser) {
const currentUser = self.get()
- if (currentUser == null) {
+ if (currentUser == null || selectedUser == null) {
self.updateDom(false)
return
}
diff --git a/public/javascripts/main.bak.js b/public/javascripts/main.bak.js
deleted file mode 100644
index 895dd3f..0000000
--- a/public/javascripts/main.bak.js
+++ /dev/null
@@ -1,244 +0,0 @@
-/* global ga FLAGS USERS */
-
-require('flexibility')
-
-const fuzzy = require('fuzzy')
-// const getUsers = require('./getUsers')
-const getURLOfUser = require('./getURLOfUser')
-const removeDiacritics = require('diacritics').remove
-const getWeek = require('./getWeek')
-const easterEggs = require('./easterEggs')
-
-const searchNode = document.querySelector('#search')
-const inputNode = searchNode.querySelector('input[type="search"]')
-const autocompleteNode = document.querySelector('.autocomplete')
-const scheduleIframe = document.querySelector('#schedule')
-const prevButton = document.querySelectorAll('#week-selector button')[0]
-const nextButton = document.querySelectorAll('#week-selector button')[1]
-const currentWeekNode = document.querySelector('.current')
-const favNode = document.querySelector('.fav')
-
-if (FLAGS.indexOf('NO_FEATURE_DETECT') === -1) {
- if (document.querySelector('#schedule').getClientRects()[0].bottom !==
- document.body.getClientRects()[0].bottom) {
- window.location = 'http://www.meetingpointmco.nl/Roosters-AL/doc/'
- } else {
- window.onerror = function () {
- window.location = 'http://www.meetingpointmco.nl/Roosters-AL/doc/'
- }
- }
-} else {
- console.log('feature detection is OFF')
-}
-
-let selectedResult = -1
-let selectedUser
-let results = []
-let offset = 0
-
-function getCurrentFav () {
- if (!window.localStorage.getItem('fav')) return
- const favCode = window.localStorage.getItem('fav').split(':')
- const fav = USERS.filter(user => user.type === favCode[0] && user.index === Number(favCode[1]))
- return fav[0]
-}
-
-function changeFav (isFav) {
- if (!selectedUser) return
- if (isFav) {
- window.localStorage.setItem('fav', selectedUser.type + ':' + selectedUser.index)
- } else {
- window.localStorage.removeItem('fav')
- }
- updateFavNode()
-}
-
-function usersEqual (user1, user2) {
- if (user1 == null || user2 == null) return false
- return user1.type === user2.type && user1.index === user2.index
-}
-
-function updateFavNode () {
- if (usersEqual(getCurrentFav(), selectedUser)) {
- favNode.innerHTML = '&#xE838;'
- } else {
- favNode.innerHTML = '&#xE83A'
- }
-}
-
-function updateWeekText () {
- if (offset === 0) currentWeekNode.innerHTML = `Week ${getWeek() + offset}`
- else currentWeekNode.innerHTML = `<strong>Week ${getWeek() + offset}</strong>`
-}
-
-updateWeekText()
-
-searchNode.addEventListener('keydown', function (e) {
- if ((results.length !== 0) && (e.key === 'ArrowDown' || e.key === 'ArrowUp')) {
- e.preventDefault()
-
- if (document.querySelector('.selected')) document.querySelector('.selected').classList.remove('selected')
-
- const change = e.key === 'ArrowDown' ? 1 : -1
- selectedResult += change
- if (selectedResult < -1) selectedResult = results.length - 1
- else if (selectedResult > results.length - 1) selectedResult = -1
-
- if (selectedResult !== -1) autocompleteNode.children[selectedResult].classList.add('selected')
- }
-})
-
-let inputEventStr
-if (navigator.userAgent.indexOf('MSIE') !== -1 ||
- navigator.appVersion.indexOf('Trident/') > 0) {
- inputEventStr = 'textinput' // IE 6-11
-} else {
- inputEventStr = 'input' // normal browsers
-}
-
-searchNode.addEventListener(inputEventStr, function (e) {
- document.body.classList.remove('no-input')
- autocompleteNode.innerHTML = ''
- if (inputNode.value.trim() === '') return
-
- selectedResult = -1
- results = fuzzy.filter(removeDiacritics(inputNode.value), USERS, {
- extract: function (el) { return removeDiacritics(el.value) }
- }).slice(0, 7)
-
- results.forEach(function (result) {
- const resultNode = document.createElement('li')
- resultNode.innerHTML = `${result.original.value}`
- autocompleteNode.appendChild(resultNode)
- })
-})
-
-searchNode.addEventListener('submit', submitForm)
-
-function submitForm (e) {
- if (e) e.preventDefault()
- if (results.length !== 0) {
- const indexInResult = selectedResult === -1 ? 0 : selectedResult
- selectedUser = USERS[results[indexInResult].index]
- }
- if (selectedUser == null) return
-
- document.body.classList.add('searched')
-
- updateFavNode()
-
- inputNode.value = selectedUser.value
- autocompleteNode.innerHTML = ''
-
- inputNode.blur()
-
- scheduleIframe.src = getURLOfUser(offset, selectedUser.type, selectedUser.index + 1)
-
- let eventAction
- switch (selectedUser.type) {
- case 'c':
- eventAction = 'Class'
- break
- case 't':
- eventAction = 'Teacher'
- break
- case 'r':
- eventAction = 'Room'
- break
- case 's':
- eventAction = 'Student'
- break
- }
- const eventLabel = selectedUser.value
-
- ga(function () {
- ga('send', { hitType: 'event', eventCategory: 'search', eventAction, eventLabel })
- })
-}
-
-autocompleteNode.addEventListener('click', function (e) {
- if (autocompleteNode.contains(e.target)) {
- selectedResult = Array.prototype.indexOf.call(e.target.parentElement.childNodes, e.target)
- submitForm()
- }
-})
-
-prevButton.addEventListener('click', function () {
- offset--
- updateWeekText()
- submitForm()
-})
-
-nextButton.addEventListener('click', function () {
- offset++
- updateWeekText()
- submitForm()
-})
-
-inputNode.addEventListener('click', function () {
- inputNode.select()
-})
-
-window.addEventListener('blur', function () {
- // this will removed the selection without drawing focus on it (safari)
- // this will removed selection even when focusing an iframe (chrome)
- const oldValue = inputNode.value
- inputNode.value = ''
- inputNode.value = oldValue
-
- // this will hide the keyboard (iOS safari)
- document.activeElement.blur()
-})
-
-searchNode.addEventListener('blur', function (e) {
- autocompleteNode.innerHTML = ''
-})
-
-favNode.addEventListener('click', function () {
- if (usersEqual(getCurrentFav(), selectedUser)) {
- changeFav(false)
- } else {
- changeFav(true)
- }
-})
-
-const currentFav = getCurrentFav()
-
-if (currentFav) {
- selectedUser = currentFav
- inputNode.value = selectedUser.value
- scheduleIframe.src = getURLOfUser(offset, selectedUser.type, selectedUser.index + 1)
- updateFavNode()
-
- let eventAction
- switch (selectedUser.type) {
- case 'c':
- eventAction = 'Class'
- break
- case 't':
- eventAction = 'Teacher'
- break
- case 'r':
- eventAction = 'Room'
- break
- case 's':
- eventAction = 'Student'
- break
- }
- const eventLabel = selectedUser.value
-
- ga(function () {
- ga('send', { hitType: 'event', eventCategory: 'search fav', eventAction, eventLabel })
- })
-} else if (inputNode.value === '') {
- document.body.classList.add('no-input')
- inputNode.focus()
-}
-
-if (scheduleIframe.src !== '') {
- document.body.classList.add('searched')
-}
-
-document.body.style.opacity = '1'
-
-window.easterEggs = easterEggs
diff --git a/public/javascripts/main.js b/public/javascripts/main.js
index 6f99621..5d0ef9c 100644
--- a/public/javascripts/main.js
+++ b/public/javascripts/main.js
@@ -1,4 +1,5 @@
require('./featureDetect').check()
+require('./zoom')
const frontpage = require('./frontpage')
const search = require('./search')
@@ -7,6 +8,7 @@ const weekSelector = require('./weekSelector')
const favorite = require('./favorite')
const scrollSnap = require('./scrollSnap')
const analytics = require('./analytics')
+const url = require('./url')
const state = {}
@@ -17,29 +19,54 @@ frontpage.show()
weekSelector.updateCurrentWeek()
scrollSnap.startListening()
-if (favorite.get() != null) {
- state.selectedItem = favorite.get()
- favorite.update(state.selectedItem)
- analytics.send.search(state.selectedItem, true)
- schedule.viewItem(weekSelector.getSelectedWeek(), state.selectedItem)
+if (url.hasSelectedUser()) {
+ state.selectedUser = url.getSelectedUser()
+
+ favorite.update(state.selectedUser)
+ url.update(state.selectedUser)
+ analytics.send.search(state.selectedUser)
+
+ schedule.viewItem(weekSelector.getSelectedWeek(), state.selectedUser)
+} else if (favorite.get() != null) {
+ state.selectedUser = favorite.get()
+
+ favorite.update(state.selectedUser)
+ url.push(state.selectedUser, false)
+ url.update(state.selectedUser)
+ analytics.send.search(state.selectedUser, true)
+
+ schedule.viewItem(weekSelector.getSelectedWeek(), state.selectedUser)
} else {
search.focus()
}
-search.on('search', function (selectedItem) {
- state.selectedItem = selectedItem
- favorite.update(state.selectedItem)
- analytics.send.search(state.selectedItem)
- schedule.viewItem(weekSelector.getSelectedWeek(), state.selectedItem)
+search.on('search', function (selectedUser) {
+ state.selectedUser = selectedUser
+
+ favorite.update(state.selectedUser)
+ url.push(state.selectedUser)
+ url.update(state.selectedUser)
+ analytics.send.search(state.selectedUser)
+
+ schedule.viewItem(weekSelector.getSelectedWeek(), state.selectedUser)
+})
+
+url.on('update', function (selectedUser) {
+ state.selectedUser = selectedUser
+
+ favorite.update(state.selectedUser)
+ url.update(state.selectedUser)
+
+ schedule.viewItem(weekSelector.getSelectedWeek(), state.selectedUser)
})
weekSelector.on('weekChanged', function (newWeek) {
- analytics.send.search(state.selectedItem)
- schedule.viewItem(newWeek, state.selectedItem)
+ analytics.send.search(state.selectedUser)
+ schedule.viewItem(newWeek, state.selectedUser)
})
favorite.on('click', function () {
- favorite.toggle(state.selectedItem)
+ favorite.toggle(state.selectedUser)
})
document.body.style.opacity = 1
diff --git a/public/javascripts/schedule.js b/public/javascripts/schedule.js
index a1ca647..657c4a0 100644
--- a/public/javascripts/schedule.js
+++ b/public/javascripts/schedule.js
@@ -1,5 +1,4 @@
const EventEmitter = require('events')
-const leftPad = require('left-pad')
const search = require('./search')
const self = new EventEmitter()
@@ -42,10 +41,8 @@ self._handleError = function (event) {
self.emit('load')
}
-self._getURLOfUsers = function (week, type, index) {
- const id = index + 1
- return '//' + window.location.host + '/meetingpointProxy/Roosters-AL%2Fdoc%2Fdagroosters%2F' +
- leftPad(week, 2, '0') + '%2F' + type + '%2F' + type + leftPad(id, 5, '0') + '.htm'
+self._getURLOfUser = function (week, user) {
+ return `/get/${user.type}/${user.value}?week=${week}`
}
self._removeChilds = function () {
@@ -55,17 +52,22 @@ self._removeChilds = function () {
}
self.viewItem = function (week, selectedUser) {
- const url = self._getURLOfUsers(week, selectedUser.type, selectedUser.index)
+ if (selectedUser == null) {
+ self._removeChilds()
+ search.updateDom(selectedUser)
+ } else {
+ const url = self._getURLOfUser(week, selectedUser)
- self._removeChilds()
+ self._removeChilds()
- const request = new window.XMLHttpRequest()
- request.addEventListener('load', self._handleLoad)
- request.addEventListener('error', self._handleError)
- request.open('GET', url, true)
- request.send()
+ const request = new window.XMLHttpRequest()
+ request.addEventListener('load', self._handleLoad)
+ request.addEventListener('error', self._handleError)
+ request.open('GET', url, true)
+ request.send()
- search.updateDom(selectedUser)
+ search.updateDom(selectedUser)
+ }
}
module.exports = self
diff --git a/public/javascripts/scrollSnap.js b/public/javascripts/scrollSnap.js
index 167f0c1..afee979 100644
--- a/public/javascripts/scrollSnap.js
+++ b/public/javascripts/scrollSnap.js
@@ -12,12 +12,13 @@ self._timeoutID = null
self._getScrollPosition = function () {
return (document.documentElement && document.documentElement.scrollTop) ||
- document.body.scrollTop
+ document.body.scrollTop
}
self._handleDoneScrolling = function () {
const scrollPosition = self._getScrollPosition()
- const weekSelectorHeight = self._nodes.weekSelector.clientHeight - self._nodes.search.clientHeight
+ const weekSelectorHeight =
+ self._nodes.weekSelector.clientHeight - self._nodes.search.clientHeight
if (scrollPosition < weekSelectorHeight && scrollPosition > 0) {
window.scroll({ top: weekSelectorHeight, left: 0, behavior: 'smooth' })
}
@@ -28,7 +29,8 @@ self._handleScroll = function () {
self._timeoutID = window.setTimeout(self._handleDoneScrolling, 500)
const scrollPosition = self._getScrollPosition()
- const weekSelectorHeight = self._nodes.weekSelector.clientHeight - self._nodes.search.clientHeight
+ const weekSelectorHeight =
+ self._nodes.weekSelector.clientHeight - self._nodes.search.clientHeight
if (scrollPosition >= weekSelectorHeight) {
document.body.classList.add('week-selector-not-visible')
} else {
@@ -37,8 +39,10 @@ self._handleScroll = function () {
}
self._handleWindowResize = function () {
- const weekSelectorHeight = self._nodes.weekSelector.clientHeight - self._nodes.search.clientHeight
- const extraPixelsNeeded = weekSelectorHeight - (document.body.clientHeight - window.innerHeight)
+ const weekSelectorHeight =
+ self._nodes.weekSelector.clientHeight - self._nodes.search.clientHeight
+ const extraPixelsNeeded =
+ weekSelectorHeight - (document.body.clientHeight - window.innerHeight)
if (extraPixelsNeeded > 0) {
document.body.style.marginBottom = extraPixelsNeeded + 'px'
} else {
diff --git a/public/javascripts/search.js b/public/javascripts/search.js
index a07d6dd..96413b0 100644
--- a/public/javascripts/search.js
+++ b/public/javascripts/search.js
@@ -13,22 +13,29 @@ self._nodes = {
}
self.submit = function () {
- const selectedItem = autocomplete.getSelectedItem()
- if (selectedItem == null) return
+ const selectedUser = autocomplete.getSelectedUser()
+ if (selectedUser == null) return
- console.log(selectedItem)
+ console.log(selectedUser)
self._nodes.input.blur()
document.body.classList.remove('week-selector-not-visible') // Safari bug
- self.emit('search', selectedItem)
+ self.emit('search', selectedUser)
}
-self.updateDom = function (selectedItem) {
- self._nodes.input.value = selectedItem.value
- autocomplete.removeAllItems()
- document.body.classList.remove('no-input')
- document.body.classList.add('searched')
+self.updateDom = function (selectedUser) {
+ if (selectedUser == null) {
+ self._nodes.input.value = ''
+ autocomplete.removeAllItems()
+ document.body.classList.add('no-input')
+ document.body.classList.remove('searched')
+ } else {
+ self._nodes.input.value = selectedUser.value
+ autocomplete.removeAllItems()
+ document.body.classList.remove('no-input')
+ document.body.classList.add('searched')
+ }
}
self.focus = function () {
@@ -42,7 +49,7 @@ self._handleSubmit = function (event) {
self._calculate = function (searchTerm) {
const allResults = fuzzy.filter(searchTerm, USERS, {
- extract: function (item) { return item.value }
+ extract: function (user) { return user.value }
})
const firstResults = allResults.slice(0, 7)
diff --git a/public/javascripts/url.js b/public/javascripts/url.js
new file mode 100644
index 0000000..17ab7c8
--- /dev/null
+++ b/public/javascripts/url.js
@@ -0,0 +1,67 @@
+/* global USERS FLAGS */
+
+const EventEmitter = require('events')
+
+const self = new EventEmitter()
+
+self._getPageTitle = function (selectedUser) {
+ let ret
+
+ if (selectedUser == null) {
+ ret = `Metis Rooster`
+ } else {
+ ret = `Metis Rooster - ${selectedUser.value}`
+ }
+
+ if (FLAGS.indexOf('BETA') !== -1) {
+ ret = `BETA ${ret}`
+ }
+
+ return ret
+}
+
+self._getPageURL = function (selectedUser) {
+ return `/${selectedUser.type}/${selectedUser.value}`
+}
+
+self.push = function (selectedUser, push) {
+ if (push == null) push = true
+ const pageTitle = self._getPageTitle(selectedUser)
+ const pageURL = self._getPageURL(selectedUser)
+ if (push) {
+ window.history.pushState(selectedUser, pageTitle, pageURL)
+ } else {
+ window.history.replaceState(selectedUser, pageTitle, pageURL)
+ }
+}
+
+self.update = function (selectedUser) {
+ document.title = self._getPageTitle(selectedUser)
+}
+
+self.hasSelectedUser = function () {
+ const pageUrl = window.location.pathname
+ return /^\/s\/|^\/t\/|^\/r\/|^\/c\//.test(pageUrl)
+}
+
+self.getSelectedUser = function () {
+ const pageUrl = window.location.pathname
+ const pageUrlData = pageUrl.split('/')
+ const type = pageUrlData[1]
+ const value = pageUrlData[2]
+
+ const user = USERS.filter(function (user) {
+ return user.type === type &&
+ user.value === value
+ })[0]
+
+ return user
+}
+
+self._handleUpdate = function (event) {
+ self.emit('update', event.state)
+}
+
+window.addEventListener('popstate', self._handleUpdate)
+
+module.exports = self
diff --git a/public/javascripts/zoom.js b/public/javascripts/zoom.js
new file mode 100644
index 0000000..59b80db
--- /dev/null
+++ b/public/javascripts/zoom.js
@@ -0,0 +1,30 @@
+const schedule = require('./schedule')
+
+const self = {}
+
+self._nodes = {
+ body: document.body
+}
+
+self._handleResize = function () {
+ // the table node may not exist before this function is called
+ const tableNode = document.querySelector('center > table')
+
+ // infact, it may not even exist when this function is called.
+ if (!tableNode) return
+
+ const tableWidth = tableNode.getBoundingClientRect().width
+ const tableGoalWidth = self._nodes.body.getBoundingClientRect().width * 0.9
+ const zoomFactor = tableGoalWidth / tableWidth
+
+ if (zoomFactor < 1) {
+ tableNode.style.zoom = `${zoomFactor}`
+ } else {
+ tableNode.style.zoom = `1`
+ }
+}
+
+schedule.on('load', self._handleResize)
+window.addEventListener('resize', self._handleResize)
+
+module.exports = self
diff --git a/public/manifest.beta.webmanifest b/public/manifest.beta.webmanifest
new file mode 100644
index 0000000..a1fdd92
--- /dev/null
+++ b/public/manifest.beta.webmanifest
@@ -0,0 +1,29 @@
+{
+ "name": "BETA Metis Rooster",
+ "short_name": "BETA Rooster",
+ "start_url": "/",
+ "display": "standalone",
+ "background_color": "#ececec",
+ "description": "Een verbeterde rooster pagina voor het metis",
+ "icons": [{
+ "src": "/icons/res/mipmap-mdpi/ic_launcher.png",
+ "sizes": "48x48",
+ "type": "image/png"
+ }, {
+ "src": "/icons/res/mipmap-hdpi/ic_launcher.png",
+ "sizes": "72x72",
+ "type": "image/png"
+ }, {
+ "src": "/icons/res/mipmap-xhdpi/ic_launcher.png",
+ "sizes": "96x96",
+ "type": "image/png"
+ }, {
+ "src": "/icons/res/mipmap-xxhdpi/ic_launcher.png",
+ "sizes": "144x144",
+ "type": "image/png"
+ }, {
+ "src": "/icons/res/mipmap-xxxhdpi/ic_launcher.png",
+ "sizes": "192x192",
+ "type": "image/png"
+ }]
+}
diff --git a/public/stylesheets/style.css b/public/stylesheets/style.css
index c2c7e8f..830b007 100644
--- a/public/stylesheets/style.css
+++ b/public/stylesheets/style.css
@@ -351,19 +351,6 @@ body.no-input #week-selector {
display: none;
}
-@media screen and (max-width: 600px) {
- table table tr {
- display: flex;
- flex-direction: column;
- }
-
- table * {
- padding: 0;
- line-height: 13px;
- font-size: 13px;
- }
-}
-
.error {
text-align: center;
margin-top: 100px;
diff --git a/routes/getSchedule.js b/routes/getSchedule.js
new file mode 100644
index 0000000..f6c3cb6
--- /dev/null
+++ b/routes/getSchedule.js
@@ -0,0 +1,55 @@
+const express = require('express')
+const router = express.Router()
+const request = require('request')
+const iconv = require('iconv-lite')
+
+const getUserIndex = require('../lib/getUserIndex')
+const getURLOfUser = require('../lib/getURLOfUser')
+
+// copied from http://www.meetingpointmco.nl/Roosters-AL/doc/dagroosters/untisscripts.js,
+// were using the same code as they do to be sure that we always get the same
+// week number.
+function getWeekNumber (target) {
+ const dayNr = (target.getDay() + 6) % 7
+ target.setDate(target.getDate() - dayNr + 3)
+ const firstThursday = target.valueOf()
+ target.setMonth(0, 1)
+ if (target.getDay() !== 4) {
+ target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7)
+ }
+
+ return 1 + Math.ceil((firstThursday - target) / 604800000)
+}
+
+router.get('/:type/:value', function (req, res, next) {
+ getUserIndex().then(users => {
+ const { type, value } = req.params
+ let { week } = req.query
+ const user =
+ users.filter(user => user.type === type && user.value === value)[0]
+
+ if (!user) {
+ next(new Error(`${type}${value} is not in the user index.`))
+ }
+
+ if (!week) {
+ week = getWeekNumber(new Date())
+ }
+
+ const { index } = user
+
+ const url = getURLOfUser(type, index, week)
+
+ request(url, { encoding: null }, function (err, data) {
+ if (err) {
+ next(err)
+ return
+ }
+
+ const utf8Body = iconv.decode(data.body, 'ISO-8859-1')
+ res.status(data.statusCode).end(utf8Body)
+ })
+ })
+})
+
+module.exports = router
diff --git a/routes/hello.js b/routes/hello.js
deleted file mode 100644
index 6356b98..0000000
--- a/routes/hello.js
+++ /dev/null
@@ -1,9 +0,0 @@
-var express = require('express')
-var router = express.Router()
-
-/* GET home page. */
-router.get('/', function (req, res, next) {
- res.render('hello')
-})
-
-module.exports = router
diff --git a/routes/index.js b/routes/index.js
index 1ab2ba3..3718015 100644
--- a/routes/index.js
+++ b/routes/index.js
@@ -2,18 +2,29 @@
const express = require('express')
const router = express.Router()
-const users = require('../lib/getUserIndex')
+const getUserIndex = require('../lib/getUserIndex')
/* GET home page. */
-router.get('/', function (req, res, next) {
- let flags = []
- if (req.query.nfd != null) {
- flags.push('NO_FEATURE_DETECT')
- }
+router.get(['/', '/s/*', '/t/*', '/r/*', '/c/*'], function (req, res, next) {
+ getUserIndex().then(users => {
+ const isBeta = process.env.BETA === '1'
- const flagsStr = `var FLAGS = ${JSON.stringify(flags)};`
- const usersStr = `var USERS = ${JSON.stringify(users.users)};`
- res.render('index', { flagsStr, usersStr })
+ let flags = []
+ if (isBeta) {
+ flags.push('BETA')
+ flags.push('NO_FEATURE_DETECT')
+ } else if (req.query.nfd != null) {
+ flags.push('NO_FEATURE_DETECT')
+ }
+
+ const flagsStr = `var FLAGS = ${JSON.stringify(flags)};`
+ const usersStr = `var USERS = ${JSON.stringify(users)};`
+
+ res.render('index', { flagsStr, usersStr, isBeta })
+ }).catch(function () {
+ console.error('Unable to get user info, emergency redirect!')
+ res.redirect('http://www.meetingpointmco.nl/Roosters-AL/doc/')
+ })
})
module.exports = router
diff --git a/routes/manifest.js b/routes/manifest.js
new file mode 100644
index 0000000..b2ce55f
--- /dev/null
+++ b/routes/manifest.js
@@ -0,0 +1,19 @@
+'use strict'
+
+const express = require('express')
+const router = express.Router()
+const path = require('path')
+
+router.get('/', function (req, res, next) {
+ console.log('got a request')
+
+ const isBeta = process.env.BETA === '1'
+
+ if (isBeta) {
+ res.sendFile('manifest.beta.webmanifest', { root: path.join(__dirname, '../public') })
+ } else {
+ res.sendFile('manifest.webmanifest', { root: path.join(__dirname, '../public') })
+ }
+})
+
+module.exports = router
diff --git a/routes/meetingpointProxy.js b/routes/meetingpointProxy.js
deleted file mode 100644
index 68f3fdf..0000000
--- a/routes/meetingpointProxy.js
+++ /dev/null
@@ -1,19 +0,0 @@
-const express = require('express')
-const router = express.Router()
-const request = require('request')
-const iconv = require('iconv-lite')
-
-router.get('/:url', function (req, res, next) {
- const url = `http://www.meetingpointmco.nl/${req.params.url}`
- request(url, { encoding: null }, function (err, data) {
- if (err) {
- next(err)
- return
- }
-
- const utf8Body = iconv.decode(data.body, 'ISO-8859-1')
- res.status(data.statusCode).end(utf8Body)
- })
-})
-
-module.exports = router
diff --git a/routes/opensearch.js b/routes/opensearch.js
new file mode 100644
index 0000000..c3e2e57
--- /dev/null
+++ b/routes/opensearch.js
@@ -0,0 +1,12 @@
+'use strict'
+
+const express = require('express')
+const router = express.Router()
+const path = require('path')
+
+router.get('/', function (req, res, next) {
+ res.setHeader('content-type', 'application/opensearchdescription+xml')
+ res.sendFile('opensearch.xml', { root: path.join(__dirname, '../public') })
+})
+
+module.exports = router
diff --git a/views/hello.jade b/views/hello.jade
deleted file mode 100644
index 260ca9f..0000000
--- a/views/hello.jade
+++ /dev/null
@@ -1,9 +0,0 @@
-extends layout
-
-block head
- link(rel='stylesheet', href='/stylesheets/hello.css')
-
-block content
- p.madeby Gemaakt door Noah Loomans
- p.ideas Heb je ideeën om dit te verbeteren? Mail me op&nbsp;
- a(href='mailto:noah.loomans+roostermml@hetcml.nl') noah.loomans+roostermml@hetcml.nl
diff --git a/views/index.jade b/views/index.jade
index 1b96615..8e75ef9 100644
--- a/views/index.jade
+++ b/views/index.jade
@@ -1,5 +1,8 @@
extends layout
+block variables
+ - var bodyStyle = 'opacity: 0;';
+
block head
link(rel='stylesheet', href='/stylesheets/style.css')
link(rel='stylesheet', href='/stylesheets/print.css', media='print')
diff --git a/views/layout.jade b/views/layout.jade
index 31b3918..f7f9e1f 100644
--- a/views/layout.jade
+++ b/views/layout.jade
@@ -1,8 +1,14 @@
+block variables
+ - var bodyStyle = '';
+
doctype html
html(lang='nl')
head
block head_top
- title Metis Rooster
+ if isBeta
+ title BETA Metis Rooster
+ else
+ title Metis Rooster
meta(name='theme-color',content='#F44336')
meta(name='viewport', content='width=device-width, initial-scale=1')
link(href='https://fonts.googleapis.com/css?family=Roboto', rel='stylesheet')
@@ -12,7 +18,7 @@ html(lang='nl')
link(rel="icon", type="image/png", href="/favicon-16x16.png", sizes="16x16")
link(rel="mask-icon", href="/safari-pinned-tab.svg", color="#f44336")
block head
- body(style='opacity: 0;')
+ body(style=bodyStyle)
block content
script.
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');ga('create', 'UA-83684754-1', 'auto');ga('send', 'pageview');