Fix lock button status sync

When there're several owners
master
Daniel Berteaud 11 years ago
parent d43ec95052
commit d05925722b
  1. 10
      public/js/vroom.js
  2. 1
      public/vroom.pl
  3. 4
      templates/default/join.html.ep

@ -136,6 +136,10 @@ function initVroom(room) {
$('.unauthEl').show(500); $('.unauthEl').show(500);
} }
} }
if (data.locked == 'yes'){
$('#lockLabel').addClass('btn-danger active');
$('#lockButton').prop('checked', true);
}
} }
}); });
} }
@ -456,10 +460,12 @@ function initVroom(room) {
// A few notif on password set/unset or lock/unlock // A few notif on password set/unset or lock/unlock
webrtc.on('room_locked', function(data){ webrtc.on('room_locked', function(data){
$('#lockLabel').addClass('btn-danger active'); $('#lockLabel').addClass('btn-danger active');
$('#lockButton').prop('checked', true);
$.notify(sprintf(locale.ROOM_LOCKED_BY_s, stringEscape(peers[data.id].displayName)), 'info'); $.notify(sprintf(locale.ROOM_LOCKED_BY_s, stringEscape(peers[data.id].displayName)), 'info');
}); });
webrtc.on('room_unlocked', function(data){ webrtc.on('room_unlocked', function(data){
$('#lockLabel').removeClass('btn-danger active'); $('#lockLabel').removeClass('btn-danger active');
$('#lockButton').prop('checked', false);
$.notify(sprintf(locale.ROOM_UNLOCKED_BY_s, stringEscape(peers[data.id].displayName)), 'info'); $.notify(sprintf(locale.ROOM_UNLOCKED_BY_s, stringEscape(peers[data.id].displayName)), 'info');
}); });
webrtc.on('password_protect_on', function(data){ webrtc.on('password_protect_on', function(data){
@ -591,11 +597,11 @@ function initVroom(room) {
if (data.status == 'success'){ if (data.status == 'success'){
$.notify(data.msg, 'info'); $.notify(data.msg, 'info');
if (action === 'lock'){ if (action === 'lock'){
$("#lockLabel").addClass('btn-danger'); $("#lockLabel").addClass('btn-danger active');
webrtc.sendToAll('room_locked', {}); webrtc.sendToAll('room_locked', {});
} }
else{ else{
$("#lockLabel").removeClass('btn-danger'); $("#lockLabel").removeClass('btn-danger active');
webrtc.sendToAll('room_unlocked', {}); webrtc.sendToAll('room_unlocked', {});
} }
} }

@ -516,7 +516,6 @@ get '/(*room)' => sub {
} }
# Now display the room page # Now display the room page
$self->render('join', $self->render('join',
locked => $data->{locked} ? 'checked':'',
turnPassword => $data->{token} turnPassword => $data->{token}
); );
}; };

@ -97,8 +97,8 @@
<center> <center>
<div class="navbar-form"> <div class="navbar-form">
<div class="btn-group" data-toggle="buttons"> <div class="btn-group" data-toggle="buttons">
<label class="btn btn-default<%= $locked eq 'checked' ? ' btn-danger':'' %> help" id="lockLabel" data-toggle="tooltip" data-placement="bottom" title="<%=l 'PREVENT_TO_JOIN' %>"> <label class="btn btn-default help" id="lockLabel" data-toggle="tooltip" data-placement="bottom" title="<%=l 'PREVENT_TO_JOIN' %>">
<input type="checkbox" id="lockButton" <%= $locked %>> <input type="checkbox" id="lockButton">
<span class="glyphicon glyphicon-lock"> <span class="glyphicon glyphicon-lock">
</span> </span>
</label> </label>

Loading…
Cancel
Save