diff options
| author | nanalelfe <nargiza.nosirova@mail.utoronto.ca> | 2016-07-25 06:59:23 +0000 |
|---|---|---|
| committer | nanalelfe <nargiza.nosirova@mail.utoronto.ca> | 2016-07-25 06:59:23 +0000 |
| commit | 553e5d112f34c6be19b388fea110dcdceb7015bd (patch) | |
| tree | 4fc43eb34b679d610eabf544cebbd29ffad7452e | |
| parent | 6d8857b2a3774db605f10631e327f152f241834b (diff) | |
Profile page hanging
| -rw-r--r-- | bin/www.js | 6 | ||||
| -rw-r--r-- | routes/user.js | 62 | ||||
| -rw-r--r-- | views/user_profile_alt.hbs | 34 |
3 files changed, 39 insertions, 63 deletions
@@ -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 @@ -173,8 +173,12 @@ col-sm-offset-0 col-md-offset-3 col-lg-offset-3 toppad prf-details"> <input type="text" class="form-control" placeholder="Username" name="receiver_username"> </div> <div class="form-group"> + <label for="subject">Subject</label> + <input type="text" class="form-control" placeholder="Subject" name="subject"> + </div> + <div class="form-group"> <label for="sending-message">Message:</label> - <textarea class="form-control" rows="3" name="message"></textarea> + <textarea class="form-control" placeholder="Enter message here..." rows="3" name="message"></textarea> </div> <button class="btn btn-primary">Send Message</button> <input type="hidden" name="_csrf" value="{{ csrfToken }}"> @@ -195,14 +199,40 @@ col-sm-offset-0 col-md-offset-3 col-lg-offset-3 toppad prf-details"> </thead> <tbody> {{# each inbox }} + <a href="#" data-toggle="modal"> <tr> <td>{{ this.date }}</td> - <td>{{ this.message }}</td> + <td>{{ this.subject }}</td> <td>{{ this.sender }}</td> </tr> + </a> {{/each}} </tbody> </table> + + {{# each inbox}} + <article class="modal fade {{this.date}}{{this.sender}}"> + <div class="modal-dialog"> + <div class="modal-content"> + + <section class="modal-header"> + <button type="button" class="close" data-dismiss="modal">×</button> + <h4 class="modal-title"><em>Subject: </em>{{ this.subject }}</h4> + <h5><em>From: </em>{{ this.sender }}</h5> + </section> + + <section class="modal-body"> + {{ this.message }} + </section> + + <div class="modal-footer"> + + </div> + + </div> + </div> + </article> + {{/each}} </div> {{ else }} <h3>No Messages.</h3> |
