From 0a9b22c5ba744ab5b5fd01baed2a2d15d98613bc Mon Sep 17 00:00:00 2001 From: Bilal ayachi Date: Sun, 10 Dec 2017 17:11:15 +0100 Subject: Add clickable user code --- src/server/routes/getSchedule.js | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'src/server/routes') diff --git a/src/server/routes/getSchedule.js b/src/server/routes/getSchedule.js index 7850918..f5da08c 100644 --- a/src/server/routes/getSchedule.js +++ b/src/server/routes/getSchedule.js @@ -22,6 +22,7 @@ function getWeekNumber (target) { return 1 + Math.ceil((firstThursday - target) / 604800000) } + router.get('/:type/:value.png', function (req, res, next) { port = process.env.PORT || 3000; const { type, value } = req.params @@ -49,6 +50,7 @@ router.get('/:type/:value', function (req, res, next) { 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.`)) } @@ -67,7 +69,37 @@ router.get('/:type/:value', function (req, res, next) { return } - const utf8Body = iconv.decode(data.body, 'ISO-8859-1') + + + + let utf8Body = iconv.decode(data.body, 'ISO-8859-1') + + + users.forEach(function (user) { + let user_list = user.value; + //let user_lijst_twee = user; + let opties = { + "leraar": "t", + "klas": "c", + "leerling": "s", + "lokaal": "r" + }; + + + user_list = new RegExp(user_list, 'g') + + + let show_user_display = user_list.toString().replace(/[&\/\\#,+()$~%.'":g*?<>{}]/g,""); + + + utf8Body = utf8Body.replace(user_list, "" + show_user_display + "") + console.log(show_user_display); + + + }) + + + res.status(data.statusCode).end(utf8Body) }) }) -- cgit v1.1