2014-12-16 23:55:11 +08:00
|
|
|
@getBuildInformation = ->
|
2015-05-08 04:15:38 +08:00
|
|
|
copyrightYear = Meteor.config?.copyrightYear or "DATE"
|
|
|
|
html5ClientBuild = Meteor.config?.html5ClientBuild or "VERSION"
|
|
|
|
defaultWelcomeMessage = Meteor.config?.defaultWelcomeMessage or "WELCOME MESSAGE"
|
|
|
|
defaultWelcomeMessageFooter = Meteor.config?.defaultWelcomeMessageFooter or "WELCOME MESSAGE"
|
2014-12-16 23:55:11 +08:00
|
|
|
link = "<a href='http://bigbluebutton.org/' target='_blank'>http://bigbluebutton.org</a>"
|
2014-12-17 00:52:52 +08:00
|
|
|
|
2014-12-16 23:55:11 +08:00
|
|
|
{
|
|
|
|
'copyrightYear': copyrightYear
|
2015-05-08 04:15:38 +08:00
|
|
|
'html5ClientBuild': html5ClientBuild
|
2014-12-17 00:52:52 +08:00
|
|
|
'defaultWelcomeMessage': defaultWelcomeMessage
|
|
|
|
'defaultWelcomeMessageFooter': defaultWelcomeMessageFooter
|
2014-12-16 23:55:11 +08:00
|
|
|
'link': link
|
|
|
|
}
|
|
|
|
|
2014-08-21 22:40:19 +08:00
|
|
|
# Convert a color `value` as integer to a hex color (e.g. 255 to #0000ff)
|
|
|
|
@colourToHex = (value) ->
|
2015-07-10 05:59:57 +08:00
|
|
|
hex = parseInt(value).toString(16)
|
|
|
|
hex = "0" + hex while hex.length < 6
|
|
|
|
"##{hex}"
|
2014-08-21 22:40:19 +08:00
|
|
|
|
2014-10-28 22:24:56 +08:00
|
|
|
# color can be a number (a hex converted to int) or a string (e.g. "#ffff00")
|
|
|
|
@formatColor = (color) ->
|
|
|
|
color ?= "0" # default value
|
|
|
|
if !color.toString().match(/\#.*/)
|
|
|
|
color = colourToHex(color)
|
|
|
|
color
|
|
|
|
|
|
|
|
@getCurrentSlideDoc = -> # returns only one document
|
2015-05-06 04:15:33 +08:00
|
|
|
BBB.getCurrentSlide()
|
2014-08-09 00:04:04 +08:00
|
|
|
|
|
|
|
@getInSession = (k) -> SessionAmplify.get k
|
|
|
|
|
|
|
|
@getTime = -> # returns epoch in ms
|
|
|
|
(new Date).valueOf()
|
|
|
|
|
2015-07-25 06:20:00 +08:00
|
|
|
# checks if the pan gesture is mostly horizontal
|
|
|
|
@isPanHorizontal = (event) ->
|
|
|
|
Math.abs(event.deltaX) > Math.abs(event.deltaY)
|
|
|
|
|
2015-04-14 21:34:41 +08:00
|
|
|
# helper to determine whether user has joined any type of audio
|
|
|
|
Handlebars.registerHelper "amIInAudio", ->
|
|
|
|
BBB.amIInAudio()
|
|
|
|
|
|
|
|
# helper to determine whether the user is in the listen only audio stream
|
|
|
|
Handlebars.registerHelper "amIListenOnlyAudio", ->
|
|
|
|
BBB.amIListenOnlyAudio()
|
|
|
|
|
2014-08-21 22:40:19 +08:00
|
|
|
Handlebars.registerHelper "colourToHex", (value) =>
|
2014-10-28 22:24:56 +08:00
|
|
|
@window.colourToHex(value)
|
2014-08-21 22:40:19 +08:00
|
|
|
|
2014-07-09 21:15:50 +08:00
|
|
|
Handlebars.registerHelper 'equals', (a, b) -> # equals operator was dropped in Meteor's migration from Handlebars to Spacebars
|
2014-07-04 01:54:41 +08:00
|
|
|
a is b
|
|
|
|
|
2014-09-05 00:32:24 +08:00
|
|
|
Handlebars.registerHelper "getCurrentMeeting", ->
|
2014-10-28 22:24:56 +08:00
|
|
|
Meteor.Meetings.findOne()
|
2014-09-05 00:32:24 +08:00
|
|
|
|
2014-08-18 22:29:02 +08:00
|
|
|
Handlebars.registerHelper "getCurrentSlide", ->
|
|
|
|
currentPresentation = Meteor.Presentations.findOne({"presentation.current": true})
|
|
|
|
presentationId = currentPresentation?.presentation?.id
|
|
|
|
Meteor.Slides.find({"presentationId": presentationId, "slide.current": true})
|
|
|
|
|
2014-06-14 02:19:50 +08:00
|
|
|
# Allow access through all templates
|
2014-07-22 21:31:32 +08:00
|
|
|
Handlebars.registerHelper "getInSession", (k) -> SessionAmplify.get k
|
2014-06-14 02:19:50 +08:00
|
|
|
|
2014-08-09 00:04:04 +08:00
|
|
|
Handlebars.registerHelper "getMeetingName", ->
|
2015-05-06 04:15:33 +08:00
|
|
|
BBB.getMeetingName()
|
2014-06-14 02:19:50 +08:00
|
|
|
|
2014-08-18 22:29:02 +08:00
|
|
|
Handlebars.registerHelper "getShapesForSlide", ->
|
2014-09-16 00:46:02 +08:00
|
|
|
currentSlide = getCurrentSlideDoc()
|
2014-10-28 22:24:56 +08:00
|
|
|
|
2014-08-18 22:29:02 +08:00
|
|
|
# try to reuse the lines above
|
|
|
|
Meteor.Shapes.find({whiteboardId: currentSlide?.slide?.id})
|
|
|
|
|
2014-08-09 00:04:04 +08:00
|
|
|
# retrieves all users in the meeting
|
|
|
|
Handlebars.registerHelper "getUsersInMeeting", ->
|
2015-01-22 02:28:45 +08:00
|
|
|
# retrieve all users with raised hands
|
|
|
|
# raised hand is an object, so we can't simply search for true
|
|
|
|
# sort users by who has raised their hand first, place them at the top
|
|
|
|
raised = Meteor.Users.find({'user.raise_hand': {$not: {$in: [0, false, null]} }}, {sort: {'user.raise_hand': 1} }).fetch()
|
|
|
|
# find all users with a lowered hand
|
|
|
|
# when a hand is lowered, it is not always just false, it can be zero, or null
|
|
|
|
lowered = Meteor.Users.find({'user.raise_hand': $in: [0, false, null]}, {sort: {'user._sort_name': 1} }).fetch()
|
|
|
|
# add the users with lowered hands, to the list of people with raised hands
|
|
|
|
raised.concat lowered
|
2014-08-09 00:04:04 +08:00
|
|
|
|
2014-10-28 22:24:56 +08:00
|
|
|
Handlebars.registerHelper "getWhiteboardTitle", ->
|
2015-05-06 04:15:33 +08:00
|
|
|
(BBB.currentPresentationName() or "Loading presentation...")
|
2014-10-28 22:24:56 +08:00
|
|
|
|
2014-11-20 07:20:34 +08:00
|
|
|
Handlebars.registerHelper "isCurrentUser", (userId) ->
|
2015-03-10 22:07:23 +08:00
|
|
|
userId is null or userId is BBB.getCurrentUser()?.userId
|
2014-08-09 00:04:04 +08:00
|
|
|
|
2014-09-04 04:02:00 +08:00
|
|
|
Handlebars.registerHelper "isCurrentUserMuted", ->
|
2014-11-12 21:30:34 +08:00
|
|
|
BBB.amIMuted()
|
2014-09-04 04:02:00 +08:00
|
|
|
|
2015-05-21 22:41:58 +08:00
|
|
|
#Retreives a username for a private chat tab from the database if it exists
|
2015-05-21 08:49:13 +08:00
|
|
|
Handlebars.registerHelper "privateChatName", ->
|
2015-05-25 11:19:57 +08:00
|
|
|
obj = Meteor.Users.findOne({ userId: getInSession "inChatWith" })
|
|
|
|
if obj?
|
|
|
|
obj?.user?.name
|
2015-05-21 08:49:13 +08:00
|
|
|
|
2014-09-04 04:02:00 +08:00
|
|
|
Handlebars.registerHelper "isCurrentUserRaisingHand", ->
|
2015-05-06 04:15:33 +08:00
|
|
|
BBB.isCurrentUserRaisingHand()
|
2014-09-04 04:02:00 +08:00
|
|
|
|
2014-09-04 03:22:08 +08:00
|
|
|
Handlebars.registerHelper "isCurrentUserSharingVideo", ->
|
2014-11-12 21:30:34 +08:00
|
|
|
BBB.amISharingVideo()
|
2014-09-04 04:11:56 +08:00
|
|
|
|
|
|
|
Handlebars.registerHelper "isCurrentUserTalking", ->
|
2014-11-12 21:30:34 +08:00
|
|
|
BBB.amITalking()
|
2014-10-11 05:35:51 +08:00
|
|
|
|
2015-05-07 03:45:51 +08:00
|
|
|
Handlebars.registerHelper "isCurrentUserPresenter", ->
|
|
|
|
BBB.isUserPresenter(getInSession('userId'))
|
|
|
|
|
2014-11-04 22:20:55 +08:00
|
|
|
Handlebars.registerHelper "isDisconnected", ->
|
|
|
|
return !Meteor.status().connected
|
2014-10-11 05:35:51 +08:00
|
|
|
|
2015-04-14 21:34:41 +08:00
|
|
|
Handlebars.registerHelper "isUserInAudio", (userId) ->
|
|
|
|
BBB.isUserInAudio(userId)
|
|
|
|
|
|
|
|
Handlebars.registerHelper "isUserListenOnlyAudio", (userId) ->
|
|
|
|
BBB.isUserListenOnlyAudio(userId)
|
2014-10-11 05:35:51 +08:00
|
|
|
|
2014-11-22 01:28:50 +08:00
|
|
|
Handlebars.registerHelper "isUserMuted", (userId) ->
|
|
|
|
BBB.isUserMuted(userId)
|
2014-10-28 22:24:56 +08:00
|
|
|
|
2014-11-22 01:28:50 +08:00
|
|
|
Handlebars.registerHelper "isUserSharingVideo", (userId) ->
|
|
|
|
BBB.isUserSharingWebcam(userId)
|
2014-10-11 05:35:51 +08:00
|
|
|
|
2014-11-22 01:28:50 +08:00
|
|
|
Handlebars.registerHelper "isUserTalking", (userId) ->
|
|
|
|
BBB.isUserTalking(userId)
|
2014-10-11 05:35:51 +08:00
|
|
|
|
2015-03-20 05:36:03 +08:00
|
|
|
Handlebars.registerHelper 'isMobile', () ->
|
|
|
|
isMobile()
|
|
|
|
|
2015-04-17 00:55:56 +08:00
|
|
|
Handlebars.registerHelper 'isPortraitMobile', () ->
|
|
|
|
isPortraitMobile()
|
2015-03-28 08:59:56 +08:00
|
|
|
|
2015-04-01 07:44:16 +08:00
|
|
|
Handlebars.registerHelper 'isMobileChromeOrFirefox', () ->
|
|
|
|
isMobile() and ((getBrowserName() is 'Chrome') or (getBrowserName() is 'Firefox'))
|
|
|
|
|
2014-10-28 22:24:56 +08:00
|
|
|
Handlebars.registerHelper "meetingIsRecording", ->
|
2015-05-06 04:15:33 +08:00
|
|
|
BBB.isMeetingRecording()
|
2014-08-09 00:04:04 +08:00
|
|
|
|
2014-08-16 01:17:51 +08:00
|
|
|
Handlebars.registerHelper "messageFontSize", ->
|
2014-10-28 22:24:56 +08:00
|
|
|
style: "font-size: #{getInSession("messageFontSize")}px;"
|
2014-08-16 01:17:51 +08:00
|
|
|
|
2014-08-18 22:29:02 +08:00
|
|
|
Handlebars.registerHelper "pointerLocation", ->
|
|
|
|
currentPresentation = Meteor.Presentations.findOne({"presentation.current": true})
|
2014-11-03 06:14:16 +08:00
|
|
|
presentationId = currentPresentation?.presentation?.id
|
|
|
|
currentSlideDoc = Meteor.Slides.findOne({"presentationId": presentationId, "slide.current": true})
|
|
|
|
pointer = currentPresentation?.pointer
|
|
|
|
pointer.x = (- currentSlideDoc.slide.x_offset * 2 + currentSlideDoc.slide.width_ratio * pointer.x) / 100
|
|
|
|
pointer.y = (- currentSlideDoc.slide.y_offset * 2 + currentSlideDoc.slide.height_ratio * pointer.y) / 100
|
|
|
|
pointer
|
2014-08-18 22:29:02 +08:00
|
|
|
|
2014-10-28 22:24:56 +08:00
|
|
|
Handlebars.registerHelper "safeName", (str) ->
|
|
|
|
safeString(str)
|
|
|
|
|
2015-06-19 03:09:17 +08:00
|
|
|
###Handlebars.registerHelper "visibility", (section) ->
|
2014-10-24 23:09:58 +08:00
|
|
|
if getInSession "display_#{section}"
|
2014-12-03 06:52:03 +08:00
|
|
|
style: 'display:block;'
|
2014-10-24 23:09:58 +08:00
|
|
|
else
|
2015-06-19 03:09:17 +08:00
|
|
|
style: 'display:none;'###
|
|
|
|
|
|
|
|
Handlebars.registerHelper "visibility", (section) ->
|
|
|
|
style: 'display:block;'
|
2014-08-09 00:04:04 +08:00
|
|
|
|
2015-05-14 02:31:07 +08:00
|
|
|
Handlebars.registerHelper 'containerPosition', (section) ->
|
|
|
|
if getInSession 'display_usersList'
|
|
|
|
return 'moved-to-right'
|
2015-05-15 03:17:07 +08:00
|
|
|
else if getInSession 'display_menu'
|
|
|
|
return 'moved-to-left'
|
2015-05-14 02:31:07 +08:00
|
|
|
else
|
|
|
|
return ''
|
|
|
|
|
2015-05-28 01:29:59 +08:00
|
|
|
# vertically shrinks the whiteboard if the slide navigation controllers are present
|
|
|
|
Handlebars.registerHelper 'whiteboardSize', (section) ->
|
|
|
|
if BBB.isUserPresenter(getInSession('userId'))
|
|
|
|
return 'presenter-whiteboard'
|
|
|
|
else
|
|
|
|
return 'viewer-whiteboard'
|
|
|
|
|
2014-08-18 22:29:02 +08:00
|
|
|
# transform plain text links into HTML tags compatible with Flash client
|
|
|
|
@linkify = (str) ->
|
|
|
|
www = /(^|[^\/])(www\.[\S]+($|\b))/img
|
|
|
|
http = /\b(https?:\/\/[0-9a-z+|.,:;\/&?_~%#=@!-]*[0-9a-z+|\/&_~%#=@-])/img
|
|
|
|
str = str.replace http, "<a href='event:$1'><u>$1</u></a>"
|
|
|
|
str = str.replace www, "$1<a href='event:http://$2'><u>$2</u></a>"
|
|
|
|
|
2014-11-19 03:35:51 +08:00
|
|
|
@setInSession = (k, v) -> SessionAmplify.set k, v
|
2014-10-28 22:24:56 +08:00
|
|
|
|
|
|
|
@safeString = (str) ->
|
2014-11-06 23:27:43 +08:00
|
|
|
if typeof str is 'string'
|
2014-10-28 22:24:56 +08:00
|
|
|
str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
|
|
|
2014-07-14 22:46:02 +08:00
|
|
|
@toggleCam = (event) ->
|
2014-08-09 00:04:04 +08:00
|
|
|
# Meteor.Users.update {_id: context._id} , {$set:{"user.sharingVideo": !context.sharingVideo}}
|
2014-06-27 01:13:19 +08:00
|
|
|
# Meteor.call('userToggleCam', context._id, !context.sharingVideo)
|
2014-06-14 02:19:50 +08:00
|
|
|
|
2014-08-09 00:04:04 +08:00
|
|
|
@toggleChatbar = ->
|
2015-03-05 01:24:54 +08:00
|
|
|
if getInSession("display_chatbar") and isOnlyOnePanelOpen()
|
|
|
|
setInSession "display_usersList", true
|
|
|
|
setInSession "display_whiteboard", true
|
|
|
|
setInSession "display_chatbar", true
|
|
|
|
else
|
|
|
|
setInSession "display_chatbar", !getInSession "display_chatbar"
|
2014-12-17 07:27:39 +08:00
|
|
|
setTimeout(redrawWhiteboard, 0)
|
2014-08-09 00:04:04 +08:00
|
|
|
|
|
|
|
@toggleMic = (event) ->
|
2015-05-06 04:15:33 +08:00
|
|
|
BBB.toggleMyMic()
|
2014-08-09 00:04:04 +08:00
|
|
|
|
|
|
|
@toggleUsersList = ->
|
2015-06-19 03:09:17 +08:00
|
|
|
if $('.sl-left-drawer').hasClass('hiddenInLandscape')
|
|
|
|
$('.sl-left-drawer').removeClass('hiddenInLandscape')
|
|
|
|
else
|
|
|
|
$('.sl-left-drawer').addClass('hiddenInLandscape')
|
2014-12-17 07:27:39 +08:00
|
|
|
setTimeout(redrawWhiteboard, 0)
|
2014-08-09 00:04:04 +08:00
|
|
|
|
2015-06-25 08:21:50 +08:00
|
|
|
@populateNotifications = (msg) ->
|
|
|
|
myUserId = getInSession "userId"
|
|
|
|
users = Meteor.Users.find().fetch()
|
|
|
|
|
|
|
|
# assuming that I only have access only to private messages where I am the sender or the recipient
|
|
|
|
myPrivateChats = Meteor.Chat.find({'message.chat_type': 'PRIVATE_CHAT'}).fetch()
|
|
|
|
|
|
|
|
uniqueArray = []
|
|
|
|
for chat in myPrivateChats
|
|
|
|
if chat.message.to_userid is myUserId
|
|
|
|
uniqueArray.push({userId: chat.message.from_userid, username: chat.message.from_username})
|
|
|
|
if chat.message.from_userid is myUserId
|
|
|
|
uniqueArray.push({userId: chat.message.to_userid, username: chat.message.to_username})
|
|
|
|
|
|
|
|
#keep unique entries only
|
|
|
|
uniqueArray = uniqueArray.filter((itm, i, a) ->
|
|
|
|
i is a.indexOf(itm)
|
|
|
|
)
|
|
|
|
|
|
|
|
if msg.message.to_userid is myUserId
|
|
|
|
new_msg_userid = msg.message.from_userid
|
|
|
|
if msg.message.from_userid is myUserId
|
|
|
|
new_msg_userid = msg.message.to_userid
|
|
|
|
|
2015-07-10 05:59:57 +08:00
|
|
|
chats = getInSession('chats')
|
|
|
|
if chats is undefined
|
|
|
|
initChats = [
|
|
|
|
userId: "PUBLIC_CHAT"
|
|
|
|
gotMail: false
|
2015-07-11 04:42:10 +08:00
|
|
|
number: 0;
|
2015-07-10 05:59:57 +08:00
|
|
|
]
|
|
|
|
setInSession 'chats', initChats
|
|
|
|
|
2015-06-25 08:21:50 +08:00
|
|
|
#insert the unique entries in the collection
|
|
|
|
for u in uniqueArray
|
|
|
|
chats = getInSession('chats')
|
|
|
|
if chats.filter((chat) -> chat.userId == u.userId).length is 0 and u.userId is new_msg_userid
|
2015-07-11 04:42:10 +08:00
|
|
|
chats.push {userId: u.userId, gotMail: false, number: 0}
|
2015-06-25 08:21:50 +08:00
|
|
|
setInSession 'chats', chats
|
|
|
|
|
2015-06-19 04:14:54 +08:00
|
|
|
@toggleShield = ->
|
2015-07-27 23:54:46 +08:00
|
|
|
if parseFloat($('.shield').css('opacity')) is 0.5 # triggered during a pan gesture
|
|
|
|
$('.shield').css('opacity', '')
|
|
|
|
|
2015-07-28 05:28:00 +08:00
|
|
|
if !$('.shield').hasClass('darken') and !$('.shield').hasClass('animatedShield')
|
2015-06-19 04:14:54 +08:00
|
|
|
$('.shield').addClass('darken')
|
2015-07-28 05:28:00 +08:00
|
|
|
else
|
|
|
|
$('.shield').removeClass('darken')
|
|
|
|
$('.shield').removeClass('animatedShield')
|
2015-05-08 06:16:43 +08:00
|
|
|
|
2015-06-04 07:13:18 +08:00
|
|
|
@removeFullscreenStyles = ->
|
|
|
|
$('#whiteboard-paper').removeClass('verticallyCentered')
|
|
|
|
$('#chat').removeClass('invisible')
|
|
|
|
$('#users').removeClass('invisible')
|
|
|
|
$('#navbar').removeClass('invisible')
|
|
|
|
$('.fullscreenButton').removeClass('exitFullscreenButton')
|
|
|
|
$('.fullscreenButton').addClass('whiteboardFullscreenButton')
|
|
|
|
$('.fullscreenButton i').removeClass('ion-arrow-shrink')
|
|
|
|
$('.fullscreenButton i').addClass('ion-arrow-expand')
|
|
|
|
|
2015-06-03 05:44:06 +08:00
|
|
|
@enterWhiteboardFullscreen = ->
|
|
|
|
element = document.getElementById('whiteboard')
|
|
|
|
if element.requestFullscreen
|
|
|
|
element.requestFullscreen()
|
|
|
|
else if element.mozRequestFullScreen
|
|
|
|
element.mozRequestFullScreen()
|
2015-06-04 06:54:39 +08:00
|
|
|
$('.fullscreenButton').addClass('iconFirefox') # browser-specific icon sizing
|
2015-06-03 05:44:06 +08:00
|
|
|
else if element.webkitRequestFullscreen
|
|
|
|
element.webkitRequestFullscreen()
|
2015-06-04 06:54:39 +08:00
|
|
|
$('.fullscreenButton').addClass('iconChrome') # browser-specific icon sizing
|
2015-06-03 05:44:06 +08:00
|
|
|
else if element.msRequestFullscreen
|
|
|
|
element.msRequestFullscreen()
|
|
|
|
$('#chat').addClass('invisible')
|
|
|
|
$('#users').addClass('invisible')
|
|
|
|
$('#navbar').addClass('invisible')
|
2015-06-04 05:49:26 +08:00
|
|
|
$('.fullscreenButton').removeClass('whiteboardFullscreenButton')
|
|
|
|
$('.fullscreenButton').addClass('exitFullscreenButton')
|
2015-06-04 07:03:02 +08:00
|
|
|
$('.fullscreenButton i').removeClass('ion-arrow-expand')
|
|
|
|
$('.fullscreenButton i').addClass('ion-arrow-shrink')
|
2015-06-04 05:54:52 +08:00
|
|
|
$('#whiteboard-paper').addClass('verticallyCentered')
|
2015-06-03 05:44:06 +08:00
|
|
|
$('#whiteboard').bind 'webkitfullscreenchange', (e) ->
|
|
|
|
if document.webkitFullscreenElement is null
|
|
|
|
$('#whiteboard').unbind('webkitfullscreenchange')
|
2015-06-04 06:54:39 +08:00
|
|
|
$('.fullscreenButton').removeClass('iconChrome')
|
2015-06-04 07:13:18 +08:00
|
|
|
removeFullscreenStyles()
|
2015-06-03 05:44:06 +08:00
|
|
|
redrawWhiteboard()
|
|
|
|
$(document).bind 'mozfullscreenchange', (e) -> # target is always the document in Firefox
|
|
|
|
if document.mozFullScreenElement is null
|
|
|
|
$(document).unbind('mozfullscreenchange')
|
2015-06-04 06:54:39 +08:00
|
|
|
$('.fullscreenButton').removeClass('iconFirefox')
|
2015-06-04 07:13:18 +08:00
|
|
|
removeFullscreenStyles()
|
2015-06-03 05:44:06 +08:00
|
|
|
redrawWhiteboard()
|
|
|
|
|
2015-06-19 04:14:54 +08:00
|
|
|
@closeMenus = ->
|
|
|
|
if $('.sl-left-drawer').hasClass('sl-left-drawer-out')
|
|
|
|
toggleLeftDrawer()
|
|
|
|
toggleLeftArrowClockwise()
|
|
|
|
else if $('.sl-right-drawer').hasClass('sl-right-drawer-out')
|
|
|
|
toggleRightDrawer()
|
|
|
|
toggleRightArrowClockwise()
|
2015-05-08 06:16:43 +08:00
|
|
|
|
2015-04-15 20:48:16 +08:00
|
|
|
# Periodically check the status of the WebRTC call, when a call has been established attempt to hangup,
|
2015-04-15 20:02:39 +08:00
|
|
|
# retry if a call is in progress, send the leave voice conference message to BBB
|
2015-04-01 03:35:37 +08:00
|
|
|
@exitVoiceCall = (event) ->
|
2015-04-15 20:48:16 +08:00
|
|
|
# To be called when the hangup is initiated
|
2015-04-01 03:35:37 +08:00
|
|
|
hangupCallback = ->
|
2015-04-14 21:34:41 +08:00
|
|
|
console.log "Exiting Voice Conference"
|
|
|
|
|
2015-04-15 20:02:39 +08:00
|
|
|
# Checks periodically until a call is established so we can successfully end the call
|
|
|
|
# clean state
|
|
|
|
getInSession("triedHangup", false)
|
|
|
|
# function to initiate call
|
2015-04-15 20:48:16 +08:00
|
|
|
(checkToHangupCall = (context) ->
|
2015-04-15 20:02:39 +08:00
|
|
|
# if an attempt to hang up the call is made when the current session is not yet finished, the request has no effect
|
2015-04-15 20:48:16 +08:00
|
|
|
# keep track in the session if we haven't tried a hangup
|
2015-04-16 23:56:56 +08:00
|
|
|
if BBB.getCallStatus() isnt null and !getInSession("triedHangup")
|
2015-04-15 20:48:16 +08:00
|
|
|
console.log "Attempting to hangup on WebRTC call"
|
2015-04-15 20:02:39 +08:00
|
|
|
if BBB.amIListenOnlyAudio() # notify BBB-apps we are leaving the call call if we are listen only
|
2015-05-06 04:15:33 +08:00
|
|
|
Meteor.call('listenOnlyRequestToggle', BBB.getMeetingId(), getInSession("userId"), getInSession("authToken"), false)
|
2015-04-15 20:02:39 +08:00
|
|
|
BBB.leaveVoiceConference hangupCallback
|
|
|
|
getInSession("triedHangup", true) # we have hung up, prevent retries
|
2015-05-13 00:15:01 +08:00
|
|
|
notification_WebRTCAudioExited()
|
2015-04-15 20:02:39 +08:00
|
|
|
else
|
2015-04-15 20:48:16 +08:00
|
|
|
console.log "RETRYING hangup on WebRTC call in #{Meteor.config.app.WebRTCHangupRetryInterval} ms"
|
2015-04-15 20:02:39 +08:00
|
|
|
setTimeout checkToHangupCall, Meteor.config.app.WebRTCHangupRetryInterval # try again periodically
|
2015-04-15 20:48:16 +08:00
|
|
|
)(@) # automatically run function
|
2014-11-12 02:56:39 +08:00
|
|
|
return false
|
2014-06-14 02:19:50 +08:00
|
|
|
|
2015-04-06 22:29:25 +08:00
|
|
|
# close the daudio UI, then join the conference. If listen only send the request to the server
|
2015-04-01 03:35:37 +08:00
|
|
|
@joinVoiceCall = (event, {isListenOnly} = {}) ->
|
2015-05-13 01:56:20 +08:00
|
|
|
if !isWebRTCAvailable()
|
|
|
|
notification_WebRTCNotSupported()
|
|
|
|
return
|
|
|
|
|
2015-04-01 03:35:37 +08:00
|
|
|
isListenOnly ?= true
|
|
|
|
|
2015-04-02 23:11:35 +08:00
|
|
|
# create voice call params
|
|
|
|
joinCallback = (message) ->
|
2015-04-14 21:34:41 +08:00
|
|
|
console.log "Beginning WebRTC Conference Call"
|
2015-04-13 19:08:03 +08:00
|
|
|
|
2015-05-13 01:56:20 +08:00
|
|
|
notification_WebRTCAudioJoining()
|
2015-04-14 21:34:41 +08:00
|
|
|
if isListenOnly
|
2015-05-06 04:15:33 +08:00
|
|
|
Meteor.call('listenOnlyRequestToggle', BBB.getMeetingId(), getInSession("userId"), getInSession("authToken"), true)
|
2015-04-06 22:29:25 +08:00
|
|
|
BBB.joinVoiceConference joinCallback, isListenOnly # make the call #TODO should we apply role permissions to this action?
|
2015-04-03 04:11:09 +08:00
|
|
|
|
2015-04-02 23:11:35 +08:00
|
|
|
return false
|
2015-04-01 03:35:37 +08:00
|
|
|
|
2014-07-29 22:20:51 +08:00
|
|
|
# Starts the entire logout procedure.
|
2014-07-25 01:56:31 +08:00
|
|
|
# meeting: the meeting the user is in
|
|
|
|
# the user's userId
|
2014-07-28 23:00:07 +08:00
|
|
|
@userLogout = (meeting, user) ->
|
2014-11-21 23:05:03 +08:00
|
|
|
Meteor.call("userLogout", meeting, user, getInSession("authToken"))
|
2015-03-10 05:25:30 +08:00
|
|
|
console.log "logging out"
|
2015-03-11 04:58:51 +08:00
|
|
|
clearSessionVar(document.location = getInSession 'logoutURL') # navigate to logout
|
2014-07-25 01:56:31 +08:00
|
|
|
|
2014-12-06 02:53:53 +08:00
|
|
|
# Clear the local user session
|
2014-12-11 03:31:03 +08:00
|
|
|
@clearSessionVar = (callback) ->
|
2015-01-21 00:01:17 +08:00
|
|
|
amplify.store('authToken', null)
|
|
|
|
amplify.store('bbbServerVersion', null)
|
2015-06-25 08:21:50 +08:00
|
|
|
amplify.store('chats', null)
|
2015-01-21 00:01:17 +08:00
|
|
|
amplify.store('dateOfBuild', null)
|
|
|
|
amplify.store('display_chatPane', null)
|
|
|
|
amplify.store('display_chatbar', null)
|
|
|
|
amplify.store('display_navbar', null)
|
|
|
|
amplify.store('display_usersList', null)
|
|
|
|
amplify.store('display_whiteboard', null)
|
|
|
|
amplify.store('inChatWith', null)
|
2015-03-11 05:03:16 +08:00
|
|
|
amplify.store('logoutURL', null)
|
2015-01-21 00:01:17 +08:00
|
|
|
amplify.store('meetingId', null)
|
|
|
|
amplify.store('messageFontSize', null)
|
|
|
|
amplify.store('tabsRenderedTime', null)
|
|
|
|
amplify.store('userId', null)
|
|
|
|
amplify.store('userName', null)
|
2015-05-15 03:17:07 +08:00
|
|
|
amplify.store('display_menu', null)
|
2015-02-07 03:41:18 +08:00
|
|
|
if callback?
|
|
|
|
callback()
|
2014-10-24 23:09:58 +08:00
|
|
|
|
2014-12-06 03:04:46 +08:00
|
|
|
# assign the default values for the Session vars
|
|
|
|
@setDefaultSettings = ->
|
|
|
|
setInSession "display_navbar", true
|
|
|
|
setInSession "display_chatbar", true
|
|
|
|
setInSession "display_whiteboard", true
|
|
|
|
setInSession "display_chatPane", true
|
2015-07-22 04:59:25 +08:00
|
|
|
|
2015-07-10 05:59:57 +08:00
|
|
|
#if it is a desktop version of the client
|
2015-03-12 04:06:48 +08:00
|
|
|
if isPortraitMobile() or isLandscapeMobile()
|
2015-03-05 05:45:01 +08:00
|
|
|
setInSession "messageFontSize", Meteor.config.app.mobileFont
|
2015-07-10 05:59:57 +08:00
|
|
|
#if this is a mobile version of the client
|
2015-03-05 05:33:37 +08:00
|
|
|
else
|
2015-03-05 05:45:01 +08:00
|
|
|
setInSession "messageFontSize", Meteor.config.app.desktopFont
|
2015-01-07 07:49:41 +08:00
|
|
|
setInSession 'display_slidingMenu', false
|
2015-01-11 10:49:08 +08:00
|
|
|
setInSession 'display_hiddenNavbarSection', false
|
2015-05-14 01:13:40 +08:00
|
|
|
if isLandscape()
|
|
|
|
setInSession 'display_usersList', true
|
|
|
|
else
|
|
|
|
setInSession 'display_usersList', false
|
2015-05-15 03:17:07 +08:00
|
|
|
setInSession 'display_menu', false
|
2015-07-22 04:59:25 +08:00
|
|
|
setInSession 'chatInputMinHeight', 0
|
2015-07-10 05:59:57 +08:00
|
|
|
|
|
|
|
#keep notifications and an opened private chat tab if page was refreshed
|
|
|
|
#reset to default if that's a new user
|
|
|
|
if loginOrRefresh()
|
|
|
|
initChats = [
|
|
|
|
userId: "PUBLIC_CHAT"
|
|
|
|
gotMail: false
|
2015-07-11 04:42:10 +08:00
|
|
|
number: 0
|
2015-07-10 05:59:57 +08:00
|
|
|
]
|
|
|
|
setInSession 'chats', initChats
|
|
|
|
setInSession "inChatWith", 'PUBLIC_CHAT'
|
|
|
|
|
2015-06-09 03:16:57 +08:00
|
|
|
TimeSync.loggingEnabled = false # suppresses the log messages from timesync
|
2014-12-11 04:09:17 +08:00
|
|
|
|
2015-07-10 05:55:28 +08:00
|
|
|
#true if it is a new user, false if the client was just refreshed
|
|
|
|
@loginOrRefresh = ->
|
|
|
|
userId = getInSession 'userId'
|
|
|
|
checkId = getInSession 'checkId'
|
|
|
|
if checkId is undefined
|
|
|
|
setInSession 'checkId', userId
|
|
|
|
return true
|
|
|
|
else if userId isnt checkId
|
|
|
|
setInSession 'checkId', userId
|
|
|
|
return true
|
2015-07-22 04:59:25 +08:00
|
|
|
else
|
2015-07-10 05:55:28 +08:00
|
|
|
return false
|
|
|
|
|
2014-12-11 04:09:17 +08:00
|
|
|
@onLoadComplete = ->
|
2015-05-07 14:26:13 +08:00
|
|
|
document.title = "BigBlueButton #{BBB.getMeetingName() ? 'HTML5'}"
|
2014-12-11 04:09:17 +08:00
|
|
|
setDefaultSettings()
|
|
|
|
|
2014-12-18 02:34:12 +08:00
|
|
|
Meteor.Users.find().observe({
|
|
|
|
removed: (oldDocument) ->
|
|
|
|
if oldDocument.userId is getInSession 'userId'
|
2015-03-11 04:58:51 +08:00
|
|
|
document.location = getInSession 'logoutURL'
|
2014-12-11 04:09:17 +08:00
|
|
|
})
|
|
|
|
|
2015-03-10 05:30:25 +08:00
|
|
|
# Detects a mobile device
|
|
|
|
@isMobile = ->
|
|
|
|
navigator.userAgent.match(/Android/i) or
|
2015-03-12 03:38:14 +08:00
|
|
|
navigator.userAgent.match(/iPhone|iPad|iPod/i) or
|
|
|
|
navigator.userAgent.match(/BlackBerry/i) or
|
2015-03-10 05:30:25 +08:00
|
|
|
navigator.userAgent.match(/Windows Phone/i) or
|
2015-03-12 03:38:14 +08:00
|
|
|
navigator.userAgent.match(/IEMobile/i) or
|
2015-03-10 05:30:25 +08:00
|
|
|
navigator.userAgent.match(/BlackBerry/i) or
|
|
|
|
navigator.userAgent.match(/webOS/i)
|
2015-03-05 08:42:22 +08:00
|
|
|
|
2015-05-08 06:16:43 +08:00
|
|
|
@isLandscape = ->
|
2015-06-13 05:25:22 +08:00
|
|
|
not isMobile() and
|
|
|
|
window.matchMedia('(orientation: landscape)').matches and # browser is landscape
|
|
|
|
window.matchMedia('(min-device-aspect-ratio: 1/1)').matches # device is landscape
|
|
|
|
|
2015-07-22 04:59:25 +08:00
|
|
|
@isPortrait = ->
|
2015-06-13 05:25:22 +08:00
|
|
|
not isMobile() and
|
|
|
|
window.matchMedia('(orientation: portrait)').matches and # browser is portrait
|
|
|
|
window.matchMedia('(min-device-aspect-ratio: 1/1)').matches # device is landscape
|
2015-05-08 06:16:43 +08:00
|
|
|
|
2015-03-05 05:33:37 +08:00
|
|
|
# Checks if the view is portrait and a mobile device is being used
|
|
|
|
@isPortraitMobile = () ->
|
2015-03-12 03:38:14 +08:00
|
|
|
isMobile() and
|
2015-03-05 05:33:37 +08:00
|
|
|
window.matchMedia('(orientation: portrait)').matches and # browser is portrait
|
2015-03-12 03:38:14 +08:00
|
|
|
window.matchMedia('(max-device-aspect-ratio: 1/1)').matches # device is portrait
|
|
|
|
|
2015-03-04 23:51:28 +08:00
|
|
|
# Checks if the view is landscape and mobile device is being used
|
|
|
|
@isLandscapeMobile = () ->
|
2015-03-12 03:38:14 +08:00
|
|
|
isMobile() and
|
2015-06-13 05:25:22 +08:00
|
|
|
window.matchMedia('(orientation: landscape)').matches and # browser is landscape
|
|
|
|
window.matchMedia('(min-device-aspect-ratio: 1/1)').matches # device is landscape
|
2015-03-12 03:38:14 +08:00
|
|
|
|
2015-03-05 01:24:54 +08:00
|
|
|
# Checks if only one panel (userlist/whiteboard/chatbar) is currently open
|
|
|
|
@isOnlyOnePanelOpen = () ->
|
|
|
|
#(getInSession "display_usersList" ? 1 : 0) + (getInSession "display_whiteboard" ? 1 : 0) + (getInSession "display_chatbar" ? 1 : 0) is 1
|
|
|
|
getInSession("display_usersList") + getInSession("display_whiteboard") + getInSession("display_chatbar") is 1
|
2015-03-08 10:58:26 +08:00
|
|
|
|
2015-03-15 10:25:49 +08:00
|
|
|
# determines which browser is being used
|
|
|
|
@getBrowserName = () ->
|
2015-04-01 07:44:16 +08:00
|
|
|
if navigator.userAgent.match(/Chrome/i)
|
|
|
|
return 'Chrome'
|
|
|
|
else if navigator.userAgent.match(/Firefox/i)
|
|
|
|
return 'Firefox'
|
|
|
|
else if navigator.userAgent.match(/Safari/i)
|
2015-03-15 10:25:49 +08:00
|
|
|
return 'Safari'
|
|
|
|
else if navigator.userAgent.match(/Trident/i)
|
|
|
|
return 'IE'
|
|
|
|
else
|
|
|
|
return null
|
2015-07-22 04:59:25 +08:00
|
|
|
|
|
|
|
# changes the height of the chat input area if needed (based on the textarea content)
|
|
|
|
@adjustChatInputHeight = () ->
|
|
|
|
$('#newMessageInput').css('height', 'auto')
|
|
|
|
projectedHeight = $('#newMessageInput')[0].scrollHeight + 23
|
|
|
|
if projectedHeight isnt $('.panel-footer').height() and
|
|
|
|
projectedHeight >= getInSession('chatInputMinHeight')
|
|
|
|
$('#newMessageInput').css('overflow', 'hidden') # prevents a scroll bar
|
|
|
|
|
|
|
|
# resizes the chat input area
|
|
|
|
$('.panel-footer').css('top', - (projectedHeight - 70) + 'px')
|
|
|
|
$('.panel-footer').css('height', projectedHeight + 'px')
|
|
|
|
|
|
|
|
$('#newMessageInput').height($('#newMessageInput')[0].scrollHeight)
|
|
|
|
|
|
|
|
# resizes the chat messages container
|
|
|
|
$('#chatbody').height($('#chat').height() - projectedHeight - 45)
|
|
|
|
$('#chatbody').scrollTop($('#chatbody')[0]?.scrollHeight)
|
|
|
|
$('#newMessageInput').css('height', '')
|