From 553e5d112f34c6be19b388fea110dcdceb7015bd Mon Sep 17 00:00:00 2001 From: nanalelfe Date: Mon, 25 Jul 2016 02:59:23 -0400 Subject: Profile page hanging --- bin/www.js | 6 ----- routes/user.js | 62 ++++++---------------------------------------- views/user_profile_alt.hbs | 34 +++++++++++++++++++++++-- 3 files changed, 39 insertions(+), 63 deletions(-) diff --git a/bin/www.js b/bin/www.js index 1d252bf..9cc2f2d 100644 --- a/bin/www.js +++ b/bin/www.js @@ -4,15 +4,9 @@ var http = require('http'); var server = http.createServer(app); -var io = require('socket.io')(server); - var port = '3000'; app.set('port', port); -io.on('connection', function(socket){ - console.log('a user connected'); -}); - server.listen(port, function(){ console.log('listening on port 3000'); }); diff --git a/routes/user.js b/routes/user.js index 90e3b8d..f6ac438 100644 --- a/routes/user.js +++ b/routes/user.js @@ -16,60 +16,6 @@ router.get('/logout', loggedIn, function (req, res, next) { }); -function getComments(req) { - var comments = []; - dbFile.retrieve_userComments_history(req.user.user_name, function (success, object) { - if (!success) { - // Need to redirect to an error page instead. - console.log("Could not retrieve comments."); - if (!comments.length) { - var obj = { - comment: 'Use a heap!', - date: '2016-04-05', - exam_id: 'some id', - exam_info : { - course_code : 'CSC263', - term: 'Fall', - year : 2016 - } - }; - comments.push(obj); - comments.push(obj); - } - } else if (object.length){ - comments = object; - console.log(object); - } - - - - }); -} - -var checkMail = function(req){ - var inbox = []; - dbFile.checkMailbox(req.user.user_name, function(success, error, data, message){ - if (success) { - inbox = data; - } else if (error) { - // For testing purposes, remove later: - if (!inbox.length) { - var mail_data = { - sender: 'The Dude', receiver: req.user.user_name, - message: 'Whoa look at this', - date: '2016-04-05' - } - } - inbox.push(mail_data); - inbox.push(mail_data); - // Need to redirect to an error page instead. - console.log("Could not retrieve mail."); - } - }); -} - - - /* Render/GET user_profile page */ router.get('/user_profile', loggedIn, isUser, function(req, res, next) { req.session.messages = null; @@ -114,7 +60,8 @@ router.get('/user_profile', loggedIn, isUser, function(req, res, next) { if (!inbox.length) { var mail_data = { sender: 'The Dude', receiver: req.user.user_name, - message: 'Whoa look at this', + subject: 'Whoa look at this', + message: 'I sent you a link on Skype', date: '2016-04-05' } } @@ -264,9 +211,14 @@ router.post('/signin', loggedOut, function(req, res, next) { router.post('/user_profile/send_message', loggedIn, function(req, res, next) { var date = new Date(); var current_date = date.toString().slice(0, 24); + var subject = req.body.subject; + if (!subject) { + subject = '(none)'; + } var mail_data = { sender: req.user.user_name, receiver: req.body.receiver_username, + subject: subject, message: req.body.message, date: current_date }; diff --git a/views/user_profile_alt.hbs b/views/user_profile_alt.hbs index 871f73e..89680e9 100644 --- a/views/user_profile_alt.hbs +++ b/views/user_profile_alt.hbs @@ -172,9 +172,13 @@ col-sm-offset-0 col-md-offset-3 col-lg-offset-3 toppad prf-details"> +
+ + +
- +
@@ -195,14 +199,40 @@ col-sm-offset-0 col-md-offset-3 col-lg-offset-3 toppad prf-details"> {{# each inbox }} + {{ this.date }} - {{ this.message }} + {{ this.subject }} {{ this.sender }} + {{/each}} + + {{# each inbox}} + + {{/each}} {{ else }}

No Messages.

-- cgit v1.2.3