Move getRole to a function

Will probably be used elsewhere soon
master
Daniel Berteaud 11 years ago
parent 89b7e7ff0f
commit 0226271045
  1. 44
      public/js/vroom.js

@ -91,24 +91,6 @@ function initVroom(room) {
dataType: 'json', dataType: 'json',
}); });
// get our role (participant or owner)
$.ajax({
data: {
action: 'getRole',
room: roomName
},
error: function(data) {
$.notify(locale.ERROR_OCCURED, 'error');
},
success: function(data) {
peers.local.role = data.msg;
// Enable owner reserved menu
if (data.msg == 'owner'){
$('.ownerEl').show(500);
}
}
});
// Screen sharing is only suported on chrome > 26 // Screen sharing is only suported on chrome > 26
if ( !$.browser.webkit || $.browser.versionNumber < 26 ) { if ( !$.browser.webkit || $.browser.versionNumber < 26 ) {
$("#shareScreenLabel").addClass('disabled'); $("#shareScreenLabel").addClass('disabled');
@ -127,6 +109,29 @@ function initVroom(room) {
return string; return string;
} }
// Update our role
function updateRole() {
$.ajax({
data: {
action: 'getRole',
room: roomName
},
error: function(data) {
$.notify(locale.ERROR_OCCURED, 'error');
},
success: function(data) {
peers.local.role = data.msg;
// Enable owner reserved menu
if (data.msg == 'owner'){
$('.ownerEl').show(500);
}
else{
$('.ownerEl').hide(500);
}
}
});
}
// Select a color (randomly) from this list, used for text chat // Select a color (randomly) from this list, used for text chat
function chooseColor(){ function chooseColor(){
// Shamelessly taken from http://martin.ankerl.com/2009/12/09/how-to-create-random-colors-programmatically/ // Shamelessly taken from http://martin.ankerl.com/2009/12/09/how-to-create-random-colors-programmatically/
@ -759,6 +764,9 @@ function initVroom(room) {
} }
}); });
// Check if we are the owner of the room
updateRole();
// Ping the room every minutes // Ping the room every minutes
// Used to detect inactive rooms // Used to detect inactive rooms
setInterval(function pingRoom(){ setInterval(function pingRoom(){

Loading…
Cancel
Save