2014-06-12 22:08:55 +08:00
|
|
|
Template.userItem.helpers
|
|
|
|
domain: ->
|
|
|
|
a = document.createElement("a")
|
|
|
|
a.href = @url
|
|
|
|
a.hostname
|
|
|
|
|
2014-06-13 03:12:09 +08:00
|
|
|
isUserModerator: =>
|
2014-06-14 00:22:30 +08:00
|
|
|
id = Session.get("userId") or "a1a1a1a1a1a1"
|
2014-06-20 05:29:52 +08:00
|
|
|
(Meteor.Users.findOne {"user.userId": id, "user.role": "MODERATOR"})?
|
2014-06-12 22:08:55 +08:00
|
|
|
|
|
|
|
# using handlebars' {{equals}} wasn't working for these some reason, so heres a simple JS function to do it
|
|
|
|
compareUserIds: (u1, u2) ->
|
|
|
|
u1 is u2
|
|
|
|
|
|
|
|
Template.userItem.events
|
2014-06-13 03:12:09 +08:00
|
|
|
"click .raiseHand": (event) ->
|
2014-06-20 05:29:52 +08:00
|
|
|
Meteor.Users.update {_id: @_id},{ $set:{ "user.handRaised": true}}
|
2014-06-12 22:08:55 +08:00
|
|
|
|
2014-06-13 03:12:09 +08:00
|
|
|
"click .disableCam": (event) ->
|
2014-06-20 05:29:52 +08:00
|
|
|
Meteor.Users.update {_id: @_id}, {$set:{ "user.sharingVideo": false}}
|
2014-06-12 22:08:55 +08:00
|
|
|
|
2014-06-13 03:12:09 +08:00
|
|
|
"click .disableMic": (event) ->
|
2014-06-20 05:29:52 +08:00
|
|
|
Meteor.Users.update { _id: @_id},{ $set:{"user.sharingAudio": false}}
|
2014-06-12 22:08:55 +08:00
|
|
|
|
2014-06-13 03:12:09 +08:00
|
|
|
"click .enableMic": (event) ->
|
2014-06-20 05:29:52 +08:00
|
|
|
Meteor.Users.update {_id: @_id}, {$set:{"user.sharingAudio": true}}
|
2014-06-12 22:08:55 +08:00
|
|
|
|
2014-06-13 03:12:09 +08:00
|
|
|
"click .enableCam": (event) ->
|
2014-06-20 05:29:52 +08:00
|
|
|
Meteor.Users.update {_id: @_id}, {$set:{ "user.sharingVideo": true}}
|
2014-06-12 22:08:55 +08:00
|
|
|
|
2014-06-13 03:12:09 +08:00
|
|
|
"click .lowerHand": (event) ->
|
2014-06-20 05:29:52 +08:00
|
|
|
Meteor.Users.update {_id: @_id}, {$set:{ "user.handRaised": false}}
|
2014-06-12 22:08:55 +08:00
|
|
|
|
2014-06-13 03:12:09 +08:00
|
|
|
"click .setPresenter": (event) ->
|
2014-06-23 21:17:19 +08:00
|
|
|
#do nothing if user is already presenter
|
2014-06-17 23:46:49 +08:00
|
|
|
unless @isPresenter
|
2014-06-23 21:17:19 +08:00
|
|
|
# find user account for new presenter
|
|
|
|
selectedUser = Meteor.Users.findOne(_id:@_id)
|
|
|
|
|
|
|
|
if selectedUser? # search for current presenter
|
|
|
|
originalPresenter = Meteor.Users.findOne(
|
|
|
|
meetingId: selectedUser.meetingId
|
2014-06-12 22:08:55 +08:00
|
|
|
"user.presenter": true
|
|
|
|
)
|
2014-06-23 21:17:19 +08:00
|
|
|
if originalPresenter? # unset old presenter
|
|
|
|
Meteor.Users.update {_id: originalPresenter._id},{ $set:{ "user.presenter": false}}
|
|
|
|
|
|
|
|
# set newly selected user as presenter
|
|
|
|
Meteor.Users.update {_id: selectedUser._id},{$set:{"user.presenter": true}}
|
2014-06-12 22:08:55 +08:00
|
|
|
|
2014-06-13 03:12:09 +08:00
|
|
|
"click .kickUser": (event) ->
|
2014-06-12 22:08:55 +08:00
|
|
|
#
|
|
|
|
# Add:
|
|
|
|
# When user is blown away, if they were presenter remove that from meeting (if kicking the presenter is even possible?)
|
|
|
|
#
|
2014-06-24 01:20:08 +08:00
|
|
|
# user = Meteor.Users.findOne(_id:@_id)
|
|
|
|
# meeting = Meetings.findOne(meetingName:user.meetingId)
|
|
|
|
|
|
|
|
# if user? and meeting?
|
|
|
|
# # find users index. I couldn't get indexOf() working
|
|
|
|
# index = -1
|
|
|
|
# i = 0
|
|
|
|
|
|
|
|
# while i < meeting.users.length
|
|
|
|
# if meeting.users[i].userId is user.user.externUserId
|
|
|
|
# index = i
|
|
|
|
# break
|
|
|
|
# i++
|
|
|
|
# if index >= 0
|
|
|
|
# meeting.users.splice index, 1 # remove user from meeting
|
|
|
|
# Meetings.update # update meeting
|
|
|
|
# _id: meeting._id
|
|
|
|
# ,
|
|
|
|
# $set:
|
|
|
|
# users: meeting.users
|
|
|
|
|
|
|
|
# Meteor.Users.update # remove meeting from user
|
|
|
|
# _id: @_id
|
|
|
|
# ,
|
|
|
|
# $set:
|
|
|
|
# meetingId: null
|
|
|
|
console.log "kicking user, logging @ here"
|
|
|
|
console.log @
|
|
|
|
Meteor.Users.update({_id:@_id}, {$set: {meetingId: ""}})
|
2014-06-17 01:45:17 +08:00
|
|
|
|
|
|
|
Template.displayOtherUsersControls.events
|
|
|
|
"click .disableMic": (event) ->
|
|
|
|
event.stopImmediatePropagation()
|
2014-06-20 05:29:52 +08:00
|
|
|
u = Meteor.Users.findOne {"user.externUserId": event.currentTarget.id}
|
|
|
|
Meteor.Users.update {_id: u._id}, {$set: {"user.sharingAudio": false}}
|
2014-06-17 01:45:17 +08:00
|
|
|
"click .enableMic": (event) ->
|
|
|
|
event.stopImmediatePropagation()
|
2014-06-20 05:29:52 +08:00
|
|
|
u = Meteor.Users.findOne {"user.externUserId": event.currentTarget.id}
|
|
|
|
Meteor.Users.update {_id: u._id}, {$set: {"user.sharingAudio": true}}
|
2014-06-17 01:45:17 +08:00
|
|
|
"click .disableCam": (event) ->
|
|
|
|
event.stopImmediatePropagation()
|
2014-06-20 05:29:52 +08:00
|
|
|
u = Meteor.Users.findOne {"user.externUserId": event.currentTarget.id}
|
|
|
|
Meteor.Users.update {_id: u._id}, {$set: {"user.sharingVideo": false}}
|
2014-06-17 01:45:17 +08:00
|
|
|
"click .enableCam": (event) ->
|
|
|
|
event.stopImmediatePropagation()
|
2014-06-20 05:29:52 +08:00
|
|
|
u = Meteor.Users.findOne {"user.externUserId": event.currentTarget.id}
|
|
|
|
Meteor.Users.update {_id: u._id}, {$set: {"user.sharingVideo": true}}
|
2014-06-17 01:45:17 +08:00
|
|
|
|
|
|
|
Template.displayOwnControls.events
|
|
|
|
"click .disableMic": (event) ->
|
|
|
|
event.stopImmediatePropagation()
|
2014-06-20 05:29:52 +08:00
|
|
|
u = Meteor.Users.findOne {"user.externUserId": event.currentTarget.id}
|
|
|
|
Meteor.Users.update {_id: u._id}, {$set: {"user.sharingAudio": false}}
|
2014-06-17 01:45:17 +08:00
|
|
|
"click .enableMic": (event) ->
|
|
|
|
event.stopImmediatePropagation()
|
2014-06-20 05:29:52 +08:00
|
|
|
u = Meteor.Users.findOne {"user.externUserId": event.currentTarget.id}
|
|
|
|
Meteor.Users.update {_id: u._id}, {$set: {"user.sharingAudio": true}}
|
2014-06-17 01:45:17 +08:00
|
|
|
"click .disableCam": (event) ->
|
|
|
|
event.stopImmediatePropagation()
|
2014-06-20 05:29:52 +08:00
|
|
|
u = Meteor.Users.findOne {"user.externUserId": event.currentTarget.id}
|
|
|
|
Meteor.Users.update {_id: u._id}, {$set: {"user.sharingVideo": false}}
|
2014-06-17 01:45:17 +08:00
|
|
|
"click .enableCam": (event) ->
|
|
|
|
event.stopImmediatePropagation()
|
2014-06-20 05:29:52 +08:00
|
|
|
u = Meteor.Users.findOne {"user.externUserId": event.currentTarget.id}
|
2014-06-23 21:21:03 +08:00
|
|
|
Meteor.Users.update {_id: u._id}, {$set: {"user.sharingVideo": true}}
|
|
|
|
|