mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-15 05:03:51 +01:00
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
This commit is contained in:
parent
79bf9d25db
commit
1a32b1f002
2 changed files with 24 additions and 1 deletions
|
@ -253,6 +253,29 @@ angular.module('RoomController', ['ngSanitize', 'mFileInput'])
|
||||||
var member = $scope.members[user_id];
|
var member = $scope.members[user_id];
|
||||||
if (member) {
|
if (member) {
|
||||||
member.powerLevel = matrixService.getUserPowerLevel($scope.room_id, user_id);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
title="{{ member.id }}"
|
title="{{ member.id }}"
|
||||||
width="80" height="80"/>
|
width="80" height="80"/>
|
||||||
<img class="userAvatarGradient" src="img/gradient.png" title="{{ member.id }}" width="80" height="24"/>
|
<img class="userAvatarGradient" src="img/gradient.png" title="{{ member.id }}" width="80" height="24"/>
|
||||||
<div class="userPowerLevel" ng-style="{'width': (10 * member.powerLevel) +'%'}"></div>
|
<div class="userPowerLevel" ng-style="{'width': member.powerLevelNorm +'%'}"></div>
|
||||||
<div class="userName">{{ member.displayname || member.id.substr(0, member.id.indexOf(':')) }}<br/>{{ member.displayname ? "" : member.id.substr(member.id.indexOf(':')) }}</div>
|
<div class="userName">{{ member.displayname || member.id.substr(0, member.id.indexOf(':')) }}<br/>{{ member.displayname ? "" : member.id.substr(member.id.indexOf(':')) }}</div>
|
||||||
</td>
|
</td>
|
||||||
<td class="userPresence" ng-class="(member.presence === 'online' ? 'online' : (member.presence === 'unavailable' ? 'unavailable' : '')) + ' ' + (member.membership == 'invite' ? 'invited' : '')">
|
<td class="userPresence" ng-class="(member.presence === 'online' ? 'online' : (member.presence === 'unavailable' ? 'unavailable' : '')) + ' ' + (member.membership == 'invite' ? 'invited' : '')">
|
||||||
|
|
Loading…
Reference in a new issue