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-06-14 02:19:50 +08:00
|
|
|
# Allow access through all templates
|
|
|
|
Handlebars.registerHelper "setInSession", (k, v) -> Session.set k, v
|
|
|
|
Handlebars.registerHelper "getInSession", (k) -> Session.get k
|
|
|
|
# Allow access throughout all coffeescript/js files
|
|
|
|
@setInSession = (k, v) -> Session.set k, v
|
|
|
|
@getInSession = (k) -> Session.get k
|
|
|
|
|
2014-06-26 02:51:16 +08:00
|
|
|
# retrieve account for selected user
|
2014-06-14 02:19:50 +08:00
|
|
|
@getCurrentUserFromSession = ->
|
2014-06-26 02:51:16 +08:00
|
|
|
Meteor.Users.findOne("userId": Session.get("userId"))
|
2014-06-14 02:19:50 +08:00
|
|
|
|
|
|
|
# retrieve account for selected user
|
|
|
|
Handlebars.registerHelper "getCurrentUser", =>
|
|
|
|
@window.getCurrentUserFromSession()
|
|
|
|
|
|
|
|
# toggle state of field in the database
|
|
|
|
@toggleCam = (context) ->
|
2014-06-27 01:13:19 +08:00
|
|
|
# Meteor.Users.update {_id: context._id} , {$set:{"user.sharingVideo": !context.sharingVideo}}
|
|
|
|
# Meteor.call('userToggleCam', context._id, !context.sharingVideo)
|
2014-06-14 02:19:50 +08:00
|
|
|
|
|
|
|
@toggleMic = (context) ->
|
2014-06-27 01:13:19 +08:00
|
|
|
# Meteor.Users.update {_id: context._id} , {$set:{"user.sharingAudio": !context.sharingAudio}}
|
|
|
|
# Meteor.call('userToggleMic', context._id, !context.sharingAudio)
|
2014-06-14 02:19:50 +08:00
|
|
|
|
|
|
|
# toggle state of session variable
|
|
|
|
@toggleUsersList = ->
|
2014-06-19 21:26:46 +08:00
|
|
|
setInSession "display_usersList", !getInSession "display_usersList"
|
2014-06-14 02:19:50 +08:00
|
|
|
|
|
|
|
@toggleNavbar = ->
|
2014-06-19 21:26:46 +08:00
|
|
|
setInSession "display_navbar", !getInSession "display_navbar"
|
|
|
|
|
|
|
|
@toggleChatbar = ->
|
2014-06-19 22:45:58 +08:00
|
|
|
setInSession "display_chatbar", !getInSession "display_chatbar"
|
|
|
|
|
|
|
|
Meteor.methods
|
|
|
|
sendMeetingInfoToClient: (meetingId, userId) ->
|
2014-06-19 23:36:51 +08:00
|
|
|
Session.set("userId", userId)
|
2014-06-23 21:21:03 +08:00
|
|
|
Session.set("meetingId", meetingId)
|
2014-07-03 00:17:05 +08:00
|
|
|
Session.set("currentChatId", meetingId)
|
2014-07-09 21:28:33 +08:00
|
|
|
Session.set("meetingName", null)
|
2014-06-27 01:13:19 +08:00
|
|
|
Session.set("bbbServerVersion", "0.90")
|
2014-07-09 21:15:50 +08:00
|
|
|
Session.set("userName", null)
|
|
|
|
|
|
|
|
@getUsersName = ->
|
|
|
|
name = Session.get("userName") # check if we actually have one in the session
|
|
|
|
if name? then name # great return it, no database query
|
|
|
|
else # we need it from the database
|
|
|
|
user = Meteor.Users.findOne({'meetingId': Session.get("meetingId"), 'userId': Session.get("userId")})
|
|
|
|
if user?.user?.name
|
|
|
|
Session.set "userName", user.user.name # store in session for fast access next time
|
|
|
|
user.user.name
|
|
|
|
else null
|
2014-06-24 00:58:30 +08:00
|
|
|
|
2014-07-09 21:28:33 +08:00
|
|
|
# @getMeetingName = ->
|
|
|
|
# name = Session.get("meetingName") # check if we actually have one in the session
|
|
|
|
# if name? then name # great return it, no database query
|
|
|
|
# else # we need it from the database
|
|
|
|
# meet = Meteor.Meetings.findOne({'meetingId': Session.get("meetingId")})
|
|
|
|
# if meet?.name
|
|
|
|
# Session.set "meetingName", meet?.name # store in session for fast access next time
|
|
|
|
# meet?.name
|
|
|
|
# else null
|
|
|
|
|
|
|
|
|
2014-06-24 00:58:30 +08:00
|
|
|
Handlebars.registerHelper "isUserSharingAudio", (u) ->
|
|
|
|
u.voiceUser.talking
|
|
|
|
|
|
|
|
Handlebars.registerHelper "isUserSharingVideo", (u) ->
|
|
|
|
u.webcam_stream.length isnt 0
|
|
|
|
|
2014-06-27 21:59:31 +08:00
|
|
|
Handlebars.registerHelper "isCurrentUser", (id) ->
|
|
|
|
id is Session.get "userId"
|
|
|
|
|
|
|
|
# retrieves all users in the meeting
|
2014-06-25 02:10:02 +08:00
|
|
|
Handlebars.registerHelper "getUsersInMeeting", ->
|
2014-07-09 21:15:50 +08:00
|
|
|
Meteor.Users.find({})
|
2014-07-07 23:30:17 +08:00
|
|
|
|