0) {
188 | if(p < this.DB && (d = this[i]>>p) > 0) { m = true; r = int2char(d); }
189 | while(i >= 0) {
190 | if(p < k) {
191 | d = (this[i]&((1<>(p+=this.DB-k);
193 | }
194 | else {
195 | d = (this[i]>>(p-=k))&km;
196 | if(p <= 0) { p += this.DB; --i; }
197 | }
198 | if(d > 0) m = true;
199 | if(m) r += int2char(d);
200 | }
201 | }
202 | return m?r:"0";
203 | }
204 |
205 | // (public) -this
206 | function bnNegate() { var r = nbi(); BigInteger.ZERO.subTo(this,r); return r; }
207 |
208 | // (public) |this|
209 | function bnAbs() { return (this.s<0)?this.negate():this; }
210 |
211 | // (public) return + if this > a, - if this < a, 0 if equal
212 | function bnCompareTo(a) {
213 | var r = this.s-a.s;
214 | if(r != 0) return r;
215 | var i = this.t;
216 | r = i-a.t;
217 | if(r != 0) return (this.s<0)?-r:r;
218 | while(--i >= 0) if((r=this[i]-a[i]) != 0) return r;
219 | return 0;
220 | }
221 |
222 | // returns bit length of the integer x
223 | function nbits(x) {
224 | var r = 1, t;
225 | if((t=x>>>16) != 0) { x = t; r += 16; }
226 | if((t=x>>8) != 0) { x = t; r += 8; }
227 | if((t=x>>4) != 0) { x = t; r += 4; }
228 | if((t=x>>2) != 0) { x = t; r += 2; }
229 | if((t=x>>1) != 0) { x = t; r += 1; }
230 | return r;
231 | }
232 |
233 | // (public) return the number of bits in "this"
234 | function bnBitLength() {
235 | if(this.t <= 0) return 0;
236 | return this.DB*(this.t-1)+nbits(this[this.t-1]^(this.s&this.DM));
237 | }
238 |
239 | // (protected) r = this << n*DB
240 | function bnpDLShiftTo(n,r) {
241 | var i;
242 | for(i = this.t-1; i >= 0; --i) r[i+n] = this[i];
243 | for(i = n-1; i >= 0; --i) r[i] = 0;
244 | r.t = this.t+n;
245 | r.s = this.s;
246 | }
247 |
248 | // (protected) r = this >> n*DB
249 | function bnpDRShiftTo(n,r) {
250 | for(var i = n; i < this.t; ++i) r[i-n] = this[i];
251 | r.t = Math.max(this.t-n,0);
252 | r.s = this.s;
253 | }
254 |
255 | // (protected) r = this << n
256 | function bnpLShiftTo(n,r) {
257 | var bs = n%this.DB;
258 | var cbs = this.DB-bs;
259 | var bm = (1<= 0; --i) {
262 | r[i+ds+1] = (this[i]>>cbs)|c;
263 | c = (this[i]&bm)<= 0; --i) r[i] = 0;
266 | r[ds] = c;
267 | r.t = this.t+ds+1;
268 | r.s = this.s;
269 | r.clamp();
270 | }
271 |
272 | // (protected) r = this >> n
273 | function bnpRShiftTo(n,r) {
274 | r.s = this.s;
275 | var ds = Math.floor(n/this.DB);
276 | if(ds >= this.t) { r.t = 0; return; }
277 | var bs = n%this.DB;
278 | var cbs = this.DB-bs;
279 | var bm = (1<>bs;
281 | for(var i = ds+1; i < this.t; ++i) {
282 | r[i-ds-1] |= (this[i]&bm)<>bs;
284 | }
285 | if(bs > 0) r[this.t-ds-1] |= (this.s&bm)<>= this.DB;
297 | }
298 | if(a.t < this.t) {
299 | c -= a.s;
300 | while(i < this.t) {
301 | c += this[i];
302 | r[i++] = c&this.DM;
303 | c >>= this.DB;
304 | }
305 | c += this.s;
306 | }
307 | else {
308 | c += this.s;
309 | while(i < a.t) {
310 | c -= a[i];
311 | r[i++] = c&this.DM;
312 | c >>= this.DB;
313 | }
314 | c -= a.s;
315 | }
316 | r.s = (c<0)?-1:0;
317 | if(c < -1) r[i++] = this.DV+c;
318 | else if(c > 0) r[i++] = c;
319 | r.t = i;
320 | r.clamp();
321 | }
322 |
323 | // (protected) r = this * a, r != this,a (HAC 14.12)
324 | // "this" should be the larger one if appropriate.
325 | function bnpMultiplyTo(a,r) {
326 | var x = this.abs(), y = a.abs();
327 | var i = x.t;
328 | r.t = i+y.t;
329 | while(--i >= 0) r[i] = 0;
330 | for(i = 0; i < y.t; ++i) r[i+x.t] = x.am(0,y[i],r,i,0,x.t);
331 | r.s = 0;
332 | r.clamp();
333 | if(this.s != a.s) BigInteger.ZERO.subTo(r,r);
334 | }
335 |
336 | // (protected) r = this^2, r != this (HAC 14.16)
337 | function bnpSquareTo(r) {
338 | var x = this.abs();
339 | var i = r.t = 2*x.t;
340 | while(--i >= 0) r[i] = 0;
341 | for(i = 0; i < x.t-1; ++i) {
342 | var c = x.am(i,x[i],r,2*i,0,1);
343 | if((r[i+x.t]+=x.am(i+1,2*x[i],r,2*i+1,c,x.t-i-1)) >= x.DV) {
344 | r[i+x.t] -= x.DV;
345 | r[i+x.t+1] = 1;
346 | }
347 | }
348 | if(r.t > 0) r[r.t-1] += x.am(i,x[i],r,2*i,0,1);
349 | r.s = 0;
350 | r.clamp();
351 | }
352 |
353 | // (protected) divide this by m, quotient and remainder to q, r (HAC 14.20)
354 | // r != q, this != m. q or r may be null.
355 | function bnpDivRemTo(m,q,r) {
356 | var pm = m.abs();
357 | if(pm.t <= 0) return;
358 | var pt = this.abs();
359 | if(pt.t < pm.t) {
360 | if(q != null) q.fromInt(0);
361 | if(r != null) this.copyTo(r);
362 | return;
363 | }
364 | if(r == null) r = nbi();
365 | var y = nbi(), ts = this.s, ms = m.s;
366 | var nsh = this.DB-nbits(pm[pm.t-1]); // normalize modulus
367 | if(nsh > 0) { pm.lShiftTo(nsh,y); pt.lShiftTo(nsh,r); }
368 | else { pm.copyTo(y); pt.copyTo(r); }
369 | var ys = y.t;
370 | var y0 = y[ys-1];
371 | if(y0 == 0) return;
372 | var yt = y0*(1<1)?y[ys-2]>>this.F2:0);
373 | var d1 = this.FV/yt, d2 = (1<= 0) {
377 | r[r.t++] = 1;
378 | r.subTo(t,r);
379 | }
380 | BigInteger.ONE.dlShiftTo(ys,t);
381 | t.subTo(y,y); // "negative" y so we can replace sub with am later
382 | while(y.t < ys) y[y.t++] = 0;
383 | while(--j >= 0) {
384 | // Estimate quotient digit
385 | var qd = (r[--i]==y0)?this.DM:Math.floor(r[i]*d1+(r[i-1]+e)*d2);
386 | if((r[i]+=y.am(0,qd,r,j,0,ys)) < qd) { // Try it out
387 | y.dlShiftTo(j,t);
388 | r.subTo(t,r);
389 | while(r[i] < --qd) r.subTo(t,r);
390 | }
391 | }
392 | if(q != null) {
393 | r.drShiftTo(ys,q);
394 | if(ts != ms) BigInteger.ZERO.subTo(q,q);
395 | }
396 | r.t = ys;
397 | r.clamp();
398 | if(nsh > 0) r.rShiftTo(nsh,r); // Denormalize remainder
399 | if(ts < 0) BigInteger.ZERO.subTo(r,r);
400 | }
401 |
402 | // (public) this mod a
403 | function bnMod(a) {
404 | var r = nbi();
405 | this.abs().divRemTo(a,null,r);
406 | if(this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r,r);
407 | return r;
408 | }
409 |
410 | // Modular reduction using "classic" algorithm
411 | function Classic(m) { this.m = m; }
412 | function cConvert(x) {
413 | if(x.s < 0 || x.compareTo(this.m) >= 0) return x.mod(this.m);
414 | else return x;
415 | }
416 | function cRevert(x) { return x; }
417 | function cReduce(x) { x.divRemTo(this.m,null,x); }
418 | function cMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
419 | function cSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
420 |
421 | Classic.prototype.convert = cConvert;
422 | Classic.prototype.revert = cRevert;
423 | Classic.prototype.reduce = cReduce;
424 | Classic.prototype.mulTo = cMulTo;
425 | Classic.prototype.sqrTo = cSqrTo;
426 |
427 | // (protected) return "-1/this % 2^DB"; useful for Mont. reduction
428 | // justification:
429 | // xy == 1 (mod m)
430 | // xy = 1+km
431 | // xy(2-xy) = (1+km)(1-km)
432 | // x[y(2-xy)] = 1-k^2m^2
433 | // x[y(2-xy)] == 1 (mod m^2)
434 | // if y is 1/x mod m, then y(2-xy) is 1/x mod m^2
435 | // should reduce x and y(2-xy) by m^2 at each step to keep size bounded.
436 | // JS multiply "overflows" differently from C/C++, so care is needed here.
437 | function bnpInvDigit() {
438 | if(this.t < 1) return 0;
439 | var x = this[0];
440 | if((x&1) == 0) return 0;
441 | var y = x&3; // y == 1/x mod 2^2
442 | y = (y*(2-(x&0xf)*y))&0xf; // y == 1/x mod 2^4
443 | y = (y*(2-(x&0xff)*y))&0xff; // y == 1/x mod 2^8
444 | y = (y*(2-(((x&0xffff)*y)&0xffff)))&0xffff; // y == 1/x mod 2^16
445 | // last step - calculate inverse mod DV directly;
446 | // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints
447 | y = (y*(2-x*y%this.DV))%this.DV; // y == 1/x mod 2^dbits
448 | // we really want the negative inverse, and -DV < y < DV
449 | return (y>0)?this.DV-y:-y;
450 | }
451 |
452 | // Montgomery reduction
453 | function Montgomery(m) {
454 | this.m = m;
455 | this.mp = m.invDigit();
456 | this.mpl = this.mp&0x7fff;
457 | this.mph = this.mp>>15;
458 | this.um = (1<<(m.DB-15))-1;
459 | this.mt2 = 2*m.t;
460 | }
461 |
462 | // xR mod m
463 | function montConvert(x) {
464 | var r = nbi();
465 | x.abs().dlShiftTo(this.m.t,r);
466 | r.divRemTo(this.m,null,r);
467 | if(x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r,r);
468 | return r;
469 | }
470 |
471 | // x/R mod m
472 | function montRevert(x) {
473 | var r = nbi();
474 | x.copyTo(r);
475 | this.reduce(r);
476 | return r;
477 | }
478 |
479 | // x = x/R mod m (HAC 14.32)
480 | function montReduce(x) {
481 | while(x.t <= this.mt2) // pad x so am has enough room later
482 | x[x.t++] = 0;
483 | for(var i = 0; i < this.m.t; ++i) {
484 | // faster way of calculating u0 = x[i]*mp mod DV
485 | var j = x[i]&0x7fff;
486 | var u0 = (j*this.mpl+(((j*this.mph+(x[i]>>15)*this.mpl)&this.um)<<15))&x.DM;
487 | // use am to combine the multiply-shift-add into one call
488 | j = i+this.m.t;
489 | x[j] += this.m.am(0,u0,x,i,0,this.m.t);
490 | // propagate carry
491 | while(x[j] >= x.DV) { x[j] -= x.DV; x[++j]++; }
492 | }
493 | x.clamp();
494 | x.drShiftTo(this.m.t,x);
495 | if(x.compareTo(this.m) >= 0) x.subTo(this.m,x);
496 | }
497 |
498 | // r = "x^2/R mod m"; x != r
499 | function montSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
500 |
501 | // r = "xy/R mod m"; x,y != r
502 | function montMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
503 |
504 | Montgomery.prototype.convert = montConvert;
505 | Montgomery.prototype.revert = montRevert;
506 | Montgomery.prototype.reduce = montReduce;
507 | Montgomery.prototype.mulTo = montMulTo;
508 | Montgomery.prototype.sqrTo = montSqrTo;
509 |
510 | // (protected) true iff this is even
511 | function bnpIsEven() { return ((this.t>0)?(this[0]&1):this.s) == 0; }
512 |
513 | // (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79)
514 | function bnpExp(e,z) {
515 | if(e > 0xffffffff || e < 1) return BigInteger.ONE;
516 | var r = nbi(), r2 = nbi(), g = z.convert(this), i = nbits(e)-1;
517 | g.copyTo(r);
518 | while(--i >= 0) {
519 | z.sqrTo(r,r2);
520 | if((e&(1< 0) z.mulTo(r2,g,r);
521 | else { var t = r; r = r2; r2 = t; }
522 | }
523 | return z.revert(r);
524 | }
525 |
526 | // (public) this^e % m, 0 <= e < 2^32
527 | function bnModPowInt(e,m) {
528 | var z;
529 | if(e < 256 || m.isEven()) z = new Classic(m); else z = new Montgomery(m);
530 | return this.exp(e,z);
531 | }
532 |
533 | // protected
534 | BigInteger.prototype.copyTo = bnpCopyTo;
535 | BigInteger.prototype.fromInt = bnpFromInt;
536 | BigInteger.prototype.fromString = bnpFromString;
537 | BigInteger.prototype.clamp = bnpClamp;
538 | BigInteger.prototype.dlShiftTo = bnpDLShiftTo;
539 | BigInteger.prototype.drShiftTo = bnpDRShiftTo;
540 | BigInteger.prototype.lShiftTo = bnpLShiftTo;
541 | BigInteger.prototype.rShiftTo = bnpRShiftTo;
542 | BigInteger.prototype.subTo = bnpSubTo;
543 | BigInteger.prototype.multiplyTo = bnpMultiplyTo;
544 | BigInteger.prototype.squareTo = bnpSquareTo;
545 | BigInteger.prototype.divRemTo = bnpDivRemTo;
546 | BigInteger.prototype.invDigit = bnpInvDigit;
547 | BigInteger.prototype.isEven = bnpIsEven;
548 | BigInteger.prototype.exp = bnpExp;
549 |
550 | // public
551 | BigInteger.prototype.toString = bnToString;
552 | BigInteger.prototype.negate = bnNegate;
553 | BigInteger.prototype.abs = bnAbs;
554 | BigInteger.prototype.compareTo = bnCompareTo;
555 | BigInteger.prototype.bitLength = bnBitLength;
556 | BigInteger.prototype.mod = bnMod;
557 | BigInteger.prototype.modPowInt = bnModPowInt;
558 |
559 | // "constants"
560 | BigInteger.ZERO = nbv(0);
561 | BigInteger.ONE = nbv(1);
562 |
--------------------------------------------------------------------------------
/js/ext/jsbn2.js:
--------------------------------------------------------------------------------
1 | /*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/
2 | */
3 | // Copyright (c) 2005-2009 Tom Wu
4 | // All Rights Reserved.
5 | // See "LICENSE" for details.
6 |
7 | // Extended JavaScript BN functions, required for RSA private ops.
8 |
9 | // Version 1.1: new BigInteger("0", 10) returns "proper" zero
10 | // Version 1.2: square() API, isProbablePrime fix
11 |
12 | // (public)
13 | function bnClone() { var r = nbi(); this.copyTo(r); return r; }
14 |
15 | // (public) return value as integer
16 | function bnIntValue() {
17 | if(this.s < 0) {
18 | if(this.t == 1) return this[0]-this.DV;
19 | else if(this.t == 0) return -1;
20 | }
21 | else if(this.t == 1) return this[0];
22 | else if(this.t == 0) return 0;
23 | // assumes 16 < DB < 32
24 | return ((this[1]&((1<<(32-this.DB))-1))<>24; }
29 |
30 | // (public) return value as short (assumes DB>=16)
31 | function bnShortValue() { return (this.t==0)?this.s:(this[0]<<16)>>16; }
32 |
33 | // (protected) return x s.t. r^x < DV
34 | function bnpChunkSize(r) { return Math.floor(Math.LN2*this.DB/Math.log(r)); }
35 |
36 | // (public) 0 if this == 0, 1 if this > 0
37 | function bnSigNum() {
38 | if(this.s < 0) return -1;
39 | else if(this.t <= 0 || (this.t == 1 && this[0] <= 0)) return 0;
40 | else return 1;
41 | }
42 |
43 | // (protected) convert to radix string
44 | function bnpToRadix(b) {
45 | if(b == null) b = 10;
46 | if(this.signum() == 0 || b < 2 || b > 36) return "0";
47 | var cs = this.chunkSize(b);
48 | var a = Math.pow(b,cs);
49 | var d = nbv(a), y = nbi(), z = nbi(), r = "";
50 | this.divRemTo(d,y,z);
51 | while(y.signum() > 0) {
52 | r = (a+z.intValue()).toString(b).substr(1) + r;
53 | y.divRemTo(d,y,z);
54 | }
55 | return z.intValue().toString(b) + r;
56 | }
57 |
58 | // (protected) convert from radix string
59 | function bnpFromRadix(s,b) {
60 | this.fromInt(0);
61 | if(b == null) b = 10;
62 | var cs = this.chunkSize(b);
63 | var d = Math.pow(b,cs), mi = false, j = 0, w = 0;
64 | for(var i = 0; i < s.length; ++i) {
65 | var x = intAt(s,i);
66 | if(x < 0) {
67 | if(s.charAt(i) == "-" && this.signum() == 0) mi = true;
68 | continue;
69 | }
70 | w = b*w+x;
71 | if(++j >= cs) {
72 | this.dMultiply(d);
73 | this.dAddOffset(w,0);
74 | j = 0;
75 | w = 0;
76 | }
77 | }
78 | if(j > 0) {
79 | this.dMultiply(Math.pow(b,j));
80 | this.dAddOffset(w,0);
81 | }
82 | if(mi) BigInteger.ZERO.subTo(this,this);
83 | }
84 |
85 | // (protected) alternate constructor
86 | function bnpFromNumber(a,b,c) {
87 | if("number" == typeof b) {
88 | // new BigInteger(int,int,RNG)
89 | if(a < 2) this.fromInt(1);
90 | else {
91 | this.fromNumber(a,c);
92 | if(!this.testBit(a-1)) // force MSB set
93 | this.bitwiseTo(BigInteger.ONE.shiftLeft(a-1),op_or,this);
94 | if(this.isEven()) this.dAddOffset(1,0); // force odd
95 | while(!this.isProbablePrime(b)) {
96 | this.dAddOffset(2,0);
97 | if(this.bitLength() > a) this.subTo(BigInteger.ONE.shiftLeft(a-1),this);
98 | }
99 | }
100 | }
101 | else {
102 | // new BigInteger(int,RNG)
103 | var x = new Array(), t = a&7;
104 | x.length = (a>>3)+1;
105 | b.nextBytes(x);
106 | if(t > 0) x[0] &= ((1< 0) {
117 | if(p < this.DB && (d = this[i]>>p) != (this.s&this.DM)>>p)
118 | r[k++] = d|(this.s<<(this.DB-p));
119 | while(i >= 0) {
120 | if(p < 8) {
121 | d = (this[i]&((1<>(p+=this.DB-8);
123 | }
124 | else {
125 | d = (this[i]>>(p-=8))&0xff;
126 | if(p <= 0) { p += this.DB; --i; }
127 | }
128 | if((d&0x80) != 0) d |= -256;
129 | if(k == 0 && (this.s&0x80) != (d&0x80)) ++k;
130 | if(k > 0 || d != this.s) r[k++] = d;
131 | }
132 | }
133 | return r;
134 | }
135 |
136 | function bnEquals(a) { return(this.compareTo(a)==0); }
137 | function bnMin(a) { return(this.compareTo(a)<0)?this:a; }
138 | function bnMax(a) { return(this.compareTo(a)>0)?this:a; }
139 |
140 | // (protected) r = this op a (bitwise)
141 | function bnpBitwiseTo(a,op,r) {
142 | var i, f, m = Math.min(a.t,this.t);
143 | for(i = 0; i < m; ++i) r[i] = op(this[i],a[i]);
144 | if(a.t < this.t) {
145 | f = a.s&this.DM;
146 | for(i = m; i < this.t; ++i) r[i] = op(this[i],f);
147 | r.t = this.t;
148 | }
149 | else {
150 | f = this.s&this.DM;
151 | for(i = m; i < a.t; ++i) r[i] = op(f,a[i]);
152 | r.t = a.t;
153 | }
154 | r.s = op(this.s,a.s);
155 | r.clamp();
156 | }
157 |
158 | // (public) this & a
159 | function op_and(x,y) { return x&y; }
160 | function bnAnd(a) { var r = nbi(); this.bitwiseTo(a,op_and,r); return r; }
161 |
162 | // (public) this | a
163 | function op_or(x,y) { return x|y; }
164 | function bnOr(a) { var r = nbi(); this.bitwiseTo(a,op_or,r); return r; }
165 |
166 | // (public) this ^ a
167 | function op_xor(x,y) { return x^y; }
168 | function bnXor(a) { var r = nbi(); this.bitwiseTo(a,op_xor,r); return r; }
169 |
170 | // (public) this & ~a
171 | function op_andnot(x,y) { return x&~y; }
172 | function bnAndNot(a) { var r = nbi(); this.bitwiseTo(a,op_andnot,r); return r; }
173 |
174 | // (public) ~this
175 | function bnNot() {
176 | var r = nbi();
177 | for(var i = 0; i < this.t; ++i) r[i] = this.DM&~this[i];
178 | r.t = this.t;
179 | r.s = ~this.s;
180 | return r;
181 | }
182 |
183 | // (public) this << n
184 | function bnShiftLeft(n) {
185 | var r = nbi();
186 | if(n < 0) this.rShiftTo(-n,r); else this.lShiftTo(n,r);
187 | return r;
188 | }
189 |
190 | // (public) this >> n
191 | function bnShiftRight(n) {
192 | var r = nbi();
193 | if(n < 0) this.lShiftTo(-n,r); else this.rShiftTo(n,r);
194 | return r;
195 | }
196 |
197 | // return index of lowest 1-bit in x, x < 2^31
198 | function lbit(x) {
199 | if(x == 0) return -1;
200 | var r = 0;
201 | if((x&0xffff) == 0) { x >>= 16; r += 16; }
202 | if((x&0xff) == 0) { x >>= 8; r += 8; }
203 | if((x&0xf) == 0) { x >>= 4; r += 4; }
204 | if((x&3) == 0) { x >>= 2; r += 2; }
205 | if((x&1) == 0) ++r;
206 | return r;
207 | }
208 |
209 | // (public) returns index of lowest 1-bit (or -1 if none)
210 | function bnGetLowestSetBit() {
211 | for(var i = 0; i < this.t; ++i)
212 | if(this[i] != 0) return i*this.DB+lbit(this[i]);
213 | if(this.s < 0) return this.t*this.DB;
214 | return -1;
215 | }
216 |
217 | // return number of 1 bits in x
218 | function cbit(x) {
219 | var r = 0;
220 | while(x != 0) { x &= x-1; ++r; }
221 | return r;
222 | }
223 |
224 | // (public) return number of set bits
225 | function bnBitCount() {
226 | var r = 0, x = this.s&this.DM;
227 | for(var i = 0; i < this.t; ++i) r += cbit(this[i]^x);
228 | return r;
229 | }
230 |
231 | // (public) true iff nth bit is set
232 | function bnTestBit(n) {
233 | var j = Math.floor(n/this.DB);
234 | if(j >= this.t) return(this.s!=0);
235 | return((this[j]&(1<<(n%this.DB)))!=0);
236 | }
237 |
238 | // (protected) this op (1<>= this.DB;
261 | }
262 | if(a.t < this.t) {
263 | c += a.s;
264 | while(i < this.t) {
265 | c += this[i];
266 | r[i++] = c&this.DM;
267 | c >>= this.DB;
268 | }
269 | c += this.s;
270 | }
271 | else {
272 | c += this.s;
273 | while(i < a.t) {
274 | c += a[i];
275 | r[i++] = c&this.DM;
276 | c >>= this.DB;
277 | }
278 | c += a.s;
279 | }
280 | r.s = (c<0)?-1:0;
281 | if(c > 0) r[i++] = c;
282 | else if(c < -1) r[i++] = this.DV+c;
283 | r.t = i;
284 | r.clamp();
285 | }
286 |
287 | // (public) this + a
288 | function bnAdd(a) { var r = nbi(); this.addTo(a,r); return r; }
289 |
290 | // (public) this - a
291 | function bnSubtract(a) { var r = nbi(); this.subTo(a,r); return r; }
292 |
293 | // (public) this * a
294 | function bnMultiply(a) { var r = nbi(); this.multiplyTo(a,r); return r; }
295 |
296 | // (public) this^2
297 | function bnSquare() { var r = nbi(); this.squareTo(r); return r; }
298 |
299 | // (public) this / a
300 | function bnDivide(a) { var r = nbi(); this.divRemTo(a,r,null); return r; }
301 |
302 | // (public) this % a
303 | function bnRemainder(a) { var r = nbi(); this.divRemTo(a,null,r); return r; }
304 |
305 | // (public) [this/a,this%a]
306 | function bnDivideAndRemainder(a) {
307 | var q = nbi(), r = nbi();
308 | this.divRemTo(a,q,r);
309 | return new Array(q,r);
310 | }
311 |
312 | // (protected) this *= n, this >= 0, 1 < n < DV
313 | function bnpDMultiply(n) {
314 | this[this.t] = this.am(0,n-1,this,0,0,this.t);
315 | ++this.t;
316 | this.clamp();
317 | }
318 |
319 | // (protected) this += n << w words, this >= 0
320 | function bnpDAddOffset(n,w) {
321 | if(n == 0) return;
322 | while(this.t <= w) this[this.t++] = 0;
323 | this[w] += n;
324 | while(this[w] >= this.DV) {
325 | this[w] -= this.DV;
326 | if(++w >= this.t) this[this.t++] = 0;
327 | ++this[w];
328 | }
329 | }
330 |
331 | // A "null" reducer
332 | function NullExp() {}
333 | function nNop(x) { return x; }
334 | function nMulTo(x,y,r) { x.multiplyTo(y,r); }
335 | function nSqrTo(x,r) { x.squareTo(r); }
336 |
337 | NullExp.prototype.convert = nNop;
338 | NullExp.prototype.revert = nNop;
339 | NullExp.prototype.mulTo = nMulTo;
340 | NullExp.prototype.sqrTo = nSqrTo;
341 |
342 | // (public) this^e
343 | function bnPow(e) { return this.exp(e,new NullExp()); }
344 |
345 | // (protected) r = lower n words of "this * a", a.t <= n
346 | // "this" should be the larger one if appropriate.
347 | function bnpMultiplyLowerTo(a,n,r) {
348 | var i = Math.min(this.t+a.t,n);
349 | r.s = 0; // assumes a,this >= 0
350 | r.t = i;
351 | while(i > 0) r[--i] = 0;
352 | var j;
353 | for(j = r.t-this.t; i < j; ++i) r[i+this.t] = this.am(0,a[i],r,i,0,this.t);
354 | for(j = Math.min(a.t,n); i < j; ++i) this.am(0,a[i],r,i,0,n-i);
355 | r.clamp();
356 | }
357 |
358 | // (protected) r = "this * a" without lower n words, n > 0
359 | // "this" should be the larger one if appropriate.
360 | function bnpMultiplyUpperTo(a,n,r) {
361 | --n;
362 | var i = r.t = this.t+a.t-n;
363 | r.s = 0; // assumes a,this >= 0
364 | while(--i >= 0) r[i] = 0;
365 | for(i = Math.max(n-this.t,0); i < a.t; ++i)
366 | r[this.t+i-n] = this.am(n-i,a[i],r,0,0,this.t+i-n);
367 | r.clamp();
368 | r.drShiftTo(1,r);
369 | }
370 |
371 | // Barrett modular reduction
372 | function Barrett(m) {
373 | // setup Barrett
374 | this.r2 = nbi();
375 | this.q3 = nbi();
376 | BigInteger.ONE.dlShiftTo(2*m.t,this.r2);
377 | this.mu = this.r2.divide(m);
378 | this.m = m;
379 | }
380 |
381 | function barrettConvert(x) {
382 | if(x.s < 0 || x.t > 2*this.m.t) return x.mod(this.m);
383 | else if(x.compareTo(this.m) < 0) return x;
384 | else { var r = nbi(); x.copyTo(r); this.reduce(r); return r; }
385 | }
386 |
387 | function barrettRevert(x) { return x; }
388 |
389 | // x = x mod m (HAC 14.42)
390 | function barrettReduce(x) {
391 | x.drShiftTo(this.m.t-1,this.r2);
392 | if(x.t > this.m.t+1) { x.t = this.m.t+1; x.clamp(); }
393 | this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3);
394 | this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);
395 | while(x.compareTo(this.r2) < 0) x.dAddOffset(1,this.m.t+1);
396 | x.subTo(this.r2,x);
397 | while(x.compareTo(this.m) >= 0) x.subTo(this.m,x);
398 | }
399 |
400 | // r = x^2 mod m; x != r
401 | function barrettSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
402 |
403 | // r = x*y mod m; x,y != r
404 | function barrettMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
405 |
406 | Barrett.prototype.convert = barrettConvert;
407 | Barrett.prototype.revert = barrettRevert;
408 | Barrett.prototype.reduce = barrettReduce;
409 | Barrett.prototype.mulTo = barrettMulTo;
410 | Barrett.prototype.sqrTo = barrettSqrTo;
411 |
412 | // (public) this^e % m (HAC 14.85)
413 | function bnModPow(e,m) {
414 | var i = e.bitLength(), k, r = nbv(1), z;
415 | if(i <= 0) return r;
416 | else if(i < 18) k = 1;
417 | else if(i < 48) k = 3;
418 | else if(i < 144) k = 4;
419 | else if(i < 768) k = 5;
420 | else k = 6;
421 | if(i < 8)
422 | z = new Classic(m);
423 | else if(m.isEven())
424 | z = new Barrett(m);
425 | else
426 | z = new Montgomery(m);
427 |
428 | // precomputation
429 | var g = new Array(), n = 3, k1 = k-1, km = (1< 1) {
432 | var g2 = nbi();
433 | z.sqrTo(g[1],g2);
434 | while(n <= km) {
435 | g[n] = nbi();
436 | z.mulTo(g2,g[n-2],g[n]);
437 | n += 2;
438 | }
439 | }
440 |
441 | var j = e.t-1, w, is1 = true, r2 = nbi(), t;
442 | i = nbits(e[j])-1;
443 | while(j >= 0) {
444 | if(i >= k1) w = (e[j]>>(i-k1))&km;
445 | else {
446 | w = (e[j]&((1<<(i+1))-1))<<(k1-i);
447 | if(j > 0) w |= e[j-1]>>(this.DB+i-k1);
448 | }
449 |
450 | n = k;
451 | while((w&1) == 0) { w >>= 1; --n; }
452 | if((i -= n) < 0) { i += this.DB; --j; }
453 | if(is1) { // ret == 1, don't bother squaring or multiplying it
454 | g[w].copyTo(r);
455 | is1 = false;
456 | }
457 | else {
458 | while(n > 1) { z.sqrTo(r,r2); z.sqrTo(r2,r); n -= 2; }
459 | if(n > 0) z.sqrTo(r,r2); else { t = r; r = r2; r2 = t; }
460 | z.mulTo(r2,g[w],r);
461 | }
462 |
463 | while(j >= 0 && (e[j]&(1< 0) {
480 | x.rShiftTo(g,x);
481 | y.rShiftTo(g,y);
482 | }
483 | while(x.signum() > 0) {
484 | if((i = x.getLowestSetBit()) > 0) x.rShiftTo(i,x);
485 | if((i = y.getLowestSetBit()) > 0) y.rShiftTo(i,y);
486 | if(x.compareTo(y) >= 0) {
487 | x.subTo(y,x);
488 | x.rShiftTo(1,x);
489 | }
490 | else {
491 | y.subTo(x,y);
492 | y.rShiftTo(1,y);
493 | }
494 | }
495 | if(g > 0) y.lShiftTo(g,y);
496 | return y;
497 | }
498 |
499 | // (protected) this % n, n < 2^26
500 | function bnpModInt(n) {
501 | if(n <= 0) return 0;
502 | var d = this.DV%n, r = (this.s<0)?n-1:0;
503 | if(this.t > 0)
504 | if(d == 0) r = this[0]%n;
505 | else for(var i = this.t-1; i >= 0; --i) r = (d*r+this[i])%n;
506 | return r;
507 | }
508 |
509 | // (public) 1/this % m (HAC 14.61)
510 | function bnModInverse(m) {
511 | var ac = m.isEven();
512 | if((this.isEven() && ac) || m.signum() == 0) return BigInteger.ZERO;
513 | var u = m.clone(), v = this.clone();
514 | var a = nbv(1), b = nbv(0), c = nbv(0), d = nbv(1);
515 | while(u.signum() != 0) {
516 | while(u.isEven()) {
517 | u.rShiftTo(1,u);
518 | if(ac) {
519 | if(!a.isEven() || !b.isEven()) { a.addTo(this,a); b.subTo(m,b); }
520 | a.rShiftTo(1,a);
521 | }
522 | else if(!b.isEven()) b.subTo(m,b);
523 | b.rShiftTo(1,b);
524 | }
525 | while(v.isEven()) {
526 | v.rShiftTo(1,v);
527 | if(ac) {
528 | if(!c.isEven() || !d.isEven()) { c.addTo(this,c); d.subTo(m,d); }
529 | c.rShiftTo(1,c);
530 | }
531 | else if(!d.isEven()) d.subTo(m,d);
532 | d.rShiftTo(1,d);
533 | }
534 | if(u.compareTo(v) >= 0) {
535 | u.subTo(v,u);
536 | if(ac) a.subTo(c,a);
537 | b.subTo(d,b);
538 | }
539 | else {
540 | v.subTo(u,v);
541 | if(ac) c.subTo(a,c);
542 | d.subTo(b,d);
543 | }
544 | }
545 | if(v.compareTo(BigInteger.ONE) != 0) return BigInteger.ZERO;
546 | if(d.compareTo(m) >= 0) return d.subtract(m);
547 | if(d.signum() < 0) d.addTo(m,d); else return d;
548 | if(d.signum() < 0) return d.add(m); else return d;
549 | }
550 |
551 | var lowprimes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997];
552 | var lplim = (1<<26)/lowprimes[lowprimes.length-1];
553 |
554 | // (public) test primality with certainty >= 1-.5^t
555 | function bnIsProbablePrime(t) {
556 | var i, x = this.abs();
557 | if(x.t == 1 && x[0] <= lowprimes[lowprimes.length-1]) {
558 | for(i = 0; i < lowprimes.length; ++i)
559 | if(x[0] == lowprimes[i]) return true;
560 | return false;
561 | }
562 | if(x.isEven()) return false;
563 | i = 1;
564 | while(i < lowprimes.length) {
565 | var m = lowprimes[i], j = i+1;
566 | while(j < lowprimes.length && m < lplim) m *= lowprimes[j++];
567 | m = x.modInt(m);
568 | while(i < j) if(m%lowprimes[i++] == 0) return false;
569 | }
570 | return x.millerRabin(t);
571 | }
572 |
573 | // (protected) true if probably prime (HAC 4.24, Miller-Rabin)
574 | function bnpMillerRabin(t) {
575 | var n1 = this.subtract(BigInteger.ONE);
576 | var k = n1.getLowestSetBit();
577 | if(k <= 0) return false;
578 | var r = n1.shiftRight(k);
579 | t = (t+1)>>1;
580 | if(t > lowprimes.length) t = lowprimes.length;
581 | var a = nbi();
582 | for(var i = 0; i < t; ++i) {
583 | //Pick bases at random, instead of starting at 2
584 | a.fromInt(lowprimes[Math.floor(Math.random()*lowprimes.length)]);
585 | var y = a.modPow(r,this);
586 | if(y.compareTo(BigInteger.ONE) != 0 && y.compareTo(n1) != 0) {
587 | var j = 1;
588 | while(j++ < k && y.compareTo(n1) != 0) {
589 | y = y.modPowInt(2,this);
590 | if(y.compareTo(BigInteger.ONE) == 0) return false;
591 | }
592 | if(y.compareTo(n1) != 0) return false;
593 | }
594 | }
595 | return true;
596 | }
597 |
598 | // protected
599 | BigInteger.prototype.chunkSize = bnpChunkSize;
600 | BigInteger.prototype.toRadix = bnpToRadix;
601 | BigInteger.prototype.fromRadix = bnpFromRadix;
602 | BigInteger.prototype.fromNumber = bnpFromNumber;
603 | BigInteger.prototype.bitwiseTo = bnpBitwiseTo;
604 | BigInteger.prototype.changeBit = bnpChangeBit;
605 | BigInteger.prototype.addTo = bnpAddTo;
606 | BigInteger.prototype.dMultiply = bnpDMultiply;
607 | BigInteger.prototype.dAddOffset = bnpDAddOffset;
608 | BigInteger.prototype.multiplyLowerTo = bnpMultiplyLowerTo;
609 | BigInteger.prototype.multiplyUpperTo = bnpMultiplyUpperTo;
610 | BigInteger.prototype.modInt = bnpModInt;
611 | BigInteger.prototype.millerRabin = bnpMillerRabin;
612 |
613 | // public
614 | BigInteger.prototype.clone = bnClone;
615 | BigInteger.prototype.intValue = bnIntValue;
616 | BigInteger.prototype.byteValue = bnByteValue;
617 | BigInteger.prototype.shortValue = bnShortValue;
618 | BigInteger.prototype.signum = bnSigNum;
619 | BigInteger.prototype.toByteArray = bnToByteArray;
620 | BigInteger.prototype.equals = bnEquals;
621 | BigInteger.prototype.min = bnMin;
622 | BigInteger.prototype.max = bnMax;
623 | BigInteger.prototype.and = bnAnd;
624 | BigInteger.prototype.or = bnOr;
625 | BigInteger.prototype.xor = bnXor;
626 | BigInteger.prototype.andNot = bnAndNot;
627 | BigInteger.prototype.not = bnNot;
628 | BigInteger.prototype.shiftLeft = bnShiftLeft;
629 | BigInteger.prototype.shiftRight = bnShiftRight;
630 | BigInteger.prototype.getLowestSetBit = bnGetLowestSetBit;
631 | BigInteger.prototype.bitCount = bnBitCount;
632 | BigInteger.prototype.testBit = bnTestBit;
633 | BigInteger.prototype.setBit = bnSetBit;
634 | BigInteger.prototype.clearBit = bnClearBit;
635 | BigInteger.prototype.flipBit = bnFlipBit;
636 | BigInteger.prototype.add = bnAdd;
637 | BigInteger.prototype.subtract = bnSubtract;
638 | BigInteger.prototype.multiply = bnMultiply;
639 | BigInteger.prototype.divide = bnDivide;
640 | BigInteger.prototype.remainder = bnRemainder;
641 | BigInteger.prototype.divideAndRemainder = bnDivideAndRemainder;
642 | BigInteger.prototype.modPow = bnModPow;
643 | BigInteger.prototype.modInverse = bnModInverse;
644 | BigInteger.prototype.pow = bnPow;
645 | BigInteger.prototype.gcd = bnGCD;
646 | BigInteger.prototype.isProbablePrime = bnIsProbablePrime;
647 |
648 | // JSBN-specific extension
649 | BigInteger.prototype.square = bnSquare;
650 |
651 | // BigInteger interfaces not implemented in jsbn:
652 |
653 | // BigInteger(int signum, byte[] magnitude)
654 | // double doubleValue()
655 | // float floatValue()
656 | // int hashCode()
657 | // long longValue()
658 | // static BigInteger valueOf(long val)
659 |
--------------------------------------------------------------------------------
/js/ext/prng4.js:
--------------------------------------------------------------------------------
1 | /*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/
2 | */
3 | // prng4.js - uses Arcfour as a PRNG
4 |
5 | function Arcfour() {
6 | this.i = 0;
7 | this.j = 0;
8 | this.S = new Array();
9 | }
10 |
11 | // Initialize arcfour context from key, an array of ints, each from [0..255]
12 | function ARC4init(key) {
13 | var i, j, t;
14 | for(i = 0; i < 256; ++i)
15 | this.S[i] = i;
16 | j = 0;
17 | for(i = 0; i < 256; ++i) {
18 | j = (j + this.S[i] + key[i % key.length]) & 255;
19 | t = this.S[i];
20 | this.S[i] = this.S[j];
21 | this.S[j] = t;
22 | }
23 | this.i = 0;
24 | this.j = 0;
25 | }
26 |
27 | function ARC4next() {
28 | var t;
29 | this.i = (this.i + 1) & 255;
30 | this.j = (this.j + this.S[this.i]) & 255;
31 | t = this.S[this.i];
32 | this.S[this.i] = this.S[this.j];
33 | this.S[this.j] = t;
34 | return this.S[(t + this.S[this.i]) & 255];
35 | }
36 |
37 | Arcfour.prototype.init = ARC4init;
38 | Arcfour.prototype.next = ARC4next;
39 |
40 | // Plug in your RNG constructor here
41 | function prng_newstate() {
42 | return new Arcfour();
43 | }
44 |
45 | // Pool size must be a multiple of 4 and greater than 32.
46 | // An array of bytes the size of the pool will be passed to init()
47 | var rng_psize = 256;
48 |
--------------------------------------------------------------------------------
/js/ext/rng.js:
--------------------------------------------------------------------------------
1 | /*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/
2 | */
3 | // Random number generator - requires a PRNG backend, e.g. prng4.js
4 |
5 | // For best results, put code like
6 | //
7 | // in your main HTML document.
8 |
9 | var rng_state;
10 | var rng_pool;
11 | var rng_pptr;
12 |
13 | // Mix in a 32-bit integer into the pool
14 | function rng_seed_int(x) {
15 | rng_pool[rng_pptr++] ^= x & 255;
16 | rng_pool[rng_pptr++] ^= (x >> 8) & 255;
17 | rng_pool[rng_pptr++] ^= (x >> 16) & 255;
18 | rng_pool[rng_pptr++] ^= (x >> 24) & 255;
19 | if(rng_pptr >= rng_psize) rng_pptr -= rng_psize;
20 | }
21 |
22 | // Mix in the current time (w/milliseconds) into the pool
23 | function rng_seed_time() {
24 | rng_seed_int(new Date().getTime());
25 | }
26 |
27 | // Initialize the pool with junk if needed.
28 | if(rng_pool == null) {
29 | rng_pool = new Array();
30 | rng_pptr = 0;
31 | var t;
32 | if(navigator.appName == "Netscape" && navigator.appVersion < "5" && window.crypto) {
33 | // Extract entropy (256 bits) from NS4 RNG if available
34 | var z = window.crypto.random(32);
35 | for(t = 0; t < z.length; ++t)
36 | rng_pool[rng_pptr++] = z.charCodeAt(t) & 255;
37 | }
38 | while(rng_pptr < rng_psize) { // extract some randomness from Math.random()
39 | t = Math.floor(65536 * Math.random());
40 | rng_pool[rng_pptr++] = t >>> 8;
41 | rng_pool[rng_pptr++] = t & 255;
42 | }
43 | rng_pptr = 0;
44 | rng_seed_time();
45 | //rng_seed_int(window.screenX);
46 | //rng_seed_int(window.screenY);
47 | }
48 |
49 | function rng_get_byte() {
50 | if(rng_state == null) {
51 | rng_seed_time();
52 | rng_state = prng_newstate();
53 | rng_state.init(rng_pool);
54 | for(rng_pptr = 0; rng_pptr < rng_pool.length; ++rng_pptr)
55 | rng_pool[rng_pptr] = 0;
56 | rng_pptr = 0;
57 | //rng_pool = null;
58 | }
59 | // TODO: allow reseeding after first request
60 | return rng_state.next();
61 | }
62 |
63 | function rng_get_bytes(ba) {
64 | var i;
65 | for(i = 0; i < ba.length; ++i) ba[i] = rng_get_byte();
66 | }
67 |
68 | function SecureRandom() {}
69 |
70 | SecureRandom.prototype.nextBytes = rng_get_bytes;
71 |
--------------------------------------------------------------------------------
/js/utils/byteUtil.js:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * 字节流转换工具js
4 | *
5 | */
6 |
7 | /*
8 | * 数组复制
9 | */
10 | function arrayCopy(src,pos1,dest,pos2,len){
11 | var realLen = len;
12 | if(pos1+len>src.length&&pos2+len<=dest.length){
13 | realLen = src.length-pos1;
14 | }else if(pos2+len>dest.length&&pos1+len<=src.length){
15 | realLen = dest.length-pos2;
16 | }else if(pos1+len<=src.length&&pos2+len<=dest.length){
17 | realLen = len;
18 | }else if(dest.length> 24)&0x000000FF,
41 | (num >> 16)&0x000000FF,
42 | (num >> 8)&0x000000FF,
43 | (num)&0x000000FF
44 | );
45 | }
46 |
47 | /*
48 | * int数转成byte数组
49 | * 事实上只不过转成byte大小的数,实际占用空间还是4字节
50 | * 返回:字节数组
51 | */
52 | function intToByte(num) {
53 | return new Array(
54 | (num >> 24)&0x000000FF,
55 | (num >> 16)&0x000000FF,
56 | (num >> 8)&0x000000FF,
57 | (num)&0x000000FF
58 | );
59 | }
60 |
61 | /*
62 | * int数组转成byte数组,一个int数值转成四个byte
63 | * 返回:byte数组
64 | */
65 | function intArrayToByteArray(nums) {
66 | var b = new Array(nums.length*4);
67 |
68 | for(var i = 0;i>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
217 | thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
218 | }
219 | } else if (thatWords.length > 0xffff) {
220 | // Copy one word at a time
221 | for (var i = 0; i < thatSigBytes; i += 4) {
222 | thisWords[(thisSigBytes + i) >>> 2] = thatWords[i >>> 2];
223 | }
224 | } else {
225 | // Copy all words at once
226 | thisWords.push.apply(thisWords, thatWords);
227 | }
228 | this.sigBytes += thatSigBytes;
229 |
230 | // Chainable
231 | return this;
232 | },
233 |
234 | /**
235 | * Removes insignificant bits.
236 | *
237 | * @example
238 | *
239 | * wordArray.clamp();
240 | */
241 | clamp: function () {
242 | // Shortcuts
243 | var words = this.words;
244 | var sigBytes = this.sigBytes;
245 |
246 | // Clamp
247 | words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
248 | words.length = Math.ceil(sigBytes / 4);
249 | },
250 |
251 | /**
252 | * Creates a copy of this word array.
253 | *
254 | * @return {WordArray} The clone.
255 | *
256 | * @example
257 | *
258 | * var clone = wordArray.clone();
259 | */
260 | clone: function () {
261 | var clone = Base.clone.call(this);
262 | clone.words = this.words.slice(0);
263 |
264 | return clone;
265 | },
266 |
267 | /**
268 | * Creates a word array filled with random bytes.
269 | *
270 | * @param {number} nBytes The number of random bytes to generate.
271 | *
272 | * @return {WordArray} The random word array.
273 | *
274 | * @static
275 | *
276 | * @example
277 | *
278 | * var wordArray = CryptoJS.lib.WordArray.random(16);
279 | */
280 | random: function (nBytes) {
281 | var words = [];
282 | for (var i = 0; i < nBytes; i += 4) {
283 | words.push((Math.random() * 0x100000000) | 0);
284 | }
285 |
286 | return new WordArray.init(words, nBytes);
287 | }
288 | });
289 |
290 | /**
291 | * Encoder namespace.
292 | */
293 | var C_enc = C.enc = {};
294 |
295 | /**
296 | * Hex encoding strategy.
297 | */
298 | var Hex = C_enc.Hex = {
299 | /**
300 | * Converts a word array to a hex string.
301 | *
302 | * @param {WordArray} wordArray The word array.
303 | *
304 | * @return {string} The hex string.
305 | *
306 | * @static
307 | *
308 | * @example
309 | *
310 | * var hexString = CryptoJS.enc.Hex.stringify(wordArray);
311 | */
312 | stringify: function (wordArray) {
313 | // Shortcuts
314 | var words = wordArray.words;
315 | var sigBytes = wordArray.sigBytes;
316 |
317 | // Convert
318 | var hexChars = [];
319 | for (var i = 0; i < sigBytes; i++) {
320 | var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
321 | hexChars.push((bite >>> 4).toString(16));
322 | hexChars.push((bite & 0x0f).toString(16));
323 | }
324 |
325 | return hexChars.join('');
326 | },
327 |
328 | /**
329 | * Converts a hex string to a word array.
330 | *
331 | * @param {string} hexStr The hex string.
332 | *
333 | * @return {WordArray} The word array.
334 | *
335 | * @static
336 | *
337 | * @example
338 | *
339 | * var wordArray = CryptoJS.enc.Hex.parse(hexString);
340 | */
341 | parse: function (hexStr) {
342 | // Shortcut
343 | var hexStrLength = hexStr.length;
344 |
345 | // Convert
346 | var words = [];
347 | for (var i = 0; i < hexStrLength; i += 2) {
348 | words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
349 | }
350 |
351 | return new WordArray.init(words, hexStrLength / 2);
352 | }
353 | };
354 |
355 | /**
356 | * Latin1 encoding strategy.
357 | */
358 | var Latin1 = C_enc.Latin1 = {
359 | /**
360 | * Converts a word array to a Latin1 string.
361 | *
362 | * @param {WordArray} wordArray The word array.
363 | *
364 | * @return {string} The Latin1 string.
365 | *
366 | * @static
367 | *
368 | * @example
369 | *
370 | * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
371 | */
372 | stringify: function (wordArray) {
373 | // Shortcuts
374 | var words = wordArray.words;
375 | var sigBytes = wordArray.sigBytes;
376 |
377 | // Convert
378 | var latin1Chars = [];
379 | for (var i = 0; i < sigBytes; i++) {
380 | var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
381 | latin1Chars.push(String.fromCharCode(bite));
382 | }
383 |
384 | return latin1Chars.join('');
385 | },
386 |
387 | /**
388 | * Converts a Latin1 string to a word array.
389 | *
390 | * @param {string} latin1Str The Latin1 string.
391 | *
392 | * @return {WordArray} The word array.
393 | *
394 | * @static
395 | *
396 | * @example
397 | *
398 | * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
399 | */
400 | parse: function (latin1Str) {
401 | // Shortcut
402 | var latin1StrLength = latin1Str.length;
403 |
404 | // Convert
405 | var words = [];
406 | for (var i = 0; i < latin1StrLength; i++) {
407 | words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
408 | }
409 |
410 | return new WordArray.init(words, latin1StrLength);
411 | }
412 | };
413 |
414 | /**
415 | * UTF-8 encoding strategy.
416 | */
417 | var Utf8 = C_enc.Utf8 = {
418 | /**
419 | * Converts a word array to a UTF-8 string.
420 | *
421 | * @param {WordArray} wordArray The word array.
422 | *
423 | * @return {string} The UTF-8 string.
424 | *
425 | * @static
426 | *
427 | * @example
428 | *
429 | * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
430 | */
431 | stringify: function (wordArray) {
432 | try {
433 | return decodeURIComponent(escape(Latin1.stringify(wordArray)));
434 | } catch (e) {
435 | throw new Error('Malformed UTF-8 data');
436 | }
437 | },
438 |
439 | /**
440 | * Converts a UTF-8 string to a word array.
441 | *
442 | * @param {string} utf8Str The UTF-8 string.
443 | *
444 | * @return {WordArray} The word array.
445 | *
446 | * @static
447 | *
448 | * @example
449 | *
450 | * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
451 | */
452 | parse: function (utf8Str) {
453 | var ens = encodeURIComponent(utf8Str);
454 | var es = unescape(ens);
455 | return Latin1.parse(es);
456 | }
457 | };
458 |
459 | /**
460 | * Abstract buffered block algorithm template.
461 | *
462 | * The property blockSize must be implemented in a concrete subtype.
463 | *
464 | * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0
465 | */
466 | var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
467 | /**
468 | * Resets this block algorithm's data buffer to its initial state.
469 | *
470 | * @example
471 | *
472 | * bufferedBlockAlgorithm.reset();
473 | */
474 | reset: function () {
475 | // Initial values
476 | this._data = new WordArray.init();
477 | this._nDataBytes = 0;
478 | },
479 |
480 | /**
481 | * Adds new data to this block algorithm's buffer.
482 | *
483 | * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
484 | *
485 | * @example
486 | *
487 | * bufferedBlockAlgorithm._append('data');
488 | * bufferedBlockAlgorithm._append(wordArray);
489 | */
490 | _append: function (data) {
491 | // Convert string to WordArray, else assume WordArray already
492 | if (typeof data == 'string') {
493 | data = Utf8.parse(data);
494 | }
495 |
496 | // Append
497 | this._data.concat(data);
498 | this._nDataBytes += data.sigBytes;
499 | },
500 |
501 | /**
502 | * Processes available data blocks.
503 | *
504 | * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
505 | *
506 | * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
507 | *
508 | * @return {WordArray} The processed data.
509 | *
510 | * @example
511 | *
512 | * var processedData = bufferedBlockAlgorithm._process();
513 | * var processedData = bufferedBlockAlgorithm._process(!!'flush');
514 | */
515 | _process: function (doFlush) {
516 | // Shortcuts
517 | var data = this._data;
518 | var dataWords = data.words;
519 | var dataSigBytes = data.sigBytes;
520 | var blockSize = this.blockSize;
521 | var blockSizeBytes = blockSize * 4;
522 |
523 | // Count blocks ready
524 | var nBlocksReady = dataSigBytes / blockSizeBytes;
525 | if (doFlush) {
526 | // Round up to include partial blocks
527 | nBlocksReady = Math.ceil(nBlocksReady);
528 | } else {
529 | // Round down to include only full blocks,
530 | // less the number of blocks that must remain in the buffer
531 | nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
532 | }
533 |
534 | // Count words ready
535 | var nWordsReady = nBlocksReady * blockSize;
536 |
537 | // Count bytes ready
538 | var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
539 |
540 | // Process blocks
541 | if (nWordsReady) {
542 | for (var offset = 0; offset < nWordsReady; offset += blockSize) {
543 | // Perform concrete-algorithm logic
544 | this._doProcessBlock(dataWords, offset);
545 | }
546 |
547 | // Remove processed words
548 | var processedWords = dataWords.splice(0, nWordsReady);
549 | data.sigBytes -= nBytesReady;
550 | }
551 |
552 | // Return processed words
553 | return new WordArray.init(processedWords, nBytesReady);
554 | },
555 |
556 | /**
557 | * Creates a copy of this object.
558 | *
559 | * @return {Object} The clone.
560 | *
561 | * @example
562 | *
563 | * var clone = bufferedBlockAlgorithm.clone();
564 | */
565 | clone: function () {
566 | var clone = Base.clone.call(this);
567 | clone._data = this._data.clone();
568 |
569 | return clone;
570 | },
571 |
572 | _minBufferSize: 0
573 | });
574 |
575 | /**
576 | * Abstract hasher template.
577 | *
578 | * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
579 | */
580 | var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
581 | /**
582 | * Configuration options.
583 | */
584 | cfg: Base.extend(),
585 |
586 | /**
587 | * Initializes a newly created hasher.
588 | *
589 | * @param {Object} cfg (Optional) The configuration options to use for this hash computation.
590 | *
591 | * @example
592 | *
593 | * var hasher = CryptoJS.algo.SHA256.create();
594 | */
595 | init: function (cfg) {
596 | // Apply config defaults
597 | this.cfg = this.cfg.extend(cfg);
598 |
599 | // Set initial values
600 | this.reset();
601 | },
602 |
603 | /**
604 | * Resets this hasher to its initial state.
605 | *
606 | * @example
607 | *
608 | * hasher.reset();
609 | */
610 | reset: function () {
611 | // Reset data buffer
612 | BufferedBlockAlgorithm.reset.call(this);
613 |
614 | // Perform concrete-hasher logic
615 | this._doReset();
616 | },
617 |
618 | /**
619 | * Updates this hasher with a message.
620 | *
621 | * @param {WordArray|string} messageUpdate The message to append.
622 | *
623 | * @return {Hasher} This hasher.
624 | *
625 | * @example
626 | *
627 | * hasher.update('message');
628 | * hasher.update(wordArray);
629 | */
630 | update: function (messageUpdate) {
631 | // Append
632 | this._append(messageUpdate);
633 |
634 | // Update the hash
635 | this._process();
636 |
637 | // Chainable
638 | return this;
639 | },
640 |
641 | /**
642 | * Finalizes the hash computation.
643 | * Note that the finalize operation is effectively a destructive, read-once operation.
644 | *
645 | * @param {WordArray|string} messageUpdate (Optional) A final message update.
646 | *
647 | * @return {WordArray} The hash.
648 | *
649 | * @example
650 | *
651 | * var hash = hasher.finalize();
652 | * var hash = hasher.finalize('message');
653 | * var hash = hasher.finalize(wordArray);
654 | */
655 | finalize: function (messageUpdate) {
656 | // Final message update
657 | if (messageUpdate) {
658 | this._append(messageUpdate);
659 | }
660 |
661 | // Perform concrete-hasher logic
662 | var hash = this._doFinalize();
663 |
664 | return hash;
665 | },
666 |
667 | blockSize: 512/32,
668 |
669 | /**
670 | * Creates a shortcut function to a hasher's object interface.
671 | *
672 | * @param {Hasher} hasher The hasher to create a helper for.
673 | *
674 | * @return {Function} The shortcut function.
675 | *
676 | * @static
677 | *
678 | * @example
679 | *
680 | * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
681 | */
682 | _createHelper: function (hasher) {
683 | return function (message, cfg) {
684 | return new hasher.init(cfg).finalize(message);
685 | };
686 | },
687 |
688 | /**
689 | * Creates a shortcut function to the HMAC's object interface.
690 | *
691 | * @param {Hasher} hasher The hasher to use in this HMAC helper.
692 | *
693 | * @return {Function} The shortcut function.
694 | *
695 | * @static
696 | *
697 | * @example
698 | *
699 | * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
700 | */
701 | _createHmacHelper: function (hasher) {
702 | return function (message, key) {
703 | return new C_algo.HMAC.init(hasher, key).finalize(message);
704 | };
705 | }
706 | });
707 |
708 | /**
709 | * Algorithm namespace.
710 | */
711 | var C_algo = C.algo = {};
712 |
713 | return C;
714 | }(Math));
715 |
--------------------------------------------------------------------------------
/js/utils/hex.js:
--------------------------------------------------------------------------------
1 | function Hex(){
2 |
3 | }
4 |
5 | Hex.encode = function(b,pos,len) {
6 | var hexCh = new Array(len*2);
7 | var hexCode = new Array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
8 |
9 | for(var i = pos,j = 0;i>4];
11 | hexCh[++j] = hexCode[(b[i]&0x0F)];
12 | }
13 |
14 | return hexCh.join('');
15 | }
16 |
17 | Hex.decode = function(hex) {
18 |
19 | if(hex == null || hex == '') {
20 | return null;
21 | }
22 | if(hex.length%2 != 0) {
23 | return null;
24 | }
25 |
26 | var ascLen = hex.length/2;
27 | var hexCh = this.toCharCodeArray(hex);
28 | var asc = new Array(ascLen);
29 |
30 | for(var i = 0;i=0x30 && hexCh[2*i]<=0x39) {
33 | asc[i] = ((hexCh[2*i]-0x30)<<4);
34 | }else if(hexCh[2*i]>=0x41 && hexCh[2*i]<=0x46) {//A-F : 0x41-0x46
35 | asc[i] = ((hexCh[2*i]-0x41+10)<<4);
36 | }else if(hexCh[2*i]>=0x61 && hexCh[2*i]<=0x66) {//a-f : 0x61-0x66
37 | asc[i] = ((hexCh[2*i]-0x61+10)<<4);
38 | }else {
39 | return null;
40 | }
41 |
42 | if(hexCh[2*i+1]>=0x30 && hexCh[2*i+1]<=0x39) {
43 | asc[i] = (asc[i] | (hexCh[2*i+1]-0x30));
44 | }else if(hexCh[2*i+1]>=0x41 && hexCh[2*i+1]<=0x46) {
45 | asc[i] = (asc[i] | (hexCh[2*i+1]-0x41+10));
46 | }else if(hexCh[2*i+1]>=0x61 && hexCh[2*i+1]<=0x66) {
47 | asc[i] = (asc[i] | (hexCh[2*i+1]-0x61+10));
48 | }else {
49 | return null;
50 | }
51 |
52 |
53 | }
54 |
55 | return asc;
56 | }
57 |
58 | Hex.utf8StrToHex = function(utf8Str){
59 | var ens = encodeURIComponent(utf8Str);
60 | var es = unescape(ens);
61 |
62 |
63 | var esLen = es.length;
64 |
65 | // Convert
66 | var words = [];
67 | for (var i = 0; i < esLen; i++) {
68 | words[i] = (es.charCodeAt(i).toString(16));
69 | }
70 | return words.join('');
71 | }
72 |
73 | Hex.utf8StrToBytes = function(utf8Str){
74 | var ens = encodeURIComponent(utf8Str);
75 | var es = unescape(ens);
76 |
77 |
78 | var esLen = es.length;
79 |
80 | // Convert
81 | var words = [];
82 | for (var i = 0; i < esLen; i++) {
83 | words[i] = es.charCodeAt(i);
84 | }
85 | return words;
86 | }
87 |
88 | Hex.hexToUtf8Str = function(utf8Str){
89 |
90 | var utf8Byte = Hex.decode(utf8Str);
91 | var latin1Chars = [];
92 | for (var i = 0; i < utf8Byte.length; i++) {
93 | latin1Chars.push(String.fromCharCode(utf8Byte[i]));
94 | }
95 | return decodeURIComponent(escape(latin1Chars.join('')));
96 | }
97 |
98 | Hex.bytesToUtf8Str = function(bytesArray){
99 |
100 | var utf8Byte = bytesArray;
101 | var latin1Chars = [];
102 | for (var i = 0; i < utf8Byte.length; i++) {
103 | latin1Chars.push(String.fromCharCode(utf8Byte[i]));
104 | }
105 | return decodeURIComponent(escape(latin1Chars.join('')));
106 | }
107 |
108 | Hex.toCharCodeArray = function(chs){
109 | var chArr = new Array(chs.length);
110 | for(var i = 0;i=0&&n0&&t-1 in e)}var E=function(e){var t,n,r,i,o,a,s,u,l,c,f,p,d,h,g,y,v,m,x,b="sizzle"+1*new Date,w=e.document,T=0,C=0,E=ae(),k=ae(),S=ae(),D=function(e,t){return e===t&&(f=!0),0},N={}.hasOwnProperty,A=[],j=A.pop,q=A.push,L=A.push,H=A.slice,O=function(e,t){for(var n=0,r=e.length;n+~]|"+M+")"+M+"*"),z=new RegExp("="+M+"*([^\\]'\"]*?)"+M+"*\\]","g"),X=new RegExp(W),U=new RegExp("^"+R+"$"),V={ID:new RegExp("^#("+R+")"),CLASS:new RegExp("^\\.("+R+")"),TAG:new RegExp("^("+R+"|[*])"),ATTR:new RegExp("^"+I),PSEUDO:new RegExp("^"+W),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+P+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},G=/^(?:input|select|textarea|button)$/i,Y=/^h\d$/i,Q=/^[^{]+\{\s*\[native \w/,J=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,K=/[+~]/,Z=new RegExp("\\\\([\\da-f]{1,6}"+M+"?|("+M+")|.)","ig"),ee=function(e,t,n){var r="0x"+t-65536;return r!==r||n?t:r<0?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,1023&r|56320)},te=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ne=function(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},re=function(){p()},ie=me(function(e){return!0===e.disabled&&("form"in e||"label"in e)},{dir:"parentNode",next:"legend"});try{L.apply(A=H.call(w.childNodes),w.childNodes),A[w.childNodes.length].nodeType}catch(e){L={apply:A.length?function(e,t){q.apply(e,H.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function oe(e,t,r,i){var o,s,l,c,f,h,v,m=t&&t.ownerDocument,T=t?t.nodeType:9;if(r=r||[],"string"!=typeof e||!e||1!==T&&9!==T&&11!==T)return r;if(!i&&((t?t.ownerDocument||t:w)!==d&&p(t),t=t||d,g)){if(11!==T&&(f=J.exec(e)))if(o=f[1]){if(9===T){if(!(l=t.getElementById(o)))return r;if(l.id===o)return r.push(l),r}else if(m&&(l=m.getElementById(o))&&x(t,l)&&l.id===o)return r.push(l),r}else{if(f[2])return L.apply(r,t.getElementsByTagName(e)),r;if((o=f[3])&&n.getElementsByClassName&&t.getElementsByClassName)return L.apply(r,t.getElementsByClassName(o)),r}if(n.qsa&&!S[e+" "]&&(!y||!y.test(e))){if(1!==T)m=t,v=e;else if("object"!==t.nodeName.toLowerCase()){(c=t.getAttribute("id"))?c=c.replace(te,ne):t.setAttribute("id",c=b),s=(h=a(e)).length;while(s--)h[s]="#"+c+" "+ve(h[s]);v=h.join(","),m=K.test(e)&&ge(t.parentNode)||t}if(v)try{return L.apply(r,m.querySelectorAll(v)),r}catch(e){}finally{c===b&&t.removeAttribute("id")}}}return u(e.replace(B,"$1"),t,r,i)}function ae(){var e=[];function t(n,i){return e.push(n+" ")>r.cacheLength&&delete t[e.shift()],t[n+" "]=i}return t}function se(e){return e[b]=!0,e}function ue(e){var t=d.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function le(e,t){var n=e.split("|"),i=n.length;while(i--)r.attrHandle[n[i]]=t}function ce(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function fe(e){return function(t){return"input"===t.nodeName.toLowerCase()&&t.type===e}}function pe(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function de(e){return function(t){return"form"in t?t.parentNode&&!1===t.disabled?"label"in t?"label"in t.parentNode?t.parentNode.disabled===e:t.disabled===e:t.isDisabled===e||t.isDisabled!==!e&&ie(t)===e:t.disabled===e:"label"in t&&t.disabled===e}}function he(e){return se(function(t){return t=+t,se(function(n,r){var i,o=e([],n.length,t),a=o.length;while(a--)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}function ge(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}n=oe.support={},o=oe.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return!!t&&"HTML"!==t.nodeName},p=oe.setDocument=function(e){var t,i,a=e?e.ownerDocument||e:w;return a!==d&&9===a.nodeType&&a.documentElement?(d=a,h=d.documentElement,g=!o(d),w!==d&&(i=d.defaultView)&&i.top!==i&&(i.addEventListener?i.addEventListener("unload",re,!1):i.attachEvent&&i.attachEvent("onunload",re)),n.attributes=ue(function(e){return e.className="i",!e.getAttribute("className")}),n.getElementsByTagName=ue(function(e){return e.appendChild(d.createComment("")),!e.getElementsByTagName("*").length}),n.getElementsByClassName=Q.test(d.getElementsByClassName),n.getById=ue(function(e){return h.appendChild(e).id=b,!d.getElementsByName||!d.getElementsByName(b).length}),n.getById?(r.filter.ID=function(e){var t=e.replace(Z,ee);return function(e){return e.getAttribute("id")===t}},r.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&g){var n=t.getElementById(e);return n?[n]:[]}}):(r.filter.ID=function(e){var t=e.replace(Z,ee);return function(e){var n="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return n&&n.value===t}},r.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&g){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),r.find.TAG=n.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):n.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},r.find.CLASS=n.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&g)return t.getElementsByClassName(e)},v=[],y=[],(n.qsa=Q.test(d.querySelectorAll))&&(ue(function(e){h.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&y.push("[*^$]="+M+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||y.push("\\["+M+"*(?:value|"+P+")"),e.querySelectorAll("[id~="+b+"-]").length||y.push("~="),e.querySelectorAll(":checked").length||y.push(":checked"),e.querySelectorAll("a#"+b+"+*").length||y.push(".#.+[+~]")}),ue(function(e){e.innerHTML="";var t=d.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&y.push("name"+M+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&y.push(":enabled",":disabled"),h.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&y.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),y.push(",.*:")})),(n.matchesSelector=Q.test(m=h.matches||h.webkitMatchesSelector||h.mozMatchesSelector||h.oMatchesSelector||h.msMatchesSelector))&&ue(function(e){n.disconnectedMatch=m.call(e,"*"),m.call(e,"[s!='']:x"),v.push("!=",W)}),y=y.length&&new RegExp(y.join("|")),v=v.length&&new RegExp(v.join("|")),t=Q.test(h.compareDocumentPosition),x=t||Q.test(h.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},D=t?function(e,t){if(e===t)return f=!0,0;var r=!e.compareDocumentPosition-!t.compareDocumentPosition;return r||(1&(r=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!n.sortDetached&&t.compareDocumentPosition(e)===r?e===d||e.ownerDocument===w&&x(w,e)?-1:t===d||t.ownerDocument===w&&x(w,t)?1:c?O(c,e)-O(c,t):0:4&r?-1:1)}:function(e,t){if(e===t)return f=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,a=[e],s=[t];if(!i||!o)return e===d?-1:t===d?1:i?-1:o?1:c?O(c,e)-O(c,t):0;if(i===o)return ce(e,t);n=e;while(n=n.parentNode)a.unshift(n);n=t;while(n=n.parentNode)s.unshift(n);while(a[r]===s[r])r++;return r?ce(a[r],s[r]):a[r]===w?-1:s[r]===w?1:0},d):d},oe.matches=function(e,t){return oe(e,null,null,t)},oe.matchesSelector=function(e,t){if((e.ownerDocument||e)!==d&&p(e),t=t.replace(z,"='$1']"),n.matchesSelector&&g&&!S[t+" "]&&(!v||!v.test(t))&&(!y||!y.test(t)))try{var r=m.call(e,t);if(r||n.disconnectedMatch||e.document&&11!==e.document.nodeType)return r}catch(e){}return oe(t,d,null,[e]).length>0},oe.contains=function(e,t){return(e.ownerDocument||e)!==d&&p(e),x(e,t)},oe.attr=function(e,t){(e.ownerDocument||e)!==d&&p(e);var i=r.attrHandle[t.toLowerCase()],o=i&&N.call(r.attrHandle,t.toLowerCase())?i(e,t,!g):void 0;return void 0!==o?o:n.attributes||!g?e.getAttribute(t):(o=e.getAttributeNode(t))&&o.specified?o.value:null},oe.escape=function(e){return(e+"").replace(te,ne)},oe.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},oe.uniqueSort=function(e){var t,r=[],i=0,o=0;if(f=!n.detectDuplicates,c=!n.sortStable&&e.slice(0),e.sort(D),f){while(t=e[o++])t===e[o]&&(i=r.push(o));while(i--)e.splice(r[i],1)}return c=null,e},i=oe.getText=function(e){var t,n="",r=0,o=e.nodeType;if(o){if(1===o||9===o||11===o){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=i(e)}else if(3===o||4===o)return e.nodeValue}else while(t=e[r++])n+=i(t);return n},(r=oe.selectors={cacheLength:50,createPseudo:se,match:V,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(Z,ee),e[3]=(e[3]||e[4]||e[5]||"").replace(Z,ee),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||oe.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&oe.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return V.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&X.test(n)&&(t=a(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(Z,ee).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=E[e+" "];return t||(t=new RegExp("(^|"+M+")"+e+"("+M+"|$)"))&&E(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r){var i=oe.attr(r,e);return null==i?"!="===t:!t||(i+="","="===t?i===n:"!="===t?i!==n:"^="===t?n&&0===i.indexOf(n):"*="===t?n&&i.indexOf(n)>-1:"$="===t?n&&i.slice(-n.length)===n:"~="===t?(" "+i.replace($," ")+" ").indexOf(n)>-1:"|="===t&&(i===n||i.slice(0,n.length+1)===n+"-"))}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,u){var l,c,f,p,d,h,g=o!==a?"nextSibling":"previousSibling",y=t.parentNode,v=s&&t.nodeName.toLowerCase(),m=!u&&!s,x=!1;if(y){if(o){while(g){p=t;while(p=p[g])if(s?p.nodeName.toLowerCase()===v:1===p.nodeType)return!1;h=g="only"===e&&!h&&"nextSibling"}return!0}if(h=[a?y.firstChild:y.lastChild],a&&m){x=(d=(l=(c=(f=(p=y)[b]||(p[b]={}))[p.uniqueID]||(f[p.uniqueID]={}))[e]||[])[0]===T&&l[1])&&l[2],p=d&&y.childNodes[d];while(p=++d&&p&&p[g]||(x=d=0)||h.pop())if(1===p.nodeType&&++x&&p===t){c[e]=[T,d,x];break}}else if(m&&(x=d=(l=(c=(f=(p=t)[b]||(p[b]={}))[p.uniqueID]||(f[p.uniqueID]={}))[e]||[])[0]===T&&l[1]),!1===x)while(p=++d&&p&&p[g]||(x=d=0)||h.pop())if((s?p.nodeName.toLowerCase()===v:1===p.nodeType)&&++x&&(m&&((c=(f=p[b]||(p[b]={}))[p.uniqueID]||(f[p.uniqueID]={}))[e]=[T,x]),p===t))break;return(x-=i)===r||x%r==0&&x/r>=0}}},PSEUDO:function(e,t){var n,i=r.pseudos[e]||r.setFilters[e.toLowerCase()]||oe.error("unsupported pseudo: "+e);return i[b]?i(t):i.length>1?(n=[e,e,"",t],r.setFilters.hasOwnProperty(e.toLowerCase())?se(function(e,n){var r,o=i(e,t),a=o.length;while(a--)e[r=O(e,o[a])]=!(n[r]=o[a])}):function(e){return i(e,0,n)}):i}},pseudos:{not:se(function(e){var t=[],n=[],r=s(e.replace(B,"$1"));return r[b]?se(function(e,t,n,i){var o,a=r(e,null,i,[]),s=e.length;while(s--)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,i,o){return t[0]=e,r(t,null,o,n),t[0]=null,!n.pop()}}),has:se(function(e){return function(t){return oe(e,t).length>0}}),contains:se(function(e){return e=e.replace(Z,ee),function(t){return(t.textContent||t.innerText||i(t)).indexOf(e)>-1}}),lang:se(function(e){return U.test(e||"")||oe.error("unsupported lang: "+e),e=e.replace(Z,ee).toLowerCase(),function(t){var n;do{if(n=g?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return(n=n.toLowerCase())===e||0===n.indexOf(e+"-")}while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===h},focus:function(e){return e===d.activeElement&&(!d.hasFocus||d.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:de(!1),disabled:de(!0),checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,!0===e.selected},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!r.pseudos.empty(e)},header:function(e){return Y.test(e.nodeName)},input:function(e){return G.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||"text"===t.toLowerCase())},first:he(function(){return[0]}),last:he(function(e,t){return[t-1]}),eq:he(function(e,t,n){return[n<0?n+t:n]}),even:he(function(e,t){for(var n=0;n=0;)e.push(r);return e}),gt:he(function(e,t,n){for(var r=n<0?n+t:n;++r1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function be(e,t,n){for(var r=0,i=t.length;r-1&&(o[l]=!(a[l]=f))}}else v=we(v===a?v.splice(h,v.length):v),i?i(null,a,v,u):L.apply(a,v)})}function Ce(e){for(var t,n,i,o=e.length,a=r.relative[e[0].type],s=a||r.relative[" "],u=a?1:0,c=me(function(e){return e===t},s,!0),f=me(function(e){return O(t,e)>-1},s,!0),p=[function(e,n,r){var i=!a&&(r||n!==l)||((t=n).nodeType?c(e,n,r):f(e,n,r));return t=null,i}];u1&&xe(p),u>1&&ve(e.slice(0,u-1).concat({value:" "===e[u-2].type?"*":""})).replace(B,"$1"),n,u0,i=e.length>0,o=function(o,a,s,u,c){var f,h,y,v=0,m="0",x=o&&[],b=[],w=l,C=o||i&&r.find.TAG("*",c),E=T+=null==w?1:Math.random()||.1,k=C.length;for(c&&(l=a===d||a||c);m!==k&&null!=(f=C[m]);m++){if(i&&f){h=0,a||f.ownerDocument===d||(p(f),s=!g);while(y=e[h++])if(y(f,a||d,s)){u.push(f);break}c&&(T=E)}n&&((f=!y&&f)&&v--,o&&x.push(f))}if(v+=m,n&&m!==v){h=0;while(y=t[h++])y(x,b,a,s);if(o){if(v>0)while(m--)x[m]||b[m]||(b[m]=j.call(u));b=we(b)}L.apply(u,b),c&&!o&&b.length>0&&v+t.length>1&&oe.uniqueSort(u)}return c&&(T=E,l=w),x};return n?se(o):o}return s=oe.compile=function(e,t){var n,r=[],i=[],o=S[e+" "];if(!o){t||(t=a(e)),n=t.length;while(n--)(o=Ce(t[n]))[b]?r.push(o):i.push(o);(o=S(e,Ee(i,r))).selector=e}return o},u=oe.select=function(e,t,n,i){var o,u,l,c,f,p="function"==typeof e&&e,d=!i&&a(e=p.selector||e);if(n=n||[],1===d.length){if((u=d[0]=d[0].slice(0)).length>2&&"ID"===(l=u[0]).type&&9===t.nodeType&&g&&r.relative[u[1].type]){if(!(t=(r.find.ID(l.matches[0].replace(Z,ee),t)||[])[0]))return n;p&&(t=t.parentNode),e=e.slice(u.shift().value.length)}o=V.needsContext.test(e)?0:u.length;while(o--){if(l=u[o],r.relative[c=l.type])break;if((f=r.find[c])&&(i=f(l.matches[0].replace(Z,ee),K.test(u[0].type)&&ge(t.parentNode)||t))){if(u.splice(o,1),!(e=i.length&&ve(u)))return L.apply(n,i),n;break}}}return(p||s(e,d))(i,t,!g,n,!t||K.test(e)&&ge(t.parentNode)||t),n},n.sortStable=b.split("").sort(D).join("")===b,n.detectDuplicates=!!f,p(),n.sortDetached=ue(function(e){return 1&e.compareDocumentPosition(d.createElement("fieldset"))}),ue(function(e){return e.innerHTML="","#"===e.firstChild.getAttribute("href")})||le("type|href|height|width",function(e,t,n){if(!n)return e.getAttribute(t,"type"===t.toLowerCase()?1:2)}),n.attributes&&ue(function(e){return e.innerHTML="",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")})||le("value",function(e,t,n){if(!n&&"input"===e.nodeName.toLowerCase())return e.defaultValue}),ue(function(e){return null==e.getAttribute("disabled")})||le(P,function(e,t,n){var r;if(!n)return!0===e[t]?t.toLowerCase():(r=e.getAttributeNode(t))&&r.specified?r.value:null}),oe}(e);w.find=E,w.expr=E.selectors,w.expr[":"]=w.expr.pseudos,w.uniqueSort=w.unique=E.uniqueSort,w.text=E.getText,w.isXMLDoc=E.isXML,w.contains=E.contains,w.escapeSelector=E.escape;var k=function(e,t,n){var r=[],i=void 0!==n;while((e=e[t])&&9!==e.nodeType)if(1===e.nodeType){if(i&&w(e).is(n))break;r.push(e)}return r},S=function(e,t){for(var n=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n},D=w.expr.match.needsContext;function N(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()}var A=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function j(e,t,n){return g(t)?w.grep(e,function(e,r){return!!t.call(e,r,e)!==n}):t.nodeType?w.grep(e,function(e){return e===t!==n}):"string"!=typeof t?w.grep(e,function(e){return u.call(t,e)>-1!==n}):w.filter(t,e,n)}w.filter=function(e,t,n){var r=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===r.nodeType?w.find.matchesSelector(r,e)?[r]:[]:w.find.matches(e,w.grep(t,function(e){return 1===e.nodeType}))},w.fn.extend({find:function(e){var t,n,r=this.length,i=this;if("string"!=typeof e)return this.pushStack(w(e).filter(function(){for(t=0;t1?w.uniqueSort(n):n},filter:function(e){return this.pushStack(j(this,e||[],!1))},not:function(e){return this.pushStack(j(this,e||[],!0))},is:function(e){return!!j(this,"string"==typeof e&&D.test(e)?w(e):e||[],!1).length}});var q,L=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/;(w.fn.init=function(e,t,n){var i,o;if(!e)return this;if(n=n||q,"string"==typeof e){if(!(i="<"===e[0]&&">"===e[e.length-1]&&e.length>=3?[null,e,null]:L.exec(e))||!i[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(i[1]){if(t=t instanceof w?t[0]:t,w.merge(this,w.parseHTML(i[1],t&&t.nodeType?t.ownerDocument||t:r,!0)),A.test(i[1])&&w.isPlainObject(t))for(i in t)g(this[i])?this[i](t[i]):this.attr(i,t[i]);return this}return(o=r.getElementById(i[2]))&&(this[0]=o,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):g(e)?void 0!==n.ready?n.ready(e):e(w):w.makeArray(e,this)}).prototype=w.fn,q=w(r);var H=/^(?:parents|prev(?:Until|All))/,O={children:!0,contents:!0,next:!0,prev:!0};w.fn.extend({has:function(e){var t=w(e,this),n=t.length;return this.filter(function(){for(var e=0;e-1:1===n.nodeType&&w.find.matchesSelector(n,e))){o.push(n);break}return this.pushStack(o.length>1?w.uniqueSort(o):o)},index:function(e){return e?"string"==typeof e?u.call(w(e),this[0]):u.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){return this.pushStack(w.uniqueSort(w.merge(this.get(),w(e,t))))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}});function P(e,t){while((e=e[t])&&1!==e.nodeType);return e}w.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return k(e,"parentNode")},parentsUntil:function(e,t,n){return k(e,"parentNode",n)},next:function(e){return P(e,"nextSibling")},prev:function(e){return P(e,"previousSibling")},nextAll:function(e){return k(e,"nextSibling")},prevAll:function(e){return k(e,"previousSibling")},nextUntil:function(e,t,n){return k(e,"nextSibling",n)},prevUntil:function(e,t,n){return k(e,"previousSibling",n)},siblings:function(e){return S((e.parentNode||{}).firstChild,e)},children:function(e){return S(e.firstChild)},contents:function(e){return N(e,"iframe")?e.contentDocument:(N(e,"template")&&(e=e.content||e),w.merge([],e.childNodes))}},function(e,t){w.fn[e]=function(n,r){var i=w.map(this,t,n);return"Until"!==e.slice(-5)&&(r=n),r&&"string"==typeof r&&(i=w.filter(r,i)),this.length>1&&(O[e]||w.uniqueSort(i),H.test(e)&&i.reverse()),this.pushStack(i)}});var M=/[^\x20\t\r\n\f]+/g;function R(e){var t={};return w.each(e.match(M)||[],function(e,n){t[n]=!0}),t}w.Callbacks=function(e){e="string"==typeof e?R(e):w.extend({},e);var t,n,r,i,o=[],a=[],s=-1,u=function(){for(i=i||e.once,r=t=!0;a.length;s=-1){n=a.shift();while(++s-1)o.splice(n,1),n<=s&&s--}),this},has:function(e){return e?w.inArray(e,o)>-1:o.length>0},empty:function(){return o&&(o=[]),this},disable:function(){return i=a=[],o=n="",this},disabled:function(){return!o},lock:function(){return i=a=[],n||t||(o=n=""),this},locked:function(){return!!i},fireWith:function(e,n){return i||(n=[e,(n=n||[]).slice?n.slice():n],a.push(n),t||u()),this},fire:function(){return l.fireWith(this,arguments),this},fired:function(){return!!r}};return l};function I(e){return e}function W(e){throw e}function $(e,t,n,r){var i;try{e&&g(i=e.promise)?i.call(e).done(t).fail(n):e&&g(i=e.then)?i.call(e,t,n):t.apply(void 0,[e].slice(r))}catch(e){n.apply(void 0,[e])}}w.extend({Deferred:function(t){var n=[["notify","progress",w.Callbacks("memory"),w.Callbacks("memory"),2],["resolve","done",w.Callbacks("once memory"),w.Callbacks("once memory"),0,"resolved"],["reject","fail",w.Callbacks("once memory"),w.Callbacks("once memory"),1,"rejected"]],r="pending",i={state:function(){return r},always:function(){return o.done(arguments).fail(arguments),this},"catch":function(e){return i.then(null,e)},pipe:function(){var e=arguments;return w.Deferred(function(t){w.each(n,function(n,r){var i=g(e[r[4]])&&e[r[4]];o[r[1]](function(){var e=i&&i.apply(this,arguments);e&&g(e.promise)?e.promise().progress(t.notify).done(t.resolve).fail(t.reject):t[r[0]+"With"](this,i?[e]:arguments)})}),e=null}).promise()},then:function(t,r,i){var o=0;function a(t,n,r,i){return function(){var s=this,u=arguments,l=function(){var e,l;if(!(t=o&&(r!==W&&(s=void 0,u=[e]),n.rejectWith(s,u))}};t?c():(w.Deferred.getStackHook&&(c.stackTrace=w.Deferred.getStackHook()),e.setTimeout(c))}}return w.Deferred(function(e){n[0][3].add(a(0,e,g(i)?i:I,e.notifyWith)),n[1][3].add(a(0,e,g(t)?t:I)),n[2][3].add(a(0,e,g(r)?r:W))}).promise()},promise:function(e){return null!=e?w.extend(e,i):i}},o={};return w.each(n,function(e,t){var a=t[2],s=t[5];i[t[1]]=a.add,s&&a.add(function(){r=s},n[3-e][2].disable,n[3-e][3].disable,n[0][2].lock,n[0][3].lock),a.add(t[3].fire),o[t[0]]=function(){return o[t[0]+"With"](this===o?void 0:this,arguments),this},o[t[0]+"With"]=a.fireWith}),i.promise(o),t&&t.call(o,o),o},when:function(e){var t=arguments.length,n=t,r=Array(n),i=o.call(arguments),a=w.Deferred(),s=function(e){return function(n){r[e]=this,i[e]=arguments.length>1?o.call(arguments):n,--t||a.resolveWith(r,i)}};if(t<=1&&($(e,a.done(s(n)).resolve,a.reject,!t),"pending"===a.state()||g(i[n]&&i[n].then)))return a.then();while(n--)$(i[n],s(n),a.reject);return a.promise()}});var B=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;w.Deferred.exceptionHook=function(t,n){e.console&&e.console.warn&&t&&B.test(t.name)&&e.console.warn("jQuery.Deferred exception: "+t.message,t.stack,n)},w.readyException=function(t){e.setTimeout(function(){throw t})};var F=w.Deferred();w.fn.ready=function(e){return F.then(e)["catch"](function(e){w.readyException(e)}),this},w.extend({isReady:!1,readyWait:1,ready:function(e){(!0===e?--w.readyWait:w.isReady)||(w.isReady=!0,!0!==e&&--w.readyWait>0||F.resolveWith(r,[w]))}}),w.ready.then=F.then;function _(){r.removeEventListener("DOMContentLoaded",_),e.removeEventListener("load",_),w.ready()}"complete"===r.readyState||"loading"!==r.readyState&&!r.documentElement.doScroll?e.setTimeout(w.ready):(r.addEventListener("DOMContentLoaded",_),e.addEventListener("load",_));var z=function(e,t,n,r,i,o,a){var s=0,u=e.length,l=null==n;if("object"===x(n)){i=!0;for(s in n)z(e,t,s,n[s],!0,o,a)}else if(void 0!==r&&(i=!0,g(r)||(a=!0),l&&(a?(t.call(e,r),t=null):(l=t,t=function(e,t,n){return l.call(w(e),n)})),t))for(;s1,null,!0)},removeData:function(e){return this.each(function(){K.remove(this,e)})}}),w.extend({queue:function(e,t,n){var r;if(e)return t=(t||"fx")+"queue",r=J.get(e,t),n&&(!r||Array.isArray(n)?r=J.access(e,t,w.makeArray(n)):r.push(n)),r||[]},dequeue:function(e,t){t=t||"fx";var n=w.queue(e,t),r=n.length,i=n.shift(),o=w._queueHooks(e,t),a=function(){w.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return J.get(e,n)||J.access(e,n,{empty:w.Callbacks("once memory").add(function(){J.remove(e,[t+"queue",n])})})}}),w.fn.extend({queue:function(e,t){var n=2;return"string"!=typeof e&&(t=e,e="fx",n--),arguments.length\x20\t\r\n\f]+)/i,he=/^$|^module$|\/(?:java|ecma)script/i,ge={option:[1,""],thead:[1,""],col:[2,""],tr:[2,""],td:[3,""],_default:[0,"",""]};ge.optgroup=ge.option,ge.tbody=ge.tfoot=ge.colgroup=ge.caption=ge.thead,ge.th=ge.td;function ye(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&N(e,t)?w.merge([e],n):n}function ve(e,t){for(var n=0,r=e.length;n-1)i&&i.push(o);else if(l=w.contains(o.ownerDocument,o),a=ye(f.appendChild(o),"script"),l&&ve(a),n){c=0;while(o=a[c++])he.test(o.type||"")&&n.push(o)}return f}!function(){var e=r.createDocumentFragment().appendChild(r.createElement("div")),t=r.createElement("input");t.setAttribute("type","radio"),t.setAttribute("checked","checked"),t.setAttribute("name","t"),e.appendChild(t),h.checkClone=e.cloneNode(!0).cloneNode(!0).lastChild.checked,e.innerHTML="",h.noCloneChecked=!!e.cloneNode(!0).lastChild.defaultValue}();var be=r.documentElement,we=/^key/,Te=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,Ce=/^([^.]*)(?:\.(.+)|)/;function Ee(){return!0}function ke(){return!1}function Se(){try{return r.activeElement}catch(e){}}function De(e,t,n,r,i,o){var a,s;if("object"==typeof t){"string"!=typeof n&&(r=r||n,n=void 0);for(s in t)De(e,s,n,r,t[s],o);return e}if(null==r&&null==i?(i=n,r=n=void 0):null==i&&("string"==typeof n?(i=r,r=void 0):(i=r,r=n,n=void 0)),!1===i)i=ke;else if(!i)return e;return 1===o&&(a=i,(i=function(e){return w().off(e),a.apply(this,arguments)}).guid=a.guid||(a.guid=w.guid++)),e.each(function(){w.event.add(this,t,i,r,n)})}w.event={global:{},add:function(e,t,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,y=J.get(e);if(y){n.handler&&(n=(o=n).handler,i=o.selector),i&&w.find.matchesSelector(be,i),n.guid||(n.guid=w.guid++),(u=y.events)||(u=y.events={}),(a=y.handle)||(a=y.handle=function(t){return"undefined"!=typeof w&&w.event.triggered!==t.type?w.event.dispatch.apply(e,arguments):void 0}),l=(t=(t||"").match(M)||[""]).length;while(l--)d=g=(s=Ce.exec(t[l])||[])[1],h=(s[2]||"").split(".").sort(),d&&(f=w.event.special[d]||{},d=(i?f.delegateType:f.bindType)||d,f=w.event.special[d]||{},c=w.extend({type:d,origType:g,data:r,handler:n,guid:n.guid,selector:i,needsContext:i&&w.expr.match.needsContext.test(i),namespace:h.join(".")},o),(p=u[d])||((p=u[d]=[]).delegateCount=0,f.setup&&!1!==f.setup.call(e,r,h,a)||e.addEventListener&&e.addEventListener(d,a)),f.add&&(f.add.call(e,c),c.handler.guid||(c.handler.guid=n.guid)),i?p.splice(p.delegateCount++,0,c):p.push(c),w.event.global[d]=!0)}},remove:function(e,t,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,y=J.hasData(e)&&J.get(e);if(y&&(u=y.events)){l=(t=(t||"").match(M)||[""]).length;while(l--)if(s=Ce.exec(t[l])||[],d=g=s[1],h=(s[2]||"").split(".").sort(),d){f=w.event.special[d]||{},p=u[d=(r?f.delegateType:f.bindType)||d]||[],s=s[2]&&new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),a=o=p.length;while(o--)c=p[o],!i&&g!==c.origType||n&&n.guid!==c.guid||s&&!s.test(c.namespace)||r&&r!==c.selector&&("**"!==r||!c.selector)||(p.splice(o,1),c.selector&&p.delegateCount--,f.remove&&f.remove.call(e,c));a&&!p.length&&(f.teardown&&!1!==f.teardown.call(e,h,y.handle)||w.removeEvent(e,d,y.handle),delete u[d])}else for(d in u)w.event.remove(e,d+t[l],n,r,!0);w.isEmptyObject(u)&&J.remove(e,"handle events")}},dispatch:function(e){var t=w.event.fix(e),n,r,i,o,a,s,u=new Array(arguments.length),l=(J.get(this,"events")||{})[t.type]||[],c=w.event.special[t.type]||{};for(u[0]=t,n=1;n=1))for(;l!==this;l=l.parentNode||this)if(1===l.nodeType&&("click"!==e.type||!0!==l.disabled)){for(o=[],a={},n=0;n-1:w.find(i,this,null,[l]).length),a[i]&&o.push(r);o.length&&s.push({elem:l,handlers:o})}return l=this,u\x20\t\r\n\f]*)[^>]*)\/>/gi,Ae=/
12 |
13 |
14 |
15 |
16 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
30 |
31 |
32 |
37 |
38 |
39 |
105 |
248 |
249 |