pushing changes to carry over work between computers
This commit is contained in:
parent
bcc1dcf34d
commit
6dcf442f1b
@ -23,28 +23,30 @@ define [
|
||||
|
||||
_registerEvents: ->
|
||||
|
||||
#globals.events.on "connection:user_list_change", (users) =>
|
||||
# globals.events.trigger("users:user_list_change", users)
|
||||
|
||||
globals.events.on "connection:load_users", (users) =>
|
||||
#alert "load users"
|
||||
for userBlock in users
|
||||
@add [
|
||||
new UserModel {id: userBlock.id, userid: userBlock.id, username: userBlock.name}
|
||||
]
|
||||
alert "onload "+@length
|
||||
globals.events.trigger("users:load_users", users)
|
||||
|
||||
globals.events.on "connection:user_join", (userid, username) =>
|
||||
users = @toJSON()
|
||||
alert ("sending users: " + users)
|
||||
globals.events.trigger("there_you_go", users)
|
||||
#globals.events.on "getUsers", =>
|
||||
#users = @toJSON()
|
||||
#globals.events.trigger("receiveUsers", users)
|
||||
|
||||
globals.events.on "connection:user_join", (newUserid, newUsername) =>
|
||||
unless @get(newUserid)? #check if the user is already present
|
||||
#newUser = new UserModel {id: newUserid, userid: newUserid, username: newUsername}
|
||||
newUser = new UserModel()
|
||||
newUser.id = newUserid
|
||||
newUser.userid = newUserid
|
||||
newUser.username = newUsername
|
||||
|
||||
unless @get(userid)? #check if the user is already present
|
||||
@add [
|
||||
new UserModel {id: userid, userid: userid, username: username}
|
||||
newUser
|
||||
]
|
||||
alert "on join "+@length
|
||||
globals.events.trigger("users:user_join", userid, username)
|
||||
globals.events.trigger("user:add_new_user", newUser)
|
||||
|
||||
globals.events.on "connection:user_left", (userid) =>
|
||||
toDel = @get(userid)
|
||||
@ -55,8 +57,6 @@ define [
|
||||
globals.events.on "connection:setPresenter", (userid) =>
|
||||
globals.events.trigger("users:setPresenter", userid)
|
||||
|
||||
|
||||
|
||||
render: ->
|
||||
alert "user collection rendering"
|
||||
|
||||
|
@ -12,11 +12,16 @@ define [
|
||||
userid: null
|
||||
username: null
|
||||
|
||||
initialize: ->
|
||||
#alert "creation"
|
||||
initialize: ->
|
||||
#alert("iiiiiinitialize"+newUserid+" "+newUsername)
|
||||
console.log "creation"
|
||||
|
||||
isValid: ->
|
||||
console.log "inside is valid- id: #{@id} userid: #{@userid} username: #{@username}"
|
||||
value = @id? and @userid? and @username?
|
||||
|
||||
render: ->
|
||||
compiledTemplate = _.template(userTemplate, {userID: @userid, username: @username})
|
||||
_.template(userTemplate, {userID: @userid, username: @username})
|
||||
|
||||
|
||||
UserModel
|
@ -8,10 +8,11 @@ define [
|
||||
'cs!views/session_navbar_hidden',
|
||||
'cs!views/session_chat',
|
||||
'cs!views/session_users',
|
||||
'cs!views/SingleUserView',
|
||||
'cs!views/session_video'
|
||||
'cs!views/session_whiteboard'
|
||||
], ($, _, Backbone, globals, sessionTemplate, SessionNavbarView, SessionNavbarHiddenView,
|
||||
SessionChatView, SessionUsersView, SessionVideoView, SessionWhiteboardView) ->
|
||||
SessionChatView, SessionUsersView, SingleUserView, SessionVideoView, SessionWhiteboardView) ->
|
||||
|
||||
SessionView = Backbone.View.extend
|
||||
tagName: 'section'
|
||||
@ -23,6 +24,7 @@ define [
|
||||
@navbarHiddenView = new SessionNavbarHiddenView()
|
||||
@navbarHiddenView.$parentEl = @$el
|
||||
@chatView = new SessionChatView()
|
||||
@singleUserView = new SingleUserView()
|
||||
@usersView = new SessionUsersView()
|
||||
@videoView = new SessionVideoView()
|
||||
@whiteboardView = new SessionWhiteboardView()
|
||||
|
@ -19,10 +19,9 @@ define [
|
||||
"click .user": "_userClicked"
|
||||
|
||||
initialize: ->
|
||||
@userListID = "#user-list"
|
||||
userListID = "#user-list"
|
||||
@model.start()
|
||||
@self = @
|
||||
#globals.events.trigger "getUsers"
|
||||
@users = null
|
||||
|
||||
# Bind to the event triggered when the client connects to the server
|
||||
if globals.connection.isConnected()
|
||||
@ -32,7 +31,7 @@ define [
|
||||
@_registerEvents()
|
||||
|
||||
render: ->
|
||||
|
||||
# this renders to unordered list where users will be appended to
|
||||
compiledTemplate = _.template(sessionUsersTemplate)
|
||||
@$el.html compiledTemplate
|
||||
|
||||
@ -43,19 +42,22 @@ define [
|
||||
globals.events.on "users:user_list_change", (users) =>
|
||||
@_removeAllUsers()
|
||||
for userBlock in users
|
||||
alert("on user_list_change; adding user:" + JSON.stringify userBlock)
|
||||
console.log("on user_list_change; adding user:" + JSON.stringify userBlock)
|
||||
@_addUser(userBlock.id, userBlock.name)
|
||||
|
||||
globals.events.on "there_you_go", (data) =>
|
||||
alert "that's what i got: " + data
|
||||
#globals.events.on "receiveUsers", (data) =>
|
||||
#@users = data
|
||||
|
||||
globals.events.on "users:load_users", (users) =>
|
||||
@_removeAllUsers()
|
||||
for userBlock in users
|
||||
@_addUser(userBlock.userid, userBlock.name)
|
||||
#@_addUser(userBlock.userid, userBlock.name)
|
||||
globals.events.trigger "user:add_new_user", {id: userBlock.userid, userid: userBlock.userid, username: userBlock.name}
|
||||
|
||||
globals.events.on "users:user_join", (userid, username) =>
|
||||
@_addUser(userid, username)
|
||||
#@_addUser(userid, username)
|
||||
console.log "fffffffffffffff"
|
||||
globals.events.trigger "user:add_new_user", {id: userid, userid: userid, username: username}
|
||||
|
||||
globals.events.on "users:user_left", (userid) =>
|
||||
@_removeUserByID(userid)
|
||||
@ -73,20 +75,6 @@ define [
|
||||
#@$("#user-"+userID).parent().context.hidden = "true"
|
||||
#console.log @$el.children("ul")
|
||||
|
||||
# Add a user to the screen.
|
||||
_addUser: (userID, username) ->
|
||||
if userID? and username?
|
||||
data =
|
||||
username: username
|
||||
userID: userID
|
||||
|
||||
compiledTemplate = _.template(userTemplate, data)
|
||||
|
||||
# TODO!!!! only add the new element if it doesn't exist yet
|
||||
# this will resolve the problem of users displayed multiple times in the userlist
|
||||
|
||||
@$el.children("ul").append compiledTemplate
|
||||
|
||||
# Marks a user as selected when clicked.
|
||||
_userClicked: (e) ->
|
||||
@$('.user.selected').removeClass('selected')
|
||||
|
Loading…
Reference in New Issue
Block a user