From 2ebf44a3b7d52c398681d7d94aa7e83dde120a8c Mon Sep 17 00:00:00 2001 From: Oleksandr Zhurbenko Date: Mon, 3 Aug 2015 17:23:57 -0700 Subject: [PATCH] Added Sorting to the userlist --- bigbluebutton-html5/app/client/globals.coffee | 66 ++++++++++++++++--- 1 file changed, 57 insertions(+), 9 deletions(-) diff --git a/bigbluebutton-html5/app/client/globals.coffee b/bigbluebutton-html5/app/client/globals.coffee index aeed4bca00..d602811c72 100755 --- a/bigbluebutton-html5/app/client/globals.coffee +++ b/bigbluebutton-html5/app/client/globals.coffee @@ -70,15 +70,11 @@ Handlebars.registerHelper "getShapesForSlide", -> # retrieves all users in the meeting Handlebars.registerHelper "getUsersInMeeting", -> - # retrieve all users with raised hands - # raised hand is an object, so we can't simply search for true - # sort users by who has raised their hand first, place them at the top - raised = Meteor.Users.find({'user.raise_hand': {$not: {$in: [0, false, null]} }}, {sort: {'user.raise_hand': 1} }).fetch() - # find all users with a lowered hand - # when a hand is lowered, it is not always just false, it can be zero, or null - lowered = Meteor.Users.find({'user.raise_hand': $in: [0, false, null]}, {sort: {'user._sort_name': 1} }).fetch() - # add the users with lowered hands, to the list of people with raised hands - raised.concat lowered + users = Meteor.Users.find().fetch() + if users?.length > 1 + getSortedUserList(users) + else + users Handlebars.registerHelper "getWhiteboardTitle", -> (BBB.currentPresentationName() or "Loading presentation...") @@ -184,6 +180,58 @@ Handlebars.registerHelper "getPollQuestions", -> if polls? and polls isnt undefined return polls.poll_info.poll.answers +@getSortedUserList = (users) -> + if users?.length > 1 + users.sort (a, b) -> + if a.user.role is "MODERATOR" and b.user.role is "MODERATOR" + if a.user.raise_hand and b.user.raise_hand + aTime = a.user.raise_hand.getTime() + bTime = b.user.raise_hand.getTime() + if aTime < bTime + return -1 + else + return 1 + else if a.user.raise_hand + return -1 + else if b.user.raise_hand + return 1 + else if a.user.role is "MODERATOR" + return -1 + else if b.user.role is "MODERATOR" + return 1 + else if a.user.raise_hand and b.user.raise_hand + aTime = a.user.raise_hand.getTime() + bTime = b.user.raise_hand.getTime() + if aTime < bTime + return -1 + else + return 1 + else if a.user.raise_hand + return -1 + else if b.user.raise_hand + return 1 + else if a.user.phone_user and b.user.phone_user + + else if a.user.phone_user + return -1 + else if b.user.phone_user + return 1 + + #Check name (case-insensitive) in the event of a tie up above. If the name + #is the same then use userID which should be unique making the order the same + #across all clients. + + if a.user._sort_name < b.user._sort_name + return -1 + else if a.user._sort_name > b.user._sort_name + return 1 + else if a.user.userid.toLowerCase() > b.user.userid.toLowerCase() + return -1 + else if a.user.userid.toLowerCase() < b.user.userid.toLowerCase() + return 1 + + users + # transform plain text links into HTML tags compatible with Flash client @linkify = (str) -> str = str.replace re_weburl, "$&"