forked from gabhi/socket-io
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.html
More file actions
111 lines (102 loc) · 2.94 KB
/
index.html
File metadata and controls
111 lines (102 loc) · 2.94 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<!doctype html>
<html>
<head>
<title>Codefresh - Socket.IO chat</title>
<style>
@import url(http://fonts.googleapis.com/css?family=Podkova:300,400,700);
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font: 13px Helvetica, Arial; }
h1 {
font-family: "Podkova", Georgia, serif;
font-size:34px;
text-align:center;
margin-top:40px;
text-shadow: 3px 3px 4px #A1A1A1;
}
#wrapper {
width:100%;
max-width:600px;
border:1px solid #E4E4E4;
position:relative;
margin:15px auto;
height:400px;
-webkit-box-shadow: 3px 2px 6px 2px #B2B2B2;
box-shadow: 3px 2px 6px 2px #B2B2B2;
-webkit-border-radius: 5px;
border-radius: 5px;
overflow:hidden;
}
#messages_wrapper {
height:357px;
border:0px solid red;
overflow-x:hidden;
overflow-y:auto;
}
form {
background: #fff;
padding: 3px;
position: absolute;
bottom: 0;
width: 100%;
border-top:1px solid #E4E4E4;
}
form input {
border: 0;
padding: 10px;
margin-right: .5%;
}
.message_content {
width: 60%;
}
.name {
width:28%;
}
form button {
width: 9%;
background: #E47200;
color:#fff;
border: none;
padding: 10px;
-webkit-border-radius: 3px;
border-radius: 3px;
}
#messages { list-style-type: none; margin: 0; padding: 0; }
#messages li { padding: 5px 10px; }
#messages li:nth-child(odd) { background: #eee; }
footer {
display:block;
text-align:center;
font-family: "Podkova", Georgia, serif;
font-size:14px;
text-align:center;
text-shadow: 3px 3px 4px #A1A1A1;
}
</style>
</head>
<body>
<h1>Socket.IO Chat</h1>
<div id="wrapper">
<div id="messages_wrapper">
<ul id="messages"></ul>
</div>
<form action="">
<input id="n" type="text" class="name" placeholder="Your name" />
<input id="m" class="message_content" autocomplete="off" placeholder="Type your message here" /><button>Send</button>
</form>
</div>
<footer>© Codefresh 2015 | Example by <a href="http://socket.io/" target="_blank">Socket.io</a></footer>
<script src="https://cdn.socket.io/socket.io-1.2.0.js"></script>
<script src="http://code.jquery.com/jquery-1.11.1.js"></script>
<script>
var socket = io();
$('form').submit(function(){
socket.emit('chat message', $('#n').val() + ": " + $('#m').val());
$('#m').val('');
return false;
});
socket.on('chat message', function(msg){
$('#messages').prepend($('<li>').text(msg));
});
</script>
</body>
</html>