File tree Expand file tree Collapse file tree 4 files changed +824
-0
lines changed
Expand file tree Collapse file tree 4 files changed +824
-0
lines changed Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
6+ < title > Chat box!!</ title >
7+ < link rel ="stylesheet " href ="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css ">
8+ < script src ="http://code.jquery.com/jquery-latest.min.js "> </ script >
9+ < script src ="/socket.io/socket.io.js "> </ script >
10+ < style >
11+ body {
12+ margin-top : 300px ;
13+ }
14+ </ style >
15+
16+ </ head >
17+ < body >
18+ < div class ="container ">
19+ < div class ="row ">
20+ < div class ="col-md-4 ">
21+ < div class ="well ">
22+ < h3 > Online Users</ h3 >
23+ < ul class ="list-group " id ="users "> </ ul >
24+ </ div >
25+ </ div >
26+ < div class ="col-md-8 ">
27+ < div class ="chat " id ="chat "> </ div >
28+ < form id ="messageForm ">
29+ < div class ="form-group ">
30+ < label > enter message</ label >
31+ < textarea class ="form-control " id ="message "> </ textarea >
32+ < br >
33+ < input type ="submit " class ="btn btn-primary " value ="Send Message "/>
34+ </ div >
35+ </ form >
36+ </ div >
37+ </ div >
38+
39+ </ div >
40+ < script >
41+ $ ( function ( ) {
42+ var socket = io . connect ( ) ;
43+ var $messageForm = $ ( '#messageForm' ) ;
44+ var $message = $ ( '#message' ) ;
45+ var $chat = $ ( '#chat' ) ;
46+
47+ $messageForm . submit ( ( e ) => {
48+ e . preventDefault ( ) ;
49+ console . log ( 'Submitted' ) ;
50+ socket . emit ( 'send message' , $message . val ( ) ) ;
51+ $message . val ( '' ) ;
52+ } ) ;
53+ } ) ;
54+ </ script >
55+ </ body >
56+ </ html >
You can’t perform that action at this time.
0 commit comments