aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
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