Replaces 'focus' occurrences with moderator for handling privileged functionalities.
This commit is contained in:
parent
ed2d7e4282
commit
7dc8102dee
10
app.js
10
app.js
|
@ -728,8 +728,6 @@ $(document).bind('entered.muc', function (event, jid, info, pres) {
|
|||
'connected',
|
||||
'connected');
|
||||
|
||||
console.log('is focus? ' + (focus ? 'true' : 'false'));
|
||||
|
||||
if (Strophe.getResourceFromJid(jid).indexOf('focus') != -1)
|
||||
{
|
||||
focusJid = jid;
|
||||
|
@ -1249,6 +1247,8 @@ $(document).ready(function () {
|
|||
}
|
||||
});
|
||||
|
||||
Moderator.init();
|
||||
|
||||
// Set the defaults for prompt dialogs.
|
||||
jQuery.prompt.setDefaults({persistent: false});
|
||||
|
||||
|
@ -1442,11 +1442,13 @@ function updateRoomUrl(newRoomUrl) {
|
|||
* Warning to the user that the conference window is about to be closed.
|
||||
*/
|
||||
function closePageWarning() {
|
||||
/*
|
||||
FIXME: do we need a warning when the focus is a server-side one now ?
|
||||
if (focus !== null)
|
||||
return "You are the owner of this conference call and"
|
||||
+ " you are about to end it.";
|
||||
else
|
||||
return "You are about to leave this conversation.";
|
||||
else*/
|
||||
return "You are about to leave this conversation.";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* global $, config, Prezi, Util, connection, setLargeVideoVisible, dockToolbar */
|
||||
/* global $, config, connection, dockToolbar, Moderator, Prezi,
|
||||
setLargeVideoVisible, ToolbarToggler, Util, VideoLayout */
|
||||
var Etherpad = (function (my) {
|
||||
var etherpadName = null;
|
||||
var etherpadIFrame = null;
|
||||
|
@ -161,7 +162,7 @@ var Etherpad = (function (my) {
|
|||
*/
|
||||
$(document).bind('etherpadadded.muc', function (event, jid, etherpadName) {
|
||||
console.log("Etherpad added", etherpadName);
|
||||
if (config.etherpad_base && !focus) {
|
||||
if (config.etherpad_base && !Moderator.isModerator()) {
|
||||
Etherpad.init(etherpadName);
|
||||
}
|
||||
});
|
||||
|
@ -169,6 +170,7 @@ var Etherpad = (function (my) {
|
|||
/**
|
||||
* On focus changed event.
|
||||
*/
|
||||
// FIXME: there is no such event as 'focusechanged.muc'
|
||||
$(document).bind('focusechanged.muc', function (event, focus) {
|
||||
console.log("Focus changed");
|
||||
if (config.etherpad_base)
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
<script src="audio_levels.js?v=2"></script><!-- audio levels plugin -->
|
||||
<script src="media_stream.js?v=1"></script><!-- media stream -->
|
||||
<script src="bottom_toolbar.js?v=5"></script><!-- media stream -->
|
||||
<script src="moderator.js?v=1"></script><!-- media stream -->
|
||||
<script src="roomname_generator.js?v=1"></script><!-- generator for random room names -->
|
||||
<script src="keyboard_shortcut.js?v=3"></script>
|
||||
<script src="recording.js?v=1"></script>
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
/* global $, config, connection, Etherpad, Toolbar, VideoLayout */
|
||||
/**
|
||||
* Contains logic responsible for enabling/disabling functionality available
|
||||
* only to moderator users.
|
||||
*/
|
||||
var Moderator = (function (my) {
|
||||
|
||||
my.isModerator = function () {
|
||||
return connection.emuc.isModerator();
|
||||
};
|
||||
|
||||
my.onModeratorStatusChanged = function (isModerator) {
|
||||
|
||||
Toolbar.showSipCallButton(isModerator);
|
||||
Toolbar.showRecordingButton(
|
||||
isModerator); //&&
|
||||
// FIXME:
|
||||
// Recording visible if
|
||||
// there are at least 2(+ 1 focus) participants
|
||||
//Object.keys(connection.emuc.members).length >= 3);
|
||||
|
||||
if (isModerator && config.etherpad_base) {
|
||||
Etherpad.init();
|
||||
}
|
||||
|
||||
$(document).trigger('local.role.moderator', [isModerator]);
|
||||
};
|
||||
|
||||
my.init = function () {
|
||||
$(document).bind(
|
||||
'role.changed.muc',
|
||||
function (event, jid, info, pres) {
|
||||
console.info(
|
||||
"Role changed for " + jid + ", new role: " + info.role);
|
||||
VideoLayout.showModeratorIndicator();
|
||||
}
|
||||
);
|
||||
|
||||
$(document).bind(
|
||||
'local.role.changed.muc',
|
||||
function (event, jid, info, pres) {
|
||||
console.info("My role changed, new role: " + info.role);
|
||||
VideoLayout.showModeratorIndicator();
|
||||
Moderator.onModeratorStatusChanged(Moderator.isModerator());
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
return my;
|
||||
}(Moderator || {}));
|
||||
|
||||
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
/* global $, $iq, config, connection, focusJid, messageHandler, Toolbar, Util */
|
||||
/* global $, $iq, config, connection, focusJid, messageHandler, Moderator,
|
||||
Toolbar, Util */
|
||||
var Recording = (function (my) {
|
||||
var status = false;
|
||||
var recordingToken = null;
|
||||
|
@ -36,7 +37,7 @@ var Recording = (function (my) {
|
|||
};
|
||||
|
||||
my.toggleRecording = function () {
|
||||
if (!connection.emuc.isModerator()) {
|
||||
if (!Moderator.isModerator()) {
|
||||
console.log(
|
||||
'non-focus, or conference not yet organized:' +
|
||||
' not enabling recording');
|
||||
|
|
|
@ -17,7 +17,7 @@ var Toolbar = (function (my) {
|
|||
*/
|
||||
my.openLockDialog = function () {
|
||||
// Only the focus is able to set a shared key.
|
||||
if (focus === null) {
|
||||
if (Moderator.isModerator()) {
|
||||
if (sharedKey) {
|
||||
messageHandler.openMessageDialog(null,
|
||||
"This conversation is currently protected by" +
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* global $, interfaceConfig, showDesktopSharingButton */
|
||||
/* global $, interfaceConfig, Moderator, showDesktopSharingButton */
|
||||
var ToolbarToggler = (function (my) {
|
||||
var toolbarTimeoutObject,
|
||||
toolbarTimeout = interfaceConfig.INITIAL_TOOLBAR_TIMEOUT;
|
||||
|
@ -25,7 +25,7 @@ var ToolbarToggler = (function (my) {
|
|||
toolbarTimeout = interfaceConfig.TOOLBAR_TIMEOUT;
|
||||
}
|
||||
|
||||
if (focus !== null)
|
||||
if (Moderator.isModerator())
|
||||
{
|
||||
// TODO: Enable settings functionality.
|
||||
// Need to uncomment the settings button in index.html.
|
||||
|
|
|
@ -380,11 +380,12 @@ var VideoLayout = (function (my) {
|
|||
var videoSpanId = 'participant_' + resourceJid;
|
||||
|
||||
if ($('#' + videoSpanId).length > 0) {
|
||||
// If there's been a focus change, make sure we add focus related
|
||||
// interface!!
|
||||
if (focus && $('#remote_popupmenu_' + resourceJid).length <= 0)
|
||||
addRemoteVideoMenu( peerJid,
|
||||
document.getElementById(videoSpanId));
|
||||
// If there's been a moderator change, make sure we add moderator
|
||||
// related interface!!
|
||||
if (Moderator.isModerator() &&
|
||||
$('#remote_popupmenu_' + resourceJid).length <= 0)
|
||||
addRemoteVideoMenu(peerJid,
|
||||
document.getElementById(videoSpanId));
|
||||
}
|
||||
else {
|
||||
var container
|
||||
|
@ -419,7 +420,7 @@ var VideoLayout = (function (my) {
|
|||
|
||||
// If the peerJid is null then this video span couldn't be directly
|
||||
// associated with a participant (this could happen in the case of prezi).
|
||||
if (focus && peerJid != null)
|
||||
if (Moderator.isModerator() && peerJid !== null)
|
||||
addRemoteVideoMenu(peerJid, container);
|
||||
|
||||
remotes.appendChild(container);
|
||||
|
@ -772,42 +773,47 @@ var VideoLayout = (function (my) {
|
|||
};
|
||||
|
||||
/**
|
||||
* Shows a visual indicator for the focus of the conference.
|
||||
* Currently if we're not the owner of the conference we obtain the focus
|
||||
* from the connection.jingle.sessions.
|
||||
* Shows a visual indicator for the moderator of the conference.
|
||||
*/
|
||||
my.showFocusIndicator = function() {
|
||||
if (focus !== null) {
|
||||
my.showModeratorIndicator = function () {
|
||||
if (Moderator.isModerator()) {
|
||||
var indicatorSpan = $('#localVideoContainer .focusindicator');
|
||||
|
||||
if (indicatorSpan.children().length === 0)
|
||||
{
|
||||
createFocusIndicatorElement(indicatorSpan[0]);
|
||||
createModeratorIndicatorElement(indicatorSpan[0]);
|
||||
}
|
||||
}
|
||||
else if (Object.keys(connection.jingle.sessions).length > 0) {
|
||||
// If we're only a participant the focus will be the only session we have.
|
||||
var session
|
||||
= connection.jingle.sessions
|
||||
[Object.keys(connection.jingle.sessions)[0]];
|
||||
var focusId
|
||||
= 'participant_' + Strophe.getResourceFromJid(session.peerjid);
|
||||
} else {
|
||||
Object.keys(connection.emuc.members).forEach(function (jid) {
|
||||
var member = connection.emuc.members[jid];
|
||||
if (member.role === 'moderator') {
|
||||
var moderatorId
|
||||
= 'participant_' + Strophe.getResourceFromJid(jid);
|
||||
|
||||
var focusContainer = document.getElementById(focusId);
|
||||
if (!focusContainer) {
|
||||
console.error("No focus container!");
|
||||
return;
|
||||
}
|
||||
var indicatorSpan = $('#' + focusId + ' .focusindicator');
|
||||
var moderatorContainer
|
||||
= document.getElementById(moderatorId);
|
||||
|
||||
if (!indicatorSpan || indicatorSpan.length === 0) {
|
||||
indicatorSpan = document.createElement('span');
|
||||
indicatorSpan.className = 'focusindicator';
|
||||
if (Strophe.getResourceFromJid(jid) === 'focus') {
|
||||
// Skip server side focus
|
||||
return;
|
||||
}
|
||||
if (!moderatorContainer) {
|
||||
console.error("No moderator container for " + jid);
|
||||
return;
|
||||
}
|
||||
var indicatorSpan
|
||||
= $('#' + moderatorId + ' .focusindicator');
|
||||
|
||||
focusContainer.appendChild(indicatorSpan);
|
||||
if (!indicatorSpan || indicatorSpan.length === 0) {
|
||||
indicatorSpan = document.createElement('span');
|
||||
indicatorSpan.className = 'focusindicator';
|
||||
|
||||
createFocusIndicatorElement(indicatorSpan);
|
||||
}
|
||||
moderatorContainer.appendChild(indicatorSpan);
|
||||
|
||||
createModeratorIndicatorElement(indicatorSpan);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1120,15 +1126,15 @@ var VideoLayout = (function (my) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates the element indicating the focus of the conference.
|
||||
* Creates the element indicating the moderator(owner) of the conference.
|
||||
*
|
||||
* @param parentElement the parent element where the focus indicator will
|
||||
* @param parentElement the parent element where the owner indicator will
|
||||
* be added
|
||||
*/
|
||||
function createFocusIndicatorElement(parentElement) {
|
||||
var focusIndicator = document.createElement('i');
|
||||
focusIndicator.className = 'fa fa-star';
|
||||
parentElement.appendChild(focusIndicator);
|
||||
function createModeratorIndicatorElement(parentElement) {
|
||||
var moderatorIndicator = document.createElement('i');
|
||||
moderatorIndicator.className = 'fa fa-star';
|
||||
parentElement.appendChild(moderatorIndicator);
|
||||
|
||||
Util.setTooltip(parentElement,
|
||||
"The owner of<br/>this conference",
|
||||
|
@ -1328,19 +1334,28 @@ var VideoLayout = (function (my) {
|
|||
* On audio muted event.
|
||||
*/
|
||||
$(document).bind('audiomuted.muc', function (event, jid, isMuted) {
|
||||
/*
|
||||
// FIXME: but focus can not mute in this case ? - check
|
||||
if (jid === connection.emuc.myroomjid) {
|
||||
|
||||
// The local mute indicator is controlled locally
|
||||
return;
|
||||
}*/
|
||||
var videoSpanId = null;
|
||||
if (jid === connection.emuc.myroomjid) {
|
||||
videoSpanId = 'localVideoContainer';
|
||||
} else {
|
||||
VideoLayout.ensurePeerContainerExists(jid);
|
||||
videoSpanId = 'participant_' + Strophe.getResourceFromJid(jid);
|
||||
}
|
||||
|
||||
VideoLayout.ensurePeerContainerExists(jid);
|
||||
|
||||
if (focus) {
|
||||
if (Moderator.isModerator()) {
|
||||
mutedAudios[jid] = isMuted;
|
||||
VideoLayout.updateRemoteVideoMenu(jid, isMuted);
|
||||
}
|
||||
|
||||
var videoSpanId = 'participant_' + Strophe.getResourceFromJid(jid);
|
||||
if (videoSpanId)
|
||||
VideoLayout.showAudioIndicator(videoSpanId, isMuted);
|
||||
});
|
||||
|
@ -1614,7 +1629,7 @@ var VideoLayout = (function (my) {
|
|||
VideoLayout.updateLargeVideo(videoelem.attr('src'), 1);
|
||||
}
|
||||
|
||||
VideoLayout.showFocusIndicator();
|
||||
VideoLayout.showModeratorIndicator();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue