aboutsummaryrefslogtreecommitdiff
path: root/src/server/routes/getSchedule.js
diff options
context:
space:
mode:
authorBilal ayachi <bilal.ayachi@hetmml.nl>2017-12-10 17:11:15 +0100
committerBilal ayachi <bilal.ayachi@hetmml.nl>2017-12-10 17:11:15 +0100
commit0a9b22c5ba744ab5b5fd01baed2a2d15d98613bc (patch)
treed7538c9a218d7b454ecce09eff27aaa57ffc3e36 /src/server/routes/getSchedule.js
parentf18692872cdc28d29917247ef4f8ef7553a8b023 (diff)
Add clickable user codeclickable-users
Diffstat (limited to 'src/server/routes/getSchedule.js')
-rw-r--r--src/server/routes/getSchedule.js34
1 files changed, 33 insertions, 1 deletions
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, "<a href='/" + optie + user_list + "'>" + show_user_display + "</a>")
+ console.log(show_user_display);
+
+
+ })
+
+
+
res.status(data.statusCode).end(utf8Body)
})
})