Node.js based forum software built for the modern web
voters info
barisusakli9d56f509674b
diff --git a/public/src/client/topic/postTools.js b/public/src/client/topic/postTools.jsindex 792806d3b9..e00f30a7c4 100644--- a/public/src/client/topic/postTools.js+++ b/public/src/client/topic/postTools.js@@ -94,6 +94,10 @@ define('forum/topic/postTools', ['composer', 'share', 'navigator'], function(comreturn 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(comreturn 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);}diff --git a/src/socket.io/admin.js b/src/socket.io/admin.jsindex f4bec7ef43..d759e9cbb8 100644--- a/src/socket.io/admin.js+++ b/src/socket.io/admin.js@@ -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;