voters info

v1.18.x
barisusakli 10 years ago
parent 8330a6e6d9
commit 9d56f50967

@ -94,6 +94,10 @@ define('forum/topic/postTools', ['composer', 'share', 'navigator'], function(com
return toggleVote($(this), '.downvoted', 'posts.downvote');
});
postContainer.on('click', '.votes', function() {
showVotes(getData($(this), 'data-pid'));
});
postContainer.on('click', '.flag', function() {
flagPost(getData($(this), 'data-pid'));
});
@ -194,6 +198,30 @@ define('forum/topic/postTools', ['composer', 'share', 'navigator'], function(com
return false;
}
function showVotes(pid) {
if (!app.isAdmin) {
return;
}
socket.emit('admin.getVoters', pid, function(err, data) {
if (err) {
return app.alertError(err.message);
}
templates.parse('partials/modals/votes_modal', data, function(html) {
var dialog = bootbox.dialog({
title: 'Voters',
message: html,
className: 'vote-modal',
show: true
});
dialog.on('click', function() {
dialog.modal('hide');
});
});
});
}
function getData(button, data) {
return button.parents('.post-row').attr(data);
}

@ -270,4 +270,33 @@ SocketAdmin.getMoreFlags = function(socket, after, callback) {
});
};
SocketAdmin.getVoters = function(socket, pid, callback) {
async.parallel({
upvoteUids: function(next) {
db.getSetMembers('pid:' + pid + ':upvote', next);
},
downvoteUids: function(next) {
db.getSetMembers('pid:' + pid + ':downvote', next);
}
}, function(err, results) {
if (err) {
return callback(err);
}
async.parallel({
upvoters: function(next) {
user.getMultipleUserFields(results.upvoteUids, ['username', 'userslug', 'picture'], next);
},
upvoteCount: function(next) {
next(null, results.upvoteUids.length);
},
downvoters: function(next) {
user.getMultipleUserFields(results.downvoteUids, ['username', 'userslug', 'picture'], next);
},
downvoteCount: function(next) {
next(null, results.downvoteUids.length);
}
}, callback);
});
};
module.exports = SocketAdmin;

Loading…
Cancel
Save