@ -139,6 +139,17 @@ exports.returnIndividualStory = function(req, res, next) {
|
||||
return res.redirect('../stories/' + dashedNameFull);
|
||||
}
|
||||
|
||||
var userVoted = false;
|
||||
try {
|
||||
var votedObj = story.upVotes.filter(function(a){
|
||||
return a['upVotedByUsername'] === req.user['profile']['username'];
|
||||
})
|
||||
if (votedObj.length > 0){
|
||||
userVoted = true;
|
||||
}
|
||||
} catch(err){
|
||||
userVoted = false;
|
||||
}
|
||||
res.render('stories/index', {
|
||||
title: story.headline,
|
||||
link: story.link,
|
||||
@ -152,7 +163,8 @@ exports.returnIndividualStory = function(req, res, next) {
|
||||
timeAgo: moment(story.timePosted).fromNow(),
|
||||
image: story.image,
|
||||
page: 'show',
|
||||
storyMetaDescription: story.metaDescription
|
||||
storyMetaDescription: story.metaDescription,
|
||||
hasUserVoted: userVoted
|
||||
});
|
||||
});
|
||||
};
|
||||
|
@ -126,6 +126,7 @@ $(document).ready(function() {
|
||||
});
|
||||
|
||||
var upvoteHandler = function () {
|
||||
$(".ion-arrow-up-b").hide();
|
||||
var _id = storyId;
|
||||
$('#upvote').unbind('click');
|
||||
var alreadyUpvoted = false;
|
||||
|
@ -6,6 +6,7 @@
|
||||
var upVotes = !{JSON.stringify(upVotes)};
|
||||
var user = !{JSON.stringify(user)};
|
||||
var image = !{JSON.stringify(image)};
|
||||
var hasUserVoted = !{JSON.stringify(hasUserVoted)};
|
||||
.spacer
|
||||
|
||||
h3.row
|
||||
@ -13,6 +14,7 @@
|
||||
.col-xs-3.col-sm-1.text-center
|
||||
.row.negative-5
|
||||
.col-xs-12.big-ion-up-arrow
|
||||
if !hasUserVoted
|
||||
a#upvote
|
||||
i.ion-arrow-up-b
|
||||
h3.story-up-votes
|
||||
|
Reference in New Issue
Block a user