Move getRole to a function

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

@ -91,7 +91,26 @@ function initVroom(room) {
dataType: 'json', dataType: 'json',
}); });
// get our role (participant or owner) // Screen sharing is only suported on chrome > 26
if ( !$.browser.webkit || $.browser.versionNumber < 26 ) {
$("#shareScreenLabel").addClass('disabled');
}
// If browser doesn't support webRTC or dataChannels
if (!webrtc.capabilities.support || !webrtc.capabilities.dataChannel){
$('#noWebrtcSupport').modal('show');
}
// Escape entities
function stringEscape(string){
string = string.replace(/[\u00A0-\u99999<>\&]/gim, function(i) {
return '&#' + i.charCodeAt(0) + ';';
});
return string;
}
// Update our role
function updateRole() {
$.ajax({ $.ajax({
data: { data: {
action: 'getRole', action: 'getRole',
@ -106,25 +125,11 @@ function initVroom(room) {
if (data.msg == 'owner'){ if (data.msg == 'owner'){
$('.ownerEl').show(500); $('.ownerEl').show(500);
} }
else{
$('.ownerEl').hide(500);
} }
});
// Screen sharing is only suported on chrome > 26
if ( !$.browser.webkit || $.browser.versionNumber < 26 ) {
$("#shareScreenLabel").addClass('disabled');
}
// If browser doesn't support webRTC or dataChannels
if (!webrtc.capabilities.support || !webrtc.capabilities.dataChannel){
$('#noWebrtcSupport').modal('show');
} }
// Escape entities
function stringEscape(string){
string = string.replace(/[\u00A0-\u99999<>\&]/gim, function(i) {
return '&#' + i.charCodeAt(0) + ';';
}); });
return string;
} }
// Select a color (randomly) from this list, used for text chat // Select a color (randomly) from this list, used for text chat
@ -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