diff options
| author | Waref Haque <warefhaque@Warefs-MacBook-Pro.local> | 2016-07-19 04:21:17 +0000 |
|---|---|---|
| committer | Waref Haque <warefhaque@Warefs-MacBook-Pro.local> | 2016-07-19 04:21:17 +0000 |
| commit | daefddd8dc45e7044e83bd40706cfdca36471fe9 (patch) | |
| tree | 6d3617d1385d7e81af353f8196ddbd67204e26b2 /app.js | |
| parent | 5392cf6f6fa08d666ee58a2a57757192d9a50398 (diff) | |
proper exams rendering
Diffstat (limited to 'app.js')
| -rw-r--r-- | app.js | 48 |
1 files changed, 0 insertions, 48 deletions
@@ -32,51 +32,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();}); -} |
