summaryrefslogtreecommitdiff
path: root/public/js/lib/chat.js
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2015-08-05 21:28:20 -0400
committerJules Laplace <jules@okfoc.us>2015-08-05 21:28:20 -0400
commit4514c2c49f0e0ec7cf9911dc254a8d20644d5def (patch)
treeb4ac5caea8dca1cdefebb8873adf9d957ce7ae2a /public/js/lib/chat.js
parent4d6b5e96fbab0602c1781a8b7c06f32aa9d56d99 (diff)
pushing messages into a div
Diffstat (limited to 'public/js/lib/chat.js')
-rw-r--r--public/js/lib/chat.js48
1 files changed, 0 insertions, 48 deletions
diff --git a/public/js/lib/chat.js b/public/js/lib/chat.js
deleted file mode 100644
index 0968418..0000000
--- a/public/js/lib/chat.js
+++ /dev/null
@@ -1,48 +0,0 @@
-var ChatView = View.extend({
-
- template: $("#collaborator-template").html(),
-
- events: {
- "submit form": "send",
- "scroll #messages": "scroll",
- },
-
- initialize: function(){
- this.$msg = this.$("#message")
- this.$messages = this.$("#messages")
- this.messages = this.$messages.get(0)
- },
-
- add: function(msg){
- var $el = $( this.template )
- $el.find(".nick").html(msg.nick)
- $el.find(".msg").html(msg.msg)
- this.$messages.append($el)
- if (! this.scrolled) {
- this.scrollToBottom()
- }
- },
-
- send: function(){
- var val = this.$msg.sanitize()
- if (! val) return
- var msg = {}
- msg.room = room.name()
- msg.msg = val
- msg.nick = user.username
- // app.socket.send("message", msg)
- },
-
- empty: function(){
- this.$messages.empty()
- },
-
- scrolled: false,
- scroll: function(){
- this.scrolled = (this.messages.scrollTop > this.messages.scrollHeight - this.$el.height() - 100)
- },
- scrollToBottom: function(){
- this.messages.scrollTop = document.body.scrollHeight
- }
-
-})