aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNoah Loomans <noahloomans@gmail.com>2017-05-26 18:35:51 +0200
committerNoah Loomans <noahloomans@gmail.com>2017-05-26 18:35:51 +0200
commita6a4ddc10ba1a458b94b13c59a4081e9ce1e5b33 (patch)
tree7b72b1131f74103d248d88778b2d05e2a93e106d /lib
parentdf9e9c861631274e3b6ba936cd7dae249e0003ea (diff)
Add emergency redirect
Diffstat (limited to 'lib')
-rw-r--r--lib/getUserIndex.js17
1 files changed, 5 insertions, 12 deletions
diff --git a/lib/getUserIndex.js b/lib/getUserIndex.js
index d71cb3b..6288dc3 100644
--- a/lib/getUserIndex.js
+++ b/lib/getUserIndex.js
@@ -4,12 +4,8 @@ const Promise = require('bluebird')
const cheerio = require('cheerio')
const request = Promise.promisify(require('request'))
-exports = {}
-module.exports = exports
-
-function getStandardUsers () {
- return new Promise(function (resolve, reject) {
- request(`http://www.meetingpointmco.nl/Roosters-AL/doc/dagroosters/frames/navbar.htm`)
+function getUserIndex () {
+ return request(`http://www.meetingpointmco.nl/Roosters-AL/doc/dagroosters/frames/navbar.htm`)
.then(function (page) {
page = page.body
@@ -17,14 +13,14 @@ function getStandardUsers () {
const $script = $('script').eq(1)
const scriptText = $script.text()
- const regexs = [/var classes = \[(.+)\];/, /var teachers = \[(.+)\];/, /var rooms = \[(.+)\];/, /var students = \[(.+)\];/]
+ 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, '')
})
})
- resolve([]
+ return ([]
.concat(items[0].map(function (item, index) {
return {
type: 'c',
@@ -54,9 +50,6 @@ function getStandardUsers () {
}
})))
})
- })
}
-getStandardUsers().then(users => {
- exports.users = users
-})
+module.exports = getUserIndex