-
Notifications
You must be signed in to change notification settings - Fork 67
/
index.html
269 lines (256 loc) · 12.8 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
<!DOCTYPE html>
<html>
<head>
<title>Pusher Chat - live demo</title>
<link href="css/chat-style.css" rel="stylesheet">
<script src="http://js.pusher.com/1.12/pusher.min.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-1.8.2.min.js" type="text/javascript"></script>
<script src="js/jquery.pusherchat.js" type="text/javascript"></script>
<script src="js/jquery.playSound.js" type="text/javascript"></script>
<style>
/* demo style */
body{color: #333;font-family:arial, verdana, sans-serif;}
small{color:#ccc ; font-size: 14px}
.account a{ color :#333; background: #eee; border: 1px solid #ccc;padding: 5px; border-radius: 5px;display: inline-block;}
pre{line-height: 11px;font-size: 11px;background: #fafafa;border: 1px solid #ccc; padding: 10px}
.hide{font-size: 19px ;color:red ; font-weight: bold;display: none}
.connexion {font-size: 19px ;color:green ; font-weight: bold;}
</style>
</head>
<body>
<h1><img src="http://html5-ninja.com/front/images/little-ninja.png" alt="html5-ninja.com" /> Pusher chat , a facebook like chat jQuery plugin, using Pusher API</h1>
<p>
If you like Pusher Chat , share our link <a href="http://html5-ninja.com" target="_blank">HTML5 Ninja</a>
</p>
<hr/>
<h2>To start the demo , first connect as.. <small>click on link to connect & open at least 2 account in different window</small> :</h2>
<div class="connexion"></div>
<div class="account">
<a href="?user_id=133&name=Elvis" id="user_133">Elvis</a>
<a href="?user_id=244&name=Kurt%20Cobain" id="user_244">Kurt Cobain</a>
<a href="?user_id=3&name=Hendrix" id="user_3">Hendrix</a>
<a href="?user_id=666&name=Satan" id="user_666">Satan</a>
<a href="?user_id=999&name=God" id="user_999">God</a>
<a href="?user_id=111&name=Jesus" id="user_111">Jesus</a>
<a href="?user_id=1&name=Homer%20Simpson" id="user_1">Homer Simpson</a>
<a href="?user_id=2&name=Roger" id="user_2">Roger</a>
<a href="?user_id=4&name=Snoopy" id="user_4">Snoopy</a>
<div class="hide">
Please wait until one of testers leaves the demo , or download the plugin & try it on your own host , thx
</div>
</div>
<hr/>
<h2>Try it your self is better</h2>
<h3>files to includes</h3>
<pre>
<link href="css/chat-style.css" rel="stylesheet"><br />
<script src="http://js.pusher.com/1.12/pusher.min.js" type="text/javascript"></script> <br />
<script src="http://code.jquery.com/jquery-1.8.2.min.js" type="text/javascript"></script><br />
<script src="js/jquery.pusherchat.js" type="text/javascript"></script>
</pre>
<h3>Default setup</h3>
<pre>
$.fn.pusherChat({
'pusherKey':'YOUR PUSHER KEY', // required : open an account on http://pusher.com/ to get one
'authPath':'server/pusher_auth.php', // required : path to authentication scripts more info at http://pusher.com/docs/authenticating_users
'friendsList' : 'ajax/friends-list.json', // required : path to friends list json
'serverPath' : 'server/server.php' // required : path to server
)}
</pre>
<h3>HTML markup structure</h3>
<p> You can edit content & style but <b>don't change the structure or id & class name</b>. </p>
<pre>
<div id="pusherChat"><br />
<div id="membersContent"> <br />
<span id="expand"><span class="close">&#x25BC;</span><span class="open">&#x25B2;</span></span><br />
<h2><span id="count">0</span> online</h2><br />
<div class="scroll"><br />
<div id="members-list"></div><br />
</div><br />
</div>
<!-- chat box template --><br />
<div id="templateChatBox"><br />
<div class="pusherChatBox"><br />
<span class="state"><br />
<span class="pencil"><br />
<img src="assets/pencil.gif" /><br />
</span><br />
<span class="quote"><br />
<img src="assets/quote.gif" /><br />
</span><br />
</span><br />
<span class="expand"><span class="close">&#x25BC;</span><span class="open">&#x25B2;</span></span><br />
<span class="closeBox">x</span><br />
<h2><a href="#" title="go to profile"><img src="" class="imgFriend" /></a> <span class="userName"></span></h2><br />
<div class="slider"><br />
<div class="logMsg"><br />
<div class="msgTxt"><br />
</div><br />
</div><br />
<form method="post" name="#123"><br />
<textarea name="msg" rows="3" ></textarea><br />
<input type="hidden" name="from" class="from" /><br />
<input type="hidden" name="to" class="to"/><br />
<input type="hidden" name="typing" class="typing" value="false"/><br />
</form><br />
</div><br />
</div><br />
</div><br />
<!-- chat box template end -->
<div class="chatBoxWrap"><br />
<div class="chatBoxslide"></div><br />
<span id="slideLeft"> <img src="assets/quote.gif" />&#x25C0;</span> <br />
<span id="slideRight">&#x25B6; <img src="assets/quote.gif" /></span><br />
</div><br />
</div>
</pre>
<hr/>
<h2>Settings</h2>
<ul>
<li>
<p> 'pusherKey': YOUR PUSHER KEY HERE //required : open an account on http://pusher.com/ to get one</p>
</li>
<li>
<p>
'authPath' : path to authentication scripts //required : more info at http://pusher.com/docs/authenticating_users
</p>
</li>
<li>
<p>
'friendsList' : path to friends list json //required :
</p>
<pre>
// json ex :
{
"133": ["Elvis","assets/elvis.jpg","http://html5-ninja.com"],
"244": ["Kurt Cobain","assets/cobain.jpg","http://html5-ninja.com"],
}
</pre>
</li>
<li>
<p>'serverPath' : path to server //required : path to server</p>
</li>
<li>
<p>
'profilePage' : false or true //link to friend profile page setup fom json ex : ["Kurt Cobain","assets/cobain.jpg","path/to/profile"]
</p>
</li>
<li>
<p>
'onFriendConnect' : function(data){...} //event : trigger when friend connect & return ID
</p>
</li>
<li>
<p>
'onFriendLogOut' : function(data){...} //event : trigger when friend log out & return ID
</p>
</li>
<li>
<p>
'onSubscription' : function(data){...} //return members object
</p>
</li>
</ul>
<h2>Security</h2>
<p>
You are a big boy ! create your own security strategy on pusher_auth.php & server.php
</p>
<!--***************************************************** pusher chat html *******************************************************-->
<div id="pusherChat">
<div id="membersContent">
<span id="expand"><span class="close">▼</span><span class="open">▲</span></span>
<h2><span id="count">0</span> online</h2>
<div class="scroll">
<div id="members-list"></div>
</div>
</div>
<!-- chat box template -->
<div id="templateChatBox">
<div class="pusherChatBox">
<span class="state">
<span class="pencil">
<img src="assets/pencil.gif" />
</span>
<span class="quote">
<img src="assets/quote.gif" />
</span>
</span>
<span class="expand"><span class="close">▼</span><span class="open">▲</span></span>
<span class="closeBox">x</span>
<h2><a href="#" title="go to profile"><img src="" class="imgFriend" /></a> <span class="userName"></span></h2>
<div class="slider">
<div class="logMsg">
<div class="msgTxt">
</div>
</div>
<form method="post" name="#123">
<textarea name="msg" rows="3" ></textarea>
<input type="hidden" name="from" class="from" />
<input type="hidden" name="to" class="to"/>
<input type="hidden" name="typing" class="typing" value="false"/>
</form>
</div>
</div>
</div>
<!-- chat box template end -->
<div class="chatBoxWrap">
<div class="chatBoxslide"></div>
<span id="slideLeft"> <img src="assets/quote.gif" />◀</span>
<span id="slideRight">▶ <img src="assets/quote.gif" /></span>
</div>
</div>
<!--***************************************************** end pusher chat html *******************************************************-->
<hr/>
<footer>
<p>follow us on twitter <a href="https://twitter.com/html5_ninja">@html5_ninja</a>, on <a href="https://www.facebook.com/Html5Ninja">Facebook</a> & on <a href="https://plus.google.com/107385672780395752994">Google+</a></p>
<p>Author & support : [email protected] <span class="pull-right">2012 © <a href="http://html5-ninja.com/">html5-ninja.com</a></span></p>
</footer>
<script type="text/javascript">
/*
* this part is only for demo you don't need this
*/
function getUrlVars() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
vars[key] = value;
});
return vars;
}
var id = getUrlVars()['user_id'];
var name = getUrlVars()['name'];
if (id=="undefined") {
id="";
} else $('#user_'+id).hide();
if (name=="undefined") name="";
if (!id) $('#pusherChat').remove();
if (name)
$('.connexion').html('You are connected as '+name.replace('%20',' '));
/*
* this part is only for demo you don't need this
*/
</script>
<script>
$.fn.pusherChat({
'pusherKey':'GET YOUR KEY FROM http://pusher.com',
'authPath':'server/pusher_auth.php?user_id='+id+'&name='+name,
'friendsList' : 'ajax/friends-list.json',
'serverPath' : 'server/server.php',
'profilePage':true,
'onFriendConnect': function(member){
if (member.id) $('#user_'+member.id).hide();
if (!$('.account a:visible').html()) $('.hide').show();
},
'onFriendLogOut': function(member){
if (member.id) $('#user_'+member.id).show();
if ($('.account a:visible').html()) $('.hide').hide();
},
'onSubscription':function(members){
if ($('.account a:visible').html()) $('.hide').hide();
$.each(members._members_map, function(val){
$('#user_'+val).hide();
});
}
});
</script>
</body>
</html>