-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
102 lines (76 loc) · 1.76 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
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
<meta charset="utf-8">
<style>
.left{
float:left;
}
.right{
float:right;
}
.pic{
display: block;
max-width:90%;
max-height:90%;
width: auto;
height: auto;
}
#box{
border-style:dashed;
overflow:scroll;
width:97%;
height:75%;
}
#full{
width:75%;
height:97%;
border-style:solid;
}
</style>
<script src="jquery.min.js"></script>
<center>
<div id='full'>
<h1>CHATAPP</h1>
Enter message and press enter :
<input id=input placeholder=you-chat-here />
<input id=pic placeholder=image-link-&-enter-key />
<button id='export'>Export Chat</button><br>
<div id=box></div>
<script src=pubnub.min.js></script>
<script>
$('#export').on('click',function(){
var a = document.body.appendChild(
document.createElement("a")
);
a.download = "export.html";
a.href = "data:text/html," + document.getElementById("box").innerHTML;
a.innerHTML = "[Export conent]";
a.click();
$('a').remove();
});
</script>
<script>(function(){
channel_name=prompt('Enter secret room name ');
var uname=prompt('Enter your name ');
alternate=0;
loc='';
var box = PUBNUB.$('box'), input = PUBNUB.$('input'), pic=PUBNUB.$('pic'),channel =channel_name ;
PUBNUB.subscribe({
channel : channel,
callback : function(text) { box.innerHTML += '<br>'+text ;
$('#box').animate({
scrollTop: $('#box')[0].scrollHeight}, 2000);
},
});
PUBNUB.bind( 'keyup', input, function(e) {
(e.keyCode || e.charCode) === 13 && PUBNUB.publish({
channel : channel, message : uname+' : '+input.value, x : (input.value='')
})
} )
PUBNUB.bind( 'keyup', pic, function(e) {
(e.keyCode || e.charCode) === 13 && PUBNUB.publish({
channel : channel, message : uname+' : <img class="pic" src="'+pic.value+'" >', x : (input.value=''),
callback:function(){ pic.value='' }
})
} )
})()</script>
</div>
</center>