-
Notifications
You must be signed in to change notification settings - Fork 0
/
chat.jade
49 lines (49 loc) · 1.23 KB
/
chat.jade
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
doctype html
html
head
title Chat
body
h1 Welcome !{name} - !{friendName}
form#send-message
|message:
input(type="text",name="name")#message
br
br
input(type="submit")
br
br
br
div#chat
| !{friendName}
br
br
each message in messages
if(friendNumber == message.sender )
!{friendName}
else
!{name}
| :
!{message.msg}
br
br
br
br
a(href='/logout') Logout
script(src="http://code.jquery.com/jquery-latest.min.js")
script(src="/socket.io/socket.io.js")
script.
var socket = io.connect('http://localhost:3000/');
$('#send-message').submit(function(e)
{
console.log("hmmm");
e.preventDefault();
socket.emit('send message',{ msg : $('#message').val() , reciever : #{friendNumber}});
$('#message').val('');
});
socket.on('new message',function(data)
{
if(data.reciever == !{mobilenumber})
$('#chat').append( data.senderName + " : " + data.msg + "<br />");
if(data.senderMobileNumber == !{mobilenumber})
$('#chat').append( data.senderName + " : " + data.msg + "<br />");
});