This is an automated email from the ASF dual-hosted git repository.
solomax pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openmeetings.git
The following commit(s) were added to refs/heads/master by this push:
new a5eec49 [OPENMEETINGS-2000] moving JS code to npm
a5eec49 is described below
commit a5eec49a0b829c47e8ecd47911967abf7a46454d
Author: Maxim Solodovnik <[email protected]>
AuthorDate: Sat Dec 26 23:49:09 2020 +0700
[OPENMEETINGS-2000] moving JS code to npm
---
openmeetings-web/src/main/front/room/src/sharer.js | 10 +--
.../src/main/front/room/src/video-manager-util.js | 62 +++++++++++++++++++
.../src/main/front/room/src/video-manager.js | 72 +++-------------------
openmeetings-web/src/main/front/room/src/video.js | 38 ++++++------
openmeetings-web/src/main/front/room/src/volume.js | 15 ++---
5 files changed, 105 insertions(+), 92 deletions(-)
diff --git a/openmeetings-web/src/main/front/room/src/sharer.js
b/openmeetings-web/src/main/front/room/src/sharer.js
index fd16010..755d821 100644
--- a/openmeetings-web/src/main/front/room/src/sharer.js
+++ b/openmeetings-web/src/main/front/room/src/sharer.js
@@ -1,4 +1,6 @@
/* Licensed under the Apache License, Version 2.0 (the "License")
http://www.apache.org/licenses/LICENSE-2.0 */
+const VideoMgrUtil = require('./video-manager-util');
+
var SHARE_STARTING = 'starting';
var SHARE_STARTED = 'started';
var SHARE_STOPPED = 'stopped';
@@ -38,13 +40,13 @@ function _init() {
sbtn = sharer.find('.share-start-stop').off().click(function() {
if (shareState === SHARE_STOPPED) {
_setShareState(SHARE_STARTING);
- VideoManager.sendMessage({
+ VideoMgrUtil.sendMessage({
id: 'wannaShare'
, shareType: type.val()
, fps: fps.val()
});
} else {
- VideoManager.sendMessage({
+ VideoMgrUtil.sendMessage({
id: 'pauseSharing'
, uid: _getShareUid()
});
@@ -55,13 +57,13 @@ function _init() {
rbtn.show().click(function() {
if (recState === SHARE_STOPPED) {
_setRecState(SHARE_STARTING);
- VideoManager.sendMessage({
+ VideoMgrUtil.sendMessage({
id: 'wannaRecord'
, shareType: type.val()
, fps: fps.val()
});
} else {
- VideoManager.sendMessage({
+ VideoMgrUtil.sendMessage({
id: 'stopRecord'
, uid: _getShareUid()
});
diff --git a/openmeetings-web/src/main/front/room/src/video-manager-util.js
b/openmeetings-web/src/main/front/room/src/video-manager-util.js
new file mode 100644
index 0000000..15c4abb
--- /dev/null
+++ b/openmeetings-web/src/main/front/room/src/video-manager-util.js
@@ -0,0 +1,62 @@
+/* Licensed under the Apache License, Version 2.0 (the "License")
http://www.apache.org/licenses/LICENSE-2.0 */
+let share;
+
+function _closeV(v) {
+ if (!v || v.length < 1) {
+ return;
+ }
+ if (v.dialog('instance') !== undefined) {
+ v.dialog('destroy');
+ }
+ v.parents('.pod').remove();
+ v.remove();
+ WbArea.updateAreaClass();
+}
+function _clickMuteOthers(uid) {
+ const s = VideoSettings.load();
+ if (false !== s.video.confirmMuteOthers) {
+ const dlg = $('#muteothers-confirm');
+ dlg.dialog({
+ appendTo: ".room-container"
+ , buttons: [
+ {
+ text: dlg.data('btn-ok')
+ , click: function() {
+ s.video.confirmMuteOthers =
!$('#muteothers-confirm-dont-show').prop('checked');
+ VideoSettings.save();
+ OmUtil.roomAction({action:
'muteOthers', uid: uid});
+ $(this).dialog('close');
+ }
+ }
+ , {
+ text: dlg.data('btn-cancel')
+ , click: function() {
+ $(this).dialog('close');
+ }
+ }
+ ]
+ })
+ } else {
+ OmUtil.roomAction({action: 'muteOthers', uid: uid});
+ }
+}
+
+module.exports = {
+ init: (_share) => {
+ share = _share;
+ }
+ , sendMessage: (_m) => {
+ OmUtil.sendMessage(_m, {type: 'kurento'});
+ }
+ , closeV: _closeV
+ , close: (uid, showShareBtn) => {
+ const v = $('#' + VideoUtil.getVid(uid));
+ if (v.length === 1) {
+ _closeV(v);
+ }
+ if (!showShareBtn && uid === share.data('uid')) {
+ share.off().hide();
+ }
+ }
+ , clickMuteOthers: _clickMuteOthers
+};
diff --git a/openmeetings-web/src/main/front/room/src/video-manager.js
b/openmeetings-web/src/main/front/room/src/video-manager.js
index 7066e2a..0a0bfda 100644
--- a/openmeetings-web/src/main/front/room/src/video-manager.js
+++ b/openmeetings-web/src/main/front/room/src/video-manager.js
@@ -1,5 +1,6 @@
/* Licensed under the Apache License, Version 2.0 (the "License")
http://www.apache.org/licenses/LICENSE-2.0 */
let share, inited = false;
+const VideoMgrUtil = require('./video-manager-util');
const Video = require('./video');
const Sharer = require('./sharer');
@@ -15,7 +16,7 @@ function _onBroadcast(msg) {
, uid = sd.uid;
if (Array.isArray(msg.cleanup)) {
msg.cleanup.forEach(function(_cuid) {
- _close(_cuid);
+ VideoMgrUtil.close(_cuid);
});
}
$('#' + VideoUtil.getVid(uid)).remove();
@@ -36,7 +37,7 @@ function _onShareUpdated(msg) {
}
function _onReceive(msg) {
const uid = msg.stream.uid;
- _closeV($('#' + VideoUtil.getVid(uid)));
+ VideoMgrUtil.closeV($('#' + VideoUtil.getVid(uid)));
new Video(msg);
OmUtil.log(uid + ' receiving video');
}
@@ -44,14 +45,14 @@ function _onKMessage(m) {
switch (m.id) {
case 'clientLeave':
$(VID_SEL + '[data-client-uid="' + m.uid +
'"]').each(function() {
- _closeV($(this));
+ VideoMgrUtil.closeV($(this));
});
if (share.data('cuid') === m.uid) {
share.off().hide();
}
break;
case 'broadcastStopped':
- _close(m.uid, false);
+ VideoMgrUtil.close(m.uid, false);
break;
case 'broadcast':
_onBroadcast(m);
@@ -81,7 +82,7 @@ function _onKMessage(m) {
//no-op
}
}
-function _onWsMessage(jqEvent, msg) {
+function _onWsMessage(_, msg) {
try {
if (msg instanceof Blob) {
return; //ping
@@ -110,6 +111,7 @@ function _init() {
Wicket.Event.subscribe('/websocket/message', _onWsMessage);
VideoSettings.init(Room.getOptions());
share = $('.room-block .room-container').find('.btn.shared');
+ VideoMgrUtil.init(share);
inited = true;
}
function _update(c) {
@@ -131,7 +133,7 @@ function _update(c) {
if (av && v.length === 1) {
v.data().update(sd);
} else if (!av && v.length === 1) {
- _closeV(v);
+ VideoMgrUtil.closeV(v);
}
});
if (c.uid === Room.getOptions().uid) {
@@ -143,21 +145,10 @@ function _update(c) {
const sd = $(this).data().stream();
if (!streamMap[sd.uid]) {
//not-inited/invalid video window
- _closeV($(this));
+ VideoMgrUtil.closeV($(this));
}
});
}
-function _closeV(v) {
- if (!v || v.length < 1) {
- return;
- }
- if (v.dialog('instance') !== undefined) {
- v.dialog('destroy');
- }
- v.parents('.pod').remove();
- v.remove();
- WbArea.updateAreaClass();
-}
function _playSharing(sd, iceServers) {
const m = {stream: sd, iceServers: iceServers};
let v = $('#' + VideoUtil.getVid(sd.uid))
@@ -193,15 +184,6 @@ function _play(streams, iceServers) {
}
});
}
-function _close(uid, showShareBtn) {
- const v = $('#' + VideoUtil.getVid(uid));
- if (v.length === 1) {
- _closeV(v);
- }
- if (!showShareBtn && uid === share.data('uid')) {
- share.off().hide();
- }
-}
function _find(uid) {
return $(VID_SEL + '[data-client-uid="' + uid +
'"][data-client-type="WEBCAM"]');
}
@@ -228,34 +210,6 @@ function _mute(uid, mute) {
v.data().mute(mute);
}
}
-function _clickMuteOthers(uid) {
- const s = VideoSettings.load();
- if (false !== s.video.confirmMuteOthers) {
- const dlg = $('#muteothers-confirm');
- dlg.dialog({
- appendTo: ".room-container"
- , buttons: [
- {
- text: dlg.data('btn-ok')
- , click: function() {
- s.video.confirmMuteOthers =
!$('#muteothers-confirm-dont-show').prop('checked');
- VideoSettings.save();
- OmUtil.roomAction({action:
'muteOthers', uid: uid});
- $(this).dialog('close');
- }
- }
- , {
- text: dlg.data('btn-cancel')
- , click: function() {
- $(this).dialog('close');
- }
- }
- ]
- })
- } else {
- OmUtil.roomAction({action: 'muteOthers', uid: uid});
- }
-}
function _muteOthers(uid) {
$(VID_SEL).each(function() {
const w = $(this), v = w.data(), v2 = w.data('client-uid');
@@ -264,11 +218,8 @@ function _muteOthers(uid) {
}
});
}
-function _sendMessage(_m) {
- OmUtil.sendMessage(_m, {type: 'kurento'});
-}
function _toggleActivity(activity) {
- _sendMessage({
+ VideoMgrUtil.sendMessage({
id: 'toggleActivity'
, activity: activity
});
@@ -278,13 +229,10 @@ module.exports = {
init: _init
, update: _update
, play: _play
- , close: _close
, refresh: _refresh
, mute: _mute
- , clickMuteOthers: _clickMuteOthers
, muteOthers: _muteOthers
, toggleActivity: _toggleActivity
- , sendMessage: _sendMessage
, destroy: function() {
Wicket.Event.unsubscribe('/websocket/message', _onWsMessage);
}
diff --git a/openmeetings-web/src/main/front/room/src/video.js
b/openmeetings-web/src/main/front/room/src/video.js
index 3cdef81..2bb752f 100644
--- a/openmeetings-web/src/main/front/room/src/video.js
+++ b/openmeetings-web/src/main/front/room/src/video.js
@@ -1,18 +1,18 @@
/* Licensed under the Apache License, Version 2.0 (the "License")
http://www.apache.org/licenses/LICENSE-2.0 */
const AudioCtx = window.AudioContext || window.webkitAudioContext;
-const VideoManager = require('./video-manager');
+const VideoMgrUtil = require('./video-manager-util');
const Sharer = require('./sharer');
const Volume = require('./volume');
module.exports = class Video {
constructor(msg) {
- const states = [];
+ const states = [], self = this;
let sd, v, vc, t, footer, size, vol, iceServers
, lm, level, userSpeaks = false, muteOthers
, hasVideo, isSharing, isRecording;
function __getVideo(_state) {
- const vid = this.video(_state);
+ const vid = self.video(_state);
return vid && vid.length > 0 ? vid[0] : null;
}
function _resizeDlgArea(_w, _h) {
@@ -30,7 +30,7 @@ module.exports = class Video {
}
function _getScreenStream(msg, state, callback) {
function __handleScreenError(err) {
- VideoManager.sendMessage({id: 'errorSharing'});
+ VideoMgrUtil.sendMessage({id: 'errorSharing'});
Sharer.setShareState(SHARE_STOPPED);
Sharer.setRecState(SHARE_STOPPED);
OmUtil.error(err);
@@ -69,7 +69,7 @@ module.exports = class Video {
function _getVideoStream(msg, state, callback) {
VideoSettings.constraints(sd, function(cnts) {
if ((VideoUtil.hasCam(sd) && !cnts.video) ||
(VideoUtil.hasMic(sd) && !cnts.audio)) {
- VideoManager.sendMessage({
+ VideoMgrUtil.sendMessage({
id : 'devicesAltered'
, uid: sd.uid
, audio: !!cnts.audio
@@ -78,7 +78,7 @@ module.exports = class Video {
}
if (!cnts.audio && !cnts.video) {
OmUtil.error('Requested devices are not
available');
- VideoManager.close(sd.uid)
+ VideoMgrUtil.close(sd.uid)
return;
}
navigator.mediaDevices.getUserMedia(cnts)
@@ -115,13 +115,13 @@ module.exports = class Video {
callback(msg, state, cnts);
})
.catch(function(err) {
- VideoManager.sendMessage({
+ VideoMgrUtil.sendMessage({
id : 'devicesAltered'
, uid: sd.uid
, audio: false
, video: false
});
- VideoManager.close(sd.uid);
+ VideoMgrUtil.close(sd.uid);
if ('NotReadableError' ===
err.name) {
OmUtil.error('Camera/Microphone is busy and can\'t be used');
} else {
@@ -159,7 +159,7 @@ module.exports = class Video {
state.options = {
videoStream: state.stream
, mediaConstraints: cnts
- , onicecandidate: this.onIceCandidate
+ , onicecandidate: self.onIceCandidate
};
if (!isSharing) {
state.options.localVideo = __getVideo(state);
@@ -197,7 +197,7 @@ module.exports = class Video {
bmsg.height =
vts.height;
bmsg.fps =
vts.frameRate;
}
- VideoManager.sendMessage(bmsg);
+ VideoMgrUtil.sendMessage(bmsg);
if (isSharing) {
Sharer.setShareState(SHARE_STARTED);
}
@@ -220,7 +220,7 @@ module.exports = class Video {
__createVideo(state);
const options = VideoUtil.addIceServers({
remoteVideo : __getVideo(state)
- , onicecandidate : this.onIceCandidate
+ , onicecandidate : self.onIceCandidate
}, msg);
const data = state.data;
data.rtcPeer = new
kurentoUtils.WebRtcPeer.WebRtcPeerRecvonly(
@@ -240,7 +240,7 @@ module.exports = class Video {
return
OmUtil.error('Receiver sdp offer error ' + genErr);
}
OmUtil.log('Invoking Receiver
SDP offer callback function');
- VideoManager.sendMessage({
+ VideoMgrUtil.sendMessage({
id : 'addListener'
, sender: sd.uid
, sdpOffer: offerSdp
@@ -285,7 +285,7 @@ module.exports = class Video {
.attr('data-client-uid', sd.cuid)
.attr('data-client-type', sd.type)
.attr('data-instance-uid', instanceUid)
- .data(this));
+ .data(self));
v = $('#' + _id);
vc = v.find('.video');
muteOthers = vc.find('.mute-others');
@@ -302,7 +302,7 @@ module.exports = class Video {
v.dialog('option', 'resizable', true);
if (isSharing) {
v.on('dialogclose', function() {
- VideoManager.close(sd.uid,
true);
+ VideoMgrUtil.close(sd.uid,
true);
});
}
}
@@ -321,7 +321,7 @@ module.exports = class Video {
, tgl = v.parent().find('.btn-toggle')
, cls = v.parent().find('.btn-wclose');
if (isSharing) {
- cls.click(function (e) {
+ cls.click(function (_) {
v.dialog('close');
return false;
});
@@ -399,7 +399,7 @@ module.exports = class Video {
}
vc.append(state.video);
if (VideoUtil.hasMic(sd)) {
- const volIco = vol.create(this)
+ const volIco = vol.create(self)
if (hasVideo) {
v.parent().find('.buttonpane').append(volIco);
} else {
@@ -416,7 +416,7 @@ module.exports = class Video {
, instanceUid: v.length > 0 ?
v.data('instance-uid') : undefined
};
if (sd.self) {
- VideoManager.sendMessage({
+ VideoMgrUtil.sendMessage({
id : 'broadcastRestarted'
, uid: sd.uid
});
@@ -438,7 +438,7 @@ module.exports = class Video {
function _setRights() {
if (Room.hasRight(['MUTE_OTHERS']) &&
VideoUtil.hasMic(sd)) {
muteOthers.addClass('enabled').off().click(function() {
- VideoManager.clickMuteOthers(sd.cuid);
+ VideoMgrUtil.clickMuteOthers(sd.cuid);
});
} else {
muteOthers.removeClass('enabled').off();
@@ -594,7 +594,7 @@ module.exports = class Video {
this.onIceCandidate = function(candidate) {
const opts = Room.getOptions();
OmUtil.log('Local candidate ' +
JSON.stringify(candidate));
- VideoManager.sendMessage({
+ VideoMgrUtil.sendMessage({
id: 'onIceCandidate'
, candidate: candidate
, uid: sd.uid
diff --git a/openmeetings-web/src/main/front/room/src/volume.js
b/openmeetings-web/src/main/front/room/src/volume.js
index 4a1b519..f5c7bef 100644
--- a/openmeetings-web/src/main/front/room/src/volume.js
+++ b/openmeetings-web/src/main/front/room/src/volume.js
@@ -1,6 +1,7 @@
/* Licensed under the Apache License, Version 2.0 (the "License")
http://www.apache.org/licenses/LICENSE-2.0 */
module.exports = class Volume {
constructor() {
+ const self = this;
let video, vol, drop, slider, handleEl, hideTimer = null
, lastVolume = 50, muted = false;
@@ -20,7 +21,7 @@ module.exports = class Volume {
this.create = (_video) => {
video = _video;
- _destroy();
+ this.destroy();
const uid = video.stream().uid
, cuid = video.stream().cuid
, volId = 'volume-' + uid;
@@ -35,7 +36,7 @@ module.exports = class Volume {
.click(function(e) {
e.stopImmediatePropagation();
OmUtil.roomAction({action: 'mute', uid:
cuid, mute: !muted});
- _mute(!muted);
+ self.mute(!muted);
drop.hide();
return false;
}).dblclick(function(e) {
@@ -59,11 +60,11 @@ module.exports = class Volume {
handleEl.text($(this).slider('value'));
}
, slide: function(event, ui) {
- _handle(ui.value);
+ self.handle(ui.value);
}
});
- _handle(lastVolume);
- _mute(muted);
+ this.handle(lastVolume);
+ this.mute(muted);
return vol;
};
this.handle = (val) => {
@@ -97,10 +98,10 @@ module.exports = class Volume {
lastVolume = val;
}
slider.slider('option', 'value', 0);
- _handle(0);
+ this.handle(0);
} else {
slider.slider('option', 'value', lastVolume);
- _handle(lastVolume);
+ this.handle(lastVolume);
}
};
this.destroy = () => {