diff --git a/public/js/vroom.js b/public/js/vroom.js index 6fac860..f7b2958 100644 --- a/public/js/vroom.js +++ b/public/js/vroom.js @@ -580,20 +580,24 @@ function initVroom(room) { room: roomName }, error: function(data) { - var msg = (data && data.msg) ? data.msg : locale.ERROR_OCCURED; - $.notify(msg, 'error'); + $.notify(locale.ERROR_OCCURED, 'error'); }, success: function(data) { - $.notify(data.msg, 'info'); - if (action === 'lock'){ - $("#lockLabel").addClass('btn-danger'); - webrtc.sendToAll('room_locked', {}); + if (data.status == 'success'){ + $.notify(data.msg, 'info'); + if (action === 'lock'){ + $("#lockLabel").addClass('btn-danger'); + webrtc.sendToAll('room_locked', {}); + } + else{ + $("#lockLabel").removeClass('btn-danger'); + webrtc.sendToAll('room_unlocked', {}); + } } else{ - $("#lockLabel").removeClass('btn-danger'); - webrtc.sendToAll('room_unlocked', {}); + $.notify(data.msg, 'error'); } - } + } }); }); diff --git a/public/vroom.pl b/public/vroom.pl index 5e8c2f8..448f160 100755 --- a/public/vroom.pl +++ b/public/vroom.pl @@ -517,14 +517,15 @@ post '/action' => sub { unless ($res){ return $self->render( json => { - msg => $self->l('ERROR_OCCURED'), + msg => $self->l('ERROR_OCCURED'), + status => 'error' }, - status => '500' ); } return $self->render( json => { - msg => $success, + msg => $success, + status => 'success' } ); }