1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-12-22 21:40:08 +00:00

Adding console.log for information about what is going on

This commit is contained in:
Tim Düsterhus 2012-01-14 12:50:39 +01:00
parent 1d3af29172
commit 5d7ef3c05b

View File

@ -20,12 +20,15 @@ TimWolla.WCF ?= {}
newMessage: $.Callbacks() newMessage: $.Callbacks()
userMenu: $.Callbacks() userMenu: $.Callbacks()
init: () -> init: () ->
console.log('[TimWolla.WCF.Chat] Initializing');
@bindEvents() @bindEvents()
@refreshRoomList() @refreshRoomList()
new WCF.PeriodicalExecuter $.proxy(@refreshRoomList, this), 60e3 new WCF.PeriodicalExecuter $.proxy(@refreshRoomList, this), 60e3
new WCF.PeriodicalExecuter $.proxy(@getMessages, this), @config.reloadTime * 1000 new WCF.PeriodicalExecuter $.proxy(@getMessages, this), @config.reloadTime * 1000
@getMessages()
$('#chatInput').focus() $('#chatInput').focus()
console.log '[TimWolla.WCF.Chat] Finished initializing'
### ###
# Binds all the events needed for Tims Chat. # Binds all the events needed for Tims Chat.
### ###
@ -121,6 +124,7 @@ TimWolla.WCF ?= {}
### ###
freeTheFish: () -> freeTheFish: () ->
return if $.wcfIsset('fish') return if $.wcfIsset('fish')
console.warn '[TimWolla.WCF.Chat] Freeing the fish'
fish = $ '<div id="fish">' + WCF.String.escapeHTML('><((((°>') + '</div>' fish = $ '<div id="fish">' + WCF.String.escapeHTML('><((((°>') + '</div>'
fish.css fish.css
position: 'absolute' position: 'absolute'
@ -192,11 +196,11 @@ TimWolla.WCF ?= {}
id = 'chatUser-'+user.userID id = 'chatUser-'+user.userID
element = $('#'+id) element = $('#'+id)
if element[0] if element[0]
console.log('Shifting: ' + user.userID); console.log '[TimWolla.WCF.Chat] Shifting user ' + user.userID
element = element.detach() element = element.detach()
$('#chatUserList').append element $('#chatUserList').append element
else else
console.log('Inserting: ' + user.userID); console.log '[TimWolla.WCF.Chat] Inserting user ' + user.userID
li = $ '<li></li>' li = $ '<li></li>'
li.attr 'id', id li.attr 'id', id
li.addClass 'chatUser' li.addClass 'chatUser'
@ -247,6 +251,7 @@ TimWolla.WCF ?= {}
# Refreshes the room-list. # Refreshes the room-list.
### ###
refreshRoomList: () -> refreshRoomList: () ->
console.log '[TimWolla.WCF.Chat] Refreshing the room-list'
$('#toggleRooms a').addClass 'ajaxLoad' $('#toggleRooms a').addClass 'ajaxLoad'
$.ajax $('#toggleRooms a').data('refreshUrl'), $.ajax $('#toggleRooms a').data('refreshUrl'),
@ -262,11 +267,14 @@ TimWolla.WCF ?= {}
li.addClass 'activeMenuItem' if room.active li.addClass 'activeMenuItem' if room.active
$('<a href="' + room.link + '">' + room.title + '</a>').addClass('chatRoom').appendTo li $('<a href="' + room.link + '">' + room.title + '</a>').addClass('chatRoom').appendTo li
$('#chatRoomList ul').append li $('#chatRoomList ul').append li
$('.chatRoom').click $.proxy (event) -> $('.chatRoom').click $.proxy (event) ->
return if typeof window.history.replaceState is 'undefined' return if typeof window.history.replaceState is 'undefined'
event.preventDefault() event.preventDefault()
@changeRoom $ event.target @changeRoom $ event.target
, this , this
console.log '[TimWolla.WCF.Chat] Found ' + data.length + ' rooms'
, this) , this)
### ###
# Handles submitting of messages. # Handles submitting of messages.