mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-12-22 21:40:08 +00:00
Adding submit-event
This commit is contained in:
parent
d451c6b118
commit
1b522931bb
@ -53,6 +53,7 @@ window.console ?=
|
|||||||
events:
|
events:
|
||||||
newMessage: $.Callbacks()
|
newMessage: $.Callbacks()
|
||||||
userMenu: $.Callbacks()
|
userMenu: $.Callbacks()
|
||||||
|
submit: $.Callbacks()
|
||||||
|
|
||||||
# socket.io
|
# socket.io
|
||||||
socket: null
|
socket: null
|
||||||
@ -411,15 +412,15 @@ window.console ?=
|
|||||||
# Initializes Server-Push
|
# Initializes Server-Push
|
||||||
###
|
###
|
||||||
initPush: () ->
|
initPush: () ->
|
||||||
if typeof window.io isnt 'undefined'
|
unless typeof window.io is 'undefined'
|
||||||
console.log 'Initializing socket.io'
|
console.log 'Initializing nodePush'
|
||||||
@socket = io.connect @config.socketIOPath
|
@socket = io.connect @config.socketIOPath
|
||||||
@socket.on 'connect', $.proxy((data) ->
|
@socket.on 'connect', $.proxy((data) ->
|
||||||
console.log 'Connected on socket.io'
|
console.log 'Connected to nodePush'
|
||||||
@pe.getMessages.stop()
|
@pe.getMessages.stop()
|
||||||
, @)
|
, @)
|
||||||
@socket.on 'disconnect', $.proxy((data) ->
|
@socket.on 'disconnect', $.proxy((data) ->
|
||||||
console.log 'Losing connection to socket.io'
|
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) ->
|
||||||
@ -510,6 +511,10 @@ window.console ?=
|
|||||||
@freeTheFish() if $('#timsChatInput').val().trim().toLowerCase() is '/free the fish'
|
@freeTheFish() if $('#timsChatInput').val().trim().toLowerCase() is '/free the fish'
|
||||||
|
|
||||||
text = $('#timsChatInput').val()
|
text = $('#timsChatInput').val()
|
||||||
|
|
||||||
|
# call submit event
|
||||||
|
text = @events.submit.fire text
|
||||||
|
|
||||||
$('#timsChatInput').val('').focus().keyup()
|
$('#timsChatInput').val('').focus().keyup()
|
||||||
$.ajax $('#timsChatForm').attr('action'),
|
$.ajax $('#timsChatForm').attr('action'),
|
||||||
data:
|
data:
|
||||||
|
Loading…
Reference in New Issue
Block a user