friends_ajax_core 0.0.51
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/app/assets/images/icons-16/icon-arrow-down-hover.png +0 -0
- data/app/assets/images/icons-16/icon-arrow-down.png +0 -0
- data/app/assets/images/icons-16/icon-arrow-right-hover.png +0 -0
- data/app/assets/images/icons-16/icon-arrow-right.png +0 -0
- data/app/assets/images/icons/icon-close.png +0 -0
- data/app/assets/images/icons/loader-16.png +0 -0
- data/app/assets/images/icons/loader-24.png +0 -0
- data/app/assets/images/menu/alpha-bg-60.png +0 -0
- data/app/assets/images/menu/alpha-bg-75.png +0 -0
- data/app/assets/images/menu/alpha-bg-95.png +0 -0
- data/app/assets/images/menu/alpha-bg-99.png +0 -0
- data/app/assets/javascripts/ajax_callbacks_core/common.js.erb +83 -0
- data/app/assets/javascripts/ajax_callbacks_core/forms.js.erb +27 -0
- data/app/assets/javascripts/ajax_callbacks_core/helpers.js.erb +216 -0
- data/app/assets/javascripts/ajax_ext_core/colorpicker.js +484 -0
- data/app/assets/javascripts/ajax_ext_core/date.js.erb +335 -0
- data/app/assets/javascripts/ajax_ext_core/faye.js +2 -0
- data/app/assets/javascripts/ajax_ext_core/jquery-json.js +178 -0
- data/app/assets/javascripts/ajax_ext_core/jquery-ui-timepicker-addon.js +1923 -0
- data/app/assets/javascripts/ajax_ext_core/jquery.hash.js +203 -0
- data/app/assets/javascripts/ajax_ext_core/jquery.jsonSuggest.js +25 -0
- data/app/assets/javascripts/ajax_ext_core/jquery.mtz.monthpicker.js +271 -0
- data/app/assets/javascripts/ajax_ext_core/preload_images.js +56 -0
- data/app/assets/javascripts/ajax_ui_core/autocomplete.js.erb +26 -0
- data/app/assets/javascripts/ajax_ui_core/datepicker.js.erb +144 -0
- data/app/assets/javascripts/ajax_ui_core/friends_ui.js.erb +23 -0
- data/app/assets/javascripts/ajax_ui_core/overlay.js.erb +85 -0
- data/app/assets/javascripts/ajax_ui_core/slide-down.js +163 -0
- data/app/assets/javascripts/friends_ajax_core.js.erb +11 -0
- data/app/assets/javascripts/init_ajax_core.js.erb +22 -0
- data/app/controllers/friends_ajax_controller.rb +6 -0
- data/app/helpers/friends_ajax_helper.rb +176 -0
- data/app/views/layouts/_ajax_overlay.html.erb +5 -0
- data/app/views/layouts/_info_overlay.html.erb +9 -0
- data/app/views/layouts/_invisible_overlay.html.erb +10 -0
- data/app/views/layouts/_layout_defaults.html.erb +39 -0
- data/app/views/layouts/_overlay_js.html.erb +30 -0
- data/app/views/layouts/ajax_overlay.html.erb +5 -0
- data/app/views/layouts/info_overlay.html.erb +9 -0
- data/config/routes.rb +10 -0
- data/lib/friends_ajax_core.rb +117 -0
- data/lib/friends_ajax_core/version.rb +4 -0
- metadata +143 -0
@@ -0,0 +1,335 @@
|
|
1
|
+
// ===================================================================
|
2
|
+
// Author: Matt Kruse <matt@mattkruse.com>
|
3
|
+
// WWW: http://www.mattkruse.com/
|
4
|
+
//
|
5
|
+
// NOTICE: You may use this code for any purpose, commercial or
|
6
|
+
// private, without any further permission from the author. You may
|
7
|
+
// remove this notice from your final code if you wish, however it is
|
8
|
+
// appreciated by the author if at least my web site address is kept.
|
9
|
+
//
|
10
|
+
// You may *NOT* re-distribute this code in any way except through its
|
11
|
+
// use. That means, you can include it in your product, or your web
|
12
|
+
// site, or any other form where the code is actually being used. You
|
13
|
+
// may not put the plain javascript up on your site for download or
|
14
|
+
// include it in your javascript libraries for download.
|
15
|
+
// If you wish to share this code with others, please just point them
|
16
|
+
// to the URL instead.
|
17
|
+
// Please DO NOT link directly to my .js files from your site. Copy
|
18
|
+
// the files to your server and use them there. Thank you.
|
19
|
+
// ===================================================================
|
20
|
+
|
21
|
+
// HISTORY
|
22
|
+
// ------------------------------------------------------------------
|
23
|
+
// May 17, 2003: Fixed bug in parseDate() for dates <1970
|
24
|
+
// March 11, 2003: Added parseDate() function
|
25
|
+
// March 11, 2003: Added "NNN" formatting option. Doesn't match up
|
26
|
+
// perfectly with SimpleDateFormat formats, but
|
27
|
+
// backwards-compatability was required.
|
28
|
+
|
29
|
+
// ------------------------------------------------------------------
|
30
|
+
// These functions use the same 'format' strings as the
|
31
|
+
// java.text.SimpleDateFormat class, with minor exceptions.
|
32
|
+
// The format string consists of the following abbreviations:
|
33
|
+
//
|
34
|
+
// Field | Full Form | Short Form
|
35
|
+
// -------------+--------------------+-----------------------
|
36
|
+
// Year | yyyy (4 digits) | yy (2 digits), y (2 or 4 digits)
|
37
|
+
// Month | MMM (name or abbr.)| MM (2 digits), M (1 or 2 digits)
|
38
|
+
// | NNN (abbr.) |
|
39
|
+
// Day of Month | dd (2 digits) | d (1 or 2 digits)
|
40
|
+
// Day of Week | EE (name) | E (abbr)
|
41
|
+
// Hour (1-12) | hh (2 digits) | h (1 or 2 digits)
|
42
|
+
// Hour (0-23) | HH (2 digits) | H (1 or 2 digits)
|
43
|
+
// Hour (0-11) | KK (2 digits) | K (1 or 2 digits)
|
44
|
+
// Hour (1-24) | kk (2 digits) | k (1 or 2 digits)
|
45
|
+
// Minute | mm (2 digits) | m (1 or 2 digits)
|
46
|
+
// Second | ss (2 digits) | s (1 or 2 digits)
|
47
|
+
// AM/PM | a |
|
48
|
+
//
|
49
|
+
// NOTE THE DIFFERENCE BETWEEN MM and mm! Month=MM, not mm!
|
50
|
+
// Examples:
|
51
|
+
// "MMM d, y" matches: January 01, 2000
|
52
|
+
// Dec 1, 1900
|
53
|
+
// Nov 20, 00
|
54
|
+
// "M/d/yy" matches: 01/20/00
|
55
|
+
// 9/2/00
|
56
|
+
// "MMM dd, yyyy hh:mm:ssa" matches: "January 01, 2000 12:30:45AM"
|
57
|
+
// ------------------------------------------------------------------
|
58
|
+
|
59
|
+
var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
|
60
|
+
var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');
|
61
|
+
function LZ(x) {return(x<0||x>9?"":"0")+x}
|
62
|
+
|
63
|
+
// ------------------------------------------------------------------
|
64
|
+
// isDate ( date_string, format_string )
|
65
|
+
// Returns true if date string matches format of format string and
|
66
|
+
// is a valid date. Else returns false.
|
67
|
+
// It is recommended that you trim whitespace around the value before
|
68
|
+
// passing it to this function, as whitespace is NOT ignored!
|
69
|
+
// ------------------------------------------------------------------
|
70
|
+
function isDate(val,format) {
|
71
|
+
var date=getDateFromFormat(val,format);
|
72
|
+
if (date==0) { return false; }
|
73
|
+
return true;
|
74
|
+
}
|
75
|
+
|
76
|
+
// -------------------------------------------------------------------
|
77
|
+
// compareDates(date1,date1format,date2,date2format)
|
78
|
+
// Compare two date strings to see which is greater.
|
79
|
+
// Returns:
|
80
|
+
// 1 if date1 is greater than date2
|
81
|
+
// 0 if date2 is greater than date1 of if they are the same
|
82
|
+
// -1 if either of the dates is in an invalid format
|
83
|
+
// -------------------------------------------------------------------
|
84
|
+
function compareDates(date1,dateformat1,date2,dateformat2) {
|
85
|
+
var d1=getDateFromFormat(date1,dateformat1);
|
86
|
+
var d2=getDateFromFormat(date2,dateformat2);
|
87
|
+
if (d1==0 || d2==0) {
|
88
|
+
return -1;
|
89
|
+
}
|
90
|
+
else if (d1 > d2) {
|
91
|
+
return 1;
|
92
|
+
}
|
93
|
+
return 0;
|
94
|
+
}
|
95
|
+
|
96
|
+
// ------------------------------------------------------------------
|
97
|
+
// formatDate (date_object, format)
|
98
|
+
// Returns a date in the output format specified.
|
99
|
+
// The format string uses the same abbreviations as in getDateFromFormat()
|
100
|
+
// ------------------------------------------------------------------
|
101
|
+
function formatDate(date,format) {
|
102
|
+
format=format+"";
|
103
|
+
var result="";
|
104
|
+
var i_format=0;
|
105
|
+
var c="";
|
106
|
+
var token="";
|
107
|
+
var y=date.getYear()+"";
|
108
|
+
var M=date.getMonth()+1;
|
109
|
+
var d=date.getDate();
|
110
|
+
var E=date.getDay();
|
111
|
+
var H=date.getHours();
|
112
|
+
var m=date.getMinutes();
|
113
|
+
var s=date.getSeconds();
|
114
|
+
var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;
|
115
|
+
// Convert real date parts into formatted versions
|
116
|
+
var value=new Object();
|
117
|
+
if (y.length < 4) {y=""+(y-0+1900);}
|
118
|
+
value["y"]=""+y;
|
119
|
+
value["yyyy"]=y;
|
120
|
+
value["yy"]=y.substring(2,4);
|
121
|
+
value["M"]=M;
|
122
|
+
value["MM"]=LZ(M);
|
123
|
+
value["MMM"]=MONTH_NAMES[M-1];
|
124
|
+
value["NNN"]=MONTH_NAMES[M+11];
|
125
|
+
value["d"]=d;
|
126
|
+
value["dd"]=LZ(d);
|
127
|
+
value["E"]=DAY_NAMES[E+7];
|
128
|
+
value["EE"]=DAY_NAMES[E];
|
129
|
+
value["H"]=H;
|
130
|
+
value["HH"]=LZ(H);
|
131
|
+
if (H==0){value["h"]=12;}
|
132
|
+
else if (H>12){value["h"]=H-12;}
|
133
|
+
else {value["h"]=H;}
|
134
|
+
value["hh"]=LZ(value["h"]);
|
135
|
+
if (H>11){value["K"]=H-12;} else {value["K"]=H;}
|
136
|
+
value["k"]=H+1;
|
137
|
+
value["KK"]=LZ(value["K"]);
|
138
|
+
value["kk"]=LZ(value["k"]);
|
139
|
+
if (H > 11) { value["a"]="PM"; }
|
140
|
+
else { value["a"]="AM"; }
|
141
|
+
value["m"]=m;
|
142
|
+
value["mm"]=LZ(m);
|
143
|
+
value["s"]=s;
|
144
|
+
value["ss"]=LZ(s);
|
145
|
+
while (i_format < format.length) {
|
146
|
+
c=format.charAt(i_format);
|
147
|
+
token="";
|
148
|
+
while ((format.charAt(i_format)==c) && (i_format < format.length)) {
|
149
|
+
token += format.charAt(i_format++);
|
150
|
+
}
|
151
|
+
if (value[token] != null) { result=result + value[token]; }
|
152
|
+
else { result=result + token; }
|
153
|
+
}
|
154
|
+
return result;
|
155
|
+
}
|
156
|
+
|
157
|
+
// ------------------------------------------------------------------
|
158
|
+
// Utility functions for parsing in getDateFromFormat()
|
159
|
+
// ------------------------------------------------------------------
|
160
|
+
function _isInteger(val) {
|
161
|
+
var digits="1234567890";
|
162
|
+
for (var i=0; i < val.length; i++) {
|
163
|
+
if (digits.indexOf(val.charAt(i))==-1) { return false; }
|
164
|
+
}
|
165
|
+
return true;
|
166
|
+
}
|
167
|
+
function _getInt(str,i,minlength,maxlength) {
|
168
|
+
for (var x=maxlength; x>=minlength; x--) {
|
169
|
+
var token=str.substring(i,i+x);
|
170
|
+
if (token.length < minlength) { return null; }
|
171
|
+
if (_isInteger(token)) { return token; }
|
172
|
+
}
|
173
|
+
return null;
|
174
|
+
}
|
175
|
+
|
176
|
+
// ------------------------------------------------------------------
|
177
|
+
// getDateFromFormat( date_string , format_string )
|
178
|
+
//
|
179
|
+
// This function takes a date string and a format string. It matches
|
180
|
+
// If the date string matches the format string, it returns the
|
181
|
+
// getTime() of the date. If it does not match, it returns 0.
|
182
|
+
// ------------------------------------------------------------------
|
183
|
+
function getDateFromFormat(val,format) {
|
184
|
+
val=val+"";
|
185
|
+
format=format+"";
|
186
|
+
var i_val=0;
|
187
|
+
var i_format=0;
|
188
|
+
var c="";
|
189
|
+
var token="";
|
190
|
+
var token2="";
|
191
|
+
var x,y;
|
192
|
+
var now=new Date();
|
193
|
+
var year=now.getYear();
|
194
|
+
var month=now.getMonth()+1;
|
195
|
+
var date=1;
|
196
|
+
var hh=now.getHours();
|
197
|
+
var mm=now.getMinutes();
|
198
|
+
var ss=now.getSeconds();
|
199
|
+
var ampm="";
|
200
|
+
|
201
|
+
while (i_format < format.length) {
|
202
|
+
// Get next token from format string
|
203
|
+
c=format.charAt(i_format);
|
204
|
+
token="";
|
205
|
+
while ((format.charAt(i_format)==c) && (i_format < format.length)) {
|
206
|
+
token += format.charAt(i_format++);
|
207
|
+
}
|
208
|
+
// Extract contents of value based on format token
|
209
|
+
if (token=="yyyy" || token=="yy" || token=="y") {
|
210
|
+
if (token=="yyyy") { x=4;y=4; }
|
211
|
+
if (token=="yy") { x=2;y=2; }
|
212
|
+
if (token=="y") { x=2;y=4; }
|
213
|
+
year=_getInt(val,i_val,x,y);
|
214
|
+
if (year==null) { return 0; }
|
215
|
+
i_val += year.length;
|
216
|
+
if (year.length==2) {
|
217
|
+
if (year > 70) { year=1900+(year-0); }
|
218
|
+
else { year=2000+(year-0); }
|
219
|
+
}
|
220
|
+
}
|
221
|
+
else if (token=="MMM"||token=="NNN"){
|
222
|
+
month=0;
|
223
|
+
for (var i=0; i<MONTH_NAMES.length; i++) {
|
224
|
+
var month_name=MONTH_NAMES[i];
|
225
|
+
if (val.substring(i_val,i_val+month_name.length).toLowerCase()==month_name.toLowerCase()) {
|
226
|
+
if (token=="MMM"||(token=="NNN"&&i>11)) {
|
227
|
+
month=i+1;
|
228
|
+
if (month>12) { month -= 12; }
|
229
|
+
i_val += month_name.length;
|
230
|
+
break;
|
231
|
+
}
|
232
|
+
}
|
233
|
+
}
|
234
|
+
if ((month < 1)||(month>12)){return 0;}
|
235
|
+
}
|
236
|
+
else if (token=="EE"||token=="E"){
|
237
|
+
for (var i=0; i<DAY_NAMES.length; i++) {
|
238
|
+
var day_name=DAY_NAMES[i];
|
239
|
+
if (val.substring(i_val,i_val+day_name.length).toLowerCase()==day_name.toLowerCase()) {
|
240
|
+
i_val += day_name.length;
|
241
|
+
break;
|
242
|
+
}
|
243
|
+
}
|
244
|
+
}
|
245
|
+
else if (token=="MM"||token=="M") {
|
246
|
+
month=_getInt(val,i_val,token.length,2);
|
247
|
+
if(month==null||(month<1)||(month>12)){return 0;}
|
248
|
+
i_val+=month.length;}
|
249
|
+
else if (token=="dd"||token=="d") {
|
250
|
+
date=_getInt(val,i_val,token.length,2);
|
251
|
+
if(date==null||(date<1)||(date>31)){return 0;}
|
252
|
+
i_val+=date.length;}
|
253
|
+
else if (token=="hh"||token=="h") {
|
254
|
+
hh=_getInt(val,i_val,token.length,2);
|
255
|
+
if(hh==null||(hh<1)||(hh>12)){return 0;}
|
256
|
+
i_val+=hh.length;}
|
257
|
+
else if (token=="HH"||token=="H") {
|
258
|
+
hh=_getInt(val,i_val,token.length,2);
|
259
|
+
if(hh==null||(hh<0)||(hh>23)){return 0;}
|
260
|
+
i_val+=hh.length;}
|
261
|
+
else if (token=="KK"||token=="K") {
|
262
|
+
hh=_getInt(val,i_val,token.length,2);
|
263
|
+
if(hh==null||(hh<0)||(hh>11)){return 0;}
|
264
|
+
i_val+=hh.length;}
|
265
|
+
else if (token=="kk"||token=="k") {
|
266
|
+
hh=_getInt(val,i_val,token.length,2);
|
267
|
+
if(hh==null||(hh<1)||(hh>24)){return 0;}
|
268
|
+
i_val+=hh.length;hh--;}
|
269
|
+
else if (token=="mm"||token=="m") {
|
270
|
+
mm=_getInt(val,i_val,token.length,2);
|
271
|
+
if(mm==null||(mm<0)||(mm>59)){return 0;}
|
272
|
+
i_val+=mm.length;}
|
273
|
+
else if (token=="ss"||token=="s") {
|
274
|
+
ss=_getInt(val,i_val,token.length,2);
|
275
|
+
if(ss==null||(ss<0)||(ss>59)){return 0;}
|
276
|
+
i_val+=ss.length;}
|
277
|
+
else if (token=="a") {
|
278
|
+
if (val.substring(i_val,i_val+2).toLowerCase()=="am") {ampm="AM";}
|
279
|
+
else if (val.substring(i_val,i_val+2).toLowerCase()=="pm") {ampm="PM";}
|
280
|
+
else {return 0;}
|
281
|
+
i_val+=2;}
|
282
|
+
else {
|
283
|
+
if (val.substring(i_val,i_val+token.length)!=token) {return 0;}
|
284
|
+
else {i_val+=token.length;}
|
285
|
+
}
|
286
|
+
}
|
287
|
+
// If there are any trailing characters left in the value, it doesn't match
|
288
|
+
if (i_val != val.length) { return 0; }
|
289
|
+
// Is date valid for month?
|
290
|
+
if (month==2) {
|
291
|
+
// Check for leap year
|
292
|
+
if ( ( (year%4==0)&&(year%100 != 0) ) || (year%400==0) ) { // leap year
|
293
|
+
if (date > 29){ return 0; }
|
294
|
+
}
|
295
|
+
else { if (date > 28) { return 0; } }
|
296
|
+
}
|
297
|
+
if ((month==4)||(month==6)||(month==9)||(month==11)) {
|
298
|
+
if (date > 30) { return 0; }
|
299
|
+
}
|
300
|
+
// Correct hours value
|
301
|
+
if (hh<12 && ampm=="PM") { hh=hh-0+12; }
|
302
|
+
else if (hh>11 && ampm=="AM") { hh-=12; }
|
303
|
+
var newdate=new Date(year,month-1,date,hh,mm,ss);
|
304
|
+
return newdate.getTime();
|
305
|
+
}
|
306
|
+
|
307
|
+
// ------------------------------------------------------------------
|
308
|
+
// parseDate( date_string [, prefer_euro_format] )
|
309
|
+
//
|
310
|
+
// This function takes a date string and tries to match it to a
|
311
|
+
// number of possible date formats to get the value. It will try to
|
312
|
+
// match against the following international formats, in this order:
|
313
|
+
// y-M-d MMM d, y MMM d,y y-MMM-d d-MMM-y MMM d
|
314
|
+
// M/d/y M-d-y M.d.y MMM-d M/d M-d
|
315
|
+
// d/M/y d-M-y d.M.y d-MMM d/M d-M
|
316
|
+
// A second argument may be passed to instruct the method to search
|
317
|
+
// for formats like d/M/y (european format) before M/d/y (American).
|
318
|
+
// Returns a Date object or null if no patterns match.
|
319
|
+
// ------------------------------------------------------------------
|
320
|
+
function parseDate(val) {
|
321
|
+
var preferEuro=(arguments.length==2)?arguments[1]:false;
|
322
|
+
generalFormats=new Array('y-M-d','MMM d, y','MMM d,y','y-MMM-d','d-MMM-y','MMM d');
|
323
|
+
monthFirst=new Array('M/d/y','M-d-y','M.d.y','MMM-d','M/d','M-d');
|
324
|
+
dateFirst =new Array('d/M/y','d-M-y','d.M.y','d-MMM','d/M','d-M');
|
325
|
+
var checkList=new Array('generalFormats',preferEuro?'dateFirst':'monthFirst',preferEuro?'monthFirst':'dateFirst');
|
326
|
+
var d=null;
|
327
|
+
for (var i=0; i<checkList.length; i++) {
|
328
|
+
var l=window[checkList[i]];
|
329
|
+
for (var j=0; j<l.length; j++) {
|
330
|
+
d=getDateFromFormat(val,l[j]);
|
331
|
+
if (d!=0) { return new Date(d); }
|
332
|
+
}
|
333
|
+
}
|
334
|
+
return null;
|
335
|
+
}
|
@@ -0,0 +1,2 @@
|
|
1
|
+
'use strict';var Faye={VERSION:'0.8.9',BAYEUX_VERSION:'1.0',ID_LENGTH:160,JSONP_CALLBACK:'jsonpcallback',CONNECTION_TYPES:['long-polling','cross-origin-long-polling','callback-polling','websocket','eventsource','in-process'],MANDATORY_CONNECTION_TYPES:['long-polling','callback-polling','in-process'],ENV:(typeof global==='undefined')?window:global,extend:function(a,b,d){if(!b)return a;for(var f in b){if(!b.hasOwnProperty(f))continue;if(a.hasOwnProperty(f)&&d===false)continue;if(a[f]!==b[f])a[f]=b[f]}return a},random:function(a){a=a||this.ID_LENGTH;if(a>32){var b=Math.ceil(a/32),d='';while(b--)d+=this.random(32);var f=d.split(''),g='';while(f.length>0)g+=f.pop();return g}var h=Math.pow(2,a)-1,i=h.toString(36).length,d=Math.floor(Math.random()*h).toString(36);while(d.length<i)d='0'+d;return d},clientIdFromMessages:function(a){var b=[].concat(a)[0];return b&&b.clientId},copyObject:function(a){var b,d,f;if(a instanceof Array){b=[];d=a.length;while(d--)b[d]=Faye.copyObject(a[d]);return b}else if(typeof a==='object'){b=(a===null)?null:{};for(f in a)b[f]=Faye.copyObject(a[f]);return b}else{return a}},commonElement:function(a,b){for(var d=0,f=a.length;d<f;d++){if(this.indexOf(b,a[d])!==-1)return a[d]}return null},indexOf:function(a,b){if(a.indexOf)return a.indexOf(b);for(var d=0,f=a.length;d<f;d++){if(a[d]===b)return d}return-1},map:function(a,b,d){if(a.map)return a.map(b,d);var f=[];if(a instanceof Array){for(var g=0,h=a.length;g<h;g++){f.push(b.call(d||null,a[g],g))}}else{for(var i in a){if(!a.hasOwnProperty(i))continue;f.push(b.call(d||null,i,a[i]))}}return f},filter:function(a,b,d){var f=[];for(var g=0,h=a.length;g<h;g++){if(b.call(d||null,a[g],g))f.push(a[g])}return f},asyncEach:function(a,b,d,f){var g=a.length,h=-1,i=0,k=false;var j=function(){i-=1;h+=1;if(h===g)return d&&d.call(f);b(a[h],n)};var m=function(){if(k)return;k=true;while(i>0)j();k=false};var n=function(){i+=1;m()};n()},toJSON:function(a){if(this.stringify)return this.stringify(a,function(key,value){return(this[key]instanceof Array)?this[key]:value});return JSON.stringify(a)},logger:function(a){if(typeof console!=='undefined')console.log(a)},timestamp:function(){var b=new Date(),d=b.getFullYear(),f=b.getMonth()+1,g=b.getDate(),h=b.getHours(),i=b.getMinutes(),k=b.getSeconds();var j=function(a){return a<10?'0'+a:String(a)};return j(d)+'-'+j(f)+'-'+j(g)+' '+j(h)+':'+j(i)+':'+j(k)}};if(typeof window!=='undefined')window.Faye=Faye;Faye.Class=function(a,b){if(typeof a!=='function'){b=a;a=Object}var d=function(){if(!this.initialize)return this;return this.initialize.apply(this,arguments)||this};var f=function(){};f.prototype=a.prototype;d.prototype=new f();Faye.extend(d.prototype,b);return d};Faye.Namespace=Faye.Class({initialize:function(){this._e={}},exists:function(a){return this._e.hasOwnProperty(a)},generate:function(){var a=Faye.random();while(this._e.hasOwnProperty(a))a=Faye.random();return this._e[a]=a},release:function(a){delete this._e[a]}});Faye.Error=Faye.Class({initialize:function(a,b,d){this.code=a;this.params=Array.prototype.slice.call(b);this.message=d},toString:function(){return this.code+':'+this.params.join(',')+':'+this.message}});Faye.Error.parse=function(a){a=a||'';if(!Faye.Grammar.ERROR.test(a))return new this(null,[],a);var b=a.split(':'),d=parseInt(b[0]),f=b[1].split(','),a=b[2];return new this(d,f,a)};Faye.Error.versionMismatch=function(){return new this(300,arguments,"Version mismatch").toString()};Faye.Error.conntypeMismatch=function(){return new this(301,arguments,"Connection types not supported").toString()};Faye.Error.extMismatch=function(){return new this(302,arguments,"Extension mismatch").toString()};Faye.Error.badRequest=function(){return new this(400,arguments,"Bad request").toString()};Faye.Error.clientUnknown=function(){return new this(401,arguments,"Unknown client").toString()};Faye.Error.parameterMissing=function(){return new this(402,arguments,"Missing required parameter").toString()};Faye.Error.channelForbidden=function(){return new this(403,arguments,"Forbidden channel").toString()};Faye.Error.channelUnknown=function(){return new this(404,arguments,"Unknown channel").toString()};Faye.Error.channelInvalid=function(){return new this(405,arguments,"Invalid channel").toString()};Faye.Error.extUnknown=function(){return new this(406,arguments,"Unknown extension").toString()};Faye.Error.publishFailed=function(){return new this(407,arguments,"Failed to publish").toString()};Faye.Error.serverError=function(){return new this(500,arguments,"Internal server error").toString()};Faye.Deferrable={callback:function(a,b){if(!a)return;if(this._v==='succeeded')return a.apply(b,this._j);this._k=this._k||[];this._k.push([a,b])},timeout:function(a,b){var d=this;var f=Faye.ENV.setTimeout(function(){d.setDeferredStatus('failed',b)},a*1000);this._w=f},errback:function(a,b){if(!a)return;if(this._v==='failed')return a.apply(b,this._j);this._l=this._l||[];this._l.push([a,b])},setDeferredStatus:function(){if(this._w)Faye.ENV.clearTimeout(this._w);var a=Array.prototype.slice.call(arguments),b=a.shift(),d;this._v=b;this._j=a;if(b==='succeeded')d=this._k;else if(b==='failed')d=this._l;if(!d)return;var f;while(f=d.shift())f[0].apply(f[1],this._j)}};Faye.Publisher={countListeners:function(a){if(!this._4||!this._4[a])return 0;return this._4[a].length},bind:function(a,b,d){this._4=this._4||{};var f=this._4[a]=this._4[a]||[];f.push([b,d])},unbind:function(a,b,d){if(!this._4||!this._4[a])return;if(!b){delete this._4[a];return}var f=this._4[a],g=f.length;while(g--){if(b!==f[g][0])continue;if(d&&f[g][1]!==d)continue;f.splice(g,1)}},trigger:function(){var a=Array.prototype.slice.call(arguments),b=a.shift();if(!this._4||!this._4[b])return;var d=this._4[b].slice(),f;for(var g=0,h=d.length;g<h;g++){f=d[g];f[0].apply(f[1],a)}}};Faye.Timeouts={addTimeout:function(a,b,d,f){this._6=this._6||{};if(this._6.hasOwnProperty(a))return;var g=this;this._6[a]=Faye.ENV.setTimeout(function(){delete g._6[a];d.call(f)},1000*b)},removeTimeout:function(a){this._6=this._6||{};var b=this._6[a];if(!b)return;clearTimeout(b);delete this._6[a]}};Faye.Logging={LOG_LEVELS:{error:3,warn:2,info:1,debug:0},logLevel:'error',log:function(a,b){if(!Faye.logger)return;var d=Faye.Logging.LOG_LEVELS;if(d[Faye.Logging.logLevel]>d[b])return;var a=Array.prototype.slice.apply(a),f=' ['+b.toUpperCase()+'] [Faye',g=this.className,h=a.shift().replace(/\?/g,function(){try{return Faye.toJSON(a.shift())}catch(e){return'[Object]'}});for(var i in Faye){if(g)continue;if(typeof Faye[i]!=='function')continue;if(this instanceof Faye[i])g=i}if(g)f+='.'+g;f+='] ';Faye.logger(Faye.timestamp()+f+h)}};(function(){for(var d in Faye.Logging.LOG_LEVELS)(function(a,b){Faye.Logging[a]=function(){this.log(arguments,a)}})(d,Faye.Logging.LOG_LEVELS[d])})();Faye.Grammar={LOWALPHA:/^[a-z]$/,UPALPHA:/^[A-Z]$/,ALPHA:/^([a-z]|[A-Z])$/,DIGIT:/^[0-9]$/,ALPHANUM:/^(([a-z]|[A-Z])|[0-9])$/,MARK:/^(\-|\_|\!|\~|\(|\)|\$|\@)$/,STRING:/^(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*$/,TOKEN:/^(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+$/,INTEGER:/^([0-9])+$/,CHANNEL_SEGMENT:/^(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+$/,CHANNEL_SEGMENTS:/^(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+(\/(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+)*$/,CHANNEL_NAME:/^\/(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+(\/(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+)*$/,WILD_CARD:/^\*{1,2}$/,CHANNEL_PATTERN:/^(\/(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+)*\/\*{1,2}$/,VERSION_ELEMENT:/^(([a-z]|[A-Z])|[0-9])(((([a-z]|[A-Z])|[0-9])|\-|\_))*$/,VERSION:/^([0-9])+(\.(([a-z]|[A-Z])|[0-9])(((([a-z]|[A-Z])|[0-9])|\-|\_))*)*$/,CLIENT_ID:/^((([a-z]|[A-Z])|[0-9]))+$/,ID:/^((([a-z]|[A-Z])|[0-9]))+$/,ERROR_MESSAGE:/^(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*$/,ERROR_ARGS:/^(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*(,(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*)*$/,ERROR_CODE:/^[0-9][0-9][0-9]$/,ERROR:/^([0-9][0-9][0-9]:(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*(,(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*)*:(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*|[0-9][0-9][0-9]::(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*)$/};Faye.Extensible={addExtension:function(a){this._7=this._7||[];this._7.push(a);if(a.added)a.added(this)},removeExtension:function(a){if(!this._7)return;var b=this._7.length;while(b--){if(this._7[b]!==a)continue;this._7.splice(b,1);if(a.removed)a.removed(this)}},pipeThroughExtensions:function(d,f,g,h){this.debug('Passing through ? extensions: ?',d,f);if(!this._7)return g.call(h,f);var i=this._7.slice();var k=function(a){if(!a)return g.call(h,a);var b=i.shift();if(!b)return g.call(h,a);if(b[d])b[d](a,k);else k(a)};k(f)}};Faye.extend(Faye.Extensible,Faye.Logging);Faye.Channel=Faye.Class({initialize:function(a){this.id=this.name=a},push:function(a){this.trigger('message',a)},isUnused:function(){return this.countListeners('message')===0}});Faye.extend(Faye.Channel.prototype,Faye.Publisher);Faye.extend(Faye.Channel,{HANDSHAKE:'/meta/handshake',CONNECT:'/meta/connect',SUBSCRIBE:'/meta/subscribe',UNSUBSCRIBE:'/meta/unsubscribe',DISCONNECT:'/meta/disconnect',META:'meta',SERVICE:'service',expand:function(a){var b=this.parse(a),d=['/**',a];var f=b.slice();f[f.length-1]='*';d.push(this.unparse(f));for(var g=1,h=b.length;g<h;g++){f=b.slice(0,g);f.push('**');d.push(this.unparse(f))}return d},isValid:function(a){return Faye.Grammar.CHANNEL_NAME.test(a)||Faye.Grammar.CHANNEL_PATTERN.test(a)},parse:function(a){if(!this.isValid(a))return null;return a.split('/').slice(1)},unparse:function(a){return'/'+a.join('/')},isMeta:function(a){var b=this.parse(a);return b?(b[0]===this.META):null},isService:function(a){var b=this.parse(a);return b?(b[0]===this.SERVICE):null},isSubscribable:function(a){if(!this.isValid(a))return null;return!this.isMeta(a)&&!this.isService(a)},Set:Faye.Class({initialize:function(){this._2={}},getKeys:function(){var a=[];for(var b in this._2)a.push(b);return a},remove:function(a){delete this._2[a]},hasSubscription:function(a){return this._2.hasOwnProperty(a)},subscribe:function(a,b,d){if(!b)return;var f;for(var g=0,h=a.length;g<h;g++){f=a[g];var i=this._2[f]=this._2[f]||new Faye.Channel(f);i.bind('message',b,d)}},unsubscribe:function(a,b,d){var f=this._2[a];if(!f)return false;f.unbind('message',b,d);if(f.isUnused()){this.remove(a);return true}else{return false}},distributeMessage:function(a){var b=Faye.Channel.expand(a.channel);for(var d=0,f=b.length;d<f;d++){var g=this._2[b[d]];if(g)g.trigger('message',a.data)}}})});Faye.Publication=Faye.Class(Faye.Deferrable);Faye.Subscription=Faye.Class({initialize:function(a,b,d,f){this._8=a;this._2=b;this._m=d;this._n=f;this._x=false},cancel:function(){if(this._x)return;this._8.unsubscribe(this._2,this._m,this._n);this._x=true},unsubscribe:function(){this.cancel()}});Faye.extend(Faye.Subscription.prototype,Faye.Deferrable);Faye.Client=Faye.Class({UNCONNECTED:1,CONNECTING:2,CONNECTED:3,DISCONNECTED:4,HANDSHAKE:'handshake',RETRY:'retry',NONE:'none',CONNECTION_TIMEOUT:60.0,DEFAULT_RETRY:5.0,DEFAULT_ENDPOINT:'/bayeux',INTERVAL:0.0,initialize:function(a,b){this.info('New client created for ?',a);this._f=b||{};this.endpoint=a||this.DEFAULT_ENDPOINT;this.endpoints=this._f.endpoints||{};this.transports={};this._D=Faye.CookieJar&&new Faye.CookieJar();this._y={};this._o=[];this.retry=this._f.retry||this.DEFAULT_RETRY;this._1=this.UNCONNECTED;this._2=new Faye.Channel.Set();this._g=0;this._p={};this._9={reconnect:this.RETRY,interval:1000*(this._f.interval||this.INTERVAL),timeout:1000*(this._f.timeout||this.CONNECTION_TIMEOUT)};if(Faye.Event)Faye.Event.on(Faye.ENV,'beforeunload',function(){if(Faye.indexOf(this._o,'autodisconnect')<0)this.disconnect()},this)},disable:function(a){this._o.push(a)},setHeader:function(a,b){this._y[a]=b},getClientId:function(){return this._0},getState:function(){switch(this._1){case this.UNCONNECTED:return'UNCONNECTED';case this.CONNECTING:return'CONNECTING';case this.CONNECTED:return'CONNECTED';case this.DISCONNECTED:return'DISCONNECTED'}},handshake:function(b,d){if(this._9.reconnect===this.NONE)return;if(this._1!==this.UNCONNECTED)return;this._1=this.CONNECTING;var f=this;this.info('Initiating handshake with ?',this.endpoint);this._z(Faye.MANDATORY_CONNECTION_TYPES);this._a({channel:Faye.Channel.HANDSHAKE,version:Faye.BAYEUX_VERSION,supportedConnectionTypes:[this._5.connectionType]},function(a){if(a.successful){this._1=this.CONNECTED;this._0=a.clientId;this._z(a.supportedConnectionTypes);this.info('Handshake successful: ?',this._0);this.subscribe(this._2.getKeys(),true);if(b)b.call(d)}else{this.info('Handshake unsuccessful');Faye.ENV.setTimeout(function(){f.handshake(b,d)},this._9.interval);this._1=this.UNCONNECTED}},this)},connect:function(a,b){if(this._9.reconnect===this.NONE)return;if(this._1===this.DISCONNECTED)return;if(this._1===this.UNCONNECTED)return this.handshake(function(){this.connect(a,b)},this);this.callback(a,b);if(this._1!==this.CONNECTED)return;this.info('Calling deferred actions for ?',this._0);this.setDeferredStatus('succeeded');this.setDeferredStatus('deferred');if(this._q)return;this._q=true;this.info('Initiating connection for ?',this._0);this._a({channel:Faye.Channel.CONNECT,clientId:this._0,connectionType:this._5.connectionType},this._A,this)},disconnect:function(){if(this._1!==this.CONNECTED)return;this._1=this.DISCONNECTED;this.info('Disconnecting ?',this._0);this._a({channel:Faye.Channel.DISCONNECT,clientId:this._0},function(a){if(a.successful)this._5.close()},this);this.info('Clearing channel listeners for ?',this._0);this._2=new Faye.Channel.Set()},subscribe:function(d,f,g){if(d instanceof Array)return Faye.map(d,function(c){return this.subscribe(c,f,g)},this);var h=new Faye.Subscription(this,d,f,g),i=(f===true),k=this._2.hasSubscription(d);if(k&&!i){this._2.subscribe([d],f,g);h.setDeferredStatus('succeeded');return h}this.connect(function(){this.info('Client ? attempting to subscribe to ?',this._0,d);if(!i)this._2.subscribe([d],f,g);this._a({channel:Faye.Channel.SUBSCRIBE,clientId:this._0,subscription:d},function(a){if(!a.successful){h.setDeferredStatus('failed',Faye.Error.parse(a.error));return this._2.unsubscribe(d,f,g)}var b=[].concat(a.subscription);this.info('Subscription acknowledged for ? to ?',this._0,b);h.setDeferredStatus('succeeded')},this)},this);return h},unsubscribe:function(d,f,g){if(d instanceof Array)return Faye.map(d,function(c){return this.unsubscribe(c,f,g)},this);var h=this._2.unsubscribe(d,f,g);if(!h)return;this.connect(function(){this.info('Client ? attempting to unsubscribe from ?',this._0,d);this._a({channel:Faye.Channel.UNSUBSCRIBE,clientId:this._0,subscription:d},function(a){if(!a.successful)return;var b=[].concat(a.subscription);this.info('Unsubscription acknowledged for ? from ?',this._0,b)},this)},this)},publish:function(b,d){var f=new Faye.Publication();this.connect(function(){this.info('Client ? queueing published message to ?: ?',this._0,b,d);this._a({channel:b,data:d,clientId:this._0},function(a){if(a.successful)f.setDeferredStatus('succeeded');else f.setDeferredStatus('failed',Faye.Error.parse(a.error))},this)},this);return f},receiveMessage:function(d){this.pipeThroughExtensions('incoming',d,function(a){if(!a)return;if(a.advice)this._E(a.advice);this._F(a);if(a.successful===undefined)return;var b=this._p[a.id];if(!b)return;delete this._p[a.id];b[0].call(b[1],a)},this)},_z:function(b){Faye.Transport.get(this,b,this._o,function(a){this.debug('Selected ? transport for ?',a.connectionType,a.endpoint);if(a===this._5)return;if(this._5)this._5.close();this._5=a;this._5.cookies=this._D;this._5.headers=this._y;a.bind('down',function(){if(this._b!==undefined&&!this._b)return;this._b=false;this.trigger('transport:down')},this);a.bind('up',function(){if(this._b!==undefined&&this._b)return;this._b=true;this.trigger('transport:up')},this)},this)},_a:function(b,d,f){b.id=this._G();if(d)this._p[b.id]=[d,f];this.pipeThroughExtensions('outgoing',b,function(a){if(!a)return;this._5.send(a,this._9.timeout/1000)},this)},_G:function(){this._g+=1;if(this._g>=Math.pow(2,32))this._g=0;return this._g.toString(36)},_E:function(a){Faye.extend(this._9,a);if(this._9.reconnect===this.HANDSHAKE&&this._1!==this.DISCONNECTED){this._1=this.UNCONNECTED;this._0=null;this._A()}},_F:function(a){if(!a.channel||a.data===undefined)return;this.info('Client ? calling listeners for ? with ?',this._0,a.channel,a.data);this._2.distributeMessage(a)},_H:function(){if(!this._q)return;this._q=null;this.info('Closed connection for ?',this._0)},_A:function(){this._H();var a=this;Faye.ENV.setTimeout(function(){a.connect()},this._9.interval)}});Faye.extend(Faye.Client.prototype,Faye.Deferrable);Faye.extend(Faye.Client.prototype,Faye.Publisher);Faye.extend(Faye.Client.prototype,Faye.Logging);Faye.extend(Faye.Client.prototype,Faye.Extensible);Faye.Transport=Faye.extend(Faye.Class({MAX_DELAY:0.0,batching:true,initialize:function(a,b){this._8=a;this.endpoint=b;this._c=[]},close:function(){},send:function(a,b){this.debug('Client ? sending message to ?: ?',this._8._0,this.endpoint,a);if(!this.batching)return this.request([a],b);this._c.push(a);this._I=b;if(a.channel===Faye.Channel.HANDSHAKE)return this.addTimeout('publish',0.01,this.flush,this);if(a.channel===Faye.Channel.CONNECT)this._r=a;if(this.shouldFlush&&this.shouldFlush(this._c))return this.flush();this.addTimeout('publish',this.MAX_DELAY,this.flush,this)},flush:function(){this.removeTimeout('publish');if(this._c.length>1&&this._r)this._r.advice={timeout:0};this.request(this._c,this._I);this._r=null;this._c=[]},receive:function(a){this.debug('Client ? received from ?: ?',this._8._0,this.endpoint,a);for(var b=0,d=a.length;b<d;b++){this._8.receiveMessage(a[b])}},retry:function(a,b){var d=false,f=this._8.retry*1000,g=this;return function(){if(d)return;d=true;Faye.ENV.setTimeout(function(){g.request(a,b)},f)}}}),{MAX_URL_LENGTH:2048,get:function(k,j,m,n,o){var l=k.endpoint;Faye.asyncEach(this._B,function(d,f){var g=d[0],h=d[1],i=k.endpoints[g]||l;if(Faye.indexOf(m,g)>=0)return f();if(Faye.indexOf(j,g)<0){h.isUsable(k,i,function(){});return f()}h.isUsable(k,i,function(a){if(!a)return f();var b=h.hasOwnProperty('create')?h.create(k,i):new h(k,i);n.call(o,b)})},function(){throw new Error('Could not find a usable connection type for '+l);})},register:function(a,b){this._B.push([a,b]);b.prototype.connectionType=a},_B:[]});Faye.extend(Faye.Transport.prototype,Faye.Logging);Faye.extend(Faye.Transport.prototype,Faye.Publisher);Faye.extend(Faye.Transport.prototype,Faye.Timeouts);Faye.Event={_h:[],on:function(a,b,d,f){var g=function(){d.call(f)};if(a.addEventListener)a.addEventListener(b,g,false);else a.attachEvent('on'+b,g);this._h.push({_i:a,_s:b,_m:d,_n:f,_C:g})},detach:function(a,b,d,f){var g=this._h.length,h;while(g--){h=this._h[g];if((a&&a!==h._i)||(b&&b!==h._s)||(d&&d!==h._m)||(f&&f!==h._n))continue;if(h._i.removeEventListener)h._i.removeEventListener(h._s,h._C,false);else h._i.detachEvent('on'+h._s,h._C);this._h.splice(g,1);h=null}}};Faye.Event.on(Faye.ENV,'unload',Faye.Event.detach,Faye.Event);Faye.URI=Faye.extend(Faye.Class({queryString:function(){var a=[];for(var b in this.params){if(!this.params.hasOwnProperty(b))continue;a.push(encodeURIComponent(b)+'='+encodeURIComponent(this.params[b]))}return a.join('&')},isSameOrigin:function(){var a=Faye.URI.parse(Faye.ENV.location.href,false);var b=(a.hostname!==this.hostname)||(a.port!==this.port)||(a.protocol!==this.protocol);return!b},toURL:function(){var a=this.queryString();return this.protocol+'//'+this.hostname+(this.port?':'+this.port:'')+this.pathname+(a?'?'+a:'')+this.hash}}),{parse:function(g,h){if(typeof g!=='string')return g;var i=new this(),k;var j=function(b,d,f){g=g.replace(d,function(a){i[b]=a;return''});if(i[b]===undefined)i[b]=f?Faye.ENV.location[b]:''};j('protocol',/^https?\:/,true);j('host',/^\/\/[^\/]+/,true);if(!/^\//.test(g))g=Faye.ENV.location.pathname.replace(/[^\/]*$/,'')+g;j('pathname',/^\/[^\?#]*/);j('search',/^\?[^#]*/);j('hash',/^#.*/);if(/^\/\//.test(i.host)){i.host=i.host.substr(2);k=i.host.split(':');i.hostname=k[0];i.port=k[1]||''}else{i.hostname=Faye.ENV.location.hostname;i.port=Faye.ENV.location.port}if(h===false){i.params={}}else{var m=i.search.replace(/^\?/,''),n=m?m.split('&'):[],o=n.length,l={};while(o--){k=n[o].split('=');l[decodeURIComponent(k[0]||'')]=decodeURIComponent(k[1]||'')}if(typeof h==='object')Faye.extend(l,h);i.params=l}return i}});if(!this.JSON){JSON={}}(function(){function m(a){return a<10?'0'+a:a}if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(a){return this.getUTCFullYear()+'-'+m(this.getUTCMonth()+1)+'-'+m(this.getUTCDate())+'T'+m(this.getUTCHours())+':'+m(this.getUTCMinutes())+':'+m(this.getUTCSeconds())+'Z'};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(a){return this.valueOf()}}var n=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,o=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,l,q,t={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},p;function s(d){o.lastIndex=0;return o.test(d)?'"'+d.replace(o,function(a){var b=t[a];return typeof b==='string'?b:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+d+'"'}function r(a,b){var d,f,g,h,i=l,k,j=b[a];if(j&&typeof j==='object'&&typeof j.toJSON==='function'){j=j.toJSON(a)}if(typeof p==='function'){j=p.call(b,a,j)}switch(typeof j){case'string':return s(j);case'number':return isFinite(j)?String(j):'null';case'boolean':case'null':return String(j);case'object':if(!j){return'null'}l+=q;k=[];if(Object.prototype.toString.apply(j)==='[object Array]'){h=j.length;for(d=0;d<h;d+=1){k[d]=r(d,j)||'null'}g=k.length===0?'[]':l?'[\n'+l+k.join(',\n'+l)+'\n'+i+']':'['+k.join(',')+']';l=i;return g}if(p&&typeof p==='object'){h=p.length;for(d=0;d<h;d+=1){f=p[d];if(typeof f==='string'){g=r(f,j);if(g){k.push(s(f)+(l?': ':':')+g)}}}}else{for(f in j){if(Object.hasOwnProperty.call(j,f)){g=r(f,j);if(g){k.push(s(f)+(l?': ':':')+g)}}}}g=k.length===0?'{}':l?'{\n'+l+k.join(',\n'+l)+'\n'+i+'}':'{'+k.join(',')+'}';l=i;return g}}Faye.stringify=function(a,b,d){var f;l='';q='';if(typeof d==='number'){for(f=0;f<d;f+=1){q+=' '}}else if(typeof d==='string'){q=d}p=b;if(b&&typeof b!=='function'&&(typeof b!=='object'||typeof b.length!=='number')){throw new Error('JSON.stringify');}return r('',{'':a})};if(typeof JSON.stringify!=='function'){JSON.stringify=Faye.stringify}if(typeof JSON.parse!=='function'){JSON.parse=function(h,i){var k;function j(a,b){var d,f,g=a[b];if(g&&typeof g==='object'){for(d in g){if(Object.hasOwnProperty.call(g,d)){f=j(g,d);if(f!==undefined){g[d]=f}else{delete g[d]}}}}return i.call(a,b,g)}n.lastIndex=0;if(n.test(h)){h=h.replace(n,function(a){return'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4)})}if(/^[\],:{}\s]*$/.test(h.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){k=eval('('+h+')');return typeof i==='function'?j({'':k},''):k}throw new SyntaxError('JSON.parse');}}}());Faye.Transport.WebSocket=Faye.extend(Faye.Class(Faye.Transport,{UNCONNECTED:1,CONNECTING:2,CONNECTED:3,batching:false,isUsable:function(a,b){this.callback(function(){a.call(b,true)});this.errback(function(){a.call(b,false)});this.connect()},request:function(b,d){if(b.length===0)return;this._d=this._d||{};for(var f=0,g=b.length;f<g;f++){this._d[b[f].id]=b[f]}this.callback(function(a){a.send(Faye.toJSON(b))});this.connect()},close:function(){if(!this._3)return;this._3.onclose=this._3.onerror=null;this._3.close();delete this._3;this.setDeferredStatus('deferred');this._1=this.UNCONNECTED},connect:function(){if(Faye.Transport.WebSocket._J)return;this._1=this._1||this.UNCONNECTED;if(this._1!==this.UNCONNECTED)return;this._1=this.CONNECTING;var g=Faye.Transport.WebSocket.getClass();if(!g)return this.setDeferredStatus('failed');this._3=new g(Faye.Transport.WebSocket.getSocketUrl(this.endpoint));var h=this;this._3.onopen=function(){h._1=h.CONNECTED;h._t=true;h.setDeferredStatus('succeeded',h._3);h.trigger('up')};this._3.onmessage=function(a){var b=JSON.parse(a.data);if(!b)return;b=[].concat(b);for(var d=0,f=b.length;d<f;d++){delete h._d[b[d].id]}h.receive(b)};this._3.onclose=this._3.onerror=function(){var a=(h._1===h.CONNECTED);h.setDeferredStatus('deferred');h._1=h.UNCONNECTED;h.close();if(a)return h.resend();if(!h._t)return h.setDeferredStatus('failed');var b=h._8.retry*1000;Faye.ENV.setTimeout(function(){h.connect()},b);h.trigger('down')}},resend:function(){if(!this._d)return;var d=Faye.map(this._d,function(a,b){return b});this.request(d)}}),{getSocketUrl:function(a){if(Faye.URI)a=Faye.URI.parse(a).toURL();return a.replace(/^http(s?):/ig,'ws$1:')},getClass:function(){return(Faye.WebSocket&&Faye.WebSocket.Client)||Faye.ENV.WebSocket||Faye.ENV.MozWebSocket},isUsable:function(a,b,d,f){this.create(a,b).isUsable(d,f)},create:function(a,b){var d=a.transports.websocket=a.transports.websocket||{};d[b]=d[b]||new this(a,b);return d[b]}});Faye.extend(Faye.Transport.WebSocket.prototype,Faye.Deferrable);Faye.Transport.register('websocket',Faye.Transport.WebSocket);if(Faye.Event)Faye.Event.on(Faye.ENV,'beforeunload',function(){Faye.Transport.WebSocket._J=true});Faye.Transport.EventSource=Faye.extend(Faye.Class(Faye.Transport,{initialize:function(b,d){Faye.Transport.prototype.initialize.call(this,b,d);if(!Faye.ENV.EventSource)return this.setDeferredStatus('failed');this._K=new Faye.Transport.XHR(b,d);var f=new EventSource(d+'/'+b.getClientId()),g=this;f.onopen=function(){g._t=true;g.setDeferredStatus('succeeded');g.trigger('up')};f.onerror=function(){if(g._t){g.trigger('down')}else{g.setDeferredStatus('failed');f.close()}};f.onmessage=function(a){g.receive(JSON.parse(a.data));g.trigger('up')};this._3=f},isUsable:function(a,b){this.callback(function(){a.call(b,true)});this.errback(function(){a.call(b,false)})},request:function(a,b){this._K.request(a,b)},close:function(){if(!this._3)return;this._3.onerror=null;this._3.close();delete this._3}}),{isUsable:function(b,d,f,g){var h=b.getClientId();if(!h)return f.call(g,false);Faye.Transport.XHR.isUsable(b,d,function(a){if(!a)return f.call(g,false);this.create(b,d).isUsable(f,g)},this)},create:function(a,b){var d=a.transports.eventsource=a.transports.eventsource||{},f=a.getClientId(),b=b+'/'+(f||'');d[b]=d[b]||new this(a,b);return d[b]}});Faye.extend(Faye.Transport.EventSource.prototype,Faye.Deferrable);Faye.Transport.register('eventsource',Faye.Transport.EventSource);Faye.Transport.XHR=Faye.extend(Faye.Class(Faye.Transport,{request:function(f,g){var h=this.retry(f,g),i=Faye.URI.parse(this.endpoint).pathname,k=this,j=Faye.ENV.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();j.open('POST',i,true);j.setRequestHeader('Content-Type','application/json');j.setRequestHeader('Pragma','no-cache');j.setRequestHeader('X-Requested-With','XMLHttpRequest');var m=this.headers;for(var n in m){if(!m.hasOwnProperty(n))continue;j.setRequestHeader(n,m[n])}var o=function(){j.abort()};Faye.Event.on(Faye.ENV,'beforeunload',o);var l=function(){Faye.Event.detach(Faye.ENV,'beforeunload',o);j.onreadystatechange=function(){};j=null};j.onreadystatechange=function(){if(j.readyState!==4)return;var a=null,b=j.status,d=((b>=200&&b<300)||b===304||b===1223);if(!d){l();h();return k.trigger('down')}try{a=JSON.parse(j.responseText)}catch(e){}l();if(a){k.receive(a);k.trigger('up')}else{h();k.trigger('down')}};j.send(Faye.toJSON(f))}}),{isUsable:function(a,b,d,f){d.call(f,Faye.URI.parse(b).isSameOrigin())}});Faye.Transport.register('long-polling',Faye.Transport.XHR);Faye.Transport.CORS=Faye.extend(Faye.Class(Faye.Transport,{request:function(b,d){var f=Faye.ENV.XDomainRequest?XDomainRequest:XMLHttpRequest,g=new f(),h=this.retry(b,d),i=this;g.open('POST',this.endpoint,true);if(g.setRequestHeader)g.setRequestHeader('Pragma','no-cache');var k=function(){if(!g)return false;g.onload=g.onerror=g.ontimeout=g.onprogress=null;g=null;Faye.ENV.clearTimeout(m);return true};g.onload=function(){var a=null;try{a=JSON.parse(g.responseText)}catch(e){}k();if(a){i.receive(a);i.trigger('up')}else{h();i.trigger('down')}};var j=function(){k();h();i.trigger('down')};var m=Faye.ENV.setTimeout(j,1.5*1000*d);g.onerror=j;g.ontimeout=j;g.onprogress=function(){};g.send('message='+encodeURIComponent(Faye.toJSON(b)))}}),{isUsable:function(a,b,d,f){if(Faye.URI.parse(b).isSameOrigin())return d.call(f,false);if(Faye.ENV.XDomainRequest)return d.call(f,Faye.URI.parse(b).protocol===Faye.URI.parse(Faye.ENV.location).protocol);if(Faye.ENV.XMLHttpRequest){var g=new Faye.ENV.XMLHttpRequest();return d.call(f,g.withCredentials!==undefined)}return d.call(f,false)}});Faye.Transport.register('cross-origin-long-polling',Faye.Transport.CORS);Faye.Transport.JSONP=Faye.extend(Faye.Class(Faye.Transport,{shouldFlush:function(a){var b={message:Faye.toJSON(a),jsonp:'__jsonp'+Faye.Transport.JSONP._u+'__'};var d=Faye.URI.parse(this.endpoint,b).toURL();return d.length>=Faye.Transport.MAX_URL_LENGTH},request:function(b,d){var f={message:Faye.toJSON(b)},g=document.getElementsByTagName('head')[0],h=document.createElement('script'),i=Faye.Transport.JSONP.getCallbackName(),k=Faye.URI.parse(this.endpoint,f),j=this.retry(b,d),m=this;Faye.ENV[i]=function(a){o();m.receive(a);m.trigger('up')};var n=Faye.ENV.setTimeout(function(){o();j();m.trigger('down')},1.5*1000*d);var o=function(){if(!Faye.ENV[i])return false;Faye.ENV[i]=undefined;try{delete Faye.ENV[i]}catch(e){}Faye.ENV.clearTimeout(n);h.parentNode.removeChild(h);return true};k.params.jsonp=i;h.type='text/javascript';h.src=k.toURL();g.appendChild(h)}}),{_u:0,getCallbackName:function(){this._u+=1;return'__jsonp'+this._u+'__'},isUsable:function(a,b,d,f){d.call(f,true)}});Faye.Transport.register('callback-polling',Faye.Transport.JSONP);
|
2
|
+
//@ sourceMappingURL=faye-browser-min.js.map
|
@@ -0,0 +1,178 @@
|
|
1
|
+
/*
|
2
|
+
* jQuery JSON Plugin
|
3
|
+
* version: 2.1 (2009-08-14)
|
4
|
+
*
|
5
|
+
* This document is licensed as free software under the terms of the
|
6
|
+
* MIT License: http://www.opensource.org/licenses/mit-license.php
|
7
|
+
*
|
8
|
+
* Brantley Harris wrote this plugin. It is based somewhat on the JSON.org
|
9
|
+
* website's http://www.json.org/json2.js, which proclaims:
|
10
|
+
* "NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.", a sentiment that
|
11
|
+
* I uphold.
|
12
|
+
*
|
13
|
+
* It is also influenced heavily by MochiKit's serializeJSON, which is
|
14
|
+
* copyrighted 2005 by Bob Ippolito.
|
15
|
+
*/
|
16
|
+
|
17
|
+
(function($) {
|
18
|
+
/** jQuery.toJSON( json-serializble )
|
19
|
+
Converts the given argument into a JSON respresentation.
|
20
|
+
|
21
|
+
If an object has a "toJSON" function, that will be used to get the representation.
|
22
|
+
Non-integer/string keys are skipped in the object, as are keys that point to a function.
|
23
|
+
|
24
|
+
json-serializble:
|
25
|
+
The *thing* to be converted.
|
26
|
+
**/
|
27
|
+
$.toJSON = function(o)
|
28
|
+
{
|
29
|
+
if (typeof(JSON) == 'object' && JSON.stringify)
|
30
|
+
return JSON.stringify(o);
|
31
|
+
|
32
|
+
var type = typeof(o);
|
33
|
+
|
34
|
+
if (o === null)
|
35
|
+
return "null";
|
36
|
+
|
37
|
+
if (type == "undefined")
|
38
|
+
return undefined;
|
39
|
+
|
40
|
+
if (type == "number" || type == "boolean")
|
41
|
+
return o + "";
|
42
|
+
|
43
|
+
if (type == "string")
|
44
|
+
return $.quoteString(o);
|
45
|
+
|
46
|
+
if (type == 'object')
|
47
|
+
{
|
48
|
+
if (typeof o.toJSON == "function")
|
49
|
+
return $.toJSON( o.toJSON() );
|
50
|
+
|
51
|
+
if (o.constructor === Date)
|
52
|
+
{
|
53
|
+
var month = o.getUTCMonth() + 1;
|
54
|
+
if (month < 10) month = '0' + month;
|
55
|
+
|
56
|
+
var day = o.getUTCDate();
|
57
|
+
if (day < 10) day = '0' + day;
|
58
|
+
|
59
|
+
var year = o.getUTCFullYear();
|
60
|
+
|
61
|
+
var hours = o.getUTCHours();
|
62
|
+
if (hours < 10) hours = '0' + hours;
|
63
|
+
|
64
|
+
var minutes = o.getUTCMinutes();
|
65
|
+
if (minutes < 10) minutes = '0' + minutes;
|
66
|
+
|
67
|
+
var seconds = o.getUTCSeconds();
|
68
|
+
if (seconds < 10) seconds = '0' + seconds;
|
69
|
+
|
70
|
+
var milli = o.getUTCMilliseconds();
|
71
|
+
if (milli < 100) milli = '0' + milli;
|
72
|
+
if (milli < 10) milli = '0' + milli;
|
73
|
+
|
74
|
+
return '"' + year + '-' + month + '-' + day + 'T' +
|
75
|
+
hours + ':' + minutes + ':' + seconds +
|
76
|
+
'.' + milli + 'Z"';
|
77
|
+
}
|
78
|
+
|
79
|
+
if (o.constructor === Array)
|
80
|
+
{
|
81
|
+
var ret = [];
|
82
|
+
for (var i = 0; i < o.length; i++)
|
83
|
+
ret.push( $.toJSON(o[i]) || "null" );
|
84
|
+
|
85
|
+
return "[" + ret.join(",") + "]";
|
86
|
+
}
|
87
|
+
|
88
|
+
var pairs = [];
|
89
|
+
for (var k in o) {
|
90
|
+
var name;
|
91
|
+
var type = typeof k;
|
92
|
+
|
93
|
+
if (type == "number")
|
94
|
+
name = '"' + k + '"';
|
95
|
+
else if (type == "string")
|
96
|
+
name = $.quoteString(k);
|
97
|
+
else
|
98
|
+
continue; //skip non-string or number keys
|
99
|
+
|
100
|
+
if (typeof o[k] == "function")
|
101
|
+
continue; //skip pairs where the value is a function.
|
102
|
+
|
103
|
+
var val = $.toJSON(o[k]);
|
104
|
+
|
105
|
+
pairs.push(name + ":" + val);
|
106
|
+
}
|
107
|
+
|
108
|
+
return "{" + pairs.join(", ") + "}";
|
109
|
+
}
|
110
|
+
};
|
111
|
+
|
112
|
+
/** jQuery.evalJSON(src)
|
113
|
+
Evaluates a given piece of json source.
|
114
|
+
**/
|
115
|
+
$.evalJSON = function(src)
|
116
|
+
{
|
117
|
+
if (typeof(JSON) == 'object' && JSON.parse)
|
118
|
+
return JSON.parse(src);
|
119
|
+
return eval("(" + src + ")");
|
120
|
+
};
|
121
|
+
|
122
|
+
/** jQuery.secureEvalJSON(src)
|
123
|
+
Evals JSON in a way that is *more* secure.
|
124
|
+
**/
|
125
|
+
$.secureEvalJSON = function(src)
|
126
|
+
{
|
127
|
+
if (typeof(JSON) == 'object' && JSON.parse)
|
128
|
+
return JSON.parse(src);
|
129
|
+
|
130
|
+
var filtered = src;
|
131
|
+
filtered = filtered.replace(/\\["\\\/bfnrtu]/g, '@');
|
132
|
+
filtered = filtered.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']');
|
133
|
+
filtered = filtered.replace(/(?:^|:|,)(?:\s*\[)+/g, '');
|
134
|
+
|
135
|
+
if (/^[\],:{}\s]*$/.test(filtered))
|
136
|
+
return eval("(" + src + ")");
|
137
|
+
else
|
138
|
+
throw new SyntaxError("Error parsing JSON, source is not valid.");
|
139
|
+
};
|
140
|
+
|
141
|
+
/** jQuery.quoteString(string)
|
142
|
+
Returns a string-repr of a string, escaping quotes intelligently.
|
143
|
+
Mostly a support function for toJSON.
|
144
|
+
|
145
|
+
Examples:
|
146
|
+
>>> jQuery.quoteString("apple")
|
147
|
+
"apple"
|
148
|
+
|
149
|
+
>>> jQuery.quoteString('"Where are we going?", she asked.')
|
150
|
+
"\"Where are we going?\", she asked."
|
151
|
+
**/
|
152
|
+
$.quoteString = function(string)
|
153
|
+
{
|
154
|
+
if (string.match(_escapeable))
|
155
|
+
{
|
156
|
+
return '"' + string.replace(_escapeable, function (a)
|
157
|
+
{
|
158
|
+
var c = _meta[a];
|
159
|
+
if (typeof c === 'string') return c;
|
160
|
+
c = a.charCodeAt();
|
161
|
+
return '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16);
|
162
|
+
}) + '"';
|
163
|
+
}
|
164
|
+
return '"' + string + '"';
|
165
|
+
};
|
166
|
+
|
167
|
+
var _escapeable = /["\\\x00-\x1f\x7f-\x9f]/g;
|
168
|
+
|
169
|
+
var _meta = {
|
170
|
+
'\b': '\\b',
|
171
|
+
'\t': '\\t',
|
172
|
+
'\n': '\\n',
|
173
|
+
'\f': '\\f',
|
174
|
+
'\r': '\\r',
|
175
|
+
'"' : '\\"',
|
176
|
+
'\\': '\\\\'
|
177
|
+
};
|
178
|
+
})(jQuery);
|