-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
executable file
·61 lines (58 loc) · 2.17 KB
/
index.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
<!doctype html>
<html>
<head>
<title>121 chat</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font: 13px Helvetica, Arial; }
form input:focus{outline:none}
form { background: #CCD7AE; padding: 3px; position: fixed; top: 0; width: 100%; }
form input#m { border: 0; padding: 10px; width: 70%; margin-right: .5%; }
form input#m_name { border: 0; padding: 10px; width: 20%; margin-right: .5%; }
form .btn{ width: 4%; background: transparent repeating-radial-gradient(#BAD1B0, #F9F9F9 10%, #8AEC8A 15%) repeat scroll 0% 0%; border: none; padding: 10px; }
#messages { list-style-type: none;margin: 0px;padding: 0px;height: 617px;overflow-y: auto;margin-top:46px }
#messages li { padding: 5px 10px; }
#messages li:first-child{border: 3px dashed #DD6C24;}
#messages li:nth-child(odd) { background: #eee; }
</style>
</head>
<body>
<form action="">
<input id="m_name" autocomplete="off" placeholder="Code Name" /><input id="m" autocomplete="off" /><button class ="btn">Send</button><a href="/google" class="btn">Google</a>
</form>
<ul id="messages"></ul>
<script src="js/socket.io-1.2.0.js"></script>
<script src="js/jquery-1.11.1.js"></script>
<script>
var socket = io();
$('form').submit(function(){
socket.emit('chat message', $('#m_name').val()+' : '+$('#m').val());
$('#m').val('');
return false;
});
socket.on('chat message', function(msg){
notify('hei there', msg);
$('#messages').prepend($('<li>').text(msg));
});
function notify(title,msg) {
if (Notification.permission !== "granted")
Notification.requestPermission();
else {
var notification = new Notification(title, {
body: $('<div/>').html(msg).text(),
});
notification.onclick = function () {
window.focus();
};
setTimeout(function() {
notification.close()
},1000);
//setTimeout(notification.close.bind(notification), 100);
/* notification.onclick = function () {
window.open("http://stackoverflow.com/a/13328397/1269037");
};*/
}
};
</script>
</body>
</html>