Handle configuration changes in the new admin page

master
Daniel Berteaud 10 years ago
parent 8fa6fad617
commit 22b1d69802
  1. 123
      public/js/vroom.js
  2. 1
      templates/default/js_common.html.ep

@ -229,6 +229,65 @@ $('#ownerPassSet').on('switchChange.bootstrapSwitch', function(event, state) {
}); });
// Submit the configuration form
$('#configureRoomForm').submit(function(e){
e.preventDefault();
// check if passwords match
if ($('#joinPassSet').bootstrapSwitch('state')){
if ($('#joinPass').val() !== $('#joinPassConfirm').val()){
$('#joinPassConfirm').notify(locale.PASSWORDS_DO_NOT_MATCH, 'error');
return false;
}
}
if ($('#ownerPassSet').bootstrapSwitch('state')){
if ($('#ownerPass').val() !== $('#ownerPassConfirm').val()){
$('#ownerPassConfirm').notify(locale.PASSWORDS_DO_NOT_MATCH, 'error');
return false;
}
}
var locked = $('#lockedSet').bootstrapSwitch('state'),
askForName = $('#askForNameSet').bootstrapSwitch('state'),
joinPass = ($('#joinPassSet').bootstrapSwitch('state')) ?
$('#joinPass').val() : false,
ownerPass = ($('#ownerPassSet').bootstrapSwitch('state')) ?
$('#ownerPass').val() : false,
emails = [];
$('input[name="emails[]"]').each(function(){
emails.push($(this).val());
});
$.ajax({
data: {
req: JSON.stringify({
action: 'update_room_conf',
param: {
room: roomName,
locked: locked,
ask_for_name: askForName,
join_password: joinPass,
owner_password: ownerPass,
emails: emails
}
})
},
error: function() {
$.notify(locale.ERROR_OCCURRED, 'error');
},
success: function(data) {
$('#ownerPass,#ownerPassConfirm,#joinPass,#joinPassConfirm').val('');
if (data.status == 'success'){
$('#configureModal').modal('hide');
// Hide passwords inputs too
$('#joinPassFields,#ownerPassFields').hide();
$.notify(data.msg, 'info');
$('#configureRoomForm').trigger('room_conf_updated');
}
else{
$.notify(data.msg, 'error');
}
}
});
});
// Used on the index page // Used on the index page
function initIndex(){ function initIndex(){
@ -398,7 +457,8 @@ function initAdmin(){
} }
$(document).on('click', '.btn-configure', function(){ $(document).on('click', '.btn-configure', function(){
getRoomConf($(this).data('room')); roomName = $(this).data('room');
getRoomConf(roomName);
}); });
// Get room list right after loading the page // Get room list right after loading the page
@ -1654,63 +1714,10 @@ function initVroom(room) {
}); });
}); });
// Submit the configuration form // The configuration formed has been submited successfuly
$('#configureRoomForm').submit(function(e){ // Lets announce it to the other peers
e.preventDefault(); $('#configureRoomForm').on('room_conf_updated', function(){
// check if passwords match webrtc.sendToAll('room_conf_updated');
if ($('#joinPassSet').bootstrapSwitch('state')){
if ($('#joinPass').val() !== $('#joinPassConfirm').val()){
$('#joinPassConfirm').notify(locale.PASSWORDS_DO_NOT_MATCH, 'error');
return false;
}
}
if ($('#ownerPassSet').bootstrapSwitch('state')){
if ($('#ownerPass').val() !== $('#ownerPassConfirm').val()){
$('#ownerPassConfirm').notify(locale.PASSWORDS_DO_NOT_MATCH, 'error');
return false;
}
}
var locked = $('#lockedSet').bootstrapSwitch('state'),
askForName = $('#askForNameSet').bootstrapSwitch('state'),
joinPass = ($('#joinPassSet').bootstrapSwitch('state')) ?
$('#joinPass').val() : false,
ownerPass = ($('#ownerPassSet').bootstrapSwitch('state')) ?
$('#ownerPass').val() : false,
emails = [];
$('input[name="emails[]"]').each(function(){
emails.push($(this).val());
});
$.ajax({
data: {
req: JSON.stringify({
action: 'update_room_conf',
param: {
room: roomName,
locked: locked,
ask_for_name: askForName,
join_password: joinPass,
owner_password: ownerPass,
emails: emails
}
})
},
error: function() {
$.notify(locale.ERROR_OCCURRED, 'error');
},
success: function(data) {
$('#ownerPass,#ownerPassConfirm,#joinPass,#joinPassConfirm').val('');
if (data.status == 'success'){
$('#configureModal').modal('hide');
// Hide passwords inputs too
$('#joinPassFields,#ownerPassFields').hide();
$.notify(data.msg, 'info');
webrtc.sendToAll('room_conf_updated');
}
else{
$.notify(data.msg, 'error');
}
}
});
}); });
// Choose another color. Useful if two peers have the same // Choose another color. Useful if two peers have the same

@ -2,6 +2,7 @@
var rootUrl = '<%= $self->get_url('/'); %>'; var rootUrl = '<%= $self->get_url('/'); %>';
var currentLang = '<%= $self->languages %>'; var currentLang = '<%= $self->languages %>';
var api_key = '<%= ($self->session('key')) ? $self->session('key') : '' %>'; var api_key = '<%= ($self->session('key')) ? $self->session('key') : '' %>';
var roomName;
</script> </script>
<% foreach my $js (qw(jquery-1.11.1.min.js bootstrap.min.js notify-combined.min.js bootstrap-switch.min.js vroom.js)){ <% foreach my $js (qw(jquery-1.11.1.min.js bootstrap.min.js notify-combined.min.js bootstrap-switch.min.js vroom.js)){
%> %>

Loading…
Cancel
Save