FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Socket.IO-node/example/chat.html at master · markjeee/Socket.IO-node · GitHub
markjeee
/
Socket.IO-node
Public
forked from
socketio/socket.io
Notifications
You must be signed in to change notification settings
Fork
1
Star
1
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
Socket.IO-node
/
example
/
chat.html
Copy path
More file actions
More file actions
Latest commit
History
History
History
61 lines (52 loc) · 2.32 KB
Breadcrumbs
Socket.IO-node
/
example
/
chat.html
Copy path
File metadata and controls
61 lines (52 loc) · 2.32 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
<!doctype html
>
<
html
>
<
head
>
<
title
>
socket.io client test
</
title
>
<
script
src
="
/json.js
"
>
</
script
>
<!-- for ie -->
<
script
src
="
/socket.io/socket.io.js
"
>
</
script
>
</
head
>
<
body
>
<
script
>
function
message
(
obj
)
{
var
el
=
document
.
createElement
(
'p'
)
;
if
(
'announcement'
in
obj
)
el
.
innerHTML
=
'<em>'
+
esc
(
obj
.
announcement
)
+
'</em>'
;
else
if
(
'message'
in
obj
)
el
.
innerHTML
=
'<b>'
+
esc
(
obj
.
message
[
0
]
)
+
':</b> '
+
esc
(
obj
.
message
[
1
]
)
;
document
.
getElementById
(
'chat'
)
.
appendChild
(
el
)
;
document
.
getElementById
(
'chat'
)
.
scrollTop
=
1000000
;
}
function
send
(
)
{
var
val
=
document
.
getElementById
(
'text'
)
.
value
;
socket
.
send
(
val
)
;
message
(
{
message
:
[
'you'
,
val
]
}
)
;
document
.
getElementById
(
'text'
)
.
value
=
''
;
}
function
esc
(
msg
)
{
return
msg
.
replace
(
/
<
/
g
,
'<'
)
.
replace
(
/
>
/
g
,
'>'
)
;
}
;
var
socket
=
new
io
.
Socket
(
null
,
{
port
:
8080
}
)
;
socket
.
connect
(
)
;
socket
.
on
(
'message'
,
function
(
obj
)
{
if
(
'buffer'
in
obj
)
{
document
.
getElementById
(
'form'
)
.
style
.
display
=
'block'
;
document
.
getElementById
(
'chat'
)
.
innerHTML
=
''
;
for
(
var
i
in
obj
.
buffer
)
message
(
obj
.
buffer
[
i
]
)
;
}
else
message
(
obj
)
;
}
)
;
</
script
>
<
h1
>
Sample chat client
</
h1
>
<
div
id
="
chat
"
>
<
p
>
Connecting...
</
p
>
</
div
>
<
form
id
="
form
"
onsubmit
="
send(); return false
"
>
<
input
type
="
text
"
autocomplete
="
off
"
id
="
text
"
>
<
input
type
="
submit
"
value
="
Send
"
>
</
form
>
<
style
>
#
chat
{
height
:
300
px
;
overflow
:
auto;
width
:
800
px
;
border
:
1
px
solid
#
eee
;
font
:
13
px
Helvetica
,
Arial; }
#
chat
p
{
padding
:
8
px
;
margin
:
0
; }
#
chat
p
:
nth-child
(odd) {
background
:
#
F6F6F6
; }
#
form
{
width
:
782
px
;
background
:
#
333
;
padding
:
5
px
10
px
;
display
:
none; }
#
form
input
[
type
=
text
] {
width
:
700
px
;
padding
:
5
px
;
background
:
#
fff
;
border
:
1
px
solid
#
fff
; }
#
form
input
[
type
=
submit
] {
cursor
:
pointer;
background
:
#
999
;
border
:
none;
padding
:
6
px
8
px
;
-moz-border-radius
:
8
px
;
-webkit-border-radius
:
8
px
;
margin-left
:
5
px
;
text-shadow
:
0
1
px
0
#
fff
; }
#
form
input
[
type
=
submit
]
:
hover
{
background
:
#
A2A2A2
; }
#
form
input
[
type
=
submit
]
:
active
{
position
:
relative;
top
:
2
px
; }
</
style
>
</
body
>
</
html
>
Back
|
FazBrowse Home
|
New Git URL