@ -27,6 +27,8 @@ var locale = {
ONE _OF _THE _PEERS : '' ,
PASSWORD _PROTECT _ON _BY _s : '' ,
PASSWORD _PROTECT _OFF _BY _s : '' ,
OWNER _PASSWORD _CHANGED _BY _s : '' ,
OWNER _PASSWORD _REMOVED _BY _s : '' ,
CANT _SEND _TO _s : '' ,
SCREEN _s : '' ,
TO _INVITE _SHARE _THIS _URL : ''
@ -442,13 +444,23 @@ function initVroom(room) {
$ ( el ) . remove ( ) ;
} ) ;
// A few notif on password set/unset
webrtc . on ( 'password_protect_on' , function ( data ) {
$ . notify ( sprintf ( locale . PASSWORD _PROTECT _ON _BY _s , stringEscape ( peers [ data . id ] . displayName ) ) , 'info' ) ;
} ) ;
webrtc . on ( 'password_protect_off' , function ( data ) {
$ . notify ( sprintf ( locale . PASSWORD _PROTECT _OFF _BY _s , stringEscape ( peers [ data . id ] . displayName ) ) , 'info' ) ;
} ) ;
webrtc . on ( 'owner_password_changed' , function ( data ) {
if ( peers . local . role == 'owner' ) {
$ . notify ( sprintf ( locale . OWNER _PASSWORD _CHANGED _BY _s , stringEscape ( peers [ data . id ] . displayName ) ) , 'warn' ) ;
}
} ) ;
webrtc . on ( 'owner_password_removed' , function ( data ) {
if ( peers . local . role == 'owner' ) {
$ . notify ( sprintf ( locale . OWNER _PASSWORD _REMOVED _BY _s , stringEscape ( peers [ data . id ] . displayName ) ) , 'warn' ) ;
}
} ) ;
// Handle the readyToCall event: join the room
webrtc . once ( 'readyToCall' , function ( ) {
@ -628,8 +640,9 @@ function initVroom(room) {
$ ( '#setJoinPassButton' ) . addClass ( 'disabled' ) ;
$ . ajax ( {
data : {
action : 'setJoin Password' ,
action : 'setPassword' ,
password : pass ,
type : 'join' ,
room : roomName
} ,
error : function ( ) {
@ -653,7 +666,8 @@ function initVroom(room) {
$ ( '#removeJoinPassButton' ) . click ( function ( event ) {
$ . ajax ( {
data : {
action : 'setJoinPassword' ,
action : 'setPassword' ,
type : 'join' ,
room : roomName
} ,
error : function ( ) {
@ -673,6 +687,70 @@ function initVroom(room) {
} ) ;
} ) ;
$ ( '#ownerPass' ) . on ( 'input' , function ( ) {
if ( $ ( '#ownerPass' ) . val ( ) == '' ) {
$ ( '#setOwnerPassButton' ) . addClass ( 'disabled' ) ;
}
else {
$ ( '#setOwnerPassButton' ) . removeClass ( 'disabled' ) ;
}
} ) ;
// Set owner password
$ ( '#setOwnerPassButton' ) . click ( function ( event ) {
var pass = $ ( '#ownerPass' ) . val ( ) ;
$ ( '#ownerPass' ) . val ( '' ) ;
$ ( '#setOwnerPassButton' ) . addClass ( 'disabled' ) ;
$ . ajax ( {
data : {
action : 'setPassword' ,
password : pass ,
type : 'owner' ,
room : roomName
} ,
error : function ( ) {
var msg = locale . ERROR _OCCURED ;
$ . notify ( msg , 'error' ) ;
} ,
success : function ( data ) {
$ ( '#ownerPass' ) . val ( '' ) ;
if ( data . status == 'success' ) {
$ . notify ( data . msg , 'success' ) ;
webrtc . sendToAll ( 'owner_password_changed' , { } ) ;
}
else {
$ . notify ( data . msg , 'error' ) ;
}
}
} ) ;
} ) ;
// Remove the owner password
$ ( '#removeOwnerPassButton' ) . click ( function ( event ) {
$ . ajax ( {
data : {
action : 'setPassword' ,
type : 'owner' ,
room : roomName
} ,
error : function ( ) {
var msg = locale . ERROR _OCCURED ;
$ . notify ( msg , 'error' ) ;
} ,
success : function ( data ) {
$ ( '#ownerPass' ) . val ( '' ) ;
if ( data . status == 'success' ) {
$ . notify ( data . msg , 'success' ) ;
webrtc . sendToAll ( 'owner_password_removed' , { } ) ;
}
else {
$ . notify ( data . msg , 'error' ) ;
}
}
} ) ;
} ) ;
// Choose another color. Useful if two peers have the same
$ ( '#changeColorButton' ) . click ( function ( ) {
peers . local . color = chooseColor ( ) ;