diff options
| author | nanalelfe <nargiza.nosirova@mail.utoronto.ca> | 2016-07-20 21:11:59 +0000 |
|---|---|---|
| committer | nanalelfe <nargiza.nosirova@mail.utoronto.ca> | 2016-07-20 21:11:59 +0000 |
| commit | d46b37fcb7c97ab59fd929cfc0a8d766ca8a0b8a (patch) | |
| tree | 3b51e4c196bacd7c4524e8dbdb472a0e972aac8c /app.js | |
| parent | 3d2f0e48def5b314121f7315ada1008f6801fa2b (diff) | |
| parent | 7a9c0a4732ba720fba72be06dcafa0dbbf26022b (diff) | |
Merged
Diffstat (limited to 'app.js')
| -rw-r--r-- | app.js | 48 |
1 files changed, 0 insertions, 48 deletions
@@ -41,51 +41,3 @@ app.use(express.static(__dirname)); app.use('/', routes); module.exports = app; - -app.listen(3000, function() { - console.log('listening on http://localhost:3000/'); -}); - -//to fetch exams given a course code and populate the exams page -app.get('/exams',function (req,res) { - console.log(req.query.search); - var courseName = req.query.search; - courseName = sanitizer.escape(courseName); - courseName = courseName.toUpperCase(); - console.log(courseName); - var result = getExamsForCourseCode(courseName); - console.log(result); - res.write(JSON.stringify(result)); -}); - -function getExamsForCourseCode(courseCode) { - var minExamInfoArray = []; - dbFile.get_all_exams(courseCode, function (exams) { - if (exams.length == 0){ - console.log("Nothing was found"); - } - else { - //console.log(exams); - //only pass over the information that is necessary for the exams page - for (var i = 0; i<exams.length;i++){ - var minExamInfo = { courseCode:exams[i].course_code, - year:exams[i].year, - term:toProperCase(exams[i].term), - instructors:exams[i].instructors, - type:toProperCase(exams[i].type) + " Examination" - }; - minExamInfoArray.push(minExamInfo); - console.log(minExamInfo); - } - } - }); - - return minExamInfoArray; -} - - -/*Helper function to make sure the proper capital case is presented*/ - -function toProperCase(string) { - return string.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();}); -} |
