2014-12-16 23:55:11 +08:00
|
|
|
@getBuildInformation = ->
|
2014-12-17 00:52:52 +08:00
|
|
|
appName = Meteor.config?.appName or "UNKNOWN NAME"
|
2014-12-16 23:55:11 +08:00
|
|
|
copyrightYear = Meteor.config?.copyrightYear or "UNKNOWN DATE"
|
|
|
|
dateOfBuild = Meteor.config?.dateOfBuild or "UNKNOWN DATE"
|
2014-12-17 00:52:52 +08:00
|
|
|
defaultWelcomeMessage = Meteor.config?.defaultWelcomeMessage or "UNKNOWN"
|
|
|
|
defaultWelcomeMessageFooter = Meteor.config?.defaultWelcomeMessageFooter or "UNKNOWN"
|
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
|
|
|
bbbServerVersion = Meteor.config?.bbbServerVersion or "UNKNOWN VERSION"
|
|
|
|
|
2014-12-16 23:55:11 +08:00
|
|
|
{
|
2014-12-17 00:52:52 +08:00
|
|
|
'appName': appName
|
2014-12-16 23:55:11 +08:00
|
|
|
'copyrightYear': copyrightYear
|
|
|
|
'dateOfBuild': dateOfBuild
|
2014-12-17 00:52:52 +08:00
|
|
|
'defaultWelcomeMessage': defaultWelcomeMessage
|
|
|
|
'defaultWelcomeMessageFooter': defaultWelcomeMessageFooter
|
2014-12-16 23:55:11 +08:00
|
|
|
'link': link
|
2014-12-17 00:52:52 +08:00
|
|
|
'bbbServerVersion': bbbServerVersion
|
2014-12-16 23:55:11 +08:00
|
|
|
}
|
|
|
|
|
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) ->
|
|
|
|
hex = parseInt(value).toString(16)
|
|
|
|
hex = "0" + hex while hex.length < 6
|
|
|
|
"##{hex}"
|
|
|
|
|
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
|
|
|
|
|
|
|
|
# thickness can be a number (e.g. "2") or a string (e.g. "2px")
|
|
|
|
@formatThickness = (thickness) ->
|
|
|
|
thickness ?= "1" # default value
|
|
|
|
if !thickness.toString().match(/.*px$/)
|
|
|
|
"#" + thickness + "px" # leading "#" - to be compatible with Firefox
|
|
|
|
thickness
|
|
|
|
|
|
|
|
@getCurrentSlideDoc = -> # returns only one document
|
|
|
|
currentPresentation = Meteor.Presentations.findOne({"presentation.current": true})
|
|
|
|
presentationId = currentPresentation?.presentation?.id
|
|
|
|
currentSlide = Meteor.Slides.findOne({"presentationId": presentationId, "slide.current": true})
|
|
|
|
|
2014-08-09 00:04:04 +08:00
|
|
|
# retrieve account for selected user
|
|
|
|
@getCurrentUserFromSession = ->
|
2014-11-22 01:28:50 +08:00
|
|
|
Meteor.Users.findOne(userId: getInSession("userId"))
|
2014-08-09 00:04:04 +08:00
|
|
|
|
|
|
|
@getInSession = (k) -> SessionAmplify.get k
|
|
|
|
|
|
|
|
@getMeetingName = ->
|
2015-01-20 22:55:03 +08:00
|
|
|
return Meteor.Meetings.findOne()?.meetingName or null
|
2014-08-09 00:04:04 +08:00
|
|
|
|
|
|
|
@getTime = -> # returns epoch in ms
|
|
|
|
(new Date).valueOf()
|
|
|
|
|
2014-09-25 03:55:55 +08:00
|
|
|
@getTimeOfJoining = ->
|
2014-11-22 01:28:50 +08:00
|
|
|
Meteor.Users.findOne(userId: getInSession "userId")?.user?.time_of_joining
|
2014-09-25 03:55:55 +08:00
|
|
|
|
2014-09-23 06:11:24 +08:00
|
|
|
@getPresentationFilename = ->
|
|
|
|
currentPresentation = Meteor.Presentations.findOne({"presentation.current": true})
|
|
|
|
currentPresentation?.presentation?.name
|
2014-10-28 22:24:56 +08:00
|
|
|
|
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-08-09 00:04:04 +08:00
|
|
|
# retrieve account for selected user
|
|
|
|
Handlebars.registerHelper "getCurrentUser", =>
|
|
|
|
@window.getCurrentUserFromSession()
|
|
|
|
|
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-01-20 22:55:03 +08:00
|
|
|
return Meteor.Meetings.findOne()?.meetingName or null
|
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-03-10 22:41:14 +08:00
|
|
|
"Presentation: " + (getPresentationFilename() or "Loading...")
|
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
|
|
|
|
|
|
|
Handlebars.registerHelper "isCurrentUserRaisingHand", ->
|
2014-11-12 21:30:34 +08:00
|
|
|
user = BBB.getCurrentUser()
|
2014-10-15 04:25:45 +08:00
|
|
|
user?.user?.raise_hand
|
2014-09-04 04:02:00 +08:00
|
|
|
|
2014-09-04 03:22:08 +08:00
|
|
|
Handlebars.registerHelper "isCurrentUserSharingAudio", ->
|
2014-11-12 21:30:34 +08:00
|
|
|
BBB.amISharingAudio()
|
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
|
|
|
|
2014-11-04 22:20:55 +08:00
|
|
|
Handlebars.registerHelper "isDisconnected", ->
|
|
|
|
return !Meteor.status().connected
|
2014-10-11 05:35:51 +08:00
|
|
|
|
2014-11-22 01:28:50 +08:00
|
|
|
Handlebars.registerHelper "isUserListenOnly", (userId) ->
|
|
|
|
user = Meteor.Users.findOne({userId:userId})
|
2014-10-24 23:09:58 +08:00
|
|
|
return user?.user?.listenOnly
|
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 "isUserSharingAudio", (userId) ->
|
|
|
|
BBB.isUserSharingAudio(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-01-11 10:49:08 +08:00
|
|
|
Handlebars.registerHelper 'isPortraitMobile', () ->
|
2015-03-02 22:59:43 +08:00
|
|
|
window.matchMedia('(orientation: portrait)').matches and window.matchMedia('(max-device-aspect-ratio: 1/1)').matches
|
2015-01-11 10:49:08 +08:00
|
|
|
|
2014-10-28 22:24:56 +08:00
|
|
|
Handlebars.registerHelper "meetingIsRecording", ->
|
|
|
|
Meteor.Meetings.findOne()?.recorded # Should only ever have one meeting, so we dont need any filter and can trust result #1
|
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)
|
|
|
|
|
2014-08-09 00:04:04 +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
|
2014-12-03 00:23:30 +08:00
|
|
|
style: 'display:none;'
|
2014-08-09 00:04:04 +08:00
|
|
|
|
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-10-28 22:24:56 +08:00
|
|
|
# check the chat history of the user and add tabs for the private chats
|
2014-11-22 11:26:02 +08:00
|
|
|
@populateChatTabs = (msg) ->
|
2014-11-28 06:02:19 +08:00
|
|
|
myUserId = getInSession "userId"
|
2014-10-28 22:24:56 +08:00
|
|
|
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
|
2014-11-28 06:02:19 +08:00
|
|
|
if chat.message.to_userid is myUserId
|
2014-10-28 22:24:56 +08:00
|
|
|
uniqueArray.push({userId: chat.message.from_userid, username: chat.message.from_username})
|
2014-11-28 06:02:19 +08:00
|
|
|
if chat.message.from_userid is myUserId
|
2014-10-28 22:24:56 +08:00
|
|
|
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)
|
|
|
|
)
|
2014-12-01 10:39:33 +08:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2014-10-28 22:24:56 +08:00
|
|
|
#insert the unique entries in the collection
|
|
|
|
for u in uniqueArray
|
2014-11-22 11:26:02 +08:00
|
|
|
tabs = getInSession('chatTabs')
|
2014-12-01 10:39:33 +08:00
|
|
|
if tabs.filter((tab) -> tab.userId == u.userId).length is 0 and u.userId is new_msg_userid
|
2014-11-22 11:26:02 +08:00
|
|
|
tabs.push {userId: u.userId, name: u.username, gotMail: false, class: 'privateChatTab'}
|
|
|
|
setInSession 'chatTabs', tabs
|
2014-10-28 22:24:56 +08:00
|
|
|
|
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) ->
|
2014-11-22 01:28:50 +08:00
|
|
|
u = Meteor.Users.findOne({userId:getInSession("userId")})
|
2014-10-15 05:20:27 +08:00
|
|
|
if u?
|
2014-11-22 01:36:21 +08:00
|
|
|
Meteor.call('muteUser', getInSession("meetingId"), u.userId, getInSession("userId"), getInSession("authToken"), not u.user.voiceUser.muted)
|
2014-08-09 00:04:04 +08:00
|
|
|
|
|
|
|
@toggleNavbar = ->
|
|
|
|
setInSession "display_navbar", !getInSession "display_navbar"
|
|
|
|
|
|
|
|
# toggle state of session variable
|
|
|
|
@toggleUsersList = ->
|
2015-03-05 01:24:54 +08:00
|
|
|
if getInSession("display_usersList") and isOnlyOnePanelOpen()
|
|
|
|
setInSession "display_usersList", true
|
|
|
|
setInSession "display_whiteboard", true
|
|
|
|
setInSession "display_chatbar", true
|
|
|
|
else
|
|
|
|
setInSession "display_usersList", !getInSession "display_usersList"
|
2014-12-17 07:27:39 +08:00
|
|
|
setTimeout(redrawWhiteboard, 0)
|
2014-08-09 00:04:04 +08:00
|
|
|
|
2014-10-24 23:09:58 +08:00
|
|
|
@toggleVoiceCall = (event) ->
|
2014-12-16 05:16:35 +08:00
|
|
|
if BBB.amISharingAudio()
|
2014-11-12 02:56:39 +08:00
|
|
|
hangupCallback = ->
|
|
|
|
console.log "left voice conference"
|
2014-11-19 06:44:52 +08:00
|
|
|
BBB.leaveVoiceConference hangupCallback #TODO should we apply role permissions to this action?
|
2014-11-12 02:56:39 +08:00
|
|
|
else
|
|
|
|
# create voice call params
|
|
|
|
joinCallback = (message) ->
|
|
|
|
console.log "started webrtc_call"
|
2014-11-19 06:44:52 +08:00
|
|
|
BBB.joinVoiceConference joinCallback # make the call #TODO should we apply role permissions to this action?
|
2014-11-12 02:56:39 +08:00
|
|
|
return false
|
2014-06-14 02:19:50 +08:00
|
|
|
|
2014-08-01 21:51:45 +08:00
|
|
|
@toggleWhiteBoard = ->
|
2015-03-05 01:24:54 +08:00
|
|
|
if getInSession("display_whiteboard") and isOnlyOnePanelOpen()
|
|
|
|
setInSession "display_usersList", true
|
|
|
|
setInSession "display_whiteboard", true
|
|
|
|
setInSession "display_chatbar", true
|
|
|
|
else
|
|
|
|
setInSession "display_whiteboard", !getInSession "display_whiteboard"
|
2014-12-17 07:27:39 +08:00
|
|
|
setTimeout(redrawWhiteboard, 0)
|
2014-06-19 22:45:58 +08:00
|
|
|
|
2014-12-30 10:08:16 +08:00
|
|
|
@toggleSlidingMenu = ->
|
|
|
|
if $('#sliding-menu').hasClass('sliding-menu-opened')
|
2015-03-08 10:58:26 +08:00
|
|
|
DestroyFixedView()
|
2015-01-07 07:49:41 +08:00
|
|
|
setInSession 'display_slidingMenu', false
|
2014-12-30 10:08:16 +08:00
|
|
|
$('#sliding-menu').removeClass('sliding-menu-opened')
|
2015-03-06 01:25:11 +08:00
|
|
|
$('#shield').css('display', 'none')
|
2015-01-07 07:07:25 +08:00
|
|
|
$(document).unbind('scroll')
|
2014-12-30 10:08:16 +08:00
|
|
|
else
|
2015-03-08 10:58:26 +08:00
|
|
|
CreateFixedView()
|
2015-01-07 07:49:41 +08:00
|
|
|
setInSession 'display_slidingMenu', true
|
2014-12-30 10:08:16 +08:00
|
|
|
$('#sliding-menu').addClass('sliding-menu-opened')
|
2015-03-06 01:25:11 +08:00
|
|
|
$('#shield').css('display', 'block')
|
2015-01-07 07:07:25 +08:00
|
|
|
$(document).bind 'scroll', () ->
|
|
|
|
window.scrollTo(0, 0)
|
2014-12-30 10:08:16 +08:00
|
|
|
|
2015-01-11 10:49:08 +08:00
|
|
|
@toggleNavbarCollapse = ->
|
|
|
|
setInSession 'display_hiddenNavbarSection', !getInSession 'display_hiddenNavbarSection'
|
|
|
|
if getInSession 'display_hiddenNavbarSection'
|
2015-01-13 05:47:10 +08:00
|
|
|
$('.navbarTitle').addClass('narrowedNavbarTitle');
|
2015-01-11 10:49:08 +08:00
|
|
|
$('.collapseNavbarSection').css('display', 'block')
|
|
|
|
else
|
|
|
|
$('.collapseNavbarSection').css('display', 'none')
|
2015-01-13 05:47:10 +08:00
|
|
|
$('.navbarTitle').removeClass('narrowedNavbarTitle');
|
2015-01-11 10:49:08 +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)
|
|
|
|
amplify.store('chatTabs', null)
|
|
|
|
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-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 = ->
|
2015-02-27 06:19:38 +08:00
|
|
|
# console.log "in setDefaultSettings"
|
2015-03-04 23:51:28 +08:00
|
|
|
if isLandscapeMobile()
|
|
|
|
setInSession "display_usersList", false
|
|
|
|
else
|
|
|
|
setInSession "display_usersList", true
|
2014-12-06 03:04:46 +08:00
|
|
|
setInSession "display_navbar", true
|
|
|
|
setInSession "display_chatbar", true
|
|
|
|
setInSession "display_whiteboard", true
|
|
|
|
setInSession "display_chatPane", true
|
|
|
|
setInSession "inChatWith", 'PUBLIC_CHAT'
|
2015-03-05 05:33:37 +08:00
|
|
|
if isPortraitMobile()
|
2015-03-05 05:45:01 +08:00
|
|
|
setInSession "messageFontSize", Meteor.config.app.mobileFont
|
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
|
2014-12-06 03:04:46 +08:00
|
|
|
|
2014-12-11 04:09:17 +08:00
|
|
|
|
|
|
|
@onLoadComplete = ->
|
|
|
|
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
|
|
|
})
|
|
|
|
|
2014-09-13 04:26:25 +08:00
|
|
|
# applies zooming to the stroke thickness
|
|
|
|
@zoomStroke = (thickness) ->
|
2014-09-16 00:46:02 +08:00
|
|
|
currentSlide = @getCurrentSlideDoc()
|
2014-09-13 04:26:25 +08:00
|
|
|
ratio = (currentSlide?.slide.width_ratio + currentSlide?.slide.height_ratio) / 2
|
|
|
|
thickness * 100 / ratio
|
2014-09-16 00:46:02 +08:00
|
|
|
|
2015-03-10 05:30:25 +08:00
|
|
|
# Detects a mobile device
|
|
|
|
@isMobile = ->
|
|
|
|
navigator.userAgent.match(/Android/i) or
|
|
|
|
navigator.userAgent.match(/iPad/i) or
|
|
|
|
navigator.userAgent.match(/iPhone/i) or
|
|
|
|
navigator.userAgent.match(/iPod/i) or
|
|
|
|
navigator.userAgent.match(/Windows Phone/i) or
|
|
|
|
navigator.userAgent.match(/BlackBerry/i) or
|
|
|
|
navigator.userAgent.match(/webOS/i)
|
2015-03-05 08:42:22 +08:00
|
|
|
|
2015-03-05 05:33:37 +08:00
|
|
|
# Checks if the view is portrait and a mobile device is being used
|
|
|
|
@isPortraitMobile = () ->
|
|
|
|
window.matchMedia('(orientation: portrait)').matches and # browser is portrait
|
|
|
|
window.matchMedia('(max-device-aspect-ratio: 1/1)').matches and # device is portrait
|
|
|
|
(navigator.userAgent.match(/Android/i) or # device is one of the following mobile devices:
|
|
|
|
navigator.userAgent.match(/iPhone|iPad|iPod/i) or
|
|
|
|
navigator.userAgent.match(/BlackBerry/i) or
|
|
|
|
navigator.userAgent.match(/Opera Mini/i) or
|
|
|
|
navigator.userAgent.match(/IEMobile/i) or
|
2015-03-05 08:42:22 +08:00
|
|
|
navigator.userAgent.match(/webOS/i))
|
|
|
|
|
2015-03-04 23:51:28 +08:00
|
|
|
# Checks if the view is landscape and mobile device is being used
|
|
|
|
@isLandscapeMobile = () ->
|
|
|
|
window.matchMedia('(orientation: landscape)').matches and # browser is landscape
|
|
|
|
window.matchMedia('(min-device-aspect-ratio: 1/1)').matches and # device is landscape
|
|
|
|
(navigator.userAgent.match(/Android/i) or # device is one of the mobile gadgets
|
|
|
|
navigator.userAgent.match(/iPad/i) or
|
|
|
|
navigator.userAgent.match(/iPhone/i) or
|
|
|
|
navigator.userAgent.match(/iPod/i) or
|
|
|
|
navigator.userAgent.match(/Windows Phone/i) or
|
|
|
|
navigator.userAgent.match(/BlackBerry/i) or
|
|
|
|
navigator.userAgent.match(/webOS/i))
|
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
|
|
|
|
|
|
|
# Reverts all the changes to userlist, whiteboard and chat made by the push menu
|
|
|
|
@DestroyFixedView = () ->
|
|
|
|
|
|
|
|
$('#chat').css('position', '')
|
|
|
|
$('#chat').css('top', '')
|
|
|
|
$('#chat').css('left', '')
|
|
|
|
|
|
|
|
$('#users').css('position', '')
|
|
|
|
$('#users').css('top', '')
|
|
|
|
$('#users').css('left', '')
|
|
|
|
|
|
|
|
$('#whiteboard').css('position', '')
|
|
|
|
$('#whiteboard').css('top', '')
|
|
|
|
$('#whiteboard').css('left', '')
|
|
|
|
|
|
|
|
$('#footer').css('position', '')
|
|
|
|
$('#footer').css('top', '')
|
|
|
|
$('#footer').css('left', '')
|
|
|
|
|
|
|
|
$('#chat').css('height', '')
|
|
|
|
$('#users').css('height', '')
|
|
|
|
$('#users').css('width', '')
|
|
|
|
$('#whiteboard').css('height', '')
|
|
|
|
$('#footer').css('height', '')
|
|
|
|
$('#footer').css('width', '')
|
|
|
|
|
|
|
|
# pushing the view back
|
|
|
|
$('#main').css('position', 'relative')
|
|
|
|
$('#main').css('top', '0')
|
|
|
|
$('#main').css('left', '0')
|
|
|
|
|
|
|
|
# Makes the position of userlist, whiteboard and chat fixed (to disable scrolling) and
|
|
|
|
# positions each element correctly
|
|
|
|
@CreateFixedView = () ->
|
|
|
|
|
|
|
|
# positioning the whiteboard
|
|
|
|
|
|
|
|
if getInSession 'display_whiteboard'
|
|
|
|
whiteboardHeight = $('#whiteboard').height()
|
|
|
|
$('#whiteboard').css('position', 'fixed')
|
|
|
|
$('#whiteboard').css('left', '15%')
|
|
|
|
$('#whiteboard').css('height', whiteboardHeight + 5 + 'px')
|
|
|
|
$('#whiteboard').css('top', '100px')
|
|
|
|
|
|
|
|
# positioning the chatbar
|
|
|
|
|
|
|
|
if getInSession 'display_chatbar'
|
|
|
|
chatHeight = $('#chat').height()
|
|
|
|
$('#chat').css('position', 'fixed')
|
|
|
|
$('#chat').css('left', '15%')
|
|
|
|
$('#chat').css('height', chatHeight)
|
|
|
|
if getInSession 'display_whiteboard'
|
|
|
|
$('#chat').css('top', 110 + $('#whiteboard').height() + 'px')
|
|
|
|
else
|
|
|
|
$('#chat').css('top', '100px')
|
|
|
|
|
|
|
|
# positioning the userlist
|
|
|
|
|
|
|
|
if getInSession 'display_usersList'
|
|
|
|
chatHeight = $('#chat').height()
|
|
|
|
usersHeight = $('#users').height()
|
|
|
|
usersWidth = $('#users').width()
|
|
|
|
|
|
|
|
$('#users').css('position', 'fixed')
|
|
|
|
$('#users').css('left', '15%')
|
|
|
|
$('#users').css('width', usersWidth) # prevents from shrinking
|
|
|
|
$('#users').css('height', usersHeight)
|
|
|
|
|
|
|
|
top = 100 # minimum margin for the userlist (height of the navbar)
|
|
|
|
if getInSession 'display_whiteboard'
|
|
|
|
top += $('#whiteboard').height() + 10
|
|
|
|
if getInSession 'display_chatbar'
|
|
|
|
top += chatHeight + 15
|
|
|
|
$('#users').css('top', top + 'px')
|
|
|
|
|
|
|
|
# positioning the footer
|
|
|
|
|
|
|
|
chatHeight = $('#chat').height()
|
|
|
|
usersHeight = $('#users').height()
|
|
|
|
footerHeight = $('#footer').height()
|
|
|
|
footerWidth = $('#footer').width()
|
|
|
|
|
|
|
|
$('#footer').css('position', 'fixed')
|
|
|
|
$('#footer').css('left', '15%')
|
|
|
|
$('#footer').css('height', footerHeight)
|
|
|
|
$('#footer').css('width', footerWidth) # prevents from shrinking
|
|
|
|
|
|
|
|
top = 100
|
|
|
|
if getInSession 'display_whiteboard'
|
|
|
|
top += $('#whiteboard').height() + 10
|
|
|
|
if getInSession 'display_chatbar'
|
|
|
|
top += chatHeight + 15
|
|
|
|
if getInSession 'display_usersList'
|
|
|
|
top += usersHeight + 30
|
|
|
|
$('#footer').css('top', top + 'px')
|
|
|
|
|
|
|
|
# pusing the rest of the page right
|
|
|
|
|
|
|
|
$('#main').css('position', 'fixed')
|
|
|
|
$('#main').css('top', '50px')
|
|
|
|
$('#main').css('left', '15%')
|