aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/getMeetingpointData.js18
-rw-r--r--lib/getURLOfUsers.js6
2 files changed, 21 insertions, 3 deletions
diff --git a/lib/getMeetingpointData.js b/lib/getMeetingpointData.js
index 94cf36c..ea0f4de 100644
--- a/lib/getMeetingpointData.js
+++ b/lib/getMeetingpointData.js
@@ -13,7 +13,13 @@ function getUsers (page) {
const regexs = [/var classes = \[(.+)\];/, /var teachers = \[(.+)\];/, /var rooms = \[(.+)\];/, /var students = \[(.+)\];/]
const items = regexs.map(function (regex) {
- return script.match(regex)[1].split(',').map(function (item) {
+ const match = script.match(regex)
+
+ if (!match) {
+ return []
+ }
+
+ return match[1].split(',').map(function (item) {
return item.replace(/"/g, '')
})
})
@@ -59,9 +65,17 @@ function getValidWeekNumbers(page) {
function requestData() {
lastUpdate = new Date()
- return request(`http://www.meetingpointmco.nl/Roosters-AL/doc/dagroosters/frames/navbar.htm`, { timeout: 5000 }).then((response) => {
+ const url = process.env.SCHOOL_LEVEL === 'mavo'
+ ? 'http://www.meetingpointmco.nl/Roosters-AL/TOSweb/dagroosters/frames/navbar.htm'
+ : 'http://www.meetingpointmco.nl/Roosters-AL/doc/dagroosters/frames/navbar.htm';
+
+ console.log(url);
+
+ return request(url, { timeout: 5000 }).then((response) => {
const page = cheerio.load(response.body)
+ console.log('hey')
const users = getUsers(page)
+ console.log(users);
const validWeekNumbers = getValidWeekNumbers(page)
meetingpointData = { users, validWeekNumbers }
diff --git a/lib/getURLOfUsers.js b/lib/getURLOfUsers.js
index 8590ee4..528620f 100644
--- a/lib/getURLOfUsers.js
+++ b/lib/getURLOfUsers.js
@@ -33,7 +33,11 @@ function getWeek () {
}
function getURLOfUsers (weekOffset, type, id) {
- return `http://www.meetingpointmco.nl/Roosters-AL/doc/dagroosters/` +
+ const baseUrl = process.env.SCHOOL_LEVEL === 'mavo'
+ ? 'http://www.meetingpointmco.nl/Roosters-AL/TOSweb'
+ : 'http://www.meetingpointmco.nl/Roosters-AL/doc'
+
+ return `${baseUrl}/dagroosters/` +
`${getWeek() + weekOffset}/${type}/${type}${leftPad(id, 5, '0')}.htm`
}