Fix minority calculation

JS objects are copied by reference in a var assignation, and / is a float operation.
This commit is contained in:
Diana Corbacho 2018-06-25 11:49:52 +01:00 committed by kjnilsson
parent cba53b4d95
commit 8cd188b67d
1 changed files with 3 additions and 7 deletions

View File

@ -192,14 +192,10 @@ function fmt_sync_state(queue) {
function fmt_members(queue) {
var res = '';
var offline = queue.members || [];
offline = jQuery.grep(offline,
function (node, i) {
return jQuery.inArray(node, queue.online) == -1;
});
var followers = queue.online;
var IsMayority = (queue.online.length >= (Math.floor(queue.members.length / 2) + 1));
var followers = Object.assign({}, queue.online);
followers.splice(followers.indexOf(queue.node), 1);
if (queue.online.length >= ((queue.members.length / 2) + 1)) {
if (IsMayority) {
res += ' <abbr title="Followers: ' + followers + '">+' +
followers.length + '</abbr>';
} else {