summary refs log tree commit diff
path: root/webclient/room/room-controller.js
diff options
context:
space:
mode:
authorEmmanuel ROHEE <erohee@amdocs.com>2014-09-03 18:55:27 +0200
committerEmmanuel ROHEE <erohee@amdocs.com>2014-09-03 18:55:48 +0200
commit1a32b1f002bcc436070bacd931e6abbd40a793d1 (patch)
tree5f9746c0044fc3a3af95a4937df3e1d5067916f5 /webclient/room/room-controller.js
parentAdded more terms. (diff)
downloadsynapse-1a32b1f002bcc436070bacd931e6abbd40a793d1.tar.xz
Normalise users power levels so that the user with the higher power level will have a bar covering 100% of the width of his avatar
Diffstat (limited to 'webclient/room/room-controller.js')
-rw-r--r--webclient/room/room-controller.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/webclient/room/room-controller.js b/webclient/room/room-controller.js
index 0ffbe8761f..52c57856ee 100644
--- a/webclient/room/room-controller.js
+++ b/webclient/room/room-controller.js
@@ -253,6 +253,29 @@ angular.module('RoomController', ['ngSanitize', 'mFileInput'])
         var member = $scope.members[user_id];
         if (member) {
             member.powerLevel = matrixService.getUserPowerLevel($scope.room_id, user_id);
+            
+            normaliseMembersPowerLevels();
+        }
+    }
+
+    // Normalise users power levels so that the user with the higher power level
+    // will have a bar covering 100% of the width of his avatar
+    var normaliseMembersPowerLevels = function() {
+        // Find the max power level
+        var maxPowerLevel = 0;
+        for (var i in $scope.members) {
+            var member = $scope.members[i];
+            if (member.powerLevel) {
+                maxPowerLevel = Math.max(maxPowerLevel, member.powerLevel);
+            }
+        }
+
+        // Normalized them on a 0..100% scale to be use in css width
+        if (maxPowerLevel) {
+            for (var i in $scope.members) {
+                var member = $scope.members[i];
+                member.powerLevelNorm = (member.powerLevel * 100) / maxPowerLevel;
+            }
         }
     }