From a6a4ddc10ba1a458b94b13c59a4081e9ce1e5b33 Mon Sep 17 00:00:00 2001 From: Noah Loomans Date: Fri, 26 May 2017 18:35:51 +0200 Subject: Add emergency redirect --- lib/getUserIndex.js | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'lib') 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 -- cgit v1.1