Hide group actions until there's at least 2 other peers

They do not make sens when you're two or less in the room
master
Daniel Berteaud 11 years ago
parent 767e59a9f3
commit b228147906
  1. 3
      public/css/vroom.css
  2. 27
      public/js/vroom.js
  3. 2
      templates/default/join.html.ep

@ -99,6 +99,9 @@
.unauthEl{ .unauthEl{
display: none; display: none;
} }
.threePeersEl{
display: none;
}
.ownerActions { .ownerActions {
position: absolute; position: absolute;
left: 15px; left: 15px;

@ -269,6 +269,18 @@ function initVroom(room) {
$('#noWebrtcSupport').modal('show'); $('#noWebrtcSupport').modal('show');
} }
// Return the number of peers in the room
function countPeers(){
var count = Object.keys(peers).length;
// Do not count ourself
count--;
// and do not count our local screen
if (peers.local.screenShared){
count--;
}
return count;
}
// Get our role and other room settings from the server // Get our role and other room settings from the server
function getRoomInfo(){ function getRoomInfo(){
$.ajax({ $.ajax({
@ -291,7 +303,10 @@ function initVroom(room) {
// Enable owner reserved menu // Enable owner reserved menu
if (data.role == 'owner'){ if (data.role == 'owner'){
$('.unauthEl').hide(500); $('.unauthEl').hide(500);
$('.ownerEl').show(500); $('.ownerEl').not('.threePeersEl').show(500);
if (countPeers() > 1){
('.threePeersEl').show(500);
}
var notif = JSON.parse(data.notif); var notif = JSON.parse(data.notif);
$.each(notif.email, function(index, val){ $.each(notif.email, function(index, val){
addNotifiedEmail(val); addNotifiedEmail(val);
@ -517,6 +532,14 @@ function initVroom(room) {
// Stop moh, we're not alone anymore // Stop moh, we're not alone anymore
$('#mohPlayer')[0].pause(); $('#mohPlayer')[0].pause();
$('.aloneEl').hide(300); $('.aloneEl').hide(300);
if (countPeers() > 1){
if (peers.local.role == 'owner'){
$('.threePeersEl').show(500);
}
else{
$('.threePeersEl').not('.ownerEl').show(500);
}
}
} }
$(div).attr('id', 'peer_' + id); $(div).attr('id', 'peer_' + id);
// Disable context menu on the video // Disable context menu on the video
@ -686,7 +709,7 @@ function initVroom(room) {
// Check if MoH is needed // Check if MoH is needed
function checkMoh(){ function checkMoh(){
setTimeout(function(){ setTimeout(function(){
if (Object.keys(peers).length < 2){ if (countPeers() < 1){
if ($('#pauseMohButton').is(':checked')){ if ($('#pauseMohButton').is(':checked')){
$('#mohPlayer').get(0).volume = .25; $('#mohPlayer').get(0).volume = .25;
$('#mohPlayer').get(0).play(); $('#mohPlayer').get(0).play();

@ -96,7 +96,7 @@
</li> </li>
</ul> </ul>
</div> </div>
<div class="btn-group dropdown ownerEl"> <div class="btn-group dropdown ownerEl threePeersEl">
<button class="btn btn-default dropdown-toggle help" type="button" id="groupActionsButton" data-toggle="dropdown" data-toggle="tooltip" data-placement="bottom" title="<%=l 'GROUP_ACTIONS' %>"> <button class="btn btn-default dropdown-toggle help" type="button" id="groupActionsButton" data-toggle="dropdown" data-toggle="tooltip" data-placement="bottom" title="<%=l 'GROUP_ACTIONS' %>">
<span class="glyphicon glyphicon-flag"></span> <span class="glyphicon glyphicon-flag"></span>
<span class="caret"></span> <span class="caret"></span>

Loading…
Cancel
Save