-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathchat.html
104 lines (88 loc) · 3.28 KB
/
chat.html
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
<!doctype html>
<html>
<head>
<title>#movies - WLA - Gib Chat</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="font-awesome-animation.min.css">
<style>
body::-webkit-scrollbar {
width: 6px;
}
body::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 6px rgb(0, 0, 0);
}
body::-webkit-scrollbar-thumb {
background-color: #526a7d;
/* outline: 1px solid slategrey; */
border-radius: 5px;
width: 3px;}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font: 13px Helvetica, Arial; color:#ccc;}
form { background: #000; padding: 3px; position: fixed; bottom: 0; width: 100%; border-radius: 5px;
background: rgba(0, 0, 0, 0.55);}
form input { border: 0; padding: 10px; width: 60%; }
#username{ border: 0; padding: 10px; width: 20%; border-right:1px solid #ccc;background-color: transparent;
border-right: 0px;
color: #fff;}
form button { width: 20%; background: rgb(130, 224, 255); border: none; padding: 10px; border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
background: rgba(255, 255, 255, 0.65);}
#messages { list-style-type: none; margin: 0; padding: 0; }
li b{ color: #444;}
#messages li { padding: 5px 10px;
background: #191818;
border-radius: 5px;
margin-top: 5px; }
#messages li:nth-child(odd) { background: rgba(0, 0, 0, 0.55); }
#messages { margin-bottom: 40px ;padding:10px;}
#count{color: #95cc16;;}
#m{background-color: rgba(255, 255, 255, 0.05);
border-top-left-radius: 5px;
border-bottom-left-radius: 5px;
color: #fff;}
.red{color:#f74a4a;}
</style>
</head>
<body>
<span style=" position: fixed;
top: 0px;
right: 10px;
font-size: 10px;
color: #a7a7a7;
background: #111;
padding: 5px;
border-radius: 5px;"><span id="count" >0</span> Watching <span class="red"> <i class="fa fa-dot-circle-o faa-burst animated" aria-hidden="true"></i> LIVE</span></span>
<div><b>Chat:</b> </div>
<ul id="messages"></ul>
<form action="">
<input id="username" placeholder="username " autocomplete="off" /><input placeholder="message" id="m" autocomplete="off" /><button>Send</button>
</form>
<script src="/socket.io/socket.io.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js"></script>
<script>
$( document ).ready(function() {
$(function () {
var socket = io();
$('form').submit(function(){
var thing = {"msg":$('#m').val(),"username":$("#username").val()}
if($("#m").val() == ''){
alert("Enter a message")
} else {
socket.emit('chat message', thing);
}
$('#m').val('');
return false;
});
socket.on('count', function(data){
$("#count").text(data);
});
socket.on('chat message', function(json){
//$("#count").text(json.count);
$('#messages').append($('<li>').html(json.msg));
window.scrollTo(0, document.body.scrollHeight);
});
});
})
</script>
</body>
</html>