swagger_yard 0.0.5 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +126 -99
- data/Rakefile +6 -22
- data/lib/swagger_yard/api.rb +26 -109
- data/lib/swagger_yard/api_declaration.rb +89 -23
- data/lib/swagger_yard/authorization.rb +36 -0
- data/lib/swagger_yard/configuration.rb +14 -0
- data/lib/swagger_yard/listing_info.rb +15 -0
- data/lib/swagger_yard/model.rb +69 -0
- data/lib/swagger_yard/operation.rb +149 -0
- data/lib/swagger_yard/parameter.rb +62 -3
- data/lib/swagger_yard/property.rb +36 -0
- data/lib/swagger_yard/resource_listing.rb +57 -18
- data/lib/swagger_yard/type.rb +34 -0
- data/lib/swagger_yard/version.rb +1 -1
- data/lib/swagger_yard.rb +35 -78
- metadata +70 -48
- data/app/controllers/swagger_yard/application_controller.rb +0 -4
- data/app/controllers/swagger_yard/swagger_controller.rb +0 -21
- data/app/views/swagger_yard/swagger/doc.html.erb +0 -80
- data/lib/generators/swagger_yard/doc_generator.rb +0 -11
- data/lib/generators/swagger_yard/js_generator.rb +0 -13
- data/lib/swagger_yard/cache.rb +0 -50
- data/lib/swagger_yard/engine.rb +0 -18
- data/lib/swagger_yard/local_dispatcher.rb +0 -51
- data/lib/swagger_yard/parser.rb +0 -35
- data/public/swagger-ui/css/hightlight.default.css +0 -135
- data/public/swagger-ui/css/screen.css +0 -1759
- data/public/swagger-ui/images/logo_small.png +0 -0
- data/public/swagger-ui/images/pet_store_api.png +0 -0
- data/public/swagger-ui/images/throbber.gif +0 -0
- data/public/swagger-ui/images/wordnik_api.png +0 -0
- data/public/swagger-ui/lib/MD5.js +0 -319
- data/public/swagger-ui/lib/backbone-min.js +0 -38
- data/public/swagger-ui/lib/handlebars-1.0.rc.1.js +0 -1920
- data/public/swagger-ui/lib/highlight.7.3.pack.js +0 -1
- data/public/swagger-ui/lib/jquery-1.8.0.min.js +0 -2
- data/public/swagger-ui/lib/jquery.ba-bbq.min.js +0 -18
- data/public/swagger-ui/lib/jquery.slideto.min.js +0 -1
- data/public/swagger-ui/lib/jquery.wiggle.min.js +0 -8
- data/public/swagger-ui/lib/swagger.js +0 -794
- data/public/swagger-ui/lib/underscore-min.js +0 -32
- data/public/swagger-ui/swagger-ui.js +0 -2090
- data/public/swagger-ui/swagger-ui_org.js +0 -2005
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -1,319 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
Javascript MD5 library - version 0.4 (Modified)
|
3
|
-
|
4
|
-
Coded (2011) by Luigi Galli - LG@4e71.org - http://faultylabs.com
|
5
|
-
Thanks to: Roberto Viola
|
6
|
-
Modified at SyncTV, Inc. 2012 to employ AMD module loading and not uppercase result string.
|
7
|
-
|
8
|
-
The below code is PUBLIC DOMAIN - NO WARRANTY!
|
9
|
-
*/
|
10
|
-
|
11
|
-
/**
|
12
|
-
* @name MD5
|
13
|
-
* @namespace Utility for dealing with MD5 hashes.
|
14
|
-
*/
|
15
|
-
|
16
|
-
/**
|
17
|
-
@name hash
|
18
|
-
@memberof MD5
|
19
|
-
@function
|
20
|
-
@description Computes the MD5 hash for the given input data
|
21
|
-
|
22
|
-
@param {String|String[]|Number[]|ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|Uint16Array|Uint32Array|Uint8Array} data
|
23
|
-
data as String - (Assumes Unicode code points are encoded as UTF-8. If you
|
24
|
-
attempt to digest Unicode strings using other encodings
|
25
|
-
you will get incorrect results!)
|
26
|
-
<br />
|
27
|
-
data as array of characters - (Assumes Unicode code points are encoded as UTF-8. If you
|
28
|
-
attempt to digest Unicode strings using other encodings
|
29
|
-
you will get incorrect results!)
|
30
|
-
<br />
|
31
|
-
data as array of bytes (plain javascript array of integer numbers)
|
32
|
-
<br />
|
33
|
-
data as ArrayBuffer (see: https://developer.mozilla.org/en/JavaScript_typed_arrays)
|
34
|
-
<br />
|
35
|
-
data as Float32Array, Float64Array, Int16Array, Int32Array, Int8Array, Uint16Array, Uint32Array or Uint8Array (see: https://developer.mozilla.org/en/JavaScript_typed_arrays)
|
36
|
-
|
37
|
-
@returns {String} MD5 hash as lowercase hex string.
|
38
|
-
*/
|
39
|
-
|
40
|
-
var MD5 = {};
|
41
|
-
MD5.hash = function(data) {
|
42
|
-
|
43
|
-
// convert number to (unsigned) 32 bit hex, zero filled string
|
44
|
-
function to_zerofilled_hex(n) {
|
45
|
-
var t1 = (n >>> 0).toString(16)
|
46
|
-
return "00000000".substr(0, 8 - t1.length) + t1
|
47
|
-
}
|
48
|
-
|
49
|
-
// convert array of chars to array of bytes
|
50
|
-
function chars_to_bytes(ac) {
|
51
|
-
var retval = []
|
52
|
-
for(var i = 0; i < ac.length; i++) {
|
53
|
-
retval = retval.concat(str_to_bytes(ac[i]))
|
54
|
-
}
|
55
|
-
return retval
|
56
|
-
}
|
57
|
-
|
58
|
-
// convert a 64 bit unsigned number to array of bytes. Little endian
|
59
|
-
function int64_to_bytes(num) {
|
60
|
-
var retval = []
|
61
|
-
for(var i = 0; i < 8; i++) {
|
62
|
-
retval.push(num & 0xFF)
|
63
|
-
num = num >>> 8
|
64
|
-
}
|
65
|
-
return retval
|
66
|
-
}
|
67
|
-
|
68
|
-
// 32 bit left-rotation
|
69
|
-
function rol(num, places) {
|
70
|
-
return ((num << places) & 0xFFFFFFFF) | (num >>> (32 - places))
|
71
|
-
}
|
72
|
-
|
73
|
-
// The 4 MD5 functions
|
74
|
-
function fF(b, c, d) {
|
75
|
-
return (b & c) | (~b & d)
|
76
|
-
}
|
77
|
-
|
78
|
-
function fG(b, c, d) {
|
79
|
-
return (d & b) | (~d & c)
|
80
|
-
}
|
81
|
-
|
82
|
-
function fH(b, c, d) {
|
83
|
-
return b ^ c ^ d
|
84
|
-
}
|
85
|
-
|
86
|
-
function fI(b, c, d) {
|
87
|
-
return c ^ (b | ~d)
|
88
|
-
}
|
89
|
-
|
90
|
-
// pick 4 bytes at specified offset. Little-endian is assumed
|
91
|
-
function bytes_to_int32(arr, off) {
|
92
|
-
return (arr[off + 3] << 24) | (arr[off + 2] << 16) | (arr[off + 1] << 8) | (arr[off])
|
93
|
-
}
|
94
|
-
|
95
|
-
/*
|
96
|
-
Conver string to array of bytes in UTF-8 encoding
|
97
|
-
See:
|
98
|
-
http://www.dangrossman.info/2007/05/25/handling-utf-8-in-javascript-php-and-non-utf8-databases/
|
99
|
-
http://stackoverflow.com/questions/1240408/reading-bytes-from-a-javascript-string
|
100
|
-
How about a String.getBytes(<ENCODING>) for Javascript!? Isn't it time to add it?
|
101
|
-
*/
|
102
|
-
function str_to_bytes(str) {
|
103
|
-
var retval = []
|
104
|
-
for(var i = 0; i < str.length; i++)
|
105
|
-
if(str.charCodeAt(i) <= 0x7F) {
|
106
|
-
retval.push(str.charCodeAt(i))
|
107
|
-
} else {
|
108
|
-
var tmp = encodeURIComponent(str.charAt(i)).substr(1).split('%')
|
109
|
-
for(var j = 0; j < tmp.length; j++) {
|
110
|
-
retval.push(parseInt(tmp[j], 0x10))
|
111
|
-
}
|
112
|
-
}
|
113
|
-
return retval
|
114
|
-
}
|
115
|
-
|
116
|
-
// convert the 4 32-bit buffers to a 128 bit hex string. (Little-endian is assumed)
|
117
|
-
function int128le_to_hex(a, b, c, d) {
|
118
|
-
var ra = ""
|
119
|
-
var t = 0
|
120
|
-
var ta = 0
|
121
|
-
for(var i = 3; i >= 0; i--) {
|
122
|
-
ta = arguments[i]
|
123
|
-
t = (ta & 0xFF)
|
124
|
-
ta = ta >>> 8
|
125
|
-
t = t << 8
|
126
|
-
t = t | (ta & 0xFF)
|
127
|
-
ta = ta >>> 8
|
128
|
-
t = t << 8
|
129
|
-
t = t | (ta & 0xFF)
|
130
|
-
ta = ta >>> 8
|
131
|
-
t = t << 8
|
132
|
-
t = t | ta
|
133
|
-
ra = ra + to_zerofilled_hex(t)
|
134
|
-
}
|
135
|
-
return ra
|
136
|
-
}
|
137
|
-
|
138
|
-
// conversion from typed byte array to plain javascript array
|
139
|
-
function typed_to_plain(tarr) {
|
140
|
-
var retval = new Array(tarr.length)
|
141
|
-
for(var i = 0; i < tarr.length; i++) {
|
142
|
-
retval[i] = tarr[i]
|
143
|
-
}
|
144
|
-
return retval
|
145
|
-
}
|
146
|
-
|
147
|
-
// check input data type and perform conversions if needed
|
148
|
-
var databytes = null
|
149
|
-
// String
|
150
|
-
var type_mismatch = null
|
151
|
-
if( typeof data == 'string') {
|
152
|
-
// convert string to array bytes
|
153
|
-
databytes = str_to_bytes(data)
|
154
|
-
} else if(data.constructor == Array) {
|
155
|
-
if(data.length === 0) {
|
156
|
-
// if it's empty, just assume array of bytes
|
157
|
-
databytes = data
|
158
|
-
} else if( typeof data[0] == 'string') {
|
159
|
-
databytes = chars_to_bytes(data)
|
160
|
-
} else if( typeof data[0] == 'number') {
|
161
|
-
databytes = data
|
162
|
-
} else {
|
163
|
-
type_mismatch = typeof data[0]
|
164
|
-
}
|
165
|
-
} else if( typeof ArrayBuffer != 'undefined') {
|
166
|
-
if( data instanceof ArrayBuffer) {
|
167
|
-
databytes = typed_to_plain(new Uint8Array(data))
|
168
|
-
} else if(( data instanceof Uint8Array) || ( data instanceof Int8Array)) {
|
169
|
-
databytes = typed_to_plain(data)
|
170
|
-
} else if(( data instanceof Uint32Array) || ( data instanceof Int32Array) || ( data instanceof Uint16Array) || ( data instanceof Int16Array) || ( data instanceof Float32Array) || ( data instanceof Float64Array)) {
|
171
|
-
databytes = typed_to_plain(new Uint8Array(data.buffer))
|
172
|
-
} else {
|
173
|
-
type_mismatch = typeof data
|
174
|
-
}
|
175
|
-
} else {
|
176
|
-
type_mismatch = typeof data
|
177
|
-
}
|
178
|
-
|
179
|
-
if(type_mismatch) {
|
180
|
-
alert('MD5 type mismatch, cannot process ' + type_mismatch)
|
181
|
-
}
|
182
|
-
|
183
|
-
function _add(n1, n2) {
|
184
|
-
return 0x0FFFFFFFF & (n1 + n2)
|
185
|
-
}
|
186
|
-
|
187
|
-
return do_digest()
|
188
|
-
|
189
|
-
function do_digest() {
|
190
|
-
|
191
|
-
// function update partial state for each run
|
192
|
-
function updateRun(nf, sin32, dw32, b32) {
|
193
|
-
var temp = d
|
194
|
-
d = c
|
195
|
-
c = b
|
196
|
-
//b = b + rol(a + (nf + (sin32 + dw32)), b32)
|
197
|
-
b = _add(b, rol(_add(a, _add(nf, _add(sin32, dw32))), b32))
|
198
|
-
a = temp
|
199
|
-
}
|
200
|
-
|
201
|
-
// save original length
|
202
|
-
var org_len = databytes.length
|
203
|
-
|
204
|
-
// first append the "1" + 7x "0"
|
205
|
-
databytes.push(0x80)
|
206
|
-
|
207
|
-
// determine required amount of padding
|
208
|
-
var tail = databytes.length % 64
|
209
|
-
// no room for msg length?
|
210
|
-
if(tail > 56) {
|
211
|
-
// pad to next 512 bit block
|
212
|
-
for(var i = 0; i < (64 - tail); i++) {
|
213
|
-
databytes.push(0x0)
|
214
|
-
}
|
215
|
-
tail = databytes.length % 64
|
216
|
-
}
|
217
|
-
for( i = 0; i < (56 - tail); i++) {
|
218
|
-
databytes.push(0x0)
|
219
|
-
}
|
220
|
-
// message length in bits mod 512 should now be 448
|
221
|
-
// append 64 bit, little-endian original msg length (in *bits*!)
|
222
|
-
databytes = databytes.concat(int64_to_bytes(org_len * 8))
|
223
|
-
|
224
|
-
// initialize 4x32 bit state
|
225
|
-
var h0 = 0x67452301
|
226
|
-
var h1 = 0xEFCDAB89
|
227
|
-
var h2 = 0x98BADCFE
|
228
|
-
var h3 = 0x10325476
|
229
|
-
|
230
|
-
// temp buffers
|
231
|
-
var a = 0, b = 0, c = 0, d = 0
|
232
|
-
|
233
|
-
// Digest message
|
234
|
-
for( i = 0; i < databytes.length / 64; i++) {
|
235
|
-
// initialize run
|
236
|
-
a = h0
|
237
|
-
b = h1
|
238
|
-
c = h2
|
239
|
-
d = h3
|
240
|
-
|
241
|
-
var ptr = i * 64
|
242
|
-
|
243
|
-
// do 64 runs
|
244
|
-
updateRun(fF(b, c, d), 0xd76aa478, bytes_to_int32(databytes, ptr), 7)
|
245
|
-
updateRun(fF(b, c, d), 0xe8c7b756, bytes_to_int32(databytes, ptr + 4), 12)
|
246
|
-
updateRun(fF(b, c, d), 0x242070db, bytes_to_int32(databytes, ptr + 8), 17)
|
247
|
-
updateRun(fF(b, c, d), 0xc1bdceee, bytes_to_int32(databytes, ptr + 12), 22)
|
248
|
-
updateRun(fF(b, c, d), 0xf57c0faf, bytes_to_int32(databytes, ptr + 16), 7)
|
249
|
-
updateRun(fF(b, c, d), 0x4787c62a, bytes_to_int32(databytes, ptr + 20), 12)
|
250
|
-
updateRun(fF(b, c, d), 0xa8304613, bytes_to_int32(databytes, ptr + 24), 17)
|
251
|
-
updateRun(fF(b, c, d), 0xfd469501, bytes_to_int32(databytes, ptr + 28), 22)
|
252
|
-
updateRun(fF(b, c, d), 0x698098d8, bytes_to_int32(databytes, ptr + 32), 7)
|
253
|
-
updateRun(fF(b, c, d), 0x8b44f7af, bytes_to_int32(databytes, ptr + 36), 12)
|
254
|
-
updateRun(fF(b, c, d), 0xffff5bb1, bytes_to_int32(databytes, ptr + 40), 17)
|
255
|
-
updateRun(fF(b, c, d), 0x895cd7be, bytes_to_int32(databytes, ptr + 44), 22)
|
256
|
-
updateRun(fF(b, c, d), 0x6b901122, bytes_to_int32(databytes, ptr + 48), 7)
|
257
|
-
updateRun(fF(b, c, d), 0xfd987193, bytes_to_int32(databytes, ptr + 52), 12)
|
258
|
-
updateRun(fF(b, c, d), 0xa679438e, bytes_to_int32(databytes, ptr + 56), 17)
|
259
|
-
updateRun(fF(b, c, d), 0x49b40821, bytes_to_int32(databytes, ptr + 60), 22)
|
260
|
-
updateRun(fG(b, c, d), 0xf61e2562, bytes_to_int32(databytes, ptr + 4), 5)
|
261
|
-
updateRun(fG(b, c, d), 0xc040b340, bytes_to_int32(databytes, ptr + 24), 9)
|
262
|
-
updateRun(fG(b, c, d), 0x265e5a51, bytes_to_int32(databytes, ptr + 44), 14)
|
263
|
-
updateRun(fG(b, c, d), 0xe9b6c7aa, bytes_to_int32(databytes, ptr), 20)
|
264
|
-
updateRun(fG(b, c, d), 0xd62f105d, bytes_to_int32(databytes, ptr + 20), 5)
|
265
|
-
updateRun(fG(b, c, d), 0x2441453, bytes_to_int32(databytes, ptr + 40), 9)
|
266
|
-
updateRun(fG(b, c, d), 0xd8a1e681, bytes_to_int32(databytes, ptr + 60), 14)
|
267
|
-
updateRun(fG(b, c, d), 0xe7d3fbc8, bytes_to_int32(databytes, ptr + 16), 20)
|
268
|
-
updateRun(fG(b, c, d), 0x21e1cde6, bytes_to_int32(databytes, ptr + 36), 5)
|
269
|
-
updateRun(fG(b, c, d), 0xc33707d6, bytes_to_int32(databytes, ptr + 56), 9)
|
270
|
-
updateRun(fG(b, c, d), 0xf4d50d87, bytes_to_int32(databytes, ptr + 12), 14)
|
271
|
-
updateRun(fG(b, c, d), 0x455a14ed, bytes_to_int32(databytes, ptr + 32), 20)
|
272
|
-
updateRun(fG(b, c, d), 0xa9e3e905, bytes_to_int32(databytes, ptr + 52), 5)
|
273
|
-
updateRun(fG(b, c, d), 0xfcefa3f8, bytes_to_int32(databytes, ptr + 8), 9)
|
274
|
-
updateRun(fG(b, c, d), 0x676f02d9, bytes_to_int32(databytes, ptr + 28), 14)
|
275
|
-
updateRun(fG(b, c, d), 0x8d2a4c8a, bytes_to_int32(databytes, ptr + 48), 20)
|
276
|
-
updateRun(fH(b, c, d), 0xfffa3942, bytes_to_int32(databytes, ptr + 20), 4)
|
277
|
-
updateRun(fH(b, c, d), 0x8771f681, bytes_to_int32(databytes, ptr + 32), 11)
|
278
|
-
updateRun(fH(b, c, d), 0x6d9d6122, bytes_to_int32(databytes, ptr + 44), 16)
|
279
|
-
updateRun(fH(b, c, d), 0xfde5380c, bytes_to_int32(databytes, ptr + 56), 23)
|
280
|
-
updateRun(fH(b, c, d), 0xa4beea44, bytes_to_int32(databytes, ptr + 4), 4)
|
281
|
-
updateRun(fH(b, c, d), 0x4bdecfa9, bytes_to_int32(databytes, ptr + 16), 11)
|
282
|
-
updateRun(fH(b, c, d), 0xf6bb4b60, bytes_to_int32(databytes, ptr + 28), 16)
|
283
|
-
updateRun(fH(b, c, d), 0xbebfbc70, bytes_to_int32(databytes, ptr + 40), 23)
|
284
|
-
updateRun(fH(b, c, d), 0x289b7ec6, bytes_to_int32(databytes, ptr + 52), 4)
|
285
|
-
updateRun(fH(b, c, d), 0xeaa127fa, bytes_to_int32(databytes, ptr), 11)
|
286
|
-
updateRun(fH(b, c, d), 0xd4ef3085, bytes_to_int32(databytes, ptr + 12), 16)
|
287
|
-
updateRun(fH(b, c, d), 0x4881d05, bytes_to_int32(databytes, ptr + 24), 23)
|
288
|
-
updateRun(fH(b, c, d), 0xd9d4d039, bytes_to_int32(databytes, ptr + 36), 4)
|
289
|
-
updateRun(fH(b, c, d), 0xe6db99e5, bytes_to_int32(databytes, ptr + 48), 11)
|
290
|
-
updateRun(fH(b, c, d), 0x1fa27cf8, bytes_to_int32(databytes, ptr + 60), 16)
|
291
|
-
updateRun(fH(b, c, d), 0xc4ac5665, bytes_to_int32(databytes, ptr + 8), 23)
|
292
|
-
updateRun(fI(b, c, d), 0xf4292244, bytes_to_int32(databytes, ptr), 6)
|
293
|
-
updateRun(fI(b, c, d), 0x432aff97, bytes_to_int32(databytes, ptr + 28), 10)
|
294
|
-
updateRun(fI(b, c, d), 0xab9423a7, bytes_to_int32(databytes, ptr + 56), 15)
|
295
|
-
updateRun(fI(b, c, d), 0xfc93a039, bytes_to_int32(databytes, ptr + 20), 21)
|
296
|
-
updateRun(fI(b, c, d), 0x655b59c3, bytes_to_int32(databytes, ptr + 48), 6)
|
297
|
-
updateRun(fI(b, c, d), 0x8f0ccc92, bytes_to_int32(databytes, ptr + 12), 10)
|
298
|
-
updateRun(fI(b, c, d), 0xffeff47d, bytes_to_int32(databytes, ptr + 40), 15)
|
299
|
-
updateRun(fI(b, c, d), 0x85845dd1, bytes_to_int32(databytes, ptr + 4), 21)
|
300
|
-
updateRun(fI(b, c, d), 0x6fa87e4f, bytes_to_int32(databytes, ptr + 32), 6)
|
301
|
-
updateRun(fI(b, c, d), 0xfe2ce6e0, bytes_to_int32(databytes, ptr + 60), 10)
|
302
|
-
updateRun(fI(b, c, d), 0xa3014314, bytes_to_int32(databytes, ptr + 24), 15)
|
303
|
-
updateRun(fI(b, c, d), 0x4e0811a1, bytes_to_int32(databytes, ptr + 52), 21)
|
304
|
-
updateRun(fI(b, c, d), 0xf7537e82, bytes_to_int32(databytes, ptr + 16), 6)
|
305
|
-
updateRun(fI(b, c, d), 0xbd3af235, bytes_to_int32(databytes, ptr + 44), 10)
|
306
|
-
updateRun(fI(b, c, d), 0x2ad7d2bb, bytes_to_int32(databytes, ptr + 8), 15)
|
307
|
-
updateRun(fI(b, c, d), 0xeb86d391, bytes_to_int32(databytes, ptr + 36), 21)
|
308
|
-
|
309
|
-
// update buffers
|
310
|
-
h0 = _add(h0, a)
|
311
|
-
h1 = _add(h1, b)
|
312
|
-
h2 = _add(h2, c)
|
313
|
-
h3 = _add(h3, d)
|
314
|
-
}
|
315
|
-
// Done! Convert buffers to 128 bit (LE)
|
316
|
-
return int128le_to_hex(h3, h2, h1, h0)
|
317
|
-
}
|
318
|
-
|
319
|
-
};
|
@@ -1,38 +0,0 @@
|
|
1
|
-
// Backbone.js 0.9.2
|
2
|
-
|
3
|
-
// (c) 2010-2012 Jeremy Ashkenas, DocumentCloud Inc.
|
4
|
-
// Backbone may be freely distributed under the MIT license.
|
5
|
-
// For all details and documentation:
|
6
|
-
// http://backbonejs.org
|
7
|
-
(function(){var l=this,y=l.Backbone,z=Array.prototype.slice,A=Array.prototype.splice,g;g="undefined"!==typeof exports?exports:l.Backbone={};g.VERSION="0.9.2";var f=l._;!f&&"undefined"!==typeof require&&(f=require("underscore"));var i=l.jQuery||l.Zepto||l.ender;g.setDomLibrary=function(a){i=a};g.noConflict=function(){l.Backbone=y;return this};g.emulateHTTP=!1;g.emulateJSON=!1;var p=/\s+/,k=g.Events={on:function(a,b,c){var d,e,f,g,j;if(!b)return this;a=a.split(p);for(d=this._callbacks||(this._callbacks=
|
8
|
-
{});e=a.shift();)f=(j=d[e])?j.tail:{},f.next=g={},f.context=c,f.callback=b,d[e]={tail:g,next:j?j.next:f};return this},off:function(a,b,c){var d,e,h,g,j,q;if(e=this._callbacks){if(!a&&!b&&!c)return delete this._callbacks,this;for(a=a?a.split(p):f.keys(e);d=a.shift();)if(h=e[d],delete e[d],h&&(b||c))for(g=h.tail;(h=h.next)!==g;)if(j=h.callback,q=h.context,b&&j!==b||c&&q!==c)this.on(d,j,q);return this}},trigger:function(a){var b,c,d,e,f,g;if(!(d=this._callbacks))return this;f=d.all;a=a.split(p);for(g=
|
9
|
-
z.call(arguments,1);b=a.shift();){if(c=d[b])for(e=c.tail;(c=c.next)!==e;)c.callback.apply(c.context||this,g);if(c=f){e=c.tail;for(b=[b].concat(g);(c=c.next)!==e;)c.callback.apply(c.context||this,b)}}return this}};k.bind=k.on;k.unbind=k.off;var o=g.Model=function(a,b){var c;a||(a={});b&&b.parse&&(a=this.parse(a));if(c=n(this,"defaults"))a=f.extend({},c,a);b&&b.collection&&(this.collection=b.collection);this.attributes={};this._escapedAttributes={};this.cid=f.uniqueId("c");this.changed={};this._silent=
|
10
|
-
{};this._pending={};this.set(a,{silent:!0});this.changed={};this._silent={};this._pending={};this._previousAttributes=f.clone(this.attributes);this.initialize.apply(this,arguments)};f.extend(o.prototype,k,{changed:null,_silent:null,_pending:null,idAttribute:"id",initialize:function(){},toJSON:function(){return f.clone(this.attributes)},get:function(a){return this.attributes[a]},escape:function(a){var b;if(b=this._escapedAttributes[a])return b;b=this.get(a);return this._escapedAttributes[a]=f.escape(null==
|
11
|
-
b?"":""+b)},has:function(a){return null!=this.get(a)},set:function(a,b,c){var d,e;f.isObject(a)||null==a?(d=a,c=b):(d={},d[a]=b);c||(c={});if(!d)return this;d instanceof o&&(d=d.attributes);if(c.unset)for(e in d)d[e]=void 0;if(!this._validate(d,c))return!1;this.idAttribute in d&&(this.id=d[this.idAttribute]);var b=c.changes={},h=this.attributes,g=this._escapedAttributes,j=this._previousAttributes||{};for(e in d){a=d[e];if(!f.isEqual(h[e],a)||c.unset&&f.has(h,e))delete g[e],(c.silent?this._silent:
|
12
|
-
b)[e]=!0;c.unset?delete h[e]:h[e]=a;!f.isEqual(j[e],a)||f.has(h,e)!=f.has(j,e)?(this.changed[e]=a,c.silent||(this._pending[e]=!0)):(delete this.changed[e],delete this._pending[e])}c.silent||this.change(c);return this},unset:function(a,b){(b||(b={})).unset=!0;return this.set(a,null,b)},clear:function(a){(a||(a={})).unset=!0;return this.set(f.clone(this.attributes),a)},fetch:function(a){var a=a?f.clone(a):{},b=this,c=a.success;a.success=function(d,e,f){if(!b.set(b.parse(d,f),a))return!1;c&&c(b,d)};
|
13
|
-
a.error=g.wrapError(a.error,b,a);return(this.sync||g.sync).call(this,"read",this,a)},save:function(a,b,c){var d,e;f.isObject(a)||null==a?(d=a,c=b):(d={},d[a]=b);c=c?f.clone(c):{};if(c.wait){if(!this._validate(d,c))return!1;e=f.clone(this.attributes)}a=f.extend({},c,{silent:!0});if(d&&!this.set(d,c.wait?a:c))return!1;var h=this,i=c.success;c.success=function(a,b,e){b=h.parse(a,e);if(c.wait){delete c.wait;b=f.extend(d||{},b)}if(!h.set(b,c))return false;i?i(h,a):h.trigger("sync",h,a,c)};c.error=g.wrapError(c.error,
|
14
|
-
h,c);b=this.isNew()?"create":"update";b=(this.sync||g.sync).call(this,b,this,c);c.wait&&this.set(e,a);return b},destroy:function(a){var a=a?f.clone(a):{},b=this,c=a.success,d=function(){b.trigger("destroy",b,b.collection,a)};if(this.isNew())return d(),!1;a.success=function(e){a.wait&&d();c?c(b,e):b.trigger("sync",b,e,a)};a.error=g.wrapError(a.error,b,a);var e=(this.sync||g.sync).call(this,"delete",this,a);a.wait||d();return e},url:function(){var a=n(this,"urlRoot")||n(this.collection,"url")||t();
|
15
|
-
return this.isNew()?a:a+("/"==a.charAt(a.length-1)?"":"/")+encodeURIComponent(this.id)},parse:function(a){return a},clone:function(){return new this.constructor(this.attributes)},isNew:function(){return null==this.id},change:function(a){a||(a={});var b=this._changing;this._changing=!0;for(var c in this._silent)this._pending[c]=!0;var d=f.extend({},a.changes,this._silent);this._silent={};for(c in d)this.trigger("change:"+c,this,this.get(c),a);if(b)return this;for(;!f.isEmpty(this._pending);){this._pending=
|
16
|
-
{};this.trigger("change",this,a);for(c in this.changed)!this._pending[c]&&!this._silent[c]&&delete this.changed[c];this._previousAttributes=f.clone(this.attributes)}this._changing=!1;return this},hasChanged:function(a){return!arguments.length?!f.isEmpty(this.changed):f.has(this.changed,a)},changedAttributes:function(a){if(!a)return this.hasChanged()?f.clone(this.changed):!1;var b,c=!1,d=this._previousAttributes,e;for(e in a)if(!f.isEqual(d[e],b=a[e]))(c||(c={}))[e]=b;return c},previous:function(a){return!arguments.length||
|
17
|
-
!this._previousAttributes?null:this._previousAttributes[a]},previousAttributes:function(){return f.clone(this._previousAttributes)},isValid:function(){return!this.validate(this.attributes)},_validate:function(a,b){if(b.silent||!this.validate)return!0;var a=f.extend({},this.attributes,a),c=this.validate(a,b);if(!c)return!0;b&&b.error?b.error(this,c,b):this.trigger("error",this,c,b);return!1}});var r=g.Collection=function(a,b){b||(b={});b.model&&(this.model=b.model);b.comparator&&(this.comparator=b.comparator);
|
18
|
-
this._reset();this.initialize.apply(this,arguments);a&&this.reset(a,{silent:!0,parse:b.parse})};f.extend(r.prototype,k,{model:o,initialize:function(){},toJSON:function(a){return this.map(function(b){return b.toJSON(a)})},add:function(a,b){var c,d,e,g,i,j={},k={},l=[];b||(b={});a=f.isArray(a)?a.slice():[a];c=0;for(d=a.length;c<d;c++){if(!(e=a[c]=this._prepareModel(a[c],b)))throw Error("Can't add an invalid model to a collection");g=e.cid;i=e.id;j[g]||this._byCid[g]||null!=i&&(k[i]||this._byId[i])?
|
19
|
-
l.push(c):j[g]=k[i]=e}for(c=l.length;c--;)a.splice(l[c],1);c=0;for(d=a.length;c<d;c++)(e=a[c]).on("all",this._onModelEvent,this),this._byCid[e.cid]=e,null!=e.id&&(this._byId[e.id]=e);this.length+=d;A.apply(this.models,[null!=b.at?b.at:this.models.length,0].concat(a));this.comparator&&this.sort({silent:!0});if(b.silent)return this;c=0;for(d=this.models.length;c<d;c++)if(j[(e=this.models[c]).cid])b.index=c,e.trigger("add",e,this,b);return this},remove:function(a,b){var c,d,e,g;b||(b={});a=f.isArray(a)?
|
20
|
-
a.slice():[a];c=0;for(d=a.length;c<d;c++)if(g=this.getByCid(a[c])||this.get(a[c]))delete this._byId[g.id],delete this._byCid[g.cid],e=this.indexOf(g),this.models.splice(e,1),this.length--,b.silent||(b.index=e,g.trigger("remove",g,this,b)),this._removeReference(g);return this},push:function(a,b){a=this._prepareModel(a,b);this.add(a,b);return a},pop:function(a){var b=this.at(this.length-1);this.remove(b,a);return b},unshift:function(a,b){a=this._prepareModel(a,b);this.add(a,f.extend({at:0},b));return a},
|
21
|
-
shift:function(a){var b=this.at(0);this.remove(b,a);return b},get:function(a){return null==a?void 0:this._byId[null!=a.id?a.id:a]},getByCid:function(a){return a&&this._byCid[a.cid||a]},at:function(a){return this.models[a]},where:function(a){return f.isEmpty(a)?[]:this.filter(function(b){for(var c in a)if(a[c]!==b.get(c))return!1;return!0})},sort:function(a){a||(a={});if(!this.comparator)throw Error("Cannot sort a set without a comparator");var b=f.bind(this.comparator,this);1==this.comparator.length?
|
22
|
-
this.models=this.sortBy(b):this.models.sort(b);a.silent||this.trigger("reset",this,a);return this},pluck:function(a){return f.map(this.models,function(b){return b.get(a)})},reset:function(a,b){a||(a=[]);b||(b={});for(var c=0,d=this.models.length;c<d;c++)this._removeReference(this.models[c]);this._reset();this.add(a,f.extend({silent:!0},b));b.silent||this.trigger("reset",this,b);return this},fetch:function(a){a=a?f.clone(a):{};void 0===a.parse&&(a.parse=!0);var b=this,c=a.success;a.success=function(d,
|
23
|
-
e,f){b[a.add?"add":"reset"](b.parse(d,f),a);c&&c(b,d)};a.error=g.wrapError(a.error,b,a);return(this.sync||g.sync).call(this,"read",this,a)},create:function(a,b){var c=this,b=b?f.clone(b):{},a=this._prepareModel(a,b);if(!a)return!1;b.wait||c.add(a,b);var d=b.success;b.success=function(e,f){b.wait&&c.add(e,b);d?d(e,f):e.trigger("sync",a,f,b)};a.save(null,b);return a},parse:function(a){return a},chain:function(){return f(this.models).chain()},_reset:function(){this.length=0;this.models=[];this._byId=
|
24
|
-
{};this._byCid={}},_prepareModel:function(a,b){b||(b={});a instanceof o?a.collection||(a.collection=this):(b.collection=this,a=new this.model(a,b),a._validate(a.attributes,b)||(a=!1));return a},_removeReference:function(a){this==a.collection&&delete a.collection;a.off("all",this._onModelEvent,this)},_onModelEvent:function(a,b,c,d){("add"==a||"remove"==a)&&c!=this||("destroy"==a&&this.remove(b,d),b&&a==="change:"+b.idAttribute&&(delete this._byId[b.previous(b.idAttribute)],this._byId[b.id]=b),this.trigger.apply(this,
|
25
|
-
arguments))}});f.each("forEach,each,map,reduce,reduceRight,find,detect,filter,select,reject,every,all,some,any,include,contains,invoke,max,min,sortBy,sortedIndex,toArray,size,first,initial,rest,last,without,indexOf,shuffle,lastIndexOf,isEmpty,groupBy".split(","),function(a){r.prototype[a]=function(){return f[a].apply(f,[this.models].concat(f.toArray(arguments)))}});var u=g.Router=function(a){a||(a={});a.routes&&(this.routes=a.routes);this._bindRoutes();this.initialize.apply(this,arguments)},B=/:\w+/g,
|
26
|
-
C=/\*\w+/g,D=/[-[\]{}()+?.,\\^$|#\s]/g;f.extend(u.prototype,k,{initialize:function(){},route:function(a,b,c){g.history||(g.history=new m);f.isRegExp(a)||(a=this._routeToRegExp(a));c||(c=this[b]);g.history.route(a,f.bind(function(d){d=this._extractParameters(a,d);c&&c.apply(this,d);this.trigger.apply(this,["route:"+b].concat(d));g.history.trigger("route",this,b,d)},this));return this},navigate:function(a,b){g.history.navigate(a,b)},_bindRoutes:function(){if(this.routes){var a=[],b;for(b in this.routes)a.unshift([b,
|
27
|
-
this.routes[b]]);b=0;for(var c=a.length;b<c;b++)this.route(a[b][0],a[b][1],this[a[b][1]])}},_routeToRegExp:function(a){a=a.replace(D,"\\$&").replace(B,"([^/]+)").replace(C,"(.*?)");return RegExp("^"+a+"$")},_extractParameters:function(a,b){return a.exec(b).slice(1)}});var m=g.History=function(){this.handlers=[];f.bindAll(this,"checkUrl")},s=/^[#\/]/,E=/msie [\w.]+/;m.started=!1;f.extend(m.prototype,k,{interval:50,getHash:function(a){return(a=(a?a.location:window.location).href.match(/#(.*)$/))?a[1]:
|
28
|
-
""},getFragment:function(a,b){if(null==a)if(this._hasPushState||b){var a=window.location.pathname,c=window.location.search;c&&(a+=c)}else a=this.getHash();a.indexOf(this.options.root)||(a=a.substr(this.options.root.length));return a.replace(s,"")},start:function(a){if(m.started)throw Error("Backbone.history has already been started");m.started=!0;this.options=f.extend({},{root:"/"},this.options,a);this._wantsHashChange=!1!==this.options.hashChange;this._wantsPushState=!!this.options.pushState;this._hasPushState=
|
29
|
-
!(!this.options.pushState||!window.history||!window.history.pushState);var a=this.getFragment(),b=document.documentMode;if(b=E.exec(navigator.userAgent.toLowerCase())&&(!b||7>=b))this.iframe=i('<iframe src="javascript:0" tabindex="-1" />').hide().appendTo("body")[0].contentWindow,this.navigate(a);this._hasPushState?i(window).bind("popstate",this.checkUrl):this._wantsHashChange&&"onhashchange"in window&&!b?i(window).bind("hashchange",this.checkUrl):this._wantsHashChange&&(this._checkUrlInterval=setInterval(this.checkUrl,
|
30
|
-
this.interval));this.fragment=a;a=window.location;b=a.pathname==this.options.root;if(this._wantsHashChange&&this._wantsPushState&&!this._hasPushState&&!b)return this.fragment=this.getFragment(null,!0),window.location.replace(this.options.root+"#"+this.fragment),!0;this._wantsPushState&&this._hasPushState&&b&&a.hash&&(this.fragment=this.getHash().replace(s,""),window.history.replaceState({},document.title,a.protocol+"//"+a.host+this.options.root+this.fragment));if(!this.options.silent)return this.loadUrl()},
|
31
|
-
stop:function(){i(window).unbind("popstate",this.checkUrl).unbind("hashchange",this.checkUrl);clearInterval(this._checkUrlInterval);m.started=!1},route:function(a,b){this.handlers.unshift({route:a,callback:b})},checkUrl:function(){var a=this.getFragment();a==this.fragment&&this.iframe&&(a=this.getFragment(this.getHash(this.iframe)));if(a==this.fragment)return!1;this.iframe&&this.navigate(a);this.loadUrl()||this.loadUrl(this.getHash())},loadUrl:function(a){var b=this.fragment=this.getFragment(a);return f.any(this.handlers,
|
32
|
-
function(a){if(a.route.test(b))return a.callback(b),!0})},navigate:function(a,b){if(!m.started)return!1;if(!b||!0===b)b={trigger:b};var c=(a||"").replace(s,"");this.fragment!=c&&(this._hasPushState?(0!=c.indexOf(this.options.root)&&(c=this.options.root+c),this.fragment=c,window.history[b.replace?"replaceState":"pushState"]({},document.title,c)):this._wantsHashChange?(this.fragment=c,this._updateHash(window.location,c,b.replace),this.iframe&&c!=this.getFragment(this.getHash(this.iframe))&&(b.replace||
|
33
|
-
this.iframe.document.open().close(),this._updateHash(this.iframe.location,c,b.replace))):window.location.assign(this.options.root+a),b.trigger&&this.loadUrl(a))},_updateHash:function(a,b,c){c?a.replace(a.toString().replace(/(javascript:|#).*$/,"")+"#"+b):a.hash=b}});var v=g.View=function(a){this.cid=f.uniqueId("view");this._configure(a||{});this._ensureElement();this.initialize.apply(this,arguments);this.delegateEvents()},F=/^(\S+)\s*(.*)$/,w="model,collection,el,id,attributes,className,tagName".split(",");
|
34
|
-
f.extend(v.prototype,k,{tagName:"div",$:function(a){return this.$el.find(a)},initialize:function(){},render:function(){return this},remove:function(){this.$el.remove();return this},make:function(a,b,c){a=document.createElement(a);b&&i(a).attr(b);c&&i(a).html(c);return a},setElement:function(a,b){this.$el&&this.undelegateEvents();this.$el=a instanceof i?a:i(a);this.el=this.$el[0];!1!==b&&this.delegateEvents();return this},delegateEvents:function(a){if(a||(a=n(this,"events"))){this.undelegateEvents();
|
35
|
-
for(var b in a){var c=a[b];f.isFunction(c)||(c=this[a[b]]);if(!c)throw Error('Method "'+a[b]+'" does not exist');var d=b.match(F),e=d[1],d=d[2],c=f.bind(c,this),e=e+(".delegateEvents"+this.cid);""===d?this.$el.bind(e,c):this.$el.delegate(d,e,c)}}},undelegateEvents:function(){this.$el.unbind(".delegateEvents"+this.cid)},_configure:function(a){this.options&&(a=f.extend({},this.options,a));for(var b=0,c=w.length;b<c;b++){var d=w[b];a[d]&&(this[d]=a[d])}this.options=a},_ensureElement:function(){if(this.el)this.setElement(this.el,
|
36
|
-
!1);else{var a=n(this,"attributes")||{};this.id&&(a.id=this.id);this.className&&(a["class"]=this.className);this.setElement(this.make(this.tagName,a),!1)}}});o.extend=r.extend=u.extend=v.extend=function(a,b){var c=G(this,a,b);c.extend=this.extend;return c};var H={create:"POST",update:"PUT","delete":"DELETE",read:"GET"};g.sync=function(a,b,c){var d=H[a];c||(c={});var e={type:d,dataType:"json"};c.url||(e.url=n(b,"url")||t());if(!c.data&&b&&("create"==a||"update"==a))e.contentType="application/json",
|
37
|
-
e.data=JSON.stringify(b.toJSON());g.emulateJSON&&(e.contentType="application/x-www-form-urlencoded",e.data=e.data?{model:e.data}:{});if(g.emulateHTTP&&("PUT"===d||"DELETE"===d))g.emulateJSON&&(e.data._method=d),e.type="POST",e.beforeSend=function(a){a.setRequestHeader("X-HTTP-Method-Override",d)};"GET"!==e.type&&!g.emulateJSON&&(e.processData=!1);return i.ajax(f.extend(e,c))};g.wrapError=function(a,b,c){return function(d,e){e=d===b?e:d;a?a(b,e,c):b.trigger("error",b,e,c)}};var x=function(){},G=function(a,
|
38
|
-
b,c){var d;d=b&&b.hasOwnProperty("constructor")?b.constructor:function(){a.apply(this,arguments)};f.extend(d,a);x.prototype=a.prototype;d.prototype=new x;b&&f.extend(d.prototype,b);c&&f.extend(d,c);d.prototype.constructor=d;d.__super__=a.prototype;return d},n=function(a,b){return!a||!a[b]?null:f.isFunction(a[b])?a[b]():a[b]},t=function(){throw Error('A "url" property or function must be specified');}}).call(this);
|