mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-12-22 21:40:08 +00:00
Clean up javascript
This commit is contained in:
parent
98f5e1bee3
commit
cad8fee417
@ -18,11 +18,11 @@ window.console ?=
|
|||||||
|
|
||||||
console =
|
console =
|
||||||
log: (message) ->
|
log: (message) ->
|
||||||
_console.log '[be.bastelstu.Chat] '+message
|
_console.log "[be.bastelstu.Chat] #{message}"
|
||||||
warn: (message) ->
|
warn: (message) ->
|
||||||
_console.warn '[be.bastelstu.Chat] '+message
|
_console.warn "[be.bastelstu.Chat] #{message}"
|
||||||
error: (message) ->
|
error: (message) ->
|
||||||
_console.error '[be.bastelstu.Chat] '+message
|
_console.error "[be.bastelstu.Chat] #{message}"
|
||||||
|
|
||||||
|
|
||||||
be.bastelstu.Chat = Class.extend
|
be.bastelstu.Chat = Class.extend
|
||||||
@ -155,13 +155,13 @@ window.console ?=
|
|||||||
toComplete = toComplete.substring 0, nextSpace
|
toComplete = toComplete.substring 0, nextSpace
|
||||||
|
|
||||||
return if toComplete.length is 0
|
return if toComplete.length is 0
|
||||||
console.log 'Autocompleting "' + toComplete + '"'
|
console.log "Autocompleting '#{toComplete}'"
|
||||||
|
|
||||||
# Insert name and increment offset
|
# Insert name and increment offset
|
||||||
name = @autocomplete toComplete
|
name = @autocomplete toComplete
|
||||||
|
|
||||||
$('#timsChatInput').val beforeComplete + name + ' ' + afterComplete
|
$('#timsChatInput').val "#{beforeComplete}#{name} #{afterComplete}"
|
||||||
$('#timsChatInput').setCaret((beforeComplete + name).length + 1);
|
$('#timsChatInput').setCaret (beforeComplete + name).length + 1
|
||||||
@autocompleteOffset++
|
@autocompleteOffset++
|
||||||
else
|
else
|
||||||
@autocompleteOffset = 0
|
@autocompleteOffset = 0
|
||||||
@ -176,7 +176,7 @@ window.console ?=
|
|||||||
, @
|
, @
|
||||||
|
|
||||||
# Refreshes the roomlist
|
# Refreshes the roomlist
|
||||||
$('#timsChatRoomList button').click $.proxy(@refreshRoomList, @)
|
$('#timsChatRoomList button').click $.proxy @refreshRoomList, @
|
||||||
|
|
||||||
# Clears the stream
|
# Clears the stream
|
||||||
$('#timsChatClear').click (event) ->
|
$('#timsChatClear').click (event) ->
|
||||||
@ -233,7 +233,7 @@ window.console ?=
|
|||||||
data:
|
data:
|
||||||
ajax: 1
|
ajax: 1
|
||||||
type: 'POST'
|
type: 'POST'
|
||||||
success: $.proxy((data, textStatus, jqXHR) ->
|
success: $.proxy (data, textStatus, jqXHR) ->
|
||||||
@loading = false
|
@loading = false
|
||||||
target.parent().removeClass 'loading'
|
target.parent().removeClass 'loading'
|
||||||
|
|
||||||
@ -249,12 +249,12 @@ window.console ?=
|
|||||||
$(@).text ''
|
$(@).text ''
|
||||||
else
|
else
|
||||||
$('#timsChatTopic').text data.topic
|
$('#timsChatTopic').text data.topic
|
||||||
$('#timsChatTopic').wcfBlindIn() if $('#timsChatTopic').text().trim() isnt '' and $('#timsChatTopic').is(':hidden')
|
$('#timsChatTopic').wcfBlindIn() if $('#timsChatTopic').text().trim() isnt '' and $('#timsChatTopic').is ':hidden'
|
||||||
|
|
||||||
$('.timsChatMessage').addClass 'unloaded', 800
|
$('.timsChatMessage').addClass 'unloaded', 800
|
||||||
@handleMessages data.messages
|
@handleMessages data.messages
|
||||||
document.title = @titleTemplate.fetch data
|
document.title = @titleTemplate.fetch data
|
||||||
, @)
|
, @
|
||||||
error: () ->
|
error: () ->
|
||||||
# Reload the page to change the room the old fashion-way
|
# Reload the page to change the room the old fashion-way
|
||||||
# inclusive the error-message :)
|
# inclusive the error-message :)
|
||||||
@ -443,13 +443,13 @@ window.console ?=
|
|||||||
console.log 'Connected to nodePush'
|
console.log 'Connected to nodePush'
|
||||||
@pe.getMessages.stop()
|
@pe.getMessages.stop()
|
||||||
, @)
|
, @)
|
||||||
@socket.on 'disconnect', $.proxy((data) ->
|
@socket.on 'disconnect', $.proxy (data) ->
|
||||||
console.log 'Lost connection to nodePush'
|
console.log 'Lost connection to nodePush'
|
||||||
@pe.getMessages = new WCF.PeriodicalExecuter $.proxy(@getMessages, @), @config.reloadTime * 1e3
|
@pe.getMessages = new WCF.PeriodicalExecuter $.proxy(@getMessages, @), @config.reloadTime * 1e3
|
||||||
, @)
|
, @
|
||||||
@socket.on 'newMessage', $.proxy((data) ->
|
@socket.on 'newMessage', $.proxy (data) ->
|
||||||
@getMessages()
|
@getMessages()
|
||||||
, @)
|
, @
|
||||||
###
|
###
|
||||||
# Inserts text into our input.
|
# Inserts text into our input.
|
||||||
#
|
#
|
||||||
@ -505,7 +505,7 @@ window.console ?=
|
|||||||
$.ajax $('#toggleRooms a').data('refreshUrl'),
|
$.ajax $('#toggleRooms a').data('refreshUrl'),
|
||||||
dataType: 'json'
|
dataType: 'json'
|
||||||
type: 'POST'
|
type: 'POST'
|
||||||
success: $.proxy((data, textStatus, jqXHR) ->
|
success: $.proxy (data, textStatus, jqXHR) ->
|
||||||
$('#timsChatRoomList li').remove()
|
$('#timsChatRoomList li').remove()
|
||||||
$('#toggleRooms .ajaxLoad').hide()
|
$('#toggleRooms .ajaxLoad').hide()
|
||||||
$('#toggleRooms .badge').text data.length
|
$('#toggleRooms .badge').text data.length
|
||||||
@ -522,8 +522,8 @@ window.console ?=
|
|||||||
@changeRoom $ event.target
|
@changeRoom $ event.target
|
||||||
, @
|
, @
|
||||||
|
|
||||||
console.log 'Found ' + data.length + ' rooms'
|
console.log "Found #{data.length} rooms"
|
||||||
, @)
|
, @
|
||||||
###
|
###
|
||||||
# Handles submitting of messages.
|
# Handles submitting of messages.
|
||||||
#
|
#
|
||||||
@ -549,9 +549,9 @@ window.console ?=
|
|||||||
smilies: $('#timsChatSmilies').data 'status'
|
smilies: $('#timsChatSmilies').data 'status'
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
beforeSend: (jqXHR) ->
|
beforeSend: (jqXHR) ->
|
||||||
success: $.proxy((data, textStatus, jqXHR) ->
|
success: $.proxy (data, textStatus, jqXHR) ->
|
||||||
@getMessages()
|
@getMessages()
|
||||||
, @)
|
, @
|
||||||
complete: () ->
|
complete: () ->
|
||||||
###
|
###
|
||||||
# Toggles between user- and room-list.
|
# Toggles between user- and room-list.
|
||||||
|
Loading…
Reference in New Issue
Block a user