JS code cleanups

master
Daniel Berteaud 9 years ago
parent a41a953a25
commit 477070baab
  1. 120
      public/js/vroom.js

@ -105,6 +105,7 @@ function localize(string){
return string; return string;
} }
// POST a JSON req on the backend API
function vroomApi(action, param, success, error){ function vroomApi(action, param, success, error){
if (typeof error !== 'function'){ if (typeof error !== 'function'){
error = function(data){ error = function(data){
@ -188,7 +189,7 @@ function fullScreen(el){
} }
} }
// Linkify urls // Linkify urls in a string
// Taken from http://rickyrosario.com/blog/converting-a-url-into-a-link-in-javascript-linkify-function/ // Taken from http://rickyrosario.com/blog/converting-a-url-into-a-link-in-javascript-linkify-function/
function linkify(text){ function linkify(text){
if (text) { if (text) {
@ -212,7 +213,7 @@ function downloadContent(filename, type, content){
saveAs(blob, filename); saveAs(blob, filename);
} }
// Return current time formatted as XX:XX:XX // Return current time formatted as hh:mm:ss
function getTime(){ function getTime(){
var d = new Date(); var d = new Date();
var hours = d.getHours().toString(), var hours = d.getHours().toString(),
@ -233,7 +234,8 @@ function utc2Local(date) {
return newDate; return newDate;
} }
// Temporarily suspend a button, prevent abuse // Temporarily suspend a button, prevent overloading the backend
// if someone start clicking quickly
function suspendButton(el){ function suspendButton(el){
$(el).attr('disabled', true); $(el).attr('disabled', true);
setTimeout(function(){ setTimeout(function(){
@ -313,6 +315,7 @@ $('#joinPassConfirm').on('input', function() {
}); });
// Hide or show password fields // Hide or show password fields
// Depending on their corresponding switch
$('#joinPassSet').on('switchChange.bootstrapSwitch', function(event, state) { $('#joinPassSet').on('switchChange.bootstrapSwitch', function(event, state) {
if (state){ if (state){
$('#joinPassFields').show(200); $('#joinPassFields').show(200);
@ -334,17 +337,21 @@ $('#ownerPassSet').on('switchChange.bootstrapSwitch', function(event, state) {
// Submit the configuration form // Submit the configuration form
$('#configureRoomForm').submit(function(e){ $('#configureRoomForm').submit(function(e){
e.preventDefault(); e.preventDefault();
// check if passwords match // check join password
if ($('#joinPassSet').bootstrapSwitch('state')){ if ($('#joinPassSet').bootstrapSwitch('state')){
// Both must match
if ($('#joinPass').val() !== $('#joinPassConfirm').val()){ if ($('#joinPass').val() !== $('#joinPassConfirm').val()){
$('#joinPassConfirm').notify(localize('PASSWORDS_DO_NOT_MATCH'), 'error'); $('#joinPassConfirm').notify(localize('PASSWORDS_DO_NOT_MATCH'), 'error');
return false; return false;
} }
// Empty password are not valid. We can't use the switch state, cause when editing a room
// with a password already set, those field are empty
if ($('#joinPassFields').css('display') !== 'none' && $('#joinPass').val() === ''){ if ($('#joinPassFields').css('display') !== 'none' && $('#joinPass').val() === ''){
$('#joinPass').notify(localize('PASSWORDS_CANNOT_BE_EMPTY'), 'error'); $('#joinPass').notify(localize('PASSWORDS_CANNOT_BE_EMPTY'), 'error');
return false; return false;
} }
} }
// Same for the owner password
if ($('#ownerPassSet').bootstrapSwitch('state')){ if ($('#ownerPassSet').bootstrapSwitch('state')){
if ($('#ownerPass').val() !== $('#ownerPassConfirm').val()){ if ($('#ownerPass').val() !== $('#ownerPassConfirm').val()){
$('#ownerPassConfirm').notify(localize('PASSWORDS_DO_NOT_MATCH'), 'error'); $('#ownerPassConfirm').notify(localize('PASSWORDS_DO_NOT_MATCH'), 'error');
@ -359,6 +366,7 @@ $('#configureRoomForm').submit(function(e){
$('.email-list').find('input').each(function(index, input){ $('.email-list').find('input').each(function(index, input){
if (!$(input).val().match(/\S+@\S+\.\S+/) && $(input).val() !== ''){ if (!$(input).val().match(/\S+@\S+\.\S+/) && $(input).val() !== ''){
$(input).parent().addClass('has-error'); $(input).parent().addClass('has-error');
// TODO: find how to display correctly the error
//$(input).parent().notify(localize('ERROR_MAIL_INVALID'), 'error'); //$(input).parent().notify(localize('ERROR_MAIL_INVALID'), 'error');
validEmail = false; validEmail = false;
// Break the each loop and return an error now, we can't submit as is // Break the each loop and return an error now, we can't submit as is
@ -383,7 +391,9 @@ $('#configureRoomForm').submit(function(e){
$('#maxMembers').val() : 0, $('#maxMembers').val() : 0,
emails = []; emails = [];
$('input[name="emails[]"]').each(function(){ $('input[name="emails[]"]').each(function(){
if ($(this).val() !== ''){
emails.push($(this).val()); emails.push($(this).val());
}
}); });
vroomApi( vroomApi(
'update_room_conf', 'update_room_conf',
@ -438,7 +448,7 @@ function getRoomInfo(cb){
$('#askForNameSet').bootstrapSwitch('state', data.ask_for_name); $('#askForNameSet').bootstrapSwitch('state', data.ask_for_name);
$('#joinPassSet').bootstrapSwitch('state', data.join_auth); $('#joinPassSet').bootstrapSwitch('state', data.join_auth);
$('#ownerPassSet').bootstrapSwitch('state', data.owner_auth); $('#ownerPassSet').bootstrapSwitch('state', data.owner_auth);
// exec the callback if defined // exec a callback if needed
if (typeof cb === 'function'){ if (typeof cb === 'function'){
cb(); cb();
} }
@ -449,7 +459,7 @@ function getRoomInfo(cb){
// Used on the index page // Used on the index page
function initIndex(){ function initIndex(){
var room; var room;
// Submit the main form to create a room // Submit the home form to create a room
$('#createRoom').submit(function(e){ $('#createRoom').submit(function(e){
e.preventDefault(); e.preventDefault();
// Do not submit if we know the name is invalid // Do not submit if we know the name is invalid
@ -466,12 +476,13 @@ function initIndex(){
room: $('#roomName').val() room: $('#roomName').val()
}, },
function(data) { function(data) {
// On success, the room has been created, lets join it
room = data.room; room = data.room;
window.location.assign(rootUrl + data.room); window.location.assign(rootUrl + data.room);
}, },
function(data){ function(data){
data = data.responseJSON; data = data.responseJSON;
if (data.err && data.err == 'ERROR_NAME_CONFLICT' ){ if (data.err && data.err === 'ERROR_NAME_CONFLICT'){
room = data.room; room = data.room;
$('#conflictModal').modal('show'); $('#conflictModal').modal('show');
} }
@ -791,7 +802,7 @@ function initAdminAudit(){
); );
} }
// Intercept form submission // When we click on either refresh or export buttons, check dates are valid
$('#events_refresh,#events_export').click(function(e){ $('#events_refresh,#events_export').click(function(e){
e.preventDefault(); e.preventDefault();
var startObj = new Date($('#dateStart').val()); var startObj = new Date($('#dateStart').val());
@ -818,16 +829,19 @@ function initAdminAudit(){
return false; return false;
} }
else{ else{
// Now, either refresh the current view
if ($(this).attr('id') === 'events_refresh'){ if ($(this).attr('id') === 'events_refresh'){
reloadEvents($('#dateStart').val(),$('#dateEnd').val()); reloadEvents($('#dateStart').val(),$('#dateEnd').val());
return; return;
} }
// Or export in XLSX as requested
else if ($(this).attr('id') === 'events_export'){ else if ($(this).attr('id') === 'events_export'){
window.location.assign('export_events?from=' + $('#dateStart').val() + '&to=' + $('#dateEnd').val()); window.location.assign('export_events?from=' + $('#dateStart').val() + '&to=' + $('#dateEnd').val());
} }
} }
}); });
// Filter as you type, but with a small delay
$('#searchEvent').on('input', function(){ $('#searchEvent').on('input', function(){
$('#loadingIcon').show(); $('#loadingIcon').show();
var lastInput = +new Date; var lastInput = +new Date;
@ -842,8 +856,10 @@ function initAdminAudit(){
}, 600); }, 600);
}); });
// When loading the page, display events from the current day
reloadEvents($('#dateStart').val(),$('#dateEnd').val()); reloadEvents($('#dateStart').val(),$('#dateEnd').val());
} }
// Started when entering a room // Started when entering a room
function initJoin(room){ function initJoin(room){
// Auth input if access is protected // Auth input if access is protected
@ -856,12 +872,7 @@ function initJoin(room){
else{ else{
$('#authBeforeJoinButton').addClass('disabled'); $('#authBeforeJoinButton').addClass('disabled');
$('#authBeforeJoinPass').parent().addClass('has-error'); $('#authBeforeJoinPass').parent().addClass('has-error');
if (pass.length < 1){ $('#authBeforeJoinPass').notify(localize(pass.length < 1 ? 'PASSWORD_REQUIRED' : 'PASSWORD_TOO_LONG'), 'error');
$('#authBeforeJoinPass').notify(localize('PASSWORD_REQUIRED'), 'error');
}
else{
$('#authBeforeJoinPass').notify(localize('PASSWORD_TOO_LONG'), 'error');
}
} }
}); });
// Submit the join password form // Submit the join password form
@ -884,15 +895,11 @@ function initJoin(room){
else{ else{
$('#displayNamePreButton').addClass('disabled'); $('#displayNamePreButton').addClass('disabled');
$('#displayNamePre').parent().addClass('has-error'); $('#displayNamePre').parent().addClass('has-error');
if (name.length < 1){ $('#displayNamePre').notify(localize(name.length < 1 ? 'DISPLAY_NAME_REQUIRED' : 'DISPLAY_NAME_TOO_LONG'), 'error');
$('#displayNamePre').notify(localize('DISPLAY_NAME_REQUIRED'), 'error');
}
else{
$('#displayNamePre').notify(localize('DISPLAY_NAME_TOO_LONG'), 'error');
}
} }
}); });
// Intercept form submission
$('#displayNamePreForm').submit(function(event){ $('#displayNamePreForm').submit(function(event){
event.preventDefault(); event.preventDefault();
var name = $('#displayNamePre').val(); var name = $('#displayNamePre').val();
@ -917,7 +924,7 @@ function initJoin(room){
}, },
function(data){ function(data){
$('.connecting-err-reason').hide(); $('.connecting-err-reason').hide();
// Once auth is passed, we get the room configuration // Once auth is passed, we retrieve room configuration
vroomApi( vroomApi(
'get_room_conf', 'get_room_conf',
{ {
@ -965,7 +972,7 @@ function initJoin(room){
try_auth('', false); try_auth('', false);
} }
// This just create the webrtc object, and then continue // This just creates the webrtc object, and then continues
function init_webrtc(room){ function init_webrtc(room){
// First get SimpleWebRTC config from the server // First get SimpleWebRTC config from the server
vroomApi( vroomApi(
@ -1024,7 +1031,7 @@ function initVroom(room) {
return count; return count;
} }
// Get the role of a peer // Get the role of a peer, by Socket.IO peer ID
function getPeerRole(id){ function getPeerRole(id){
vroomApi( vroomApi(
'get_peer_role', 'get_peer_role',
@ -1042,7 +1049,7 @@ function initVroom(room) {
webrtc.sendToAll('role_change', {}); webrtc.sendToAll('role_change', {});
} }
peers.local.role = data.role; peers.local.role = data.role;
if (data.role == 'owner'){ if (data.role === 'owner'){
$('.unauthEl').hide(500); $('.unauthEl').hide(500);
$('.ownerEl').show(500); $('.ownerEl').show(500);
} }
@ -1055,7 +1062,7 @@ function initVroom(room) {
} }
else if (peers[id]){ else if (peers[id]){
peers[id].role = data.role; peers[id].role = data.role;
if (data.role == 'owner'){ if (data.role === 'owner'){
// If this peer is an owner, we add the mark on its preview // If this peer is an owner, we add the mark on its preview
$('#overlay_' + id).append($('<div>').attr('id', 'owner_' + id).addClass('owner hidden-xs')); $('#overlay_' + id).append($('<div>').attr('id', 'owner_' + id).addClass('owner hidden-xs'));
// And we disable owner's action for him // And we disable owner's action for him
@ -1192,12 +1199,12 @@ function initVroom(room) {
id: 'actionKick_' + id, id: 'actionKick_' + id,
click: function() { kickPeer(id) }, click: function() { kickPeer(id) },
}).prop('title', localize('KICK_PEER')))); }).prop('title', localize('KICK_PEER'))));
// Display the menu now if we're a owner, but add some delay // Display the menu now if we're an owner, but add some delay
// as those actions won't work until all the channels are ready // as those actions won't work until all the channels are ready
setTimeout (function(){ setTimeout (function(){
$(div).hover( $(div).hover(
function(){ function(){
if (peers.local.role == 'owner'){ if (peers.local.role === 'owner' || peers.local.role === 'admin'){
$('#ownerActions_' + id).show(200); $('#ownerActions_' + id).show(200);
} }
}, },
@ -1207,7 +1214,7 @@ function initVroom(room) {
); );
}, 3500); }, 3500);
// Choose a random color. If everything is OK // Choose a random color. If everything is OK
// this peer will send us its owne color in a few seconds // this peer will send us its own color in a few seconds
var color = chooseColor(); var color = chooseColor();
// Now store this new peer in our object // Now store this new peer in our object
peers[peer.id] = { peers[peer.id] = {
@ -1226,7 +1233,7 @@ function initVroom(room) {
setTimeout(function(){ setTimeout(function(){
// displayName is private data, lets send it through dataChannel // displayName is private data, lets send it through dataChannel
if ($('#displayName').val() !== ''){ if ($('#displayName').val() !== ''){
peer.sendDirectly('vroom','setDisplayName', $('#displayName').val()); peer.sendDirectly('vroom','set_display_name', $('#displayName').val());
} }
// color can be sent through the signaling channel // color can be sent through the signaling channel
peer.send('peer_color', {color: peers.local.color}); peer.send('peer_color', {color: peers.local.color});
@ -1234,7 +1241,7 @@ function initVroom(room) {
peer.send('media_info', {video: !!video}); peer.send('media_info', {video: !!video});
// We don't have chat history yet ? Lets ask to this new peer // We don't have chat history yet ? Lets ask to this new peer
if(!peers.local.hasHistory && chatIndex == 0){ if(!peers.local.hasHistory && chatIndex == 0){
peer.sendDirectly('vroom', 'getHistory', ''); peer.sendDirectly('vroom', 'chat_history_request', '');
} }
// Get the role of this peer // Get the role of this peer
getPeerRole(peer.id); getPeerRole(peer.id);
@ -1339,10 +1346,10 @@ function initVroom(room) {
// Mute a peer // Mute a peer
function mutePeer(id, globalAction){ function mutePeer(id, globalAction){
if (peers[id] && peers[id].role != 'owner'){ if (peers[id] && peers[id].role !== 'owner'){
if (!globalAction || if (!globalAction ||
(!peers[id].micMuted && globalAction == 'mute') || (!peers[id].micMuted && globalAction === 'mute') ||
(peers[id].micMuted && globalAction == 'unmute')){ (peers[id].micMuted && globalAction === 'unmute')){
var msg = localize('YOU_HAVE_MUTED_s'); var msg = localize('YOU_HAVE_MUTED_s');
var who = (peers[id].hasName) ? peers[id].displayName : localize('A_PARTICIPANT'); var who = (peers[id].hasName) ? peers[id].displayName : localize('A_PARTICIPANT');
if (peers[id].micMuted){ if (peers[id].micMuted){
@ -1361,10 +1368,10 @@ function initVroom(room) {
// Pause a peer's webcam // Pause a peer's webcam
function pausePeer(id, globalAction){ function pausePeer(id, globalAction){
if (peers[id] && peers[id].role != 'owner'){ if (peers[id] && peers[id].role !== 'owner'){
if (!globalAction || if (!globalAction ||
(!peers[id].videoPaused && globalAction == 'pause') || (!peers[id].videoPaused && globalAction === 'pause') ||
(peers[id].videoPaused && globalAction == 'resume')){ (peers[id].videoPaused && globalAction === 'resume')){
var msg = localize('YOU_HAVE_SUSPENDED_s'); var msg = localize('YOU_HAVE_SUSPENDED_s');
var who = (peers[id].hasName) ? peers[id].displayName : localize('A_PARTICIPANT'); var who = (peers[id].hasName) ? peers[id].displayName : localize('A_PARTICIPANT');
if (peers[id].videoPaused){ if (peers[id].videoPaused){
@ -1381,7 +1388,7 @@ function initVroom(room) {
// Promote a peer (he will be owner) // Promote a peer (he will be owner)
function promotePeer(id){ function promotePeer(id){
if (peers[id] && peers[id].role != 'owner'){ if (peers[id] && peers[id].role !== 'owner'){
vroomApi( vroomApi(
'promote_peer', 'promote_peer',
{ {
@ -1400,9 +1407,9 @@ function initVroom(room) {
} }
} }
// Kick a peer our of the room // Kick a peer out of the room
function kickPeer(id){ function kickPeer(id){
if (peers[id] && peers[id].role != 'owner'){ if (peers[id] && peers[id].role !== 'owner'){
webrtc.sendToAll('owner_kick', {peer: id}); webrtc.sendToAll('owner_kick', {peer: id});
// Wait a bit for the peer to leave, but end connection if it's still here // Wait a bit for the peer to leave, but end connection if it's still here
// after 2 seconds // after 2 seconds
@ -1464,7 +1471,7 @@ function initVroom(room) {
baseUrl: etherpad.path, baseUrl: etherpad.path,
padId: etherpad.group + '$' + room, padId: etherpad.group + '$' + room,
showControls: true, showControls: true,
showLineNumbers: false, showLineNumbers: true,
height: maxHeight()-7 + 'px', height: maxHeight()-7 + 'px',
border: 2, border: 2,
userColor: peers.local.color, userColor: peers.local.color,
@ -1476,12 +1483,12 @@ function initVroom(room) {
webrtc.on('owner_toggle_mute', function(data){ webrtc.on('owner_toggle_mute', function(data){
// Ignore this if the remote peer isn't an owner of the room // Ignore this if the remote peer isn't an owner of the room
// or if the peer receiving it is our local screen sharing // or if the peer receiving it is our local screen sharing
if (peers[data.id].role != 'owner' || data.roomType == 'screen'){ if (peers[data.id].role !== 'owner' || data.roomType === 'screen'){
return; return;
} }
// We are the one being (un)muted, and we're not owner // We are the one being (un)muted, and we're not owner
// Be nice and obey // Be nice and obey
if (data.payload.peer && data.payload.peer == peers.local.id && peers.local.role != 'owner'){ if (data.payload.peer && data.payload.peer == peers.local.id && peers.local.role !== 'owner'){
var who = (peers[data.id].hasName) ? peers[data.id].displayName : localize('A_ROOM_ADMIN'); var who = (peers[data.id].hasName) ? peers[data.id].displayName : localize('A_ROOM_ADMIN');
if (!peers.local.micMuted){ if (!peers.local.micMuted){
muteMic(); muteMic();
@ -1547,8 +1554,8 @@ function initVroom(room) {
$.notify(sprintf(localize('s_CHANGED_ROOM_CONFIG'), who), 'success'); $.notify(sprintf(localize('s_CHANGED_ROOM_CONFIG'), who), 'success');
}); });
// This peer indicates he has no webcam
webrtc.on('media_info', function(data){ webrtc.on('media_info', function(data){
// This peer indicates he has no webcam
if (!data.payload.video){ if (!data.payload.video){
$('#overlay_' + data.id).append($('<div>').attr('id', 'noWebcam_' + data.id).addClass('noWebcam')); $('#overlay_' + data.id).append($('<div>').attr('id', 'noWebcam_' + data.id).addClass('noWebcam'));
$('#actionPause_' + data.id).addClass('disabled'); $('#actionPause_' + data.id).addClass('disabled');
@ -1569,7 +1576,7 @@ function initVroom(room) {
getPeerRole(peers.local.id); getPeerRole(peers.local.id);
$.notify(sprintf(localize('s_IS_PROMOTING_YOU'), who), 'success'); $.notify(sprintf(localize('s_IS_PROMOTING_YOU'), who), 'success');
} }
else if (data.payload.peer != peers.local.id && peers[data.payload.peer]){ else if (data.payload.peer !== peers.local.id && peers[data.payload.peer]){
var who = (peers[data.id].hasName) ? var who = (peers[data.id].hasName) ?
peers[data.id].displayName : localize('A_ROOM_ADMIN'); peers[data.id].displayName : localize('A_ROOM_ADMIN');
var target = (peers[data.payload.peer].hasName) ? var target = (peers[data.payload.peer].hasName) ?
@ -1647,7 +1654,7 @@ function initVroom(room) {
updatePeerLatency(peer.id,diff); updatePeerLatency(peer.id,diff);
} }
// The peer sets a displayName, record this in our peers object // The peer sets a displayName, record this in our peers object
else if (data.type == 'setDisplayName'){ else if (data.type === 'set_display_name'){
var name = data.payload; var name = data.payload;
// Ignore it if it's too long // Ignore it if it's too long
if (name.length > 50){ if (name.length > 50){
@ -1664,11 +1671,11 @@ function initVroom(room) {
updateDisplayName(peer.id); updateDisplayName(peer.id);
} }
// This peer asked for our chat history, lets send him // This peer asked for our chat history, lets send him
else if (data.type == 'getHistory'){ else if (data.type === 'chat_history_request'){
peer.sendDirectly('vroom', 'chatHistory', JSON.stringify(chatHistory)); peer.sendDirectly('vroom', 'chat_history_response', JSON.stringify(chatHistory));
} }
// This peer is sending its chat history (and we don't have it yet) // This peer is sending its chat history (and we don't have it yet)
else if (data.type == 'chatHistory' && !peers.local.hasHistory){ else if (data.type === 'chat_history_response' && !peers.local.hasHistory){
peers.local.hasHistory = true; peers.local.hasHistory = true;
var history = JSON.parse(data.payload); var history = JSON.parse(data.payload);
for (var i = 0; i < Object.keys(history).length; i++){ for (var i = 0; i < Object.keys(history).length; i++){
@ -1676,7 +1683,7 @@ function initVroom(room) {
} }
} }
// One peer just sent a text chat message // One peer just sent a text chat message
else if (data.type == 'textChat'){ else if (data.type === 'text_chat'){
// Notify if the chat menu is collapsed // Notify if the chat menu is collapsed
if ($('#chatDropdown').hasClass('collapsed')){ if ($('#chatDropdown').hasClass('collapsed')){
$('#chatDropdown').addClass('btn-danger'); $('#chatDropdown').addClass('btn-danger');
@ -1747,7 +1754,7 @@ function initVroom(room) {
// This peer claims he changed its role (usually from participant to owner) // This peer claims he changed its role (usually from participant to owner)
// Lets check this // Lets check this
webrtc.on('role_change', function(data){ webrtc.on('role_change', function(data){
if (data.roomType == 'screen'){ if (data.roomType === 'screen'){
return; return;
} }
getPeerRole(data.id); getPeerRole(data.id);
@ -1827,7 +1834,7 @@ function initVroom(room) {
id = id + '_screen'; id = id + '_screen';
} }
// Or the peer itself // Or the peer itself
else if (peer && peers[peer.id] && id != 'local'){ else if (peer && peers[peer.id] && id !== 'local'){
delete peers[peer.id]; delete peers[peer.id];
} }
$('#peer_' + id).hide(300); $('#peer_' + id).hide(300);
@ -1851,7 +1858,7 @@ function initVroom(room) {
} }
}); });
// Display an error if an error occures during p2p connection // Display an message if an error occures during p2p connection
function p2pFailure(peer){ function p2pFailure(peer){
peer.end(); peer.end();
$.notify(localize('ERROR_ESTABLISHING_P2P')); $.notify(localize('ERROR_ESTABLISHING_P2P'));
@ -1927,7 +1934,7 @@ function initVroom(room) {
$('#displayName').parent().removeClass('has-error'); $('#displayName').parent().removeClass('has-error');
} }
// Enable chat input when you set your disaplay name // Enable chat input when you set your disaplay name
if (name != '' && $('#chatBox').attr('disabled')){ if (name !i== '' && $('#chatBox').attr('disabled')){
$('#chatBox').removeAttr('disabled').removeAttr('placeholder'); $('#chatBox').removeAttr('disabled').removeAttr('placeholder');
peers.local.hasName = true; peers.local.hasName = true;
} }
@ -1938,13 +1945,13 @@ function initVroom(room) {
} }
peers.local.displayName = name; peers.local.displayName = name;
updateDisplayName('local'); updateDisplayName('local');
webrtc.sendDirectlyToAll('vroom', 'setDisplayName', name); webrtc.sendDirectlyToAll('vroom', 'set_display_name', name);
lastNameChange = +new Date; lastNameChange = +new Date;
// Should we reload etherpad iFrame with this new name ? // Should we reload etherpad iFrame with this new name ?
if (etherpad.enabled){ if (etherpad.enabled){
// Wait ~3 sec and reload etherpad // Wait ~3 sec and reload etherpad
setTimeout(function(){ setTimeout(function(){
if (lastNameChange && lastNameChange + 3000 < +new Date && $('#etherpadContainer').html() != ''){ if (lastNameChange && lastNameChange + 3000 < +new Date && $('#etherpadContainer').html() !== ''){
loadEtherpadIframe(); loadEtherpadIframe();
} }
}, 3100); }, 3100);
@ -1963,6 +1970,7 @@ function initVroom(room) {
// An error occured while sharing our screen // An error occured while sharing our screen
if(err){ if(err){
if (err.name === 'EXTENSION_UNAVAILABLE'){ if (err.name === 'EXTENSION_UNAVAILABLE'){
// TODO: remove this test, v 34 or 35 are old now
var ver = 34; var ver = 34;
if ($.browser.linux){ if ($.browser.linux){
ver = 35; ver = 35;
@ -2199,7 +2207,7 @@ function initVroom(room) {
$('#chatForm').submit(function (e){ $('#chatForm').submit(function (e){
e.preventDefault(); e.preventDefault();
if ($('#chatBox').val()){ if ($('#chatBox').val()){
webrtc.sendDirectlyToAll('vroom', 'textChat', $('#chatBox').val()); webrtc.sendDirectlyToAll('vroom', 'text_chat', $('#chatBox').val());
// Local echo of our own message // Local echo of our own message
newChatMessage('local',$('#chatBox').val()); newChatMessage('local',$('#chatBox').val());
// reset the input box // reset the input box

Loading…
Cancel
Save