4 <meta charset=
"utf-8" />
5 <title>BIP39 - Mnemonic Code
</title>
8 * Bootstrap v3.2
.0 (http://getbootstrap.com)
9 * Copyright
2011-
2014 Twitter, Inc.
10 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
13 /*! normalize.css v3.0
.1 | MIT License | git.io/normalize */
15 font-family: sans-serif;
16 -webkit-text-size-adjust:
100%;
17 -ms-text-size-adjust:
100%;
40 display: inline-block;
41 vertical-align: baseline;
43 audio:not([controls]) {
52 background: transparent;
59 border-bottom:
1px dotted;
84 vertical-align: baseline;
103 -webkit-box-sizing: content-box;
104 -moz-box-sizing: content-box;
105 box-sizing: content-box;
114 font-family: monospace, monospace;
131 text-transform: none;
134 html input[
type="button"],
136 input[
type="submit"] {
137 -webkit-appearance: button;
141 html input[disabled] {
144 button::-moz-focus-inner,
145 input::-moz-focus-inner {
152 input[
type="checkbox"],
153 input[
type="radio"] {
154 -webkit-box-sizing: border-box;
155 -moz-box-sizing: border-box;
156 box-sizing: border-box;
159 input[
type="number"]::-webkit-inner-spin-button,
160 input[
type="number"]::-webkit-outer-spin-button {
163 input[
type="search"] {
164 -webkit-box-sizing: content-box;
165 -moz-box-sizing: content-box;
166 box-sizing: content-box;
167 -webkit-appearance: textfield;
169 input[
type="search"]::-webkit-search-cancel-button,
170 input[
type="search"]::-webkit-search-decoration {
171 -webkit-appearance: none;
174 padding:
.35em
.625em
.75em;
176 border:
1px solid #c0c0c0;
190 border-collapse: collapse;
198 color: #
000 !important;
199 text-shadow: none !important;
200 background: transparent !important;
201 -webkit-box-shadow: none !important;
202 box-shadow: none !important;
206 text-decoration: underline;
209 content: " (" attr(href) ")";
212 content: " (" attr(title) ")";
214 a[href^="javascript:"]:after,
220 border:
1px solid #
999;
222 page-break-inside: avoid;
225 display: table-header-group;
229 page-break-inside: avoid;
232 max-width:
100% !important;
242 page-break-after: avoid;
245 background: #fff !important;
252 background-color: #fff !important;
255 .dropup
> .btn
> .caret {
256 border-top-color: #
000 !important;
259 border:
1px solid #
000;
262 border-collapse: collapse !important;
266 border:
1px solid #ddd !important;
270 font-family: 'Glyphicons Halflings';
272 src: url('../fonts/glyphicons-halflings-regular.eot');
273 src: url('../fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('../fonts/glyphicons-halflings-regular.woff') format('woff'), url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
278 display: inline-block;
279 font-family: 'Glyphicons Halflings';
284 -webkit-font-smoothing: antialiased;
285 -moz-osx-font-smoothing: grayscale;
287 .glyphicon-asterisk:before {
290 .glyphicon-plus:before {
293 .glyphicon-euro:before {
296 .glyphicon-minus:before {
299 .glyphicon-cloud:before {
302 .glyphicon-envelope:before {
305 .glyphicon-pencil:before {
308 .glyphicon-glass:before {
311 .glyphicon-music:before {
314 .glyphicon-search:before {
317 .glyphicon-heart:before {
320 .glyphicon-star:before {
323 .glyphicon-star-empty:before {
326 .glyphicon-user:before {
329 .glyphicon-film:before {
332 .glyphicon-th-large:before {
335 .glyphicon-th:before {
338 .glyphicon-th-list:before {
341 .glyphicon-ok:before {
344 .glyphicon-remove:before {
347 .glyphicon-zoom-in:before {
350 .glyphicon-zoom-out:before {
353 .glyphicon-off:before {
356 .glyphicon-signal:before {
359 .glyphicon-cog:before {
362 .glyphicon-trash:before {
365 .glyphicon-home:before {
368 .glyphicon-file:before {
371 .glyphicon-time:before {
374 .glyphicon-road:before {
377 .glyphicon-download-alt:before {
380 .glyphicon-download:before {
383 .glyphicon-upload:before {
386 .glyphicon-inbox:before {
389 .glyphicon-play-circle:before {
392 .glyphicon-repeat:before {
395 .glyphicon-refresh:before {
398 .glyphicon-list-alt:before {
401 .glyphicon-lock:before {
404 .glyphicon-flag:before {
407 .glyphicon-headphones:before {
410 .glyphicon-volume-off:before {
413 .glyphicon-volume-down:before {
416 .glyphicon-volume-up:before {
419 .glyphicon-qrcode:before {
422 .glyphicon-barcode:before {
425 .glyphicon-tag:before {
428 .glyphicon-tags:before {
431 .glyphicon-book:before {
434 .glyphicon-bookmark:before {
437 .glyphicon-print:before {
440 .glyphicon-camera:before {
443 .glyphicon-font:before {
446 .glyphicon-bold:before {
449 .glyphicon-italic:before {
452 .glyphicon-text-height:before {
455 .glyphicon-text-width:before {
458 .glyphicon-align-left:before {
461 .glyphicon-align-center:before {
464 .glyphicon-align-right:before {
467 .glyphicon-align-justify:before {
470 .glyphicon-list:before {
473 .glyphicon-indent-left:before {
476 .glyphicon-indent-right:before {
479 .glyphicon-facetime-video:before {
482 .glyphicon-picture:before {
485 .glyphicon-map-marker:before {
488 .glyphicon-adjust:before {
491 .glyphicon-tint:before {
494 .glyphicon-edit:before {
497 .glyphicon-share:before {
500 .glyphicon-check:before {
503 .glyphicon-move:before {
506 .glyphicon-step-backward:before {
509 .glyphicon-fast-backward:before {
512 .glyphicon-backward:before {
515 .glyphicon-play:before {
518 .glyphicon-pause:before {
521 .glyphicon-stop:before {
524 .glyphicon-forward:before {
527 .glyphicon-fast-forward:before {
530 .glyphicon-step-forward:before {
533 .glyphicon-eject:before {
536 .glyphicon-chevron-left:before {
539 .glyphicon-chevron-right:before {
542 .glyphicon-plus-sign:before {
545 .glyphicon-minus-sign:before {
548 .glyphicon-remove-sign:before {
551 .glyphicon-ok-sign:before {
554 .glyphicon-question-sign:before {
557 .glyphicon-info-sign:before {
560 .glyphicon-screenshot:before {
563 .glyphicon-remove-circle:before {
566 .glyphicon-ok-circle:before {
569 .glyphicon-ban-circle:before {
572 .glyphicon-arrow-left:before {
575 .glyphicon-arrow-right:before {
578 .glyphicon-arrow-up:before {
581 .glyphicon-arrow-down:before {
584 .glyphicon-share-alt:before {
587 .glyphicon-resize-full:before {
590 .glyphicon-resize-small:before {
593 .glyphicon-exclamation-sign:before {
596 .glyphicon-gift:before {
599 .glyphicon-leaf:before {
602 .glyphicon-fire:before {
605 .glyphicon-eye-open:before {
608 .glyphicon-eye-close:before {
611 .glyphicon-warning-sign:before {
614 .glyphicon-plane:before {
617 .glyphicon-calendar:before {
620 .glyphicon-random:before {
623 .glyphicon-comment:before {
626 .glyphicon-magnet:before {
629 .glyphicon-chevron-up:before {
632 .glyphicon-chevron-down:before {
635 .glyphicon-retweet:before {
638 .glyphicon-shopping-cart:before {
641 .glyphicon-folder-close:before {
644 .glyphicon-folder-open:before {
647 .glyphicon-resize-vertical:before {
650 .glyphicon-resize-horizontal:before {
653 .glyphicon-hdd:before {
656 .glyphicon-bullhorn:before {
659 .glyphicon-bell:before {
662 .glyphicon-certificate:before {
665 .glyphicon-thumbs-up:before {
668 .glyphicon-thumbs-down:before {
671 .glyphicon-hand-right:before {
674 .glyphicon-hand-left:before {
677 .glyphicon-hand-up:before {
680 .glyphicon-hand-down:before {
683 .glyphicon-circle-arrow-right:before {
686 .glyphicon-circle-arrow-left:before {
689 .glyphicon-circle-arrow-up:before {
692 .glyphicon-circle-arrow-down:before {
695 .glyphicon-globe:before {
698 .glyphicon-wrench:before {
701 .glyphicon-tasks:before {
704 .glyphicon-filter:before {
707 .glyphicon-briefcase:before {
710 .glyphicon-fullscreen:before {
713 .glyphicon-dashboard:before {
716 .glyphicon-paperclip:before {
719 .glyphicon-heart-empty:before {
722 .glyphicon-link:before {
725 .glyphicon-phone:before {
728 .glyphicon-pushpin:before {
731 .glyphicon-usd:before {
734 .glyphicon-gbp:before {
737 .glyphicon-sort:before {
740 .glyphicon-sort-by-alphabet:before {
743 .glyphicon-sort-by-alphabet-alt:before {
746 .glyphicon-sort-by-order:before {
749 .glyphicon-sort-by-order-alt:before {
752 .glyphicon-sort-by-attributes:before {
755 .glyphicon-sort-by-attributes-alt:before {
758 .glyphicon-unchecked:before {
761 .glyphicon-expand:before {
764 .glyphicon-collapse-down:before {
767 .glyphicon-collapse-up:before {
770 .glyphicon-log-in:before {
773 .glyphicon-flash:before {
776 .glyphicon-log-out:before {
779 .glyphicon-new-window:before {
782 .glyphicon-record:before {
785 .glyphicon-save:before {
788 .glyphicon-open:before {
791 .glyphicon-saved:before {
794 .glyphicon-import:before {
797 .glyphicon-export:before {
800 .glyphicon-send:before {
803 .glyphicon-floppy-disk:before {
806 .glyphicon-floppy-saved:before {
809 .glyphicon-floppy-remove:before {
812 .glyphicon-floppy-save:before {
815 .glyphicon-floppy-open:before {
818 .glyphicon-credit-card:before {
821 .glyphicon-transfer:before {
824 .glyphicon-cutlery:before {
827 .glyphicon-header:before {
830 .glyphicon-compressed:before {
833 .glyphicon-earphone:before {
836 .glyphicon-phone-alt:before {
839 .glyphicon-tower:before {
842 .glyphicon-stats:before {
845 .glyphicon-sd-video:before {
848 .glyphicon-hd-video:before {
851 .glyphicon-subtitles:before {
854 .glyphicon-sound-stereo:before {
857 .glyphicon-sound-dolby:before {
860 .glyphicon-sound-
5-
1:before {
863 .glyphicon-sound-
6-
1:before {
866 .glyphicon-sound-
7-
1:before {
869 .glyphicon-copyright-mark:before {
872 .glyphicon-registration-mark:before {
875 .glyphicon-cloud-download:before {
878 .glyphicon-cloud-upload:before {
881 .glyphicon-tree-conifer:before {
884 .glyphicon-tree-deciduous:before {
888 -webkit-box-sizing: border-box;
889 -moz-box-sizing: border-box;
890 box-sizing: border-box;
894 -webkit-box-sizing: border-box;
895 -moz-box-sizing: border-box;
896 box-sizing: border-box;
901 -webkit-tap-highlight-color: rgba(
0,
0,
0,
0);
904 font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
906 line-height:
1.42857143;
908 background-color: #fff;
914 font-family: inherit;
916 line-height: inherit;
920 text-decoration: none;
925 text-decoration: underline;
928 outline: thin dotted;
929 outline:
5px auto -webkit-focus-ring-color;
930 outline-offset: -
2px;
936 vertical-align: middle;
941 .carousel-inner
> .item
> img,
942 .carousel-inner
> .item
> a
> img {
952 display: inline-block;
957 line-height:
1.42857143;
958 background-color: #fff;
959 border:
1px solid #ddd;
961 -webkit-transition: all
.2s ease-in-out;
962 -o-transition: all
.2s ease-in-out;
963 transition: all
.2s ease-in-out;
972 border-top:
1px solid #eee;
981 clip: rect(
0,
0,
0,
0);
984 .sr-only-focusable:active,
985 .sr-only-focusable:focus {
1005 font-family: inherit;
1034 font-weight: normal;
1045 margin-bottom:
10px;
1068 margin-bottom:
10px;
1112 margin-bottom:
20px;
1117 @media (min-width:
768px) {
1132 background-color: #fcf8e3;
1144 text-align: justify;
1147 white-space: nowrap;
1150 text-transform: lowercase;
1153 text-transform: uppercase;
1156 text-transform: capitalize;
1164 a.text-primary:hover {
1170 a.text-success:hover {
1182 a.text-warning:hover {
1188 a.text-danger:hover {
1193 background-color: #
428bca;
1195 a.bg-primary:hover {
1196 background-color: #
3071a9;
1199 background-color: #dff0d8;
1201 a.bg-success:hover {
1202 background-color: #c1e2b3;
1205 background-color: #d9edf7;
1208 background-color: #afd9ee;
1211 background-color: #fcf8e3;
1213 a.bg-warning:hover {
1214 background-color: #f7ecb5;
1217 background-color: #f2dede;
1220 background-color: #e4b9b9;
1223 padding-bottom:
9px;
1224 margin:
40px
0 20px;
1225 border-bottom:
1px solid #eee;
1230 margin-bottom:
10px;
1248 display: inline-block;
1254 margin-bottom:
20px;
1258 line-height:
1.42857143;
1266 @media (min-width:
768px) {
1273 text-overflow: ellipsis;
1274 white-space: nowrap;
1281 abbr[data-original-title] {
1283 border-bottom:
1px dotted #
777;
1287 text-transform: uppercase;
1293 border-left:
5px solid #eee;
1295 blockquote p:last-child,
1296 blockquote ul:last-child,
1297 blockquote ol:last-child {
1305 line-height:
1.42857143;
1308 blockquote footer:before,
1309 blockquote small:before,
1310 blockquote .small:before {
1311 content: '\
2014 \
00A0';
1313 .blockquote-reverse,
1314 blockquote.pull-right {
1315 padding-right:
15px;
1318 border-right:
5px solid #eee;
1321 .blockquote-reverse footer:before,
1322 blockquote.pull-right footer:before,
1323 .blockquote-reverse small:before,
1324 blockquote.pull-right small:before,
1325 .blockquote-reverse .small:before,
1326 blockquote.pull-right .small:before {
1329 .blockquote-reverse footer:after,
1330 blockquote.pull-right footer:after,
1331 .blockquote-reverse small:after,
1332 blockquote.pull-right small:after,
1333 .blockquote-reverse .small:after,
1334 blockquote.pull-right .small:after {
1335 content: '\
00A0 \
2014';
1342 margin-bottom:
20px;
1344 line-height:
1.42857143;
1350 font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
1356 background-color: #f9f2f4;
1363 background-color: #
333;
1365 -webkit-box-shadow: inset
0 -
1px
0 rgba(
0,
0,
0,
.25);
1366 box-shadow: inset
0 -
1px
0 rgba(
0,
0,
0,
.25);
1371 -webkit-box-shadow: none;
1379 line-height:
1.42857143;
1381 word-break: break-all;
1382 word-wrap: break-word;
1383 background-color: #f5f5f5;
1384 border:
1px solid #ccc;
1391 white-space: pre-wrap;
1392 background-color: transparent;
1400 padding-right:
15px;
1405 @media (min-width:
768px) {
1410 @media (min-width:
992px) {
1415 @media (min-width:
1200px) {
1421 padding-right:
15px;
1427 margin-right: -
15px;
1430 .col-xs-
1, .col-sm-
1, .col-md-
1, .col-lg-
1, .col-xs-
2, .col-sm-
2, .col-md-
2, .col-lg-
2, .col-xs-
3, .col-sm-
3, .col-md-
3, .col-lg-
3, .col-xs-
4, .col-sm-
4, .col-md-
4, .col-lg-
4, .col-xs-
5, .col-sm-
5, .col-md-
5, .col-lg-
5, .col-xs-
6, .col-sm-
6, .col-md-
6, .col-lg-
6, .col-xs-
7, .col-sm-
7, .col-md-
7, .col-lg-
7, .col-xs-
8, .col-sm-
8, .col-md-
8, .col-lg-
8, .col-xs-
9, .col-sm-
9, .col-md-
9, .col-lg-
9, .col-xs-
10, .col-sm-
10, .col-md-
10, .col-lg-
10, .col-xs-
11, .col-sm-
11, .col-md-
11, .col-lg-
11, .col-xs-
12, .col-sm-
12, .col-md-
12, .col-lg-
12 {
1433 padding-right:
15px;
1436 .col-xs-
1, .col-xs-
2, .col-xs-
3, .col-xs-
4, .col-xs-
5, .col-xs-
6, .col-xs-
7, .col-xs-
8, .col-xs-
9, .col-xs-
10, .col-xs-
11, .col-xs-
12 {
1443 width:
91.66666667%;
1446 width:
83.33333333%;
1452 width:
66.66666667%;
1455 width:
58.33333333%;
1461 width:
41.66666667%;
1464 width:
33.33333333%;
1470 width:
16.66666667%;
1479 right:
91.66666667%;
1482 right:
83.33333333%;
1488 right:
66.66666667%;
1491 right:
58.33333333%;
1497 right:
41.66666667%;
1500 right:
33.33333333%;
1506 right:
16.66666667%;
1557 margin-left:
91.66666667%;
1560 margin-left:
83.33333333%;
1566 margin-left:
66.66666667%;
1569 margin-left:
58.33333333%;
1575 margin-left:
41.66666667%;
1578 margin-left:
33.33333333%;
1584 margin-left:
16.66666667%;
1587 margin-left:
8.33333333%;
1592 @media (min-width:
768px) {
1593 .col-sm-
1, .col-sm-
2, .col-sm-
3, .col-sm-
4, .col-sm-
5, .col-sm-
6, .col-sm-
7, .col-sm-
8, .col-sm-
9, .col-sm-
10, .col-sm-
11, .col-sm-
12 {
1600 width:
91.66666667%;
1603 width:
83.33333333%;
1609 width:
66.66666667%;
1612 width:
58.33333333%;
1618 width:
41.66666667%;
1621 width:
33.33333333%;
1627 width:
16.66666667%;
1636 right:
91.66666667%;
1639 right:
83.33333333%;
1645 right:
66.66666667%;
1648 right:
58.33333333%;
1654 right:
41.66666667%;
1657 right:
33.33333333%;
1663 right:
16.66666667%;
1714 margin-left:
91.66666667%;
1717 margin-left:
83.33333333%;
1723 margin-left:
66.66666667%;
1726 margin-left:
58.33333333%;
1732 margin-left:
41.66666667%;
1735 margin-left:
33.33333333%;
1741 margin-left:
16.66666667%;
1744 margin-left:
8.33333333%;
1750 @media (min-width:
992px) {
1751 .col-md-
1, .col-md-
2, .col-md-
3, .col-md-
4, .col-md-
5, .col-md-
6, .col-md-
7, .col-md-
8, .col-md-
9, .col-md-
10, .col-md-
11, .col-md-
12 {
1758 width:
91.66666667%;
1761 width:
83.33333333%;
1767 width:
66.66666667%;
1770 width:
58.33333333%;
1776 width:
41.66666667%;
1779 width:
33.33333333%;
1785 width:
16.66666667%;
1794 right:
91.66666667%;
1797 right:
83.33333333%;
1803 right:
66.66666667%;
1806 right:
58.33333333%;
1812 right:
41.66666667%;
1815 right:
33.33333333%;
1821 right:
16.66666667%;
1872 margin-left:
91.66666667%;
1875 margin-left:
83.33333333%;
1881 margin-left:
66.66666667%;
1884 margin-left:
58.33333333%;
1890 margin-left:
41.66666667%;
1893 margin-left:
33.33333333%;
1899 margin-left:
16.66666667%;
1902 margin-left:
8.33333333%;
1908 @media (min-width:
1200px) {
1909 .col-lg-
1, .col-lg-
2, .col-lg-
3, .col-lg-
4, .col-lg-
5, .col-lg-
6, .col-lg-
7, .col-lg-
8, .col-lg-
9, .col-lg-
10, .col-lg-
11, .col-lg-
12 {
1916 width:
91.66666667%;
1919 width:
83.33333333%;
1925 width:
66.66666667%;
1928 width:
58.33333333%;
1934 width:
41.66666667%;
1937 width:
33.33333333%;
1943 width:
16.66666667%;
1952 right:
91.66666667%;
1955 right:
83.33333333%;
1961 right:
66.66666667%;
1964 right:
58.33333333%;
1970 right:
41.66666667%;
1973 right:
33.33333333%;
1979 right:
16.66666667%;
2030 margin-left:
91.66666667%;
2033 margin-left:
83.33333333%;
2039 margin-left:
66.66666667%;
2042 margin-left:
58.33333333%;
2048 margin-left:
41.66666667%;
2051 margin-left:
33.33333333%;
2057 margin-left:
16.66666667%;
2060 margin-left:
8.33333333%;
2067 background-color: transparent;
2075 margin-bottom:
20px;
2077 .table
> thead
> tr
> th,
2078 .table
> tbody
> tr
> th,
2079 .table
> tfoot
> tr
> th,
2080 .table
> thead
> tr
> td,
2081 .table
> tbody
> tr
> td,
2082 .table
> tfoot
> tr
> td {
2084 line-height:
1.42857143;
2085 vertical-align: top;
2086 border-top:
1px solid #ddd;
2088 .table
> thead
> tr
> th {
2089 vertical-align: bottom;
2090 border-bottom:
2px solid #ddd;
2092 .table
> caption + thead
> tr:first-child
> th,
2093 .table
> colgroup + thead
> tr:first-child
> th,
2094 .table
> thead:first-child
> tr:first-child
> th,
2095 .table
> caption + thead
> tr:first-child
> td,
2096 .table
> colgroup + thead
> tr:first-child
> td,
2097 .table
> thead:first-child
> tr:first-child
> td {
2100 .table
> tbody + tbody {
2101 border-top:
2px solid #ddd;
2104 background-color: #fff;
2106 .table-condensed
> thead
> tr
> th,
2107 .table-condensed
> tbody
> tr
> th,
2108 .table-condensed
> tfoot
> tr
> th,
2109 .table-condensed
> thead
> tr
> td,
2110 .table-condensed
> tbody
> tr
> td,
2111 .table-condensed
> tfoot
> tr
> td {
2115 border:
1px solid #ddd;
2117 .table-bordered
> thead
> tr
> th,
2118 .table-bordered
> tbody
> tr
> th,
2119 .table-bordered
> tfoot
> tr
> th,
2120 .table-bordered
> thead
> tr
> td,
2121 .table-bordered
> tbody
> tr
> td,
2122 .table-bordered
> tfoot
> tr
> td {
2123 border:
1px solid #ddd;
2125 .table-bordered
> thead
> tr
> th,
2126 .table-bordered
> thead
> tr
> td {
2127 border-bottom-width:
2px;
2129 .table-striped
> tbody
> tr:nth-child(odd)
> td,
2130 .table-striped
> tbody
> tr:nth-child(odd)
> th {
2131 background-color: #f9f9f9;
2133 .table-hover
> tbody
> tr:hover
> td,
2134 .table-hover
> tbody
> tr:hover
> th {
2135 background-color: #f5f5f5;
2137 table col[class*="col-"] {
2139 display: table-column;
2142 table td[class*="col-"],
2143 table th[class*="col-"] {
2145 display: table-cell;
2148 .table
> thead
> tr
> td.active,
2149 .table
> tbody
> tr
> td.active,
2150 .table
> tfoot
> tr
> td.active,
2151 .table
> thead
> tr
> th.active,
2152 .table
> tbody
> tr
> th.active,
2153 .table
> tfoot
> tr
> th.active,
2154 .table
> thead
> tr.active
> td,
2155 .table
> tbody
> tr.active
> td,
2156 .table
> tfoot
> tr.active
> td,
2157 .table
> thead
> tr.active
> th,
2158 .table
> tbody
> tr.active
> th,
2159 .table
> tfoot
> tr.active
> th {
2160 background-color: #f5f5f5;
2162 .table-hover
> tbody
> tr
> td.active:hover,
2163 .table-hover
> tbody
> tr
> th.active:hover,
2164 .table-hover
> tbody
> tr.active:hover
> td,
2165 .table-hover
> tbody
> tr:hover
> .active,
2166 .table-hover
> tbody
> tr.active:hover
> th {
2167 background-color: #e8e8e8;
2169 .table
> thead
> tr
> td.success,
2170 .table
> tbody
> tr
> td.success,
2171 .table
> tfoot
> tr
> td.success,
2172 .table
> thead
> tr
> th.success,
2173 .table
> tbody
> tr
> th.success,
2174 .table
> tfoot
> tr
> th.success,
2175 .table
> thead
> tr.success
> td,
2176 .table
> tbody
> tr.success
> td,
2177 .table
> tfoot
> tr.success
> td,
2178 .table
> thead
> tr.success
> th,
2179 .table
> tbody
> tr.success
> th,
2180 .table
> tfoot
> tr.success
> th {
2181 background-color: #dff0d8;
2183 .table-hover
> tbody
> tr
> td.success:hover,
2184 .table-hover
> tbody
> tr
> th.success:hover,
2185 .table-hover
> tbody
> tr.success:hover
> td,
2186 .table-hover
> tbody
> tr:hover
> .success,
2187 .table-hover
> tbody
> tr.success:hover
> th {
2188 background-color: #d0e9c6;
2190 .table
> thead
> tr
> td.info,
2191 .table
> tbody
> tr
> td.info,
2192 .table
> tfoot
> tr
> td.info,
2193 .table
> thead
> tr
> th.info,
2194 .table
> tbody
> tr
> th.info,
2195 .table
> tfoot
> tr
> th.info,
2196 .table
> thead
> tr.info
> td,
2197 .table
> tbody
> tr.info
> td,
2198 .table
> tfoot
> tr.info
> td,
2199 .table
> thead
> tr.info
> th,
2200 .table
> tbody
> tr.info
> th,
2201 .table
> tfoot
> tr.info
> th {
2202 background-color: #d9edf7;
2204 .table-hover
> tbody
> tr
> td.info:hover,
2205 .table-hover
> tbody
> tr
> th.info:hover,
2206 .table-hover
> tbody
> tr.info:hover
> td,
2207 .table-hover
> tbody
> tr:hover
> .info,
2208 .table-hover
> tbody
> tr.info:hover
> th {
2209 background-color: #c4e3f3;
2211 .table
> thead
> tr
> td.warning,
2212 .table
> tbody
> tr
> td.warning,
2213 .table
> tfoot
> tr
> td.warning,
2214 .table
> thead
> tr
> th.warning,
2215 .table
> tbody
> tr
> th.warning,
2216 .table
> tfoot
> tr
> th.warning,
2217 .table
> thead
> tr.warning
> td,
2218 .table
> tbody
> tr.warning
> td,
2219 .table
> tfoot
> tr.warning
> td,
2220 .table
> thead
> tr.warning
> th,
2221 .table
> tbody
> tr.warning
> th,
2222 .table
> tfoot
> tr.warning
> th {
2223 background-color: #fcf8e3;
2225 .table-hover
> tbody
> tr
> td.warning:hover,
2226 .table-hover
> tbody
> tr
> th.warning:hover,
2227 .table-hover
> tbody
> tr.warning:hover
> td,
2228 .table-hover
> tbody
> tr:hover
> .warning,
2229 .table-hover
> tbody
> tr.warning:hover
> th {
2230 background-color: #faf2cc;
2232 .table
> thead
> tr
> td.danger,
2233 .table
> tbody
> tr
> td.danger,
2234 .table
> tfoot
> tr
> td.danger,
2235 .table
> thead
> tr
> th.danger,
2236 .table
> tbody
> tr
> th.danger,
2237 .table
> tfoot
> tr
> th.danger,
2238 .table
> thead
> tr.danger
> td,
2239 .table
> tbody
> tr.danger
> td,
2240 .table
> tfoot
> tr.danger
> td,
2241 .table
> thead
> tr.danger
> th,
2242 .table
> tbody
> tr.danger
> th,
2243 .table
> tfoot
> tr.danger
> th {
2244 background-color: #f2dede;
2246 .table-hover
> tbody
> tr
> td.danger:hover,
2247 .table-hover
> tbody
> tr
> th.danger:hover,
2248 .table-hover
> tbody
> tr.danger:hover
> td,
2249 .table-hover
> tbody
> tr:hover
> .danger,
2250 .table-hover
> tbody
> tr.danger:hover
> th {
2251 background-color: #ebcccc;
2253 @media screen and (max-width:
767px) {
2256 margin-bottom:
15px;
2259 -webkit-overflow-scrolling: touch;
2260 -ms-overflow-style: -ms-autohiding-scrollbar;
2261 border:
1px solid #ddd;
2263 .table-responsive
> .table {
2266 .table-responsive
> .table
> thead
> tr
> th,
2267 .table-responsive
> .table
> tbody
> tr
> th,
2268 .table-responsive
> .table
> tfoot
> tr
> th,
2269 .table-responsive
> .table
> thead
> tr
> td,
2270 .table-responsive
> .table
> tbody
> tr
> td,
2271 .table-responsive
> .table
> tfoot
> tr
> td {
2272 white-space: nowrap;
2274 .table-responsive
> .table-bordered {
2277 .table-responsive
> .table-bordered
> thead
> tr
> th:first-child,
2278 .table-responsive
> .table-bordered
> tbody
> tr
> th:first-child,
2279 .table-responsive
> .table-bordered
> tfoot
> tr
> th:first-child,
2280 .table-responsive
> .table-bordered
> thead
> tr
> td:first-child,
2281 .table-responsive
> .table-bordered
> tbody
> tr
> td:first-child,
2282 .table-responsive
> .table-bordered
> tfoot
> tr
> td:first-child {
2285 .table-responsive
> .table-bordered
> thead
> tr
> th:last-child,
2286 .table-responsive
> .table-bordered
> tbody
> tr
> th:last-child,
2287 .table-responsive
> .table-bordered
> tfoot
> tr
> th:last-child,
2288 .table-responsive
> .table-bordered
> thead
> tr
> td:last-child,
2289 .table-responsive
> .table-bordered
> tbody
> tr
> td:last-child,
2290 .table-responsive
> .table-bordered
> tfoot
> tr
> td:last-child {
2293 .table-responsive
> .table-bordered
> tbody
> tr:last-child
> th,
2294 .table-responsive
> .table-bordered
> tfoot
> tr:last-child
> th,
2295 .table-responsive
> .table-bordered
> tbody
> tr:last-child
> td,
2296 .table-responsive
> .table-bordered
> tfoot
> tr:last-child
> td {
2310 margin-bottom:
20px;
2312 line-height: inherit;
2315 border-bottom:
1px solid #e5e5e5;
2318 display: inline-block;
2323 input[
type="search"] {
2324 -webkit-box-sizing: border-box;
2325 -moz-box-sizing: border-box;
2326 box-sizing: border-box;
2328 input[
type="radio"],
2329 input[
type="checkbox"] {
2332 line-height: normal;
2334 input[
type="file"] {
2337 input[
type="range"] {
2345 input[
type="file"]:focus,
2346 input[
type="radio"]:focus,
2347 input[
type="checkbox"]:focus {
2348 outline: thin dotted;
2349 outline:
5px auto -webkit-focus-ring-color;
2350 outline-offset: -
2px;
2356 line-height:
1.42857143;
2365 line-height:
1.42857143;
2367 background-color: #fff;
2368 background-image: none;
2369 border:
1px solid #ccc;
2371 -webkit-box-shadow: inset
0 1px
1px rgba(
0,
0,
0,
.075);
2372 box-shadow: inset
0 1px
1px rgba(
0,
0,
0,
.075);
2373 -webkit-transition: border-color ease-in-out
.15s, -webkit-box-shadow ease-in-out
.15s;
2374 -o-transition: border-color ease-in-out
.15s, box-shadow ease-in-out
.15s;
2375 transition: border-color ease-in-out
.15s, box-shadow ease-in-out
.15s;
2377 .form-control:focus {
2378 border-color: #
66afe9;
2380 -webkit-box-shadow: inset
0 1px
1px rgba(
0,
0,
0,
.075),
0 0 8px rgba(
102,
175,
233,
.6);
2381 box-shadow: inset
0 1px
1px rgba(
0,
0,
0,
.075),
0 0 8px rgba(
102,
175,
233,
.6);
2383 .form-control::-moz-placeholder {
2387 .form-control:-ms-input-placeholder {
2390 .form-control::-webkit-input-placeholder {
2393 .form-control[disabled],
2394 .form-control[readonly],
2395 fieldset[disabled] .form-control {
2396 cursor: not-allowed;
2397 background-color: #eee;
2400 textarea.form-control {
2403 input[
type="search"] {
2404 -webkit-appearance: none;
2408 input[
type="datetime-local"],
2409 input[
type="month"] {
2411 line-height:
1.42857143 \
0;
2413 input[
type="date"].input-sm,
2414 input[
type="time"].input-sm,
2415 input[
type="datetime-local"].input-sm,
2416 input[
type="month"].input-sm {
2419 input[
type="date"].input-lg,
2420 input[
type="time"].input-lg,
2421 input[
type="datetime-local"].input-lg,
2422 input[
type="month"].input-lg {
2426 margin-bottom:
15px;
2434 margin-bottom:
10px;
2440 font-weight: normal;
2443 .radio input[
type="radio"],
2444 .radio-inline input[
type="radio"],
2445 .checkbox input[
type="checkbox"],
2446 .checkbox-inline input[
type="checkbox"] {
2452 .checkbox + .checkbox {
2457 display: inline-block;
2460 font-weight: normal;
2461 vertical-align: middle;
2464 .radio-inline + .radio-inline,
2465 .checkbox-inline + .checkbox-inline {
2469 input[
type="radio"][disabled],
2470 input[
type="checkbox"][disabled],
2471 input[
type="radio"].disabled,
2472 input[
type="checkbox"].disabled,
2473 fieldset[disabled] input[
type="radio"],
2474 fieldset[disabled] input[
type="checkbox"] {
2475 cursor: not-allowed;
2477 .radio-inline.disabled,
2478 .checkbox-inline.disabled,
2479 fieldset[disabled] .radio-inline,
2480 fieldset[disabled] .checkbox-inline {
2481 cursor: not-allowed;
2483 .radio.disabled label,
2484 .checkbox.disabled label,
2485 fieldset[disabled] .radio label,
2486 fieldset[disabled] .checkbox label {
2487 cursor: not-allowed;
2489 .form-control-static {
2491 padding-bottom:
7px;
2494 .form-control-static.input-lg,
2495 .form-control-static.input-sm {
2500 .form-horizontal .form-group-sm .form-control {
2512 select[multiple].input-sm {
2516 .form-horizontal .form-group-lg .form-control {
2528 select[multiple].input-lg {
2534 .has-feedback .form-control {
2535 padding-right:
42.5px;
2537 .form-control-feedback {
2548 .input-lg + .form-control-feedback {
2553 .input-sm + .form-control-feedback {
2558 .has-success .help-block,
2559 .has-success .control-label,
2560 .has-success .radio,
2561 .has-success .checkbox,
2562 .has-success .radio-inline,
2563 .has-success .checkbox-inline {
2566 .has-success .form-control {
2567 border-color: #
3c763d;
2568 -webkit-box-shadow: inset
0 1px
1px rgba(
0,
0,
0,
.075);
2569 box-shadow: inset
0 1px
1px rgba(
0,
0,
0,
.075);
2571 .has-success .form-control:focus {
2572 border-color: #
2b542c;
2573 -webkit-box-shadow: inset
0 1px
1px rgba(
0,
0,
0,
.075),
0 0 6px #
67b168;
2574 box-shadow: inset
0 1px
1px rgba(
0,
0,
0,
.075),
0 0 6px #
67b168;
2576 .has-success .input-group-addon {
2578 background-color: #dff0d8;
2579 border-color: #
3c763d;
2581 .has-success .form-control-feedback {
2584 .has-warning .help-block,
2585 .has-warning .control-label,
2586 .has-warning .radio,
2587 .has-warning .checkbox,
2588 .has-warning .radio-inline,
2589 .has-warning .checkbox-inline {
2592 .has-warning .form-control {
2593 border-color: #
8a6d3b;
2594 -webkit-box-shadow: inset
0 1px
1px rgba(
0,
0,
0,
.075);
2595 box-shadow: inset
0 1px
1px rgba(
0,
0,
0,
.075);
2597 .has-warning .form-control:focus {
2598 border-color: #
66512c;
2599 -webkit-box-shadow: inset
0 1px
1px rgba(
0,
0,
0,
.075),
0 0 6px #c0a16b;
2600 box-shadow: inset
0 1px
1px rgba(
0,
0,
0,
.075),
0 0 6px #c0a16b;
2602 .has-warning .input-group-addon {
2604 background-color: #fcf8e3;
2605 border-color: #
8a6d3b;
2607 .has-warning .form-control-feedback {
2610 .has-error .help-block,
2611 .has-error .control-label,
2613 .has-error .checkbox,
2614 .has-error .radio-inline,
2615 .has-error .checkbox-inline {
2618 .has-error .form-control {
2619 border-color: #a94442;
2620 -webkit-box-shadow: inset
0 1px
1px rgba(
0,
0,
0,
.075);
2621 box-shadow: inset
0 1px
1px rgba(
0,
0,
0,
.075);
2623 .has-error .form-control:focus {
2624 border-color: #
843534;
2625 -webkit-box-shadow: inset
0 1px
1px rgba(
0,
0,
0,
.075),
0 0 6px #ce8483;
2626 box-shadow: inset
0 1px
1px rgba(
0,
0,
0,
.075),
0 0 6px #ce8483;
2628 .has-error .input-group-addon {
2630 background-color: #f2dede;
2631 border-color: #a94442;
2633 .has-error .form-control-feedback {
2636 .has-feedback label.sr-only ~ .form-control-feedback {
2642 margin-bottom:
10px;
2645 @media (min-width:
768px) {
2646 .form-inline .form-group {
2647 display: inline-block;
2649 vertical-align: middle;
2651 .form-inline .form-control {
2652 display: inline-block;
2654 vertical-align: middle;
2656 .form-inline .input-group {
2657 display: inline-table;
2658 vertical-align: middle;
2660 .form-inline .input-group .input-group-addon,
2661 .form-inline .input-group .input-group-btn,
2662 .form-inline .input-group .form-control {
2665 .form-inline .input-group
> .form-control {
2668 .form-inline .control-label {
2670 vertical-align: middle;
2672 .form-inline .radio,
2673 .form-inline .checkbox {
2674 display: inline-block;
2677 vertical-align: middle;
2679 .form-inline .radio label,
2680 .form-inline .checkbox label {
2683 .form-inline .radio input[
type="radio"],
2684 .form-inline .checkbox input[
type="checkbox"] {
2688 .form-inline .has-feedback .form-control-feedback {
2692 .form-horizontal .radio,
2693 .form-horizontal .checkbox,
2694 .form-horizontal .radio-inline,
2695 .form-horizontal .checkbox-inline {
2700 .form-horizontal .radio,
2701 .form-horizontal .checkbox {
2704 .form-horizontal .form-group {
2705 margin-right: -
15px;
2708 @media (min-width:
768px) {
2709 .form-horizontal .control-label {
2715 .form-horizontal .has-feedback .form-control-feedback {
2719 @media (min-width:
768px) {
2720 .form-horizontal .form-group-lg .control-label {
2721 padding-top:
14.3px;
2724 @media (min-width:
768px) {
2725 .form-horizontal .form-group-sm .control-label {
2730 display: inline-block;
2734 font-weight: normal;
2735 line-height:
1.42857143;
2737 white-space: nowrap;
2738 vertical-align: middle;
2740 -webkit-user-select: none;
2741 -moz-user-select: none;
2742 -ms-user-select: none;
2744 background-image: none;
2745 border:
1px solid transparent;
2751 outline: thin dotted;
2752 outline:
5px auto -webkit-focus-ring-color;
2753 outline-offset: -
2px;
2758 text-decoration: none;
2762 background-image: none;
2764 -webkit-box-shadow: inset
0 3px
5px rgba(
0,
0,
0,
.125);
2765 box-shadow: inset
0 3px
5px rgba(
0,
0,
0,
.125);
2769 fieldset[disabled] .btn {
2770 pointer-events: none;
2771 cursor: not-allowed;
2772 filter: alpha(opacity=
65);
2773 -webkit-box-shadow: none;
2779 background-color: #fff;
2784 .btn-default:active,
2785 .btn-default.active,
2786 .open
> .dropdown-toggle.btn-default {
2788 background-color: #e6e6e6;
2789 border-color: #adadad;
2791 .btn-default:active,
2792 .btn-default.active,
2793 .open
> .dropdown-toggle.btn-default {
2794 background-image: none;
2796 .btn-default.disabled,
2797 .btn-default[disabled],
2798 fieldset[disabled] .btn-default,
2799 .btn-default.disabled:hover,
2800 .btn-default[disabled]:hover,
2801 fieldset[disabled] .btn-default:hover,
2802 .btn-default.disabled:focus,
2803 .btn-default[disabled]:focus,
2804 fieldset[disabled] .btn-default:focus,
2805 .btn-default.disabled:active,
2806 .btn-default[disabled]:active,
2807 fieldset[disabled] .btn-default:active,
2808 .btn-default.disabled.active,
2809 .btn-default[disabled].active,
2810 fieldset[disabled] .btn-default.active {
2811 background-color: #fff;
2814 .btn-default .badge {
2816 background-color: #
333;
2820 background-color: #
428bca;
2821 border-color: #
357ebd;
2825 .btn-primary:active,
2826 .btn-primary.active,
2827 .open
> .dropdown-toggle.btn-primary {
2829 background-color: #
3071a9;
2830 border-color: #
285e8e;
2832 .btn-primary:active,
2833 .btn-primary.active,
2834 .open
> .dropdown-toggle.btn-primary {
2835 background-image: none;
2837 .btn-primary.disabled,
2838 .btn-primary[disabled],
2839 fieldset[disabled] .btn-primary,
2840 .btn-primary.disabled:hover,
2841 .btn-primary[disabled]:hover,
2842 fieldset[disabled] .btn-primary:hover,
2843 .btn-primary.disabled:focus,
2844 .btn-primary[disabled]:focus,
2845 fieldset[disabled] .btn-primary:focus,
2846 .btn-primary.disabled:active,
2847 .btn-primary[disabled]:active,
2848 fieldset[disabled] .btn-primary:active,
2849 .btn-primary.disabled.active,
2850 .btn-primary[disabled].active,
2851 fieldset[disabled] .btn-primary.active {
2852 background-color: #
428bca;
2853 border-color: #
357ebd;
2855 .btn-primary .badge {
2857 background-color: #fff;
2861 background-color: #
5cb85c;
2862 border-color: #
4cae4c;
2866 .btn-success:active,
2867 .btn-success.active,
2868 .open
> .dropdown-toggle.btn-success {
2870 background-color: #
449d44;
2871 border-color: #
398439;
2873 .btn-success:active,
2874 .btn-success.active,
2875 .open
> .dropdown-toggle.btn-success {
2876 background-image: none;
2878 .btn-success.disabled,
2879 .btn-success[disabled],
2880 fieldset[disabled] .btn-success,
2881 .btn-success.disabled:hover,
2882 .btn-success[disabled]:hover,
2883 fieldset[disabled] .btn-success:hover,
2884 .btn-success.disabled:focus,
2885 .btn-success[disabled]:focus,
2886 fieldset[disabled] .btn-success:focus,
2887 .btn-success.disabled:active,
2888 .btn-success[disabled]:active,
2889 fieldset[disabled] .btn-success:active,
2890 .btn-success.disabled.active,
2891 .btn-success[disabled].active,
2892 fieldset[disabled] .btn-success.active {
2893 background-color: #
5cb85c;
2894 border-color: #
4cae4c;
2896 .btn-success .badge {
2898 background-color: #fff;
2902 background-color: #
5bc0de;
2903 border-color: #
46b8da;
2909 .open
> .dropdown-toggle.btn-info {
2911 background-color: #
31b0d5;
2912 border-color: #
269abc;
2916 .open
> .dropdown-toggle.btn-info {
2917 background-image: none;
2920 .btn-info[disabled],
2921 fieldset[disabled] .btn-info,
2922 .btn-info.disabled:hover,
2923 .btn-info[disabled]:hover,
2924 fieldset[disabled] .btn-info:hover,
2925 .btn-info.disabled:focus,
2926 .btn-info[disabled]:focus,
2927 fieldset[disabled] .btn-info:focus,
2928 .btn-info.disabled:active,
2929 .btn-info[disabled]:active,
2930 fieldset[disabled] .btn-info:active,
2931 .btn-info.disabled.active,
2932 .btn-info[disabled].active,
2933 fieldset[disabled] .btn-info.active {
2934 background-color: #
5bc0de;
2935 border-color: #
46b8da;
2939 background-color: #fff;
2943 background-color: #f0ad4e;
2944 border-color: #eea236;
2948 .btn-warning:active,
2949 .btn-warning.active,
2950 .open
> .dropdown-toggle.btn-warning {
2952 background-color: #ec971f;
2953 border-color: #d58512;
2955 .btn-warning:active,
2956 .btn-warning.active,
2957 .open
> .dropdown-toggle.btn-warning {
2958 background-image: none;
2960 .btn-warning.disabled,
2961 .btn-warning[disabled],
2962 fieldset[disabled] .btn-warning,
2963 .btn-warning.disabled:hover,
2964 .btn-warning[disabled]:hover,
2965 fieldset[disabled] .btn-warning:hover,
2966 .btn-warning.disabled:focus,
2967 .btn-warning[disabled]:focus,
2968 fieldset[disabled] .btn-warning:focus,
2969 .btn-warning.disabled:active,
2970 .btn-warning[disabled]:active,
2971 fieldset[disabled] .btn-warning:active,
2972 .btn-warning.disabled.active,
2973 .btn-warning[disabled].active,
2974 fieldset[disabled] .btn-warning.active {
2975 background-color: #f0ad4e;
2976 border-color: #eea236;
2978 .btn-warning .badge {
2980 background-color: #fff;
2984 background-color: #d9534f;
2985 border-color: #d43f3a;
2991 .open
> .dropdown-toggle.btn-danger {
2993 background-color: #c9302c;
2994 border-color: #ac2925;
2998 .open
> .dropdown-toggle.btn-danger {
2999 background-image: none;
3001 .btn-danger.disabled,
3002 .btn-danger[disabled],
3003 fieldset[disabled] .btn-danger,
3004 .btn-danger.disabled:hover,
3005 .btn-danger[disabled]:hover,
3006 fieldset[disabled] .btn-danger:hover,
3007 .btn-danger.disabled:focus,
3008 .btn-danger[disabled]:focus,
3009 fieldset[disabled] .btn-danger:focus,
3010 .btn-danger.disabled:active,
3011 .btn-danger[disabled]:active,
3012 fieldset[disabled] .btn-danger:active,
3013 .btn-danger.disabled.active,
3014 .btn-danger[disabled].active,
3015 fieldset[disabled] .btn-danger.active {
3016 background-color: #d9534f;
3017 border-color: #d43f3a;
3019 .btn-danger .badge {
3021 background-color: #fff;
3024 font-weight: normal;
3031 .btn-link[disabled],
3032 fieldset[disabled] .btn-link {
3033 background-color: transparent;
3034 -webkit-box-shadow: none;
3041 border-color: transparent;
3046 text-decoration: underline;
3047 background-color: transparent;
3049 .btn-link[disabled]:hover,
3050 fieldset[disabled] .btn-link:hover,
3051 .btn-link[disabled]:focus,
3052 fieldset[disabled] .btn-link:focus {
3054 text-decoration: none;
3057 .btn-group-lg
> .btn {
3064 .btn-group-sm
> .btn {
3071 .btn-group-xs
> .btn {
3081 .btn-block + .btn-block {
3084 input[
type="submit"].btn-block,
3085 input[
type="reset"].btn-block,
3086 input[
type="button"].btn-block {
3091 -webkit-transition: opacity
.15s linear;
3092 -o-transition: opacity
.15s linear;
3093 transition: opacity
.15s linear;
3108 display: table-row-group;
3114 -webkit-transition: height
.35s ease;
3115 -o-transition: height
.35s ease;
3116 transition: height
.35s ease;
3119 display: inline-block;
3123 vertical-align: middle;
3124 border-top:
4px solid;
3125 border-right:
4px solid transparent;
3126 border-left:
4px solid transparent;
3131 .dropdown-toggle:focus {
3147 background-color: #fff;
3148 -webkit-background-clip: padding-box;
3149 background-clip: padding-box;
3150 border:
1px solid #ccc;
3151 border:
1px solid rgba(
0,
0,
0,
.15);
3153 -webkit-box-shadow:
0 6px
12px rgba(
0,
0,
0,
.175);
3154 box-shadow:
0 6px
12px rgba(
0,
0,
0,
.175);
3156 .dropdown-menu.pull-right {
3160 .dropdown-menu .divider {
3164 background-color: #e5e5e5;
3166 .dropdown-menu
> li
> a {
3170 font-weight: normal;
3171 line-height:
1.42857143;
3173 white-space: nowrap;
3175 .dropdown-menu
> li
> a:hover,
3176 .dropdown-menu
> li
> a:focus {
3178 text-decoration: none;
3179 background-color: #f5f5f5;
3181 .dropdown-menu
> .active
> a,
3182 .dropdown-menu
> .active
> a:hover,
3183 .dropdown-menu
> .active
> a:focus {
3185 text-decoration: none;
3186 background-color: #
428bca;
3189 .dropdown-menu
> .disabled
> a,
3190 .dropdown-menu
> .disabled
> a:hover,
3191 .dropdown-menu
> .disabled
> a:focus {
3194 .dropdown-menu
> .disabled
> a:hover,
3195 .dropdown-menu
> .disabled
> a:focus {
3196 text-decoration: none;
3197 cursor: not-allowed;
3198 background-color: transparent;
3199 background-image: none;
3200 filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
3202 .open
> .dropdown-menu {
3208 .dropdown-menu-right {
3212 .dropdown-menu-left {
3220 line-height:
1.42857143;
3222 white-space: nowrap;
3224 .dropdown-backdrop {
3232 .pull-right
> .dropdown-menu {
3237 .navbar-fixed-bottom .dropdown .caret {
3240 border-bottom:
4px solid;
3242 .dropup .dropdown-menu,
3243 .navbar-fixed-bottom .dropdown .dropdown-menu {
3248 @media (min-width:
768px) {
3249 .navbar-right .dropdown-menu {
3253 .navbar-right .dropdown-menu-left {
3259 .btn-group-vertical {
3261 display: inline-block;
3262 vertical-align: middle;
3265 .btn-group-vertical
> .btn {
3269 .btn-group
> .btn:hover,
3270 .btn-group-vertical
> .btn:hover,
3271 .btn-group
> .btn:focus,
3272 .btn-group-vertical
> .btn:focus,
3273 .btn-group
> .btn:active,
3274 .btn-group-vertical
> .btn:active,
3275 .btn-group
> .btn.active,
3276 .btn-group-vertical
> .btn.active {
3279 .btn-group
> .btn:focus,
3280 .btn-group-vertical
> .btn:focus {
3283 .btn-group .btn + .btn,
3284 .btn-group .btn + .btn-group,
3285 .btn-group .btn-group + .btn,
3286 .btn-group .btn-group + .btn-group {
3292 .btn-toolbar .btn-group,
3293 .btn-toolbar .input-group {
3296 .btn-toolbar
> .btn,
3297 .btn-toolbar
> .btn-group,
3298 .btn-toolbar
> .input-group {
3301 .btn-group
> .btn:not(:first-child):not(:last-child):not(.dropdown-toggle) {
3304 .btn-group
> .btn:first-child {
3307 .btn-group
> .btn:first-child:not(:last-child):not(.dropdown-toggle) {
3308 border-top-right-radius:
0;
3309 border-bottom-right-radius:
0;
3311 .btn-group
> .btn:last-child:not(:first-child),
3312 .btn-group
> .dropdown-toggle:not(:first-child) {
3313 border-top-left-radius:
0;
3314 border-bottom-left-radius:
0;
3316 .btn-group
> .btn-group {
3319 .btn-group
> .btn-group:not(:first-child):not(:last-child)
> .btn {
3322 .btn-group
> .btn-group:first-child
> .btn:last-child,
3323 .btn-group
> .btn-group:first-child
> .dropdown-toggle {
3324 border-top-right-radius:
0;
3325 border-bottom-right-radius:
0;
3327 .btn-group
> .btn-group:last-child
> .btn:first-child {
3328 border-top-left-radius:
0;
3329 border-bottom-left-radius:
0;
3331 .btn-group .dropdown-toggle:active,
3332 .btn-group.open .dropdown-toggle {
3335 .btn-group
> .btn + .dropdown-toggle {
3339 .btn-group
> .btn-lg + .dropdown-toggle {
3340 padding-right:
12px;
3343 .btn-group.open .dropdown-toggle {
3344 -webkit-box-shadow: inset
0 3px
5px rgba(
0,
0,
0,
.125);
3345 box-shadow: inset
0 3px
5px rgba(
0,
0,
0,
.125);
3347 .btn-group.open .dropdown-toggle.btn-link {
3348 -webkit-box-shadow: none;
3355 border-width:
5px
5px
0;
3356 border-bottom-width:
0;
3358 .dropup .btn-lg .caret {
3359 border-width:
0 5px
5px;
3361 .btn-group-vertical
> .btn,
3362 .btn-group-vertical
> .btn-group,
3363 .btn-group-vertical
> .btn-group
> .btn {
3369 .btn-group-vertical
> .btn-group
> .btn {
3372 .btn-group-vertical
> .btn + .btn,
3373 .btn-group-vertical
> .btn + .btn-group,
3374 .btn-group-vertical
> .btn-group + .btn,
3375 .btn-group-vertical
> .btn-group + .btn-group {
3379 .btn-group-vertical
> .btn:not(:first-child):not(:last-child) {
3382 .btn-group-vertical
> .btn:first-child:not(:last-child) {
3383 border-top-right-radius:
4px;
3384 border-bottom-right-radius:
0;
3385 border-bottom-left-radius:
0;
3387 .btn-group-vertical
> .btn:last-child:not(:first-child) {
3388 border-top-left-radius:
0;
3389 border-top-right-radius:
0;
3390 border-bottom-left-radius:
4px;
3392 .btn-group-vertical
> .btn-group:not(:first-child):not(:last-child)
> .btn {
3395 .btn-group-vertical
> .btn-group:first-child:not(:last-child)
> .btn:last-child,
3396 .btn-group-vertical
> .btn-group:first-child:not(:last-child)
> .dropdown-toggle {
3397 border-bottom-right-radius:
0;
3398 border-bottom-left-radius:
0;
3400 .btn-group-vertical
> .btn-group:last-child:not(:first-child)
> .btn:first-child {
3401 border-top-left-radius:
0;
3402 border-top-right-radius:
0;
3404 .btn-group-justified {
3407 table-layout: fixed;
3408 border-collapse: separate;
3410 .btn-group-justified
> .btn,
3411 .btn-group-justified
> .btn-group {
3412 display: table-cell;
3416 .btn-group-justified
> .btn-group .btn {
3419 .btn-group-justified
> .btn-group .dropdown-menu {
3422 [
data-toggle="buttons"]
> .btn
> input[
type="radio"],
3423 [
data-toggle="buttons"]
> .btn
> input[
type="checkbox"] {
3426 filter: alpha(opacity=
0);
3432 border-collapse: separate;
3434 .input-group[class*="col-"] {
3439 .input-group .form-control {
3446 .input-group-lg
> .form-control,
3447 .input-group-lg
> .input-group-addon,
3448 .input-group-lg
> .input-group-btn
> .btn {
3455 select.input-group-lg
> .form-control,
3456 select.input-group-lg
> .input-group-addon,
3457 select.input-group-lg
> .input-group-btn
> .btn {
3461 textarea.input-group-lg
> .form-control,
3462 textarea.input-group-lg
> .input-group-addon,
3463 textarea.input-group-lg
> .input-group-btn
> .btn,
3464 select[multiple].input-group-lg
> .form-control,
3465 select[multiple].input-group-lg
> .input-group-addon,
3466 select[multiple].input-group-lg
> .input-group-btn
> .btn {
3469 .input-group-sm
> .form-control,
3470 .input-group-sm
> .input-group-addon,
3471 .input-group-sm
> .input-group-btn
> .btn {
3478 select.input-group-sm
> .form-control,
3479 select.input-group-sm
> .input-group-addon,
3480 select.input-group-sm
> .input-group-btn
> .btn {
3484 textarea.input-group-sm
> .form-control,
3485 textarea.input-group-sm
> .input-group-addon,
3486 textarea.input-group-sm
> .input-group-btn
> .btn,
3487 select[multiple].input-group-sm
> .form-control,
3488 select[multiple].input-group-sm
> .input-group-addon,
3489 select[multiple].input-group-sm
> .input-group-btn
> .btn {
3494 .input-group .form-control {
3495 display: table-cell;
3497 .input-group-addon:not(:first-child):not(:last-child),
3498 .input-group-btn:not(:first-child):not(:last-child),
3499 .input-group .form-control:not(:first-child):not(:last-child) {
3505 white-space: nowrap;
3506 vertical-align: middle;
3508 .input-group-addon {
3511 font-weight: normal;
3515 background-color: #eee;
3516 border:
1px solid #ccc;
3519 .input-group-addon.input-sm {
3524 .input-group-addon.input-lg {
3529 .input-group-addon input[
type="radio"],
3530 .input-group-addon input[
type="checkbox"] {
3533 .input-group .form-control:first-child,
3534 .input-group-addon:first-child,
3535 .input-group-btn:first-child
> .btn,
3536 .input-group-btn:first-child
> .btn-group
> .btn,
3537 .input-group-btn:first-child
> .dropdown-toggle,
3538 .input-group-btn:last-child
> .btn:not(:last-child):not(.dropdown-toggle),
3539 .input-group-btn:last-child
> .btn-group:not(:last-child)
> .btn {
3540 border-top-right-radius:
0;
3541 border-bottom-right-radius:
0;
3543 .input-group-addon:first-child {
3546 .input-group .form-control:last-child,
3547 .input-group-addon:last-child,
3548 .input-group-btn:last-child
> .btn,
3549 .input-group-btn:last-child
> .btn-group
> .btn,
3550 .input-group-btn:last-child
> .dropdown-toggle,
3551 .input-group-btn:first-child
> .btn:not(:first-child),
3552 .input-group-btn:first-child
> .btn-group:not(:first-child)
> .btn {
3553 border-top-left-radius:
0;
3554 border-bottom-left-radius:
0;
3556 .input-group-addon:last-child {
3562 white-space: nowrap;
3564 .input-group-btn
> .btn {
3567 .input-group-btn
> .btn + .btn {
3570 .input-group-btn
> .btn:hover,
3571 .input-group-btn
> .btn:focus,
3572 .input-group-btn
> .btn:active {
3575 .input-group-btn:first-child
> .btn,
3576 .input-group-btn:first-child
> .btn-group {
3579 .input-group-btn:last-child
> .btn,
3580 .input-group-btn:last-child
> .btn-group {
3597 .nav
> li
> a:hover,
3598 .nav
> li
> a:focus {
3599 text-decoration: none;
3600 background-color: #eee;
3602 .nav
> li.disabled
> a {
3605 .nav
> li.disabled
> a:hover,
3606 .nav
> li.disabled
> a:focus {
3608 text-decoration: none;
3609 cursor: not-allowed;
3610 background-color: transparent;
3613 .nav .open
> a:hover,
3614 .nav .open
> a:focus {
3615 background-color: #eee;
3616 border-color: #
428bca;
3622 background-color: #e5e5e5;
3624 .nav
> li
> a
> img {
3628 border-bottom:
1px solid #ddd;
3632 margin-bottom: -
1px;
3634 .nav-tabs
> li
> a {
3636 line-height:
1.42857143;
3637 border:
1px solid transparent;
3638 border-radius:
4px
4px
0 0;
3640 .nav-tabs
> li
> a:hover {
3641 border-color: #eee #eee #ddd;
3643 .nav-tabs
> li.active
> a,
3644 .nav-tabs
> li.active
> a:hover,
3645 .nav-tabs
> li.active
> a:focus {
3648 background-color: #fff;
3649 border:
1px solid #ddd;
3650 border-bottom-color: transparent;
3652 .nav-tabs.nav-justified {
3656 .nav-tabs.nav-justified
> li {
3659 .nav-tabs.nav-justified
> li
> a {
3663 .nav-tabs.nav-justified
> .dropdown .dropdown-menu {
3667 @media (min-width:
768px) {
3668 .nav-tabs.nav-justified
> li {
3669 display: table-cell;
3672 .nav-tabs.nav-justified
> li
> a {
3676 .nav-tabs.nav-justified
> li
> a {
3680 .nav-tabs.nav-justified
> .active
> a,
3681 .nav-tabs.nav-justified
> .active
> a:hover,
3682 .nav-tabs.nav-justified
> .active
> a:focus {
3683 border:
1px solid #ddd;
3685 @media (min-width:
768px) {
3686 .nav-tabs.nav-justified
> li
> a {
3687 border-bottom:
1px solid #ddd;
3688 border-radius:
4px
4px
0 0;
3690 .nav-tabs.nav-justified
> .active
> a,
3691 .nav-tabs.nav-justified
> .active
> a:hover,
3692 .nav-tabs.nav-justified
> .active
> a:focus {
3693 border-bottom-color: #fff;
3699 .nav-pills
> li
> a {
3702 .nav-pills
> li + li {
3705 .nav-pills
> li.active
> a,
3706 .nav-pills
> li.active
> a:hover,
3707 .nav-pills
> li.active
> a:focus {
3709 background-color: #
428bca;
3714 .nav-stacked
> li + li {
3721 .nav-justified
> li {
3724 .nav-justified
> li
> a {
3728 .nav-justified
> .dropdown .dropdown-menu {
3732 @media (min-width:
768px) {
3733 .nav-justified
> li {
3734 display: table-cell;
3737 .nav-justified
> li
> a {
3741 .nav-tabs-justified {
3744 .nav-tabs-justified
> li
> a {
3748 .nav-tabs-justified
> .active
> a,
3749 .nav-tabs-justified
> .active
> a:hover,
3750 .nav-tabs-justified
> .active
> a:focus {
3751 border:
1px solid #ddd;
3753 @media (min-width:
768px) {
3754 .nav-tabs-justified
> li
> a {
3755 border-bottom:
1px solid #ddd;
3756 border-radius:
4px
4px
0 0;
3758 .nav-tabs-justified
> .active
> a,
3759 .nav-tabs-justified
> .active
> a:hover,
3760 .nav-tabs-justified
> .active
> a:focus {
3761 border-bottom-color: #fff;
3764 .tab-content
> .tab-pane {
3767 .tab-content
> .active {
3770 .nav-tabs .dropdown-menu {
3772 border-top-left-radius:
0;
3773 border-top-right-radius:
0;
3778 margin-bottom:
20px;
3779 border:
1px solid transparent;
3781 @media (min-width:
768px) {
3786 @media (min-width:
768px) {
3792 padding-right:
15px;
3794 overflow-x: visible;
3795 -webkit-overflow-scrolling: touch;
3796 border-top:
1px solid transparent;
3797 -webkit-box-shadow: inset
0 1px
0 rgba(
255,
255,
255,
.1);
3798 box-shadow: inset
0 1px
0 rgba(
255,
255,
255,
.1);
3800 .navbar-collapse.in {
3803 @media (min-width:
768px) {
3807 -webkit-box-shadow: none;
3810 .navbar-collapse.collapse {
3811 display: block !important;
3812 height: auto !important;
3814 overflow: visible !important;
3816 .navbar-collapse.in {
3817 overflow-y: visible;
3819 .navbar-fixed-top .navbar-collapse,
3820 .navbar-static-top .navbar-collapse,
3821 .navbar-fixed-bottom .navbar-collapse {
3826 .navbar-fixed-top .navbar-collapse,
3827 .navbar-fixed-bottom .navbar-collapse {
3830 @media (max-width:
480px) and (orientation: landscape) {
3831 .navbar-fixed-top .navbar-collapse,
3832 .navbar-fixed-bottom .navbar-collapse {
3836 .container
> .navbar-header,
3837 .container-fluid
> .navbar-header,
3838 .container
> .navbar-collapse,
3839 .container-fluid
> .navbar-collapse {
3840 margin-right: -
15px;
3843 @media (min-width:
768px) {
3844 .container
> .navbar-header,
3845 .container-fluid
> .navbar-header,
3846 .container
> .navbar-collapse,
3847 .container-fluid
> .navbar-collapse {
3852 .navbar-static-top {
3854 border-width:
0 0 1px;
3856 @media (min-width:
768px) {
3857 .navbar-static-top {
3862 .navbar-fixed-bottom {
3867 -webkit-transform: translate3d(
0,
0,
0);
3868 -o-transform: translate3d(
0,
0,
0);
3869 transform: translate3d(
0,
0,
0);
3871 @media (min-width:
768px) {
3873 .navbar-fixed-bottom {
3879 border-width:
0 0 1px;
3881 .navbar-fixed-bottom {
3884 border-width:
1px
0 0;
3893 .navbar-brand:hover,
3894 .navbar-brand:focus {
3895 text-decoration: none;
3897 @media (min-width:
768px) {
3898 .navbar
> .container .navbar-brand,
3899 .navbar
> .container-fluid .navbar-brand {
3910 background-color: transparent;
3911 background-image: none;
3912 border:
1px solid transparent;
3915 .navbar-toggle:focus {
3918 .navbar-toggle .icon-bar {
3924 .navbar-toggle .icon-bar + .icon-bar {
3927 @media (min-width:
768px) {
3933 margin:
7.5px -
15px;
3935 .navbar-nav
> li
> a {
3937 padding-bottom:
10px;
3940 @media (max-width:
767px) {
3941 .navbar-nav .open .dropdown-menu {
3946 background-color: transparent;
3948 -webkit-box-shadow: none;
3951 .navbar-nav .open .dropdown-menu
> li
> a,
3952 .navbar-nav .open .dropdown-menu .dropdown-header {
3953 padding:
5px
15px
5px
25px;
3955 .navbar-nav .open .dropdown-menu
> li
> a {
3958 .navbar-nav .open .dropdown-menu
> li
> a:hover,
3959 .navbar-nav .open .dropdown-menu
> li
> a:focus {
3960 background-image: none;
3963 @media (min-width:
768px) {
3971 .navbar-nav
> li
> a {
3973 padding-bottom:
15px;
3975 .navbar-nav.navbar-right:last-child {
3976 margin-right: -
15px;
3979 @media (min-width:
768px) {
3981 float: left !important;
3984 float: right !important;
3990 margin-right: -
15px;
3993 border-top:
1px solid transparent;
3994 border-bottom:
1px solid transparent;
3995 -webkit-box-shadow: inset
0 1px
0 rgba(
255,
255,
255,
.1),
0 1px
0 rgba(
255,
255,
255,
.1);
3996 box-shadow: inset
0 1px
0 rgba(
255,
255,
255,
.1),
0 1px
0 rgba(
255,
255,
255,
.1);
3998 @media (min-width:
768px) {
3999 .navbar-form .form-group {
4000 display: inline-block;
4002 vertical-align: middle;
4004 .navbar-form .form-control {
4005 display: inline-block;
4007 vertical-align: middle;
4009 .navbar-form .input-group {
4010 display: inline-table;
4011 vertical-align: middle;
4013 .navbar-form .input-group .input-group-addon,
4014 .navbar-form .input-group .input-group-btn,
4015 .navbar-form .input-group .form-control {
4018 .navbar-form .input-group
> .form-control {
4021 .navbar-form .control-label {
4023 vertical-align: middle;
4025 .navbar-form .radio,
4026 .navbar-form .checkbox {
4027 display: inline-block;
4030 vertical-align: middle;
4032 .navbar-form .radio label,
4033 .navbar-form .checkbox label {
4036 .navbar-form .radio input[
type="radio"],
4037 .navbar-form .checkbox input[
type="checkbox"] {
4041 .navbar-form .has-feedback .form-control-feedback {
4045 @media (max-width:
767px) {
4046 .navbar-form .form-group {
4050 @media (min-width:
768px) {
4058 -webkit-box-shadow: none;
4061 .navbar-form.navbar-right:last-child {
4062 margin-right: -
15px;
4065 .navbar-nav
> li
> .dropdown-menu {
4067 border-top-left-radius:
0;
4068 border-top-right-radius:
0;
4070 .navbar-fixed-bottom .navbar-nav
> li
> .dropdown-menu {
4071 border-bottom-right-radius:
0;
4072 border-bottom-left-radius:
0;
4078 .navbar-btn.btn-sm {
4080 margin-bottom:
10px;
4082 .navbar-btn.btn-xs {
4084 margin-bottom:
14px;
4088 margin-bottom:
15px;
4090 @media (min-width:
768px) {
4096 .navbar-text.navbar-right:last-child {
4101 background-color: #f8f8f8;
4102 border-color: #e7e7e7;
4104 .navbar-default .navbar-brand {
4107 .navbar-default .navbar-brand:hover,
4108 .navbar-default .navbar-brand:focus {
4110 background-color: transparent;
4112 .navbar-default .navbar-text {
4115 .navbar-default .navbar-nav
> li
> a {
4118 .navbar-default .navbar-nav
> li
> a:hover,
4119 .navbar-default .navbar-nav
> li
> a:focus {
4121 background-color: transparent;
4123 .navbar-default .navbar-nav
> .active
> a,
4124 .navbar-default .navbar-nav
> .active
> a:hover,
4125 .navbar-default .navbar-nav
> .active
> a:focus {
4127 background-color: #e7e7e7;
4129 .navbar-default .navbar-nav
> .disabled
> a,
4130 .navbar-default .navbar-nav
> .disabled
> a:hover,
4131 .navbar-default .navbar-nav
> .disabled
> a:focus {
4133 background-color: transparent;
4135 .navbar-default .navbar-toggle {
4138 .navbar-default .navbar-toggle:hover,
4139 .navbar-default .navbar-toggle:focus {
4140 background-color: #ddd;
4142 .navbar-default .navbar-toggle .icon-bar {
4143 background-color: #
888;
4145 .navbar-default .navbar-collapse,
4146 .navbar-default .navbar-form {
4147 border-color: #e7e7e7;
4149 .navbar-default .navbar-nav
> .open
> a,
4150 .navbar-default .navbar-nav
> .open
> a:hover,
4151 .navbar-default .navbar-nav
> .open
> a:focus {
4153 background-color: #e7e7e7;
4155 @media (max-width:
767px) {
4156 .navbar-default .navbar-nav .open .dropdown-menu
> li
> a {
4159 .navbar-default .navbar-nav .open .dropdown-menu
> li
> a:hover,
4160 .navbar-default .navbar-nav .open .dropdown-menu
> li
> a:focus {
4162 background-color: transparent;
4164 .navbar-default .navbar-nav .open .dropdown-menu
> .active
> a,
4165 .navbar-default .navbar-nav .open .dropdown-menu
> .active
> a:hover,
4166 .navbar-default .navbar-nav .open .dropdown-menu
> .active
> a:focus {
4168 background-color: #e7e7e7;
4170 .navbar-default .navbar-nav .open .dropdown-menu
> .disabled
> a,
4171 .navbar-default .navbar-nav .open .dropdown-menu
> .disabled
> a:hover,
4172 .navbar-default .navbar-nav .open .dropdown-menu
> .disabled
> a:focus {
4174 background-color: transparent;
4177 .navbar-default .navbar-link {
4180 .navbar-default .navbar-link:hover {
4183 .navbar-default .btn-link {
4186 .navbar-default .btn-link:hover,
4187 .navbar-default .btn-link:focus {
4190 .navbar-default .btn-link[disabled]:hover,
4191 fieldset[disabled] .navbar-default .btn-link:hover,
4192 .navbar-default .btn-link[disabled]:focus,
4193 fieldset[disabled] .navbar-default .btn-link:focus {
4197 background-color: #
222;
4198 border-color: #
080808;
4200 .navbar-inverse .navbar-brand {
4203 .navbar-inverse .navbar-brand:hover,
4204 .navbar-inverse .navbar-brand:focus {
4206 background-color: transparent;
4208 .navbar-inverse .navbar-text {
4211 .navbar-inverse .navbar-nav
> li
> a {
4214 .navbar-inverse .navbar-nav
> li
> a:hover,
4215 .navbar-inverse .navbar-nav
> li
> a:focus {
4217 background-color: transparent;
4219 .navbar-inverse .navbar-nav
> .active
> a,
4220 .navbar-inverse .navbar-nav
> .active
> a:hover,
4221 .navbar-inverse .navbar-nav
> .active
> a:focus {
4223 background-color: #
080808;
4225 .navbar-inverse .navbar-nav
> .disabled
> a,
4226 .navbar-inverse .navbar-nav
> .disabled
> a:hover,
4227 .navbar-inverse .navbar-nav
> .disabled
> a:focus {
4229 background-color: transparent;
4231 .navbar-inverse .navbar-toggle {
4234 .navbar-inverse .navbar-toggle:hover,
4235 .navbar-inverse .navbar-toggle:focus {
4236 background-color: #
333;
4238 .navbar-inverse .navbar-toggle .icon-bar {
4239 background-color: #fff;
4241 .navbar-inverse .navbar-collapse,
4242 .navbar-inverse .navbar-form {
4243 border-color: #
101010;
4245 .navbar-inverse .navbar-nav
> .open
> a,
4246 .navbar-inverse .navbar-nav
> .open
> a:hover,
4247 .navbar-inverse .navbar-nav
> .open
> a:focus {
4249 background-color: #
080808;
4251 @media (max-width:
767px) {
4252 .navbar-inverse .navbar-nav .open .dropdown-menu
> .dropdown-header {
4253 border-color: #
080808;
4255 .navbar-inverse .navbar-nav .open .dropdown-menu .divider {
4256 background-color: #
080808;
4258 .navbar-inverse .navbar-nav .open .dropdown-menu
> li
> a {
4261 .navbar-inverse .navbar-nav .open .dropdown-menu
> li
> a:hover,
4262 .navbar-inverse .navbar-nav .open .dropdown-menu
> li
> a:focus {
4264 background-color: transparent;
4266 .navbar-inverse .navbar-nav .open .dropdown-menu
> .active
> a,
4267 .navbar-inverse .navbar-nav .open .dropdown-menu
> .active
> a:hover,
4268 .navbar-inverse .navbar-nav .open .dropdown-menu
> .active
> a:focus {
4270 background-color: #
080808;
4272 .navbar-inverse .navbar-nav .open .dropdown-menu
> .disabled
> a,
4273 .navbar-inverse .navbar-nav .open .dropdown-menu
> .disabled
> a:hover,
4274 .navbar-inverse .navbar-nav .open .dropdown-menu
> .disabled
> a:focus {
4276 background-color: transparent;
4279 .navbar-inverse .navbar-link {
4282 .navbar-inverse .navbar-link:hover {
4285 .navbar-inverse .btn-link {
4288 .navbar-inverse .btn-link:hover,
4289 .navbar-inverse .btn-link:focus {
4292 .navbar-inverse .btn-link[disabled]:hover,
4293 fieldset[disabled] .navbar-inverse .btn-link:hover,
4294 .navbar-inverse .btn-link[disabled]:focus,
4295 fieldset[disabled] .navbar-inverse .btn-link:focus {
4300 margin-bottom:
20px;
4302 background-color: #f5f5f5;
4306 display: inline-block;
4308 .breadcrumb
> li + li:before {
4313 .breadcrumb
> .active {
4317 display: inline-block;
4325 .pagination
> li
> a,
4326 .pagination
> li
> span {
4331 line-height:
1.42857143;
4333 text-decoration: none;
4334 background-color: #fff;
4335 border:
1px solid #ddd;
4337 .pagination
> li:first-child
> a,
4338 .pagination
> li:first-child
> span {
4340 border-top-left-radius:
4px;
4341 border-bottom-left-radius:
4px;
4343 .pagination
> li:last-child
> a,
4344 .pagination
> li:last-child
> span {
4345 border-top-right-radius:
4px;
4346 border-bottom-right-radius:
4px;
4348 .pagination
> li
> a:hover,
4349 .pagination
> li
> span:hover,
4350 .pagination
> li
> a:focus,
4351 .pagination
> li
> span:focus {
4353 background-color: #eee;
4356 .pagination
> .active
> a,
4357 .pagination
> .active
> span,
4358 .pagination
> .active
> a:hover,
4359 .pagination
> .active
> span:hover,
4360 .pagination
> .active
> a:focus,
4361 .pagination
> .active
> span:focus {
4365 background-color: #
428bca;
4366 border-color: #
428bca;
4368 .pagination
> .disabled
> span,
4369 .pagination
> .disabled
> span:hover,
4370 .pagination
> .disabled
> span:focus,
4371 .pagination
> .disabled
> a,
4372 .pagination
> .disabled
> a:hover,
4373 .pagination
> .disabled
> a:focus {
4375 cursor: not-allowed;
4376 background-color: #fff;
4379 .pagination-lg
> li
> a,
4380 .pagination-lg
> li
> span {
4384 .pagination-lg
> li:first-child
> a,
4385 .pagination-lg
> li:first-child
> span {
4386 border-top-left-radius:
6px;
4387 border-bottom-left-radius:
6px;
4389 .pagination-lg
> li:last-child
> a,
4390 .pagination-lg
> li:last-child
> span {
4391 border-top-right-radius:
6px;
4392 border-bottom-right-radius:
6px;
4394 .pagination-sm
> li
> a,
4395 .pagination-sm
> li
> span {
4399 .pagination-sm
> li:first-child
> a,
4400 .pagination-sm
> li:first-child
> span {
4401 border-top-left-radius:
3px;
4402 border-bottom-left-radius:
3px;
4404 .pagination-sm
> li:last-child
> a,
4405 .pagination-sm
> li:last-child
> span {
4406 border-top-right-radius:
3px;
4407 border-bottom-right-radius:
3px;
4420 display: inline-block;
4422 background-color: #fff;
4423 border:
1px solid #ddd;
4424 border-radius:
15px;
4426 .pager li
> a:hover,
4427 .pager li
> a:focus {
4428 text-decoration: none;
4429 background-color: #eee;
4432 .pager .next
> span {
4435 .pager .previous
> a,
4436 .pager .previous
> span {
4439 .pager .disabled
> a,
4440 .pager .disabled
> a:hover,
4441 .pager .disabled
> a:focus,
4442 .pager .disabled
> span {
4444 cursor: not-allowed;
4445 background-color: #fff;
4449 padding:
.2em
.6em
.3em;
4455 white-space: nowrap;
4456 vertical-align: baseline;
4457 border-radius:
.25em;
4462 text-decoration: none;
4473 background-color: #
777;
4475 .label-default[href]:hover,
4476 .label-default[href]:focus {
4477 background-color: #
5e5e5e;
4480 background-color: #
428bca;
4482 .label-primary[href]:hover,
4483 .label-primary[href]:focus {
4484 background-color: #
3071a9;
4487 background-color: #
5cb85c;
4489 .label-success[href]:hover,
4490 .label-success[href]:focus {
4491 background-color: #
449d44;
4494 background-color: #
5bc0de;
4496 .label-info[href]:hover,
4497 .label-info[href]:focus {
4498 background-color: #
31b0d5;
4501 background-color: #f0ad4e;
4503 .label-warning[href]:hover,
4504 .label-warning[href]:focus {
4505 background-color: #ec971f;
4508 background-color: #d9534f;
4510 .label-danger[href]:hover,
4511 .label-danger[href]:focus {
4512 background-color: #c9302c;
4515 display: inline-block;
4523 white-space: nowrap;
4524 vertical-align: baseline;
4525 background-color: #
777;
4526 border-radius:
10px;
4542 text-decoration: none;
4545 a.list-group-item.active
> .badge,
4546 .nav-pills
> .active
> a
> .badge {
4548 background-color: #fff;
4550 .nav-pills
> li
> a
> .badge {
4555 margin-bottom:
30px;
4557 background-color: #eee;
4564 margin-bottom:
15px;
4569 border-top-color: #d5d5d5;
4571 .container .jumbotron {
4574 .jumbotron .container {
4577 @media screen and (min-width:
768px) {
4580 padding-bottom:
48px;
4582 .container .jumbotron {
4583 padding-right:
60px;
4594 margin-bottom:
20px;
4595 line-height:
1.42857143;
4596 background-color: #fff;
4597 border:
1px solid #ddd;
4599 -webkit-transition: all
.2s ease-in-out;
4600 -o-transition: all
.2s ease-in-out;
4601 transition: all
.2s ease-in-out;
4604 .thumbnail a
> img {
4610 a.thumbnail.active {
4611 border-color: #
428bca;
4613 .thumbnail .caption {
4619 margin-bottom:
20px;
4620 border:
1px solid transparent;
4627 .alert .alert-link {
4638 .alert-dismissible {
4639 padding-right:
35px;
4641 .alert-dismissable .close,
4642 .alert-dismissible .close {
4650 background-color: #dff0d8;
4651 border-color: #d6e9c6;
4654 border-top-color: #c9e2b3;
4656 .alert-success .alert-link {
4661 background-color: #d9edf7;
4662 border-color: #bce8f1;
4665 border-top-color: #a6e1ec;
4667 .alert-info .alert-link {
4672 background-color: #fcf8e3;
4673 border-color: #faebcc;
4676 border-top-color: #f7e1b5;
4678 .alert-warning .alert-link {
4683 background-color: #f2dede;
4684 border-color: #ebccd1;
4687 border-top-color: #e4b9c0;
4689 .alert-danger .alert-link {
4692 @-webkit-keyframes progress-bar-stripes {
4694 background-position:
40px
0;
4697 background-position:
0 0;
4700 @-o-keyframes progress-bar-stripes {
4702 background-position:
40px
0;
4705 background-position:
0 0;
4708 @keyframes progress-bar-stripes {
4710 background-position:
40px
0;
4713 background-position:
0 0;
4718 margin-bottom:
20px;
4720 background-color: #f5f5f5;
4722 -webkit-box-shadow: inset
0 1px
2px rgba(
0,
0,
0,
.1);
4723 box-shadow: inset
0 1px
2px rgba(
0,
0,
0,
.1);
4733 background-color: #
428bca;
4734 -webkit-box-shadow: inset
0 -
1px
0 rgba(
0,
0,
0,
.15);
4735 box-shadow: inset
0 -
1px
0 rgba(
0,
0,
0,
.15);
4736 -webkit-transition: width
.6s ease;
4737 -o-transition: width
.6s ease;
4738 transition: width
.6s ease;
4740 .progress-striped .progress-bar,
4741 .progress-bar-striped {
4742 background-image: -webkit-linear-gradient(
45deg, rgba(
255,
255,
255,
.15)
25%, transparent
25%, transparent
50%, rgba(
255,
255,
255,
.15)
50%, rgba(
255,
255,
255,
.15)
75%, transparent
75%, transparent);
4743 background-image: -o-linear-gradient(
45deg, rgba(
255,
255,
255,
.15)
25%, transparent
25%, transparent
50%, rgba(
255,
255,
255,
.15)
50%, rgba(
255,
255,
255,
.15)
75%, transparent
75%, transparent);
4744 background-image: linear-gradient(
45deg, rgba(
255,
255,
255,
.15)
25%, transparent
25%, transparent
50%, rgba(
255,
255,
255,
.15)
50%, rgba(
255,
255,
255,
.15)
75%, transparent
75%, transparent);
4745 -webkit-background-size:
40px
40px;
4746 background-size:
40px
40px;
4748 .progress.active .progress-bar,
4749 .progress-bar.active {
4750 -webkit-animation: progress-bar-stripes
2s linear infinite;
4751 -o-animation: progress-bar-stripes
2s linear infinite;
4752 animation: progress-bar-stripes
2s linear infinite;
4754 .progress-bar[
aria-valuenow="
1"],
4755 .progress-bar[
aria-valuenow="
2"] {
4758 .progress-bar[
aria-valuenow="
0"] {
4761 background-color: transparent;
4762 background-image: none;
4763 -webkit-box-shadow: none;
4766 .progress-bar-success {
4767 background-color: #
5cb85c;
4769 .progress-striped .progress-bar-success {
4770 background-image: -webkit-linear-gradient(
45deg, rgba(
255,
255,
255,
.15)
25%, transparent
25%, transparent
50%, rgba(
255,
255,
255,
.15)
50%, rgba(
255,
255,
255,
.15)
75%, transparent
75%, transparent);
4771 background-image: -o-linear-gradient(
45deg, rgba(
255,
255,
255,
.15)
25%, transparent
25%, transparent
50%, rgba(
255,
255,
255,
.15)
50%, rgba(
255,
255,
255,
.15)
75%, transparent
75%, transparent);
4772 background-image: linear-gradient(
45deg, rgba(
255,
255,
255,
.15)
25%, transparent
25%, transparent
50%, rgba(
255,
255,
255,
.15)
50%, rgba(
255,
255,
255,
.15)
75%, transparent
75%, transparent);
4774 .progress-bar-info {
4775 background-color: #
5bc0de;
4777 .progress-striped .progress-bar-info {
4778 background-image: -webkit-linear-gradient(
45deg, rgba(
255,
255,
255,
.15)
25%, transparent
25%, transparent
50%, rgba(
255,
255,
255,
.15)
50%, rgba(
255,
255,
255,
.15)
75%, transparent
75%, transparent);
4779 background-image: -o-linear-gradient(
45deg, rgba(
255,
255,
255,
.15)
25%, transparent
25%, transparent
50%, rgba(
255,
255,
255,
.15)
50%, rgba(
255,
255,
255,
.15)
75%, transparent
75%, transparent);
4780 background-image: linear-gradient(
45deg, rgba(
255,
255,
255,
.15)
25%, transparent
25%, transparent
50%, rgba(
255,
255,
255,
.15)
50%, rgba(
255,
255,
255,
.15)
75%, transparent
75%, transparent);
4782 .progress-bar-warning {
4783 background-color: #f0ad4e;
4785 .progress-striped .progress-bar-warning {
4786 background-image: -webkit-linear-gradient(
45deg, rgba(
255,
255,
255,
.15)
25%, transparent
25%, transparent
50%, rgba(
255,
255,
255,
.15)
50%, rgba(
255,
255,
255,
.15)
75%, transparent
75%, transparent);
4787 background-image: -o-linear-gradient(
45deg, rgba(
255,
255,
255,
.15)
25%, transparent
25%, transparent
50%, rgba(
255,
255,
255,
.15)
50%, rgba(
255,
255,
255,
.15)
75%, transparent
75%, transparent);
4788 background-image: linear-gradient(
45deg, rgba(
255,
255,
255,
.15)
25%, transparent
25%, transparent
50%, rgba(
255,
255,
255,
.15)
50%, rgba(
255,
255,
255,
.15)
75%, transparent
75%, transparent);
4790 .progress-bar-danger {
4791 background-color: #d9534f;
4793 .progress-striped .progress-bar-danger {
4794 background-image: -webkit-linear-gradient(
45deg, rgba(
255,
255,
255,
.15)
25%, transparent
25%, transparent
50%, rgba(
255,
255,
255,
.15)
50%, rgba(
255,
255,
255,
.15)
75%, transparent
75%, transparent);
4795 background-image: -o-linear-gradient(
45deg, rgba(
255,
255,
255,
.15)
25%, transparent
25%, transparent
50%, rgba(
255,
255,
255,
.15)
50%, rgba(
255,
255,
255,
.15)
75%, transparent
75%, transparent);
4796 background-image: linear-gradient(
45deg, rgba(
255,
255,
255,
.15)
25%, transparent
25%, transparent
50%, rgba(
255,
255,
255,
.15)
50%, rgba(
255,
255,
255,
.15)
75%, transparent
75%, transparent);
4807 .media:first-child {
4816 .media
> .pull-left {
4819 .media
> .pull-right {
4828 margin-bottom:
20px;
4834 margin-bottom: -
1px;
4835 background-color: #fff;
4836 border:
1px solid #ddd;
4838 .list-group-item:first-child {
4839 border-top-left-radius:
4px;
4840 border-top-right-radius:
4px;
4842 .list-group-item:last-child {
4844 border-bottom-right-radius:
4px;
4845 border-bottom-left-radius:
4px;
4847 .list-group-item
> .badge {
4850 .list-group-item
> .badge + .badge {
4856 a.list-group-item .list-group-item-heading {
4859 a.list-group-item:hover,
4860 a.list-group-item:focus {
4862 text-decoration: none;
4863 background-color: #f5f5f5;
4865 .list-group-item.disabled,
4866 .list-group-item.disabled:hover,
4867 .list-group-item.disabled:focus {
4869 background-color: #eee;
4871 .list-group-item.disabled .list-group-item-heading,
4872 .list-group-item.disabled:hover .list-group-item-heading,
4873 .list-group-item.disabled:focus .list-group-item-heading {
4876 .list-group-item.disabled .list-group-item-text,
4877 .list-group-item.disabled:hover .list-group-item-text,
4878 .list-group-item.disabled:focus .list-group-item-text {
4881 .list-group-item.active,
4882 .list-group-item.active:hover,
4883 .list-group-item.active:focus {
4886 background-color: #
428bca;
4887 border-color: #
428bca;
4889 .list-group-item.active .list-group-item-heading,
4890 .list-group-item.active:hover .list-group-item-heading,
4891 .list-group-item.active:focus .list-group-item-heading,
4892 .list-group-item.active .list-group-item-heading
> small,
4893 .list-group-item.active:hover .list-group-item-heading
> small,
4894 .list-group-item.active:focus .list-group-item-heading
> small,
4895 .list-group-item.active .list-group-item-heading
> .small,
4896 .list-group-item.active:hover .list-group-item-heading
> .small,
4897 .list-group-item.active:focus .list-group-item-heading
> .small {
4900 .list-group-item.active .list-group-item-text,
4901 .list-group-item.active:hover .list-group-item-text,
4902 .list-group-item.active:focus .list-group-item-text {
4905 .list-group-item-success {
4907 background-color: #dff0d8;
4909 a.list-group-item-success {
4912 a.list-group-item-success .list-group-item-heading {
4915 a.list-group-item-success:hover,
4916 a.list-group-item-success:focus {
4918 background-color: #d0e9c6;
4920 a.list-group-item-success.active,
4921 a.list-group-item-success.active:hover,
4922 a.list-group-item-success.active:focus {
4924 background-color: #
3c763d;
4925 border-color: #
3c763d;
4927 .list-group-item-info {
4929 background-color: #d9edf7;
4931 a.list-group-item-info {
4934 a.list-group-item-info .list-group-item-heading {
4937 a.list-group-item-info:hover,
4938 a.list-group-item-info:focus {
4940 background-color: #c4e3f3;
4942 a.list-group-item-info.active,
4943 a.list-group-item-info.active:hover,
4944 a.list-group-item-info.active:focus {
4946 background-color: #
31708f;
4947 border-color: #
31708f;
4949 .list-group-item-warning {
4951 background-color: #fcf8e3;
4953 a.list-group-item-warning {
4956 a.list-group-item-warning .list-group-item-heading {
4959 a.list-group-item-warning:hover,
4960 a.list-group-item-warning:focus {
4962 background-color: #faf2cc;
4964 a.list-group-item-warning.active,
4965 a.list-group-item-warning.active:hover,
4966 a.list-group-item-warning.active:focus {
4968 background-color: #
8a6d3b;
4969 border-color: #
8a6d3b;
4971 .list-group-item-danger {
4973 background-color: #f2dede;
4975 a.list-group-item-danger {
4978 a.list-group-item-danger .list-group-item-heading {
4981 a.list-group-item-danger:hover,
4982 a.list-group-item-danger:focus {
4984 background-color: #ebcccc;
4986 a.list-group-item-danger.active,
4987 a.list-group-item-danger.active:hover,
4988 a.list-group-item-danger.active:focus {
4990 background-color: #a94442;
4991 border-color: #a94442;
4993 .list-group-item-heading {
4997 .list-group-item-text {
5002 margin-bottom:
20px;
5003 background-color: #fff;
5004 border:
1px solid transparent;
5006 -webkit-box-shadow:
0 1px
1px rgba(
0,
0,
0,
.05);
5007 box-shadow:
0 1px
1px rgba(
0,
0,
0,
.05);
5014 border-bottom:
1px solid transparent;
5015 border-top-left-radius:
3px;
5016 border-top-right-radius:
3px;
5018 .panel-heading
> .dropdown .dropdown-toggle {
5032 background-color: #f5f5f5;
5033 border-top:
1px solid #ddd;
5034 border-bottom-right-radius:
3px;
5035 border-bottom-left-radius:
3px;
5037 .panel
> .list-group {
5040 .panel
> .list-group .list-group-item {
5041 border-width:
1px
0;
5044 .panel
> .list-group:first-child .list-group-item:first-child {
5046 border-top-left-radius:
3px;
5047 border-top-right-radius:
3px;
5049 .panel
> .list-group:last-child .list-group-item:last-child {
5051 border-bottom-right-radius:
3px;
5052 border-bottom-left-radius:
3px;
5054 .panel-heading + .list-group .list-group-item:first-child {
5055 border-top-width:
0;
5057 .list-group + .panel-footer {
5058 border-top-width:
0;
5061 .panel
> .table-responsive
> .table,
5062 .panel
> .panel-collapse
> .table {
5065 .panel
> .table:first-child,
5066 .panel
> .table-responsive:first-child
> .table:first-child {
5067 border-top-left-radius:
3px;
5068 border-top-right-radius:
3px;
5070 .panel
> .table:first-child
> thead:first-child
> tr:first-child td:first-child,
5071 .panel
> .table-responsive:first-child
> .table:first-child
> thead:first-child
> tr:first-child td:first-child,
5072 .panel
> .table:first-child
> tbody:first-child
> tr:first-child td:first-child,
5073 .panel
> .table-responsive:first-child
> .table:first-child
> tbody:first-child
> tr:first-child td:first-child,
5074 .panel
> .table:first-child
> thead:first-child
> tr:first-child th:first-child,
5075 .panel
> .table-responsive:first-child
> .table:first-child
> thead:first-child
> tr:first-child th:first-child,
5076 .panel
> .table:first-child
> tbody:first-child
> tr:first-child th:first-child,
5077 .panel
> .table-responsive:first-child
> .table:first-child
> tbody:first-child
> tr:first-child th:first-child {
5078 border-top-left-radius:
3px;
5080 .panel
> .table:first-child
> thead:first-child
> tr:first-child td:last-child,
5081 .panel
> .table-responsive:first-child
> .table:first-child
> thead:first-child
> tr:first-child td:last-child,
5082 .panel
> .table:first-child
> tbody:first-child
> tr:first-child td:last-child,
5083 .panel
> .table-responsive:first-child
> .table:first-child
> tbody:first-child
> tr:first-child td:last-child,
5084 .panel
> .table:first-child
> thead:first-child
> tr:first-child th:last-child,
5085 .panel
> .table-responsive:first-child
> .table:first-child
> thead:first-child
> tr:first-child th:last-child,
5086 .panel
> .table:first-child
> tbody:first-child
> tr:first-child th:last-child,
5087 .panel
> .table-responsive:first-child
> .table:first-child
> tbody:first-child
> tr:first-child th:last-child {
5088 border-top-right-radius:
3px;
5090 .panel
> .table:last-child,
5091 .panel
> .table-responsive:last-child
> .table:last-child {
5092 border-bottom-right-radius:
3px;
5093 border-bottom-left-radius:
3px;
5095 .panel
> .table:last-child
> tbody:last-child
> tr:last-child td:first-child,
5096 .panel
> .table-responsive:last-child
> .table:last-child
> tbody:last-child
> tr:last-child td:first-child,
5097 .panel
> .table:last-child
> tfoot:last-child
> tr:last-child td:first-child,
5098 .panel
> .table-responsive:last-child
> .table:last-child
> tfoot:last-child
> tr:last-child td:first-child,
5099 .panel
> .table:last-child
> tbody:last-child
> tr:last-child th:first-child,
5100 .panel
> .table-responsive:last-child
> .table:last-child
> tbody:last-child
> tr:last-child th:first-child,
5101 .panel
> .table:last-child
> tfoot:last-child
> tr:last-child th:first-child,
5102 .panel
> .table-responsive:last-child
> .table:last-child
> tfoot:last-child
> tr:last-child th:first-child {
5103 border-bottom-left-radius:
3px;
5105 .panel
> .table:last-child
> tbody:last-child
> tr:last-child td:last-child,
5106 .panel
> .table-responsive:last-child
> .table:last-child
> tbody:last-child
> tr:last-child td:last-child,
5107 .panel
> .table:last-child
> tfoot:last-child
> tr:last-child td:last-child,
5108 .panel
> .table-responsive:last-child
> .table:last-child
> tfoot:last-child
> tr:last-child td:last-child,
5109 .panel
> .table:last-child
> tbody:last-child
> tr:last-child th:last-child,
5110 .panel
> .table-responsive:last-child
> .table:last-child
> tbody:last-child
> tr:last-child th:last-child,
5111 .panel
> .table:last-child
> tfoot:last-child
> tr:last-child th:last-child,
5112 .panel
> .table-responsive:last-child
> .table:last-child
> tfoot:last-child
> tr:last-child th:last-child {
5113 border-bottom-right-radius:
3px;
5115 .panel
> .panel-body + .table,
5116 .panel
> .panel-body + .table-responsive {
5117 border-top:
1px solid #ddd;
5119 .panel
> .table
> tbody:first-child
> tr:first-child th,
5120 .panel
> .table
> tbody:first-child
> tr:first-child td {
5123 .panel
> .table-bordered,
5124 .panel
> .table-responsive
> .table-bordered {
5127 .panel
> .table-bordered
> thead
> tr
> th:first-child,
5128 .panel
> .table-responsive
> .table-bordered
> thead
> tr
> th:first-child,
5129 .panel
> .table-bordered
> tbody
> tr
> th:first-child,
5130 .panel
> .table-responsive
> .table-bordered
> tbody
> tr
> th:first-child,
5131 .panel
> .table-bordered
> tfoot
> tr
> th:first-child,
5132 .panel
> .table-responsive
> .table-bordered
> tfoot
> tr
> th:first-child,
5133 .panel
> .table-bordered
> thead
> tr
> td:first-child,
5134 .panel
> .table-responsive
> .table-bordered
> thead
> tr
> td:first-child,
5135 .panel
> .table-bordered
> tbody
> tr
> td:first-child,
5136 .panel
> .table-responsive
> .table-bordered
> tbody
> tr
> td:first-child,
5137 .panel
> .table-bordered
> tfoot
> tr
> td:first-child,
5138 .panel
> .table-responsive
> .table-bordered
> tfoot
> tr
> td:first-child {
5141 .panel
> .table-bordered
> thead
> tr
> th:last-child,
5142 .panel
> .table-responsive
> .table-bordered
> thead
> tr
> th:last-child,
5143 .panel
> .table-bordered
> tbody
> tr
> th:last-child,
5144 .panel
> .table-responsive
> .table-bordered
> tbody
> tr
> th:last-child,
5145 .panel
> .table-bordered
> tfoot
> tr
> th:last-child,
5146 .panel
> .table-responsive
> .table-bordered
> tfoot
> tr
> th:last-child,
5147 .panel
> .table-bordered
> thead
> tr
> td:last-child,
5148 .panel
> .table-responsive
> .table-bordered
> thead
> tr
> td:last-child,
5149 .panel
> .table-bordered
> tbody
> tr
> td:last-child,
5150 .panel
> .table-responsive
> .table-bordered
> tbody
> tr
> td:last-child,
5151 .panel
> .table-bordered
> tfoot
> tr
> td:last-child,
5152 .panel
> .table-responsive
> .table-bordered
> tfoot
> tr
> td:last-child {
5155 .panel
> .table-bordered
> thead
> tr:first-child
> td,
5156 .panel
> .table-responsive
> .table-bordered
> thead
> tr:first-child
> td,
5157 .panel
> .table-bordered
> tbody
> tr:first-child
> td,
5158 .panel
> .table-responsive
> .table-bordered
> tbody
> tr:first-child
> td,
5159 .panel
> .table-bordered
> thead
> tr:first-child
> th,
5160 .panel
> .table-responsive
> .table-bordered
> thead
> tr:first-child
> th,
5161 .panel
> .table-bordered
> tbody
> tr:first-child
> th,
5162 .panel
> .table-responsive
> .table-bordered
> tbody
> tr:first-child
> th {
5165 .panel
> .table-bordered
> tbody
> tr:last-child
> td,
5166 .panel
> .table-responsive
> .table-bordered
> tbody
> tr:last-child
> td,
5167 .panel
> .table-bordered
> tfoot
> tr:last-child
> td,
5168 .panel
> .table-responsive
> .table-bordered
> tfoot
> tr:last-child
> td,
5169 .panel
> .table-bordered
> tbody
> tr:last-child
> th,
5170 .panel
> .table-responsive
> .table-bordered
> tbody
> tr:last-child
> th,
5171 .panel
> .table-bordered
> tfoot
> tr:last-child
> th,
5172 .panel
> .table-responsive
> .table-bordered
> tfoot
> tr:last-child
> th {
5175 .panel
> .table-responsive {
5180 margin-bottom:
20px;
5182 .panel-group .panel {
5186 .panel-group .panel + .panel {
5189 .panel-group .panel-heading {
5192 .panel-group .panel-heading + .panel-collapse
> .panel-body {
5193 border-top:
1px solid #ddd;
5195 .panel-group .panel-footer {
5198 .panel-group .panel-footer + .panel-collapse .panel-body {
5199 border-bottom:
1px solid #ddd;
5204 .panel-default
> .panel-heading {
5206 background-color: #f5f5f5;
5209 .panel-default
> .panel-heading + .panel-collapse
> .panel-body {
5210 border-top-color: #ddd;
5212 .panel-default
> .panel-heading .badge {
5214 background-color: #
333;
5216 .panel-default
> .panel-footer + .panel-collapse
> .panel-body {
5217 border-bottom-color: #ddd;
5220 border-color: #
428bca;
5222 .panel-primary
> .panel-heading {
5224 background-color: #
428bca;
5225 border-color: #
428bca;
5227 .panel-primary
> .panel-heading + .panel-collapse
> .panel-body {
5228 border-top-color: #
428bca;
5230 .panel-primary
> .panel-heading .badge {
5232 background-color: #fff;
5234 .panel-primary
> .panel-footer + .panel-collapse
> .panel-body {
5235 border-bottom-color: #
428bca;
5238 border-color: #d6e9c6;
5240 .panel-success
> .panel-heading {
5242 background-color: #dff0d8;
5243 border-color: #d6e9c6;
5245 .panel-success
> .panel-heading + .panel-collapse
> .panel-body {
5246 border-top-color: #d6e9c6;
5248 .panel-success
> .panel-heading .badge {
5250 background-color: #
3c763d;
5252 .panel-success
> .panel-footer + .panel-collapse
> .panel-body {
5253 border-bottom-color: #d6e9c6;
5256 border-color: #bce8f1;
5258 .panel-info
> .panel-heading {
5260 background-color: #d9edf7;
5261 border-color: #bce8f1;
5263 .panel-info
> .panel-heading + .panel-collapse
> .panel-body {
5264 border-top-color: #bce8f1;
5266 .panel-info
> .panel-heading .badge {
5268 background-color: #
31708f;
5270 .panel-info
> .panel-footer + .panel-collapse
> .panel-body {
5271 border-bottom-color: #bce8f1;
5274 border-color: #faebcc;
5276 .panel-warning
> .panel-heading {
5278 background-color: #fcf8e3;
5279 border-color: #faebcc;
5281 .panel-warning
> .panel-heading + .panel-collapse
> .panel-body {
5282 border-top-color: #faebcc;
5284 .panel-warning
> .panel-heading .badge {
5286 background-color: #
8a6d3b;
5288 .panel-warning
> .panel-footer + .panel-collapse
> .panel-body {
5289 border-bottom-color: #faebcc;
5292 border-color: #ebccd1;
5294 .panel-danger
> .panel-heading {
5296 background-color: #f2dede;
5297 border-color: #ebccd1;
5299 .panel-danger
> .panel-heading + .panel-collapse
> .panel-body {
5300 border-top-color: #ebccd1;
5302 .panel-danger
> .panel-heading .badge {
5304 background-color: #a94442;
5306 .panel-danger
> .panel-footer + .panel-collapse
> .panel-body {
5307 border-bottom-color: #ebccd1;
5316 .embed-responsive .embed-responsive-item,
5317 .embed-responsive iframe,
5318 .embed-responsive embed,
5319 .embed-responsive object {
5328 .embed-responsive.embed-responsive-
16by9 {
5329 padding-bottom:
56.25%;
5331 .embed-responsive.embed-responsive-
4by3 {
5332 padding-bottom:
75%;
5337 margin-bottom:
20px;
5338 background-color: #f5f5f5;
5339 border:
1px solid #e3e3e3;
5341 -webkit-box-shadow: inset
0 1px
1px rgba(
0,
0,
0,
.05);
5342 box-shadow: inset
0 1px
1px rgba(
0,
0,
0,
.05);
5346 border-color: rgba(
0,
0,
0,
.15);
5362 text-shadow:
0 1px
0 #fff;
5363 filter: alpha(opacity=
20);
5369 text-decoration: none;
5371 filter: alpha(opacity=
50);
5375 -webkit-appearance: none;
5378 background: transparent;
5393 -webkit-overflow-scrolling: touch;
5396 .modal.fade .modal-dialog {
5397 -webkit-transition: -webkit-transform
.3s ease-out;
5398 -o-transition: -o-transform
.3s ease-out;
5399 transition: transform
.3s ease-out;
5400 -webkit-transform: translate3d(
0, -
25%,
0);
5401 -o-transform: translate3d(
0, -
25%,
0);
5402 transform: translate3d(
0, -
25%,
0);
5404 .modal.in .modal-dialog {
5405 -webkit-transform: translate3d(
0,
0,
0);
5406 -o-transform: translate3d(
0,
0,
0);
5407 transform: translate3d(
0,
0,
0);
5409 .modal-open .modal {
5420 background-color: #fff;
5421 -webkit-background-clip: padding-box;
5422 background-clip: padding-box;
5423 border:
1px solid #
999;
5424 border:
1px solid rgba(
0,
0,
0,
.2);
5427 -webkit-box-shadow:
0 3px
9px rgba(
0,
0,
0,
.5);
5428 box-shadow:
0 3px
9px rgba(
0,
0,
0,
.5);
5437 background-color: #
000;
5439 .modal-backdrop.fade {
5440 filter: alpha(opacity=
0);
5443 .modal-backdrop.in {
5444 filter: alpha(opacity=
50);
5448 min-height:
16.42857143px;
5450 border-bottom:
1px solid #e5e5e5;
5452 .modal-header .close {
5457 line-height:
1.42857143;
5466 border-top:
1px solid #e5e5e5;
5468 .modal-footer .btn + .btn {
5472 .modal-footer .btn-group .btn + .btn {
5475 .modal-footer .btn-block + .btn-block {
5478 .modal-scrollbar-measure {
5485 @media (min-width:
768px) {
5491 -webkit-box-shadow:
0 5px
15px rgba(
0,
0,
0,
.5);
5492 box-shadow:
0 5px
15px rgba(
0,
0,
0,
.5);
5498 @media (min-width:
992px) {
5509 visibility: visible;
5510 filter: alpha(opacity=
0);
5514 filter: alpha(opacity=
90);
5538 text-decoration: none;
5539 background-color: #
000;
5546 border-color: transparent;
5547 border-style: solid;
5549 .tooltip.top .tooltip-arrow {
5553 border-width:
5px
5px
0;
5554 border-top-color: #
000;
5556 .tooltip.top-left .tooltip-arrow {
5559 border-width:
5px
5px
0;
5560 border-top-color: #
000;
5562 .tooltip.top-right .tooltip-arrow {
5565 border-width:
5px
5px
0;
5566 border-top-color: #
000;
5568 .tooltip.right .tooltip-arrow {
5572 border-width:
5px
5px
5px
0;
5573 border-right-color: #
000;
5575 .tooltip.left .tooltip-arrow {
5579 border-width:
5px
0 5px
5px;
5580 border-left-color: #
000;
5582 .tooltip.bottom .tooltip-arrow {
5586 border-width:
0 5px
5px;
5587 border-bottom-color: #
000;
5589 .tooltip.bottom-left .tooltip-arrow {
5592 border-width:
0 5px
5px;
5593 border-bottom-color: #
000;
5595 .tooltip.bottom-right .tooltip-arrow {
5598 border-width:
0 5px
5px;
5599 border-bottom-color: #
000;
5610 white-space: normal;
5611 background-color: #fff;
5612 -webkit-background-clip: padding-box;
5613 background-clip: padding-box;
5614 border:
1px solid #ccc;
5615 border:
1px solid rgba(
0,
0,
0,
.2);
5617 -webkit-box-shadow:
0 5px
10px rgba(
0,
0,
0,
.2);
5618 box-shadow:
0 5px
10px rgba(
0,
0,
0,
.2);
5636 font-weight: normal;
5638 background-color: #f7f7f7;
5639 border-bottom:
1px solid #ebebeb;
5640 border-radius:
5px
5px
0 0;
5646 .popover
> .arrow:after {
5651 border-color: transparent;
5652 border-style: solid;
5657 .popover
> .arrow:after {
5661 .popover.top
> .arrow {
5665 border-top-color: #
999;
5666 border-top-color: rgba(
0,
0,
0,
.25);
5667 border-bottom-width:
0;
5669 .popover.top
> .arrow:after {
5673 border-top-color: #fff;
5674 border-bottom-width:
0;
5676 .popover.right
> .arrow {
5680 border-right-color: #
999;
5681 border-right-color: rgba(
0,
0,
0,
.25);
5682 border-left-width:
0;
5684 .popover.right
> .arrow:after {
5688 border-right-color: #fff;
5689 border-left-width:
0;
5691 .popover.bottom
> .arrow {
5695 border-top-width:
0;
5696 border-bottom-color: #
999;
5697 border-bottom-color: rgba(
0,
0,
0,
.25);
5699 .popover.bottom
> .arrow:after {
5703 border-top-width:
0;
5704 border-bottom-color: #fff;
5706 .popover.left
> .arrow {
5710 border-right-width:
0;
5711 border-left-color: #
999;
5712 border-left-color: rgba(
0,
0,
0,
.25);
5714 .popover.left
> .arrow:after {
5718 border-right-width:
0;
5719 border-left-color: #fff;
5729 .carousel-inner
> .item {
5732 -webkit-transition:
.6s ease-in-out left;
5733 -o-transition:
.6s ease-in-out left;
5734 transition:
.6s ease-in-out left;
5736 .carousel-inner
> .item
> img,
5737 .carousel-inner
> .item
> a
> img {
5740 .carousel-inner
> .active,
5741 .carousel-inner
> .next,
5742 .carousel-inner
> .prev {
5745 .carousel-inner
> .active {
5748 .carousel-inner
> .next,
5749 .carousel-inner
> .prev {
5754 .carousel-inner
> .next {
5757 .carousel-inner
> .prev {
5760 .carousel-inner
> .next.left,
5761 .carousel-inner
> .prev.right {
5764 .carousel-inner
> .active.left {
5767 .carousel-inner
> .active.right {
5779 text-shadow:
0 1px
2px rgba(
0,
0,
0,
.6);
5780 filter: alpha(opacity=
50);
5783 .carousel-control.left {
5784 background-image: -webkit-linear-gradient(left, rgba(
0,
0,
0,
.5)
0%, rgba(
0,
0,
0,
.0001)
100%);
5785 background-image: -o-linear-gradient(left, rgba(
0,
0,
0,
.5)
0%, rgba(
0,
0,
0,
.0001)
100%);
5786 background-image: -webkit-gradient(linear, left top, right top, from(rgba(
0,
0,
0,
.5)), to(rgba(
0,
0,
0,
.0001)));
5787 background-image: linear-gradient(to right, rgba(
0,
0,
0,
.5)
0%, rgba(
0,
0,
0,
.0001)
100%);
5788 filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#
80000000', endColorstr='#
00000000', GradientType=
1);
5789 background-repeat: repeat-x;
5791 .carousel-control.right {
5794 background-image: -webkit-linear-gradient(left, rgba(
0,
0,
0,
.0001)
0%, rgba(
0,
0,
0,
.5)
100%);
5795 background-image: -o-linear-gradient(left, rgba(
0,
0,
0,
.0001)
0%, rgba(
0,
0,
0,
.5)
100%);
5796 background-image: -webkit-gradient(linear, left top, right top, from(rgba(
0,
0,
0,
.0001)), to(rgba(
0,
0,
0,
.5)));
5797 background-image: linear-gradient(to right, rgba(
0,
0,
0,
.0001)
0%, rgba(
0,
0,
0,
.5)
100%);
5798 filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#
00000000', endColorstr='#
80000000', GradientType=
1);
5799 background-repeat: repeat-x;
5801 .carousel-control:hover,
5802 .carousel-control:focus {
5804 text-decoration: none;
5805 filter: alpha(opacity=
90);
5809 .carousel-control .icon-prev,
5810 .carousel-control .icon-next,
5811 .carousel-control .glyphicon-chevron-left,
5812 .carousel-control .glyphicon-chevron-right {
5816 display: inline-block;
5818 .carousel-control .icon-prev,
5819 .carousel-control .glyphicon-chevron-left {
5823 .carousel-control .icon-next,
5824 .carousel-control .glyphicon-chevron-right {
5826 margin-right: -
10px;
5828 .carousel-control .icon-prev,
5829 .carousel-control .icon-next {
5835 .carousel-control .icon-prev:before {
5838 .carousel-control .icon-next:before {
5841 .carousel-indicators {
5852 .carousel-indicators li {
5853 display: inline-block;
5857 text-indent: -
999px;
5859 background-color: #
000 \
9;
5860 background-color: rgba(
0,
0,
0,
0);
5861 border:
1px solid #fff;
5862 border-radius:
10px;
5864 .carousel-indicators .active {
5868 background-color: #fff;
5877 padding-bottom:
20px;
5880 text-shadow:
0 1px
2px rgba(
0,
0,
0,
.6);
5882 .carousel-caption .btn {
5885 @media screen and (min-width:
768px) {
5886 .carousel-control .glyphicon-chevron-left,
5887 .carousel-control .glyphicon-chevron-right,
5888 .carousel-control .icon-prev,
5889 .carousel-control .icon-next {
5895 .carousel-control .glyphicon-chevron-left,
5896 .carousel-control .icon-prev {
5899 .carousel-control .glyphicon-chevron-right,
5900 .carousel-control .icon-next {
5901 margin-right: -
15px;
5906 padding-bottom:
30px;
5908 .carousel-indicators {
5914 .dl-horizontal dd:before,
5915 .dl-horizontal dd:after,
5918 .container-fluid:before,
5919 .container-fluid:after,
5922 .form-horizontal .form-group:before,
5923 .form-horizontal .form-group:after,
5924 .btn-toolbar:before,
5926 .btn-group-vertical
> .btn-group:before,
5927 .btn-group-vertical
> .btn-group:after,
5932 .navbar-header:before,
5933 .navbar-header:after,
5934 .navbar-collapse:before,
5935 .navbar-collapse:after,
5940 .modal-footer:before,
5941 .modal-footer:after {
5946 .dl-horizontal dd:after,
5948 .container-fluid:after,
5950 .form-horizontal .form-group:after,
5952 .btn-group-vertical
> .btn-group:after,
5955 .navbar-header:after,
5956 .navbar-collapse:after,
5959 .modal-footer:after {
5968 float: right !important;
5971 float: left !important;
5974 display: none !important;
5977 display: block !important;
5986 background-color: transparent;
5990 display: none !important;
5991 visibility: hidden !important;
5995 -webkit-transform: translate3d(
0,
0,
0);
5996 -o-transform: translate3d(
0,
0,
0);
5997 transform: translate3d(
0,
0,
0);
6000 width: device-width;
6006 display: none !important;
6010 .visible-xs-inline-block,
6013 .visible-sm-inline-block,
6016 .visible-md-inline-block,
6019 .visible-lg-inline-block {
6020 display: none !important;
6022 @media (max-width:
767px) {
6024 display: block !important;
6030 display: table-row !important;
6034 display: table-cell !important;
6037 @media (max-width:
767px) {
6039 display: block !important;
6042 @media (max-width:
767px) {
6043 .visible-xs-inline {
6044 display: inline !important;
6047 @media (max-width:
767px) {
6048 .visible-xs-inline-block {
6049 display: inline-block !important;
6052 @media (min-width:
768px) and (max-width:
991px) {
6054 display: block !important;
6060 display: table-row !important;
6064 display: table-cell !important;
6067 @media (min-width:
768px) and (max-width:
991px) {
6069 display: block !important;
6072 @media (min-width:
768px) and (max-width:
991px) {
6073 .visible-sm-inline {
6074 display: inline !important;
6077 @media (min-width:
768px) and (max-width:
991px) {
6078 .visible-sm-inline-block {
6079 display: inline-block !important;
6082 @media (min-width:
992px) and (max-width:
1199px) {
6084 display: block !important;
6090 display: table-row !important;
6094 display: table-cell !important;
6097 @media (min-width:
992px) and (max-width:
1199px) {
6099 display: block !important;
6102 @media (min-width:
992px) and (max-width:
1199px) {
6103 .visible-md-inline {
6104 display: inline !important;
6107 @media (min-width:
992px) and (max-width:
1199px) {
6108 .visible-md-inline-block {
6109 display: inline-block !important;
6112 @media (min-width:
1200px) {
6114 display: block !important;
6120 display: table-row !important;
6124 display: table-cell !important;
6127 @media (min-width:
1200px) {
6129 display: block !important;
6132 @media (min-width:
1200px) {
6133 .visible-lg-inline {
6134 display: inline !important;
6137 @media (min-width:
1200px) {
6138 .visible-lg-inline-block {
6139 display: inline-block !important;
6142 @media (max-width:
767px) {
6144 display: none !important;
6147 @media (min-width:
768px) and (max-width:
991px) {
6149 display: none !important;
6152 @media (min-width:
992px) and (max-width:
1199px) {
6154 display: none !important;
6157 @media (min-width:
1200px) {
6159 display: none !important;
6163 display: none !important;
6167 display: block !important;
6169 table.visible-print {
6173 display: table-row !important;
6177 display: table-cell !important;
6180 .visible-print-block {
6181 display: none !important;
6184 .visible-print-block {
6185 display: block !important;
6188 .visible-print-inline {
6189 display: none !important;
6192 .visible-print-inline {
6193 display: inline !important;
6196 .visible-print-inline-block {
6197 display: none !important;
6200 .visible-print-inline-block {
6201 display: inline-block !important;
6206 display: none !important;
6209 /*# sourceMappingURL=bootstrap.css.map */
6211 <meta content=
"Mnemonic code for generating deterministic keys" name=
"description"/>
6212 <meta content=
"width=device-width, initial-scale=1.0" name=
"viewport" />
6213 <meta content=
"bitcoin mnemonic converter" name=
"description" />
6214 <meta content=
"DC POS" name=
"author" />
6218 padding-bottom:
32px;
6220 .form-control[readonly] {
6223 .feedback-container {
6233 background-color: orange;
6237 border:
2px solid #
555;
6239 border-bottom-left-radius:
20px
20px;
6240 border-bottom-right-radius:
20px
20px;
6245 <div class=
"container">
6247 <h1 class=
"text-center">Mnemonic Code Converter
</h1>
6250 <div class=
"col-md-12">
6252 <form class=
"form-horizontal" role=
"form">
6253 <div class=
"col-sm-2"></div>
6254 <div class=
"col-sm-10">
6255 <p>You can enter an existing BIP39 mnemonic, or generate a new random one. Typing your own twelve words will probably not work how you expect, since the words require a particular structure (the last word is a checksum)
</p>
6256 <p>For more info see the
<a href=
"https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki" target=
"_blank">BIP39 spec
</a></p>
6258 <div class=
"form-group">
6259 <label for=
"phrase" class=
"col-sm-2 control-label">BIP39 Mnemonic
</label>
6260 <div class=
"col-sm-10">
6261 <textarea id=
"phrase" class=
"phrase form-control"></textarea>
6264 <div class=
"form-group">
6265 <label for=
"strength" class=
"col-sm-2 control-label">Number of words
</label>
6266 <div class=
"col-sm-10">
6267 <div class=
"input-group">
6268 <input type=
"number" class=
"strength form-control" id=
"strength" value=
"12">
6269 <span class=
"input-group-btn">
6270 <button class=
"btn generate">Generate Random Mnemonic
</button>
6275 <div class=
"form-group">
6276 <label for=
"passphrase" class=
"col-sm-2 control-label">BIP39 Passphrase (optional)
</label>
6277 <div class=
"col-sm-10">
6278 <textarea id=
"passphrase" class=
"passphrase form-control"></textarea>
6281 <div class=
"form-group">
6282 <label for=
"network-phrase" class=
"col-sm-2 control-label">Coin
</label>
6283 <div class=
"col-sm-10">
6284 <select id=
"network-phrase" class=
"network form-control">
6285 <option value=
"bitcoin">Bitcoin
</option>
6286 <option value=
"bitcoin-testnet">Bitcoin Testnet
</option>
6287 <option value=
"litecoin">Litecoin
</option>
6288 <option value=
"dogecoin">Dogecoin
</option>
6292 <div class=
"form-group">
6293 <label for=
"root-key" class=
"col-sm-2 control-label">BIP32 Root Key
</label>
6294 <div class=
"col-sm-10">
6295 <textarea id=
"root-key" class=
"root-key form-control" readonly=
"readonly"></textarea>
6305 <div class=
"col-md-12">
6306 <h2>Derivation Path
</h2>
6307 <ul class=
"derivation-type nav nav-tabs" role=
"tablist">
6308 <li id=
"hive-tab" class=
"active">
6309 <a href=
"#hive" role=
"tab" data-toggle=
"tab">Hive Wallet
</a>
6311 <li id=
"mycelium-tab">
6312 <a href=
"#mycelium" role=
"tab" data-toggle=
"tab">Mycelium Wallet
</a>
6315 <a href=
"#bip44" role=
"tab" data-toggle=
"tab">BIP44
</a>
6318 <a href=
"#bip32" role=
"tab" data-toggle=
"tab">BIP32
</a>
6321 <div class=
"derivation-type tab-content">
6322 <div id=
"hive" class=
"tab-pane active">
6323 <form class=
"form-horizontal" role=
"form">
6325 <div class=
"col-sm-2"></div>
6326 <div class=
"col-sm-10">
6327 <p>For more info see the
<a href=
"https://www.hivewallet.com/" target=
"_blank">Hive Wallet homepage
</a></p>
6329 <div class=
"form-group">
6330 <label for=
"hive-path" class=
"col-sm-2 control-label">BIP32 Derivation Path
</label>
6331 <div class=
"col-sm-10">
6332 <input id=
"hive-path" type=
"text" class=
"path form-control" value=
"m/0'/0" readonly=
"readonly">
6337 <div id=
"mycelium" class=
"tab-pane">
6338 <form class=
"form-horizontal" role=
"form">
6340 <div class=
"col-sm-2"></div>
6341 <div class=
"col-sm-10">
6342 <p>For more info see the
<a href=
"http://www.mycelium.com/" target=
"_blank">Mycelium Wallet homepage
</a></p>
6344 <div class=
"form-group">
6345 <label for=
"mycelium-path" class=
"col-sm-2 control-label">BIP32 Derivation Path
</label>
6346 <div class=
"col-sm-10">
6347 <input id=
"mycelium-path" type=
"text" class=
"path form-control" value=
"m/44'/0'/0'/0" readonly=
"readonly">
6352 <div id=
"bip44" class=
"tab-pane">
6353 <form class=
"form-horizontal" role=
"form">
6355 <div class=
"col-sm-2"></div>
6356 <div class=
"col-sm-10">
6357 <p>For more info see the
<a href=
"https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki" target=
"_blank">BIP44 spec
</a></p>
6359 <div class=
"form-group">
6360 <label for=
"purpose" class=
"col-sm-2 control-label">
6361 <a href=
"https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#purpose" target=
"_blank">Purpose
</a>
6363 <div class=
"col-sm-10">
6364 <input id=
"purpose" type=
"text" class=
"purpose form-control" value=
"44">
6367 <div class=
"form-group">
6368 <label for=
"coin" class=
"col-sm-2 control-label">
6369 <a href=
"https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#registered-coin-types" target=
"_blank">Coin
</a>
6371 <div class=
"col-sm-10">
6372 <input id=
"coin" type=
"text" class=
"coin form-control" value=
"0">
6375 <div class=
"form-group">
6376 <label for=
"account" class=
"col-sm-2 control-label">
6377 <a href=
"https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#account" target=
"_blank">Account
</a>
6379 <div class=
"col-sm-10">
6380 <input id=
"account" type=
"text" class=
"account form-control" value=
"0">
6383 <div class=
"form-group">
6384 <label for=
"change" class=
"col-sm-2 control-label">
6385 <a href=
"https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#change" target=
"_blank">External / Internal
</a>
6387 <div class=
"col-sm-10">
6388 <input id=
"change" type=
"text" class=
"change form-control" value=
"0">
6391 <div class=
"form-group">
6392 <label for=
"bip44-path" class=
"col-sm-2 control-label">BIP32 Derivation Path
</label>
6393 <div class=
"col-sm-10">
6394 <input id=
"bip44-path" type=
"text" class=
"path form-control" value=
"m/44'/0'/0'/0" readonly=
"readonly">
6399 <div id=
"bip32" class=
"tab-pane">
6400 <form class=
"form-horizontal" role=
"form">
6402 <div class=
"col-sm-2"></div>
6403 <div class=
"col-sm-10">
6404 <p>For more info see the
<a href=
"https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki" target=
"_blank">BIP32 spec
</a></p>
6406 <div class=
"form-group">
6407 <label for=
"bip32-path" class=
"col-sm-2 control-label">BIP32 Derivation Path
</label>
6408 <div class=
"col-sm-10">
6409 <input id=
"bip32-path" type=
"text" class=
"path form-control" value=
"m/0">
6415 <form class=
"form-horizontal" role=
"form">
6416 <div class=
"form-group">
6417 <label for=
"extended-priv-key" class=
"col-sm-2 control-label">BIP32 Extended Key
</label>
6418 <div class=
"col-sm-10">
6419 <textarea id=
"extended-priv-key" class=
"extended-priv-key form-control" readonly=
"readonly"></textarea>
6422 <div class=
"form-group">
6423 <label for=
"extended-pub-key" class=
"col-sm-2 control-label">BIP32 Extended Key (addresses only)
</label>
6424 <div class=
"col-sm-10">
6425 <textarea id=
"extended-pub-key" class=
"extended-pub-key form-control" readonly=
"readonly"></textarea>
6435 <div class=
"col-md-12">
6436 <h2>Derived Addresses
</h2>
6437 <p>Note these addreses are derived from the
<strong>BIP32 Extended Key
</strong></p>
6438 <table class=
"table table-striped">
6441 <div class=
"input-group">
6443 <button class=
"index-toggle">Toggle
</button>
6447 <div class=
"input-group">
6449 <button class=
"address-toggle">Toggle
</button>
6453 <div class=
"input-group">
6454 Private Key
6455 <button class=
"private-key-toggle">Toggle
</button>
6459 <tbody class=
"addresses">
6460 <tr><td> </td><td> </td><td> </td></tr>
6461 <tr><td> </td><td> </td><td> </td></tr>
6462 <tr><td> </td><td> </td><td> </td></tr>
6463 <tr><td> </td><td> </td><td> </td></tr>
6464 <tr><td> </td><td> </td><td> </td></tr>
6469 <span>Show next
</button>
6470 <input type=
"number" class=
"rows-to-add" value=
"20">
6471 <button class=
"more">Show
</button>
6476 <div class=
"col-md-12">
6478 <h3>BIP39
<span class=
"small">Mnemonic code for generating deterministic keys
</span></h3>
6481 <a href=
"https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki">official BIP39 spec
</a>
6483 <h3>BIP32
<span class=
"small">Hierarchical Deterministic Wallets
</span></h3>
6486 <a href=
"https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki" target=
"_blank">official BIP32 spec
</a>
6488 <a href=
"http://bip32.org/" target=
"_blank">bip32.org
</a>
6490 <h3>BIP44
<span class=
"small">Multi-Account Hierarchy for Deterministic Wallets
</span></h3>
6493 <a href=
"https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki" target=
"_blank">official BIP44 spec
</a>
6495 <h3>Private Keys
</h3>
6498 <a href=
"https://brainwallet.github.io/" target=
"_blank">brainwallet.org
</a>,
6499 but be careful - it can be easy to make mistakes if you
6500 don't know what you're doing
6508 <div class=
"col-md-12">
6510 <h2>Offline Usage
</h2>
6513 You can use this tool without having to be online.
6516 In your browser, select file save-as, and save this page
6520 Double-click that file to open it in a browser
6521 on any offline computer.
6524 Alternatively, download it from
6525 <a href=
"https://github.com/dcpos/bip39">
6526 https://github.com/dcpos/bip39
6535 <div class=
"col-md-12">
6537 <h2>This project is
100% open-source code
</h2>
6540 <span>Get the source code at -
</span>
6541 <a href=
"https://github.com/dcpos/bip39" target=
"_blank">
6542 https://github.com/dcpos/bip39
6549 <span>BitcoinJS -
</span>
6550 <a href=
"https://github.com/bitcoinjs/bitcoinjs-lib" target=
"_blank">
6551 https://github.com/bitcoinjs/bitcoinjs-lib
6556 <span>jsBIP39 -
</span>
6557 <a href=
"https://github.com/iancoleman/jsbip39" target=
"_blank">
6558 https://github.com/iancoleman/jsbip39
6563 <span>sjcl -
</span>
6564 <a href=
"https://github.com/bitwiseshiftleft/sjcl" target=
"_blank">
6565 https://github.com/bitwiseshiftleft/sjcl
6570 <span>jQuery -
</span>
6571 <a href=
"https://jquery.com/" target=
"_blank">
6577 <span>Twitter Bootstrap -
</span>
6578 <a href=
"http://getbootstrap.com/" target=
"_blank">
6579 http://getbootstrap.com/
6588 <div class=
"feedback-container">
6589 <div class=
"feedback">Loading...
</div>
6592 <script type=
"text/template" id=
"address-row-template">
6594 <td class=
"index"><span></span></td>
6595 <td class=
"address"><span></span></td>
6596 <td class=
"privkey"><span></span></td>
6601 * jQuery JavaScript Library v2.1
.1
6602 * http://jquery.com/
6604 * Includes Sizzle.js
6605 * http://sizzlejs.com/
6607 * Copyright
2005,
2014 jQuery Foundation, Inc. and other contributors
6608 * Released under the MIT license
6609 * http://jquery.org/license
6611 * Date:
2014-
05-
01T17:
11Z
6614 (function( global, factory ) {
6616 if ( typeof module === "object" && typeof module.exports === "object" ) {
6617 // For CommonJS and CommonJS-like environments where a proper window is present,
6618 // execute the factory and get jQuery
6619 // For environments that do not inherently posses a window with a document
6620 // (such as Node.js), expose a jQuery-making factory as module.exports
6621 // This accentuates the need for the creation of a real window
6622 // e.g. var jQuery = require("jquery")(window);
6623 // See ticket #
14549 for more info
6624 module.exports = global.document ?
6625 factory( global, true ) :
6627 if ( !w.document ) {
6628 throw new Error( "jQuery requires a window with a document" );
6630 return factory( w );
6636 // Pass this if window is not defined yet
6637 }(typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
6639 // Can't do this because several apps including ASP.NET trace
6640 // the stack via arguments.caller.callee and Firefox dies if
6641 // you try to trace through "use strict" call chains. (#
13335)
6642 // Support: Firefox
18+
6647 var slice = arr.slice;
6649 var concat = arr.concat;
6651 var push = arr.push;
6653 var indexOf = arr.indexOf;
6655 var class2type = {};
6657 var toString = class2type.toString;
6659 var hasOwn = class2type.hasOwnProperty;
6666 // Use the correct document accordingly with window argument (sandbox)
6667 document = window.document,
6671 // Define a local copy of jQuery
6672 jQuery = function( selector, context ) {
6673 // The jQuery object is actually just the init constructor 'enhanced'
6674 // Need init if jQuery is called (just allow error to be thrown if not included)
6675 return new jQuery.fn.init( selector, context );
6678 // Support: Android
<4.1
6679 // Make sure we trim BOM and NBSP
6680 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
6682 // Matches dashed string for camelizing
6683 rmsPrefix = /^-ms-/,
6684 rdashAlpha = /-([\da-z])/gi,
6686 // Used by jQuery.camelCase as callback to replace()
6687 fcamelCase = function( all, letter ) {
6688 return letter.toUpperCase();
6691 jQuery.fn = jQuery.prototype = {
6692 // The current version of jQuery being used
6695 constructor: jQuery,
6697 // Start with an empty selector
6700 // The default length of a jQuery object is
0
6703 toArray: function() {
6704 return slice.call( this );
6707 // Get the Nth element in the matched element set OR
6708 // Get the whole matched element set as a clean array
6709 get: function( num ) {
6710 return num != null ?
6712 // Return just the one element from the set
6713 ( num <
0 ? this[ num + this.length ] : this[ num ] ) :
6715 // Return all the elements in a clean array
6719 // Take an array of elements and push it onto the stack
6720 // (returning the new matched element set)
6721 pushStack: function( elems ) {
6723 // Build a new jQuery matched element set
6724 var ret = jQuery.merge( this.constructor(), elems );
6726 // Add the old object onto the stack (as a reference)
6727 ret.prevObject = this;
6728 ret.context = this.context;
6730 // Return the newly-formed element set
6734 // Execute a callback for every element in the matched set.
6735 // (You can seed the arguments with an array of args, but this is
6736 // only used internally.)
6737 each: function( callback, args ) {
6738 return jQuery.each( this, callback, args );
6741 map: function( callback ) {
6742 return this.pushStack( jQuery.map(this, function( elem, i ) {
6743 return callback.call( elem, i, elem );
6748 return this.pushStack( slice.apply( this, arguments ) );
6752 return this.eq(
0 );
6756 return this.eq( -
1 );
6760 var len = this.length,
6761 j = +i + ( i <
0 ? len :
0 );
6762 return this.pushStack( j
>=
0 && j < len ? [ this[j] ] : [] );
6766 return this.prevObject || this.constructor(null);
6769 // For internal use only.
6770 // Behaves like an Array's method, not like a jQuery method.
6776 jQuery.extend = jQuery.fn.extend = function() {
6777 var options, name, src, copy, copyIsArray, clone,
6778 target = arguments[
0] || {},
6780 length = arguments.length,
6783 // Handle a deep copy situation
6784 if ( typeof target === "boolean" ) {
6787 // skip the boolean and the target
6788 target = arguments[ i ] || {};
6792 // Handle case when target is a string or something (possible in deep copy)
6793 if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
6797 // extend jQuery itself if only one argument is passed
6798 if ( i === length ) {
6803 for ( ; i < length; i++ ) {
6804 // Only deal with non-null/undefined values
6805 if ( (options = arguments[ i ]) != null ) {
6806 // Extend the base object
6807 for ( name in options ) {
6808 src = target[ name ];
6809 copy = options[ name ];
6811 // Prevent never-ending loop
6812 if ( target === copy ) {
6816 // Recurse if we're merging plain objects or arrays
6817 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
6818 if ( copyIsArray ) {
6819 copyIsArray = false;
6820 clone = src && jQuery.isArray(src) ? src : [];
6823 clone = src && jQuery.isPlainObject(src) ? src : {};
6826 // Never move original objects, clone them
6827 target[ name ] = jQuery.extend( deep, clone, copy );
6829 // Don't bring in undefined values
6830 } else if ( copy !== undefined ) {
6831 target[ name ] = copy;
6837 // Return the modified object
6842 // Unique for each copy of jQuery on the page
6843 expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
6845 // Assume jQuery is ready without the ready module
6848 error: function( msg ) {
6849 throw new Error( msg );
6852 noop: function() {},
6854 // See test/unit/core.js for details concerning isFunction.
6855 // Since version
1.3, DOM methods and functions like alert
6856 // aren't supported. They return false on IE (#
2968).
6857 isFunction: function( obj ) {
6858 return jQuery.type(obj) === "function";
6861 isArray: Array.isArray,
6863 isWindow: function( obj ) {
6864 return obj != null && obj === obj.window;
6867 isNumeric: function( obj ) {
6868 // parseFloat NaNs numeric-cast false positives (null|true|false|"")
6869 // ...but misinterprets leading-number strings, particularly hex literals ("
0x...")
6870 // subtraction forces infinities to NaN
6871 return !jQuery.isArray( obj ) && obj - parseFloat( obj )
>=
0;
6874 isPlainObject: function( obj ) {
6875 // Not plain objects:
6876 // - Any object or value whose internal [[Class]] property is not "[object Object]"
6879 if ( jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
6883 if ( obj.constructor &&
6884 !hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) {
6888 // If the function hasn't returned already, we're confident that
6889 // |obj| is a plain object, created by {} or constructed with new Object
6893 isEmptyObject: function( obj ) {
6895 for ( name in obj ) {
6901 type: function( obj ) {
6902 if ( obj == null ) {
6905 // Support: Android <
4.0, iOS <
6 (functionish RegExp)
6906 return typeof obj === "object" || typeof obj === "function" ?
6907 class2type[ toString.call(obj) ] || "object" :
6911 // Evaluates a script in a global context
6912 globalEval: function( code ) {
6916 code = jQuery.trim( code );
6919 // If the code includes a valid, prologue position
6920 // strict mode pragma, execute code by injecting a
6921 // script tag into the document.
6922 if ( code.indexOf("use strict") ===
1 ) {
6923 script = document.createElement("script");
6925 document.head.appendChild( script ).parentNode.removeChild( script );
6927 // Otherwise, avoid the DOM node creation, insertion
6928 // and removal by using an indirect global eval
6934 // Convert dashed to camelCase; used by the css and data modules
6935 // Microsoft forgot to hump their vendor prefix (#
9572)
6936 camelCase: function( string ) {
6937 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
6940 nodeName: function( elem, name ) {
6941 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
6944 // args is for internal usage only
6945 each: function( obj, callback, args ) {
6948 length = obj.length,
6949 isArray = isArraylike( obj );
6953 for ( ; i < length; i++ ) {
6954 value = callback.apply( obj[ i ], args );
6956 if ( value === false ) {
6962 value = callback.apply( obj[ i ], args );
6964 if ( value === false ) {
6970 // A special, fast, case for the most common use of each
6973 for ( ; i < length; i++ ) {
6974 value = callback.call( obj[ i ], i, obj[ i ] );
6976 if ( value === false ) {
6982 value = callback.call( obj[ i ], i, obj[ i ] );
6984 if ( value === false ) {
6994 // Support: Android
<4.1
6995 trim: function( text ) {
6996 return text == null ?
6998 ( text +
"" ).replace( rtrim,
"" );
7001 // results is for internal usage only
7002 makeArray: function( arr, results ) {
7003 var ret = results || [];
7005 if ( arr != null ) {
7006 if ( isArraylike( Object(arr) ) ) {
7008 typeof arr ===
"string" ?
7012 push.call( ret, arr );
7019 inArray: function( elem, arr, i ) {
7020 return arr == null ? -
1 : indexOf.call( arr, elem, i );
7023 merge: function( first, second ) {
7024 var len = +second.length,
7028 for ( ; j < len; j++ ) {
7029 first[ i++ ] = second[ j ];
7037 grep: function( elems, callback, invert ) {
7038 var callbackInverse,
7041 length = elems.length,
7042 callbackExpect = !invert;
7044 // Go through the array, only saving the items
7045 // that pass the validator function
7046 for ( ; i < length; i++ ) {
7047 callbackInverse = !callback( elems[ i ], i );
7048 if ( callbackInverse !== callbackExpect ) {
7049 matches.push( elems[ i ] );
7056 // arg is for internal usage only
7057 map: function( elems, callback, arg ) {
7060 length = elems.length,
7061 isArray = isArraylike( elems ),
7064 // Go through the array, translating each of the items to their new values
7066 for ( ; i < length; i++ ) {
7067 value = callback( elems[ i ], i, arg );
7069 if ( value != null ) {
7074 // Go through every key on the object,
7076 for ( i in elems ) {
7077 value = callback( elems[ i ], i, arg );
7079 if ( value != null ) {
7085 // Flatten any nested arrays
7086 return concat.apply( [], ret );
7089 // A global GUID counter for objects
7092 // Bind a function to a context, optionally partially applying any
7094 proxy: function( fn, context ) {
7095 var tmp, args, proxy;
7097 if ( typeof context ===
"string" ) {
7098 tmp = fn[ context ];
7103 // Quick check to determine if target is callable, in the spec
7104 // this throws a TypeError, but we will just return undefined.
7105 if ( !jQuery.isFunction( fn ) ) {
7110 args = slice.call( arguments,
2 );
7111 proxy = function() {
7112 return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
7115 // Set the guid of unique handler to the same of original handler, so it can be removed
7116 proxy.guid = fn.guid = fn.guid || jQuery.guid++;
7123 // jQuery.support is not used in Core but other projects attach their
7124 // properties to it so it needs to exist.
7128 // Populate the class2type map
7129 jQuery.each(
"Boolean Number String Function Array Date RegExp Object Error".split(
" "), function(i, name) {
7130 class2type[
"[object " + name +
"]" ] = name.toLowerCase();
7133 function isArraylike( obj ) {
7134 var length = obj.length,
7135 type = jQuery.type( obj );
7137 if ( type ===
"function" || jQuery.isWindow( obj ) ) {
7141 if ( obj.nodeType ===
1 && length ) {
7145 return type ===
"array" || length ===
0 ||
7146 typeof length ===
"number" && length
> 0 && ( length -
1 ) in obj;
7150 * Sizzle CSS Selector Engine v1.10
.19
7151 * http://sizzlejs.com/
7153 * Copyright
2013 jQuery Foundation, Inc. and other contributors
7154 * Released under the MIT license
7155 * http://jquery.org/license
7159 (function( window ) {
7173 // Local document vars
7183 // Instance-specific data
7184 expando =
"sizzle" + -(new Date()),
7185 preferredDoc = window.document,
7188 classCache = createCache(),
7189 tokenCache = createCache(),
7190 compilerCache = createCache(),
7191 sortOrder = function( a, b ) {
7193 hasDuplicate = true;
7198 // General-purpose constants
7199 strundefined = typeof undefined,
7200 MAX_NEGATIVE =
1 <<
31,
7203 hasOwn = ({}).hasOwnProperty,
7206 push_native = arr.push,
7209 // Use a stripped-down indexOf if we can't use a native one
7210 indexOf = arr.indexOf || function( elem ) {
7213 for ( ; i < len; i++ ) {
7214 if ( this[i] === elem ) {
7221 booleans =
"checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
7223 // Regular expressions
7225 // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
7226 whitespace =
"[\\x20\\t\\r\\n\\f]",
7227 // http://www.w3.org/TR/css3-syntax/#characters
7228 characterEncoding =
"(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
7230 // Loosely modeled on CSS identifier characters
7231 // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors
7232 // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
7233 identifier = characterEncoding.replace(
"w",
"w#" ),
7235 // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
7236 attributes =
"\\[" + whitespace +
"*(" + characterEncoding +
")(?:" + whitespace +
7237 // Operator (capture
2)
7238 "*([*^$|!~]?=)" + whitespace +
7239 //
"Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
7240 "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\
"])*)\"|(
" + identifier + "))|)
" + whitespace +
7243 pseudos = ":(
" + characterEncoding + ")(?:\\((
" +
7244 // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
7245 // 1. quoted (capture 3; capture 4 or capture 5)
7246 "('((?:\\\\.|[^\\\\'])*)'|\
"((?:\\\\.|[^\\\\\"])*)\
")|" +
7247 //
2. simple (capture
6)
7248 "((?:\\\\.|[^\\\\()[\\]]|" + attributes +
")*)|" +
7249 //
3. anything else (capture
2)
7253 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
7254 rtrim = new RegExp(
"^" + whitespace +
"+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace +
"+$",
"g" ),
7256 rcomma = new RegExp(
"^" + whitespace +
"*," + whitespace +
"*" ),
7257 rcombinators = new RegExp(
"^" + whitespace +
"*([>+~]|" + whitespace +
")" + whitespace +
"*" ),
7259 rattributeQuotes = new RegExp(
"=" + whitespace +
"*([^\\]'\"]*?)
" + whitespace + "*\\]
", "g
" ),
7261 rpseudo = new RegExp( pseudos ),
7262 ridentifier = new RegExp( "^
" + identifier + "$
" ),
7265 "ID
": new RegExp( "^#(
" + characterEncoding + ")
" ),
7266 "CLASS
": new RegExp( "^\\.(
" + characterEncoding + ")
" ),
7267 "TAG
": new RegExp( "^(
" + characterEncoding.replace( "w
", "w*
" ) + ")
" ),
7268 "ATTR
": new RegExp( "^
" + attributes ),
7269 "PSEUDO
": new RegExp( "^
" + pseudos ),
7270 "CHILD
": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(
" + whitespace +
7271 "*(even|odd|(([+-]|)(\\d*)n|)
" + whitespace + "*(?:([+-]|)
" + whitespace +
7272 "*(\\d+)|))
" + whitespace + "*\\)|)
", "i
" ),
7273 "bool
": new RegExp( "^(?:
" + booleans + ")$
", "i
" ),
7274 // For use in libraries implementing .is()
7275 // We use this for POS matching in `select`
7276 "needsContext
": new RegExp( "^
" + whitespace + "*[
>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
7277 whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
7280 rinputs = /^(?:input|select|textarea|button)$/i,
7283 rnative = /^[^{]+\{\s*\[native \w/,
7285 // Easily-parseable/retrievable ID or TAG or CLASS selectors
7286 rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
7291 // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
7292 runescape = new RegExp( "\\\\([\\da-f]{
1,
6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
7293 funescape = function( _, escaped, escapedWhitespace ) {
7294 var high = "
0x" + escaped -
0x10000;
7295 // NaN means non-codepoint
7296 // Support: Firefox
<24
7297 // Workaround erroneous numeric interpretation of +
"0x"
7298 return high !== high || escapedWhitespace ?
7302 String.fromCharCode( high +
0x10000 ) :
7303 // Supplemental Plane codepoint (surrogate pair)
7304 String.fromCharCode( high
>> 10 |
0xD800, high &
0x3FF |
0xDC00 );
7307 // Optimize for push.apply( _, NodeList )
7310 (arr = slice.call( preferredDoc.childNodes )),
7311 preferredDoc.childNodes
7313 // Support: Android
<4.0
7314 // Detect silently failing push.apply
7315 arr[ preferredDoc.childNodes.length ].nodeType;
7317 push = { apply: arr.length ?
7319 // Leverage slice if possible
7320 function( target, els ) {
7321 push_native.apply( target, slice.call(els) );
7325 // Otherwise append directly
7326 function( target, els ) {
7327 var j = target.length,
7329 // Can't trust NodeList.length
7330 while ( (target[j++] = els[i++]) ) {}
7331 target.length = j -
1;
7336 function Sizzle( selector, context, results, seed ) {
7337 var match, elem, m, nodeType,
7339 i, groups, old, nid, newContext, newSelector;
7341 if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
7342 setDocument( context );
7345 context = context || document;
7346 results = results || [];
7348 if ( !selector || typeof selector !==
"string" ) {
7352 if ( (nodeType = context.nodeType) !==
1 && nodeType !==
9 ) {
7356 if ( documentIsHTML && !seed ) {
7359 if ( (match = rquickExpr.exec( selector )) ) {
7360 // Speed-up: Sizzle(
"#ID")
7361 if ( (m = match[
1]) ) {
7362 if ( nodeType ===
9 ) {
7363 elem = context.getElementById( m );
7364 // Check parentNode to catch when Blackberry
4.6 returns
7365 // nodes that are no longer in the document (jQuery #
6963)
7366 if ( elem && elem.parentNode ) {
7367 // Handle the case where IE, Opera, and Webkit return items
7368 // by name instead of ID
7369 if ( elem.id === m ) {
7370 results.push( elem );
7377 // Context is not a document
7378 if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
7379 contains( context, elem ) && elem.id === m ) {
7380 results.push( elem );
7385 // Speed-up: Sizzle(
"TAG")
7386 } else if ( match[
2] ) {
7387 push.apply( results, context.getElementsByTagName( selector ) );
7390 // Speed-up: Sizzle(
".CLASS")
7391 } else if ( (m = match[
3]) && support.getElementsByClassName && context.getElementsByClassName ) {
7392 push.apply( results, context.getElementsByClassName( m ) );
7398 if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
7399 nid = old = expando;
7400 newContext = context;
7401 newSelector = nodeType ===
9 && selector;
7403 // qSA works strangely on Element-rooted queries
7404 // We can work around this by specifying an extra ID on the root
7405 // and working up from there (Thanks to Andrew Dupont for the technique)
7406 // IE
8 doesn't work on object elements
7407 if ( nodeType ===
1 && context.nodeName.toLowerCase() !==
"object" ) {
7408 groups = tokenize( selector );
7410 if ( (old = context.getAttribute(
"id")) ) {
7411 nid = old.replace( rescape,
"\\$&" );
7413 context.setAttribute(
"id", nid );
7415 nid =
"[id='" + nid +
"'] ";
7419 groups[i] = nid + toSelector( groups[i] );
7421 newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context;
7422 newSelector = groups.join(
",");
7425 if ( newSelector ) {
7427 push.apply( results,
7428 newContext.querySelectorAll( newSelector )
7434 context.removeAttribute(
"id");
7442 return select( selector.replace( rtrim,
"$1" ), context, results, seed );
7446 * Create key-value caches of limited size
7447 * @returns {Function(string, Object)} Returns the Object data after storing it on itself with
7448 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
7449 * deleting the oldest entry
7451 function createCache() {
7454 function cache( key, value ) {
7455 // Use (key +
" ") to avoid collision with native prototype properties (see Issue #
157)
7456 if ( keys.push( key +
" " )
> Expr.cacheLength ) {
7457 // Only keep the most recent entries
7458 delete cache[ keys.shift() ];
7460 return (cache[ key + " " ] = value);
7466 * Mark a function for special use by Sizzle
7467 * @param {Function} fn The function to mark
7469 function markFunction( fn ) {
7470 fn[ expando ] = true;
7475 * Support testing using an element
7476 * @param {Function} fn Passed the created div and expects a boolean result
7478 function assert( fn ) {
7479 var div = document.createElement("div");
7486 // Remove from its parent by default
7487 if ( div.parentNode ) {
7488 div.parentNode.removeChild( div );
7490 // release memory in IE
7496 * Adds the same handler for all of the specified attrs
7497 * @param {String} attrs Pipe-separated list of attributes
7498 * @param {Function} handler The method that will be applied
7500 function addHandle( attrs, handler ) {
7501 var arr = attrs.split("|"),
7505 Expr.attrHandle[ arr[i] ] = handler;
7510 * Checks document order of two siblings
7511 * @param {Element} a
7512 * @param {Element} b
7513 * @returns {Number} Returns less than
0 if a precedes b, greater than
0 if a follows b
7515 function siblingCheck( a, b ) {
7517 diff = cur && a.nodeType ===
1 && b.nodeType ===
1 &&
7518 ( ~b.sourceIndex || MAX_NEGATIVE ) -
7519 ( ~a.sourceIndex || MAX_NEGATIVE );
7521 // Use IE sourceIndex if available on both nodes
7526 // Check if b follows a
7528 while ( (cur = cur.nextSibling) ) {
7539 * Returns a function to use in pseudos for input types
7540 * @param {String} type
7542 function createInputPseudo( type ) {
7543 return function( elem ) {
7544 var name = elem.nodeName.toLowerCase();
7545 return name === "input" && elem.type === type;
7550 * Returns a function to use in pseudos for buttons
7551 * @param {String} type
7553 function createButtonPseudo( type ) {
7554 return function( elem ) {
7555 var name = elem.nodeName.toLowerCase();
7556 return (name === "input" || name === "button") && elem.type === type;
7561 * Returns a function to use in pseudos for positionals
7562 * @param {Function} fn
7564 function createPositionalPseudo( fn ) {
7565 return markFunction(function( argument ) {
7566 argument = +argument;
7567 return markFunction(function( seed, matches ) {
7569 matchIndexes = fn( [], seed.length, argument ),
7570 i = matchIndexes.length;
7572 // Match elements found at the specified indexes
7574 if ( seed[ (j = matchIndexes[i]) ] ) {
7575 seed[j] = !(matches[j] = seed[j]);
7583 * Checks a node for validity as a Sizzle context
7584 * @param {Element|Object=} context
7585 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
7587 function testContext( context ) {
7588 return context && typeof context.getElementsByTagName !== strundefined && context;
7591 // Expose support vars for convenience
7592 support = Sizzle.support = {};
7596 * @param {Element|Object} elem An element or a document
7597 * @returns {Boolean} True iff elem is a non-HTML XML node
7599 isXML = Sizzle.isXML = function( elem ) {
7600 // documentElement is verified for cases where it doesn't yet exist
7601 // (such as loading iframes in IE - #
4833)
7602 var documentElement = elem && (elem.ownerDocument || elem).documentElement;
7603 return documentElement ? documentElement.nodeName !== "HTML" : false;
7607 * Sets document-related variables once based on the current document
7608 * @param {Element|Object} [doc] An element or document object to use to set the document
7609 * @returns {Object} Returns the current document
7611 setDocument = Sizzle.setDocument = function( node ) {
7613 doc = node ? node.ownerDocument || node : preferredDoc,
7614 parent = doc.defaultView;
7616 // If no document and documentElement is available, return
7617 if ( doc === document || doc.nodeType !==
9 || !doc.documentElement ) {
7623 docElem = doc.documentElement;
7626 documentIsHTML = !isXML( doc );
7629 // If iframe document is assigned to
"document" variable and if iframe has been reloaded,
7630 // IE will throw
"permission denied" error when accessing
"document" variable, see jQuery #
13936
7631 // IE6-
8 do not support the defaultView property so parent will be undefined
7632 if ( parent && parent !== parent.top ) {
7633 // IE11 does not have attachEvent, so all must suffer
7634 if ( parent.addEventListener ) {
7635 parent.addEventListener(
"unload", function() {
7638 } else if ( parent.attachEvent ) {
7639 parent.attachEvent(
"onunload", function() {
7646 ---------------------------------------------------------------------- */
7649 // Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans)
7650 support.attributes = assert(function( div ) {
7651 div.className =
"i";
7652 return !div.getAttribute(
"className");
7656 ---------------------------------------------------------------------- */
7658 // Check if getElementsByTagName(
"*") returns only elements
7659 support.getElementsByTagName = assert(function( div ) {
7660 div.appendChild( doc.createComment(
"") );
7661 return !div.getElementsByTagName(
"*").length;
7664 // Check if getElementsByClassName can be trusted
7665 support.getElementsByClassName = rnative.test( doc.getElementsByClassName ) && assert(function( div ) {
7666 div.innerHTML =
"<div class='a'></div><div class='a i'></div>";
7668 // Support: Safari
<4
7669 // Catch class over-caching
7670 div.firstChild.className =
"i";
7671 // Support: Opera
<10
7672 // Catch gEBCN failure to find non-leading classes
7673 return div.getElementsByClassName(
"i").length ===
2;
7677 // Check if getElementById returns elements by name
7678 // The broken getElementById methods don't pick up programatically-set names,
7679 // so use a roundabout getElementsByName test
7680 support.getById = assert(function( div ) {
7681 docElem.appendChild( div ).id = expando;
7682 return !doc.getElementsByName || !doc.getElementsByName( expando ).length;
7685 // ID find and filter
7686 if ( support.getById ) {
7687 Expr.find[
"ID"] = function( id, context ) {
7688 if ( typeof context.getElementById !== strundefined && documentIsHTML ) {
7689 var m = context.getElementById( id );
7690 // Check parentNode to catch when Blackberry
4.6 returns
7691 // nodes that are no longer in the document #
6963
7692 return m && m.parentNode ? [ m ] : [];
7695 Expr.filter[
"ID"] = function( id ) {
7696 var attrId = id.replace( runescape, funescape );
7697 return function( elem ) {
7698 return elem.getAttribute(
"id") === attrId;
7703 // getElementById is not reliable as a find shortcut
7704 delete Expr.find[
"ID"];
7706 Expr.filter[
"ID"] = function( id ) {
7707 var attrId = id.replace( runescape, funescape );
7708 return function( elem ) {
7709 var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode(
"id");
7710 return node && node.value === attrId;
7716 Expr.find[
"TAG"] = support.getElementsByTagName ?
7717 function( tag, context ) {
7718 if ( typeof context.getElementsByTagName !== strundefined ) {
7719 return context.getElementsByTagName( tag );
7722 function( tag, context ) {
7726 results = context.getElementsByTagName( tag );
7728 // Filter out possible comments
7729 if ( tag ===
"*" ) {
7730 while ( (elem = results[i++]) ) {
7731 if ( elem.nodeType ===
1 ) {
7742 Expr.find[
"CLASS"] = support.getElementsByClassName && function( className, context ) {
7743 if ( typeof context.getElementsByClassName !== strundefined && documentIsHTML ) {
7744 return context.getElementsByClassName( className );
7748 /* QSA/matchesSelector
7749 ---------------------------------------------------------------------- */
7751 // QSA and matchesSelector support
7753 // matchesSelector(:active) reports false when true (IE9/Opera
11.5)
7756 // qSa(:focus) reports false when true (Chrome
21)
7757 // We allow this because of a bug in IE8/
9 that throws an error
7758 // whenever `document.activeElement` is accessed on an iframe
7759 // So, we allow :focus to pass through QSA all the time to avoid the IE error
7760 // See http://bugs.jquery.com/ticket/
13378
7763 if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) {
7765 // Regex strategy adopted from Diego Perini
7766 assert(function( div ) {
7767 // Select is set to empty string on purpose
7768 // This is to test IE's treatment of not explicitly
7769 // setting a boolean content attribute,
7770 // since its presence should be enough
7771 // http://bugs.jquery.com/ticket/
12359
7772 div.innerHTML =
"<select msallowclip=''><option selected=''></option></select>";
7774 // Support: IE8, Opera
11-
12.16
7775 // Nothing should be selected when empty strings follow ^= or $= or *=
7776 // The test attribute must be unknown in Opera but
"safe" for WinRT
7777 // http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
7778 if ( div.querySelectorAll(
"[msallowclip^='']").length ) {
7779 rbuggyQSA.push(
"[*^$]=" + whitespace +
"*(?:''|\"\
")" );
7783 // Boolean attributes and
"value" are not treated correctly
7784 if ( !div.querySelectorAll(
"[selected]").length ) {
7785 rbuggyQSA.push(
"\\[" + whitespace +
"*(?:value|" + booleans +
")" );
7788 // Webkit/Opera - :checked should return selected option elements
7789 // http://www.w3.org/TR/
2011/REC-css3-selectors-
20110929/#checked
7790 // IE8 throws error here and will not see later tests
7791 if ( !div.querySelectorAll(
":checked").length ) {
7792 rbuggyQSA.push(
":checked");
7796 assert(function( div ) {
7797 // Support: Windows
8 Native Apps
7798 // The type and name attributes are restricted during .innerHTML assignment
7799 var input = doc.createElement(
"input");
7800 input.setAttribute(
"type",
"hidden" );
7801 div.appendChild( input ).setAttribute(
"name",
"D" );
7804 // Enforce case-sensitivity of name attribute
7805 if ( div.querySelectorAll(
"[name=d]").length ) {
7806 rbuggyQSA.push(
"name" + whitespace +
"*[*^$|!~]?=" );
7809 // FF
3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
7810 // IE8 throws error here and will not see later tests
7811 if ( !div.querySelectorAll(
":enabled").length ) {
7812 rbuggyQSA.push(
":enabled",
":disabled" );
7815 // Opera
10-
11 does not throw on post-comma invalid pseudos
7816 div.querySelectorAll(
"*,:x");
7817 rbuggyQSA.push(
",.*:");
7821 if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
7822 docElem.webkitMatchesSelector ||
7823 docElem.mozMatchesSelector ||
7824 docElem.oMatchesSelector ||
7825 docElem.msMatchesSelector) )) ) {
7827 assert(function( div ) {
7828 // Check to see if it's possible to do matchesSelector
7829 // on a disconnected node (IE
9)
7830 support.disconnectedMatch = matches.call( div,
"div" );
7832 // This should fail with an exception
7833 // Gecko does not error, returns false instead
7834 matches.call( div,
"[s!='']:x" );
7835 rbuggyMatches.push(
"!=", pseudos );
7839 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join(
"|") );
7840 rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join(
"|") );
7843 ---------------------------------------------------------------------- */
7844 hasCompare = rnative.test( docElem.compareDocumentPosition );
7846 // Element contains another
7847 // Purposefully does not implement inclusive descendent
7848 // As in, an element does not contain itself
7849 contains = hasCompare || rnative.test( docElem.contains ) ?
7851 var adown = a.nodeType ===
9 ? a.documentElement : a,
7852 bup = b && b.parentNode;
7853 return a === bup || !!( bup && bup.nodeType ===
1 && (
7855 adown.contains( bup ) :
7856 a.compareDocumentPosition && a.compareDocumentPosition( bup ) &
16
7861 while ( (b = b.parentNode) ) {
7871 ---------------------------------------------------------------------- */
7873 // Document order sorting
7874 sortOrder = hasCompare ?
7877 // Flag for duplicate removal
7879 hasDuplicate = true;
7883 // Sort on method existence if only one input has compareDocumentPosition
7884 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
7889 // Calculate position if both inputs belong to the same document
7890 compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
7891 a.compareDocumentPosition( b ) :
7893 // Otherwise we know they are disconnected
7896 // Disconnected nodes
7898 (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
7900 // Choose the first element that is related to our preferred document
7901 if ( a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
7904 if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
7908 // Maintain original order
7910 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
7914 return compare &
4 ? -
1 :
1;
7917 // Exit early if the nodes are identical
7919 hasDuplicate = true;
7930 // Parentless nodes are either documents or disconnected
7931 if ( !aup || !bup ) {
7932 return a === doc ? -
1 :
7937 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
7940 // If the nodes are siblings, we can do a quick check
7941 } else if ( aup === bup ) {
7942 return siblingCheck( a, b );
7945 // Otherwise we need full lists of their ancestors for comparison
7947 while ( (cur = cur.parentNode) ) {
7951 while ( (cur = cur.parentNode) ) {
7955 // Walk down the tree looking for a discrepancy
7956 while ( ap[i] === bp[i] ) {
7961 // Do a sibling check if the nodes have a common ancestor
7962 siblingCheck( ap[i], bp[i] ) :
7964 // Otherwise nodes in our document sort first
7965 ap[i] === preferredDoc ? -
1 :
7966 bp[i] === preferredDoc ?
1 :
7973 Sizzle.matches = function( expr, elements ) {
7974 return Sizzle( expr, null, null, elements );
7977 Sizzle.matchesSelector = function( elem, expr ) {
7978 // Set document vars if needed
7979 if ( ( elem.ownerDocument || elem ) !== document ) {
7980 setDocument( elem );
7983 // Make sure that attribute selectors are quoted
7984 expr = expr.replace( rattributeQuotes,
"='$1']" );
7986 if ( support.matchesSelector && documentIsHTML &&
7987 ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
7988 ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
7991 var ret = matches.call( elem, expr );
7993 // IE
9's matchesSelector returns false on disconnected nodes
7994 if ( ret || support.disconnectedMatch ||
7995 // As well, disconnected nodes are said to be in a document
7997 elem.document && elem.document.nodeType !==
11 ) {
8003 return Sizzle( expr, document, null, [ elem ] ).length
> 0;
8006 Sizzle.contains = function( context, elem ) {
8007 // Set document vars if needed
8008 if ( ( context.ownerDocument || context ) !== document ) {
8009 setDocument( context );
8011 return contains( context, elem );
8014 Sizzle.attr = function( elem, name ) {
8015 // Set document vars if needed
8016 if ( ( elem.ownerDocument || elem ) !== document ) {
8017 setDocument( elem );
8020 var fn = Expr.attrHandle[ name.toLowerCase() ],
8021 // Don't get fooled by Object.prototype properties (jQuery #
13807)
8022 val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
8023 fn( elem, name, !documentIsHTML ) :
8026 return val !== undefined ?
8028 support.attributes || !documentIsHTML ?
8029 elem.getAttribute( name ) :
8030 (val = elem.getAttributeNode(name)) && val.specified ?
8035 Sizzle.error = function( msg ) {
8036 throw new Error(
"Syntax error, unrecognized expression: " + msg );
8040 * Document sorting and removing duplicates
8041 * @param {ArrayLike} results
8043 Sizzle.uniqueSort = function( results ) {
8049 // Unless we *know* we can detect duplicates, assume their presence
8050 hasDuplicate = !support.detectDuplicates;
8051 sortInput = !support.sortStable && results.slice(
0 );
8052 results.sort( sortOrder );
8054 if ( hasDuplicate ) {
8055 while ( (elem = results[i++]) ) {
8056 if ( elem === results[ i ] ) {
8057 j = duplicates.push( i );
8061 results.splice( duplicates[ j ],
1 );
8065 // Clear input after sorting to release objects
8066 // See https://github.com/jquery/sizzle/pull/
225
8073 * Utility function for retrieving the text value of an array of DOM nodes
8074 * @param {Array|Element} elem
8076 getText = Sizzle.getText = function( elem ) {
8080 nodeType = elem.nodeType;
8083 // If no nodeType, this is expected to be an array
8084 while ( (node = elem[i++]) ) {
8085 // Do not traverse comment nodes
8086 ret += getText( node );
8088 } else if ( nodeType ===
1 || nodeType ===
9 || nodeType ===
11 ) {
8089 // Use textContent for elements
8090 // innerText usage removed for consistency of new lines (jQuery #
11153)
8091 if ( typeof elem.textContent ===
"string" ) {
8092 return elem.textContent;
8094 // Traverse its children
8095 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
8096 ret += getText( elem );
8099 } else if ( nodeType ===
3 || nodeType ===
4 ) {
8100 return elem.nodeValue;
8102 // Do not include comment or processing instruction nodes
8107 Expr = Sizzle.selectors = {
8109 // Can be adjusted by the user
8112 createPseudo: markFunction,
8121 ">": { dir:
"parentNode", first: true },
8122 " ": { dir:
"parentNode" },
8123 "+": { dir:
"previousSibling", first: true },
8124 "~": { dir:
"previousSibling" }
8128 "ATTR": function( match ) {
8129 match[
1] = match[
1].replace( runescape, funescape );
8131 // Move the given value to match[
3] whether quoted or unquoted
8132 match[
3] = ( match[
3] || match[
4] || match[
5] ||
"" ).replace( runescape, funescape );
8134 if ( match[
2] ===
"~=" ) {
8135 match[
3] =
" " + match[
3] +
" ";
8138 return match.slice(
0,
4 );
8141 "CHILD": function( match ) {
8142 /* matches from matchExpr[
"CHILD"]
8143 1 type (only|nth|...)
8144 2 what (child|of-type)
8145 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
8146 4 xn-component of xn+y argument ([+-]?\d*n|)
8147 5 sign of xn-component
8149 7 sign of y-component
8152 match[
1] = match[
1].toLowerCase();
8154 if ( match[
1].slice(
0,
3 ) ===
"nth" ) {
8155 // nth-* requires argument
8157 Sizzle.error( match[
0] );
8160 // numeric x and y parameters for Expr.filter.CHILD
8161 // remember that false/true cast respectively to
0/
1
8162 match[
4] = +( match[
4] ? match[
5] + (match[
6] ||
1) :
2 * ( match[
3] ===
"even" || match[
3] ===
"odd" ) );
8163 match[
5] = +( ( match[
7] + match[
8] ) || match[
3] ===
"odd" );
8165 // other types prohibit arguments
8166 } else if ( match[
3] ) {
8167 Sizzle.error( match[
0] );
8173 "PSEUDO": function( match ) {
8175 unquoted = !match[
6] && match[
2];
8177 if ( matchExpr[
"CHILD"].test( match[
0] ) ) {
8181 // Accept quoted arguments as-is
8183 match[
2] = match[
4] || match[
5] ||
"";
8185 // Strip excess characters from unquoted arguments
8186 } else if ( unquoted && rpseudo.test( unquoted ) &&
8187 // Get excess from tokenize (recursively)
8188 (excess = tokenize( unquoted, true )) &&
8189 // advance to the next closing parenthesis
8190 (excess = unquoted.indexOf(
")", unquoted.length - excess ) - unquoted.length) ) {
8192 // excess is a negative index
8193 match[
0] = match[
0].slice(
0, excess );
8194 match[
2] = unquoted.slice(
0, excess );
8197 // Return only captures needed by the pseudo filter method (type and argument)
8198 return match.slice(
0,
3 );
8204 "TAG": function( nodeNameSelector ) {
8205 var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
8206 return nodeNameSelector ===
"*" ?
8207 function() { return true; } :
8209 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
8213 "CLASS": function( className ) {
8214 var pattern = classCache[ className +
" " ];
8217 (pattern = new RegExp(
"(^|" + whitespace +
")" + className +
"(" + whitespace +
"|$)" )) &&
8218 classCache( className, function( elem ) {
8219 return pattern.test( typeof elem.className ===
"string" && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute(
"class") ||
"" );
8223 "ATTR": function( name, operator, check ) {
8224 return function( elem ) {
8225 var result = Sizzle.attr( elem, name );
8227 if ( result == null ) {
8228 return operator ===
"!=";
8236 return operator ===
"=" ? result === check :
8237 operator ===
"!=" ? result !== check :
8238 operator ===
"^=" ? check && result.indexOf( check ) ===
0 :
8239 operator ===
"*=" ? check && result.indexOf( check )
> -
1 :
8240 operator === "$=" ? check && result.slice( -check.length ) === check :
8241 operator === "~=" ? ( " " + result + " " ).indexOf( check )
> -
1 :
8242 operator === "|=" ? result === check || result.slice(
0, check.length +
1 ) === check + "-" :
8247 "CHILD": function( type, what, argument, first, last ) {
8248 var simple = type.slice(
0,
3 ) !== "nth",
8249 forward = type.slice( -
4 ) !== "last",
8250 ofType = what === "of-type";
8252 return first ===
1 && last ===
0 ?
8254 // Shortcut for :nth-*(n)
8256 return !!elem.parentNode;
8259 function( elem, context, xml ) {
8260 var cache, outerCache, node, diff, nodeIndex, start,
8261 dir = simple !== forward ? "nextSibling" : "previousSibling",
8262 parent = elem.parentNode,
8263 name = ofType && elem.nodeName.toLowerCase(),
8264 useCache = !xml && !ofType;
8268 // :(first|last|only)-(child|of-type)
8272 while ( (node = node[ dir ]) ) {
8273 if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType ===
1 ) {
8277 // Reverse direction for :only-* (if we haven't yet done so)
8278 start = dir = type === "only" && !start && "nextSibling";
8283 start = [ forward ? parent.firstChild : parent.lastChild ];
8285 // non-xml :nth-child(...) stores cache data on `parent`
8286 if ( forward && useCache ) {
8287 // Seek `elem` from a previously-cached index
8288 outerCache = parent[ expando ] || (parent[ expando ] = {});
8289 cache = outerCache[ type ] || [];
8290 nodeIndex = cache[
0] === dirruns && cache[
1];
8291 diff = cache[
0] === dirruns && cache[
2];
8292 node = nodeIndex && parent.childNodes[ nodeIndex ];
8294 while ( (node = ++nodeIndex && node && node[ dir ] ||
8296 // Fallback to seeking `elem` from the start
8297 (diff = nodeIndex =
0) || start.pop()) ) {
8299 // When found, cache indexes on `parent` and break
8300 if ( node.nodeType ===
1 && ++diff && node === elem ) {
8301 outerCache[ type ] = [ dirruns, nodeIndex, diff ];
8306 // Use previously-cached element index if available
8307 } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[
0] === dirruns ) {
8310 // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
8312 // Use the same loop as above to seek `elem` from the start
8313 while ( (node = ++nodeIndex && node && node[ dir ] ||
8314 (diff = nodeIndex =
0) || start.pop()) ) {
8316 if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType ===
1 ) && ++diff ) {
8317 // Cache the index of each encountered element
8319 (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ];
8322 if ( node === elem ) {
8329 // Incorporate the offset, then check against cycle size
8331 return diff === first || ( diff % first ===
0 && diff / first
>=
0 );
8336 "PSEUDO": function( pseudo, argument ) {
8337 // pseudo-class names are case-insensitive
8338 // http://www.w3.org/TR/selectors/#pseudo-classes
8339 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
8340 // Remember that setFilters inherits from pseudos
8342 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
8343 Sizzle.error( "unsupported pseudo: " + pseudo );
8345 // The user may use createPseudo to indicate that
8346 // arguments are needed to create the filter function
8347 // just as Sizzle does
8348 if ( fn[ expando ] ) {
8349 return fn( argument );
8352 // But maintain support for old signatures
8353 if ( fn.length
> 1 ) {
8354 args = [ pseudo, pseudo,
"", argument ];
8355 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
8356 markFunction(function( seed, matches ) {
8358 matched = fn( seed, argument ),
8361 idx = indexOf.call( seed, matched[i] );
8362 seed[ idx ] = !( matches[ idx ] = matched[i] );
8366 return fn( elem,
0, args );
8375 // Potentially complex pseudos
8376 "not": markFunction(function( selector ) {
8377 // Trim the selector passed to compile
8378 // to avoid treating leading and trailing
8379 // spaces as combinators
8382 matcher = compile( selector.replace( rtrim,
"$1" ) );
8384 return matcher[ expando ] ?
8385 markFunction(function( seed, matches, context, xml ) {
8387 unmatched = matcher( seed, null, xml, [] ),
8390 // Match elements unmatched by `matcher`
8392 if ( (elem = unmatched[i]) ) {
8393 seed[i] = !(matches[i] = elem);
8397 function( elem, context, xml ) {
8399 matcher( input, null, xml, results );
8400 return !results.pop();
8404 "has": markFunction(function( selector ) {
8405 return function( elem ) {
8406 return Sizzle( selector, elem ).length
> 0;
8410 "contains": markFunction(function( text ) {
8411 return function( elem ) {
8412 return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text )
> -
1;
8416 // "Whether an element is represented by a :lang() selector
8417 // is based solely on the element's language value
8418 // being equal to the identifier C,
8419 // or beginning with the identifier C immediately followed by "-".
8420 // The matching of C against the element's language value is performed case-insensitively.
8421 // The identifier C does not have to be a valid language name."
8422 // http://www.w3.org/TR/selectors/#lang-pseudo
8423 "lang": markFunction( function( lang ) {
8424 // lang value must be a valid identifier
8425 if ( !ridentifier.test(lang || "") ) {
8426 Sizzle.error( "unsupported lang: " + lang );
8428 lang = lang.replace( runescape, funescape ).toLowerCase();
8429 return function( elem ) {
8432 if ( (elemLang = documentIsHTML ?
8434 elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
8436 elemLang = elemLang.toLowerCase();
8437 return elemLang === lang || elemLang.indexOf( lang + "-" ) ===
0;
8439 } while ( (elem = elem.parentNode) && elem.nodeType ===
1 );
8445 "target": function( elem ) {
8446 var hash = window.location && window.location.hash;
8447 return hash && hash.slice(
1 ) === elem.id;
8450 "root": function( elem ) {
8451 return elem === docElem;
8454 "focus": function( elem ) {
8455 return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
8458 // Boolean properties
8459 "enabled": function( elem ) {
8460 return elem.disabled === false;
8463 "disabled": function( elem ) {
8464 return elem.disabled === true;
8467 "checked": function( elem ) {
8468 // In CSS3, :checked should return both checked and selected elements
8469 // http://www.w3.org/TR/
2011/REC-css3-selectors-
20110929/#checked
8470 var nodeName = elem.nodeName.toLowerCase();
8471 return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
8474 "selected": function( elem ) {
8475 // Accessing this property makes selected-by-default
8476 // options in Safari work properly
8477 if ( elem.parentNode ) {
8478 elem.parentNode.selectedIndex;
8481 return elem.selected === true;
8485 "empty": function( elem ) {
8486 // http://www.w3.org/TR/selectors/#empty-pseudo
8487 // :empty is negated by element (
1) or content nodes (text:
3; cdata:
4; entity ref:
5),
8488 // but not by others (comment:
8; processing instruction:
7; etc.)
8489 // nodeType <
6 works because attributes (
2) do not appear as children
8490 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
8491 if ( elem.nodeType <
6 ) {
8498 "parent": function( elem ) {
8499 return !Expr.pseudos["empty"]( elem );
8502 // Element/input types
8503 "header": function( elem ) {
8504 return rheader.test( elem.nodeName );
8507 "input": function( elem ) {
8508 return rinputs.test( elem.nodeName );
8511 "button": function( elem ) {
8512 var name = elem.nodeName.toLowerCase();
8513 return name === "input" && elem.type === "button" || name === "button";
8516 "text": function( elem ) {
8518 return elem.nodeName.toLowerCase() === "input" &&
8519 elem.type === "text" &&
8522 // New HTML5 attribute values (e.g.,
"search") appear with elem.type ===
"text"
8523 ( (attr = elem.getAttribute(
"type")) == null || attr.toLowerCase() ===
"text" );
8526 // Position-in-collection
8527 "first": createPositionalPseudo(function() {
8531 "last": createPositionalPseudo(function( matchIndexes, length ) {
8532 return [ length -
1 ];
8535 "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
8536 return [ argument <
0 ? argument + length : argument ];
8539 "even": createPositionalPseudo(function( matchIndexes, length ) {
8541 for ( ; i < length; i +=
2 ) {
8542 matchIndexes.push( i );
8544 return matchIndexes;
8547 "odd": createPositionalPseudo(function( matchIndexes, length ) {
8549 for ( ; i < length; i +=
2 ) {
8550 matchIndexes.push( i );
8552 return matchIndexes;
8555 "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
8556 var i = argument <
0 ? argument + length : argument;
8557 for ( ; --i
>=
0; ) {
8558 matchIndexes.push( i );
8560 return matchIndexes;
8563 "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
8564 var i = argument <
0 ? argument + length : argument;
8565 for ( ; ++i < length; ) {
8566 matchIndexes.push( i );
8568 return matchIndexes;
8573 Expr.pseudos["nth"] = Expr.pseudos["eq"];
8575 // Add button/input type pseudos
8576 for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
8577 Expr.pseudos[ i ] = createInputPseudo( i );
8579 for ( i in { submit: true, reset: true } ) {
8580 Expr.pseudos[ i ] = createButtonPseudo( i );
8583 // Easy API for creating new setFilters
8584 function setFilters() {}
8585 setFilters.prototype = Expr.filters = Expr.pseudos;
8586 Expr.setFilters = new setFilters();
8588 tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
8589 var matched, match, tokens, type,
8590 soFar, groups, preFilters,
8591 cached = tokenCache[ selector + " " ];
8594 return parseOnly ?
0 : cached.slice(
0 );
8599 preFilters = Expr.preFilter;
8603 // Comma and first run
8604 if ( !matched || (match = rcomma.exec( soFar )) ) {
8606 // Don't consume trailing commas as valid
8607 soFar = soFar.slice( match[
0].length ) || soFar;
8609 groups.push( (tokens = []) );
8615 if ( (match = rcombinators.exec( soFar )) ) {
8616 matched = match.shift();
8619 // Cast descendant combinators to space
8620 type: match[
0].replace( rtrim, " " )
8622 soFar = soFar.slice( matched.length );
8626 for ( type in Expr.filter ) {
8627 if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
8628 (match = preFilters[ type ]( match ))) ) {
8629 matched = match.shift();
8635 soFar = soFar.slice( matched.length );
8644 // Return the length of the invalid excess
8645 // if we're just parsing
8646 // Otherwise, throw an error or return tokens
8650 Sizzle.error( selector ) :
8652 tokenCache( selector, groups ).slice(
0 );
8655 function toSelector( tokens ) {
8657 len = tokens.length,
8659 for ( ; i < len; i++ ) {
8660 selector += tokens[i].value;
8665 function addCombinator( matcher, combinator, base ) {
8666 var dir = combinator.dir,
8667 checkNonElements = base && dir === "parentNode",
8670 return combinator.first ?
8671 // Check against closest ancestor/preceding element
8672 function( elem, context, xml ) {
8673 while ( (elem = elem[ dir ]) ) {
8674 if ( elem.nodeType ===
1 || checkNonElements ) {
8675 return matcher( elem, context, xml );
8680 // Check against all ancestor/preceding elements
8681 function( elem, context, xml ) {
8682 var oldCache, outerCache,
8683 newCache = [ dirruns, doneName ];
8685 // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
8687 while ( (elem = elem[ dir ]) ) {
8688 if ( elem.nodeType ===
1 || checkNonElements ) {
8689 if ( matcher( elem, context, xml ) ) {
8695 while ( (elem = elem[ dir ]) ) {
8696 if ( elem.nodeType ===
1 || checkNonElements ) {
8697 outerCache = elem[ expando ] || (elem[ expando ] = {});
8698 if ( (oldCache = outerCache[ dir ]) &&
8699 oldCache[
0 ] === dirruns && oldCache[
1 ] === doneName ) {
8701 // Assign to newCache so results back-propagate to previous elements
8702 return (newCache[
2 ] = oldCache[
2 ]);
8704 // Reuse newcache so results back-propagate to previous elements
8705 outerCache[ dir ] = newCache;
8707 // A match means we're done; a fail means we have to keep checking
8708 if ( (newCache[
2 ] = matcher( elem, context, xml )) ) {
8718 function elementMatcher( matchers ) {
8719 return matchers.length
> 1 ?
8720 function( elem, context, xml ) {
8721 var i = matchers.length;
8723 if ( !matchers[i]( elem, context, xml ) ) {
8732 function multipleContexts( selector, contexts, results ) {
8734 len = contexts.length;
8735 for ( ; i < len; i++ ) {
8736 Sizzle( selector, contexts[i], results );
8741 function condense( unmatched, map, filter, context, xml ) {
8745 len = unmatched.length,
8746 mapped = map != null;
8748 for ( ; i < len; i++ ) {
8749 if ( (elem = unmatched[i]) ) {
8750 if ( !filter || filter( elem, context, xml ) ) {
8751 newUnmatched.push( elem );
8759 return newUnmatched;
8762 function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
8763 if ( postFilter && !postFilter[ expando ] ) {
8764 postFilter = setMatcher( postFilter );
8766 if ( postFinder && !postFinder[ expando ] ) {
8767 postFinder = setMatcher( postFinder, postSelector );
8769 return markFunction(function( seed, results, context, xml ) {
8773 preexisting = results.length,
8775 // Get initial elements from seed or context
8776 elems = seed || multipleContexts( selector ||
"*", context.nodeType ? [ context ] : context, [] ),
8778 // Prefilter to get matcher input, preserving a map for seed-results synchronization
8779 matcherIn = preFilter && ( seed || !selector ) ?
8780 condense( elems, preMap, preFilter, context, xml ) :
8783 matcherOut = matcher ?
8784 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
8785 postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
8787 // ...intermediate processing is necessary
8790 // ...otherwise use results directly
8794 // Find primary matches
8796 matcher( matcherIn, matcherOut, context, xml );
8801 temp = condense( matcherOut, postMap );
8802 postFilter( temp, [], context, xml );
8804 // Un-match failing elements by moving them back to matcherIn
8807 if ( (elem = temp[i]) ) {
8808 matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
8814 if ( postFinder || preFilter ) {
8816 // Get the final matcherOut by condensing this intermediate into postFinder contexts
8818 i = matcherOut.length;
8820 if ( (elem = matcherOut[i]) ) {
8821 // Restore matcherIn since elem is not yet a final match
8822 temp.push( (matcherIn[i] = elem) );
8825 postFinder( null, (matcherOut = []), temp, xml );
8828 // Move matched elements from seed to results to keep them synchronized
8829 i = matcherOut.length;
8831 if ( (elem = matcherOut[i]) &&
8832 (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i])
> -
1 ) {
8834 seed[temp] = !(results[temp] = elem);
8839 // Add elements to results, through postFinder if defined
8841 matcherOut = condense(
8842 matcherOut === results ?
8843 matcherOut.splice( preexisting, matcherOut.length ) :
8847 postFinder( null, results, matcherOut, xml );
8849 push.apply( results, matcherOut );
8855 function matcherFromTokens( tokens ) {
8856 var checkContext, matcher, j,
8857 len = tokens.length,
8858 leadingRelative = Expr.relative[ tokens[
0].type ],
8859 implicitRelative = leadingRelative || Expr.relative[" "],
8860 i = leadingRelative ?
1 :
0,
8862 // The foundational matcher ensures that elements are reachable from top-level context(s)
8863 matchContext = addCombinator( function( elem ) {
8864 return elem === checkContext;
8865 }, implicitRelative, true ),
8866 matchAnyContext = addCombinator( function( elem ) {
8867 return indexOf.call( checkContext, elem )
> -
1;
8868 }, implicitRelative, true ),
8869 matchers = [ function( elem, context, xml ) {
8870 return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
8871 (checkContext = context).nodeType ?
8872 matchContext( elem, context, xml ) :
8873 matchAnyContext( elem, context, xml ) );
8876 for ( ; i < len; i++ ) {
8877 if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
8878 matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
8880 matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
8882 // Return special upon seeing a positional matcher
8883 if ( matcher[ expando ] ) {
8884 // Find the next relative operator (if any) for proper handling
8886 for ( ; j < len; j++ ) {
8887 if ( Expr.relative[ tokens[j].type ] ) {
8892 i
> 1 && elementMatcher( matchers ),
8893 i
> 1 && toSelector(
8894 // If the preceding token was a descendant combinator, insert an implicit any-element `*`
8895 tokens.slice(
0, i -
1 ).concat({ value: tokens[ i -
2 ].type ===
" " ?
"*" :
"" })
8896 ).replace( rtrim,
"$1" ),
8898 i < j && matcherFromTokens( tokens.slice( i, j ) ),
8899 j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
8900 j < len && toSelector( tokens )
8903 matchers.push( matcher );
8907 return elementMatcher( matchers );
8910 function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
8911 var bySet = setMatchers.length
> 0,
8912 byElement = elementMatchers.length
> 0,
8913 superMatcher = function( seed, context, xml, results, outermost ) {
8914 var elem, j, matcher,
8917 unmatched = seed && [],
8919 contextBackup = outermostContext,
8920 // We must always have either seed elements or outermost context
8921 elems = seed || byElement && Expr.find[
"TAG"](
"*", outermost ),
8922 // Use integer dirruns iff this is the outermost matcher
8923 dirrunsUnique = (dirruns += contextBackup == null ?
1 : Math.random() ||
0.1),
8927 outermostContext = context !== document && context;
8930 // Add elements passing elementMatchers directly to results
8931 // Keep `i` a string if there are no elements so `matchedCount` will be
"00" below
8932 // Support: IE
<9, Safari
8933 // Tolerate NodeList properties (IE:
"length"; Safari:
<number>) matching elements by id
8934 for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
8935 if ( byElement && elem ) {
8937 while ( (matcher = elementMatchers[j++]) ) {
8938 if ( matcher( elem, context, xml ) ) {
8939 results.push( elem );
8944 dirruns = dirrunsUnique;
8948 // Track unmatched elements for set filters
8950 // They will have gone through all possible matchers
8951 if ( (elem = !matcher && elem) ) {
8955 // Lengthen the array for every element, matched or not
8957 unmatched.push( elem );
8962 // Apply set filters to unmatched elements
8964 if ( bySet && i !== matchedCount ) {
8966 while ( (matcher = setMatchers[j++]) ) {
8967 matcher( unmatched, setMatched, context, xml );
8971 // Reintegrate element matches to eliminate the need for sorting
8972 if ( matchedCount
> 0 ) {
8974 if ( !(unmatched[i] || setMatched[i]) ) {
8975 setMatched[i] = pop.call( results );
8980 // Discard index placeholder values to get only actual matches
8981 setMatched = condense( setMatched );
8984 // Add matches to results
8985 push.apply( results, setMatched );
8987 // Seedless set matches succeeding multiple successful matchers stipulate sorting
8988 if ( outermost && !seed && setMatched.length
> 0 &&
8989 ( matchedCount + setMatchers.length )
> 1 ) {
8991 Sizzle.uniqueSort( results );
8995 // Override manipulation of globals by nested matchers
8997 dirruns = dirrunsUnique;
8998 outermostContext = contextBackup;
9005 markFunction( superMatcher ) :
9009 compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
9012 elementMatchers = [],
9013 cached = compilerCache[ selector +
" " ];
9016 // Generate a function of recursive functions that can be used to check each element
9018 match = tokenize( selector );
9022 cached = matcherFromTokens( match[i] );
9023 if ( cached[ expando ] ) {
9024 setMatchers.push( cached );
9026 elementMatchers.push( cached );
9030 // Cache the compiled function
9031 cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
9033 // Save selector and tokenization
9034 cached.selector = selector;
9040 * A low-level selection function that works with Sizzle's compiled
9041 * selector functions
9042 * @param {String|Function} selector A selector or a pre-compiled
9043 * selector function built with Sizzle.compile
9044 * @param {Element} context
9045 * @param {Array} [results]
9046 * @param {Array} [seed] A set of elements to match against
9048 select = Sizzle.select = function( selector, context, results, seed ) {
9049 var i, tokens, token, type, find,
9050 compiled = typeof selector ===
"function" && selector,
9051 match = !seed && tokenize( (selector = compiled.selector || selector) );
9053 results = results || [];
9055 // Try to minimize operations if there is no seed and only one group
9056 if ( match.length ===
1 ) {
9058 // Take a shortcut and set the context if the root selector is an ID
9059 tokens = match[
0] = match[
0].slice(
0 );
9060 if ( tokens.length
> 2 && (token = tokens[
0]).type ===
"ID" &&
9061 support.getById && context.nodeType ===
9 && documentIsHTML &&
9062 Expr.relative[ tokens[
1].type ] ) {
9064 context = ( Expr.find[
"ID"]( token.matches[
0].replace(runescape, funescape), context ) || [] )[
0];
9068 // Precompiled matchers will still verify ancestry, so step up a level
9069 } else if ( compiled ) {
9070 context = context.parentNode;
9073 selector = selector.slice( tokens.shift().value.length );
9076 // Fetch a seed set for right-to-left matching
9077 i = matchExpr[
"needsContext"].test( selector ) ?
0 : tokens.length;
9081 // Abort if we hit a combinator
9082 if ( Expr.relative[ (type = token.type) ] ) {
9085 if ( (find = Expr.find[ type ]) ) {
9086 // Search, expanding context for leading sibling combinators
9088 token.matches[
0].replace( runescape, funescape ),
9089 rsibling.test( tokens[
0].type ) && testContext( context.parentNode ) || context
9092 // If seed is empty or no tokens remain, we can return early
9093 tokens.splice( i,
1 );
9094 selector = seed.length && toSelector( tokens );
9096 push.apply( results, seed );
9106 // Compile and execute a filtering function if one is not provided
9107 // Provide `match` to avoid retokenization if we modified the selector above
9108 ( compiled || compile( selector, match ) )(
9113 rsibling.test( selector ) && testContext( context.parentNode ) || context
9118 // One-time assignments
9121 support.sortStable = expando.split(
"").sort( sortOrder ).join(
"") === expando;
9123 // Support: Chrome
<14
9124 // Always assume duplicates if they aren't passed to the comparison function
9125 support.detectDuplicates = !!hasDuplicate;
9127 // Initialize against the default document
9130 // Support: Webkit
<537.32 - Safari
6.0.3/Chrome
25 (fixed in Chrome
27)
9131 // Detached nodes confoundingly follow *each other*
9132 support.sortDetached = assert(function( div1 ) {
9133 // Should return
1, but returns
4 (following)
9134 return div1.compareDocumentPosition( document.createElement(
"div") ) &
1;
9138 // Prevent attribute/property
"interpolation"
9139 // http://msdn.microsoft.com/en-us/library/ms536429%
28VS
.85%
29.aspx
9140 if ( !assert(function( div ) {
9141 div.innerHTML =
"<a href='#'></a>";
9142 return div.firstChild.getAttribute(
"href") ===
"#" ;
9144 addHandle(
"type|href|height|width", function( elem, name, isXML ) {
9146 return elem.getAttribute( name, name.toLowerCase() ===
"type" ?
1 :
2 );
9152 // Use defaultValue in place of getAttribute(
"value")
9153 if ( !support.attributes || !assert(function( div ) {
9154 div.innerHTML =
"<input/>";
9155 div.firstChild.setAttribute(
"value",
"" );
9156 return div.firstChild.getAttribute(
"value" ) ===
"";
9158 addHandle(
"value", function( elem, name, isXML ) {
9159 if ( !isXML && elem.nodeName.toLowerCase() ===
"input" ) {
9160 return elem.defaultValue;
9166 // Use getAttributeNode to fetch booleans when getAttribute lies
9167 if ( !assert(function( div ) {
9168 return div.getAttribute(
"disabled") == null;
9170 addHandle( booleans, function( elem, name, isXML ) {
9173 return elem[ name ] === true ? name.toLowerCase() :
9174 (val = elem.getAttributeNode( name )) && val.specified ?
9187 jQuery.find = Sizzle;
9188 jQuery.expr = Sizzle.selectors;
9189 jQuery.expr[
":"] = jQuery.expr.pseudos;
9190 jQuery.unique = Sizzle.uniqueSort;
9191 jQuery.text = Sizzle.getText;
9192 jQuery.isXMLDoc = Sizzle.isXML;
9193 jQuery.contains = Sizzle.contains;
9197 var rneedsContext = jQuery.expr.match.needsContext;
9199 var rsingleTag = (/^<(\w+)\s*\/
?>(?:<\/\
1>|)$/);
9203 var risSimple = /^.[^:#\[\.,]*$/;
9205 // Implement the identical functionality for filter and not
9206 function winnow( elements, qualifier, not ) {
9207 if ( jQuery.isFunction( qualifier ) ) {
9208 return jQuery.grep( elements, function( elem, i ) {
9210 return !!qualifier.call( elem, i, elem ) !== not;
9215 if ( qualifier.nodeType ) {
9216 return jQuery.grep( elements, function( elem ) {
9217 return ( elem === qualifier ) !== not;
9222 if ( typeof qualifier === "string" ) {
9223 if ( risSimple.test( qualifier ) ) {
9224 return jQuery.filter( qualifier, elements, not );
9227 qualifier = jQuery.filter( qualifier, elements );
9230 return jQuery.grep( elements, function( elem ) {
9231 return ( indexOf.call( qualifier, elem )
>=
0 ) !== not;
9235 jQuery.filter = function( expr, elems, not ) {
9236 var elem = elems[
0 ];
9239 expr = ":not(" + expr + ")";
9242 return elems.length ===
1 && elem.nodeType ===
1 ?
9243 jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
9244 jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
9245 return elem.nodeType ===
1;
9250 find: function( selector ) {
9256 if ( typeof selector !== "string" ) {
9257 return this.pushStack( jQuery( selector ).filter(function() {
9258 for ( i =
0; i < len; i++ ) {
9259 if ( jQuery.contains( self[ i ], this ) ) {
9266 for ( i =
0; i < len; i++ ) {
9267 jQuery.find( selector, self[ i ], ret );
9270 // Needed because $( selector, context ) becomes $( context ).find( selector )
9271 ret = this.pushStack( len
> 1 ? jQuery.unique( ret ) : ret );
9272 ret.selector = this.selector ? this.selector +
" " + selector : selector;
9275 filter: function( selector ) {
9276 return this.pushStack( winnow(this, selector || [], false) );
9278 not: function( selector ) {
9279 return this.pushStack( winnow(this, selector || [], true) );
9281 is: function( selector ) {
9285 // If this is a positional/relative selector, check membership in the returned set
9286 // so $(
"p:first").is(
"p:last") won't return true for a doc with two
"p".
9287 typeof selector ===
"string" && rneedsContext.test( selector ) ?
9288 jQuery( selector ) :
9296 // Initialize a jQuery object
9299 // A central reference to the root jQuery(document)
9302 // A simple way to check for HTML strings
9303 // Prioritize #id over
<tag> to avoid XSS via location.hash (#
9521)
9304 // Strict HTML recognition (#
11290: must start with <)
9305 rquickExpr = /^(?:\s*(<[\w\W]+
>)[^
>]*|#([\w-]*))$/,
9307 init = jQuery.fn.init = function( selector, context ) {
9310 // HANDLE: $(""), $(null), $(undefined), $(false)
9315 // Handle HTML strings
9316 if ( typeof selector === "string" ) {
9317 if ( selector[
0] === "<" && selector[ selector.length -
1 ] === "
>" && selector.length >= 3 ) {
9318 // Assume that strings that start and end with <> are HTML and skip the regex check
9319 match = [ null, selector, null ];
9322 match = rquickExpr.exec( selector );
9325 // Match html or make sure no context is specified for #id
9326 if ( match && (match[1] || !context) ) {
9328 // HANDLE: $(html) -> $(array)
9330 context = context instanceof jQuery ? context[0] : context;
9332 // scripts is true for back-compat
9333 // Intentionally let the error be thrown if parseHTML is not present
9334 jQuery.merge( this, jQuery.parseHTML(
9336 context && context.nodeType ? context.ownerDocument || context : document,
9340 // HANDLE: $(html, props)
9341 if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
9342 for ( match in context ) {
9343 // Properties of context are called as methods if possible
9344 if ( jQuery.isFunction( this[ match ] ) ) {
9345 this[ match ]( context[ match ] );
9347 // ...and otherwise set as attributes
9349 this.attr( match, context[ match ] );
9358 elem = document.getElementById( match[2] );
9360 // Check parentNode to catch when Blackberry 4.6 returns
9361 // nodes that are no longer in the document #6963
9362 if ( elem && elem.parentNode ) {
9363 // Inject the element directly into the jQuery object
9368 this.context = document;
9369 this.selector = selector;
9373 // HANDLE: $(expr, $(...))
9374 } else if ( !context || context.jquery ) {
9375 return ( context || rootjQuery ).find( selector );
9377 // HANDLE: $(expr, context)
9378 // (which is just equivalent to: $(context).find(expr)
9380 return this.constructor( context ).find( selector );
9383 // HANDLE: $(DOMElement)
9384 } else if ( selector.nodeType ) {
9385 this.context = this[0] = selector;
9389 // HANDLE: $(function)
9390 // Shortcut for document ready
9391 } else if ( jQuery.isFunction( selector ) ) {
9392 return typeof rootjQuery.ready !== "undefined" ?
9393 rootjQuery.ready( selector ) :
9394 // Execute immediately if ready is not present
9398 if ( selector.selector !== undefined ) {
9399 this.selector = selector.selector;
9400 this.context = selector.context;
9403 return jQuery.makeArray( selector, this );
9406 // Give the init function the jQuery prototype for later instantiation
9407 init.prototype = jQuery.fn;
9409 // Initialize central reference
9410 rootjQuery = jQuery( document );
9413 var rparentsprev = /^(?:parents|prev(?:Until|All))/,
9414 // methods guaranteed to produce a unique set when starting from a unique set
9415 guaranteedUnique = {
9423 dir: function( elem, dir, until ) {
9425 truncate = until !== undefined;
9427 while ( (elem = elem[ dir ]) && elem.nodeType !==
9 ) {
9428 if ( elem.nodeType ===
1 ) {
9429 if ( truncate && jQuery( elem ).is( until ) ) {
9432 matched.push( elem );
9438 sibling: function( n, elem ) {
9441 for ( ; n; n = n.nextSibling ) {
9442 if ( n.nodeType ===
1 && n !== elem ) {
9452 has: function( target ) {
9453 var targets = jQuery( target, this ),
9456 return this.filter(function() {
9458 for ( ; i < l; i++ ) {
9459 if ( jQuery.contains( this, targets[i] ) ) {
9466 closest: function( selectors, context ) {
9471 pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
9472 jQuery( selectors, context || this.context ) :
9475 for ( ; i < l; i++ ) {
9476 for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) {
9477 // Always skip document fragments
9478 if ( cur.nodeType <
11 && (pos ?
9479 pos.index(cur)
> -
1 :
9481 // Don't pass non-elements to Sizzle
9482 cur.nodeType ===
1 &&
9483 jQuery.find.matchesSelector(cur, selectors)) ) {
9485 matched.push( cur );
9491 return this.pushStack( matched.length
> 1 ? jQuery.unique( matched ) : matched );
9494 // Determine the position of an element within
9495 // the matched set of elements
9496 index: function( elem ) {
9498 // No argument, return index in parent
9500 return ( this[
0 ] && this[
0 ].parentNode ) ? this.first().prevAll().length : -
1;
9503 // index in selector
9504 if ( typeof elem ===
"string" ) {
9505 return indexOf.call( jQuery( elem ), this[
0 ] );
9508 // Locate the position of the desired element
9509 return indexOf.call( this,
9511 // If it receives a jQuery object, the first element is used
9512 elem.jquery ? elem[
0 ] : elem
9516 add: function( selector, context ) {
9517 return this.pushStack(
9519 jQuery.merge( this.get(), jQuery( selector, context ) )
9524 addBack: function( selector ) {
9525 return this.add( selector == null ?
9526 this.prevObject : this.prevObject.filter(selector)
9531 function sibling( cur, dir ) {
9532 while ( (cur = cur[dir]) && cur.nodeType !==
1 ) {}
9537 parent: function( elem ) {
9538 var parent = elem.parentNode;
9539 return parent && parent.nodeType !==
11 ? parent : null;
9541 parents: function( elem ) {
9542 return jQuery.dir( elem,
"parentNode" );
9544 parentsUntil: function( elem, i, until ) {
9545 return jQuery.dir( elem,
"parentNode", until );
9547 next: function( elem ) {
9548 return sibling( elem,
"nextSibling" );
9550 prev: function( elem ) {
9551 return sibling( elem,
"previousSibling" );
9553 nextAll: function( elem ) {
9554 return jQuery.dir( elem,
"nextSibling" );
9556 prevAll: function( elem ) {
9557 return jQuery.dir( elem,
"previousSibling" );
9559 nextUntil: function( elem, i, until ) {
9560 return jQuery.dir( elem,
"nextSibling", until );
9562 prevUntil: function( elem, i, until ) {
9563 return jQuery.dir( elem,
"previousSibling", until );
9565 siblings: function( elem ) {
9566 return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
9568 children: function( elem ) {
9569 return jQuery.sibling( elem.firstChild );
9571 contents: function( elem ) {
9572 return elem.contentDocument || jQuery.merge( [], elem.childNodes );
9574 }, function( name, fn ) {
9575 jQuery.fn[ name ] = function( until, selector ) {
9576 var matched = jQuery.map( this, fn, until );
9578 if ( name.slice( -
5 ) !==
"Until" ) {
9582 if ( selector && typeof selector ===
"string" ) {
9583 matched = jQuery.filter( selector, matched );
9586 if ( this.length
> 1 ) {
9587 // Remove duplicates
9588 if ( !guaranteedUnique[ name ] ) {
9589 jQuery.unique( matched );
9592 // Reverse order for parents* and prev-derivatives
9593 if ( rparentsprev.test( name ) ) {
9598 return this.pushStack( matched );
9601 var rnotwhite = (/\S+/g);
9605 // String to Object options format cache
9606 var optionsCache = {};
9608 // Convert String-formatted options into Object-formatted ones and store in cache
9609 function createOptions( options ) {
9610 var object = optionsCache[ options ] = {};
9611 jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) {
9612 object[ flag ] = true;
9618 * Create a callback list using the following parameters:
9620 * options: an optional list of space-separated options that will change how
9621 * the callback list behaves or a more traditional option object
9623 * By default a callback list will act like an event callback list and can be
9624 *
"fired" multiple times.
9628 * once: will ensure the callback list can only be fired once (like a Deferred)
9630 * memory: will keep track of previous values and will call any callback added
9631 * after the list has been fired right away with the latest
"memorized"
9632 * values (like a Deferred)
9634 * unique: will ensure a callback can only be added once (no duplicate in the list)
9636 * stopOnFalse: interrupt callings when a callback returns false
9639 jQuery.Callbacks = function( options ) {
9641 // Convert options from String-formatted to Object-formatted if needed
9642 // (we check in cache first)
9643 options = typeof options ===
"string" ?
9644 ( optionsCache[ options ] || createOptions( options ) ) :
9645 jQuery.extend( {}, options );
9647 var // Last fire value (for non-forgettable lists)
9649 // Flag to know if list was already fired
9651 // Flag to know if list is currently firing
9653 // First callback to fire (used internally by add and fireWith)
9655 // End of the loop when firing
9657 // Index of currently firing callback (modified by remove if needed)
9659 // Actual callback list
9661 // Stack of fire calls for repeatable lists
9662 stack = !options.once && [],
9664 fire = function( data ) {
9665 memory = options.memory && data;
9667 firingIndex = firingStart ||
0;
9669 firingLength = list.length;
9671 for ( ; list && firingIndex < firingLength; firingIndex++ ) {
9672 if ( list[ firingIndex ].apply( data[
0 ], data[
1 ] ) === false && options.stopOnFalse ) {
9673 memory = false; // To prevent further calls using add
9680 if ( stack.length ) {
9681 fire( stack.shift() );
9683 } else if ( memory ) {
9690 // Actual Callbacks object
9692 // Add a callback or a collection of callbacks to the list
9695 // First, we save the current length
9696 var start = list.length;
9697 (function add( args ) {
9698 jQuery.each( args, function( _, arg ) {
9699 var type = jQuery.type( arg );
9700 if ( type ===
"function" ) {
9701 if ( !options.unique || !self.has( arg ) ) {
9704 } else if ( arg && arg.length && type !==
"string" ) {
9705 // Inspect recursively
9710 // Do we need to add the callbacks to the
9711 // current firing batch?
9713 firingLength = list.length;
9714 // With memory, if we're not firing then
9715 // we should call right away
9716 } else if ( memory ) {
9717 firingStart = start;
9723 // Remove a callback from the list
9724 remove: function() {
9726 jQuery.each( arguments, function( _, arg ) {
9728 while ( ( index = jQuery.inArray( arg, list, index ) )
> -
1 ) {
9729 list.splice( index,
1 );
9730 // Handle firing indexes
9732 if ( index <= firingLength ) {
9735 if ( index <= firingIndex ) {
9744 // Check if a given callback is in the list.
9745 // If no argument is given, return whether or not list has callbacks attached.
9746 has: function( fn ) {
9747 return fn ? jQuery.inArray( fn, list )
> -
1 : !!( list && list.length );
9749 // Remove all callbacks from the list
9755 // Have the list do nothing anymore
9756 disable: function() {
9757 list = stack = memory = undefined;
9761 disabled: function() {
9764 // Lock the list in its current state
9773 locked: function() {
9776 // Call all callbacks with the given context and arguments
9777 fireWith: function( context, args ) {
9778 if ( list && ( !fired || stack ) ) {
9780 args = [ context, args.slice ? args.slice() : args ];
9789 // Call all the callbacks with the given arguments
9791 self.fireWith( this, arguments );
9794 // To know if the callbacks have already been called at least once
9806 Deferred: function( func ) {
9808 // action, add listener, listener list, final state
9809 [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
9810 [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
9811 [ "notify", "progress", jQuery.Callbacks("memory") ]
9818 always: function() {
9819 deferred.done( arguments ).fail( arguments );
9822 then: function( /* fnDone, fnFail, fnProgress */ ) {
9823 var fns = arguments;
9824 return jQuery.Deferred(function( newDefer ) {
9825 jQuery.each( tuples, function( i, tuple ) {
9826 var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
9827 // deferred[ done | fail | progress ] for forwarding actions to newDefer
9828 deferred[ tuple[
1] ](function() {
9829 var returned = fn && fn.apply( this, arguments );
9830 if ( returned && jQuery.isFunction( returned.promise ) ) {
9832 .done( newDefer.resolve )
9833 .fail( newDefer.reject )
9834 .progress( newDefer.notify );
9836 newDefer[ tuple[
0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments );
9843 // Get a promise for this deferred
9844 // If obj is provided, the promise aspect is added to the object
9845 promise: function( obj ) {
9846 return obj != null ? jQuery.extend( obj, promise ) : promise;
9851 // Keep pipe for back-compat
9852 promise.pipe = promise.then;
9854 // Add list-specific methods
9855 jQuery.each( tuples, function( i, tuple ) {
9856 var list = tuple[
2 ],
9857 stateString = tuple[
3 ];
9859 // promise[ done | fail | progress ] = list.add
9860 promise[ tuple[
1] ] = list.add;
9863 if ( stateString ) {
9864 list.add(function() {
9865 // state = [ resolved | rejected ]
9866 state = stateString;
9868 // [ reject_list | resolve_list ].disable; progress_list.lock
9869 }, tuples[ i ^
1 ][
2 ].disable, tuples[
2 ][
2 ].lock );
9872 // deferred[ resolve | reject | notify ]
9873 deferred[ tuple[
0] ] = function() {
9874 deferred[ tuple[
0] + "With" ]( this === deferred ? promise : this, arguments );
9877 deferred[ tuple[
0] + "With" ] = list.fireWith;
9880 // Make the deferred a promise
9881 promise.promise( deferred );
9883 // Call given func if any
9885 func.call( deferred, deferred );
9893 when: function( subordinate /* , ..., subordinateN */ ) {
9895 resolveValues = slice.call( arguments ),
9896 length = resolveValues.length,
9898 // the count of uncompleted subordinates
9899 remaining = length !==
1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length :
0,
9901 // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
9902 deferred = remaining ===
1 ? subordinate : jQuery.Deferred(),
9904 // Update function for both resolve and progress values
9905 updateFunc = function( i, contexts, values ) {
9906 return function( value ) {
9907 contexts[ i ] = this;
9908 values[ i ] = arguments.length
> 1 ? slice.call( arguments ) : value;
9909 if ( values === progressValues ) {
9910 deferred.notifyWith( contexts, values );
9911 } else if ( !( --remaining ) ) {
9912 deferred.resolveWith( contexts, values );
9917 progressValues, progressContexts, resolveContexts;
9919 // add listeners to Deferred subordinates; treat others as resolved
9921 progressValues = new Array( length );
9922 progressContexts = new Array( length );
9923 resolveContexts = new Array( length );
9924 for ( ; i < length; i++ ) {
9925 if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
9926 resolveValues[ i ].promise()
9927 .done( updateFunc( i, resolveContexts, resolveValues ) )
9928 .fail( deferred.reject )
9929 .progress( updateFunc( i, progressContexts, progressValues ) );
9936 // if we're not waiting on anything, resolve the master
9938 deferred.resolveWith( resolveContexts, resolveValues );
9941 return deferred.promise();
9946 // The deferred used on DOM ready
9949 jQuery.fn.ready = function( fn ) {
9951 jQuery.ready.promise().done( fn );
9957 // Is the DOM ready to be used? Set to true once it occurs.
9960 // A counter to track how many items to wait for before
9961 // the ready event fires. See #
6781
9964 // Hold (or release) the ready event
9965 holdReady: function( hold ) {
9969 jQuery.ready( true );
9973 // Handle when the DOM is ready
9974 ready: function( wait ) {
9976 // Abort if there are pending holds or we're already ready
9977 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
9981 // Remember that the DOM is ready
9982 jQuery.isReady = true;
9984 // If a normal DOM Ready event fired, decrement, and wait if need be
9985 if ( wait !== true && --jQuery.readyWait
> 0 ) {
9989 // If there are functions bound, to execute
9990 readyList.resolveWith( document, [ jQuery ] );
9992 // Trigger any bound ready events
9993 if ( jQuery.fn.triggerHandler ) {
9994 jQuery( document ).triggerHandler(
"ready" );
9995 jQuery( document ).off(
"ready" );
10001 * The ready event handler and self cleanup method
10003 function completed() {
10004 document.removeEventListener(
"DOMContentLoaded", completed, false );
10005 window.removeEventListener(
"load", completed, false );
10009 jQuery.ready.promise = function( obj ) {
10010 if ( !readyList ) {
10012 readyList = jQuery.Deferred();
10014 // Catch cases where $(document).ready() is called after the browser event has already occurred.
10015 // we once tried to use readyState
"interactive" here, but it caused issues like the one
10016 // discovered by ChrisS here: http://bugs.jquery.com/ticket/
12282#comment:
15
10017 if ( document.readyState ===
"complete" ) {
10018 // Handle it asynchronously to allow scripts the opportunity to delay ready
10019 setTimeout( jQuery.ready );
10023 // Use the handy event callback
10024 document.addEventListener(
"DOMContentLoaded", completed, false );
10026 // A fallback to window.onload, that will always work
10027 window.addEventListener(
"load", completed, false );
10030 return readyList.promise( obj );
10033 // Kick off the DOM ready check even if the user does not
10034 jQuery.ready.promise();
10039 // Multifunctional method to get and set values of a collection
10040 // The value/s can optionally be executed if it's a function
10041 var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
10043 len = elems.length,
10044 bulk = key == null;
10046 // Sets many values
10047 if ( jQuery.type( key ) ===
"object" ) {
10050 jQuery.access( elems, fn, i, key[i], true, emptyGet, raw );
10054 } else if ( value !== undefined ) {
10057 if ( !jQuery.isFunction( value ) ) {
10062 // Bulk operations run against the entire set
10064 fn.call( elems, value );
10067 // ...except when executing function values
10070 fn = function( elem, key, value ) {
10071 return bulk.call( jQuery( elem ), value );
10077 for ( ; i < len; i++ ) {
10078 fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) );
10089 len ? fn( elems[
0], key ) : emptyGet;
10094 * Determines whether an object can have data
10096 jQuery.acceptData = function( owner ) {
10099 // - Node.ELEMENT_NODE
10100 // - Node.DOCUMENT_NODE
10104 return owner.nodeType ===
1 || owner.nodeType ===
9 || !( +owner.nodeType );
10109 // Support: Android <
4,
10110 // Old WebKit does not have Object.preventExtensions/freeze method,
10111 // return new empty object instead with no [[set]] accessor
10112 Object.defineProperty( this.cache = {},
0, {
10118 this.expando = jQuery.expando + Math.random();
10122 Data.accepts = jQuery.acceptData;
10125 key: function( owner ) {
10126 // We can accept data for non-element nodes in modern browsers,
10127 // but we should not, see #
8335.
10128 // Always return the key for a frozen object.
10129 if ( !Data.accepts( owner ) ) {
10133 var descriptor = {},
10134 // Check if the owner object already has a cache key
10135 unlock = owner[ this.expando ];
10137 // If not, create one
10139 unlock = Data.uid++;
10141 // Secure it in a non-enumerable, non-writable property
10143 descriptor[ this.expando ] = { value: unlock };
10144 Object.defineProperties( owner, descriptor );
10146 // Support: Android <
4
10147 // Fallback to a less secure definition
10149 descriptor[ this.expando ] = unlock;
10150 jQuery.extend( owner, descriptor );
10154 // Ensure the cache object
10155 if ( !this.cache[ unlock ] ) {
10156 this.cache[ unlock ] = {};
10161 set: function( owner, data, value ) {
10163 // There may be an unlock assigned to this node,
10164 // if there is no entry for this
"owner", create one inline
10165 // and set the unlock as though an owner entry had always existed
10166 unlock = this.key( owner ),
10167 cache = this.cache[ unlock ];
10169 // Handle: [ owner, key, value ] args
10170 if ( typeof data ===
"string" ) {
10171 cache[ data ] = value;
10173 // Handle: [ owner, { properties } ] args
10175 // Fresh assignments by object are shallow copied
10176 if ( jQuery.isEmptyObject( cache ) ) {
10177 jQuery.extend( this.cache[ unlock ], data );
10178 // Otherwise, copy the properties one-by-one to the cache object
10180 for ( prop in data ) {
10181 cache[ prop ] = data[ prop ];
10187 get: function( owner, key ) {
10188 // Either a valid cache is found, or will be created.
10189 // New caches will be created and the unlock returned,
10190 // allowing direct access to the newly created
10191 // empty data object. A valid owner object must be provided.
10192 var cache = this.cache[ this.key( owner ) ];
10194 return key === undefined ?
10195 cache : cache[ key ];
10197 access: function( owner, key, value ) {
10199 // In cases where either:
10201 //
1. No key was specified
10202 //
2. A string key was specified, but no value provided
10204 // Take the
"read" path and allow the get method to determine
10205 // which value to return, respectively either:
10207 //
1. The entire cache object
10208 //
2. The data stored at the key
10210 if ( key === undefined ||
10211 ((key && typeof key ===
"string") && value === undefined) ) {
10213 stored = this.get( owner, key );
10215 return stored !== undefined ?
10216 stored : this.get( owner, jQuery.camelCase(key) );
10219 // [*]When the key is not a string, or both a key and value
10220 // are specified, set or extend (existing objects) with either:
10222 //
1. An object of properties
10223 //
2. A key and value
10225 this.set( owner, key, value );
10227 // Since the
"set" path can have two possible entry points
10228 // return the expected data based on which path was taken[*]
10229 return value !== undefined ? value : key;
10231 remove: function( owner, key ) {
10232 var i, name, camel,
10233 unlock = this.key( owner ),
10234 cache = this.cache[ unlock ];
10236 if ( key === undefined ) {
10237 this.cache[ unlock ] = {};
10240 // Support array or space separated string of keys
10241 if ( jQuery.isArray( key ) ) {
10242 // If
"name" is an array of keys...
10243 // When data is initially created, via (
"key",
"val") signature,
10244 // keys will be converted to camelCase.
10245 // Since there is no way to tell _how_ a key was added, remove
10246 // both plain key and camelCase key. #
12786
10247 // This will only penalize the array argument path.
10248 name = key.concat( key.map( jQuery.camelCase ) );
10250 camel = jQuery.camelCase( key );
10251 // Try the string as a key before any manipulation
10252 if ( key in cache ) {
10253 name = [ key, camel ];
10255 // If a key with the spaces exists, use it.
10256 // Otherwise, create an array by matching non-whitespace
10258 name = name in cache ?
10259 [ name ] : ( name.match( rnotwhite ) || [] );
10265 delete cache[ name[ i ] ];
10269 hasData: function( owner ) {
10270 return !jQuery.isEmptyObject(
10271 this.cache[ owner[ this.expando ] ] || {}
10274 discard: function( owner ) {
10275 if ( owner[ this.expando ] ) {
10276 delete this.cache[ owner[ this.expando ] ];
10280 var data_priv = new Data();
10282 var data_user = new Data();
10287 Implementation Summary
10289 1. Enforce API surface and semantic compatibility with
1.9.x branch
10290 2. Improve the module's maintainability by reducing the storage
10291 paths to a single mechanism.
10292 3. Use the same single mechanism to support
"private" and
"user" data.
10293 4. _Never_ expose
"private" data to user code (TODO: Drop _data, _removeData)
10294 5. Avoid exposing implementation details on user objects (eg. expando properties)
10295 6. Provide a clear path for implementation upgrade to WeakMap in
2014
10297 var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
10298 rmultiDash = /([A-Z])/g;
10300 function dataAttr( elem, key, data ) {
10303 // If nothing was found internally, try to fetch any
10304 // data from the HTML5 data-* attribute
10305 if ( data === undefined && elem.nodeType ===
1 ) {
10306 name =
"data-" + key.replace( rmultiDash,
"-$1" ).toLowerCase();
10307 data = elem.getAttribute( name );
10309 if ( typeof data ===
"string" ) {
10311 data = data ===
"true" ? true :
10312 data ===
"false" ? false :
10313 data ===
"null" ? null :
10314 // Only convert to a number if it doesn't change the string
10315 +data +
"" === data ? +data :
10316 rbrace.test( data ) ? jQuery.parseJSON( data ) :
10320 // Make sure we set the data so it isn't changed later
10321 data_user.set( elem, key, data );
10330 hasData: function( elem ) {
10331 return data_user.hasData( elem ) || data_priv.hasData( elem );
10334 data: function( elem, name, data ) {
10335 return data_user.access( elem, name, data );
10338 removeData: function( elem, name ) {
10339 data_user.remove( elem, name );
10342 // TODO: Now that all calls to _data and _removeData have been replaced
10343 // with direct calls to data_priv methods, these can be deprecated.
10344 _data: function( elem, name, data ) {
10345 return data_priv.access( elem, name, data );
10348 _removeData: function( elem, name ) {
10349 data_priv.remove( elem, name );
10354 data: function( key, value ) {
10357 attrs = elem && elem.attributes;
10360 if ( key === undefined ) {
10361 if ( this.length ) {
10362 data = data_user.get( elem );
10364 if ( elem.nodeType ===
1 && !data_priv.get( elem,
"hasDataAttrs" ) ) {
10369 // The attrs elements can be null (#
14894)
10370 if ( attrs[ i ] ) {
10371 name = attrs[ i ].name;
10372 if ( name.indexOf(
"data-" ) ===
0 ) {
10373 name = jQuery.camelCase( name.slice(
5) );
10374 dataAttr( elem, name, data[ name ] );
10378 data_priv.set( elem,
"hasDataAttrs", true );
10385 // Sets multiple values
10386 if ( typeof key ===
"object" ) {
10387 return this.each(function() {
10388 data_user.set( this, key );
10392 return access( this, function( value ) {
10394 camelKey = jQuery.camelCase( key );
10396 // The calling jQuery object (element matches) is not empty
10397 // (and therefore has an element appears at this[
0 ]) and the
10398 // `value` parameter was not undefined. An empty jQuery object
10399 // will result in `undefined` for elem = this[
0 ] which will
10400 // throw an exception if an attempt to read a data cache is made.
10401 if ( elem && value === undefined ) {
10402 // Attempt to get data from the cache
10403 // with the key as-is
10404 data = data_user.get( elem, key );
10405 if ( data !== undefined ) {
10409 // Attempt to get data from the cache
10410 // with the key camelized
10411 data = data_user.get( elem, camelKey );
10412 if ( data !== undefined ) {
10416 // Attempt to
"discover" the data in
10417 // HTML5 custom data-* attrs
10418 data = dataAttr( elem, camelKey, undefined );
10419 if ( data !== undefined ) {
10423 // We tried really hard, but the data doesn't exist.
10428 this.each(function() {
10429 // First, attempt to store a copy or reference of any
10430 // data that might've been store with a camelCased key.
10431 var data = data_user.get( this, camelKey );
10433 // For HTML5 data-* attribute interop, we have to
10434 // store property names with dashes in a camelCase form.
10435 // This might not apply to all properties...*
10436 data_user.set( this, camelKey, value );
10438 // *... In the case of properties that might _actually_
10439 // have dashes, we need to also store a copy of that
10440 // unchanged property.
10441 if ( key.indexOf(
"-") !== -
1 && data !== undefined ) {
10442 data_user.set( this, key, value );
10445 }, null, value, arguments.length
> 1, null, true );
10448 removeData: function( key ) {
10449 return this.each(function() {
10450 data_user.remove( this, key );
10457 queue: function( elem, type, data ) {
10461 type = ( type ||
"fx" ) +
"queue";
10462 queue = data_priv.get( elem, type );
10464 // Speed up dequeue by getting out quickly if this is just a lookup
10466 if ( !queue || jQuery.isArray( data ) ) {
10467 queue = data_priv.access( elem, type, jQuery.makeArray(data) );
10469 queue.push( data );
10472 return queue || [];
10476 dequeue: function( elem, type ) {
10477 type = type ||
"fx";
10479 var queue = jQuery.queue( elem, type ),
10480 startLength = queue.length,
10481 fn = queue.shift(),
10482 hooks = jQuery._queueHooks( elem, type ),
10483 next = function() {
10484 jQuery.dequeue( elem, type );
10487 // If the fx queue is dequeued, always remove the progress sentinel
10488 if ( fn ===
"inprogress" ) {
10489 fn = queue.shift();
10495 // Add a progress sentinel to prevent the fx queue from being
10496 // automatically dequeued
10497 if ( type ===
"fx" ) {
10498 queue.unshift(
"inprogress" );
10501 // clear up the last queue stop function
10503 fn.call( elem, next, hooks );
10506 if ( !startLength && hooks ) {
10507 hooks.empty.fire();
10511 // not intended for public consumption - generates a queueHooks object, or returns the current one
10512 _queueHooks: function( elem, type ) {
10513 var key = type +
"queueHooks";
10514 return data_priv.get( elem, key ) || data_priv.access( elem, key, {
10515 empty: jQuery.Callbacks(
"once memory").add(function() {
10516 data_priv.remove( elem, [ type +
"queue", key ] );
10523 queue: function( type, data ) {
10526 if ( typeof type !==
"string" ) {
10532 if ( arguments.length < setter ) {
10533 return jQuery.queue( this[
0], type );
10536 return data === undefined ?
10538 this.each(function() {
10539 var queue = jQuery.queue( this, type, data );
10541 // ensure a hooks for this queue
10542 jQuery._queueHooks( this, type );
10544 if ( type ===
"fx" && queue[
0] !==
"inprogress" ) {
10545 jQuery.dequeue( this, type );
10549 dequeue: function( type ) {
10550 return this.each(function() {
10551 jQuery.dequeue( this, type );
10554 clearQueue: function( type ) {
10555 return this.queue( type ||
"fx", [] );
10557 // Get a promise resolved when queues of a certain type
10558 // are emptied (fx is the type by default)
10559 promise: function( type, obj ) {
10562 defer = jQuery.Deferred(),
10565 resolve = function() {
10566 if ( !( --count ) ) {
10567 defer.resolveWith( elements, [ elements ] );
10571 if ( typeof type !==
"string" ) {
10575 type = type ||
"fx";
10578 tmp = data_priv.get( elements[ i ], type +
"queueHooks" );
10579 if ( tmp && tmp.empty ) {
10581 tmp.empty.add( resolve );
10585 return defer.promise( obj );
10588 var pnum = (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source;
10590 var cssExpand = [
"Top",
"Right",
"Bottom",
"Left" ];
10592 var isHidden = function( elem, el ) {
10593 // isHidden might be called from jQuery#filter function;
10594 // in that case, element will be second argument
10596 return jQuery.css( elem,
"display" ) ===
"none" || !jQuery.contains( elem.ownerDocument, elem );
10599 var rcheckableType = (/^(?:checkbox|radio)$/i);
10604 var fragment = document.createDocumentFragment(),
10605 div = fragment.appendChild( document.createElement(
"div" ) ),
10606 input = document.createElement(
"input" );
10608 // #
11217 - WebKit loses check when the name is after the checked attribute
10609 // Support: Windows Web Apps (WWA)
10610 // `name` and `type` need .setAttribute for WWA
10611 input.setAttribute(
"type",
"radio" );
10612 input.setAttribute(
"checked",
"checked" );
10613 input.setAttribute(
"name",
"t" );
10615 div.appendChild( input );
10617 // Support: Safari
5.1, iOS
5.1, Android
4.x, Android
2.3
10618 // old WebKit doesn't clone checked state correctly in fragments
10619 support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
10621 // Make sure textarea (and checkbox) defaultValue is properly cloned
10622 // Support: IE9-IE11+
10623 div.innerHTML =
"<textarea>x</textarea>";
10624 support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
10626 var strundefined = typeof undefined;
10630 support.focusinBubbles =
"onfocusin" in window;
10634 rkeyEvent = /^key/,
10635 rmouseEvent = /^(?:mouse|pointer|contextmenu)|click/,
10636 rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
10637 rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
10639 function returnTrue() {
10643 function returnFalse() {
10647 function safeActiveElement() {
10649 return document.activeElement;
10650 } catch ( err ) { }
10654 * Helper functions for managing events -- not part of the public interface.
10655 * Props to Dean Edwards' addEvent library for many of the ideas.
10661 add: function( elem, types, handler, data, selector ) {
10663 var handleObjIn, eventHandle, tmp,
10664 events, t, handleObj,
10665 special, handlers, type, namespaces, origType,
10666 elemData = data_priv.get( elem );
10668 // Don't attach events to noData or text/comment nodes (but allow plain objects)
10673 // Caller can pass in an object of custom data in lieu of the handler
10674 if ( handler.handler ) {
10675 handleObjIn = handler;
10676 handler = handleObjIn.handler;
10677 selector = handleObjIn.selector;
10680 // Make sure that the handler has a unique ID, used to find/remove it later
10681 if ( !handler.guid ) {
10682 handler.guid = jQuery.guid++;
10685 // Init the element's event structure and main handler, if this is the first
10686 if ( !(events = elemData.events) ) {
10687 events = elemData.events = {};
10689 if ( !(eventHandle = elemData.handle) ) {
10690 eventHandle = elemData.handle = function( e ) {
10691 // Discard the second event of a jQuery.event.trigger() and
10692 // when an event is called after a page has unloaded
10693 return typeof jQuery !== strundefined && jQuery.event.triggered !== e.type ?
10694 jQuery.event.dispatch.apply( elem, arguments ) : undefined;
10698 // Handle multiple events separated by a space
10699 types = ( types ||
"" ).match( rnotwhite ) || [
"" ];
10702 tmp = rtypenamespace.exec( types[t] ) || [];
10703 type = origType = tmp[
1];
10704 namespaces = ( tmp[
2] ||
"" ).split(
"." ).sort();
10706 // There *must* be a type, no attaching namespace-only handlers
10711 // If event changes its type, use the special event handlers for the changed type
10712 special = jQuery.event.special[ type ] || {};
10714 // If selector defined, determine special event api type, otherwise given type
10715 type = ( selector ? special.delegateType : special.bindType ) || type;
10717 // Update special based on newly reset type
10718 special = jQuery.event.special[ type ] || {};
10720 // handleObj is passed to all event handlers
10721 handleObj = jQuery.extend({
10723 origType: origType,
10726 guid: handler.guid,
10727 selector: selector,
10728 needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
10729 namespace: namespaces.join(
".")
10732 // Init the event handler queue if we're the first
10733 if ( !(handlers = events[ type ]) ) {
10734 handlers = events[ type ] = [];
10735 handlers.delegateCount =
0;
10737 // Only use addEventListener if the special events handler returns false
10738 if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
10739 if ( elem.addEventListener ) {
10740 elem.addEventListener( type, eventHandle, false );
10745 if ( special.add ) {
10746 special.add.call( elem, handleObj );
10748 if ( !handleObj.handler.guid ) {
10749 handleObj.handler.guid = handler.guid;
10753 // Add to the element's handler list, delegates in front
10755 handlers.splice( handlers.delegateCount++,
0, handleObj );
10757 handlers.push( handleObj );
10760 // Keep track of which events have ever been used, for event optimization
10761 jQuery.event.global[ type ] = true;
10766 // Detach an event or set of events from an element
10767 remove: function( elem, types, handler, selector, mappedTypes ) {
10769 var j, origCount, tmp,
10770 events, t, handleObj,
10771 special, handlers, type, namespaces, origType,
10772 elemData = data_priv.hasData( elem ) && data_priv.get( elem );
10774 if ( !elemData || !(events = elemData.events) ) {
10778 // Once for each type.namespace in types; type may be omitted
10779 types = ( types ||
"" ).match( rnotwhite ) || [
"" ];
10782 tmp = rtypenamespace.exec( types[t] ) || [];
10783 type = origType = tmp[
1];
10784 namespaces = ( tmp[
2] ||
"" ).split(
"." ).sort();
10786 // Unbind all events (on this namespace, if provided) for the element
10788 for ( type in events ) {
10789 jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
10794 special = jQuery.event.special[ type ] || {};
10795 type = ( selector ? special.delegateType : special.bindType ) || type;
10796 handlers = events[ type ] || [];
10797 tmp = tmp[
2] && new RegExp(
"(^|\\.)" + namespaces.join(
"\\.(?:.*\\.|)") +
"(\\.|$)" );
10799 // Remove matching events
10800 origCount = j = handlers.length;
10802 handleObj = handlers[ j ];
10804 if ( ( mappedTypes || origType === handleObj.origType ) &&
10805 ( !handler || handler.guid === handleObj.guid ) &&
10806 ( !tmp || tmp.test( handleObj.namespace ) ) &&
10807 ( !selector || selector === handleObj.selector || selector ===
"**" && handleObj.selector ) ) {
10808 handlers.splice( j,
1 );
10810 if ( handleObj.selector ) {
10811 handlers.delegateCount--;
10813 if ( special.remove ) {
10814 special.remove.call( elem, handleObj );
10819 // Remove generic event handler if we removed something and no more handlers exist
10820 // (avoids potential for endless recursion during removal of special event handlers)
10821 if ( origCount && !handlers.length ) {
10822 if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
10823 jQuery.removeEvent( elem, type, elemData.handle );
10826 delete events[ type ];
10830 // Remove the expando if it's no longer used
10831 if ( jQuery.isEmptyObject( events ) ) {
10832 delete elemData.handle;
10833 data_priv.remove( elem,
"events" );
10837 trigger: function( event, data, elem, onlyHandlers ) {
10839 var i, cur, tmp, bubbleType, ontype, handle, special,
10840 eventPath = [ elem || document ],
10841 type = hasOwn.call( event,
"type" ) ? event.type : event,
10842 namespaces = hasOwn.call( event,
"namespace" ) ? event.namespace.split(
".") : [];
10844 cur = tmp = elem = elem || document;
10846 // Don't do events on text and comment nodes
10847 if ( elem.nodeType ===
3 || elem.nodeType ===
8 ) {
10851 // focus/blur morphs to focusin/out; ensure we're not firing them right now
10852 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
10856 if ( type.indexOf(
".")
>=
0 ) {
10857 // Namespaced trigger; create a regexp to match event type in handle()
10858 namespaces = type.split(".");
10859 type = namespaces.shift();
10862 ontype = type.indexOf(":") <
0 && "on" + type;
10864 // Caller can pass in a jQuery.Event object, Object, or just an event type string
10865 event = event[ jQuery.expando ] ?
10867 new jQuery.Event( type, typeof event === "object" && event );
10869 // Trigger bitmask: &
1 for native handlers; &
2 for jQuery (always true)
10870 event.isTrigger = onlyHandlers ?
2 :
3;
10871 event.namespace = namespaces.join(".");
10872 event.namespace_re = event.namespace ?
10873 new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
10876 // Clean up the event in case it is being reused
10877 event.result = undefined;
10878 if ( !event.target ) {
10879 event.target = elem;
10882 // Clone any incoming data and prepend the event, creating the handler arg list
10883 data = data == null ?
10885 jQuery.makeArray( data, [ event ] );
10887 // Allow special events to draw outside the lines
10888 special = jQuery.event.special[ type ] || {};
10889 if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
10893 // Determine event propagation path in advance, per W3C events spec (#
9951)
10894 // Bubble up to document, then to window; watch for a global ownerDocument var (#
9724)
10895 if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
10897 bubbleType = special.delegateType || type;
10898 if ( !rfocusMorph.test( bubbleType + type ) ) {
10899 cur = cur.parentNode;
10901 for ( ; cur; cur = cur.parentNode ) {
10902 eventPath.push( cur );
10906 // Only add window if we got to document (e.g., not plain obj or detached DOM)
10907 if ( tmp === (elem.ownerDocument || document) ) {
10908 eventPath.push( tmp.defaultView || tmp.parentWindow || window );
10912 // Fire handlers on the event path
10914 while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) {
10916 event.type = i
> 1 ?
10918 special.bindType || type;
10921 handle = ( data_priv.get( cur,
"events" ) || {} )[ event.type ] && data_priv.get( cur,
"handle" );
10923 handle.apply( cur, data );
10927 handle = ontype && cur[ ontype ];
10928 if ( handle && handle.apply && jQuery.acceptData( cur ) ) {
10929 event.result = handle.apply( cur, data );
10930 if ( event.result === false ) {
10931 event.preventDefault();
10937 // If nobody prevented the default action, do it now
10938 if ( !onlyHandlers && !event.isDefaultPrevented() ) {
10940 if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) &&
10941 jQuery.acceptData( elem ) ) {
10943 // Call a native DOM method on the target with the same name name as the event.
10944 // Don't do default actions on window, that's where global variables be (#
6170)
10945 if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) {
10947 // Don't re-trigger an onFOO event when we call its FOO() method
10948 tmp = elem[ ontype ];
10951 elem[ ontype ] = null;
10954 // Prevent re-triggering of the same event, since we already bubbled it above
10955 jQuery.event.triggered = type;
10957 jQuery.event.triggered = undefined;
10960 elem[ ontype ] = tmp;
10966 return event.result;
10969 dispatch: function( event ) {
10971 // Make a writable jQuery.Event from the native event object
10972 event = jQuery.event.fix( event );
10974 var i, j, ret, matched, handleObj,
10976 args = slice.call( arguments ),
10977 handlers = ( data_priv.get( this,
"events" ) || {} )[ event.type ] || [],
10978 special = jQuery.event.special[ event.type ] || {};
10980 // Use the fix-ed jQuery.Event rather than the (read-only) native event
10982 event.delegateTarget = this;
10984 // Call the preDispatch hook for the mapped type, and let it bail if desired
10985 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
10989 // Determine handlers
10990 handlerQueue = jQuery.event.handlers.call( this, event, handlers );
10992 // Run delegates first; they may want to stop propagation beneath us
10994 while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) {
10995 event.currentTarget = matched.elem;
10998 while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) {
11000 // Triggered event must either
1) have no namespace, or
11001 //
2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
11002 if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) {
11004 event.handleObj = handleObj;
11005 event.data = handleObj.data;
11007 ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
11008 .apply( matched.elem, args );
11010 if ( ret !== undefined ) {
11011 if ( (event.result = ret) === false ) {
11012 event.preventDefault();
11013 event.stopPropagation();
11020 // Call the postDispatch hook for the mapped type
11021 if ( special.postDispatch ) {
11022 special.postDispatch.call( this, event );
11025 return event.result;
11028 handlers: function( event, handlers ) {
11029 var i, matches, sel, handleObj,
11031 delegateCount = handlers.delegateCount,
11032 cur = event.target;
11034 // Find delegate handlers
11035 // Black-hole SVG
<use> instance trees (#
13180)
11036 // Avoid non-left-click bubbling in Firefox (#
3861)
11037 if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) {
11039 for ( ; cur !== this; cur = cur.parentNode || this ) {
11041 // Don't process clicks on disabled elements (#
6911, #
8165, #
11382, #
11764)
11042 if ( cur.disabled !== true || event.type !== "click" ) {
11044 for ( i =
0; i < delegateCount; i++ ) {
11045 handleObj = handlers[ i ];
11047 // Don't conflict with Object.prototype properties (#
13203)
11048 sel = handleObj.selector + " ";
11050 if ( matches[ sel ] === undefined ) {
11051 matches[ sel ] = handleObj.needsContext ?
11052 jQuery( sel, this ).index( cur )
>=
0 :
11053 jQuery.find( sel, this, null, [ cur ] ).length;
11055 if ( matches[ sel ] ) {
11056 matches.push( handleObj );
11059 if ( matches.length ) {
11060 handlerQueue.push({ elem: cur, handlers: matches });
11066 // Add the remaining (directly-bound) handlers
11067 if ( delegateCount < handlers.length ) {
11068 handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) });
11071 return handlerQueue;
11074 // Includes some event props shared by KeyEvent and MouseEvent
11075 props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
11080 props: "char charCode key keyCode".split(" "),
11081 filter: function( event, original ) {
11083 // Add which for key events
11084 if ( event.which == null ) {
11085 event.which = original.charCode != null ? original.charCode : original.keyCode;
11093 props: "button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
11094 filter: function( event, original ) {
11095 var eventDoc, doc, body,
11096 button = original.button;
11098 // Calculate pageX/Y if missing and clientX/Y available
11099 if ( event.pageX == null && original.clientX != null ) {
11100 eventDoc = event.target.ownerDocument || document;
11101 doc = eventDoc.documentElement;
11102 body = eventDoc.body;
11104 event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft ||
0 ) - ( doc && doc.clientLeft || body && body.clientLeft ||
0 );
11105 event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop ||
0 ) - ( doc && doc.clientTop || body && body.clientTop ||
0 );
11108 // Add which for click:
1 === left;
2 === middle;
3 === right
11109 // Note: button is not normalized, so don't use it
11110 if ( !event.which && button !== undefined ) {
11111 event.which = ( button &
1 ?
1 : ( button &
2 ?
3 : ( button &
4 ?
2 :
0 ) ) );
11118 fix: function( event ) {
11119 if ( event[ jQuery.expando ] ) {
11123 // Create a writable copy of the event object and normalize some properties
11126 originalEvent = event,
11127 fixHook = this.fixHooks[ type ];
11130 this.fixHooks[ type ] = fixHook =
11131 rmouseEvent.test( type ) ? this.mouseHooks :
11132 rkeyEvent.test( type ) ? this.keyHooks :
11135 copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
11137 event = new jQuery.Event( originalEvent );
11142 event[ prop ] = originalEvent[ prop ];
11145 // Support: Cordova
2.5 (WebKit) (#
13255)
11146 // All events should have a target; Cordova deviceready doesn't
11147 if ( !event.target ) {
11148 event.target = document;
11151 // Support: Safari
6.0+, Chrome <
28
11152 // Target should not be a text node (#
504, #
13143)
11153 if ( event.target.nodeType ===
3 ) {
11154 event.target = event.target.parentNode;
11157 return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
11162 // Prevent triggered image.load events from bubbling to window.load
11166 // Fire native event if possible so blur/focus sequence is correct
11167 trigger: function() {
11168 if ( this !== safeActiveElement() && this.focus ) {
11173 delegateType: "focusin"
11176 trigger: function() {
11177 if ( this === safeActiveElement() && this.blur ) {
11182 delegateType: "focusout"
11185 // For checkbox, fire native event so checked state will be right
11186 trigger: function() {
11187 if ( this.type === "checkbox" && this.click && jQuery.nodeName( this, "input" ) ) {
11193 // For cross-browser consistency, don't fire native .click() on links
11194 _default: function( event ) {
11195 return jQuery.nodeName( event.target, "a" );
11200 postDispatch: function( event ) {
11202 // Support: Firefox
20+
11203 // Firefox doesn't alert if the returnValue field is not set.
11204 if ( event.result !== undefined && event.originalEvent ) {
11205 event.originalEvent.returnValue = event.result;
11211 simulate: function( type, elem, event, bubble ) {
11212 // Piggyback on a donor event to simulate a different one.
11213 // Fake originalEvent to avoid donor's stopPropagation, but if the
11214 // simulated event prevents default then we do the same on the donor.
11215 var e = jQuery.extend(
11216 new jQuery.Event(),
11225 jQuery.event.trigger( e, null, elem );
11227 jQuery.event.dispatch.call( elem, e );
11229 if ( e.isDefaultPrevented() ) {
11230 event.preventDefault();
11235 jQuery.removeEvent = function( elem, type, handle ) {
11236 if ( elem.removeEventListener ) {
11237 elem.removeEventListener( type, handle, false );
11241 jQuery.Event = function( src, props ) {
11242 // Allow instantiation without the 'new' keyword
11243 if ( !(this instanceof jQuery.Event) ) {
11244 return new jQuery.Event( src, props );
11248 if ( src && src.type ) {
11249 this.originalEvent = src;
11250 this.type = src.type;
11252 // Events bubbling up the document may have been marked as prevented
11253 // by a handler lower down the tree; reflect the correct value.
11254 this.isDefaultPrevented = src.defaultPrevented ||
11255 src.defaultPrevented === undefined &&
11256 // Support: Android <
4.0
11257 src.returnValue === false ?
11266 // Put explicitly provided properties onto the event object
11268 jQuery.extend( this, props );
11271 // Create a timestamp if incoming event doesn't have one
11272 this.timeStamp = src && src.timeStamp || jQuery.now();
11274 // Mark it as fixed
11275 this[ jQuery.expando ] = true;
11278 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
11279 // http://www.w3.org/TR/
2003/WD-DOM-Level-
3-Events-
20030331/ecma-script-binding.html
11280 jQuery.Event.prototype = {
11281 isDefaultPrevented: returnFalse,
11282 isPropagationStopped: returnFalse,
11283 isImmediatePropagationStopped: returnFalse,
11285 preventDefault: function() {
11286 var e = this.originalEvent;
11288 this.isDefaultPrevented = returnTrue;
11290 if ( e && e.preventDefault ) {
11291 e.preventDefault();
11294 stopPropagation: function() {
11295 var e = this.originalEvent;
11297 this.isPropagationStopped = returnTrue;
11299 if ( e && e.stopPropagation ) {
11300 e.stopPropagation();
11303 stopImmediatePropagation: function() {
11304 var e = this.originalEvent;
11306 this.isImmediatePropagationStopped = returnTrue;
11308 if ( e && e.stopImmediatePropagation ) {
11309 e.stopImmediatePropagation();
11312 this.stopPropagation();
11316 // Create mouseenter/leave events using mouseover/out and event-time checks
11317 // Support: Chrome
15+
11319 mouseenter: "mouseover",
11320 mouseleave: "mouseout",
11321 pointerenter: "pointerover",
11322 pointerleave: "pointerout"
11323 }, function( orig, fix ) {
11324 jQuery.event.special[ orig ] = {
11328 handle: function( event ) {
11331 related = event.relatedTarget,
11332 handleObj = event.handleObj;
11334 // For mousenter/leave call the handler if related is outside the target.
11335 // NB: No relatedTarget if the mouse left/entered the browser window
11336 if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
11337 event.type = handleObj.origType;
11338 ret = handleObj.handler.apply( this, arguments );
11346 // Create "bubbling" focus and blur events
11347 // Support: Firefox, Chrome, Safari
11348 if ( !support.focusinBubbles ) {
11349 jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
11351 // Attach a single capturing handler on the document while someone wants focusin/focusout
11352 var handler = function( event ) {
11353 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
11356 jQuery.event.special[ fix ] = {
11357 setup: function() {
11358 var doc = this.ownerDocument || this,
11359 attaches = data_priv.access( doc, fix );
11362 doc.addEventListener( orig, handler, true );
11364 data_priv.access( doc, fix, ( attaches ||
0 ) +
1 );
11366 teardown: function() {
11367 var doc = this.ownerDocument || this,
11368 attaches = data_priv.access( doc, fix ) -
1;
11371 doc.removeEventListener( orig, handler, true );
11372 data_priv.remove( doc, fix );
11375 data_priv.access( doc, fix, attaches );
11384 on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
11387 // Types can be a map of types/handlers
11388 if ( typeof types === "object" ) {
11389 // ( types-Object, selector, data )
11390 if ( typeof selector !== "string" ) {
11391 // ( types-Object, data )
11392 data = data || selector;
11393 selector = undefined;
11395 for ( type in types ) {
11396 this.on( type, selector, data, types[ type ], one );
11401 if ( data == null && fn == null ) {
11404 data = selector = undefined;
11405 } else if ( fn == null ) {
11406 if ( typeof selector === "string" ) {
11407 // ( types, selector, fn )
11411 // ( types, data, fn )
11414 selector = undefined;
11417 if ( fn === false ) {
11419 } else if ( !fn ) {
11425 fn = function( event ) {
11426 // Can use an empty set, since event contains the info
11427 jQuery().off( event );
11428 return origFn.apply( this, arguments );
11430 // Use same guid so caller can remove using origFn
11431 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
11433 return this.each( function() {
11434 jQuery.event.add( this, types, fn, data, selector );
11437 one: function( types, selector, data, fn ) {
11438 return this.on( types, selector, data, fn,
1 );
11440 off: function( types, selector, fn ) {
11441 var handleObj, type;
11442 if ( types && types.preventDefault && types.handleObj ) {
11443 // ( event ) dispatched jQuery.Event
11444 handleObj = types.handleObj;
11445 jQuery( types.delegateTarget ).off(
11446 handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
11447 handleObj.selector,
11452 if ( typeof types === "object" ) {
11453 // ( types-object [, selector] )
11454 for ( type in types ) {
11455 this.off( type, selector, types[ type ] );
11459 if ( selector === false || typeof selector === "function" ) {
11460 // ( types [, fn] )
11462 selector = undefined;
11464 if ( fn === false ) {
11467 return this.each(function() {
11468 jQuery.event.remove( this, types, fn, selector );
11472 trigger: function( type, data ) {
11473 return this.each(function() {
11474 jQuery.event.trigger( type, data, this );
11477 triggerHandler: function( type, data ) {
11478 var elem = this[
0];
11480 return jQuery.event.trigger( type, data, elem, true );
11487 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^
>]*)\
/>/gi,
11488 rtagName = /<([\w:]+)/,
11489 rhtml = /<|&#?\w+;/,
11490 rnoInnerhtml = /<(?:script|style|link)/i,
11491 //
checked="checked" or checked
11492 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
11493 rscriptType = /^$|\/(?:java|ecma)script/i,
11494 rscriptTypeMasked = /^true\/(.*)/,
11495 rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)
>\s*$/g,
11497 // We have to close these tags to support XHTML (#
13200)
11501 option: [
1, "
<select multiple='multiple'
>", "</select>" ],
11503 thead: [ 1, "<table>", "</table>" ],
11504 col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
11505 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
11506 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
11508 _default: [ 0, "", "" ]
11512 wrapMap.optgroup = wrapMap.option;
11514 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
11515 wrapMap.th = wrapMap.td;
11517 // Support: 1.x compatibility
11518 // Manipulating tables requires a tbody
11519 function manipulationTarget( elem, content ) {
11520 return jQuery.nodeName( elem, "table
" ) &&
11521 jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr
" ) ?
11523 elem.getElementsByTagName("tbody
")[0] ||
11524 elem.appendChild( elem.ownerDocument.createElement("tbody
") ) :
11528 // Replace/restore the type attribute of script elements for safe DOM manipulation
11529 function disableScript( elem ) {
11530 elem.type = (elem.getAttribute("type
") !== null) + "/
" + elem.type;
11533 function restoreScript( elem ) {
11534 var match = rscriptTypeMasked.exec( elem.type );
11537 elem.type = match[ 1 ];
11539 elem.removeAttribute("type
");
11545 // Mark scripts as having already been evaluated
11546 function setGlobalEval( elems, refElements ) {
11550 for ( ; i < l; i++ ) {
11552 elems[ i ], "globalEval
", !refElements || data_priv.get( refElements[ i ], "globalEval
" )
11557 function cloneCopyEvent( src, dest ) {
11558 var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
11560 if ( dest.nodeType !== 1 ) {
11564 // 1. Copy private data: events, handlers, etc.
11565 if ( data_priv.hasData( src ) ) {
11566 pdataOld = data_priv.access( src );
11567 pdataCur = data_priv.set( dest, pdataOld );
11568 events = pdataOld.events;
11571 delete pdataCur.handle;
11572 pdataCur.events = {};
11574 for ( type in events ) {
11575 for ( i = 0, l = events[ type ].length; i < l; i++ ) {
11576 jQuery.event.add( dest, type, events[ type ][ i ] );
11582 // 2. Copy user data
11583 if ( data_user.hasData( src ) ) {
11584 udataOld = data_user.access( src );
11585 udataCur = jQuery.extend( {}, udataOld );
11587 data_user.set( dest, udataCur );
11591 function getAll( context, tag ) {
11592 var ret = context.getElementsByTagName ? context.getElementsByTagName( tag || "*
" ) :
11593 context.querySelectorAll ? context.querySelectorAll( tag || "*
" ) :
11596 return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
11597 jQuery.merge( [ context ], ret ) :
11601 // Support: IE >= 9
11602 function fixInput( src, dest ) {
11603 var nodeName = dest.nodeName.toLowerCase();
11605 // Fails to persist the checked state of a cloned checkbox or radio button.
11606 if ( nodeName === "input
" && rcheckableType.test( src.type ) ) {
11607 dest.checked = src.checked;
11609 // Fails to return the selected option to the default selected state when cloning options
11610 } else if ( nodeName === "input
" || nodeName === "textarea
" ) {
11611 dest.defaultValue = src.defaultValue;
11616 clone: function( elem, dataAndEvents, deepDataAndEvents ) {
11617 var i, l, srcElements, destElements,
11618 clone = elem.cloneNode( true ),
11619 inPage = jQuery.contains( elem.ownerDocument, elem );
11621 // Support: IE >= 9
11622 // Fix Cloning issues
11623 if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
11624 !jQuery.isXMLDoc( elem ) ) {
11626 // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
11627 destElements = getAll( clone );
11628 srcElements = getAll( elem );
11630 for ( i = 0, l = srcElements.length; i < l; i++ ) {
11631 fixInput( srcElements[ i ], destElements[ i ] );
11635 // Copy the events from the original to the clone
11636 if ( dataAndEvents ) {
11637 if ( deepDataAndEvents ) {
11638 srcElements = srcElements || getAll( elem );
11639 destElements = destElements || getAll( clone );
11641 for ( i = 0, l = srcElements.length; i < l; i++ ) {
11642 cloneCopyEvent( srcElements[ i ], destElements[ i ] );
11645 cloneCopyEvent( elem, clone );
11649 // Preserve script evaluation history
11650 destElements = getAll( clone, "script
" );
11651 if ( destElements.length > 0 ) {
11652 setGlobalEval( destElements, !inPage && getAll( elem, "script
" ) );
11655 // Return the cloned set
11659 buildFragment: function( elems, context, scripts, selection ) {
11660 var elem, tmp, tag, wrap, contains, j,
11661 fragment = context.createDocumentFragment(),
11666 for ( ; i < l; i++ ) {
11669 if ( elem || elem === 0 ) {
11671 // Add nodes directly
11672 if ( jQuery.type( elem ) === "object
" ) {
11673 // Support: QtWebKit
11674 // jQuery.merge because push.apply(_, arraylike) throws
11675 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
11677 // Convert non-html into a text node
11678 } else if ( !rhtml.test( elem ) ) {
11679 nodes.push( context.createTextNode( elem ) );
11681 // Convert html into DOM nodes
11683 tmp = tmp || fragment.appendChild( context.createElement("div
") );
11685 // Deserialize a standard representation
11686 tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
11687 wrap = wrapMap[ tag ] || wrapMap._default;
11688 tmp.innerHTML = wrap[ 1 ] + elem.replace( rxhtmlTag, "<$
1></$
2>" ) + wrap[ 2 ];
11690 // Descend through wrappers to the right content
11693 tmp = tmp.lastChild;
11696 // Support: QtWebKit
11697 // jQuery.merge because push.apply(_, arraylike) throws
11698 jQuery.merge( nodes, tmp.childNodes );
11700 // Remember the top-level container
11701 tmp = fragment.firstChild;
11704 // Support: Webkit, IE
11705 tmp.textContent = "";
11710 // Remove wrapper from fragment
11711 fragment.textContent = "";
11714 while ( (elem = nodes[ i++ ]) ) {
11716 // #4087 - If origin and destination elements are the same, and this is
11717 // that element, do not do anything
11718 if ( selection && jQuery.inArray( elem, selection ) !== -1 ) {
11722 contains = jQuery.contains( elem.ownerDocument, elem );
11724 // Append to fragment
11725 tmp = getAll( fragment.appendChild( elem ), "script
" );
11727 // Preserve script evaluation history
11729 setGlobalEval( tmp );
11732 // Capture executables
11735 while ( (elem = tmp[ j++ ]) ) {
11736 if ( rscriptType.test( elem.type || "" ) ) {
11737 scripts.push( elem );
11746 cleanData: function( elems ) {
11747 var data, elem, type, key,
11748 special = jQuery.event.special,
11751 for ( ; (elem = elems[ i ]) !== undefined; i++ ) {
11752 if ( jQuery.acceptData( elem ) ) {
11753 key = elem[ data_priv.expando ];
11755 if ( key && (data = data_priv.cache[ key ]) ) {
11756 if ( data.events ) {
11757 for ( type in data.events ) {
11758 if ( special[ type ] ) {
11759 jQuery.event.remove( elem, type );
11761 // This is a shortcut to avoid jQuery.event.remove's overhead
11763 jQuery.removeEvent( elem, type, data.handle );
11767 if ( data_priv.cache[ key ] ) {
11768 // Discard any remaining `private` data
11769 delete data_priv.cache[ key ];
11773 // Discard any remaining `user` data
11774 delete data_user.cache[ elem[ data_user.expando ] ];
11780 text: function( value ) {
11781 return access( this, function( value ) {
11782 return value === undefined ?
11783 jQuery.text( this ) :
11784 this.empty().each(function() {
11785 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
11786 this.textContent = value;
11789 }, null, value, arguments.length );
11792 append: function() {
11793 return this.domManip( arguments, function( elem ) {
11794 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
11795 var target = manipulationTarget( this, elem );
11796 target.appendChild( elem );
11801 prepend: function() {
11802 return this.domManip( arguments, function( elem ) {
11803 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
11804 var target = manipulationTarget( this, elem );
11805 target.insertBefore( elem, target.firstChild );
11810 before: function() {
11811 return this.domManip( arguments, function( elem ) {
11812 if ( this.parentNode ) {
11813 this.parentNode.insertBefore( elem, this );
11818 after: function() {
11819 return this.domManip( arguments, function( elem ) {
11820 if ( this.parentNode ) {
11821 this.parentNode.insertBefore( elem, this.nextSibling );
11826 remove: function( selector, keepData /* Internal Use Only */ ) {
11828 elems = selector ? jQuery.filter( selector, this ) : this,
11831 for ( ; (elem = elems[i]) != null; i++ ) {
11832 if ( !keepData && elem.nodeType === 1 ) {
11833 jQuery.cleanData( getAll( elem ) );
11836 if ( elem.parentNode ) {
11837 if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
11838 setGlobalEval( getAll( elem, "script
" ) );
11840 elem.parentNode.removeChild( elem );
11847 empty: function() {
11851 for ( ; (elem = this[i]) != null; i++ ) {
11852 if ( elem.nodeType === 1 ) {
11854 // Prevent memory leaks
11855 jQuery.cleanData( getAll( elem, false ) );
11857 // Remove any remaining nodes
11858 elem.textContent = "";
11865 clone: function( dataAndEvents, deepDataAndEvents ) {
11866 dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
11867 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
11869 return this.map(function() {
11870 return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
11874 html: function( value ) {
11875 return access( this, function( value ) {
11876 var elem = this[ 0 ] || {},
11880 if ( value === undefined && elem.nodeType === 1 ) {
11881 return elem.innerHTML;
11884 // See if we can take a shortcut and just use innerHTML
11885 if ( typeof value === "string
" && !rnoInnerhtml.test( value ) &&
11886 !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
11888 value = value.replace( rxhtmlTag, "<$
1></$
2>" );
11891 for ( ; i < l; i++ ) {
11892 elem = this[ i ] || {};
11894 // Remove element nodes and prevent memory leaks
11895 if ( elem.nodeType === 1 ) {
11896 jQuery.cleanData( getAll( elem, false ) );
11897 elem.innerHTML = value;
11903 // If using innerHTML throws an exception, use the fallback method
11908 this.empty().append( value );
11910 }, null, value, arguments.length );
11913 replaceWith: function() {
11914 var arg = arguments[ 0 ];
11916 // Make the changes, replacing each context element with the new content
11917 this.domManip( arguments, function( elem ) {
11918 arg = this.parentNode;
11920 jQuery.cleanData( getAll( this ) );
11923 arg.replaceChild( elem, this );
11927 // Force removal if there was no new content (e.g., from empty arguments)
11928 return arg && (arg.length || arg.nodeType) ? this : this.remove();
11931 detach: function( selector ) {
11932 return this.remove( selector, true );
11935 domManip: function( args, callback ) {
11937 // Flatten any nested arrays
11938 args = concat.apply( [], args );
11940 var fragment, first, scripts, hasScripts, node, doc,
11946 isFunction = jQuery.isFunction( value );
11948 // We can't cloneNode fragments that contain checked, in WebKit
11950 ( l > 1 && typeof value === "string
" &&
11951 !support.checkClone && rchecked.test( value ) ) ) {
11952 return this.each(function( index ) {
11953 var self = set.eq( index );
11954 if ( isFunction ) {
11955 args[ 0 ] = value.call( this, index, self.html() );
11957 self.domManip( args, callback );
11962 fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this );
11963 first = fragment.firstChild;
11965 if ( fragment.childNodes.length === 1 ) {
11970 scripts = jQuery.map( getAll( fragment, "script
" ), disableScript );
11971 hasScripts = scripts.length;
11973 // Use the original fragment for the last item instead of the first because it can end up
11974 // being emptied incorrectly in certain situations (#8070).
11975 for ( ; i < l; i++ ) {
11978 if ( i !== iNoClone ) {
11979 node = jQuery.clone( node, true, true );
11981 // Keep references to cloned scripts for later restoration
11982 if ( hasScripts ) {
11983 // Support: QtWebKit
11984 // jQuery.merge because push.apply(_, arraylike) throws
11985 jQuery.merge( scripts, getAll( node, "script
" ) );
11989 callback.call( this[ i ], node, i );
11992 if ( hasScripts ) {
11993 doc = scripts[ scripts.length - 1 ].ownerDocument;
11995 // Reenable scripts
11996 jQuery.map( scripts, restoreScript );
11998 // Evaluate executable scripts on first document insertion
11999 for ( i = 0; i < hasScripts; i++ ) {
12000 node = scripts[ i ];
12001 if ( rscriptType.test( node.type || "" ) &&
12002 !data_priv.access( node, "globalEval
" ) && jQuery.contains( doc, node ) ) {
12005 // Optional AJAX dependency, but won't run scripts if not present
12006 if ( jQuery._evalUrl ) {
12007 jQuery._evalUrl( node.src );
12010 jQuery.globalEval( node.textContent.replace( rcleanScript, "" ) );
12023 appendTo: "append
",
12024 prependTo: "prepend
",
12025 insertBefore: "before
",
12026 insertAfter: "after
",
12027 replaceAll: "replaceWith
"
12028 }, function( name, original ) {
12029 jQuery.fn[ name ] = function( selector ) {
12032 insert = jQuery( selector ),
12033 last = insert.length - 1,
12036 for ( ; i <= last; i++ ) {
12037 elems = i === last ? this : this.clone( true );
12038 jQuery( insert[ i ] )[ original ]( elems );
12040 // Support: QtWebKit
12041 // .get() because push.apply(_, arraylike) throws
12042 push.apply( ret, elems.get() );
12045 return this.pushStack( ret );
12054 * Retrieve the actual display of a element
12055 * @param {String} name nodeName of the element
12056 * @param {Object} doc Document object
12058 // Called only from within defaultDisplay
12059 function actualDisplay( name, doc ) {
12061 elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
12063 // getDefaultComputedStyle might be reliably used only on attached element
12064 display = window.getDefaultComputedStyle && ( style = window.getDefaultComputedStyle( elem[ 0 ] ) ) ?
12066 // Use of this method is a temporary fix (more like optmization) until something better comes along,
12067 // since it was removed from specification and supported only in FF
12068 style.display : jQuery.css( elem[ 0 ], "display
" );
12070 // We don't have any data stored on the element,
12071 // so use "detach
" method as fast way to get rid of the element
12078 * Try to determine the default display value of an element
12079 * @param {String} nodeName
12081 function defaultDisplay( nodeName ) {
12082 var doc = document,
12083 display = elemdisplay[ nodeName ];
12086 display = actualDisplay( nodeName, doc );
12088 // If the simple way fails, read from inside an iframe
12089 if ( display === "none
" || !display ) {
12091 // Use the already-created iframe if possible
12092 iframe = (iframe || jQuery( "<iframe frameborder='
0' width='
0' height='
0'
/>" )).appendTo( doc.documentElement );
12094 // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
12095 doc = iframe[ 0 ].contentDocument;
12101 display = actualDisplay( nodeName, doc );
12105 // Store the correct default display
12106 elemdisplay[ nodeName ] = display;
12111 var rmargin = (/^margin/);
12113 var rnumnonpx = new RegExp( "^(
" + pnum + ")(?!px)[a-z%]+$
", "i
" );
12115 var getStyles = function( elem ) {
12116 return elem.ownerDocument.defaultView.getComputedStyle( elem, null );
12121 function curCSS( elem, name, computed ) {
12122 var width, minWidth, maxWidth, ret,
12123 style = elem.style;
12125 computed = computed || getStyles( elem );
12128 // getPropertyValue is only needed for .css('filter') in IE9, see #12537
12130 ret = computed.getPropertyValue( name ) || computed[ name ];
12135 if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
12136 ret = jQuery.style( elem, name );
12139 // Support: iOS < 6
12140 // A tribute to the "awesome hack by Dean Edwards
"
12141 // iOS < 6 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
12142 // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
12143 if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
12145 // Remember the original values
12146 width = style.width;
12147 minWidth = style.minWidth;
12148 maxWidth = style.maxWidth;
12150 // Put in the new values to get a computed value out
12151 style.minWidth = style.maxWidth = style.width = ret;
12152 ret = computed.width;
12154 // Revert the changed values
12155 style.width = width;
12156 style.minWidth = minWidth;
12157 style.maxWidth = maxWidth;
12161 return ret !== undefined ?
12163 // IE returns zIndex value as an integer.
12169 function addGetHookIf( conditionFn, hookFn ) {
12170 // Define the hook, we'll check on the first run if it's really needed.
12173 if ( conditionFn() ) {
12174 // Hook not needed (or it's not possible to use it due to missing dependency),
12176 // Since there are no other hooks for marginRight, remove the whole object.
12181 // Hook needed; redefine it so that the support test is not executed again.
12183 return (this.get = hookFn).apply( this, arguments );
12190 var pixelPositionVal, boxSizingReliableVal,
12191 docElem = document.documentElement,
12192 container = document.createElement( "div
" ),
12193 div = document.createElement( "div
" );
12195 if ( !div.style ) {
12199 div.style.backgroundClip = "content-box
";
12200 div.cloneNode( true ).style.backgroundClip = "";
12201 support.clearCloneStyle = div.style.backgroundClip === "content-box
";
12203 container.style.cssText = "border:
0;width:
0;height:
0;top:
0;left:-
9999px;margin-top:
1px;
" +
12204 "position:absolute
";
12205 container.appendChild( div );
12207 // Executing both pixelPosition & boxSizingReliable tests require only one layout
12208 // so they're executed at the same time to save the second computation.
12209 function computePixelPositionAndBoxSizingReliable() {
12210 div.style.cssText =
12211 // Support: Firefox<29, Android 2.3
12212 // Vendor-prefix box-sizing
12213 "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;
" +
12214 "box-sizing:border-box;display:block;margin-top:
1%;top:
1%;
" +
12215 "border:
1px;padding:
1px;width:
4px;position:absolute
";
12216 div.innerHTML = "";
12217 docElem.appendChild( container );
12219 var divStyle = window.getComputedStyle( div, null );
12220 pixelPositionVal = divStyle.top !== "1%
";
12221 boxSizingReliableVal = divStyle.width === "4px
";
12223 docElem.removeChild( container );
12226 // Support: node.js jsdom
12227 // Don't assume that getComputedStyle is a property of the global object
12228 if ( window.getComputedStyle ) {
12229 jQuery.extend( support, {
12230 pixelPosition: function() {
12231 // This test is executed only once but we still do memoizing
12232 // since we can use the boxSizingReliable pre-computing.
12233 // No need to check if the test was already performed, though.
12234 computePixelPositionAndBoxSizingReliable();
12235 return pixelPositionVal;
12237 boxSizingReliable: function() {
12238 if ( boxSizingReliableVal == null ) {
12239 computePixelPositionAndBoxSizingReliable();
12241 return boxSizingReliableVal;
12243 reliableMarginRight: function() {
12244 // Support: Android 2.3
12245 // Check if div with explicit width and no margin-right incorrectly
12246 // gets computed margin-right based on width of container. (#3333)
12247 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
12248 // This support function is only executed once so no memoizing is needed.
12250 marginDiv = div.appendChild( document.createElement( "div
" ) );
12252 // Reset CSS: box-sizing; display; margin; border; padding
12253 marginDiv.style.cssText = div.style.cssText =
12254 // Support: Firefox<29, Android 2.3
12255 // Vendor-prefix box-sizing
12256 "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;
" +
12257 "box-sizing:content-box;display:block;margin:
0;border:
0;padding:
0";
12258 marginDiv.style.marginRight = marginDiv.style.width = "0";
12259 div.style.width = "1px
";
12260 docElem.appendChild( container );
12262 ret = !parseFloat( window.getComputedStyle( marginDiv, null ).marginRight );
12264 docElem.removeChild( container );
12273 // A method for quickly swapping in/out CSS properties to get correct calculations.
12274 jQuery.swap = function( elem, options, callback, args ) {
12278 // Remember the old values, and insert the new ones
12279 for ( name in options ) {
12280 old[ name ] = elem.style[ name ];
12281 elem.style[ name ] = options[ name ];
12284 ret = callback.apply( elem, args || [] );
12286 // Revert the old values
12287 for ( name in options ) {
12288 elem.style[ name ] = old[ name ];
12296 // swappable if display is none or starts with table except "table
", "table-cell
", or "table-caption
"
12297 // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
12298 rdisplayswap = /^(none|table(?!-c[ea]).+)/,
12299 rnumsplit = new RegExp( "^(
" + pnum + ")(.*)$
", "i
" ),
12300 rrelNum = new RegExp( "^([+-])=(
" + pnum + ")
", "i
" ),
12302 cssShow = { position: "absolute
", visibility: "hidden
", display: "block
" },
12303 cssNormalTransform = {
12304 letterSpacing: "0",
12308 cssPrefixes = [ "Webkit
", "O
", "Moz
", "ms
" ];
12310 // return a css property mapped to a potentially vendor prefixed property
12311 function vendorPropName( style, name ) {
12313 // shortcut for names that are not vendor prefixed
12314 if ( name in style ) {
12318 // check for vendor prefixed names
12319 var capName = name[0].toUpperCase() + name.slice(1),
12321 i = cssPrefixes.length;
12324 name = cssPrefixes[ i ] + capName;
12325 if ( name in style ) {
12333 function setPositiveNumber( elem, value, subtract ) {
12334 var matches = rnumsplit.exec( value );
12336 // Guard against undefined "subtract
", e.g., when used as in cssHooks
12337 Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px
" ) :
12341 function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
12342 var i = extra === ( isBorderBox ? "border
" : "content
" ) ?
12343 // If we already have the right measurement, avoid augmentation
12345 // Otherwise initialize for horizontal or vertical properties
12346 name === "width
" ? 1 : 0,
12350 for ( ; i < 4; i += 2 ) {
12351 // both box models exclude margin, so add it if we want it
12352 if ( extra === "margin
" ) {
12353 val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
12356 if ( isBorderBox ) {
12357 // border-box includes padding, so remove it if we want content
12358 if ( extra === "content
" ) {
12359 val -= jQuery.css( elem, "padding
" + cssExpand[ i ], true, styles );
12362 // at this point, extra isn't border nor margin, so remove border
12363 if ( extra !== "margin
" ) {
12364 val -= jQuery.css( elem, "border
" + cssExpand[ i ] + "Width
", true, styles );
12367 // at this point, extra isn't content, so add padding
12368 val += jQuery.css( elem, "padding
" + cssExpand[ i ], true, styles );
12370 // at this point, extra isn't content nor padding, so add border
12371 if ( extra !== "padding
" ) {
12372 val += jQuery.css( elem, "border
" + cssExpand[ i ] + "Width
", true, styles );
12380 function getWidthOrHeight( elem, name, extra ) {
12382 // Start with offset property, which is equivalent to the border-box value
12383 var valueIsBorderBox = true,
12384 val = name === "width
" ? elem.offsetWidth : elem.offsetHeight,
12385 styles = getStyles( elem ),
12386 isBorderBox = jQuery.css( elem, "boxSizing
", false, styles ) === "border-box
";
12388 // some non-html elements return undefined for offsetWidth, so check for null/undefined
12389 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
12390 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
12391 if ( val <= 0 || val == null ) {
12392 // Fall back to computed then uncomputed css if necessary
12393 val = curCSS( elem, name, styles );
12394 if ( val < 0 || val == null ) {
12395 val = elem.style[ name ];
12398 // Computed unit is not pixels. Stop here and return.
12399 if ( rnumnonpx.test(val) ) {
12403 // we need the check for style in case a browser which returns unreliable values
12404 // for getComputedStyle silently falls back to the reliable elem.style
12405 valueIsBorderBox = isBorderBox &&
12406 ( support.boxSizingReliable() || val === elem.style[ name ] );
12408 // Normalize "", auto, and prepare for extra
12409 val = parseFloat( val ) || 0;
12412 // use the active box-sizing model to add/subtract irrelevant styles
12414 augmentWidthOrHeight(
12417 extra || ( isBorderBox ? "border
" : "content
" ),
12424 function showHide( elements, show ) {
12425 var display, elem, hidden,
12428 length = elements.length;
12430 for ( ; index < length; index++ ) {
12431 elem = elements[ index ];
12432 if ( !elem.style ) {
12436 values[ index ] = data_priv.get( elem, "olddisplay
" );
12437 display = elem.style.display;
12439 // Reset the inline display of this element to learn if it is
12440 // being hidden by cascaded rules or not
12441 if ( !values[ index ] && display === "none
" ) {
12442 elem.style.display = "";
12445 // Set elements which have been overridden with display: none
12446 // in a stylesheet to whatever the default browser style is
12447 // for such an element
12448 if ( elem.style.display === "" && isHidden( elem ) ) {
12449 values[ index ] = data_priv.access( elem, "olddisplay
", defaultDisplay(elem.nodeName) );
12452 hidden = isHidden( elem );
12454 if ( display !== "none
" || !hidden ) {
12455 data_priv.set( elem, "olddisplay
", hidden ? display : jQuery.css( elem, "display
" ) );
12460 // Set the display of most of the elements in a second loop
12461 // to avoid the constant reflow
12462 for ( index = 0; index < length; index++ ) {
12463 elem = elements[ index ];
12464 if ( !elem.style ) {
12467 if ( !show || elem.style.display === "none
" || elem.style.display === "" ) {
12468 elem.style.display = show ? values[ index ] || "" : "none
";
12476 // Add in style property hooks for overriding the default
12477 // behavior of getting and setting a style property
12480 get: function( elem, computed ) {
12482 // We should always get a number back from opacity
12483 var ret = curCSS( elem, "opacity
" );
12484 return ret === "" ? "1" : ret;
12490 // Don't automatically add "px
" to these possibly-unitless properties
12492 "columnCount
": true,
12493 "fillOpacity
": true,
12495 "flexShrink
": true,
12496 "fontWeight
": true,
12497 "lineHeight
": true,
12506 // Add in properties whose names you wish to fix before
12507 // setting or getting the value
12509 // normalize float css property
12510 "float
": "cssFloat
"
12513 // Get and set the style property on a DOM Node
12514 style: function( elem, name, value, extra ) {
12515 // Don't set styles on text and comment nodes
12516 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
12520 // Make sure that we're working with the right name
12521 var ret, type, hooks,
12522 origName = jQuery.camelCase( name ),
12523 style = elem.style;
12525 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
12527 // gets hook for the prefixed version
12528 // followed by the unprefixed version
12529 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
12531 // Check if we're setting a value
12532 if ( value !== undefined ) {
12533 type = typeof value;
12535 // convert relative number strings (+= or -=) to relative numbers. #7345
12536 if ( type === "string
" && (ret = rrelNum.exec( value )) ) {
12537 value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
12542 // Make sure that null and NaN values aren't set. See: #7116
12543 if ( value == null || value !== value ) {
12547 // If a number was passed in, add 'px' to the (except for certain CSS properties)
12548 if ( type === "number
" && !jQuery.cssNumber[ origName ] ) {
12552 // Fixes #8908, it can be done more correctly by specifying setters in cssHooks,
12553 // but it would mean to define eight (for every problematic property) identical functions
12554 if ( !support.clearCloneStyle && value === "" && name.indexOf( "background
" ) === 0 ) {
12555 style[ name ] = "inherit
";
12558 // If a hook was provided, use that value, otherwise just set the specified value
12559 if ( !hooks || !("set
" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
12560 style[ name ] = value;
12564 // If a hook was provided get the non-computed value from there
12565 if ( hooks && "get
" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
12569 // Otherwise just get the value from the style object
12570 return style[ name ];
12574 css: function( elem, name, extra, styles ) {
12575 var val, num, hooks,
12576 origName = jQuery.camelCase( name );
12578 // Make sure that we're working with the right name
12579 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
12581 // gets hook for the prefixed version
12582 // followed by the unprefixed version
12583 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
12585 // If a hook was provided get the computed value from there
12586 if ( hooks && "get
" in hooks ) {
12587 val = hooks.get( elem, true, extra );
12590 // Otherwise, if a way to get the computed value exists, use that
12591 if ( val === undefined ) {
12592 val = curCSS( elem, name, styles );
12595 //convert "normal
" to computed value
12596 if ( val === "normal
" && name in cssNormalTransform ) {
12597 val = cssNormalTransform[ name ];
12600 // Return, converting to number if forced or a qualifier was provided and val looks numeric
12601 if ( extra === "" || extra ) {
12602 num = parseFloat( val );
12603 return extra === true || jQuery.isNumeric( num ) ? num || 0 : val;
12609 jQuery.each([ "height
", "width
" ], function( i, name ) {
12610 jQuery.cssHooks[ name ] = {
12611 get: function( elem, computed, extra ) {
12613 // certain elements can have dimension info if we invisibly show them
12614 // however, it must have a current display style that would benefit from this
12615 return rdisplayswap.test( jQuery.css( elem, "display
" ) ) && elem.offsetWidth === 0 ?
12616 jQuery.swap( elem, cssShow, function() {
12617 return getWidthOrHeight( elem, name, extra );
12619 getWidthOrHeight( elem, name, extra );
12623 set: function( elem, value, extra ) {
12624 var styles = extra && getStyles( elem );
12625 return setPositiveNumber( elem, value, extra ?
12626 augmentWidthOrHeight(
12630 jQuery.css( elem, "boxSizing
", false, styles ) === "border-box
",
12638 // Support: Android 2.3
12639 jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
12640 function( elem, computed ) {
12642 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
12643 // Work around by temporarily setting element display to inline-block
12644 return jQuery.swap( elem, { "display
": "inline-block
" },
12645 curCSS, [ elem, "marginRight
" ] );
12650 // These hooks are used by animate to expand properties
12655 }, function( prefix, suffix ) {
12656 jQuery.cssHooks[ prefix + suffix ] = {
12657 expand: function( value ) {
12661 // assumes a single number if not a string
12662 parts = typeof value === "string
" ? value.split(" ") : [ value ];
12664 for ( ; i < 4; i++ ) {
12665 expanded[ prefix + cssExpand[ i ] + suffix ] =
12666 parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
12673 if ( !rmargin.test( prefix ) ) {
12674 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
12679 css: function( name, value ) {
12680 return access( this, function( elem, name, value ) {
12685 if ( jQuery.isArray( name ) ) {
12686 styles = getStyles( elem );
12689 for ( ; i < len; i++ ) {
12690 map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
12696 return value !== undefined ?
12697 jQuery.style( elem, name, value ) :
12698 jQuery.css( elem, name );
12699 }, name, value, arguments.length > 1 );
12702 return showHide( this, true );
12705 return showHide( this );
12707 toggle: function( state ) {
12708 if ( typeof state === "boolean
" ) {
12709 return state ? this.show() : this.hide();
12712 return this.each(function() {
12713 if ( isHidden( this ) ) {
12714 jQuery( this ).show();
12716 jQuery( this ).hide();
12723 function Tween( elem, options, prop, end, easing ) {
12724 return new Tween.prototype.init( elem, options, prop, end, easing );
12726 jQuery.Tween = Tween;
12728 Tween.prototype = {
12729 constructor: Tween,
12730 init: function( elem, options, prop, end, easing, unit ) {
12733 this.easing = easing || "swing
";
12734 this.options = options;
12735 this.start = this.now = this.cur();
12737 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px
" );
12740 var hooks = Tween.propHooks[ this.prop ];
12742 return hooks && hooks.get ?
12743 hooks.get( this ) :
12744 Tween.propHooks._default.get( this );
12746 run: function( percent ) {
12748 hooks = Tween.propHooks[ this.prop ];
12750 if ( this.options.duration ) {
12751 this.pos = eased = jQuery.easing[ this.easing ](
12752 percent, this.options.duration * percent, 0, 1, this.options.duration
12755 this.pos = eased = percent;
12757 this.now = ( this.end - this.start ) * eased + this.start;
12759 if ( this.options.step ) {
12760 this.options.step.call( this.elem, this.now, this );
12763 if ( hooks && hooks.set ) {
12766 Tween.propHooks._default.set( this );
12772 Tween.prototype.init.prototype = Tween.prototype;
12774 Tween.propHooks = {
12776 get: function( tween ) {
12779 if ( tween.elem[ tween.prop ] != null &&
12780 (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
12781 return tween.elem[ tween.prop ];
12784 // passing an empty string as a 3rd parameter to .css will automatically
12785 // attempt a parseFloat and fallback to a string if the parse fails
12786 // so, simple values such as "10px
" are parsed to Float.
12787 // complex values such as "rotate(
1rad)
" are returned as is.
12788 result = jQuery.css( tween.elem, tween.prop, "" );
12789 // Empty strings, null, undefined and "auto
" are converted to 0.
12790 return !result || result === "auto
" ? 0 : result;
12792 set: function( tween ) {
12793 // use step hook for back compat - use cssHook if its there - use .style if its
12794 // available and use plain properties where available
12795 if ( jQuery.fx.step[ tween.prop ] ) {
12796 jQuery.fx.step[ tween.prop ]( tween );
12797 } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
12798 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
12800 tween.elem[ tween.prop ] = tween.now;
12807 // Panic based approach to setting things on disconnected nodes
12809 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
12810 set: function( tween ) {
12811 if ( tween.elem.nodeType && tween.elem.parentNode ) {
12812 tween.elem[ tween.prop ] = tween.now;
12818 linear: function( p ) {
12821 swing: function( p ) {
12822 return 0.5 - Math.cos( p * Math.PI ) / 2;
12826 jQuery.fx = Tween.prototype.init;
12828 // Back Compat <1.8 extension point
12829 jQuery.fx.step = {};
12836 rfxtypes = /^(?:toggle|show|hide)$/,
12837 rfxnum = new RegExp( "^(?:([+-])=|)(
" + pnum + ")([a-z%]*)$
", "i
" ),
12838 rrun = /queueHooks$/,
12839 animationPrefilters = [ defaultPrefilter ],
12841 "*
": [ function( prop, value ) {
12842 var tween = this.createTween( prop, value ),
12843 target = tween.cur(),
12844 parts = rfxnum.exec( value ),
12845 unit = parts && parts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px
" ),
12847 // Starting value computation is required for potential unit mismatches
12848 start = ( jQuery.cssNumber[ prop ] || unit !== "px
" && +target ) &&
12849 rfxnum.exec( jQuery.css( tween.elem, prop ) ),
12851 maxIterations = 20;
12853 if ( start && start[ 3 ] !== unit ) {
12854 // Trust units reported by jQuery.css
12855 unit = unit || start[ 3 ];
12857 // Make sure we update the tween properties later on
12858 parts = parts || [];
12860 // Iteratively approximate from a nonzero starting point
12861 start = +target || 1;
12864 // If previous iteration zeroed out, double until we get *something*
12865 // Use a string for doubling factor so we don't accidentally see scale as unchanged below
12866 scale = scale || ".5";
12868 // Adjust and apply
12869 start = start / scale;
12870 jQuery.style( tween.elem, prop, start + unit );
12872 // Update scale, tolerating zero or NaN from tween.cur()
12873 // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
12874 } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
12877 // Update tween properties
12879 start = tween.start = +start || +target || 0;
12881 // If a +=/-= token was provided, we're doing a relative animation
12882 tween.end = parts[ 1 ] ?
12883 start + ( parts[ 1 ] + 1 ) * parts[ 2 ] :
12891 // Animations created synchronously will run synchronously
12892 function createFxNow() {
12893 setTimeout(function() {
12896 return ( fxNow = jQuery.now() );
12899 // Generate parameters to create a standard animation
12900 function genFx( type, includeWidth ) {
12903 attrs = { height: type };
12905 // if we include width, step value is 1 to do all cssExpand values,
12906 // if we don't include width, step value is 2 to skip over Left and Right
12907 includeWidth = includeWidth ? 1 : 0;
12908 for ( ; i < 4 ; i += 2 - includeWidth ) {
12909 which = cssExpand[ i ];
12910 attrs[ "margin
" + which ] = attrs[ "padding
" + which ] = type;
12913 if ( includeWidth ) {
12914 attrs.opacity = attrs.width = type;
12920 function createTween( value, prop, animation ) {
12922 collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*
" ] ),
12924 length = collection.length;
12925 for ( ; index < length; index++ ) {
12926 if ( (tween = collection[ index ].call( animation, prop, value )) ) {
12928 // we're done with this property
12934 function defaultPrefilter( elem, props, opts ) {
12935 /* jshint validthis: true */
12936 var prop, value, toggle, tween, hooks, oldfire, display, checkDisplay,
12939 style = elem.style,
12940 hidden = elem.nodeType && isHidden( elem ),
12941 dataShow = data_priv.get( elem, "fxshow
" );
12943 // handle queue: false promises
12944 if ( !opts.queue ) {
12945 hooks = jQuery._queueHooks( elem, "fx
" );
12946 if ( hooks.unqueued == null ) {
12947 hooks.unqueued = 0;
12948 oldfire = hooks.empty.fire;
12949 hooks.empty.fire = function() {
12950 if ( !hooks.unqueued ) {
12957 anim.always(function() {
12958 // doing this makes sure that the complete handler will be called
12959 // before this completes
12960 anim.always(function() {
12962 if ( !jQuery.queue( elem, "fx
" ).length ) {
12963 hooks.empty.fire();
12969 // height/width overflow pass
12970 if ( elem.nodeType === 1 && ( "height
" in props || "width
" in props ) ) {
12971 // Make sure that nothing sneaks out
12972 // Record all 3 overflow attributes because IE9-10 do not
12973 // change the overflow attribute when overflowX and
12974 // overflowY are set to the same value
12975 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
12977 // Set display property to inline-block for height/width
12978 // animations on inline elements that are having width/height animated
12979 display = jQuery.css( elem, "display
" );
12981 // Test default display if display is currently "none
"
12982 checkDisplay = display === "none
" ?
12983 data_priv.get( elem, "olddisplay
" ) || defaultDisplay( elem.nodeName ) : display;
12985 if ( checkDisplay === "inline
" && jQuery.css( elem, "float
" ) === "none
" ) {
12986 style.display = "inline-block
";
12990 if ( opts.overflow ) {
12991 style.overflow = "hidden
";
12992 anim.always(function() {
12993 style.overflow = opts.overflow[ 0 ];
12994 style.overflowX = opts.overflow[ 1 ];
12995 style.overflowY = opts.overflow[ 2 ];
13000 for ( prop in props ) {
13001 value = props[ prop ];
13002 if ( rfxtypes.exec( value ) ) {
13003 delete props[ prop ];
13004 toggle = toggle || value === "toggle
";
13005 if ( value === ( hidden ? "hide
" : "show
" ) ) {
13007 // If there is dataShow left over from a stopped hide or show and we are going to proceed with show, we should pretend to be hidden
13008 if ( value === "show
" && dataShow && dataShow[ prop ] !== undefined ) {
13014 orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
13016 // Any non-fx value stops us from restoring the original display value
13018 display = undefined;
13022 if ( !jQuery.isEmptyObject( orig ) ) {
13024 if ( "hidden
" in dataShow ) {
13025 hidden = dataShow.hidden;
13028 dataShow = data_priv.access( elem, "fxshow
", {} );
13031 // store state if its toggle - enables .stop().toggle() to "reverse
"
13033 dataShow.hidden = !hidden;
13036 jQuery( elem ).show();
13038 anim.done(function() {
13039 jQuery( elem ).hide();
13042 anim.done(function() {
13045 data_priv.remove( elem, "fxshow
" );
13046 for ( prop in orig ) {
13047 jQuery.style( elem, prop, orig[ prop ] );
13050 for ( prop in orig ) {
13051 tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
13053 if ( !( prop in dataShow ) ) {
13054 dataShow[ prop ] = tween.start;
13056 tween.end = tween.start;
13057 tween.start = prop === "width
" || prop === "height
" ? 1 : 0;
13062 // If this is a noop like .hide().hide(), restore an overwritten display value
13063 } else if ( (display === "none
" ? defaultDisplay( elem.nodeName ) : display) === "inline
" ) {
13064 style.display = display;
13068 function propFilter( props, specialEasing ) {
13069 var index, name, easing, value, hooks;
13071 // camelCase, specialEasing and expand cssHook pass
13072 for ( index in props ) {
13073 name = jQuery.camelCase( index );
13074 easing = specialEasing[ name ];
13075 value = props[ index ];
13076 if ( jQuery.isArray( value ) ) {
13077 easing = value[ 1 ];
13078 value = props[ index ] = value[ 0 ];
13081 if ( index !== name ) {
13082 props[ name ] = value;
13083 delete props[ index ];
13086 hooks = jQuery.cssHooks[ name ];
13087 if ( hooks && "expand
" in hooks ) {
13088 value = hooks.expand( value );
13089 delete props[ name ];
13091 // not quite $.extend, this wont overwrite keys already present.
13092 // also - reusing 'index' from above because we have the correct "name
"
13093 for ( index in value ) {
13094 if ( !( index in props ) ) {
13095 props[ index ] = value[ index ];
13096 specialEasing[ index ] = easing;
13100 specialEasing[ name ] = easing;
13105 function Animation( elem, properties, options ) {
13109 length = animationPrefilters.length,
13110 deferred = jQuery.Deferred().always( function() {
13111 // don't match elem in the :animated selector
13114 tick = function() {
13118 var currentTime = fxNow || createFxNow(),
13119 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
13120 // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
13121 temp = remaining / animation.duration || 0,
13122 percent = 1 - temp,
13124 length = animation.tweens.length;
13126 for ( ; index < length ; index++ ) {
13127 animation.tweens[ index ].run( percent );
13130 deferred.notifyWith( elem, [ animation, percent, remaining ]);
13132 if ( percent < 1 && length ) {
13135 deferred.resolveWith( elem, [ animation ] );
13139 animation = deferred.promise({
13141 props: jQuery.extend( {}, properties ),
13142 opts: jQuery.extend( true, { specialEasing: {} }, options ),
13143 originalProperties: properties,
13144 originalOptions: options,
13145 startTime: fxNow || createFxNow(),
13146 duration: options.duration,
13148 createTween: function( prop, end ) {
13149 var tween = jQuery.Tween( elem, animation.opts, prop, end,
13150 animation.opts.specialEasing[ prop ] || animation.opts.easing );
13151 animation.tweens.push( tween );
13154 stop: function( gotoEnd ) {
13156 // if we are going to the end, we want to run all the tweens
13157 // otherwise we skip this part
13158 length = gotoEnd ? animation.tweens.length : 0;
13163 for ( ; index < length ; index++ ) {
13164 animation.tweens[ index ].run( 1 );
13167 // resolve when we played the last frame
13168 // otherwise, reject
13170 deferred.resolveWith( elem, [ animation, gotoEnd ] );
13172 deferred.rejectWith( elem, [ animation, gotoEnd ] );
13177 props = animation.props;
13179 propFilter( props, animation.opts.specialEasing );
13181 for ( ; index < length ; index++ ) {
13182 result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
13188 jQuery.map( props, createTween, animation );
13190 if ( jQuery.isFunction( animation.opts.start ) ) {
13191 animation.opts.start.call( elem, animation );
13195 jQuery.extend( tick, {
13198 queue: animation.opts.queue
13202 // attach callbacks from options
13203 return animation.progress( animation.opts.progress )
13204 .done( animation.opts.done, animation.opts.complete )
13205 .fail( animation.opts.fail )
13206 .always( animation.opts.always );
13209 jQuery.Animation = jQuery.extend( Animation, {
13211 tweener: function( props, callback ) {
13212 if ( jQuery.isFunction( props ) ) {
13216 props = props.split(" ");
13221 length = props.length;
13223 for ( ; index < length ; index++ ) {
13224 prop = props[ index ];
13225 tweeners[ prop ] = tweeners[ prop ] || [];
13226 tweeners[ prop ].unshift( callback );
13230 prefilter: function( callback, prepend ) {
13232 animationPrefilters.unshift( callback );
13234 animationPrefilters.push( callback );
13239 jQuery.speed = function( speed, easing, fn ) {
13240 var opt = speed && typeof speed === "object
" ? jQuery.extend( {}, speed ) : {
13241 complete: fn || !fn && easing ||
13242 jQuery.isFunction( speed ) && speed,
13244 easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
13247 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number
" ? opt.duration :
13248 opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
13250 // normalize opt.queue - true/undefined/null -> "fx
"
13251 if ( opt.queue == null || opt.queue === true ) {
13256 opt.old = opt.complete;
13258 opt.complete = function() {
13259 if ( jQuery.isFunction( opt.old ) ) {
13260 opt.old.call( this );
13264 jQuery.dequeue( this, opt.queue );
13272 fadeTo: function( speed, to, easing, callback ) {
13274 // show any hidden elements after setting opacity to 0
13275 return this.filter( isHidden ).css( "opacity
", 0 ).show()
13277 // animate to the value specified
13278 .end().animate({ opacity: to }, speed, easing, callback );
13280 animate: function( prop, speed, easing, callback ) {
13281 var empty = jQuery.isEmptyObject( prop ),
13282 optall = jQuery.speed( speed, easing, callback ),
13283 doAnimation = function() {
13284 // Operate on a copy of prop so per-property easing won't be lost
13285 var anim = Animation( this, jQuery.extend( {}, prop ), optall );
13287 // Empty animations, or finishing resolves immediately
13288 if ( empty || data_priv.get( this, "finish
" ) ) {
13292 doAnimation.finish = doAnimation;
13294 return empty || optall.queue === false ?
13295 this.each( doAnimation ) :
13296 this.queue( optall.queue, doAnimation );
13298 stop: function( type, clearQueue, gotoEnd ) {
13299 var stopQueue = function( hooks ) {
13300 var stop = hooks.stop;
13305 if ( typeof type !== "string
" ) {
13306 gotoEnd = clearQueue;
13310 if ( clearQueue && type !== false ) {
13311 this.queue( type || "fx
", [] );
13314 return this.each(function() {
13315 var dequeue = true,
13316 index = type != null && type + "queueHooks
",
13317 timers = jQuery.timers,
13318 data = data_priv.get( this );
13321 if ( data[ index ] && data[ index ].stop ) {
13322 stopQueue( data[ index ] );
13325 for ( index in data ) {
13326 if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
13327 stopQueue( data[ index ] );
13332 for ( index = timers.length; index--; ) {
13333 if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
13334 timers[ index ].anim.stop( gotoEnd );
13336 timers.splice( index, 1 );
13340 // start the next in the queue if the last step wasn't forced
13341 // timers currently will call their complete callbacks, which will dequeue
13342 // but only if they were gotoEnd
13343 if ( dequeue || !gotoEnd ) {
13344 jQuery.dequeue( this, type );
13348 finish: function( type ) {
13349 if ( type !== false ) {
13350 type = type || "fx
";
13352 return this.each(function() {
13354 data = data_priv.get( this ),
13355 queue = data[ type + "queue
" ],
13356 hooks = data[ type + "queueHooks
" ],
13357 timers = jQuery.timers,
13358 length = queue ? queue.length : 0;
13360 // enable finishing flag on private data
13361 data.finish = true;
13363 // empty the queue first
13364 jQuery.queue( this, type, [] );
13366 if ( hooks && hooks.stop ) {
13367 hooks.stop.call( this, true );
13370 // look for any active animations, and finish them
13371 for ( index = timers.length; index--; ) {
13372 if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
13373 timers[ index ].anim.stop( true );
13374 timers.splice( index, 1 );
13378 // look for any animations in the old queue and finish them
13379 for ( index = 0; index < length; index++ ) {
13380 if ( queue[ index ] && queue[ index ].finish ) {
13381 queue[ index ].finish.call( this );
13385 // turn off finishing flag
13386 delete data.finish;
13391 jQuery.each([ "toggle
", "show
", "hide
" ], function( i, name ) {
13392 var cssFn = jQuery.fn[ name ];
13393 jQuery.fn[ name ] = function( speed, easing, callback ) {
13394 return speed == null || typeof speed === "boolean
" ?
13395 cssFn.apply( this, arguments ) :
13396 this.animate( genFx( name, true ), speed, easing, callback );
13400 // Generate shortcuts for custom animations
13402 slideDown: genFx("show
"),
13403 slideUp: genFx("hide
"),
13404 slideToggle: genFx("toggle
"),
13405 fadeIn: { opacity: "show
" },
13406 fadeOut: { opacity: "hide
" },
13407 fadeToggle: { opacity: "toggle
" }
13408 }, function( name, props ) {
13409 jQuery.fn[ name ] = function( speed, easing, callback ) {
13410 return this.animate( props, speed, easing, callback );
13414 jQuery.timers = [];
13415 jQuery.fx.tick = function() {
13418 timers = jQuery.timers;
13420 fxNow = jQuery.now();
13422 for ( ; i < timers.length; i++ ) {
13423 timer = timers[ i ];
13424 // Checks the timer has not already been removed
13425 if ( !timer() && timers[ i ] === timer ) {
13426 timers.splice( i--, 1 );
13430 if ( !timers.length ) {
13436 jQuery.fx.timer = function( timer ) {
13437 jQuery.timers.push( timer );
13441 jQuery.timers.pop();
13445 jQuery.fx.interval = 13;
13447 jQuery.fx.start = function() {
13449 timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
13453 jQuery.fx.stop = function() {
13454 clearInterval( timerId );
13458 jQuery.fx.speeds = {
13466 // Based off of the plugin by Clint Helfers, with permission.
13467 // http://blindsignals.com/index.php/2009/07/jquery-delay/
13468 jQuery.fn.delay = function( time, type ) {
13469 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
13470 type = type || "fx
";
13472 return this.queue( type, function( next, hooks ) {
13473 var timeout = setTimeout( next, time );
13474 hooks.stop = function() {
13475 clearTimeout( timeout );
13482 var input = document.createElement( "input
" ),
13483 select = document.createElement( "select
" ),
13484 opt = select.appendChild( document.createElement( "option
" ) );
13486 input.type = "checkbox
";
13488 // Support: iOS 5.1, Android 4.x, Android 2.3
13489 // Check the default checkbox/radio value ("" on old WebKit; "on
" elsewhere)
13490 support.checkOn = input.value !== "";
13492 // Must access the parent to make an option select properly
13493 // Support: IE9, IE10
13494 support.optSelected = opt.selected;
13496 // Make sure that the options inside disabled selects aren't marked as disabled
13497 // (WebKit marks them as disabled)
13498 select.disabled = true;
13499 support.optDisabled = !opt.disabled;
13501 // Check if an input maintains its value after becoming a radio
13502 // Support: IE9, IE10
13503 input = document.createElement( "input
" );
13505 input.type = "radio
";
13506 support.radioValue = input.value === "t
";
13510 var nodeHook, boolHook,
13511 attrHandle = jQuery.expr.attrHandle;
13514 attr: function( name, value ) {
13515 return access( this, jQuery.attr, name, value, arguments.length > 1 );
13518 removeAttr: function( name ) {
13519 return this.each(function() {
13520 jQuery.removeAttr( this, name );
13526 attr: function( elem, name, value ) {
13528 nType = elem.nodeType;
13530 // don't get/set attributes on text, comment and attribute nodes
13531 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
13535 // Fallback to prop when attributes are not supported
13536 if ( typeof elem.getAttribute === strundefined ) {
13537 return jQuery.prop( elem, name, value );
13540 // All attributes are lowercase
13541 // Grab necessary hook if one is defined
13542 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
13543 name = name.toLowerCase();
13544 hooks = jQuery.attrHooks[ name ] ||
13545 ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook );
13548 if ( value !== undefined ) {
13550 if ( value === null ) {
13551 jQuery.removeAttr( elem, name );
13553 } else if ( hooks && "set
" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
13557 elem.setAttribute( name, value + "" );
13561 } else if ( hooks && "get
" in hooks && (ret = hooks.get( elem, name )) !== null ) {
13565 ret = jQuery.find.attr( elem, name );
13567 // Non-existent attributes return null, we normalize to undefined
13568 return ret == null ?
13574 removeAttr: function( elem, value ) {
13575 var name, propName,
13577 attrNames = value && value.match( rnotwhite );
13579 if ( attrNames && elem.nodeType === 1 ) {
13580 while ( (name = attrNames[i++]) ) {
13581 propName = jQuery.propFix[ name ] || name;
13583 // Boolean attributes get special treatment (#10870)
13584 if ( jQuery.expr.match.bool.test( name ) ) {
13585 // Set corresponding property to false
13586 elem[ propName ] = false;
13589 elem.removeAttribute( name );
13596 set: function( elem, value ) {
13597 if ( !support.radioValue && value === "radio
" &&
13598 jQuery.nodeName( elem, "input
" ) ) {
13599 // Setting the type on a radio button after the value resets the value in IE6-9
13600 // Reset value to default in case type is set after value during creation
13601 var val = elem.value;
13602 elem.setAttribute( "type
", value );
13613 // Hooks for boolean attributes
13615 set: function( elem, value, name ) {
13616 if ( value === false ) {
13617 // Remove boolean attributes when set to false
13618 jQuery.removeAttr( elem, name );
13620 elem.setAttribute( name, name );
13625 jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
13626 var getter = attrHandle[ name ] || jQuery.find.attr;
13628 attrHandle[ name ] = function( elem, name, isXML ) {
13631 // Avoid an infinite loop by temporarily removing this function from the getter
13632 handle = attrHandle[ name ];
13633 attrHandle[ name ] = ret;
13634 ret = getter( elem, name, isXML ) != null ?
13635 name.toLowerCase() :
13637 attrHandle[ name ] = handle;
13646 var rfocusable = /^(?:input|select|textarea|button)$/i;
13649 prop: function( name, value ) {
13650 return access( this, jQuery.prop, name, value, arguments.length > 1 );
13653 removeProp: function( name ) {
13654 return this.each(function() {
13655 delete this[ jQuery.propFix[ name ] || name ];
13663 "class
": "className
"
13666 prop: function( elem, name, value ) {
13667 var ret, hooks, notxml,
13668 nType = elem.nodeType;
13670 // don't get/set properties on text, comment and attribute nodes
13671 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
13675 notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
13678 // Fix name and attach hooks
13679 name = jQuery.propFix[ name ] || name;
13680 hooks = jQuery.propHooks[ name ];
13683 if ( value !== undefined ) {
13684 return hooks && "set
" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ?
13686 ( elem[ name ] = value );
13689 return hooks && "get
" in hooks && (ret = hooks.get( elem, name )) !== null ?
13697 get: function( elem ) {
13698 return elem.hasAttribute( "tabindex
" ) || rfocusable.test( elem.nodeName ) || elem.href ?
13707 // Selectedness for an option in an optgroup can be inaccurate
13708 if ( !support.optSelected ) {
13709 jQuery.propHooks.selected = {
13710 get: function( elem ) {
13711 var parent = elem.parentNode;
13712 if ( parent && parent.parentNode ) {
13713 parent.parentNode.selectedIndex;
13732 jQuery.propFix[ this.toLowerCase() ] = this;
13738 var rclass = /[\t\r\n\f]/g;
13741 addClass: function( value ) {
13742 var classes, elem, cur, clazz, j, finalValue,
13743 proceed = typeof value === "string
" && value,
13747 if ( jQuery.isFunction( value ) ) {
13748 return this.each(function( j ) {
13749 jQuery( this ).addClass( value.call( this, j, this.className ) );
13754 // The disjunction here is for better compressibility (see removeClass)
13755 classes = ( value || "" ).match( rnotwhite ) || [];
13757 for ( ; i < len; i++ ) {
13759 cur = elem.nodeType === 1 && ( elem.className ?
13760 ( " " + elem.className + " " ).replace( rclass, " " ) :
13766 while ( (clazz = classes[j++]) ) {
13767 if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
13768 cur += clazz + " ";
13772 // only assign if different to avoid unneeded rendering.
13773 finalValue = jQuery.trim( cur );
13774 if ( elem.className !== finalValue ) {
13775 elem.className = finalValue;
13784 removeClass: function( value ) {
13785 var classes, elem, cur, clazz, j, finalValue,
13786 proceed = arguments.length === 0 || typeof value === "string
" && value,
13790 if ( jQuery.isFunction( value ) ) {
13791 return this.each(function( j ) {
13792 jQuery( this ).removeClass( value.call( this, j, this.className ) );
13796 classes = ( value || "" ).match( rnotwhite ) || [];
13798 for ( ; i < len; i++ ) {
13800 // This expression is here for better compressibility (see addClass)
13801 cur = elem.nodeType === 1 && ( elem.className ?
13802 ( " " + elem.className + " " ).replace( rclass, " " ) :
13808 while ( (clazz = classes[j++]) ) {
13809 // Remove *all* instances
13810 while ( cur.indexOf( " " + clazz + " " ) >= 0 ) {
13811 cur = cur.replace( " " + clazz + " ", " " );
13815 // only assign if different to avoid unneeded rendering.
13816 finalValue = value ? jQuery.trim( cur ) : "";
13817 if ( elem.className !== finalValue ) {
13818 elem.className = finalValue;
13827 toggleClass: function( value, stateVal ) {
13828 var type = typeof value;
13830 if ( typeof stateVal === "boolean
" && type === "string
" ) {
13831 return stateVal ? this.addClass( value ) : this.removeClass( value );
13834 if ( jQuery.isFunction( value ) ) {
13835 return this.each(function( i ) {
13836 jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
13840 return this.each(function() {
13841 if ( type === "string
" ) {
13842 // toggle individual class names
13845 self = jQuery( this ),
13846 classNames = value.match( rnotwhite ) || [];
13848 while ( (className = classNames[ i++ ]) ) {
13849 // check each className given, space separated list
13850 if ( self.hasClass( className ) ) {
13851 self.removeClass( className );
13853 self.addClass( className );
13857 // Toggle whole class name
13858 } else if ( type === strundefined || type === "boolean
" ) {
13859 if ( this.className ) {
13860 // store className if set
13861 data_priv.set( this, "__className__
", this.className );
13864 // If the element has a class name or if we're passed "false
",
13865 // then remove the whole classname (if there was one, the above saved it).
13866 // Otherwise bring back whatever was previously saved (if anything),
13867 // falling back to the empty string if nothing was stored.
13868 this.className = this.className || value === false ? "" : data_priv.get( this, "__className__
" ) || "";
13873 hasClass: function( selector ) {
13874 var className = " " + selector + " ",
13877 for ( ; i < l; i++ ) {
13878 if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
13890 var rreturn = /\r/g;
13893 val: function( value ) {
13894 var hooks, ret, isFunction,
13897 if ( !arguments.length ) {
13899 hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
13901 if ( hooks && "get
" in hooks && (ret = hooks.get( elem, "value
" )) !== undefined ) {
13907 return typeof ret === "string
" ?
13908 // handle most common string cases
13909 ret.replace(rreturn, "") :
13910 // handle cases where value is null/undef or number
13911 ret == null ? "" : ret;
13917 isFunction = jQuery.isFunction( value );
13919 return this.each(function( i ) {
13922 if ( this.nodeType !== 1 ) {
13926 if ( isFunction ) {
13927 val = value.call( this, i, jQuery( this ).val() );
13932 // Treat null/undefined as ""; convert numbers to string
13933 if ( val == null ) {
13936 } else if ( typeof val === "number
" ) {
13939 } else if ( jQuery.isArray( val ) ) {
13940 val = jQuery.map( val, function( value ) {
13941 return value == null ? "" : value + "";
13945 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
13947 // If set returns undefined, fall back to normal setting
13948 if ( !hooks || !("set
" in hooks) || hooks.set( this, val, "value
" ) === undefined ) {
13958 get: function( elem ) {
13959 var val = jQuery.find.attr( elem, "value
" );
13960 return val != null ?
13962 // Support: IE10-11+
13963 // option.text throws exceptions (#14686, #14858)
13964 jQuery.trim( jQuery.text( elem ) );
13968 get: function( elem ) {
13970 options = elem.options,
13971 index = elem.selectedIndex,
13972 one = elem.type === "select-one
" || index < 0,
13973 values = one ? null : [],
13974 max = one ? index + 1 : options.length,
13979 // Loop through all the selected options
13980 for ( ; i < max; i++ ) {
13981 option = options[ i ];
13983 // IE6-9 doesn't update selected after form reset (#2551)
13984 if ( ( option.selected || i === index ) &&
13985 // Don't return options that are disabled or in a disabled optgroup
13986 ( support.optDisabled ? !option.disabled : option.getAttribute( "disabled
" ) === null ) &&
13987 ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup
" ) ) ) {
13989 // Get the specific value for the option
13990 value = jQuery( option ).val();
13992 // We don't need an array for one selects
13997 // Multi-Selects return an array
13998 values.push( value );
14005 set: function( elem, value ) {
14006 var optionSet, option,
14007 options = elem.options,
14008 values = jQuery.makeArray( value ),
14009 i = options.length;
14012 option = options[ i ];
14013 if ( (option.selected = jQuery.inArray( option.value, values ) >= 0) ) {
14018 // force browsers to behave consistently when non-matching value is set
14019 if ( !optionSet ) {
14020 elem.selectedIndex = -1;
14028 // Radios and checkboxes getter/setter
14029 jQuery.each([ "radio
", "checkbox
" ], function() {
14030 jQuery.valHooks[ this ] = {
14031 set: function( elem, value ) {
14032 if ( jQuery.isArray( value ) ) {
14033 return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
14037 if ( !support.checkOn ) {
14038 jQuery.valHooks[ this ].get = function( elem ) {
14040 // "" is returned instead of "on
" if a value isn't specified
14041 return elem.getAttribute("value
") === null ? "on
" : elem.value;
14049 // Return jQuery for attributes-only inclusion
14052 jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick
" +
14053 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave
" +
14054 "change select submit keydown keypress keyup error contextmenu
").split(" "), function( i, name ) {
14056 // Handle event binding
14057 jQuery.fn[ name ] = function( data, fn ) {
14058 return arguments.length > 0 ?
14059 this.on( name, null, data, fn ) :
14060 this.trigger( name );
14065 hover: function( fnOver, fnOut ) {
14066 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
14069 bind: function( types, data, fn ) {
14070 return this.on( types, null, data, fn );
14072 unbind: function( types, fn ) {
14073 return this.off( types, null, fn );
14076 delegate: function( selector, types, data, fn ) {
14077 return this.on( types, selector, data, fn );
14079 undelegate: function( selector, types, fn ) {
14080 // ( namespace ) or ( selector, types [, fn] )
14081 return arguments.length === 1 ? this.off( selector, "**
" ) : this.off( types, selector || "**
", fn );
14086 var nonce = jQuery.now();
14088 var rquery = (/\?/);
14092 // Support: Android 2.3
14093 // Workaround failure to string-cast null input
14094 jQuery.parseJSON = function( data ) {
14095 return JSON.parse( data + "" );
14099 // Cross-browser xml parsing
14100 jQuery.parseXML = function( data ) {
14102 if ( !data || typeof data !== "string
" ) {
14108 tmp = new DOMParser();
14109 xml = tmp.parseFromString( data, "text/xml
" );
14114 if ( !xml || xml.getElementsByTagName( "parsererror
" ).length ) {
14115 jQuery.error( "Invalid XML:
" + data );
14122 // Document location
14127 rts = /([?&])_=[^&]*/,
14128 rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
14129 // #7653, #8125, #8152: local protocol detection
14130 rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
14131 rnoContent = /^(?:GET|HEAD)$/,
14132 rprotocol = /^\/\//,
14133 rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,
14136 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
14137 * 2) These are called:
14138 * - BEFORE asking for a transport
14139 * - AFTER param serialization (s.data is a string if s.processData is true)
14140 * 3) key is the dataType
14141 * 4) the catchall symbol "*
" can be used
14142 * 5) execution will start with transport dataType and THEN continue down to "*
" if needed
14146 /* Transports bindings
14147 * 1) key is the dataType
14148 * 2) the catchall symbol "*
" can be used
14149 * 3) selection will start with transport dataType and THEN go to "*
" if needed
14153 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
14154 allTypes = "*/
".concat("*
");
14156 // #8138, IE may throw an exception when accessing
14157 // a field from window.location if document.domain has been set
14159 ajaxLocation = location.href;
14161 // Use the href attribute of an A element
14162 // since IE will modify it given document.location
14163 ajaxLocation = document.createElement( "a
" );
14164 ajaxLocation.href = "";
14165 ajaxLocation = ajaxLocation.href;
14168 // Segment location into parts
14169 ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
14171 // Base "constructor
" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
14172 function addToPrefiltersOrTransports( structure ) {
14174 // dataTypeExpression is optional and defaults to "*
"
14175 return function( dataTypeExpression, func ) {
14177 if ( typeof dataTypeExpression !== "string
" ) {
14178 func = dataTypeExpression;
14179 dataTypeExpression = "*
";
14184 dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || [];
14186 if ( jQuery.isFunction( func ) ) {
14187 // For each dataType in the dataTypeExpression
14188 while ( (dataType = dataTypes[i++]) ) {
14189 // Prepend if requested
14190 if ( dataType[0] === "+
" ) {
14191 dataType = dataType.slice( 1 ) || "*
";
14192 (structure[ dataType ] = structure[ dataType ] || []).unshift( func );
14194 // Otherwise append
14196 (structure[ dataType ] = structure[ dataType ] || []).push( func );
14203 // Base inspection function for prefilters and transports
14204 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
14206 var inspected = {},
14207 seekingTransport = ( structure === transports );
14209 function inspect( dataType ) {
14211 inspected[ dataType ] = true;
14212 jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
14213 var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
14214 if ( typeof dataTypeOrTransport === "string
" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
14215 options.dataTypes.unshift( dataTypeOrTransport );
14216 inspect( dataTypeOrTransport );
14218 } else if ( seekingTransport ) {
14219 return !( selected = dataTypeOrTransport );
14225 return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*
" ] && inspect( "*
" );
14228 // A special extend for ajax options
14229 // that takes "flat
" options (not to be deep extended)
14231 function ajaxExtend( target, src ) {
14233 flatOptions = jQuery.ajaxSettings.flatOptions || {};
14235 for ( key in src ) {
14236 if ( src[ key ] !== undefined ) {
14237 ( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ];
14241 jQuery.extend( true, target, deep );
14247 /* Handles responses to an ajax request:
14248 * - finds the right dataType (mediates between content-type and expected dataType)
14249 * - returns the corresponding response
14251 function ajaxHandleResponses( s, jqXHR, responses ) {
14253 var ct, type, finalDataType, firstDataType,
14254 contents = s.contents,
14255 dataTypes = s.dataTypes;
14257 // Remove auto dataType and get content-type in the process
14258 while ( dataTypes[ 0 ] === "*
" ) {
14260 if ( ct === undefined ) {
14261 ct = s.mimeType || jqXHR.getResponseHeader("Content-Type
");
14265 // Check if we're dealing with a known content-type
14267 for ( type in contents ) {
14268 if ( contents[ type ] && contents[ type ].test( ct ) ) {
14269 dataTypes.unshift( type );
14275 // Check to see if we have a response for the expected dataType
14276 if ( dataTypes[ 0 ] in responses ) {
14277 finalDataType = dataTypes[ 0 ];
14279 // Try convertible dataTypes
14280 for ( type in responses ) {
14281 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
14282 finalDataType = type;
14285 if ( !firstDataType ) {
14286 firstDataType = type;
14289 // Or just use first one
14290 finalDataType = finalDataType || firstDataType;
14293 // If we found a dataType
14294 // We add the dataType to the list if needed
14295 // and return the corresponding response
14296 if ( finalDataType ) {
14297 if ( finalDataType !== dataTypes[ 0 ] ) {
14298 dataTypes.unshift( finalDataType );
14300 return responses[ finalDataType ];
14304 /* Chain conversions given the request and the original response
14305 * Also sets the responseXXX fields on the jqXHR instance
14307 function ajaxConvert( s, response, jqXHR, isSuccess ) {
14308 var conv2, current, conv, tmp, prev,
14310 // Work with a copy of dataTypes in case we need to modify it for conversion
14311 dataTypes = s.dataTypes.slice();
14313 // Create converters map with lowercased keys
14314 if ( dataTypes[ 1 ] ) {
14315 for ( conv in s.converters ) {
14316 converters[ conv.toLowerCase() ] = s.converters[ conv ];
14320 current = dataTypes.shift();
14322 // Convert to each sequential dataType
14323 while ( current ) {
14325 if ( s.responseFields[ current ] ) {
14326 jqXHR[ s.responseFields[ current ] ] = response;
14329 // Apply the dataFilter if provided
14330 if ( !prev && isSuccess && s.dataFilter ) {
14331 response = s.dataFilter( response, s.dataType );
14335 current = dataTypes.shift();
14339 // There's only work to do if current dataType is non-auto
14340 if ( current === "*
" ) {
14344 // Convert response if prev dataType is non-auto and differs from current
14345 } else if ( prev !== "*
" && prev !== current ) {
14347 // Seek a direct converter
14348 conv = converters[ prev + " " + current ] || converters[ "*
" + current ];
14350 // If none found, seek a pair
14352 for ( conv2 in converters ) {
14354 // If conv2 outputs current
14355 tmp = conv2.split( " " );
14356 if ( tmp[ 1 ] === current ) {
14358 // If prev can be converted to accepted input
14359 conv = converters[ prev + " " + tmp[ 0 ] ] ||
14360 converters[ "*
" + tmp[ 0 ] ];
14362 // Condense equivalence converters
14363 if ( conv === true ) {
14364 conv = converters[ conv2 ];
14366 // Otherwise, insert the intermediate dataType
14367 } else if ( converters[ conv2 ] !== true ) {
14368 current = tmp[ 0 ];
14369 dataTypes.unshift( tmp[ 1 ] );
14377 // Apply converter (if not an equivalence)
14378 if ( conv !== true ) {
14380 // Unless errors are allowed to bubble, catch and return them
14381 if ( conv && s[ "throws
" ] ) {
14382 response = conv( response );
14385 response = conv( response );
14387 return { state: "parsererror
", error: conv ? e : "No conversion from
" + prev + " to
" + current };
14395 return { state: "success
", data: response };
14400 // Counter for holding the number of active queries
14403 // Last-Modified header cache for next request
14410 isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
14414 contentType: "application/x-www-form-urlencoded; charset=UTF-
8",
14423 traditional: false,
14429 text: "text/plain
",
14431 xml: "application/xml, text/xml
",
14432 json: "application/json, text/javascript
"
14442 xml: "responseXML
",
14443 text: "responseText
",
14444 json: "responseJSON
"
14448 // Keys separate source (or catchall "*
") and destination types with a single space
14451 // Convert anything to text
14454 // Text to html (true = no transformation)
14457 // Evaluate text as a json expression
14458 "text json
": jQuery.parseJSON,
14460 // Parse text as xml
14461 "text xml
": jQuery.parseXML
14464 // For options that shouldn't be deep extended:
14465 // you can add your own custom options here if
14466 // and when you create one that shouldn't be
14467 // deep extended (see ajaxExtend)
14474 // Creates a full fledged settings object into target
14475 // with both ajaxSettings and settings fields.
14476 // If target is omitted, writes into ajaxSettings.
14477 ajaxSetup: function( target, settings ) {
14480 // Building a settings object
14481 ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
14483 // Extending ajaxSettings
14484 ajaxExtend( jQuery.ajaxSettings, target );
14487 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
14488 ajaxTransport: addToPrefiltersOrTransports( transports ),
14491 ajax: function( url, options ) {
14493 // If url is an object, simulate pre-1.5 signature
14494 if ( typeof url === "object
" ) {
14499 // Force options to be an object
14500 options = options || {};
14503 // URL without anti-cache param
14505 // Response headers
14506 responseHeadersString,
14510 // Cross-domain detection vars
14512 // To know if global events are to be dispatched
14516 // Create the final options object
14517 s = jQuery.ajaxSetup( {}, options ),
14518 // Callbacks context
14519 callbackContext = s.context || s,
14520 // Context for global events is callbackContext if it is a DOM node or jQuery collection
14521 globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ?
14522 jQuery( callbackContext ) :
14525 deferred = jQuery.Deferred(),
14526 completeDeferred = jQuery.Callbacks("once memory
"),
14527 // Status-dependent callbacks
14528 statusCode = s.statusCode || {},
14529 // Headers (they are sent all at once)
14530 requestHeaders = {},
14531 requestHeadersNames = {},
14534 // Default abort message
14535 strAbort = "canceled
",
14540 // Builds headers hashtable if needed
14541 getResponseHeader: function( key ) {
14543 if ( state === 2 ) {
14544 if ( !responseHeaders ) {
14545 responseHeaders = {};
14546 while ( (match = rheaders.exec( responseHeadersString )) ) {
14547 responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
14550 match = responseHeaders[ key.toLowerCase() ];
14552 return match == null ? null : match;
14556 getAllResponseHeaders: function() {
14557 return state === 2 ? responseHeadersString : null;
14560 // Caches the header
14561 setRequestHeader: function( name, value ) {
14562 var lname = name.toLowerCase();
14564 name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
14565 requestHeaders[ name ] = value;
14570 // Overrides response content-type header
14571 overrideMimeType: function( type ) {
14578 // Status-dependent callbacks
14579 statusCode: function( map ) {
14583 for ( code in map ) {
14584 // Lazy-add the new callback in a way that preserves old ones
14585 statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
14588 // Execute the appropriate callbacks
14589 jqXHR.always( map[ jqXHR.status ] );
14595 // Cancel the request
14596 abort: function( statusText ) {
14597 var finalText = statusText || strAbort;
14599 transport.abort( finalText );
14601 done( 0, finalText );
14606 // Attach deferreds
14607 deferred.promise( jqXHR ).complete = completeDeferred.add;
14608 jqXHR.success = jqXHR.done;
14609 jqXHR.error = jqXHR.fail;
14611 // Remove hash character (#7531: and string promotion)
14612 // Add protocol if not provided (prefilters might expect it)
14613 // Handle falsy url in the settings object (#10093: consistency with old signature)
14614 // We also use the url parameter if available
14615 s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" )
14616 .replace( rprotocol, ajaxLocParts[ 1 ] + "//
" );
14618 // Alias method option to type as per ticket #12004
14619 s.type = options.method || options.type || s.method || s.type;
14621 // Extract dataTypes list
14622 s.dataTypes = jQuery.trim( s.dataType || "*
" ).toLowerCase().match( rnotwhite ) || [ "" ];
14624 // A cross-domain request is in order when we have a protocol:host:port mismatch
14625 if ( s.crossDomain == null ) {
14626 parts = rurl.exec( s.url.toLowerCase() );
14627 s.crossDomain = !!( parts &&
14628 ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
14629 ( parts[ 3 ] || ( parts[ 1 ] === "http:
" ? "80" : "443" ) ) !==
14630 ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:
" ? "80" : "443" ) ) )
14634 // Convert data if not already a string
14635 if ( s.data && s.processData && typeof s.data !== "string
" ) {
14636 s.data = jQuery.param( s.data, s.traditional );
14639 // Apply prefilters
14640 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
14642 // If request was aborted inside a prefilter, stop there
14643 if ( state === 2 ) {
14647 // We can fire global events as of now if asked to
14648 fireGlobals = s.global;
14650 // Watch for a new set of requests
14651 if ( fireGlobals && jQuery.active++ === 0 ) {
14652 jQuery.event.trigger("ajaxStart
");
14655 // Uppercase the type
14656 s.type = s.type.toUpperCase();
14658 // Determine if request has content
14659 s.hasContent = !rnoContent.test( s.type );
14661 // Save the URL in case we're toying with the If-Modified-Since
14662 // and/or If-None-Match header later on
14665 // More options handling for requests with no content
14666 if ( !s.hasContent ) {
14668 // If data is available, append data to url
14670 cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&
" : "?
" ) + s.data );
14671 // #9682: remove data so that it's not used in an eventual retry
14675 // Add anti-cache in url if needed
14676 if ( s.cache === false ) {
14677 s.url = rts.test( cacheURL ) ?
14679 // If there is already a '_' parameter, set its value
14680 cacheURL.replace( rts, "$
1_=
" + nonce++ ) :
14682 // Otherwise add one to the end
14683 cacheURL + ( rquery.test( cacheURL ) ? "&
" : "?
" ) + "_=
" + nonce++;
14687 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
14688 if ( s.ifModified ) {
14689 if ( jQuery.lastModified[ cacheURL ] ) {
14690 jqXHR.setRequestHeader( "If-Modified-Since
", jQuery.lastModified[ cacheURL ] );
14692 if ( jQuery.etag[ cacheURL ] ) {
14693 jqXHR.setRequestHeader( "If-None-Match
", jQuery.etag[ cacheURL ] );
14697 // Set the correct header, if data is being sent
14698 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
14699 jqXHR.setRequestHeader( "Content-Type
", s.contentType );
14702 // Set the Accepts header for the server, depending on the dataType
14703 jqXHR.setRequestHeader(
14705 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
14706 s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*
" ? ",
" + allTypes + "; q=
0.01" : "" ) :
14710 // Check for headers option
14711 for ( i in s.headers ) {
14712 jqXHR.setRequestHeader( i, s.headers[ i ] );
14715 // Allow custom headers/mimetypes and early abort
14716 if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
14717 // Abort if not done already and return
14718 return jqXHR.abort();
14721 // aborting is no longer a cancellation
14722 strAbort = "abort
";
14724 // Install callbacks on deferreds
14725 for ( i in { success: 1, error: 1, complete: 1 } ) {
14726 jqXHR[ i ]( s[ i ] );
14730 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
14732 // If no transport, we auto-abort
14733 if ( !transport ) {
14734 done( -1, "No Transport
" );
14736 jqXHR.readyState = 1;
14738 // Send global event
14739 if ( fireGlobals ) {
14740 globalEventContext.trigger( "ajaxSend
", [ jqXHR, s ] );
14743 if ( s.async && s.timeout > 0 ) {
14744 timeoutTimer = setTimeout(function() {
14745 jqXHR.abort("timeout
");
14751 transport.send( requestHeaders, done );
14753 // Propagate exception as error if not done
14756 // Simply rethrow otherwise
14763 // Callback for when everything is done
14764 function done( status, nativeStatusText, responses, headers ) {
14765 var isSuccess, success, error, response, modified,
14766 statusText = nativeStatusText;
14769 if ( state === 2 ) {
14773 // State is "done
" now
14776 // Clear timeout if it exists
14777 if ( timeoutTimer ) {
14778 clearTimeout( timeoutTimer );
14781 // Dereference transport for early garbage collection
14782 // (no matter how long the jqXHR object will be used)
14783 transport = undefined;
14785 // Cache response headers
14786 responseHeadersString = headers || "";
14789 jqXHR.readyState = status > 0 ? 4 : 0;
14791 // Determine if successful
14792 isSuccess = status >= 200 && status < 300 || status === 304;
14794 // Get response data
14796 response = ajaxHandleResponses( s, jqXHR, responses );
14799 // Convert no matter what (that way responseXXX fields are always set)
14800 response = ajaxConvert( s, response, jqXHR, isSuccess );
14802 // If successful, handle type chaining
14805 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
14806 if ( s.ifModified ) {
14807 modified = jqXHR.getResponseHeader("Last-Modified
");
14809 jQuery.lastModified[ cacheURL ] = modified;
14811 modified = jqXHR.getResponseHeader("etag
");
14813 jQuery.etag[ cacheURL ] = modified;
14818 if ( status === 204 || s.type === "HEAD
" ) {
14819 statusText = "nocontent
";
14822 } else if ( status === 304 ) {
14823 statusText = "notmodified
";
14825 // If we have data, let's convert it
14827 statusText = response.state;
14828 success = response.data;
14829 error = response.error;
14830 isSuccess = !error;
14833 // We extract error from statusText
14834 // then normalize statusText and status for non-aborts
14835 error = statusText;
14836 if ( status || !statusText ) {
14837 statusText = "error
";
14838 if ( status < 0 ) {
14844 // Set data for the fake xhr object
14845 jqXHR.status = status;
14846 jqXHR.statusText = ( nativeStatusText || statusText ) + "";
14850 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
14852 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
14855 // Status-dependent callbacks
14856 jqXHR.statusCode( statusCode );
14857 statusCode = undefined;
14859 if ( fireGlobals ) {
14860 globalEventContext.trigger( isSuccess ? "ajaxSuccess
" : "ajaxError
",
14861 [ jqXHR, s, isSuccess ? success : error ] );
14865 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
14867 if ( fireGlobals ) {
14868 globalEventContext.trigger( "ajaxComplete
", [ jqXHR, s ] );
14869 // Handle the global AJAX counter
14870 if ( !( --jQuery.active ) ) {
14871 jQuery.event.trigger("ajaxStop
");
14879 getJSON: function( url, data, callback ) {
14880 return jQuery.get( url, data, callback, "json
" );
14883 getScript: function( url, callback ) {
14884 return jQuery.get( url, undefined, callback, "script
" );
14888 jQuery.each( [ "get
", "post
" ], function( i, method ) {
14889 jQuery[ method ] = function( url, data, callback, type ) {
14890 // shift arguments if data argument was omitted
14891 if ( jQuery.isFunction( data ) ) {
14892 type = type || callback;
14897 return jQuery.ajax({
14907 // Attach a bunch of functions for handling common AJAX events
14908 jQuery.each( [ "ajaxStart
", "ajaxStop
", "ajaxComplete
", "ajaxError
", "ajaxSuccess
", "ajaxSend
" ], function( i, type ) {
14909 jQuery.fn[ type ] = function( fn ) {
14910 return this.on( type, fn );
14915 jQuery._evalUrl = function( url ) {
14916 return jQuery.ajax({
14919 dataType: "script
",
14928 wrapAll: function( html ) {
14931 if ( jQuery.isFunction( html ) ) {
14932 return this.each(function( i ) {
14933 jQuery( this ).wrapAll( html.call(this, i) );
14939 // The elements to wrap the target around
14940 wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
14942 if ( this[ 0 ].parentNode ) {
14943 wrap.insertBefore( this[ 0 ] );
14946 wrap.map(function() {
14949 while ( elem.firstElementChild ) {
14950 elem = elem.firstElementChild;
14960 wrapInner: function( html ) {
14961 if ( jQuery.isFunction( html ) ) {
14962 return this.each(function( i ) {
14963 jQuery( this ).wrapInner( html.call(this, i) );
14967 return this.each(function() {
14968 var self = jQuery( this ),
14969 contents = self.contents();
14971 if ( contents.length ) {
14972 contents.wrapAll( html );
14975 self.append( html );
14980 wrap: function( html ) {
14981 var isFunction = jQuery.isFunction( html );
14983 return this.each(function( i ) {
14984 jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
14988 unwrap: function() {
14989 return this.parent().each(function() {
14990 if ( !jQuery.nodeName( this, "body
" ) ) {
14991 jQuery( this ).replaceWith( this.childNodes );
14998 jQuery.expr.filters.hidden = function( elem ) {
14999 // Support: Opera <= 12.12
15000 // Opera reports offsetWidths and offsetHeights less than zero on some elements
15001 return elem.offsetWidth <= 0 && elem.offsetHeight <= 0;
15003 jQuery.expr.filters.visible = function( elem ) {
15004 return !jQuery.expr.filters.hidden( elem );
15011 rbracket = /\[\]$/,
15013 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
15014 rsubmittable = /^(?:input|select|textarea|keygen)/i;
15016 function buildParams( prefix, obj, traditional, add ) {
15019 if ( jQuery.isArray( obj ) ) {
15020 // Serialize array item.
15021 jQuery.each( obj, function( i, v ) {
15022 if ( traditional || rbracket.test( prefix ) ) {
15023 // Treat each array item as a scalar.
15027 // Item is non-scalar (array or object), encode its numeric index.
15028 buildParams( prefix + "[
" + ( typeof v === "object
" ? i : "" ) + "]
", v, traditional, add );
15032 } else if ( !traditional && jQuery.type( obj ) === "object
" ) {
15033 // Serialize object item.
15034 for ( name in obj ) {
15035 buildParams( prefix + "[
" + name + "]
", obj[ name ], traditional, add );
15039 // Serialize scalar item.
15040 add( prefix, obj );
15044 // Serialize an array of form elements or a set of
15045 // key/values into a query string
15046 jQuery.param = function( a, traditional ) {
15049 add = function( key, value ) {
15050 // If value is a function, invoke it and return its value
15051 value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
15052 s[ s.length ] = encodeURIComponent( key ) + "=
" + encodeURIComponent( value );
15055 // Set traditional to true for jQuery <= 1.3.2 behavior.
15056 if ( traditional === undefined ) {
15057 traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
15060 // If an array was passed in, assume that it is an array of form elements.
15061 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
15062 // Serialize the form elements
15063 jQuery.each( a, function() {
15064 add( this.name, this.value );
15068 // If traditional, encode the "old
" way (the way 1.3.2 or older
15069 // did it), otherwise encode params recursively.
15070 for ( prefix in a ) {
15071 buildParams( prefix, a[ prefix ], traditional, add );
15075 // Return the resulting serialization
15076 return s.join( "&
" ).replace( r20, "+
" );
15080 serialize: function() {
15081 return jQuery.param( this.serializeArray() );
15083 serializeArray: function() {
15084 return this.map(function() {
15085 // Can add propHook for "elements
" to filter or add form elements
15086 var elements = jQuery.prop( this, "elements
" );
15087 return elements ? jQuery.makeArray( elements ) : this;
15089 .filter(function() {
15090 var type = this.type;
15092 // Use .is( ":disabled
" ) so that fieldset[disabled] works
15093 return this.name && !jQuery( this ).is( ":disabled
" ) &&
15094 rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
15095 ( this.checked || !rcheckableType.test( type ) );
15097 .map(function( i, elem ) {
15098 var val = jQuery( this ).val();
15100 return val == null ?
15102 jQuery.isArray( val ) ?
15103 jQuery.map( val, function( val ) {
15104 return { name: elem.name, value: val.replace( rCRLF, "\r\n
" ) };
15106 { name: elem.name, value: val.replace( rCRLF, "\r\n
" ) };
15112 jQuery.ajaxSettings.xhr = function() {
15114 return new XMLHttpRequest();
15120 xhrSuccessStatus = {
15121 // file protocol always yields status code 0, assume 200
15124 // #1450: sometimes IE returns 1223 when it should be 204
15127 xhrSupported = jQuery.ajaxSettings.xhr();
15130 // Open requests must be manually aborted on unload (#5280)
15131 if ( window.ActiveXObject ) {
15132 jQuery( window ).on( "unload
", function() {
15133 for ( var key in xhrCallbacks ) {
15134 xhrCallbacks[ key ]();
15139 support.cors = !!xhrSupported && ( "withCredentials
" in xhrSupported );
15140 support.ajax = xhrSupported = !!xhrSupported;
15142 jQuery.ajaxTransport(function( options ) {
15145 // Cross domain only allowed if supported through XMLHttpRequest
15146 if ( support.cors || xhrSupported && !options.crossDomain ) {
15148 send: function( headers, complete ) {
15150 xhr = options.xhr(),
15153 xhr.open( options.type, options.url, options.async, options.username, options.password );
15155 // Apply custom fields if provided
15156 if ( options.xhrFields ) {
15157 for ( i in options.xhrFields ) {
15158 xhr[ i ] = options.xhrFields[ i ];
15162 // Override mime type if needed
15163 if ( options.mimeType && xhr.overrideMimeType ) {
15164 xhr.overrideMimeType( options.mimeType );
15167 // X-Requested-With header
15168 // For cross-domain requests, seeing as conditions for a preflight are
15169 // akin to a jigsaw puzzle, we simply never set it to be sure.
15170 // (it can always be set on a per-request basis or even using ajaxSetup)
15171 // For same-domain requests, won't change header if already provided.
15172 if ( !options.crossDomain && !headers["X-Requested-With
"] ) {
15173 headers["X-Requested-With
"] = "XMLHttpRequest
";
15177 for ( i in headers ) {
15178 xhr.setRequestHeader( i, headers[ i ] );
15182 callback = function( type ) {
15183 return function() {
15185 delete xhrCallbacks[ id ];
15186 callback = xhr.onload = xhr.onerror = null;
15188 if ( type === "abort
" ) {
15190 } else if ( type === "error
" ) {
15192 // file: protocol always yields status 0; see #8605, #14207
15198 xhrSuccessStatus[ xhr.status ] || xhr.status,
15201 // Accessing binary-data responseText throws an exception
15203 typeof xhr.responseText === "string
" ? {
15204 text: xhr.responseText
15206 xhr.getAllResponseHeaders()
15213 // Listen to events
15214 xhr.onload = callback();
15215 xhr.onerror = callback("error
");
15217 // Create the abort callback
15218 callback = xhrCallbacks[ id ] = callback("abort
");
15221 // Do send the request (this may raise an exception)
15222 xhr.send( options.hasContent && options.data || null );
15224 // #14683: Only rethrow if this hasn't been notified as an error yet
15231 abort: function() {
15243 // Install script dataType
15246 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript
"
15249 script: /(?:java|ecma)script/
15252 "text script
": function( text ) {
15253 jQuery.globalEval( text );
15259 // Handle cache's special case and crossDomain
15260 jQuery.ajaxPrefilter( "script
", function( s ) {
15261 if ( s.cache === undefined ) {
15264 if ( s.crossDomain ) {
15269 // Bind script tag hack transport
15270 jQuery.ajaxTransport( "script
", function( s ) {
15271 // This transport only deals with cross domain requests
15272 if ( s.crossDomain ) {
15273 var script, callback;
15275 send: function( _, complete ) {
15276 script = jQuery("<script>").prop({
15278 charset: s.scriptCharset,
15282 callback = function( evt ) {
15286 complete( evt.type === "error
" ? 404 : 200, evt.type );
15290 document.head.appendChild( script[ 0 ] );
15292 abort: function() {
15304 var oldCallbacks = [],
15305 rjsonp = /(=)\?(?=&|$)|\?\?/;
15307 // Default jsonp settings
15310 jsonpCallback: function() {
15311 var callback = oldCallbacks.pop() || ( jQuery.expando + "_
" + ( nonce++ ) );
15312 this[ callback ] = true;
15317 // Detect, normalize options and install callbacks for jsonp requests
15318 jQuery.ajaxPrefilter( "json jsonp
", function( s, originalSettings, jqXHR ) {
15320 var callbackName, overwritten, responseContainer,
15321 jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
15323 typeof s.data === "string
" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded
") && rjsonp.test( s.data ) && "data
"
15326 // Handle iff the expected data type is "jsonp
" or we have a parameter to set
15327 if ( jsonProp || s.dataTypes[ 0 ] === "jsonp
" ) {
15329 // Get callback name, remembering preexisting value associated with it
15330 callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
15331 s.jsonpCallback() :
15334 // Insert callback into url or form data
15336 s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$
1" + callbackName );
15337 } else if ( s.jsonp !== false ) {
15338 s.url += ( rquery.test( s.url ) ? "&
" : "?
" ) + s.jsonp + "=
" + callbackName;
15341 // Use data converter to retrieve json after script execution
15342 s.converters["script json
"] = function() {
15343 if ( !responseContainer ) {
15344 jQuery.error( callbackName + " was not called
" );
15346 return responseContainer[ 0 ];
15349 // force json dataType
15350 s.dataTypes[ 0 ] = "json
";
15352 // Install callback
15353 overwritten = window[ callbackName ];
15354 window[ callbackName ] = function() {
15355 responseContainer = arguments;
15358 // Clean-up function (fires after converters)
15359 jqXHR.always(function() {
15360 // Restore preexisting value
15361 window[ callbackName ] = overwritten;
15363 // Save back as free
15364 if ( s[ callbackName ] ) {
15365 // make sure that re-using the options doesn't screw things around
15366 s.jsonpCallback = originalSettings.jsonpCallback;
15368 // save the callback name for future use
15369 oldCallbacks.push( callbackName );
15372 // Call if it was a function and we have a response
15373 if ( responseContainer && jQuery.isFunction( overwritten ) ) {
15374 overwritten( responseContainer[ 0 ] );
15377 responseContainer = overwritten = undefined;
15380 // Delegate to script
15388 // data: string of html
15389 // context (optional): If specified, the fragment will be created in this context, defaults to document
15390 // keepScripts (optional): If true, will include scripts passed in the html string
15391 jQuery.parseHTML = function( data, context, keepScripts ) {
15392 if ( !data || typeof data !== "string
" ) {
15395 if ( typeof context === "boolean
" ) {
15396 keepScripts = context;
15399 context = context || document;
15401 var parsed = rsingleTag.exec( data ),
15402 scripts = !keepScripts && [];
15406 return [ context.createElement( parsed[1] ) ];
15409 parsed = jQuery.buildFragment( [ data ], context, scripts );
15411 if ( scripts && scripts.length ) {
15412 jQuery( scripts ).remove();
15415 return jQuery.merge( [], parsed.childNodes );
15419 // Keep a copy of the old load method
15420 var _load = jQuery.fn.load;
15423 * Load a url into a page
15425 jQuery.fn.load = function( url, params, callback ) {
15426 if ( typeof url !== "string
" && _load ) {
15427 return _load.apply( this, arguments );
15430 var selector, type, response,
15432 off = url.indexOf(" ");
15435 selector = jQuery.trim( url.slice( off ) );
15436 url = url.slice( 0, off );
15439 // If it's a function
15440 if ( jQuery.isFunction( params ) ) {
15442 // We assume that it's the callback
15444 params = undefined;
15446 // Otherwise, build a param string
15447 } else if ( params && typeof params === "object
" ) {
15451 // If we have elements to modify, make the request
15452 if ( self.length > 0 ) {
15456 // if "type
" variable is undefined, then "GET
" method will be used
15460 }).done(function( responseText ) {
15462 // Save response for use in complete callback
15463 response = arguments;
15465 self.html( selector ?
15467 // If a selector was specified, locate the right elements in a dummy div
15468 // Exclude scripts to avoid IE 'Permission Denied' errors
15469 jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) :
15471 // Otherwise use the full result
15474 }).complete( callback && function( jqXHR, status ) {
15475 self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
15485 jQuery.expr.filters.animated = function( elem ) {
15486 return jQuery.grep(jQuery.timers, function( fn ) {
15487 return elem === fn.elem;
15494 var docElem = window.document.documentElement;
15497 * Gets a window from an element
15499 function getWindow( elem ) {
15500 return jQuery.isWindow( elem ) ? elem : elem.nodeType === 9 && elem.defaultView;
15504 setOffset: function( elem, options, i ) {
15505 var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
15506 position = jQuery.css( elem, "position
" ),
15507 curElem = jQuery( elem ),
15510 // Set position first, in-case top/left are set even on static elem
15511 if ( position === "static
" ) {
15512 elem.style.position = "relative
";
15515 curOffset = curElem.offset();
15516 curCSSTop = jQuery.css( elem, "top
" );
15517 curCSSLeft = jQuery.css( elem, "left
" );
15518 calculatePosition = ( position === "absolute
" || position === "fixed
" ) &&
15519 ( curCSSTop + curCSSLeft ).indexOf("auto
") > -1;
15521 // Need to be able to calculate position if either top or left is auto and position is either absolute or fixed
15522 if ( calculatePosition ) {
15523 curPosition = curElem.position();
15524 curTop = curPosition.top;
15525 curLeft = curPosition.left;
15528 curTop = parseFloat( curCSSTop ) || 0;
15529 curLeft = parseFloat( curCSSLeft ) || 0;
15532 if ( jQuery.isFunction( options ) ) {
15533 options = options.call( elem, i, curOffset );
15536 if ( options.top != null ) {
15537 props.top = ( options.top - curOffset.top ) + curTop;
15539 if ( options.left != null ) {
15540 props.left = ( options.left - curOffset.left ) + curLeft;
15543 if ( "using
" in options ) {
15544 options.using.call( elem, props );
15547 curElem.css( props );
15553 offset: function( options ) {
15554 if ( arguments.length ) {
15555 return options === undefined ?
15557 this.each(function( i ) {
15558 jQuery.offset.setOffset( this, options, i );
15564 box = { top: 0, left: 0 },
15565 doc = elem && elem.ownerDocument;
15571 docElem = doc.documentElement;
15573 // Make sure it's not a disconnected DOM node
15574 if ( !jQuery.contains( docElem, elem ) ) {
15578 // If we don't have gBCR, just use 0,0 rather than error
15579 // BlackBerry 5, iOS 3 (original iPhone)
15580 if ( typeof elem.getBoundingClientRect !== strundefined ) {
15581 box = elem.getBoundingClientRect();
15583 win = getWindow( doc );
15585 top: box.top + win.pageYOffset - docElem.clientTop,
15586 left: box.left + win.pageXOffset - docElem.clientLeft
15590 position: function() {
15591 if ( !this[ 0 ] ) {
15595 var offsetParent, offset,
15597 parentOffset = { top: 0, left: 0 };
15599 // Fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is its only offset parent
15600 if ( jQuery.css( elem, "position
" ) === "fixed
" ) {
15601 // We assume that getBoundingClientRect is available when computed position is fixed
15602 offset = elem.getBoundingClientRect();
15605 // Get *real* offsetParent
15606 offsetParent = this.offsetParent();
15608 // Get correct offsets
15609 offset = this.offset();
15610 if ( !jQuery.nodeName( offsetParent[ 0 ], "html
" ) ) {
15611 parentOffset = offsetParent.offset();
15614 // Add offsetParent borders
15615 parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth
", true );
15616 parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth
", true );
15619 // Subtract parent offsets and element margins
15621 top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop
", true ),
15622 left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft
", true )
15626 offsetParent: function() {
15627 return this.map(function() {
15628 var offsetParent = this.offsetParent || docElem;
15630 while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html
" ) && jQuery.css( offsetParent, "position
" ) === "static
" ) ) {
15631 offsetParent = offsetParent.offsetParent;
15634 return offsetParent || docElem;
15639 // Create scrollLeft and scrollTop methods
15640 jQuery.each( { scrollLeft: "pageXOffset
", scrollTop: "pageYOffset
" }, function( method, prop ) {
15641 var top = "pageYOffset
" === prop;
15643 jQuery.fn[ method ] = function( val ) {
15644 return access( this, function( elem, method, val ) {
15645 var win = getWindow( elem );
15647 if ( val === undefined ) {
15648 return win ? win[ prop ] : elem[ method ];
15653 !top ? val : window.pageXOffset,
15654 top ? val : window.pageYOffset
15658 elem[ method ] = val;
15660 }, method, val, arguments.length, null );
15664 // Add the top/left cssHooks using jQuery.fn.position
15665 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
15666 // getComputedStyle returns percent when specified for top/left/bottom/right
15667 // rather than make the css module depend on the offset module, we just check for it here
15668 jQuery.each( [ "top
", "left
" ], function( i, prop ) {
15669 jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
15670 function( elem, computed ) {
15672 computed = curCSS( elem, prop );
15673 // if curCSS returns percentage, fallback to offset
15674 return rnumnonpx.test( computed ) ?
15675 jQuery( elem ).position()[ prop ] + "px
" :
15683 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
15684 jQuery.each( { Height: "height
", Width: "width
" }, function( name, type ) {
15685 jQuery.each( { padding: "inner
" + name, content: type, "": "outer
" + name }, function( defaultExtra, funcName ) {
15686 // margin is only for outerHeight, outerWidth
15687 jQuery.fn[ funcName ] = function( margin, value ) {
15688 var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean
" ),
15689 extra = defaultExtra || ( margin === true || value === true ? "margin
" : "border
" );
15691 return access( this, function( elem, type, value ) {
15694 if ( jQuery.isWindow( elem ) ) {
15695 // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
15696 // isn't a whole lot we can do. See pull request at this URL for discussion:
15697 // https://github.com/jquery/jquery/pull/764
15698 return elem.document.documentElement[ "client
" + name ];
15701 // Get document width or height
15702 if ( elem.nodeType === 9 ) {
15703 doc = elem.documentElement;
15705 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
15706 // whichever is greatest
15708 elem.body[ "scroll
" + name ], doc[ "scroll
" + name ],
15709 elem.body[ "offset
" + name ], doc[ "offset
" + name ],
15710 doc[ "client
" + name ]
15714 return value === undefined ?
15715 // Get width or height on the element, requesting but not forcing parseFloat
15716 jQuery.css( elem, type, extra ) :
15718 // Set width or height on the element
15719 jQuery.style( elem, type, value, extra );
15720 }, type, chainable ? margin : undefined, chainable, null );
15726 // The number of elements contained in the matched element set
15727 jQuery.fn.size = function() {
15728 return this.length;
15731 jQuery.fn.andSelf = jQuery.fn.addBack;
15736 // Register as a named AMD module, since jQuery can be concatenated with other
15737 // files that may use define, but not via a proper concatenation script that
15738 // understands anonymous AMD modules. A named AMD is safest and most robust
15739 // way to register. Lowercase jquery is used because AMD module names are
15740 // derived from file names, and jQuery is normally delivered in a lowercase
15741 // file name. Do this after creating the global so that if an AMD module wants
15742 // to call noConflict to hide this version of jQuery, it will work.
15744 // Note that for maximum portability, libraries that are not jQuery should
15745 // declare themselves as anonymous modules, and avoid setting a global if an
15746 // AMD loader is present. jQuery is a special case. For more information, see
15747 // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
15749 if ( typeof define === "function
" && define.amd ) {
15750 define( "jquery
", [], function() {
15759 // Map over jQuery in case of overwrite
15760 _jQuery = window.jQuery,
15762 // Map over the $ in case of overwrite
15765 jQuery.noConflict = function( deep ) {
15766 if ( window.$ === jQuery ) {
15770 if ( deep && window.jQuery === jQuery ) {
15771 window.jQuery = _jQuery;
15777 // Expose jQuery and $ identifiers, even in
15778 // AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
15779 // and CommonJS for browser emulators (#13566)
15780 if ( typeof noGlobal === strundefined ) {
15781 window.jQuery = window.$ = jQuery;
15793 * Bootstrap v3.2.0 (http://getbootstrap.com)
15794 * Copyright 2011-2014 Twitter, Inc.
15795 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
15798 if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript requires jQuery') }
15800 /* ========================================================================
15801 * Bootstrap: transition.js v3.2.0
15802 * http://getbootstrap.com/javascript/#transitions
15803 * ========================================================================
15804 * Copyright 2011-2014 Twitter, Inc.
15805 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
15806 * ======================================================================== */
15812 // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
15813 // ============================================================
15815 function transitionEnd() {
15816 var el = document.createElement('bootstrap')
15818 var transEndEventNames = {
15819 WebkitTransition : 'webkitTransitionEnd',
15820 MozTransition : 'transitionend',
15821 OTransition : 'oTransitionEnd otransitionend',
15822 transition : 'transitionend'
15825 for (var name in transEndEventNames) {
15826 if (el.style[name] !== undefined) {
15827 return { end: transEndEventNames[name] }
15831 return false // explicit for ie8 ( ._.)
15834 // http://blog.alexmaccaw.com/css-transitions
15835 $.fn.emulateTransitionEnd = function (duration) {
15838 $(this).one('bsTransitionEnd', function () { called = true })
15839 var callback = function () { if (!called) $($el).trigger($.support.transition.end) }
15840 setTimeout(callback, duration)
15845 $.support.transition = transitionEnd()
15847 if (!$.support.transition) return
15849 $.event.special.bsTransitionEnd = {
15850 bindType: $.support.transition.end,
15851 delegateType: $.support.transition.end,
15852 handle: function (e) {
15853 if ($(e.target).is(this)) return e.handleObj.handler.apply(this, arguments)
15860 /* ========================================================================
15861 * Bootstrap: alert.js v3.2.0
15862 * http://getbootstrap.com/javascript/#alerts
15863 * ========================================================================
15864 * Copyright 2011-2014 Twitter, Inc.
15865 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
15866 * ======================================================================== */
15872 // ALERT CLASS DEFINITION
15873 // ======================
15875 var dismiss = '[data-dismiss="alert"]'
15876 var Alert = function (el) {
15877 $(el).on('click', dismiss, this.close)
15880 Alert.VERSION = '
3.2.0'
15882 Alert.prototype.close = function (e) {
15883 var $this = $(this)
15884 var selector = $this.attr('data-target')
15887 selector = $this.attr('href')
15888 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
15891 var $parent = $(selector)
15893 if (e) e.preventDefault()
15895 if (!$parent.length) {
15896 $parent = $this.hasClass('alert') ? $this : $this.parent()
15899 $parent.trigger(e = $.Event('close.bs.alert'))
15901 if (e.isDefaultPrevented()) return
15903 $parent.removeClass('in')
15905 function removeElement() {
15906 // detach from parent, fire event then clean up data
15907 $parent.detach().trigger('closed.bs.alert').remove()
15910 $.support.transition && $parent.hasClass('fade') ?
15912 .one('bsTransitionEnd', removeElement)
15913 .emulateTransitionEnd(
150) :
15918 // ALERT PLUGIN DEFINITION
15919 // =======================
15921 function Plugin(option) {
15922 return this.each(function () {
15923 var $this = $(this)
15924 var data = $this.data('bs.alert')
15926 if (!data) $this.data('bs.alert', (data = new Alert(this)))
15927 if (typeof option == 'string') data[option].call($this)
15931 var old = $.fn.alert
15933 $.fn.alert = Plugin
15934 $.fn.alert.Constructor = Alert
15937 // ALERT NO CONFLICT
15938 // =================
15940 $.fn.alert.noConflict = function () {
15949 $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close)
15953 /* ========================================================================
15954 * Bootstrap: button.js v3.2
.0
15955 * http://getbootstrap.com/javascript/#buttons
15956 * ========================================================================
15957 * Copyright
2011-
2014 Twitter, Inc.
15958 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
15959 * ======================================================================== */
15965 // BUTTON PUBLIC CLASS DEFINITION
15966 // ==============================
15968 var Button = function (element, options) {
15969 this.$element = $(element)
15970 this.options = $.extend({}, Button.DEFAULTS, options)
15971 this.isLoading = false
15974 Button.VERSION = '
3.2.0'
15976 Button.DEFAULTS = {
15977 loadingText: 'loading...'
15980 Button.prototype.setState = function (state) {
15982 var $el = this.$element
15983 var val = $el.is('input') ? 'val' : 'html'
15984 var data = $el.data()
15986 state = state + 'Text'
15988 if (data.resetText == null) $el.data('resetText', $el[val]())
15990 $el[val](data[state] == null ? this.options[state] : data[state])
15992 // push to event loop to allow forms to submit
15993 setTimeout($.proxy(function () {
15994 if (state == 'loadingText') {
15995 this.isLoading = true
15996 $el.addClass(d).attr(d, d)
15997 } else if (this.isLoading) {
15998 this.isLoading = false
15999 $el.removeClass(d).removeAttr(d)
16004 Button.prototype.toggle = function () {
16006 var $parent = this.$element.closest('[
data-toggle="buttons"]')
16008 if ($parent.length) {
16009 var $input = this.$element.find('input')
16010 if ($input.prop('type') == 'radio') {
16011 if ($input.prop('checked') && this.$element.hasClass('active')) changed = false
16012 else $parent.find('.active').removeClass('active')
16014 if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change')
16017 if (changed) this.$element.toggleClass('active')
16021 // BUTTON PLUGIN DEFINITION
16022 // ========================
16024 function Plugin(option) {
16025 return this.each(function () {
16026 var $this = $(this)
16027 var data = $this.data('bs.button')
16028 var options = typeof option == 'object' && option
16030 if (!data) $this.data('bs.button', (data = new Button(this, options)))
16032 if (option == 'toggle') data.toggle()
16033 else if (option) data.setState(option)
16037 var old = $.fn.button
16039 $.fn.button = Plugin
16040 $.fn.button.Constructor = Button
16043 // BUTTON NO CONFLICT
16044 // ==================
16046 $.fn.button.noConflict = function () {
16055 $(document).on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) {
16056 var $btn = $(e.target)
16057 if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
16058 Plugin.call($btn, 'toggle')
16064 /* ========================================================================
16065 * Bootstrap: carousel.js v3.2
.0
16066 * http://getbootstrap.com/javascript/#carousel
16067 * ========================================================================
16068 * Copyright
2011-
2014 Twitter, Inc.
16069 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
16070 * ======================================================================== */
16076 // CAROUSEL CLASS DEFINITION
16077 // =========================
16079 var Carousel = function (element, options) {
16080 this.$element = $(element).on('keydown.bs.carousel', $.proxy(this.keydown, this))
16081 this.$indicators = this.$element.find('.carousel-indicators')
16082 this.options = options
16089 this.options.pause == 'hover' && this.$element
16090 .on('mouseenter.bs.carousel', $.proxy(this.pause, this))
16091 .on('mouseleave.bs.carousel', $.proxy(this.cycle, this))
16094 Carousel.VERSION = '
3.2.0'
16096 Carousel.DEFAULTS = {
16102 Carousel.prototype.keydown = function (e) {
16104 case
37: this.prev(); break
16105 case
39: this.next(); break
16112 Carousel.prototype.cycle = function (e) {
16113 e || (this.paused = false)
16115 this.interval && clearInterval(this.interval)
16117 this.options.interval
16119 && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
16124 Carousel.prototype.getItemIndex = function (item) {
16125 this.$items = item.parent().children('.item')
16126 return this.$items.index(item || this.$active)
16129 Carousel.prototype.to = function (pos) {
16131 var activeIndex = this.getItemIndex(this.$active = this.$element.find('.item.active'))
16133 if (pos
> (this.$items.length -
1) || pos <
0) return
16135 if (this.sliding) return this.$element.one('slid.bs.carousel', function () { that.to(pos) }) // yes, "slid"
16136 if (activeIndex == pos) return this.pause().cycle()
16138 return this.slide(pos
> activeIndex ? 'next' : 'prev', $(this.$items[pos]))
16141 Carousel.prototype.pause = function (e) {
16142 e || (this.paused = true)
16144 if (this.$element.find('.next, .prev').length && $.support.transition) {
16145 this.$element.trigger($.support.transition.end)
16149 this.interval = clearInterval(this.interval)
16154 Carousel.prototype.next = function () {
16155 if (this.sliding) return
16156 return this.slide('next')
16159 Carousel.prototype.prev = function () {
16160 if (this.sliding) return
16161 return this.slide('prev')
16164 Carousel.prototype.slide = function (type, next) {
16165 var $active = this.$element.find('.item.active')
16166 var $next = next || $active[type]()
16167 var isCycling = this.interval
16168 var direction = type == 'next' ? 'left' : 'right'
16169 var fallback = type == 'next' ? 'first' : 'last'
16172 if (!$next.length) {
16173 if (!this.options.wrap) return
16174 $next = this.$element.find('.item')[fallback]()
16177 if ($next.hasClass('active')) return (this.sliding = false)
16179 var relatedTarget = $next[
0]
16180 var slideEvent = $.Event('slide.bs.carousel', {
16181 relatedTarget: relatedTarget,
16182 direction: direction
16184 this.$element.trigger(slideEvent)
16185 if (slideEvent.isDefaultPrevented()) return
16187 this.sliding = true
16189 isCycling && this.pause()
16191 if (this.$indicators.length) {
16192 this.$indicators.find('.active').removeClass('active')
16193 var $nextIndicator = $(this.$indicators.children()[this.getItemIndex($next)])
16194 $nextIndicator && $nextIndicator.addClass('active')
16197 var slidEvent = $.Event('slid.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) // yes, "slid"
16198 if ($.support.transition && this.$element.hasClass('slide')) {
16199 $next.addClass(type)
16200 $next[
0].offsetWidth // force reflow
16201 $active.addClass(direction)
16202 $next.addClass(direction)
16204 .one('bsTransitionEnd', function () {
16205 $next.removeClass([type, direction].join(' ')).addClass('active')
16206 $active.removeClass(['active', direction].join(' '))
16207 that.sliding = false
16208 setTimeout(function () {
16209 that.$element.trigger(slidEvent)
16212 .emulateTransitionEnd($active.css('transition-duration').slice(
0, -
1) *
1000)
16214 $active.removeClass('active')
16215 $next.addClass('active')
16216 this.sliding = false
16217 this.$element.trigger(slidEvent)
16220 isCycling && this.cycle()
16226 // CAROUSEL PLUGIN DEFINITION
16227 // ==========================
16229 function Plugin(option) {
16230 return this.each(function () {
16231 var $this = $(this)
16232 var data = $this.data('bs.carousel')
16233 var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option)
16234 var action = typeof option == 'string' ? option : options.slide
16236 if (!data) $this.data('bs.carousel', (data = new Carousel(this, options)))
16237 if (typeof option == 'number') data.to(option)
16238 else if (action) data[action]()
16239 else if (options.interval) data.pause().cycle()
16243 var old = $.fn.carousel
16245 $.fn.carousel = Plugin
16246 $.fn.carousel.Constructor = Carousel
16249 // CAROUSEL NO CONFLICT
16250 // ====================
16252 $.fn.carousel.noConflict = function () {
16253 $.fn.carousel = old
16258 // CAROUSEL DATA-API
16259 // =================
16261 $(document).on('click.bs.carousel.data-api', '[data-slide], [data-slide-to]', function (e) {
16263 var $this = $(this)
16264 var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) // strip for ie7
16265 if (!$target.hasClass('carousel')) return
16266 var options = $.extend({}, $target.data(), $this.data())
16267 var slideIndex = $this.attr('data-slide-to')
16268 if (slideIndex) options.interval = false
16270 Plugin.call($target, options)
16273 $target.data('bs.carousel').to(slideIndex)
16279 $(window).on('load', function () {
16280 $('[
data-ride="carousel"]').each(function () {
16281 var $carousel = $(this)
16282 Plugin.call($carousel, $carousel.data())
16288 /* ========================================================================
16289 * Bootstrap: collapse.js v3.2
.0
16290 * http://getbootstrap.com/javascript/#collapse
16291 * ========================================================================
16292 * Copyright
2011-
2014 Twitter, Inc.
16293 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
16294 * ======================================================================== */
16300 // COLLAPSE PUBLIC CLASS DEFINITION
16301 // ================================
16303 var Collapse = function (element, options) {
16304 this.$element = $(element)
16305 this.options = $.extend({}, Collapse.DEFAULTS, options)
16306 this.transitioning = null
16308 if (this.options.parent) this.$parent = $(this.options.parent)
16309 if (this.options.toggle) this.toggle()
16312 Collapse.VERSION = '
3.2.0'
16314 Collapse.DEFAULTS = {
16318 Collapse.prototype.dimension = function () {
16319 var hasWidth = this.$element.hasClass('width')
16320 return hasWidth ? 'width' : 'height'
16323 Collapse.prototype.show = function () {
16324 if (this.transitioning || this.$element.hasClass('in')) return
16326 var startEvent = $.Event('show.bs.collapse')
16327 this.$element.trigger(startEvent)
16328 if (startEvent.isDefaultPrevented()) return
16330 var actives = this.$parent && this.$parent.find('
> .panel
> .in')
16332 if (actives && actives.length) {
16333 var hasData = actives.data('bs.collapse')
16334 if (hasData && hasData.transitioning) return
16335 Plugin.call(actives, 'hide')
16336 hasData || actives.data('bs.collapse', null)
16339 var dimension = this.dimension()
16342 .removeClass('collapse')
16343 .addClass('collapsing')[dimension](
0)
16345 this.transitioning =
1
16347 var complete = function () {
16349 .removeClass('collapsing')
16350 .addClass('collapse in')[dimension]('')
16351 this.transitioning =
0
16353 .trigger('shown.bs.collapse')
16356 if (!$.support.transition) return complete.call(this)
16358 var scrollSize = $.camelCase(['scroll', dimension].join('-'))
16361 .one('bsTransitionEnd', $.proxy(complete, this))
16362 .emulateTransitionEnd(
350)[dimension](this.$element[
0][scrollSize])
16365 Collapse.prototype.hide = function () {
16366 if (this.transitioning || !this.$element.hasClass('in')) return
16368 var startEvent = $.Event('hide.bs.collapse')
16369 this.$element.trigger(startEvent)
16370 if (startEvent.isDefaultPrevented()) return
16372 var dimension = this.dimension()
16374 this.$element[dimension](this.$element[dimension]())[
0].offsetHeight
16377 .addClass('collapsing')
16378 .removeClass('collapse')
16381 this.transitioning =
1
16383 var complete = function () {
16384 this.transitioning =
0
16386 .trigger('hidden.bs.collapse')
16387 .removeClass('collapsing')
16388 .addClass('collapse')
16391 if (!$.support.transition) return complete.call(this)
16395 .one('bsTransitionEnd', $.proxy(complete, this))
16396 .emulateTransitionEnd(
350)
16399 Collapse.prototype.toggle = function () {
16400 this[this.$element.hasClass('in') ? 'hide' : 'show']()
16404 // COLLAPSE PLUGIN DEFINITION
16405 // ==========================
16407 function Plugin(option) {
16408 return this.each(function () {
16409 var $this = $(this)
16410 var data = $this.data('bs.collapse')
16411 var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option)
16413 if (!data && options.toggle && option == 'show') option = !option
16414 if (!data) $this.data('bs.collapse', (data = new Collapse(this, options)))
16415 if (typeof option == 'string') data[option]()
16419 var old = $.fn.collapse
16421 $.fn.collapse = Plugin
16422 $.fn.collapse.Constructor = Collapse
16425 // COLLAPSE NO CONFLICT
16426 // ====================
16428 $.fn.collapse.noConflict = function () {
16429 $.fn.collapse = old
16434 // COLLAPSE DATA-API
16435 // =================
16437 $(document).on('click.bs.collapse.data-api', '[
data-toggle="collapse"]', function (e) {
16439 var $this = $(this)
16440 var target = $this.attr('data-target')
16441 || e.preventDefault()
16442 || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') // strip for ie7
16443 var $target = $(target)
16444 var data = $target.data('bs.collapse')
16445 var option = data ? 'toggle' : $this.data()
16446 var parent = $this.attr('data-parent')
16447 var $parent = parent && $(parent)
16449 if (!data || !data.transitioning) {
16450 if ($parent) $parent.find('[
data-toggle="collapse"][
data-parent="' + parent + '"]').not($this).addClass('collapsed')
16451 $this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
16454 Plugin.call($target, option)
16459 /* ========================================================================
16460 * Bootstrap: dropdown.js v3.2
.0
16461 * http://getbootstrap.com/javascript/#dropdowns
16462 * ========================================================================
16463 * Copyright
2011-
2014 Twitter, Inc.
16464 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
16465 * ======================================================================== */
16471 // DROPDOWN CLASS DEFINITION
16472 // =========================
16474 var backdrop = '.dropdown-backdrop'
16475 var toggle = '[
data-toggle="dropdown"]'
16476 var Dropdown = function (element) {
16477 $(element).on('click.bs.dropdown', this.toggle)
16480 Dropdown.VERSION = '
3.2.0'
16482 Dropdown.prototype.toggle = function (e) {
16483 var $this = $(this)
16485 if ($this.is('.disabled, :disabled')) return
16487 var $parent = getParent($this)
16488 var isActive = $parent.hasClass('open')
16493 if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {
16494 // if mobile we use a backdrop because click events don't delegate
16495 $('
<div class=
"dropdown-backdrop"/>').insertAfter($(this)).on('click', clearMenus)
16498 var relatedTarget = { relatedTarget: this }
16499 $parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget))
16501 if (e.isDefaultPrevented()) return
16503 $this.trigger('focus')
16506 .toggleClass('open')
16507 .trigger('shown.bs.dropdown', relatedTarget)
16513 Dropdown.prototype.keydown = function (e) {
16514 if (!/(
38|
40|
27)/.test(e.keyCode)) return
16516 var $this = $(this)
16519 e.stopPropagation()
16521 if ($this.is('.disabled, :disabled')) return
16523 var $parent = getParent($this)
16524 var isActive = $parent.hasClass('open')
16526 if (!isActive || (isActive && e.keyCode ==
27)) {
16527 if (e.which ==
27) $parent.find(toggle).trigger('focus')
16528 return $this.trigger('click')
16531 var desc = ' li:not(.divider):visible a'
16532 var $items = $parent.find('[
role="menu"]' + desc + ', [
role="listbox"]' + desc)
16534 if (!$items.length) return
16536 var index = $items.index($items.filter(':focus'))
16538 if (e.keyCode ==
38 && index
> 0) index-- // up
16539 if (e.keyCode ==
40 && index < $items.length -
1) index++ // down
16540 if (!~index) index =
0
16542 $items.eq(index).trigger('focus')
16545 function clearMenus(e) {
16546 if (e && e.which ===
3) return
16547 $(backdrop).remove()
16548 $(toggle).each(function () {
16549 var $parent = getParent($(this))
16550 var relatedTarget = { relatedTarget: this }
16551 if (!$parent.hasClass('open')) return
16552 $parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
16553 if (e.isDefaultPrevented()) return
16554 $parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget)
16558 function getParent($this) {
16559 var selector = $this.attr('data-target')
16562 selector = $this.attr('href')
16563 selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
16566 var $parent = selector && $(selector)
16568 return $parent && $parent.length ? $parent : $this.parent()
16572 // DROPDOWN PLUGIN DEFINITION
16573 // ==========================
16575 function Plugin(option) {
16576 return this.each(function () {
16577 var $this = $(this)
16578 var data = $this.data('bs.dropdown')
16580 if (!data) $this.data('bs.dropdown', (data = new Dropdown(this)))
16581 if (typeof option == 'string') data[option].call($this)
16585 var old = $.fn.dropdown
16587 $.fn.dropdown = Plugin
16588 $.fn.dropdown.Constructor = Dropdown
16591 // DROPDOWN NO CONFLICT
16592 // ====================
16594 $.fn.dropdown.noConflict = function () {
16595 $.fn.dropdown = old
16600 // APPLY TO STANDARD DROPDOWN ELEMENTS
16601 // ===================================
16604 .on('click.bs.dropdown.data-api', clearMenus)
16605 .on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
16606 .on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle)
16607 .on('keydown.bs.dropdown.data-api', toggle + ', [
role=
"menu"], [
role=
"listbox"]', Dropdown.prototype.keydown)
16611 /* ========================================================================
16612 * Bootstrap: modal.js v3.2
.0
16613 * http://getbootstrap.com/javascript/#modals
16614 * ========================================================================
16615 * Copyright
2011-
2014 Twitter, Inc.
16616 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
16617 * ======================================================================== */
16623 // MODAL CLASS DEFINITION
16624 // ======================
16626 var Modal = function (element, options) {
16627 this.options = options
16628 this.$body = $(document.body)
16629 this.$element = $(element)
16631 this.isShown = null
16632 this.scrollbarWidth =
0
16634 if (this.options.remote) {
16636 .find('.modal-content')
16637 .load(this.options.remote, $.proxy(function () {
16638 this.$element.trigger('loaded.bs.modal')
16643 Modal.VERSION = '
3.2.0'
16651 Modal.prototype.toggle = function (_relatedTarget) {
16652 return this.isShown ? this.hide() : this.show(_relatedTarget)
16655 Modal.prototype.show = function (_relatedTarget) {
16657 var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })
16659 this.$element.trigger(e)
16661 if (this.isShown || e.isDefaultPrevented()) return
16663 this.isShown = true
16665 this.checkScrollbar()
16666 this.$body.addClass('modal-open')
16668 this.setScrollbar()
16671 this.$element.on('click.dismiss.bs.modal', '[
data-dismiss=
"modal"]', $.proxy(this.hide, this))
16673 this.backdrop(function () {
16674 var transition = $.support.transition && that.$element.hasClass('fade')
16676 if (!that.$element.parent().length) {
16677 that.$element.appendTo(that.$body) // don't move modals dom position
16685 that.$element[
0].offsetWidth // force reflow
16690 .attr('aria-hidden', false)
16692 that.enforceFocus()
16694 var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget })
16697 that.$element.find('.modal-dialog') // wait for modal to slide in
16698 .one('bsTransitionEnd', function () {
16699 that.$element.trigger('focus').trigger(e)
16701 .emulateTransitionEnd(
300) :
16702 that.$element.trigger('focus').trigger(e)
16706 Modal.prototype.hide = function (e) {
16707 if (e) e.preventDefault()
16709 e = $.Event('hide.bs.modal')
16711 this.$element.trigger(e)
16713 if (!this.isShown || e.isDefaultPrevented()) return
16715 this.isShown = false
16717 this.$body.removeClass('modal-open')
16719 this.resetScrollbar()
16722 $(document).off('focusin.bs.modal')
16726 .attr('aria-hidden', true)
16727 .off('click.dismiss.bs.modal')
16729 $.support.transition && this.$element.hasClass('fade') ?
16731 .one('bsTransitionEnd', $.proxy(this.hideModal, this))
16732 .emulateTransitionEnd(
300) :
16736 Modal.prototype.enforceFocus = function () {
16738 .off('focusin.bs.modal') // guard against infinite focus loop
16739 .on('focusin.bs.modal', $.proxy(function (e) {
16740 if (this.$element[
0] !== e.target && !this.$element.has(e.target).length) {
16741 this.$element.trigger('focus')
16746 Modal.prototype.escape = function () {
16747 if (this.isShown && this.options.keyboard) {
16748 this.$element.on('keyup.dismiss.bs.modal', $.proxy(function (e) {
16749 e.which ==
27 && this.hide()
16751 } else if (!this.isShown) {
16752 this.$element.off('keyup.dismiss.bs.modal')
16756 Modal.prototype.hideModal = function () {
16758 this.$element.hide()
16759 this.backdrop(function () {
16760 that.$element.trigger('hidden.bs.modal')
16764 Modal.prototype.removeBackdrop = function () {
16765 this.$backdrop && this.$backdrop.remove()
16766 this.$backdrop = null
16769 Modal.prototype.backdrop = function (callback) {
16771 var animate = this.$element.hasClass('fade') ? 'fade' : ''
16773 if (this.isShown && this.options.backdrop) {
16774 var doAnimate = $.support.transition && animate
16776 this.$backdrop = $('
<div class=
"modal-backdrop ' + animate + '" />')
16777 .appendTo(this.$body)
16779 this.$element.on('click.dismiss.bs.modal', $.proxy(function (e) {
16780 if (e.target !== e.currentTarget) return
16781 this.options.backdrop == 'static'
16782 ? this.$element[
0].focus.call(this.$element[
0])
16783 : this.hide.call(this)
16786 if (doAnimate) this.$backdrop[
0].offsetWidth // force reflow
16788 this.$backdrop.addClass('in')
16790 if (!callback) return
16794 .one('bsTransitionEnd', callback)
16795 .emulateTransitionEnd(
150) :
16798 } else if (!this.isShown && this.$backdrop) {
16799 this.$backdrop.removeClass('in')
16801 var callbackRemove = function () {
16802 that.removeBackdrop()
16803 callback && callback()
16805 $.support.transition && this.$element.hasClass('fade') ?
16807 .one('bsTransitionEnd', callbackRemove)
16808 .emulateTransitionEnd(
150) :
16811 } else if (callback) {
16816 Modal.prototype.checkScrollbar = function () {
16817 if (document.body.clientWidth
>= window.innerWidth) return
16818 this.scrollbarWidth = this.scrollbarWidth || this.measureScrollbar()
16821 Modal.prototype.setScrollbar = function () {
16822 var bodyPad = parseInt((this.$body.css('padding-right') ||
0),
10)
16823 if (this.scrollbarWidth) this.$body.css('padding-right', bodyPad + this.scrollbarWidth)
16826 Modal.prototype.resetScrollbar = function () {
16827 this.$body.css('padding-right', '')
16830 Modal.prototype.measureScrollbar = function () { // thx walsh
16831 var scrollDiv = document.createElement('div')
16832 scrollDiv.className = 'modal-scrollbar-measure'
16833 this.$body.append(scrollDiv)
16834 var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth
16835 this.$body[
0].removeChild(scrollDiv)
16836 return scrollbarWidth
16840 // MODAL PLUGIN DEFINITION
16841 // =======================
16843 function Plugin(option, _relatedTarget) {
16844 return this.each(function () {
16845 var $this = $(this)
16846 var data = $this.data('bs.modal')
16847 var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)
16849 if (!data) $this.data('bs.modal', (data = new Modal(this, options)))
16850 if (typeof option == 'string') data[option](_relatedTarget)
16851 else if (options.show) data.show(_relatedTarget)
16855 var old = $.fn.modal
16857 $.fn.modal = Plugin
16858 $.fn.modal.Constructor = Modal
16861 // MODAL NO CONFLICT
16862 // =================
16864 $.fn.modal.noConflict = function () {
16873 $(document).on('click.bs.modal.data-api', '[
data-toggle="modal"]', function (e) {
16874 var $this = $(this)
16875 var href = $this.attr('href')
16876 var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) // strip for ie7
16877 var option = $target.data('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
16879 if ($this.is('a')) e.preventDefault()
16881 $target.one('show.bs.modal', function (showEvent) {
16882 if (showEvent.isDefaultPrevented()) return // only register focus restorer if modal will actually get shown
16883 $target.one('hidden.bs.modal', function () {
16884 $this.is(':visible') && $this.trigger('focus')
16887 Plugin.call($target, option, this)
16892 /* ========================================================================
16893 * Bootstrap: tooltip.js v3.2
.0
16894 * http://getbootstrap.com/javascript/#tooltip
16895 * Inspired by the original jQuery.tipsy by Jason Frame
16896 * ========================================================================
16897 * Copyright
2011-
2014 Twitter, Inc.
16898 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
16899 * ======================================================================== */
16905 // TOOLTIP PUBLIC CLASS DEFINITION
16906 // ===============================
16908 var Tooltip = function (element, options) {
16914 this.$element = null
16916 this.init('tooltip', element, options)
16919 Tooltip.VERSION = '
3.2.0'
16921 Tooltip.DEFAULTS = {
16925 template: '
<div class=
"tooltip" role=
"tooltip"><div class=
"tooltip-arrow"></div><div class=
"tooltip-inner"></div></div>',
16926 trigger: 'hover focus',
16937 Tooltip.prototype.init = function (type, element, options) {
16938 this.enabled = true
16940 this.$element = $(element)
16941 this.options = this.getOptions(options)
16942 this.$viewport = this.options.viewport && $(this.options.viewport.selector || this.options.viewport)
16944 var triggers = this.options.trigger.split(' ')
16946 for (var i = triggers.length; i--;) {
16947 var trigger = triggers[i]
16949 if (trigger == 'click') {
16950 this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
16951 } else if (trigger != 'manual') {
16952 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin'
16953 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout'
16955 this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
16956 this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
16960 this.options.selector ?
16961 (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
16965 Tooltip.prototype.getDefaults = function () {
16966 return Tooltip.DEFAULTS
16969 Tooltip.prototype.getOptions = function (options) {
16970 options = $.extend({}, this.getDefaults(), this.$element.data(), options)
16972 if (options.delay && typeof options.delay == 'number') {
16974 show: options.delay,
16975 hide: options.delay
16982 Tooltip.prototype.getDelegateOptions = function () {
16984 var defaults = this.getDefaults()
16986 this._options && $.each(this._options, function (key, value) {
16987 if (defaults[key] != value) options[key] = value
16993 Tooltip.prototype.enter = function (obj) {
16994 var self = obj instanceof this.constructor ?
16995 obj : $(obj.currentTarget).data('bs.' + this.type)
16998 self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
16999 $(obj.currentTarget).data('bs.' + this.type, self)
17002 clearTimeout(self.timeout)
17004 self.hoverState = 'in'
17006 if (!self.options.delay || !self.options.delay.show) return self.show()
17008 self.timeout = setTimeout(function () {
17009 if (self.hoverState == 'in') self.show()
17010 }, self.options.delay.show)
17013 Tooltip.prototype.leave = function (obj) {
17014 var self = obj instanceof this.constructor ?
17015 obj : $(obj.currentTarget).data('bs.' + this.type)
17018 self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
17019 $(obj.currentTarget).data('bs.' + this.type, self)
17022 clearTimeout(self.timeout)
17024 self.hoverState = 'out'
17026 if (!self.options.delay || !self.options.delay.hide) return self.hide()
17028 self.timeout = setTimeout(function () {
17029 if (self.hoverState == 'out') self.hide()
17030 }, self.options.delay.hide)
17033 Tooltip.prototype.show = function () {
17034 var e = $.Event('show.bs.' + this.type)
17036 if (this.hasContent() && this.enabled) {
17037 this.$element.trigger(e)
17039 var inDom = $.contains(document.documentElement, this.$element[
0])
17040 if (e.isDefaultPrevented() || !inDom) return
17043 var $tip = this.tip()
17045 var tipId = this.getUID(this.type)
17048 $tip.attr('id', tipId)
17049 this.$element.attr('aria-describedby', tipId)
17051 if (this.options.animation) $tip.addClass('fade')
17053 var placement = typeof this.options.placement == 'function' ?
17054 this.options.placement.call(this, $tip[
0], this.$element[
0]) :
17055 this.options.placement
17057 var autoToken = /\s?auto?\s?/i
17058 var autoPlace = autoToken.test(placement)
17059 if (autoPlace) placement = placement.replace(autoToken, '') || 'top'
17063 .css({ top:
0, left:
0, display: 'block' })
17064 .addClass(placement)
17065 .data('bs.' + this.type, this)
17067 this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
17069 var pos = this.getPosition()
17070 var actualWidth = $tip[
0].offsetWidth
17071 var actualHeight = $tip[
0].offsetHeight
17074 var orgPlacement = placement
17075 var $parent = this.$element.parent()
17076 var parentDim = this.getPosition($parent)
17078 placement = placement == 'bottom' && pos.top + pos.height + actualHeight - parentDim.scroll
> parentDim.height ? 'top' :
17079 placement == 'top' && pos.top - parentDim.scroll - actualHeight <
0 ? 'bottom' :
17080 placement == 'right' && pos.right + actualWidth
> parentDim.width ? 'left' :
17081 placement == 'left' && pos.left - actualWidth < parentDim.left ? 'right' :
17085 .removeClass(orgPlacement)
17086 .addClass(placement)
17089 var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight)
17091 this.applyPlacement(calculatedOffset, placement)
17093 var complete = function () {
17094 that.$element.trigger('shown.bs.' + that.type)
17095 that.hoverState = null
17098 $.support.transition && this.$tip.hasClass('fade') ?
17100 .one('bsTransitionEnd', complete)
17101 .emulateTransitionEnd(
150) :
17106 Tooltip.prototype.applyPlacement = function (offset, placement) {
17107 var $tip = this.tip()
17108 var width = $tip[
0].offsetWidth
17109 var height = $tip[
0].offsetHeight
17111 // manually read margins because getBoundingClientRect includes difference
17112 var marginTop = parseInt($tip.css('margin-top'),
10)
17113 var marginLeft = parseInt($tip.css('margin-left'),
10)
17115 // we must check for NaN for ie
8/
9
17116 if (isNaN(marginTop)) marginTop =
0
17117 if (isNaN(marginLeft)) marginLeft =
0
17119 offset.top = offset.top + marginTop
17120 offset.left = offset.left + marginLeft
17122 // $.fn.offset doesn't round pixel values
17123 // so we use setOffset directly with our own function B-
0
17124 $.offset.setOffset($tip[
0], $.extend({
17125 using: function (props) {
17127 top: Math.round(props.top),
17128 left: Math.round(props.left)
17133 $tip.addClass('in')
17135 // check to see if placing tip in new offset caused the tip to resize itself
17136 var actualWidth = $tip[
0].offsetWidth
17137 var actualHeight = $tip[
0].offsetHeight
17139 if (placement == 'top' && actualHeight != height) {
17140 offset.top = offset.top + height - actualHeight
17143 var delta = this.getViewportAdjustedDelta(placement, offset, actualWidth, actualHeight)
17145 if (delta.left) offset.left += delta.left
17146 else offset.top += delta.top
17148 var arrowDelta = delta.left ? delta.left *
2 - width + actualWidth : delta.top *
2 - height + actualHeight
17149 var arrowPosition = delta.left ? 'left' : 'top'
17150 var arrowOffsetPosition = delta.left ? 'offsetWidth' : 'offsetHeight'
17152 $tip.offset(offset)
17153 this.replaceArrow(arrowDelta, $tip[
0][arrowOffsetPosition], arrowPosition)
17156 Tooltip.prototype.replaceArrow = function (delta, dimension, position) {
17157 this.arrow().css(position, delta ? (
50 * (
1 - delta / dimension) + '%') : '')
17160 Tooltip.prototype.setContent = function () {
17161 var $tip = this.tip()
17162 var title = this.getTitle()
17164 $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
17165 $tip.removeClass('fade in top bottom left right')
17168 Tooltip.prototype.hide = function () {
17170 var $tip = this.tip()
17171 var e = $.Event('hide.bs.' + this.type)
17173 this.$element.removeAttr('aria-describedby')
17175 function complete() {
17176 if (that.hoverState != 'in') $tip.detach()
17177 that.$element.trigger('hidden.bs.' + that.type)
17180 this.$element.trigger(e)
17182 if (e.isDefaultPrevented()) return
17184 $tip.removeClass('in')
17186 $.support.transition && this.$tip.hasClass('fade') ?
17188 .one('bsTransitionEnd', complete)
17189 .emulateTransitionEnd(
150) :
17192 this.hoverState = null
17197 Tooltip.prototype.fixTitle = function () {
17198 var $e = this.$element
17199 if ($e.attr('title') || typeof ($e.attr('data-original-title')) != 'string') {
17200 $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
17204 Tooltip.prototype.hasContent = function () {
17205 return this.getTitle()
17208 Tooltip.prototype.getPosition = function ($element) {
17209 $element = $element || this.$element
17210 var el = $element[
0]
17211 var isBody = el.tagName == 'BODY'
17212 return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : null, {
17213 scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop(),
17214 width: isBody ? $(window).width() : $element.outerWidth(),
17215 height: isBody ? $(window).height() : $element.outerHeight()
17216 }, isBody ? { top:
0, left:
0 } : $element.offset())
17219 Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {
17220 return placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width /
2 - actualWidth /
2 } :
17221 placement == 'top' ? { top: pos.top - actualHeight, left: pos.left + pos.width /
2 - actualWidth /
2 } :
17222 placement == 'left' ? { top: pos.top + pos.height /
2 - actualHeight /
2, left: pos.left - actualWidth } :
17223 /* placement == 'right' */ { top: pos.top + pos.height /
2 - actualHeight /
2, left: pos.left + pos.width }
17227 Tooltip.prototype.getViewportAdjustedDelta = function (placement, pos, actualWidth, actualHeight) {
17228 var delta = { top:
0, left:
0 }
17229 if (!this.$viewport) return delta
17231 var viewportPadding = this.options.viewport && this.options.viewport.padding ||
0
17232 var viewportDimensions = this.getPosition(this.$viewport)
17234 if (/right|left/.test(placement)) {
17235 var topEdgeOffset = pos.top - viewportPadding - viewportDimensions.scroll
17236 var bottomEdgeOffset = pos.top + viewportPadding - viewportDimensions.scroll + actualHeight
17237 if (topEdgeOffset < viewportDimensions.top) { // top overflow
17238 delta.top = viewportDimensions.top - topEdgeOffset
17239 } else if (bottomEdgeOffset
> viewportDimensions.top + viewportDimensions.height) { // bottom overflow
17240 delta.top = viewportDimensions.top + viewportDimensions.height - bottomEdgeOffset
17243 var leftEdgeOffset = pos.left - viewportPadding
17244 var rightEdgeOffset = pos.left + viewportPadding + actualWidth
17245 if (leftEdgeOffset < viewportDimensions.left) { // left overflow
17246 delta.left = viewportDimensions.left - leftEdgeOffset
17247 } else if (rightEdgeOffset
> viewportDimensions.width) { // right overflow
17248 delta.left = viewportDimensions.left + viewportDimensions.width - rightEdgeOffset
17255 Tooltip.prototype.getTitle = function () {
17257 var $e = this.$element
17258 var o = this.options
17260 title = $e.attr('data-original-title')
17261 || (typeof o.title == 'function' ? o.title.call($e[
0]) : o.title)
17266 Tooltip.prototype.getUID = function (prefix) {
17267 do prefix += ~~(Math.random() *
1000000)
17268 while (document.getElementById(prefix))
17272 Tooltip.prototype.tip = function () {
17273 return (this.$tip = this.$tip || $(this.options.template))
17276 Tooltip.prototype.arrow = function () {
17277 return (this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow'))
17280 Tooltip.prototype.validate = function () {
17281 if (!this.$element[
0].parentNode) {
17283 this.$element = null
17284 this.options = null
17288 Tooltip.prototype.enable = function () {
17289 this.enabled = true
17292 Tooltip.prototype.disable = function () {
17293 this.enabled = false
17296 Tooltip.prototype.toggleEnabled = function () {
17297 this.enabled = !this.enabled
17300 Tooltip.prototype.toggle = function (e) {
17303 self = $(e.currentTarget).data('bs.' + this.type)
17305 self = new this.constructor(e.currentTarget, this.getDelegateOptions())
17306 $(e.currentTarget).data('bs.' + this.type, self)
17310 self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
17313 Tooltip.prototype.destroy = function () {
17314 clearTimeout(this.timeout)
17315 this.hide().$element.off('.' + this.type).removeData('bs.' + this.type)
17319 // TOOLTIP PLUGIN DEFINITION
17320 // =========================
17322 function Plugin(option) {
17323 return this.each(function () {
17324 var $this = $(this)
17325 var data = $this.data('bs.tooltip')
17326 var options = typeof option == 'object' && option
17328 if (!data && option == 'destroy') return
17329 if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
17330 if (typeof option == 'string') data[option]()
17334 var old = $.fn.tooltip
17336 $.fn.tooltip = Plugin
17337 $.fn.tooltip.Constructor = Tooltip
17340 // TOOLTIP NO CONFLICT
17341 // ===================
17343 $.fn.tooltip.noConflict = function () {
17350 /* ========================================================================
17351 * Bootstrap: popover.js v3.2
.0
17352 * http://getbootstrap.com/javascript/#popovers
17353 * ========================================================================
17354 * Copyright
2011-
2014 Twitter, Inc.
17355 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
17356 * ======================================================================== */
17362 // POPOVER PUBLIC CLASS DEFINITION
17363 // ===============================
17365 var Popover = function (element, options) {
17366 this.init('popover', element, options)
17369 if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js')
17371 Popover.VERSION = '
3.2.0'
17373 Popover.DEFAULTS = $.extend({}, $.fn.tooltip.Constructor.DEFAULTS, {
17374 placement: 'right',
17377 template: '
<div class=
"popover" role=
"tooltip"><div class=
"arrow"></div><h3 class=
"popover-title"></h3><div class=
"popover-content"></div></div>'
17381 // NOTE: POPOVER EXTENDS tooltip.js
17382 // ================================
17384 Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype)
17386 Popover.prototype.constructor = Popover
17388 Popover.prototype.getDefaults = function () {
17389 return Popover.DEFAULTS
17392 Popover.prototype.setContent = function () {
17393 var $tip = this.tip()
17394 var title = this.getTitle()
17395 var content = this.getContent()
17397 $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
17398 $tip.find('.popover-content').empty()[ // we use append for html objects to maintain js events
17399 this.options.html ? (typeof content == 'string' ? 'html' : 'append') : 'text'
17402 $tip.removeClass('fade top bottom left right in')
17404 // IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do
17405 // this manually by checking the contents.
17406 if (!$tip.find('.popover-title').html()) $tip.find('.popover-title').hide()
17409 Popover.prototype.hasContent = function () {
17410 return this.getTitle() || this.getContent()
17413 Popover.prototype.getContent = function () {
17414 var $e = this.$element
17415 var o = this.options
17417 return $e.attr('data-content')
17418 || (typeof o.content == 'function' ?
17419 o.content.call($e[
0]) :
17423 Popover.prototype.arrow = function () {
17424 return (this.$arrow = this.$arrow || this.tip().find('.arrow'))
17427 Popover.prototype.tip = function () {
17428 if (!this.$tip) this.$tip = $(this.options.template)
17433 // POPOVER PLUGIN DEFINITION
17434 // =========================
17436 function Plugin(option) {
17437 return this.each(function () {
17438 var $this = $(this)
17439 var data = $this.data('bs.popover')
17440 var options = typeof option == 'object' && option
17442 if (!data && option == 'destroy') return
17443 if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
17444 if (typeof option == 'string') data[option]()
17448 var old = $.fn.popover
17450 $.fn.popover = Plugin
17451 $.fn.popover.Constructor = Popover
17454 // POPOVER NO CONFLICT
17455 // ===================
17457 $.fn.popover.noConflict = function () {
17464 /* ========================================================================
17465 * Bootstrap: scrollspy.js v3.2
.0
17466 * http://getbootstrap.com/javascript/#scrollspy
17467 * ========================================================================
17468 * Copyright
2011-
2014 Twitter, Inc.
17469 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
17470 * ======================================================================== */
17476 // SCROLLSPY CLASS DEFINITION
17477 // ==========================
17479 function ScrollSpy(element, options) {
17480 var process = $.proxy(this.process, this)
17482 this.$body = $('body')
17483 this.$scrollElement = $(element).is('body') ? $(window) : $(element)
17484 this.options = $.extend({}, ScrollSpy.DEFAULTS, options)
17485 this.selector = (this.options.target || '') + ' .nav li
> a'
17488 this.activeTarget = null
17489 this.scrollHeight =
0
17491 this.$scrollElement.on('scroll.bs.scrollspy', process)
17496 ScrollSpy.VERSION = '
3.2.0'
17498 ScrollSpy.DEFAULTS = {
17502 ScrollSpy.prototype.getScrollHeight = function () {
17503 return this.$scrollElement[
0].scrollHeight || Math.max(this.$body[
0].scrollHeight, document.documentElement.scrollHeight)
17506 ScrollSpy.prototype.refresh = function () {
17507 var offsetMethod = 'offset'
17510 if (!$.isWindow(this.$scrollElement[
0])) {
17511 offsetMethod = 'position'
17512 offsetBase = this.$scrollElement.scrollTop()
17517 this.scrollHeight = this.getScrollHeight()
17522 .find(this.selector)
17525 var href = $el.data('target') || $el.attr('href')
17526 var $href = /^#./.test(href) && $(href)
17530 && $href.is(':visible')
17531 && [[$href[offsetMethod]().top + offsetBase, href]]) || null
17533 .sort(function (a, b) { return a[
0] - b[
0] })
17534 .each(function () {
17535 self.offsets.push(this[
0])
17536 self.targets.push(this[
1])
17540 ScrollSpy.prototype.process = function () {
17541 var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
17542 var scrollHeight = this.getScrollHeight()
17543 var maxScroll = this.options.offset + scrollHeight - this.$scrollElement.height()
17544 var offsets = this.offsets
17545 var targets = this.targets
17546 var activeTarget = this.activeTarget
17549 if (this.scrollHeight != scrollHeight) {
17553 if (scrollTop
>= maxScroll) {
17554 return activeTarget != (i = targets[targets.length -
1]) && this.activate(i)
17557 if (activeTarget && scrollTop <= offsets[
0]) {
17558 return activeTarget != (i = targets[
0]) && this.activate(i)
17561 for (i = offsets.length; i--;) {
17562 activeTarget != targets[i]
17563 && scrollTop
>= offsets[i]
17564 && (!offsets[i +
1] || scrollTop <= offsets[i +
1])
17565 && this.activate(targets[i])
17569 ScrollSpy.prototype.activate = function (target) {
17570 this.activeTarget = target
17573 .parentsUntil(this.options.target, '.active')
17574 .removeClass('active')
17576 var selector = this.selector +
17577 '[
data-target="' + target + '"],' +
17578 this.selector + '[
href="' + target + '"]'
17580 var active = $(selector)
17582 .addClass('active')
17584 if (active.parent('.dropdown-menu').length) {
17586 .closest('li.dropdown')
17587 .addClass('active')
17590 active.trigger('activate.bs.scrollspy')
17594 // SCROLLSPY PLUGIN DEFINITION
17595 // ===========================
17597 function Plugin(option) {
17598 return this.each(function () {
17599 var $this = $(this)
17600 var data = $this.data('bs.scrollspy')
17601 var options = typeof option == 'object' && option
17603 if (!data) $this.data('bs.scrollspy', (data = new ScrollSpy(this, options)))
17604 if (typeof option == 'string') data[option]()
17608 var old = $.fn.scrollspy
17610 $.fn.scrollspy = Plugin
17611 $.fn.scrollspy.Constructor = ScrollSpy
17614 // SCROLLSPY NO CONFLICT
17615 // =====================
17617 $.fn.scrollspy.noConflict = function () {
17618 $.fn.scrollspy = old
17623 // SCROLLSPY DATA-API
17624 // ==================
17626 $(window).on('load.bs.scrollspy.data-api', function () {
17627 $('[
data-spy="scroll"]').each(function () {
17629 Plugin.call($spy, $spy.data())
17635 /* ========================================================================
17636 * Bootstrap: tab.js v3.2
.0
17637 * http://getbootstrap.com/javascript/#tabs
17638 * ========================================================================
17639 * Copyright
2011-
2014 Twitter, Inc.
17640 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
17641 * ======================================================================== */
17647 // TAB CLASS DEFINITION
17648 // ====================
17650 var Tab = function (element) {
17651 this.element = $(element)
17654 Tab.VERSION = '
3.2.0'
17656 Tab.prototype.show = function () {
17657 var $this = this.element
17658 var $ul = $this.closest('ul:not(.dropdown-menu)')
17659 var selector = $this.data('target')
17662 selector = $this.attr('href')
17663 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
17666 if ($this.parent('li').hasClass('active')) return
17668 var previous = $ul.find('.active:last a')[
0]
17669 var e = $.Event('show.bs.tab', {
17670 relatedTarget: previous
17675 if (e.isDefaultPrevented()) return
17677 var $target = $(selector)
17679 this.activate($this.closest('li'), $ul)
17680 this.activate($target, $target.parent(), function () {
17682 type: 'shown.bs.tab',
17683 relatedTarget: previous
17688 Tab.prototype.activate = function (element, container, callback) {
17689 var $active = container.find('
> .active')
17690 var transition = callback
17691 && $.support.transition
17692 && $active.hasClass('fade')
17696 .removeClass('active')
17697 .find('
> .dropdown-menu
> .active')
17698 .removeClass('active')
17700 element.addClass('active')
17703 element[
0].offsetWidth // reflow for transition
17704 element.addClass('in')
17706 element.removeClass('fade')
17709 if (element.parent('.dropdown-menu')) {
17710 element.closest('li.dropdown').addClass('active')
17713 callback && callback()
17718 .one('bsTransitionEnd', next)
17719 .emulateTransitionEnd(
150) :
17722 $active.removeClass('in')
17726 // TAB PLUGIN DEFINITION
17727 // =====================
17729 function Plugin(option) {
17730 return this.each(function () {
17731 var $this = $(this)
17732 var data = $this.data('bs.tab')
17734 if (!data) $this.data('bs.tab', (data = new Tab(this)))
17735 if (typeof option == 'string') data[option]()
17742 $.fn.tab.Constructor = Tab
17748 $.fn.tab.noConflict = function () {
17757 $(document).on('click.bs.tab.data-api', '[
data-toggle="tab"], [
data-toggle="pill"]', function (e) {
17759 Plugin.call($(this), 'show')
17764 /* ========================================================================
17765 * Bootstrap: affix.js v3.2
.0
17766 * http://getbootstrap.com/javascript/#affix
17767 * ========================================================================
17768 * Copyright
2011-
2014 Twitter, Inc.
17769 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
17770 * ======================================================================== */
17776 // AFFIX CLASS DEFINITION
17777 // ======================
17779 var Affix = function (element, options) {
17780 this.options = $.extend({}, Affix.DEFAULTS, options)
17782 this.$target = $(this.options.target)
17783 .on('scroll.bs.affix.data-api', $.proxy(this.checkPosition, this))
17784 .on('click.bs.affix.data-api', $.proxy(this.checkPositionWithEventLoop, this))
17786 this.$element = $(element)
17789 this.pinnedOffset = null
17791 this.checkPosition()
17794 Affix.VERSION = '
3.2.0'
17796 Affix.RESET = 'affix affix-top affix-bottom'
17803 Affix.prototype.getPinnedOffset = function () {
17804 if (this.pinnedOffset) return this.pinnedOffset
17805 this.$element.removeClass(Affix.RESET).addClass('affix')
17806 var scrollTop = this.$target.scrollTop()
17807 var position = this.$element.offset()
17808 return (this.pinnedOffset = position.top - scrollTop)
17811 Affix.prototype.checkPositionWithEventLoop = function () {
17812 setTimeout($.proxy(this.checkPosition, this),
1)
17815 Affix.prototype.checkPosition = function () {
17816 if (!this.$element.is(':visible')) return
17818 var scrollHeight = $(document).height()
17819 var scrollTop = this.$target.scrollTop()
17820 var position = this.$element.offset()
17821 var offset = this.options.offset
17822 var offsetTop = offset.top
17823 var offsetBottom = offset.bottom
17825 if (typeof offset != 'object') offsetBottom = offsetTop = offset
17826 if (typeof offsetTop == 'function') offsetTop = offset.top(this.$element)
17827 if (typeof offsetBottom == 'function') offsetBottom = offset.bottom(this.$element)
17829 var affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ? false :
17830 offsetBottom != null && (position.top + this.$element.height()
>= scrollHeight - offsetBottom) ? 'bottom' :
17831 offsetTop != null && (scrollTop <= offsetTop) ? 'top' : false
17833 if (this.affixed === affix) return
17834 if (this.unpin != null) this.$element.css('top', '')
17836 var affixType = 'affix' + (affix ? '-' + affix : '')
17837 var e = $.Event(affixType + '.bs.affix')
17839 this.$element.trigger(e)
17841 if (e.isDefaultPrevented()) return
17843 this.affixed = affix
17844 this.unpin = affix == 'bottom' ? this.getPinnedOffset() : null
17847 .removeClass(Affix.RESET)
17848 .addClass(affixType)
17849 .trigger($.Event(affixType.replace('affix', 'affixed')))
17851 if (affix == 'bottom') {
17852 this.$element.offset({
17853 top: scrollHeight - this.$element.height() - offsetBottom
17859 // AFFIX PLUGIN DEFINITION
17860 // =======================
17862 function Plugin(option) {
17863 return this.each(function () {
17864 var $this = $(this)
17865 var data = $this.data('bs.affix')
17866 var options = typeof option == 'object' && option
17868 if (!data) $this.data('bs.affix', (data = new Affix(this, options)))
17869 if (typeof option == 'string') data[option]()
17873 var old = $.fn.affix
17875 $.fn.affix = Plugin
17876 $.fn.affix.Constructor = Affix
17879 // AFFIX NO CONFLICT
17880 // =================
17882 $.fn.affix.noConflict = function () {
17891 $(window).on('load', function () {
17892 $('[
data-spy="affix"]').each(function () {
17894 var data = $spy.data()
17896 data.offset = data.offset || {}
17898 if (data.offsetBottom) data.offset.bottom = data.offsetBottom
17899 if (data.offsetTop) data.offset.top = data.offsetTop
17901 Plugin.call($spy, data)
17908 (function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.Bitcoin=e()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&
&require;if(!u&&a)return a(o,!
0);if(i)return i(o,!
0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][
0].call(f.exports,function(e){var n=t[o][
1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&
&require;for(var o=
0;o
<r.length;o++)s(r[o]);return s})({
1:[function(_dereq_,module,exports){
17909 var assert = _dereq_('assert')
17911 module.exports = BigInteger
17913 // JavaScript engine analysis
17914 var canary =
0xdeadbeefcafe;
17915 var j_lm = ((canary&
0xffffff)==
0xefcafe);
17917 // (public) Constructor
17918 function BigInteger(a,b,c) {
17919 if (!(this instanceof BigInteger)) {
17920 return new BigInteger(a, b, c);
17924 if(
"number" == typeof a) this.fromNumber(a,b,c);
17925 else if(b == null &&
"string" != typeof a) this.fromString(a,
256);
17926 else this.fromString(a,b);
17930 var proto = BigInteger.prototype;
17932 // return new, unset BigInteger
17933 function nbi() { return new BigInteger(null); }
17938 // am: Compute w_j += (x*this_i), propagate carries,
17939 // c is initial carry, returns final carry.
17940 // c <
3*dvalue, x <
2*dvalue, this_i < dvalue
17941 // We need to select the fastest one that works in this environment.
17943 // am1: use a single mult and divide to get the high bits,
17944 // max digit bits should be
26 because
17945 // max internal value =
2*dvalue^
2-
2*dvalue (<
2^
53)
17946 function am1(i,x,w,j,c,n) {
17948 var v = x*this[i++]+w[j]+c;
17949 c = Math.floor(v/
0x4000000);
17950 w[j++] = v
&0x3ffffff;
17954 // am2 avoids a big mult-and-extract completely.
17955 // Max digit bits should be <=
30 because we do bitwise ops
17956 // on values up to
2*hdvalue^
2-hdvalue-
1 (<
2^
31)
17957 function am2(i,x,w,j,c,n) {
17958 var xl = x&
0x7fff, xh = x
>>15;
17960 var l = this[i]
&0x7fff;
17961 var h = this[i++]
>>15;
17963 l = xl*l+((m&
0x7fff)<
<15)+w[j]+(c&
0x3fffffff);
17964 c = (l
>>>30)+(m
>>>15)+xh*h+(c
>>>30);
17965 w[j++] = l
&0x3fffffff;
17969 // Alternately, set max digit bits to
28 since some
17970 // browsers slow down when dealing with
32-bit numbers.
17971 function am3(i,x,w,j,c,n) {
17972 var xl = x&
0x3fff, xh = x
>>14;
17974 var l = this[i]
&0x3fff;
17975 var h = this[i++]
>>14;
17977 l = xl*l+((m&
0x3fff)<
<14)+w[j]+c;
17978 c = (l
>>28)+(m
>>14)+xh*h;
17979 w[j++] = l
&0xfffffff;
17985 BigInteger.prototype.am = am1;
17989 if(j_lm && (navigator.appName ==
"Microsoft Internet Explorer")) {
17990 BigInteger.prototype.am = am2;
17993 else if(j_lm && (navigator.appName !=
"Netscape")) {
17994 BigInteger.prototype.am = am1;
17997 else { // Mozilla/Netscape seems to prefer am3
17998 BigInteger.prototype.am = am3;
18003 BigInteger.prototype.DB = dbits;
18004 BigInteger.prototype.DM = ((
1<
<dbits)-
1);
18005 var DV = BigInteger.prototype.DV = (
1<
<dbits);
18008 BigInteger.prototype.FV = Math.pow(
2,BI_FP);
18009 BigInteger.prototype.F1 = BI_FP-dbits;
18010 BigInteger.prototype.F2 =
2*dbits-BI_FP;
18012 // Digit conversions
18013 var BI_RM =
"0123456789abcdefghijklmnopqrstuvwxyz";
18014 var BI_RC = new Array();
18016 rr =
"0".charCodeAt(
0);
18017 for(vv =
0; vv <=
9; ++vv) BI_RC[rr++] = vv;
18018 rr =
"a".charCodeAt(
0);
18019 for(vv =
10; vv <
36; ++vv) BI_RC[rr++] = vv;
18020 rr =
"A".charCodeAt(
0);
18021 for(vv =
10; vv <
36; ++vv) BI_RC[rr++] = vv;
18023 function int2char(n) { return BI_RM.charAt(n); }
18024 function intAt(s,i) {
18025 var c = BI_RC[s.charCodeAt(i)];
18026 return (c==null)?-
1:c;
18029 // (protected) copy this to r
18030 function bnpCopyTo(r) {
18031 for(var i = this.t-
1; i
>=
0; --i) r[i] = this[i];
18036 // (protected) set from integer value x, -DV <= x < DV
18037 function bnpFromInt(x) {
18039 this.s = (x
<0)?-
1:
0;
18040 if(x
> 0) this[
0] = x;
18041 else if(x < -
1) this[
0] = x+DV;
18045 // return bigint initialized to value
18046 function nbv(i) { var r = nbi(); r.fromInt(i); return r; }
18048 // (protected) set from string and radix
18049 function bnpFromString(s,b) {
18054 else if(b ==
8) k =
3;
18055 else if(b ==
256) k =
8; // byte array
18056 else if(b ==
2) k =
1;
18057 else if(b ==
32) k =
5;
18058 else if(b ==
4) k =
2;
18059 else { self.fromRadix(s,b); return; }
18062 var i = s.length, mi = false, sh =
0;
18064 var x = (k==
8)?s[i]&
0xff:intAt(s,i);
18066 if(s.charAt(i) == "-") mi = true;
18071 self[self.t++] = x;
18072 else if(sh+k
> self.DB) {
18073 self[self.t-
1] |= (x&((
1<<(self.DB-sh))-
1))<
<sh;
18074 self[self.t++] = (x
>>(self.DB-sh));
18077 self[self.t-
1] |= x<
<sh;
18079 if(sh
>= self.DB) sh -= self.DB;
18081 if(k ==
8 && (s[
0]&
0x80) !=
0) {
18083 if(sh
> 0) self[self.t-
1] |= ((
1<<(self.DB-sh))-
1)<
<sh;
18086 if(mi) BigInteger.ZERO.subTo(self,self);
18089 // (protected) clamp off excess high words
18090 function bnpClamp() {
18091 var c = this.s&this.DM;
18092 while(this.t
> 0 && this[this.t-
1] == c) --this.t;
18095 // (public) return string representation in given radix
18096 function bnToString(b) {
18098 if(self.s <
0) return
"-"+self.negate().toString(b);
18101 else if(b ==
8) k =
3;
18102 else if(b ==
2) k =
1;
18103 else if(b ==
32) k =
5;
18104 else if(b ==
4) k =
2;
18105 else return self.toRadix(b);
18106 var km = (
1<
<k)-
1, d, m = false, r =
"", i = self.t;
18107 var p = self.DB-(i*self.DB)%k;
18109 if(p < self.DB && (d = self[i]
>>p)
> 0) { m = true; r = int2char(d); }
18112 d = (self[i]&((
1<
<p)-
1))<<(k-p);
18113 d |= self[--i]
>>(p+=self.DB-k);
18116 d = (self[i]
>>(p-=k))
&km;
18117 if(p <=
0) { p += self.DB; --i; }
18119 if(d
> 0) m = true;
18120 if(m) r += int2char(d);
18127 function bnNegate() { var r = nbi(); BigInteger.ZERO.subTo(this,r); return r; }
18130 function bnAbs() { return (this.s
<0)?this.negate():this; }
18132 // (public) return + if this
> a, - if this < a,
0 if equal
18133 function bnCompareTo(a) {
18134 var r = this.s-a.s;
18135 if(r !=
0) return r;
18138 if(r !=
0) return (this.s
<0)?-r:r;
18139 while(--i
>=
0) if((r=this[i]-a[i]) !=
0) return r;
18143 // returns bit length of the integer x
18144 function nbits(x) {
18146 if((t=x
>>>16) !=
0) { x = t; r +=
16; }
18147 if((t=x
>>8) !=
0) { x = t; r +=
8; }
18148 if((t=x
>>4) !=
0) { x = t; r +=
4; }
18149 if((t=x
>>2) !=
0) { x = t; r +=
2; }
18150 if((t=x
>>1) !=
0) { x = t; r +=
1; }
18154 // (public) return the number of bits in
"this"
18155 function bnBitLength() {
18156 if(this.t <=
0) return
0;
18157 return this.DB*(this.t-
1)+nbits(this[this.t-
1]^(this.s&this.DM));
18160 // (protected) r = this << n*DB
18161 function bnpDLShiftTo(n,r) {
18163 for(i = this.t-
1; i
>=
0; --i) r[i+n] = this[i];
18164 for(i = n-
1; i
>=
0; --i) r[i] =
0;
18169 // (protected) r = this
>> n*DB
18170 function bnpDRShiftTo(n,r) {
18171 for(var i = n; i < this.t; ++i) r[i-n] = this[i];
18172 r.t = Math.max(this.t-n,
0);
18176 // (protected) r = this << n
18177 function bnpLShiftTo(n,r) {
18179 var bs = n%self.DB;
18180 var cbs = self.DB-bs;
18181 var bm = (
1<
<cbs)-
1;
18182 var ds = Math.floor(n/self.DB), c = (self.s<
<bs)&self.DM, i;
18183 for(i = self.t-
1; i
>=
0; --i) {
18184 r[i+ds+
1] = (self[i]
>>cbs)|c;
18185 c = (self[i]&bm)<
<bs;
18187 for(i = ds-
1; i
>=
0; --i) r[i] =
0;
18194 // (protected) r = this
>> n
18195 function bnpRShiftTo(n,r) {
18198 var ds = Math.floor(n/self.DB);
18199 if(ds
>= self.t) { r.t =
0; return; }
18200 var bs = n%self.DB;
18201 var cbs = self.DB-bs;
18202 var bm = (
1<
<bs)-
1;
18203 r[
0] = self[ds]
>>bs;
18204 for(var i = ds+
1; i < self.t; ++i) {
18205 r[i-ds-
1] |= (self[i]&bm)<
<cbs;
18206 r[i-ds] = self[i]
>>bs;
18208 if(bs
> 0) r[self.t-ds-
1] |= (self.s&bm)<
<cbs;
18213 // (protected) r = this - a
18214 function bnpSubTo(a,r) {
18216 var i =
0, c =
0, m = Math.min(a.t,self.t);
18219 r[i++] = c&self.DM;
18224 while(i < self.t) {
18226 r[i++] = c&self.DM;
18235 r[i++] = c&self.DM;
18241 if(c < -
1) r[i++] = self.DV+c;
18242 else if(c
> 0) r[i++] = c;
18247 // (protected) r = this * a, r != this,a (HAC
14.12)
18248 //
"this" should be the larger one if appropriate.
18249 function bnpMultiplyTo(a,r) {
18250 var x = this.abs(), y = a.abs();
18253 while(--i
>=
0) r[i] =
0;
18254 for(i =
0; i < y.t; ++i) r[i+x.t] = x.am(
0,y[i],r,i,
0,x.t);
18257 if(this.s != a.s) BigInteger.ZERO.subTo(r,r);
18260 // (protected) r = this^
2, r != this (HAC
14.16)
18261 function bnpSquareTo(r) {
18262 var x = this.abs();
18263 var i = r.t =
2*x.t;
18264 while(--i
>=
0) r[i] =
0;
18265 for(i =
0; i < x.t-
1; ++i) {
18266 var c = x.am(i,x[i],r,
2*i,
0,
1);
18267 if((r[i+x.t]+=x.am(i+
1,
2*x[i],r,
2*i+
1,c,x.t-i-
1))
>= x.DV) {
18272 if(r.t
> 0) r[r.t-
1] += x.am(i,x[i],r,
2*i,
0,
1);
18277 // (protected) divide this by m, quotient and remainder to q, r (HAC
14.20)
18278 // r != q, this != m. q or r may be null.
18279 function bnpDivRemTo(m,q,r) {
18282 if(pm.t <=
0) return;
18283 var pt = self.abs();
18285 if(q != null) q.fromInt(
0);
18286 if(r != null) self.copyTo(r);
18289 if(r == null) r = nbi();
18290 var y = nbi(), ts = self.s, ms = m.s;
18291 var nsh = self.DB-nbits(pm[pm.t-
1]); // normalize modulus
18292 if(nsh
> 0) { pm.lShiftTo(nsh,y); pt.lShiftTo(nsh,r); }
18293 else { pm.copyTo(y); pt.copyTo(r); }
18296 if(y0 ==
0) return;
18297 var yt = y0*(
1<
<self.F1)+((ys
>1)?y[ys-
2]
>>self.F2:
0);
18298 var d1 = self.FV/yt, d2 = (
1<
<self.F1)/yt, e =
1<
<self.F2;
18299 var i = r.t, j = i-ys, t = (q==null)?nbi():q;
18301 if(r.compareTo(t)
>=
0) {
18305 BigInteger.ONE.dlShiftTo(ys,t);
18306 t.subTo(y,y); // "negative" y so we can replace sub with am later
18307 while(y.t < ys) y[y.t++] =
0;
18309 // Estimate quotient digit
18310 var qd = (r[--i]==y0)?self.DM:Math.floor(r[i]*d1+(r[i-
1]+e)*d2);
18311 if((r[i]+=y.am(
0,qd,r,j,
0,ys)) < qd) { // Try it out
18314 while(r[i] < --qd) r.subTo(t,r);
18319 if(ts != ms) BigInteger.ZERO.subTo(q,q);
18323 if(nsh
> 0) r.rShiftTo(nsh,r); // Denormalize remainder
18324 if(ts <
0) BigInteger.ZERO.subTo(r,r);
18327 // (public) this mod a
18328 function bnMod(a) {
18330 this.abs().divRemTo(a,null,r);
18331 if(this.s <
0 && r.compareTo(BigInteger.ZERO)
> 0) a.subTo(r,r);
18335 // Modular reduction using
"classic" algorithm
18336 function Classic(m) { this.m = m; }
18337 function cConvert(x) {
18338 if(x.s <
0 || x.compareTo(this.m)
>=
0) return x.mod(this.m);
18341 function cRevert(x) { return x; }
18342 function cReduce(x) { x.divRemTo(this.m,null,x); }
18343 function cMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
18344 function cSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
18346 Classic.prototype.convert = cConvert;
18347 Classic.prototype.revert = cRevert;
18348 Classic.prototype.reduce = cReduce;
18349 Classic.prototype.mulTo = cMulTo;
18350 Classic.prototype.sqrTo = cSqrTo;
18352 // (protected) return "-
1/this %
2^DB"; useful for Mont. reduction
18356 // xy(
2-xy) = (
1+km)(
1-km)
18357 // x[y(
2-xy)] =
1-k^
2m^
2
18358 // x[y(
2-xy)] ==
1 (mod m^
2)
18359 // if y is
1/x mod m, then y(
2-xy) is
1/x mod m^
2
18360 // should reduce x and y(
2-xy) by m^
2 at each step to keep size bounded.
18361 // JS multiply "overflows" differently from C/C++, so care is needed here.
18362 function bnpInvDigit() {
18363 if(this.t <
1) return
0;
18365 if((x&
1) ==
0) return
0;
18366 var y = x
&3; // y ==
1/x mod
2^
2
18367 y = (y*(
2-(x&
0xf)*y))
&0xf; // y ==
1/x mod
2^
4
18368 y = (y*(
2-(x&
0xff)*y))
&0xff; // y ==
1/x mod
2^
8
18369 y = (y*(
2-(((x&
0xffff)*y)&
0xffff)))
&0xffff; // y ==
1/x mod
2^
16
18370 // last step - calculate inverse mod DV directly;
18371 // assumes
16 < DB <=
32 and assumes ability to handle
48-bit ints
18372 y = (y*(
2-x*y%this.DV))%this.DV; // y ==
1/x mod
2^dbits
18373 // we really want the negative inverse, and -DV < y < DV
18374 return (y
>0)?this.DV-y:-y;
18377 // Montgomery reduction
18378 function Montgomery(m) {
18380 this.mp = m.invDigit();
18381 this.mpl = this.mp
&0x7fff;
18382 this.mph = this.mp
>>15;
18383 this.um = (
1<<(m.DB-
15))-
1;
18388 function montConvert(x) {
18390 x.abs().dlShiftTo(this.m.t,r);
18391 r.divRemTo(this.m,null,r);
18392 if(x.s <
0 && r.compareTo(BigInteger.ZERO)
> 0) this.m.subTo(r,r);
18397 function montRevert(x) {
18404 // x = x/R mod m (HAC
14.32)
18405 function montReduce(x) {
18406 while(x.t <= this.mt2) // pad x so am has enough room later
18408 for(var i =
0; i < this.m.t; ++i) {
18409 // faster way of calculating u0 = x[i]*mp mod DV
18410 var j = x[i]
&0x7fff;
18411 var u0 = (j*this.mpl+(((j*this.mph+(x[i]
>>15)*this.mpl)&this.um)<
<15))&x.DM;
18412 // use am to combine the multiply-shift-add into one call
18414 x[j] += this.m.am(
0,u0,x,i,
0,this.m.t);
18416 while(x[j]
>= x.DV) { x[j] -= x.DV; x[++j]++; }
18419 x.drShiftTo(this.m.t,x);
18420 if(x.compareTo(this.m)
>=
0) x.subTo(this.m,x);
18423 // r = "x^
2/R mod m"; x != r
18424 function montSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
18426 // r = "xy/R mod m"; x,y != r
18427 function montMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
18429 Montgomery.prototype.convert = montConvert;
18430 Montgomery.prototype.revert = montRevert;
18431 Montgomery.prototype.reduce = montReduce;
18432 Montgomery.prototype.mulTo = montMulTo;
18433 Montgomery.prototype.sqrTo = montSqrTo;
18435 // (protected) true iff this is even
18436 function bnpIsEven() { return ((this.t
>0)?(this[
0]&
1):this.s) ==
0; }
18438 // (protected) this^e, e <
2^
32, doing sqr and mul with
"r" (HAC
14.79)
18439 function bnpExp(e,z) {
18440 if(e
> 0xffffffff || e <
1) return BigInteger.ONE;
18441 var r = nbi(), r2 = nbi(), g = z.convert(this), i = nbits(e)-
1;
18445 if((e&(
1<
<i))
> 0) z.mulTo(r2,g,r);
18446 else { var t = r; r = r2; r2 = t; }
18448 return z.revert(r);
18451 // (public) this^e % m,
0 <= e <
2^
32
18452 function bnModPowInt(e,m) {
18454 if(e <
256 || m.isEven()) z = new Classic(m); else z = new Montgomery(m);
18455 return this.exp(e,z);
18459 proto.copyTo = bnpCopyTo;
18460 proto.fromInt = bnpFromInt;
18461 proto.fromString = bnpFromString;
18462 proto.clamp = bnpClamp;
18463 proto.dlShiftTo = bnpDLShiftTo;
18464 proto.drShiftTo = bnpDRShiftTo;
18465 proto.lShiftTo = bnpLShiftTo;
18466 proto.rShiftTo = bnpRShiftTo;
18467 proto.subTo = bnpSubTo;
18468 proto.multiplyTo = bnpMultiplyTo;
18469 proto.squareTo = bnpSquareTo;
18470 proto.divRemTo = bnpDivRemTo;
18471 proto.invDigit = bnpInvDigit;
18472 proto.isEven = bnpIsEven;
18473 proto.exp = bnpExp;
18476 proto.toString = bnToString;
18477 proto.negate = bnNegate;
18479 proto.compareTo = bnCompareTo;
18480 proto.bitLength = bnBitLength;
18482 proto.modPowInt = bnModPowInt;
18486 function nbi() { return new BigInteger(null); }
18489 function bnClone() { var r = nbi(); this.copyTo(r); return r; }
18491 // (public) return value as integer
18492 function bnIntValue() {
18494 if(this.t ==
1) return this[
0]-this.DV;
18495 else if(this.t ==
0) return -
1;
18497 else if(this.t ==
1) return this[
0];
18498 else if(this.t ==
0) return
0;
18499 // assumes
16 < DB <
32
18500 return ((this[
1]&((
1<<(
32-this.DB))-
1))<
<this.DB)|this[
0];
18503 // (public) return value as byte
18504 function bnByteValue() { return (this.t==
0)?this.s:(this[
0]<
<24)
>>24; }
18506 // (public) return value as short (assumes DB
>=
16)
18507 function bnShortValue() { return (this.t==
0)?this.s:(this[
0]<
<16)
>>16; }
18509 // (protected) return x s.t. r^x < DV
18510 function bnpChunkSize(r) { return Math.floor(Math.LN2*this.DB/Math.log(r)); }
18512 // (public)
0 if this ==
0,
1 if this
> 0
18513 function bnSigNum() {
18514 if(this.s <
0) return -
1;
18515 else if(this.t <=
0 || (this.t ==
1 && this[
0] <=
0)) return
0;
18519 // (protected) convert to radix string
18520 function bnpToRadix(b) {
18521 if(b == null) b =
10;
18522 if(this.signum() ==
0 || b <
2 || b
> 36) return
"0";
18523 var cs = this.chunkSize(b);
18524 var a = Math.pow(b,cs);
18525 var d = nbv(a), y = nbi(), z = nbi(), r =
"";
18526 this.divRemTo(d,y,z);
18527 while(y.signum()
> 0) {
18528 r = (a+z.intValue()).toString(b).substr(
1) + r;
18531 return z.intValue().toString(b) + r;
18534 // (protected) convert from radix string
18535 function bnpFromRadix(s,b) {
18538 if(b == null) b =
10;
18539 var cs = self.chunkSize(b);
18540 var d = Math.pow(b,cs), mi = false, j =
0, w =
0;
18541 for(var i =
0; i < s.length; ++i) {
18542 var x = intAt(s,i);
18544 if(s.charAt(i) ==
"-" && self.signum() ==
0) mi = true;
18550 self.dAddOffset(w,
0);
18556 self.dMultiply(Math.pow(b,j));
18557 self.dAddOffset(w,
0);
18559 if(mi) BigInteger.ZERO.subTo(self,self);
18562 // (protected) alternate constructor
18563 function bnpFromNumber(a,b,c) {
18565 if(
"number" == typeof b) {
18566 // new BigInteger(int,int,RNG)
18567 if(a <
2) self.fromInt(
1);
18569 self.fromNumber(a,c);
18570 if(!self.testBit(a-
1)) // force MSB set
18571 self.bitwiseTo(BigInteger.ONE.shiftLeft(a-
1),op_or,self);
18572 if(self.isEven()) self.dAddOffset(
1,
0); // force odd
18573 while(!self.isProbablePrime(b)) {
18574 self.dAddOffset(
2,
0);
18575 if(self.bitLength()
> a) self.subTo(BigInteger.ONE.shiftLeft(a-
1),self);
18580 // new BigInteger(int,RNG)
18581 var x = new Array(), t = a
&7;
18582 x.length = (a
>>3)+
1;
18584 if(t
> 0) x[
0] &= ((
1<
<t)-
1); else x[
0] =
0;
18585 self.fromString(x,
256);
18589 // (public) convert to bigendian byte array
18590 function bnToByteArray() {
18592 var i = self.t, r = new Array();
18594 var p = self.DB-(i*self.DB)%
8, d, k =
0;
18596 if(p < self.DB && (d = self[i]
>>p) != (self.s&self.DM)
>>p)
18597 r[k++] = d|(self.s<<(self.DB-p));
18600 d = (self[i]&((
1<
<p)-
1))<<(
8-p);
18601 d |= self[--i]
>>(p+=self.DB-
8);
18604 d = (self[i]
>>(p-=
8))
&0xff;
18605 if(p <=
0) { p += self.DB; --i; }
18607 if((d&
0x80) !=
0) d |= -
256;
18608 if(k ===
0 && (self.s&
0x80) != (d&
0x80)) ++k;
18609 if(k
> 0 || d != self.s) r[k++] = d;
18615 function bnEquals(a) { return(this.compareTo(a)==
0); }
18616 function bnMin(a) { return(this.compareTo(a)
<0)?this:a; }
18617 function bnMax(a) { return(this.compareTo(a)
>0)?this:a; }
18619 // (protected) r = this op a (bitwise)
18620 function bnpBitwiseTo(a,op,r) {
18622 var i, f, m = Math.min(a.t,self.t);
18623 for(i =
0; i < m; ++i) r[i] = op(self[i],a[i]);
18626 for(i = m; i < self.t; ++i) r[i] = op(self[i],f);
18630 f = self.s&self.DM;
18631 for(i = m; i < a.t; ++i) r[i] = op(f,a[i]);
18634 r.s = op(self.s,a.s);
18638 // (public) this & a
18639 function op_and(x,y) { return x
&y; }
18640 function bnAnd(a) { var r = nbi(); this.bitwiseTo(a,op_and,r); return r; }
18642 // (public) this | a
18643 function op_or(x,y) { return x|y; }
18644 function bnOr(a) { var r = nbi(); this.bitwiseTo(a,op_or,r); return r; }
18646 // (public) this ^ a
18647 function op_xor(x,y) { return x^y; }
18648 function bnXor(a) { var r = nbi(); this.bitwiseTo(a,op_xor,r); return r; }
18650 // (public) this & ~a
18651 function op_andnot(x,y) { return x&~y; }
18652 function bnAndNot(a) { var r = nbi(); this.bitwiseTo(a,op_andnot,r); return r; }
18657 for(var i =
0; i < this.t; ++i) r[i] = this.DM&~this[i];
18663 // (public) this << n
18664 function bnShiftLeft(n) {
18666 if(n <
0) this.rShiftTo(-n,r); else this.lShiftTo(n,r);
18670 // (public) this
>> n
18671 function bnShiftRight(n) {
18673 if(n <
0) this.lShiftTo(-n,r); else this.rShiftTo(n,r);
18677 // return index of lowest
1-bit in x, x <
2^
31
18679 if(x ==
0) return -
1;
18681 if((x&
0xffff) ==
0) { x
>>=
16; r +=
16; }
18682 if((x&
0xff) ==
0) { x
>>=
8; r +=
8; }
18683 if((x&
0xf) ==
0) { x
>>=
4; r +=
4; }
18684 if((x&
3) ==
0) { x
>>=
2; r +=
2; }
18685 if((x&
1) ==
0) ++r;
18689 // (public) returns index of lowest
1-bit (or -
1 if none)
18690 function bnGetLowestSetBit() {
18691 for(var i =
0; i < this.t; ++i)
18692 if(this[i] !=
0) return i*this.DB+lbit(this[i]);
18693 if(this.s <
0) return this.t*this.DB;
18697 // return number of
1 bits in x
18700 while(x !=
0) { x &= x-
1; ++r; }
18704 // (public) return number of set bits
18705 function bnBitCount() {
18706 var r =
0, x = this.s&this.DM;
18707 for(var i =
0; i < this.t; ++i) r += cbit(this[i]^x);
18711 // (public) true iff nth bit is set
18712 function bnTestBit(n) {
18713 var j = Math.floor(n/this.DB);
18714 if(j
>= this.t) return(this.s!=
0);
18715 return((this[j]&(
1<<(n%this.DB)))!=
0);
18718 // (protected) this op (
1<
<n)
18719 function bnpChangeBit(n,op) {
18720 var r = BigInteger.ONE.shiftLeft(n);
18721 this.bitwiseTo(r,op,r);
18725 // (public) this | (
1<
<n)
18726 function bnSetBit(n) { return this.changeBit(n,op_or); }
18728 // (public) this & ~(
1<
<n)
18729 function bnClearBit(n) { return this.changeBit(n,op_andnot); }
18731 // (public) this ^ (
1<
<n)
18732 function bnFlipBit(n) { return this.changeBit(n,op_xor); }
18734 // (protected) r = this + a
18735 function bnpAddTo(a,r) {
18738 var i =
0, c =
0, m = Math.min(a.t,self.t);
18741 r[i++] = c&self.DM;
18746 while(i < self.t) {
18748 r[i++] = c&self.DM;
18757 r[i++] = c&self.DM;
18763 if(c
> 0) r[i++] = c;
18764 else if(c < -
1) r[i++] = self.DV+c;
18769 // (public) this + a
18770 function bnAdd(a) { var r = nbi(); this.addTo(a,r); return r; }
18772 // (public) this - a
18773 function bnSubtract(a) { var r = nbi(); this.subTo(a,r); return r; }
18775 // (public) this * a
18776 function bnMultiply(a) { var r = nbi(); this.multiplyTo(a,r); return r; }
18779 function bnSquare() { var r = nbi(); this.squareTo(r); return r; }
18781 // (public) this / a
18782 function bnDivide(a) { var r = nbi(); this.divRemTo(a,r,null); return r; }
18784 // (public) this % a
18785 function bnRemainder(a) { var r = nbi(); this.divRemTo(a,null,r); return r; }
18787 // (public) [this/a,this%a]
18788 function bnDivideAndRemainder(a) {
18789 var q = nbi(), r = nbi();
18790 this.divRemTo(a,q,r);
18791 return new Array(q,r);
18794 // (protected) this *= n, this
>=
0,
1 < n < DV
18795 function bnpDMultiply(n) {
18796 this[this.t] = this.am(
0,n-
1,this,
0,
0,this.t);
18801 // (protected) this += n << w words, this
>=
0
18802 function bnpDAddOffset(n,w) {
18804 while(this.t <= w) this[this.t++] =
0;
18806 while(this[w]
>= this.DV) {
18807 this[w] -= this.DV;
18808 if(++w
>= this.t) this[this.t++] =
0;
18813 // A "null" reducer
18814 function NullExp() {}
18815 function nNop(x) { return x; }
18816 function nMulTo(x,y,r) { x.multiplyTo(y,r); }
18817 function nSqrTo(x,r) { x.squareTo(r); }
18819 NullExp.prototype.convert = nNop;
18820 NullExp.prototype.revert = nNop;
18821 NullExp.prototype.mulTo = nMulTo;
18822 NullExp.prototype.sqrTo = nSqrTo;
18825 function bnPow(e) { return this.exp(e,new NullExp()); }
18827 // (protected) r = lower n words of "this * a", a.t <= n
18828 // "this" should be the larger one if appropriate.
18829 function bnpMultiplyLowerTo(a,n,r) {
18830 var i = Math.min(this.t+a.t,n);
18831 r.s =
0; // assumes a,this
>=
0
18833 while(i
> 0) r[--i] =
0;
18835 for(j = r.t-this.t; i < j; ++i) r[i+this.t] = this.am(
0,a[i],r,i,
0,this.t);
18836 for(j = Math.min(a.t,n); i < j; ++i) this.am(
0,a[i],r,i,
0,n-i);
18840 // (protected) r =
"this * a" without lower n words, n
> 0
18841 //
"this" should be the larger one if appropriate.
18842 function bnpMultiplyUpperTo(a,n,r) {
18844 var i = r.t = this.t+a.t-n;
18845 r.s =
0; // assumes a,this
>=
0
18846 while(--i
>=
0) r[i] =
0;
18847 for(i = Math.max(n-this.t,
0); i < a.t; ++i)
18848 r[this.t+i-n] = this.am(n-i,a[i],r,
0,
0,this.t+i-n);
18853 // Barrett modular reduction
18854 function Barrett(m) {
18858 BigInteger.ONE.dlShiftTo(
2*m.t,this.r2);
18859 this.mu = this.r2.divide(m);
18863 function barrettConvert(x) {
18864 if(x.s <
0 || x.t
> 2*this.m.t) return x.mod(this.m);
18865 else if(x.compareTo(this.m) <
0) return x;
18866 else { var r = nbi(); x.copyTo(r); this.reduce(r); return r; }
18869 function barrettRevert(x) { return x; }
18871 // x = x mod m (HAC
14.42)
18872 function barrettReduce(x) {
18874 x.drShiftTo(self.m.t-
1,self.r2);
18875 if(x.t
> self.m.t+
1) { x.t = self.m.t+
1; x.clamp(); }
18876 self.mu.multiplyUpperTo(self.r2,self.m.t+
1,self.q3);
18877 self.m.multiplyLowerTo(self.q3,self.m.t+
1,self.r2);
18878 while(x.compareTo(self.r2) <
0) x.dAddOffset(
1,self.m.t+
1);
18879 x.subTo(self.r2,x);
18880 while(x.compareTo(self.m)
>=
0) x.subTo(self.m,x);
18883 // r = x^
2 mod m; x != r
18884 function barrettSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
18886 // r = x*y mod m; x,y != r
18887 function barrettMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
18889 Barrett.prototype.convert = barrettConvert;
18890 Barrett.prototype.revert = barrettRevert;
18891 Barrett.prototype.reduce = barrettReduce;
18892 Barrett.prototype.mulTo = barrettMulTo;
18893 Barrett.prototype.sqrTo = barrettSqrTo;
18895 // (public) this^e % m (HAC
14.85)
18896 function bnModPow(e,m) {
18897 var i = e.bitLength(), k, r = nbv(
1), z;
18898 if(i <=
0) return r;
18899 else if(i <
18) k =
1;
18900 else if(i <
48) k =
3;
18901 else if(i <
144) k =
4;
18902 else if(i <
768) k =
5;
18905 z = new Classic(m);
18906 else if(m.isEven())
18907 z = new Barrett(m);
18909 z = new Montgomery(m);
18912 var g = new Array(), n =
3, k1 = k-
1, km = (
1<
<k)-
1;
18913 g[
1] = z.convert(this);
18919 z.mulTo(g2,g[n-
2],g[n]);
18924 var j = e.t-
1, w, is1 = true, r2 = nbi(), t;
18927 if(i
>= k1) w = (e[j]
>>(i-k1))
&km;
18929 w = (e[j]&((
1<<(i+
1))-
1))<<(k1-i);
18930 if(j
> 0) w |= e[j-
1]
>>(this.DB+i-k1);
18934 while((w&
1) ==
0) { w
>>=
1; --n; }
18935 if((i -= n) <
0) { i += this.DB; --j; }
18936 if(is1) { // ret ==
1, don't bother squaring or multiplying it
18941 while(n
> 1) { z.sqrTo(r,r2); z.sqrTo(r2,r); n -=
2; }
18942 if(n
> 0) z.sqrTo(r,r2); else { t = r; r = r2; r2 = t; }
18943 z.mulTo(r2,g[w],r);
18946 while(j
>=
0 && (e[j]&(
1<
<i)) ==
0) {
18947 z.sqrTo(r,r2); t = r; r = r2; r2 = t;
18948 if(--i <
0) { i = this.DB-
1; --j; }
18951 return z.revert(r);
18954 // (public) gcd(this,a) (HAC
14.54)
18955 function bnGCD(a) {
18956 var x = (this.s
<0)?this.negate():this.clone();
18957 var y = (a.s
<0)?a.negate():a.clone();
18958 if(x.compareTo(y) <
0) { var t = x; x = y; y = t; }
18959 var i = x.getLowestSetBit(), g = y.getLowestSetBit();
18960 if(g <
0) return x;
18966 while(x.signum()
> 0) {
18967 if((i = x.getLowestSetBit())
> 0) x.rShiftTo(i,x);
18968 if((i = y.getLowestSetBit())
> 0) y.rShiftTo(i,y);
18969 if(x.compareTo(y)
>=
0) {
18978 if(g
> 0) y.lShiftTo(g,y);
18982 // (protected) this % n, n <
2^
26
18983 function bnpModInt(n) {
18984 if(n <=
0) return
0;
18985 var d = this.DV%n, r = (this.s
<0)?n-
1:
0;
18987 if(d ==
0) r = this[
0]%n;
18988 else for(var i = this.t-
1; i
>=
0; --i) r = (d*r+this[i])%n;
18992 // (public)
1/this % m (HAC
14.61)
18993 function bnModInverse(m) {
18994 var ac = m.isEven();
18995 if((this.isEven() && ac) || m.signum() ==
0) return BigInteger.ZERO;
18996 var u = m.clone(), v = this.clone();
18997 var a = nbv(
1), b = nbv(
0), c = nbv(
0), d = nbv(
1);
18998 while(u.signum() !=
0) {
18999 while(u.isEven()) {
19002 if(!a.isEven() || !b.isEven()) { a.addTo(this,a); b.subTo(m,b); }
19005 else if(!b.isEven()) b.subTo(m,b);
19008 while(v.isEven()) {
19011 if(!c.isEven() || !d.isEven()) { c.addTo(this,c); d.subTo(m,d); }
19014 else if(!d.isEven()) d.subTo(m,d);
19017 if(u.compareTo(v)
>=
0) {
19019 if(ac) a.subTo(c,a);
19024 if(ac) c.subTo(a,c);
19028 if(v.compareTo(BigInteger.ONE) !=
0) return BigInteger.ZERO;
19029 if(d.compareTo(m)
>=
0) return d.subtract(m);
19030 if(d.signum() <
0) d.addTo(m,d); else return d;
19031 if(d.signum() <
0) return d.add(m); else return d;
19035 proto.chunkSize = bnpChunkSize;
19036 proto.toRadix = bnpToRadix;
19037 proto.fromRadix = bnpFromRadix;
19038 proto.fromNumber = bnpFromNumber;
19039 proto.bitwiseTo = bnpBitwiseTo;
19040 proto.changeBit = bnpChangeBit;
19041 proto.addTo = bnpAddTo;
19042 proto.dMultiply = bnpDMultiply;
19043 proto.dAddOffset = bnpDAddOffset;
19044 proto.multiplyLowerTo = bnpMultiplyLowerTo;
19045 proto.multiplyUpperTo = bnpMultiplyUpperTo;
19046 proto.modInt = bnpModInt;
19049 proto.clone = bnClone;
19050 proto.intValue = bnIntValue;
19051 proto.byteValue = bnByteValue;
19052 proto.shortValue = bnShortValue;
19053 proto.signum = bnSigNum;
19054 proto.toByteArray = bnToByteArray;
19055 proto.equals = bnEquals;
19061 proto.andNot = bnAndNot;
19063 proto.shiftLeft = bnShiftLeft;
19064 proto.shiftRight = bnShiftRight;
19065 proto.getLowestSetBit = bnGetLowestSetBit;
19066 proto.bitCount = bnBitCount;
19067 proto.testBit = bnTestBit;
19068 proto.setBit = bnSetBit;
19069 proto.clearBit = bnClearBit;
19070 proto.flipBit = bnFlipBit;
19072 proto.subtract = bnSubtract;
19073 proto.multiply = bnMultiply;
19074 proto.divide = bnDivide;
19075 proto.remainder = bnRemainder;
19076 proto.divideAndRemainder = bnDivideAndRemainder;
19077 proto.modPow = bnModPow;
19078 proto.modInverse = bnModInverse;
19082 // JSBN-specific extension
19083 proto.square = bnSquare;
19085 // BigInteger interfaces not implemented in jsbn:
19087 // BigInteger(int signum, byte[] magnitude)
19088 // double doubleValue()
19089 // float floatValue()
19091 // long longValue()
19092 // static BigInteger valueOf(long val)
19095 BigInteger.ZERO = nbv(
0);
19096 BigInteger.ONE = nbv(
1);
19097 BigInteger.valueOf = nbv;
19099 },{"assert":
4}],
2:[function(_dereq_,module,exports){
19100 (function (Buffer){
19101 // FIXME: Kind of a weird way to throw exceptions, consider removing
19102 var assert = _dereq_('assert')
19103 var BigInteger = _dereq_('./bigi')
19106 * Turns a byte array into a big integer.
19108 * This function will interpret a byte array as a big integer in big
19111 BigInteger.fromByteArrayUnsigned = function(byteArray) {
19112 // BigInteger expects a DER integer conformant byte array
19113 if (byteArray[
0] &
0x80) {
19114 return new BigInteger([
0].concat(byteArray))
19117 return new BigInteger(byteArray)
19121 * Returns a byte array representation of the big integer.
19123 * This returns the absolute of the contained value in big endian
19124 * form. A value of zero results in an empty array.
19126 BigInteger.prototype.toByteArrayUnsigned = function() {
19127 var byteArray = this.toByteArray()
19128 return byteArray[
0] ===
0 ? byteArray.slice(
1) : byteArray
19131 BigInteger.fromDERInteger = function(byteArray) {
19132 return new BigInteger(byteArray)
19136 * Converts BigInteger to a DER integer representation.
19138 * The format for this value uses the most significant bit as a sign
19139 * bit. If the most significant bit is already set and the integer is
19140 * positive, a
0x00 is prepended.
19155 *
62300 =
> 0x00f35c
19158 BigInteger.prototype.toDERInteger = BigInteger.prototype.toByteArray
19160 BigInteger.fromBuffer = function(buffer) {
19161 // BigInteger expects a DER integer conformant byte array
19162 if (buffer[
0] &
0x80) {
19163 var byteArray = Array.prototype.slice.call(buffer)
19165 return new BigInteger([
0].concat(byteArray))
19168 return new BigInteger(buffer)
19171 BigInteger.fromHex = function(hex) {
19172 if (hex === '') return BigInteger.ZERO
19174 assert.equal(hex, hex.match(/^[A-Fa-f0-
9]+/), 'Invalid hex string')
19175 assert.equal(hex.length %
2,
0, 'Incomplete hex')
19176 return new BigInteger(hex,
16)
19179 BigInteger.prototype.toBuffer = function(size) {
19180 var byteArray = this.toByteArrayUnsigned()
19183 var padding = size - byteArray.length
19184 while (zeros.length < padding) zeros.push(
0)
19186 return new Buffer(zeros.concat(byteArray))
19189 BigInteger.prototype.toHex = function(size) {
19190 return this.toBuffer(size).toString('hex')
19193 }).call(this,_dereq_(
"buffer").Buffer)
19194 },{
"./bigi":
1,
"assert":
4,
"buffer":
8}],
3:[function(_dereq_,module,exports){
19195 var BigInteger = _dereq_('./bigi')
19198 _dereq_('./convert')
19200 module.exports = BigInteger
19201 },{
"./bigi":
1,
"./convert":
2}],
4:[function(_dereq_,module,exports){
19202 // http://wiki.commonjs.org/wiki/Unit_Testing/
1.0
19204 // THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
19206 // Originally from narwhal.js (http://narwhaljs.org)
19207 // Copyright (c)
2009 Thomas Robinson
<280north.com
>
19209 // Permission is hereby granted, free of charge, to any person obtaining a copy
19210 // of this software and associated documentation files (the 'Software'), to
19211 // deal in the Software without restriction, including without limitation the
19212 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
19213 // sell copies of the Software, and to permit persons to whom the Software is
19214 // furnished to do so, subject to the following conditions:
19216 // The above copyright notice and this permission notice shall be included in
19217 // all copies or substantial portions of the Software.
19219 // THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19220 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19221 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19222 // AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19223 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
19224 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19226 // when used in node, this will actually load the util module we depend on
19227 // versus loading the builtin util module as happens otherwise
19228 // this is a bug in node module loading as far as I am concerned
19229 var util = _dereq_('util/');
19231 var pSlice = Array.prototype.slice;
19232 var hasOwn = Object.prototype.hasOwnProperty;
19234 //
1. The assert module provides functions that throw
19235 // AssertionError's when particular conditions are not met. The
19236 // assert module must conform to the following interface.
19238 var assert = module.exports = ok;
19240 //
2. The AssertionError is defined in assert.
19241 // new assert.AssertionError({ message: message,
19243 // expected: expected })
19245 assert.AssertionError = function AssertionError(options) {
19246 this.name = 'AssertionError';
19247 this.actual = options.actual;
19248 this.expected = options.expected;
19249 this.operator = options.operator;
19250 if (options.message) {
19251 this.message = options.message;
19252 this.generatedMessage = false;
19254 this.message = getMessage(this);
19255 this.generatedMessage = true;
19257 var stackStartFunction = options.stackStartFunction || fail;
19259 if (Error.captureStackTrace) {
19260 Error.captureStackTrace(this, stackStartFunction);
19263 // non v8 browsers so we can have a stacktrace
19264 var err = new Error();
19266 var out = err.stack;
19268 // try to strip useless frames
19269 var fn_name = stackStartFunction.name;
19270 var idx = out.indexOf('\n' + fn_name);
19272 // once we have located the function frame
19273 // we need to strip out everything before it (and its line)
19274 var next_line = out.indexOf('\n', idx +
1);
19275 out = out.substring(next_line +
1);
19283 // assert.AssertionError instanceof Error
19284 util.inherits(assert.AssertionError, Error);
19286 function replacer(key, value) {
19287 if (util.isUndefined(value)) {
19290 if (util.isNumber(value) && (isNaN(value) || !isFinite(value))) {
19291 return value.toString();
19293 if (util.isFunction(value) || util.isRegExp(value)) {
19294 return value.toString();
19299 function truncate(s, n) {
19300 if (util.isString(s)) {
19301 return s.length < n ? s : s.slice(
0, n);
19307 function getMessage(self) {
19308 return truncate(JSON.stringify(self.actual, replacer),
128) + ' ' +
19309 self.operator + ' ' +
19310 truncate(JSON.stringify(self.expected, replacer),
128);
19313 // At present only the three keys mentioned above are used and
19314 // understood by the spec. Implementations or sub modules can pass
19315 // other keys to the AssertionError's constructor - they will be
19318 //
3. All of the following functions must throw an AssertionError
19319 // when a corresponding condition is not met, with a message that
19320 // may be undefined if not provided. All assertion methods provide
19321 // both the actual and expected values to the assertion error for
19322 // display purposes.
19324 function fail(actual, expected, message, operator, stackStartFunction) {
19325 throw new assert.AssertionError({
19328 expected: expected,
19329 operator: operator,
19330 stackStartFunction: stackStartFunction
19334 // EXTENSION! allows for well behaved errors defined elsewhere.
19335 assert.fail = fail;
19337 //
4. Pure assertion tests whether a value is truthy, as determined
19339 // assert.ok(guard, message_opt);
19340 // This statement is equivalent to assert.equal(true, !!guard,
19341 // message_opt);. To test strictly for the value true, use
19342 // assert.strictEqual(true, guard, message_opt);.
19344 function ok(value, message) {
19345 if (!value) fail(value, true, message, '==', assert.ok);
19349 //
5. The equality assertion tests shallow, coercive equality with
19351 // assert.equal(actual, expected, message_opt);
19353 assert.equal = function equal(actual, expected, message) {
19354 if (actual != expected) fail(actual, expected, message, '==', assert.equal);
19357 //
6. The non-equality assertion tests for whether two objects are not equal
19358 // with != assert.notEqual(actual, expected, message_opt);
19360 assert.notEqual = function notEqual(actual, expected, message) {
19361 if (actual == expected) {
19362 fail(actual, expected, message, '!=', assert.notEqual);
19366 //
7. The equivalence assertion tests a deep equality relation.
19367 // assert.deepEqual(actual, expected, message_opt);
19369 assert.deepEqual = function deepEqual(actual, expected, message) {
19370 if (!_deepEqual(actual, expected)) {
19371 fail(actual, expected, message, 'deepEqual', assert.deepEqual);
19375 function _deepEqual(actual, expected) {
19376 //
7.1. All identical values are equivalent, as determined by ===.
19377 if (actual === expected) {
19380 } else if (util.isBuffer(actual) && util.isBuffer(expected)) {
19381 if (actual.length != expected.length) return false;
19383 for (var i =
0; i < actual.length; i++) {
19384 if (actual[i] !== expected[i]) return false;
19389 //
7.2. If the expected value is a Date object, the actual value is
19390 // equivalent if it is also a Date object that refers to the same time.
19391 } else if (util.isDate(actual) && util.isDate(expected)) {
19392 return actual.getTime() === expected.getTime();
19394 //
7.3 If the expected value is a RegExp object, the actual value is
19395 // equivalent if it is also a RegExp object with the same source and
19396 // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
19397 } else if (util.isRegExp(actual) && util.isRegExp(expected)) {
19398 return actual.source === expected.source &&
19399 actual.global === expected.global &&
19400 actual.multiline === expected.multiline &&
19401 actual.lastIndex === expected.lastIndex &&
19402 actual.ignoreCase === expected.ignoreCase;
19404 //
7.4. Other pairs that do not both pass typeof value == 'object',
19405 // equivalence is determined by ==.
19406 } else if (!util.isObject(actual) && !util.isObject(expected)) {
19407 return actual == expected;
19409 //
7.5 For all other Object pairs, including Array objects, equivalence is
19410 // determined by having the same number of owned properties (as verified
19411 // with Object.prototype.hasOwnProperty.call), the same set of keys
19412 // (although not necessarily the same order), equivalent values for every
19413 // corresponding key, and an identical 'prototype' property. Note: this
19414 // accounts for both named and indexed properties on Arrays.
19416 return objEquiv(actual, expected);
19420 function isArguments(object) {
19421 return Object.prototype.toString.call(object) == '[object Arguments]';
19424 function objEquiv(a, b) {
19425 if (util.isNullOrUndefined(a) || util.isNullOrUndefined(b))
19427 // an identical 'prototype' property.
19428 if (a.prototype !== b.prototype) return false;
19429 //~~~I've managed to break Object.keys through screwy arguments passing.
19430 // Converting to array solves the problem.
19431 if (isArguments(a)) {
19432 if (!isArguments(b)) {
19435 a = pSlice.call(a);
19436 b = pSlice.call(b);
19437 return _deepEqual(a, b);
19440 var ka = objectKeys(a),
19441 kb = objectKeys(b),
19443 } catch (e) {//happens when one is a string literal and the other isn't
19446 // having the same number of owned properties (keys incorporates
19448 if (ka.length != kb.length)
19450 //the same set of keys (although not necessarily the same order),
19453 //~~~cheap key test
19454 for (i = ka.length -
1; i
>=
0; i--) {
19455 if (ka[i] != kb[i])
19458 //equivalent values for every corresponding key, and
19459 //~~~possibly expensive deep test
19460 for (i = ka.length -
1; i
>=
0; i--) {
19462 if (!_deepEqual(a[key], b[key])) return false;
19467 //
8. The non-equivalence assertion tests for any deep inequality.
19468 // assert.notDeepEqual(actual, expected, message_opt);
19470 assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
19471 if (_deepEqual(actual, expected)) {
19472 fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
19476 //
9. The strict equality assertion tests strict equality, as determined by ===.
19477 // assert.strictEqual(actual, expected, message_opt);
19479 assert.strictEqual = function strictEqual(actual, expected, message) {
19480 if (actual !== expected) {
19481 fail(actual, expected, message, '===', assert.strictEqual);
19485 //
10. The strict non-equality assertion tests for strict inequality, as
19486 // determined by !==. assert.notStrictEqual(actual, expected, message_opt);
19488 assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
19489 if (actual === expected) {
19490 fail(actual, expected, message, '!==', assert.notStrictEqual);
19494 function expectedException(actual, expected) {
19495 if (!actual || !expected) {
19499 if (Object.prototype.toString.call(expected) == '[object RegExp]') {
19500 return expected.test(actual);
19501 } else if (actual instanceof expected) {
19503 } else if (expected.call({}, actual) === true) {
19510 function _throws(shouldThrow, block, expected, message) {
19513 if (util.isString(expected)) {
19514 message = expected;
19524 message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
19525 (message ? ' ' + message : '.');
19527 if (shouldThrow && !actual) {
19528 fail(actual, expected, 'Missing expected exception' + message);
19531 if (!shouldThrow && expectedException(actual, expected)) {
19532 fail(actual, expected, 'Got unwanted exception' + message);
19535 if ((shouldThrow && actual && expected &&
19536 !expectedException(actual, expected)) || (!shouldThrow && actual)) {
19541 //
11. Expected to throw an error:
19542 // assert.throws(block, Error_opt, message_opt);
19544 assert.throws = function(block, /*optional*/error, /*optional*/message) {
19545 _throws.apply(this, [true].concat(pSlice.call(arguments)));
19548 // EXTENSION! This is annoying to write outside this module.
19549 assert.doesNotThrow = function(block, /*optional*/message) {
19550 _throws.apply(this, [false].concat(pSlice.call(arguments)));
19553 assert.ifError = function(err) { if (err) {throw err;}};
19555 var objectKeys = Object.keys || function (obj) {
19557 for (var key in obj) {
19558 if (hasOwn.call(obj, key)) keys.push(key);
19563 },{"util/":
6}],
5:[function(_dereq_,module,exports){
19564 module.exports = function isBuffer(arg) {
19565 return arg && typeof arg === 'object'
19566 && typeof arg.copy === 'function'
19567 && typeof arg.fill === 'function'
19568 && typeof arg.readUInt8 === 'function';
19570 },{}],
6:[function(_dereq_,module,exports){
19571 (function (process,global){
19572 // Copyright Joyent, Inc. and other Node contributors.
19574 // Permission is hereby granted, free of charge, to any person obtaining a
19575 // copy of this software and associated documentation files (the
19576 // "Software"), to deal in the Software without restriction, including
19577 // without limitation the rights to use, copy, modify, merge, publish,
19578 // distribute, sublicense, and/or sell copies of the Software, and to permit
19579 // persons to whom the Software is furnished to do so, subject to the
19580 // following conditions:
19582 // The above copyright notice and this permission notice shall be included
19583 // in all copies or substantial portions of the Software.
19585 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19586 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19587 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
19588 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
19589 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19590 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
19591 // USE OR OTHER DEALINGS IN THE SOFTWARE.
19593 var formatRegExp = /%[sdj%]/g;
19594 exports.format = function(f) {
19595 if (!isString(f)) {
19597 for (var i =
0; i < arguments.length; i++) {
19598 objects.push(inspect(arguments[i]));
19600 return objects.join(' ');
19604 var args = arguments;
19605 var len = args.length;
19606 var str = String(f).replace(formatRegExp, function(x) {
19607 if (x === '%%') return '%';
19608 if (i
>= len) return x;
19610 case '%s': return String(args[i++]);
19611 case '%d': return Number(args[i++]);
19614 return JSON.stringify(args[i++]);
19616 return '[Circular]';
19622 for (var x = args[i]; i < len; x = args[++i]) {
19623 if (isNull(x) || !isObject(x)) {
19626 str += ' ' + inspect(x);
19633 // Mark that a method should not be used.
19634 // Returns a modified function which warns once by default.
19635 // If --no-deprecation is set, then it is a no-op.
19636 exports.deprecate = function(fn, msg) {
19637 // Allow for deprecating things in the process of starting up.
19638 if (isUndefined(global.process)) {
19639 return function() {
19640 return exports.deprecate(fn, msg).apply(this, arguments);
19644 if (process.noDeprecation === true) {
19648 var warned = false;
19649 function deprecated() {
19651 if (process.throwDeprecation) {
19652 throw new Error(msg);
19653 } else if (process.traceDeprecation) {
19654 console.trace(msg);
19656 console.error(msg);
19660 return fn.apply(this, arguments);
19669 exports.debuglog = function(set) {
19670 if (isUndefined(debugEnviron))
19671 debugEnviron = process.env.NODE_DEBUG || '';
19672 set = set.toUpperCase();
19673 if (!debugs[set]) {
19674 if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
19675 var pid = process.pid;
19676 debugs[set] = function() {
19677 var msg = exports.format.apply(exports, arguments);
19678 console.error('%s %d: %s', set, pid, msg);
19681 debugs[set] = function() {};
19684 return debugs[set];
19689 * Echos the value of a value. Trys to print the value out
19690 * in the best way possible given the different types.
19692 * @param {Object} obj The object to print out.
19693 * @param {Object} opts Optional options object that alters the output.
19695 /* legacy: obj, showHidden, depth, colors*/
19696 function inspect(obj, opts) {
19700 stylize: stylizeNoColor
19703 if (arguments.length
>=
3) ctx.depth = arguments[
2];
19704 if (arguments.length
>=
4) ctx.colors = arguments[
3];
19705 if (isBoolean(opts)) {
19707 ctx.showHidden = opts;
19709 // got an "options" object
19710 exports._extend(ctx, opts);
19712 // set default options
19713 if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
19714 if (isUndefined(ctx.depth)) ctx.depth =
2;
19715 if (isUndefined(ctx.colors)) ctx.colors = false;
19716 if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
19717 if (ctx.colors) ctx.stylize = stylizeWithColor;
19718 return formatValue(ctx, obj, ctx.depth);
19720 exports.inspect = inspect;
19723 // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
19726 'italic' : [
3,
23],
19727 'underline' : [
4,
24],
19728 'inverse' : [
7,
27],
19729 'white' : [
37,
39],
19731 'black' : [
30,
39],
19734 'green' : [
32,
39],
19735 'magenta' : [
35,
39],
19737 'yellow' : [
33,
39]
19740 // Don't use 'blue' not visible on cmd.exe
19743 'number': 'yellow',
19744 'boolean': 'yellow',
19745 'undefined': 'grey',
19749 // "name": intentionally not styling
19754 function stylizeWithColor(str, styleType) {
19755 var style = inspect.styles[styleType];
19758 return '\u001b[' + inspect.colors[style][
0] + 'm' + str +
19759 '\u001b[' + inspect.colors[style][
1] + 'm';
19766 function stylizeNoColor(str, styleType) {
19771 function arrayToHash(array) {
19774 array.forEach(function(val, idx) {
19782 function formatValue(ctx, value, recurseTimes) {
19783 // Provide a hook for user-specified inspect functions.
19784 // Check that value is an object with an inspect function on it
19785 if (ctx.customInspect &&
19787 isFunction(value.inspect) &&
19788 // Filter out the util module, it's inspect function is special
19789 value.inspect !== exports.inspect &&
19790 // Also filter out any prototype objects using the circular check.
19791 !(value.constructor && value.constructor.prototype === value)) {
19792 var ret = value.inspect(recurseTimes, ctx);
19793 if (!isString(ret)) {
19794 ret = formatValue(ctx, ret, recurseTimes);
19799 // Primitive types cannot have properties
19800 var primitive = formatPrimitive(ctx, value);
19805 // Look up the keys of the object.
19806 var keys = Object.keys(value);
19807 var visibleKeys = arrayToHash(keys);
19809 if (ctx.showHidden) {
19810 keys = Object.getOwnPropertyNames(value);
19813 // IE doesn't make error fields non-enumerable
19814 // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs
.94).aspx
19816 && (keys.indexOf('message')
>=
0 || keys.indexOf('description')
>=
0)) {
19817 return formatError(value);
19820 // Some type of object without properties can be shortcutted.
19821 if (keys.length ===
0) {
19822 if (isFunction(value)) {
19823 var name = value.name ? ': ' + value.name : '';
19824 return ctx.stylize('[Function' + name + ']', 'special');
19826 if (isRegExp(value)) {
19827 return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
19829 if (isDate(value)) {
19830 return ctx.stylize(Date.prototype.toString.call(value), 'date');
19832 if (isError(value)) {
19833 return formatError(value);
19837 var base = '', array = false, braces = ['{', '}'];
19839 // Make Array say that they are Array
19840 if (isArray(value)) {
19842 braces = ['[', ']'];
19845 // Make functions say that they are functions
19846 if (isFunction(value)) {
19847 var n = value.name ? ': ' + value.name : '';
19848 base = ' [Function' + n + ']';
19851 // Make RegExps say that they are RegExps
19852 if (isRegExp(value)) {
19853 base = ' ' + RegExp.prototype.toString.call(value);
19856 // Make dates with properties first say the date
19857 if (isDate(value)) {
19858 base = ' ' + Date.prototype.toUTCString.call(value);
19861 // Make error with message first say the error
19862 if (isError(value)) {
19863 base = ' ' + formatError(value);
19866 if (keys.length ===
0 && (!array || value.length ==
0)) {
19867 return braces[
0] + base + braces[
1];
19870 if (recurseTimes <
0) {
19871 if (isRegExp(value)) {
19872 return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
19874 return ctx.stylize('[Object]', 'special');
19878 ctx.seen.push(value);
19882 output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
19884 output = keys.map(function(key) {
19885 return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
19891 return reduceToSingleString(output, base, braces);
19895 function formatPrimitive(ctx, value) {
19896 if (isUndefined(value))
19897 return ctx.stylize('undefined', 'undefined');
19898 if (isString(value)) {
19899 var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
19900 .replace(/'/g, "\\'")
19901 .replace(/\\"/g, '"') + '\'';
19902 return ctx.stylize(simple, 'string');
19904 if (isNumber(value))
19905 return ctx.stylize('' + value, 'number');
19906 if (isBoolean(value))
19907 return ctx.stylize('' + value, 'boolean');
19908 // For some reason typeof null is "object", so special case here.
19910 return ctx.stylize('null', 'null');
19914 function formatError(value) {
19915 return '[' + Error.prototype.toString.call(value) + ']';
19919 function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
19921 for (var i =
0, l = value.length; i < l; ++i) {
19922 if (hasOwnProperty(value, String(i))) {
19923 output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
19929 keys.forEach(function(key) {
19930 if (!key.match(/^\d+$/)) {
19931 output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
19939 function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
19940 var name, str, desc;
19941 desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
19944 str = ctx.stylize('[Getter/Setter]', 'special');
19946 str = ctx.stylize('[Getter]', 'special');
19950 str = ctx.stylize('[Setter]', 'special');
19953 if (!hasOwnProperty(visibleKeys, key)) {
19954 name = '[' + key + ']';
19957 if (ctx.seen.indexOf(desc.value) <
0) {
19958 if (isNull(recurseTimes)) {
19959 str = formatValue(ctx, desc.value, null);
19961 str = formatValue(ctx, desc.value, recurseTimes -
1);
19963 if (str.indexOf('\n')
> -
1) {
19965 str = str.split('\n').map(function(line) {
19967 }).join('\n').substr(
2);
19969 str = '\n' + str.split('\n').map(function(line) {
19975 str = ctx.stylize('[Circular]', 'special');
19978 if (isUndefined(name)) {
19979 if (array && key.match(/^\d+$/)) {
19982 name = JSON.stringify('' + key);
19983 if (name.match(/^"([a-zA-Z_][a-zA-Z_0-
9]*)"$/)) {
19984 name = name.substr(
1, name.length -
2);
19985 name = ctx.stylize(name, 'name');
19987 name = name.replace(/'/g, "\\'")
19988 .replace(/\\"/g, '"')
19989 .replace(/(^"|"$)/g, "'");
19990 name = ctx.stylize(name, 'string');
19994 return name + ': ' + str;
19998 function reduceToSingleString(output, base, braces) {
19999 var numLinesEst =
0;
20000 var length = output.reduce(function(prev, cur) {
20002 if (cur.indexOf('\n')
>=
0) numLinesEst++;
20003 return prev + cur.replace(/\u001b\[\d\d?m/g, '').length +
1;
20008 (base === '' ? '' : base + '\n ') +
20010 output.join(',\n ') +
20015 return braces[
0] + base + ' ' + output.join(', ') + ' ' + braces[
1];
20019 // NOTE: These type checking functions intentionally don't use `instanceof`
20020 // because it is fragile and can be easily faked with `Object.create()`.
20021 function isArray(ar) {
20022 return Array.isArray(ar);
20024 exports.isArray = isArray;
20026 function isBoolean(arg) {
20027 return typeof arg === 'boolean';
20029 exports.isBoolean = isBoolean;
20031 function isNull(arg) {
20032 return arg === null;
20034 exports.isNull = isNull;
20036 function isNullOrUndefined(arg) {
20037 return arg == null;
20039 exports.isNullOrUndefined = isNullOrUndefined;
20041 function isNumber(arg) {
20042 return typeof arg === 'number';
20044 exports.isNumber = isNumber;
20046 function isString(arg) {
20047 return typeof arg === 'string';
20049 exports.isString = isString;
20051 function isSymbol(arg) {
20052 return typeof arg === 'symbol';
20054 exports.isSymbol = isSymbol;
20056 function isUndefined(arg) {
20057 return arg === void
0;
20059 exports.isUndefined = isUndefined;
20061 function isRegExp(re) {
20062 return isObject(re) && objectToString(re) === '[object RegExp]';
20064 exports.isRegExp = isRegExp;
20066 function isObject(arg) {
20067 return typeof arg === 'object' && arg !== null;
20069 exports.isObject = isObject;
20071 function isDate(d) {
20072 return isObject(d) && objectToString(d) === '[object Date]';
20074 exports.isDate = isDate;
20076 function isError(e) {
20077 return isObject(e) &&
20078 (objectToString(e) === '[object Error]' || e instanceof Error);
20080 exports.isError = isError;
20082 function isFunction(arg) {
20083 return typeof arg === 'function';
20085 exports.isFunction = isFunction;
20087 function isPrimitive(arg) {
20088 return arg === null ||
20089 typeof arg === 'boolean' ||
20090 typeof arg === 'number' ||
20091 typeof arg === 'string' ||
20092 typeof arg === 'symbol' || // ES6 symbol
20093 typeof arg === 'undefined';
20095 exports.isPrimitive = isPrimitive;
20097 exports.isBuffer = _dereq_('./support/isBuffer');
20099 function objectToString(o) {
20100 return Object.prototype.toString.call(o);
20105 return n <
10 ? '
0' + n.toString(
10) : n.toString(
10);
20109 var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
20110 'Oct', 'Nov', 'Dec'];
20113 function timestamp() {
20114 var d = new Date();
20115 var time = [pad(d.getHours()),
20116 pad(d.getMinutes()),
20117 pad(d.getSeconds())].join(':');
20118 return [d.getDate(), months[d.getMonth()], time].join(' ');
20122 // log is just a thin wrapper to console.log that prepends a timestamp
20123 exports.log = function() {
20124 console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
20129 * Inherit the prototype methods from one constructor into another.
20131 * The Function.prototype.inherits from lang.js rewritten as a standalone
20132 * function (not on Function.prototype). NOTE: If this file is to be loaded
20133 * during bootstrapping this function needs to be rewritten using some native
20134 * functions as prototype setup using normal JavaScript does not work as
20135 * expected during bootstrapping (see mirror.js in r114903).
20137 * @param {function} ctor Constructor function which needs to inherit the
20139 * @param {function} superCtor Constructor function to inherit prototype from.
20141 exports.inherits = _dereq_('inherits');
20143 exports._extend = function(origin, add) {
20144 // Don't do anything if add isn't an object
20145 if (!add || !isObject(add)) return origin;
20147 var keys = Object.keys(add);
20148 var i = keys.length;
20150 origin[keys[i]] = add[keys[i]];
20155 function hasOwnProperty(obj, prop) {
20156 return Object.prototype.hasOwnProperty.call(obj, prop);
20159 }).call(this,_dereq_(
"FWaASH"),typeof self !==
"undefined" ? self : typeof window !==
"undefined" ? window : {})
20160 },{
"./support/isBuffer":
5,
"FWaASH":
12,
"inherits":
11}],
7:[function(_dereq_,module,exports){
20162 },{}],
8:[function(_dereq_,module,exports){
20164 * The buffer module from node.js, for the browser.
20166 * at author Feross Aboukhadijeh
<feross@feross.org
> <http://feross.org
>
20170 var base64 = _dereq_('base64-js')
20171 var ieee754 = _dereq_('ieee754')
20173 exports.Buffer = Buffer
20174 exports.SlowBuffer = Buffer
20175 exports.INSPECT_MAX_BYTES =
50
20176 Buffer.poolSize =
8192
20179 * If `Buffer._useTypedArrays`:
20180 * === true Use Uint8Array implementation (fastest)
20181 * === false Use Object implementation (compatible down to IE6)
20183 Buffer._useTypedArrays = (function () {
20184 // Detect if browser supports Typed Arrays. Supported browsers are IE
10+, Firefox
4+,
20185 // Chrome
7+, Safari
5.1+, Opera
11.6+, iOS
4.2+. If the browser does not support adding
20186 // properties to `Uint8Array` instances, then that's the same as no `Uint8Array` support
20187 // because we need to be able to add all the node Buffer API methods. This is an issue
20188 // in Firefox
4-
29. Now fixed: https://bugzilla.mozilla.org/show_bug.cgi?id=
695438
20190 var buf = new ArrayBuffer(
0)
20191 var arr = new Uint8Array(buf)
20192 arr.foo = function () { return
42 }
20193 return
42 === arr.foo() &&
20194 typeof arr.subarray === 'function' // Chrome
9-
10 lack `subarray`
20204 * The Buffer constructor returns instances of `Uint8Array` that are augmented
20205 * with function properties for all the node `Buffer` API functions. We use
20206 * `Uint8Array` so that square bracket notation works as expected -- it returns
20209 * By augmenting the instances, we can avoid modifying the `Uint8Array`
20212 function Buffer (subject, encoding, noZero) {
20213 if (!(this instanceof Buffer))
20214 return new Buffer(subject, encoding, noZero)
20216 var type = typeof subject
20218 if (encoding === 'base64' && type === 'string') {
20219 subject = base64clean(subject)
20224 if (type === 'number')
20225 length = coerce(subject)
20226 else if (type === 'string')
20227 length = Buffer.byteLength(subject, encoding)
20228 else if (type === 'object')
20229 length = coerce(subject.length) // assume that object is array-like
20231 throw new Error('First argument needs to be a number, array or string.')
20234 if (Buffer._useTypedArrays) {
20235 // Preferred: Return an augmented `Uint8Array` instance for best performance
20236 buf = Buffer._augment(new Uint8Array(length))
20238 // Fallback: Return THIS instance of Buffer (created by `new`)
20240 buf.length = length
20241 buf._isBuffer = true
20245 if (Buffer._useTypedArrays && typeof subject.byteLength === 'number') {
20246 // Speed optimization -- use set if we're copying from a typed array
20248 } else if (isArrayish(subject)) {
20249 // Treat array-ish objects as a byte array
20250 if (Buffer.isBuffer(subject)) {
20251 for (i =
0; i < length; i++)
20252 buf[i] = subject.readUInt8(i)
20254 for (i =
0; i < length; i++)
20255 buf[i] = ((subject[i] %
256) +
256) %
256
20257 } else if (type === 'string') {
20258 buf.write(subject,
0, encoding)
20259 } else if (type === 'number' && !Buffer._useTypedArrays && !noZero) {
20260 for (i =
0; i < length; i++) {
20271 Buffer.isEncoding = function (encoding) {
20272 switch (String(encoding).toLowerCase()) {
20290 Buffer.isBuffer = function (b) {
20291 return !!(b !== null && b !== undefined && b._isBuffer)
20294 Buffer.byteLength = function (str, encoding) {
20296 str = str.toString()
20297 switch (encoding || 'utf8') {
20299 ret = str.length /
2
20303 ret = utf8ToBytes(str).length
20311 ret = base64ToBytes(str).length
20317 ret = str.length *
2
20320 throw new Error('Unknown encoding')
20325 Buffer.concat = function (list, totalLength) {
20326 assert(isArray(list), 'Usage: Buffer.concat(list[, length])')
20328 if (list.length ===
0) {
20329 return new Buffer(
0)
20330 } else if (list.length ===
1) {
20335 if (totalLength === undefined) {
20337 for (i =
0; i < list.length; i++) {
20338 totalLength += list[i].length
20342 var buf = new Buffer(totalLength)
20344 for (i =
0; i < list.length; i++) {
20346 item.copy(buf, pos)
20352 Buffer.compare = function (a, b) {
20353 assert(Buffer.isBuffer(a) && Buffer.isBuffer(b), 'Arguments must be Buffers')
20356 for (var i =
0, len = Math.min(x, y); i < len && a[i] === b[i]; i++) {}
20370 // BUFFER INSTANCE METHODS
20371 // =======================
20373 function hexWrite (buf, string, offset, length) {
20374 offset = Number(offset) ||
0
20375 var remaining = buf.length - offset
20379 length = Number(length)
20380 if (length
> remaining) {
20385 // must be an even number of digits
20386 var strLen = string.length
20387 assert(strLen %
2 ===
0, 'Invalid hex string')
20389 if (length
> strLen /
2) {
20390 length = strLen /
2
20392 for (var i =
0; i < length; i++) {
20393 var byte = parseInt(string.substr(i *
2,
2),
16)
20394 assert(!isNaN(byte), 'Invalid hex string')
20395 buf[offset + i] = byte
20400 function utf8Write (buf, string, offset, length) {
20401 var charsWritten = blitBuffer(utf8ToBytes(string), buf, offset, length)
20402 return charsWritten
20405 function asciiWrite (buf, string, offset, length) {
20406 var charsWritten = blitBuffer(asciiToBytes(string), buf, offset, length)
20407 return charsWritten
20410 function binaryWrite (buf, string, offset, length) {
20411 return asciiWrite(buf, string, offset, length)
20414 function base64Write (buf, string, offset, length) {
20415 var charsWritten = blitBuffer(base64ToBytes(string), buf, offset, length)
20416 return charsWritten
20419 function utf16leWrite (buf, string, offset, length) {
20420 var charsWritten = blitBuffer(utf16leToBytes(string), buf, offset, length)
20421 return charsWritten
20424 Buffer.prototype.write = function (string, offset, length, encoding) {
20425 // Support both (string, offset, length, encoding)
20426 // and the legacy (string, encoding, offset, length)
20427 if (isFinite(offset)) {
20428 if (!isFinite(length)) {
20433 var swap = encoding
20439 offset = Number(offset) ||
0
20440 var remaining = this.length - offset
20444 length = Number(length)
20445 if (length
> remaining) {
20449 encoding = String(encoding || 'utf8').toLowerCase()
20452 switch (encoding) {
20454 ret = hexWrite(this, string, offset, length)
20458 ret = utf8Write(this, string, offset, length)
20461 ret = asciiWrite(this, string, offset, length)
20464 ret = binaryWrite(this, string, offset, length)
20467 ret = base64Write(this, string, offset, length)
20473 ret = utf16leWrite(this, string, offset, length)
20476 throw new Error('Unknown encoding')
20481 Buffer.prototype.toString = function (encoding, start, end) {
20484 encoding = String(encoding || 'utf8').toLowerCase()
20485 start = Number(start) ||
0
20486 end = (end === undefined) ? self.length : Number(end)
20488 // Fastpath empty strings
20493 switch (encoding) {
20495 ret = hexSlice(self, start, end)
20499 ret = utf8Slice(self, start, end)
20502 ret = asciiSlice(self, start, end)
20505 ret = binarySlice(self, start, end)
20508 ret = base64Slice(self, start, end)
20514 ret = utf16leSlice(self, start, end)
20517 throw new Error('Unknown encoding')
20522 Buffer.prototype.toJSON = function () {
20525 data: Array.prototype.slice.call(this._arr || this,
0)
20529 Buffer.prototype.equals = function (b) {
20530 assert(Buffer.isBuffer(b), 'Argument must be a Buffer')
20531 return Buffer.compare(this, b) ===
0
20534 Buffer.prototype.compare = function (b) {
20535 assert(Buffer.isBuffer(b), 'Argument must be a Buffer')
20536 return Buffer.compare(this, b)
20539 // copy(targetBuffer, targetStart=
0, sourceStart=
0, sourceEnd=buffer.length)
20540 Buffer.prototype.copy = function (target, target_start, start, end) {
20543 if (!start) start =
0
20544 if (!end && end !==
0) end = this.length
20545 if (!target_start) target_start =
0
20547 // Copy
0 bytes; we're done
20548 if (end === start) return
20549 if (target.length ===
0 || source.length ===
0) return
20551 // Fatal error conditions
20552 assert(end
>= start, 'sourceEnd < sourceStart')
20553 assert(target_start
>=
0 && target_start < target.length,
20554 'targetStart out of bounds')
20555 assert(start
>=
0 && start < source.length, 'sourceStart out of bounds')
20556 assert(end
>=
0 && end <= source.length, 'sourceEnd out of bounds')
20559 if (end
> this.length)
20561 if (target.length - target_start < end - start)
20562 end = target.length - target_start + start
20564 var len = end - start
20566 if (len <
100 || !Buffer._useTypedArrays) {
20567 for (var i =
0; i < len; i++) {
20568 target[i + target_start] = this[i + start]
20571 target._set(this.subarray(start, start + len), target_start)
20575 function base64Slice (buf, start, end) {
20576 if (start ===
0 && end === buf.length) {
20577 return base64.fromByteArray(buf)
20579 return base64.fromByteArray(buf.slice(start, end))
20583 function utf8Slice (buf, start, end) {
20586 end = Math.min(buf.length, end)
20588 for (var i = start; i < end; i++) {
20589 if (buf[i] <=
0x7F) {
20590 res += decodeUtf8Char(tmp) + String.fromCharCode(buf[i])
20593 tmp += '%' + buf[i].toString(
16)
20597 return res + decodeUtf8Char(tmp)
20600 function asciiSlice (buf, start, end) {
20602 end = Math.min(buf.length, end)
20604 for (var i = start; i < end; i++) {
20605 ret += String.fromCharCode(buf[i])
20610 function binarySlice (buf, start, end) {
20611 return asciiSlice(buf, start, end)
20614 function hexSlice (buf, start, end) {
20615 var len = buf.length
20617 if (!start || start <
0) start =
0
20618 if (!end || end <
0 || end
> len) end = len
20621 for (var i = start; i < end; i++) {
20622 out += toHex(buf[i])
20627 function utf16leSlice (buf, start, end) {
20628 var bytes = buf.slice(start, end)
20630 for (var i =
0; i < bytes.length; i +=
2) {
20631 res += String.fromCharCode(bytes[i] + bytes[i +
1] *
256)
20636 Buffer.prototype.slice = function (start, end) {
20637 var len = this.length
20638 start = clamp(start, len,
0)
20639 end = clamp(end, len, len)
20641 if (Buffer._useTypedArrays) {
20642 return Buffer._augment(this.subarray(start, end))
20644 var sliceLen = end - start
20645 var newBuf = new Buffer(sliceLen, undefined, true)
20646 for (var i =
0; i < sliceLen; i++) {
20647 newBuf[i] = this[i + start]
20653 // `get` will be removed in Node
0.13+
20654 Buffer.prototype.get = function (offset) {
20655 console.log('.get() is deprecated. Access using array indexes instead.')
20656 return this.readUInt8(offset)
20659 // `set` will be removed in Node
0.13+
20660 Buffer.prototype.set = function (v, offset) {
20661 console.log('.set() is deprecated. Access using array indexes instead.')
20662 return this.writeUInt8(v, offset)
20665 Buffer.prototype.readUInt8 = function (offset, noAssert) {
20667 assert(offset !== undefined && offset !== null, 'missing offset')
20668 assert(offset < this.length, 'Trying to read beyond buffer length')
20671 if (offset
>= this.length)
20674 return this[offset]
20677 function readUInt16 (buf, offset, littleEndian, noAssert) {
20679 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20680 assert(offset !== undefined && offset !== null, 'missing offset')
20681 assert(offset +
1 < buf.length, 'Trying to read beyond buffer length')
20684 var len = buf.length
20689 if (littleEndian) {
20691 if (offset +
1 < len)
20692 val |= buf[offset +
1] <<
8
20694 val = buf[offset] <<
8
20695 if (offset +
1 < len)
20696 val |= buf[offset +
1]
20701 Buffer.prototype.readUInt16LE = function (offset, noAssert) {
20702 return readUInt16(this, offset, true, noAssert)
20705 Buffer.prototype.readUInt16BE = function (offset, noAssert) {
20706 return readUInt16(this, offset, false, noAssert)
20709 function readUInt32 (buf, offset, littleEndian, noAssert) {
20711 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20712 assert(offset !== undefined && offset !== null, 'missing offset')
20713 assert(offset +
3 < buf.length, 'Trying to read beyond buffer length')
20716 var len = buf.length
20721 if (littleEndian) {
20722 if (offset +
2 < len)
20723 val = buf[offset +
2] <<
16
20724 if (offset +
1 < len)
20725 val |= buf[offset +
1] <<
8
20727 if (offset +
3 < len)
20728 val = val + (buf[offset +
3] <<
24 >>> 0)
20730 if (offset +
1 < len)
20731 val = buf[offset +
1] <<
16
20732 if (offset +
2 < len)
20733 val |= buf[offset +
2] <<
8
20734 if (offset +
3 < len)
20735 val |= buf[offset +
3]
20736 val = val + (buf[offset] <<
24 >>> 0)
20741 Buffer.prototype.readUInt32LE = function (offset, noAssert) {
20742 return readUInt32(this, offset, true, noAssert)
20745 Buffer.prototype.readUInt32BE = function (offset, noAssert) {
20746 return readUInt32(this, offset, false, noAssert)
20749 Buffer.prototype.readInt8 = function (offset, noAssert) {
20751 assert(offset !== undefined && offset !== null,
20753 assert(offset < this.length, 'Trying to read beyond buffer length')
20756 if (offset
>= this.length)
20759 var neg = this[offset] &
0x80
20761 return (
0xff - this[offset] +
1) * -
1
20763 return this[offset]
20766 function readInt16 (buf, offset, littleEndian, noAssert) {
20768 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20769 assert(offset !== undefined && offset !== null, 'missing offset')
20770 assert(offset +
1 < buf.length, 'Trying to read beyond buffer length')
20773 var len = buf.length
20777 var val = readUInt16(buf, offset, littleEndian, true)
20778 var neg = val &
0x8000
20780 return (
0xffff - val +
1) * -
1
20785 Buffer.prototype.readInt16LE = function (offset, noAssert) {
20786 return readInt16(this, offset, true, noAssert)
20789 Buffer.prototype.readInt16BE = function (offset, noAssert) {
20790 return readInt16(this, offset, false, noAssert)
20793 function readInt32 (buf, offset, littleEndian, noAssert) {
20795 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20796 assert(offset !== undefined && offset !== null, 'missing offset')
20797 assert(offset +
3 < buf.length, 'Trying to read beyond buffer length')
20800 var len = buf.length
20804 var val = readUInt32(buf, offset, littleEndian, true)
20805 var neg = val &
0x80000000
20807 return (
0xffffffff - val +
1) * -
1
20812 Buffer.prototype.readInt32LE = function (offset, noAssert) {
20813 return readInt32(this, offset, true, noAssert)
20816 Buffer.prototype.readInt32BE = function (offset, noAssert) {
20817 return readInt32(this, offset, false, noAssert)
20820 function readFloat (buf, offset, littleEndian, noAssert) {
20822 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20823 assert(offset +
3 < buf.length, 'Trying to read beyond buffer length')
20826 return ieee754.read(buf, offset, littleEndian,
23,
4)
20829 Buffer.prototype.readFloatLE = function (offset, noAssert) {
20830 return readFloat(this, offset, true, noAssert)
20833 Buffer.prototype.readFloatBE = function (offset, noAssert) {
20834 return readFloat(this, offset, false, noAssert)
20837 function readDouble (buf, offset, littleEndian, noAssert) {
20839 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20840 assert(offset +
7 < buf.length, 'Trying to read beyond buffer length')
20843 return ieee754.read(buf, offset, littleEndian,
52,
8)
20846 Buffer.prototype.readDoubleLE = function (offset, noAssert) {
20847 return readDouble(this, offset, true, noAssert)
20850 Buffer.prototype.readDoubleBE = function (offset, noAssert) {
20851 return readDouble(this, offset, false, noAssert)
20854 Buffer.prototype.writeUInt8 = function (value, offset, noAssert) {
20856 assert(value !== undefined && value !== null, 'missing value')
20857 assert(offset !== undefined && offset !== null, 'missing offset')
20858 assert(offset < this.length, 'trying to write beyond buffer length')
20859 verifuint(value,
0xff)
20862 if (offset
>= this.length) return
20864 this[offset] = value
20868 function writeUInt16 (buf, value, offset, littleEndian, noAssert) {
20870 assert(value !== undefined && value !== null, 'missing value')
20871 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20872 assert(offset !== undefined && offset !== null, 'missing offset')
20873 assert(offset +
1 < buf.length, 'trying to write beyond buffer length')
20874 verifuint(value,
0xffff)
20877 var len = buf.length
20881 for (var i =
0, j = Math.min(len - offset,
2); i < j; i++) {
20883 (value & (
0xff << (
8 * (littleEndian ? i :
1 - i))))
>>>
20884 (littleEndian ? i :
1 - i) *
8
20889 Buffer.prototype.writeUInt16LE = function (value, offset, noAssert) {
20890 return writeUInt16(this, value, offset, true, noAssert)
20893 Buffer.prototype.writeUInt16BE = function (value, offset, noAssert) {
20894 return writeUInt16(this, value, offset, false, noAssert)
20897 function writeUInt32 (buf, value, offset, littleEndian, noAssert) {
20899 assert(value !== undefined && value !== null, 'missing value')
20900 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20901 assert(offset !== undefined && offset !== null, 'missing offset')
20902 assert(offset +
3 < buf.length, 'trying to write beyond buffer length')
20903 verifuint(value,
0xffffffff)
20906 var len = buf.length
20910 for (var i =
0, j = Math.min(len - offset,
4); i < j; i++) {
20912 (value
>>> (littleEndian ? i :
3 - i) *
8) &
0xff
20917 Buffer.prototype.writeUInt32LE = function (value, offset, noAssert) {
20918 return writeUInt32(this, value, offset, true, noAssert)
20921 Buffer.prototype.writeUInt32BE = function (value, offset, noAssert) {
20922 return writeUInt32(this, value, offset, false, noAssert)
20925 Buffer.prototype.writeInt8 = function (value, offset, noAssert) {
20927 assert(value !== undefined && value !== null, 'missing value')
20928 assert(offset !== undefined && offset !== null, 'missing offset')
20929 assert(offset < this.length, 'Trying to write beyond buffer length')
20930 verifsint(value,
0x7f, -
0x80)
20933 if (offset
>= this.length)
20937 this.writeUInt8(value, offset, noAssert)
20939 this.writeUInt8(
0xff + value +
1, offset, noAssert)
20943 function writeInt16 (buf, value, offset, littleEndian, noAssert) {
20945 assert(value !== undefined && value !== null, 'missing value')
20946 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20947 assert(offset !== undefined && offset !== null, 'missing offset')
20948 assert(offset +
1 < buf.length, 'Trying to write beyond buffer length')
20949 verifsint(value,
0x7fff, -
0x8000)
20952 var len = buf.length
20957 writeUInt16(buf, value, offset, littleEndian, noAssert)
20959 writeUInt16(buf,
0xffff + value +
1, offset, littleEndian, noAssert)
20963 Buffer.prototype.writeInt16LE = function (value, offset, noAssert) {
20964 return writeInt16(this, value, offset, true, noAssert)
20967 Buffer.prototype.writeInt16BE = function (value, offset, noAssert) {
20968 return writeInt16(this, value, offset, false, noAssert)
20971 function writeInt32 (buf, value, offset, littleEndian, noAssert) {
20973 assert(value !== undefined && value !== null, 'missing value')
20974 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20975 assert(offset !== undefined && offset !== null, 'missing offset')
20976 assert(offset +
3 < buf.length, 'Trying to write beyond buffer length')
20977 verifsint(value,
0x7fffffff, -
0x80000000)
20980 var len = buf.length
20985 writeUInt32(buf, value, offset, littleEndian, noAssert)
20987 writeUInt32(buf,
0xffffffff + value +
1, offset, littleEndian, noAssert)
20991 Buffer.prototype.writeInt32LE = function (value, offset, noAssert) {
20992 return writeInt32(this, value, offset, true, noAssert)
20995 Buffer.prototype.writeInt32BE = function (value, offset, noAssert) {
20996 return writeInt32(this, value, offset, false, noAssert)
20999 function writeFloat (buf, value, offset, littleEndian, noAssert) {
21001 assert(value !== undefined && value !== null, 'missing value')
21002 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
21003 assert(offset !== undefined && offset !== null, 'missing offset')
21004 assert(offset +
3 < buf.length, 'Trying to write beyond buffer length')
21005 verifIEEE754(value,
3.4028234663852886e+38, -
3.4028234663852886e+38)
21008 var len = buf.length
21012 ieee754.write(buf, value, offset, littleEndian,
23,
4)
21016 Buffer.prototype.writeFloatLE = function (value, offset, noAssert) {
21017 return writeFloat(this, value, offset, true, noAssert)
21020 Buffer.prototype.writeFloatBE = function (value, offset, noAssert) {
21021 return writeFloat(this, value, offset, false, noAssert)
21024 function writeDouble (buf, value, offset, littleEndian, noAssert) {
21026 assert(value !== undefined && value !== null, 'missing value')
21027 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
21028 assert(offset !== undefined && offset !== null, 'missing offset')
21029 assert(offset +
7 < buf.length,
21030 'Trying to write beyond buffer length')
21031 verifIEEE754(value,
1.7976931348623157E+308, -
1.7976931348623157E+308)
21034 var len = buf.length
21038 ieee754.write(buf, value, offset, littleEndian,
52,
8)
21042 Buffer.prototype.writeDoubleLE = function (value, offset, noAssert) {
21043 return writeDouble(this, value, offset, true, noAssert)
21046 Buffer.prototype.writeDoubleBE = function (value, offset, noAssert) {
21047 return writeDouble(this, value, offset, false, noAssert)
21050 // fill(value, start=
0, end=buffer.length)
21051 Buffer.prototype.fill = function (value, start, end) {
21052 if (!value) value =
0
21053 if (!start) start =
0
21054 if (!end) end = this.length
21056 assert(end
>= start, 'end < start')
21058 // Fill
0 bytes; we're done
21059 if (end === start) return
21060 if (this.length ===
0) return
21062 assert(start
>=
0 && start < this.length, 'start out of bounds')
21063 assert(end
>=
0 && end <= this.length, 'end out of bounds')
21066 if (typeof value === 'number') {
21067 for (i = start; i < end; i++) {
21071 var bytes = utf8ToBytes(value.toString())
21072 var len = bytes.length
21073 for (i = start; i < end; i++) {
21074 this[i] = bytes[i % len]
21081 Buffer.prototype.inspect = function () {
21083 var len = this.length
21084 for (var i =
0; i < len; i++) {
21085 out[i] = toHex(this[i])
21086 if (i === exports.INSPECT_MAX_BYTES) {
21091 return '
<Buffer ' + out.join(' ') + '
>'
21095 * Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance.
21096 * Added in Node
0.12. Only available in browsers that support ArrayBuffer.
21098 Buffer.prototype.toArrayBuffer = function () {
21099 if (typeof Uint8Array !== 'undefined') {
21100 if (Buffer._useTypedArrays) {
21101 return (new Buffer(this)).buffer
21103 var buf = new Uint8Array(this.length)
21104 for (var i =
0, len = buf.length; i < len; i +=
1) {
21110 throw new Error('Buffer.toArrayBuffer not supported in this browser')
21114 // HELPER FUNCTIONS
21115 // ================
21117 var BP = Buffer.prototype
21120 * Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods
21122 Buffer._augment = function (arr) {
21123 arr._isBuffer = true
21125 // save reference to original Uint8Array get/set methods before overwriting
21129 // deprecated, will be removed in node
0.13+
21133 arr.write = BP.write
21134 arr.toString = BP.toString
21135 arr.toLocaleString = BP.toString
21136 arr.toJSON = BP.toJSON
21137 arr.equals = BP.equals
21138 arr.compare = BP.compare
21140 arr.slice = BP.slice
21141 arr.readUInt8 = BP.readUInt8
21142 arr.readUInt16LE = BP.readUInt16LE
21143 arr.readUInt16BE = BP.readUInt16BE
21144 arr.readUInt32LE = BP.readUInt32LE
21145 arr.readUInt32BE = BP.readUInt32BE
21146 arr.readInt8 = BP.readInt8
21147 arr.readInt16LE = BP.readInt16LE
21148 arr.readInt16BE = BP.readInt16BE
21149 arr.readInt32LE = BP.readInt32LE
21150 arr.readInt32BE = BP.readInt32BE
21151 arr.readFloatLE = BP.readFloatLE
21152 arr.readFloatBE = BP.readFloatBE
21153 arr.readDoubleLE = BP.readDoubleLE
21154 arr.readDoubleBE = BP.readDoubleBE
21155 arr.writeUInt8 = BP.writeUInt8
21156 arr.writeUInt16LE = BP.writeUInt16LE
21157 arr.writeUInt16BE = BP.writeUInt16BE
21158 arr.writeUInt32LE = BP.writeUInt32LE
21159 arr.writeUInt32BE = BP.writeUInt32BE
21160 arr.writeInt8 = BP.writeInt8
21161 arr.writeInt16LE = BP.writeInt16LE
21162 arr.writeInt16BE = BP.writeInt16BE
21163 arr.writeInt32LE = BP.writeInt32LE
21164 arr.writeInt32BE = BP.writeInt32BE
21165 arr.writeFloatLE = BP.writeFloatLE
21166 arr.writeFloatBE = BP.writeFloatBE
21167 arr.writeDoubleLE = BP.writeDoubleLE
21168 arr.writeDoubleBE = BP.writeDoubleBE
21170 arr.inspect = BP.inspect
21171 arr.toArrayBuffer = BP.toArrayBuffer
21176 var INVALID_BASE64_RE = /[^+\/
0-
9A-z]/g
21178 function base64clean (str) {
21179 // Node strips out invalid characters like \n and \t from the string, base64-js does not
21180 str = stringtrim(str).replace(INVALID_BASE64_RE, '')
21181 // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
21182 while (str.length %
4 !==
0) {
21188 function stringtrim (str) {
21189 if (str.trim) return str.trim()
21190 return str.replace(/^\s+|\s+$/g, '')
21193 // slice(start, end)
21194 function clamp (index, len, defaultValue) {
21195 if (typeof index !== 'number') return defaultValue
21196 index = ~~index; // Coerce to integer.
21197 if (index
>= len) return len
21198 if (index
>=
0) return index
21200 if (index
>=
0) return index
21204 function coerce (length) {
21205 // Coerce length to a number (possibly NaN), round up
21206 // in case it's fractional (e.g.
123.456) then do a
21207 // double negate to coerce a NaN to
0. Easy, right?
21208 length = ~~Math.ceil(+length)
21209 return length <
0 ?
0 : length
21212 function isArray (subject) {
21213 return (Array.isArray || function (subject) {
21214 return Object.prototype.toString.call(subject) === '[object Array]'
21218 function isArrayish (subject) {
21219 return isArray(subject) || Buffer.isBuffer(subject) ||
21220 subject && typeof subject === 'object' &&
21221 typeof subject.length === 'number'
21224 function toHex (n) {
21225 if (n <
16) return '
0' + n.toString(
16)
21226 return n.toString(
16)
21229 function utf8ToBytes (str) {
21231 for (var i =
0; i < str.length; i++) {
21232 var b = str.charCodeAt(i)
21237 if (b
>=
0xD800 && b <=
0xDFFF) i++
21238 var h = encodeURIComponent(str.slice(start, i+
1)).substr(
1).split('%')
21239 for (var j =
0; j < h.length; j++) {
21240 byteArray.push(parseInt(h[j],
16))
21247 function asciiToBytes (str) {
21249 for (var i =
0; i < str.length; i++) {
21250 // Node's code seems to be doing this and not &
0x7F..
21251 byteArray.push(str.charCodeAt(i) &
0xFF)
21256 function utf16leToBytes (str) {
21259 for (var i =
0; i < str.length; i++) {
21260 c = str.charCodeAt(i)
21270 function base64ToBytes (str) {
21271 return base64.toByteArray(str)
21274 function blitBuffer (src, dst, offset, length) {
21275 for (var i =
0; i < length; i++) {
21276 if ((i + offset
>= dst.length) || (i
>= src.length))
21278 dst[i + offset] = src[i]
21283 function decodeUtf8Char (str) {
21285 return decodeURIComponent(str)
21287 return String.fromCharCode(
0xFFFD) // UTF
8 invalid char
21292 * We have to make sure that the value is a valid integer. This means that it
21293 * is non-negative. It has no fractional component and that it does not
21294 * exceed the maximum allowed value.
21296 function verifuint (value, max) {
21297 assert(typeof value === 'number', 'cannot write a non-number as a number')
21298 assert(value
>=
0, 'specified a negative value for writing an unsigned value')
21299 assert(value <= max, 'value is larger than maximum value for type')
21300 assert(Math.floor(value) === value, 'value has a fractional component')
21303 function verifsint (value, max, min) {
21304 assert(typeof value === 'number', 'cannot write a non-number as a number')
21305 assert(value <= max, 'value larger than maximum allowed value')
21306 assert(value
>= min, 'value smaller than minimum allowed value')
21307 assert(Math.floor(value) === value, 'value has a fractional component')
21310 function verifIEEE754 (value, max, min) {
21311 assert(typeof value === 'number', 'cannot write a non-number as a number')
21312 assert(value <= max, 'value larger than maximum allowed value')
21313 assert(value
>= min, 'value smaller than minimum allowed value')
21316 function assert (test, message) {
21317 if (!test) throw new Error(message || 'Failed assertion')
21320 },{"base64-js":
9,"ieee754":
10}],
9:[function(_dereq_,module,exports){
21321 var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
21323 ;(function (exports) {
21326 var Arr = (typeof Uint8Array !== 'undefined')
21330 var PLUS = '+'.charCodeAt(
0)
21331 var SLASH = '/'.charCodeAt(
0)
21332 var NUMBER = '
0'.charCodeAt(
0)
21333 var LOWER = 'a'.charCodeAt(
0)
21334 var UPPER = 'A'.charCodeAt(
0)
21336 function decode (elt) {
21337 var code = elt.charCodeAt(
0)
21340 if (code === SLASH)
21343 return -
1 //no match
21344 if (code < NUMBER +
10)
21345 return code - NUMBER +
26 +
26
21346 if (code < UPPER +
26)
21347 return code - UPPER
21348 if (code < LOWER +
26)
21349 return code - LOWER +
26
21352 function b64ToByteArray (b64) {
21353 var i, j, l, tmp, placeHolders, arr
21355 if (b64.length %
4 > 0) {
21356 throw new Error('Invalid string. Length must be a multiple of
4')
21359 // the number of equal signs (place holders)
21360 // if there are two placeholders, than the two characters before it
21361 // represent one byte
21362 // if there is only one, then the three characters before it represent
2 bytes
21363 // this is just a cheap hack to not do indexOf twice
21364 var len = b64.length
21365 placeHolders = '=' === b64.charAt(len -
2) ?
2 : '=' === b64.charAt(len -
1) ?
1 :
0
21367 // base64 is
4/
3 + up to two characters of the original data
21368 arr = new Arr(b64.length *
3 /
4 - placeHolders)
21370 // if there are placeholders, only get up to the last complete
4 chars
21371 l = placeHolders
> 0 ? b64.length -
4 : b64.length
21375 function push (v) {
21379 for (i =
0, j =
0; i < l; i +=
4, j +=
3) {
21380 tmp = (decode(b64.charAt(i)) <<
18) | (decode(b64.charAt(i +
1)) <<
12) | (decode(b64.charAt(i +
2)) <<
6) | decode(b64.charAt(i +
3))
21381 push((tmp &
0xFF0000)
>> 16)
21382 push((tmp &
0xFF00)
>> 8)
21386 if (placeHolders ===
2) {
21387 tmp = (decode(b64.charAt(i)) <<
2) | (decode(b64.charAt(i +
1))
>> 4)
21389 } else if (placeHolders ===
1) {
21390 tmp = (decode(b64.charAt(i)) <<
10) | (decode(b64.charAt(i +
1)) <<
4) | (decode(b64.charAt(i +
2))
>> 2)
21391 push((tmp
>> 8) &
0xFF)
21398 function uint8ToBase64 (uint8) {
21400 extraBytes = uint8.length %
3, // if we have
1 byte left, pad
2 bytes
21404 function encode (num) {
21405 return lookup.charAt(num)
21408 function tripletToBase64 (num) {
21409 return encode(num
>> 18 &
0x3F) + encode(num
>> 12 &
0x3F) + encode(num
>> 6 &
0x3F) + encode(num &
0x3F)
21412 // go through the array every three bytes, we'll deal with trailing stuff later
21413 for (i =
0, length = uint8.length - extraBytes; i < length; i +=
3) {
21414 temp = (uint8[i] <<
16) + (uint8[i +
1] <<
8) + (uint8[i +
2])
21415 output += tripletToBase64(temp)
21418 // pad the end with zeros, but make sure to not forget the extra bytes
21419 switch (extraBytes) {
21421 temp = uint8[uint8.length -
1]
21422 output += encode(temp
>> 2)
21423 output += encode((temp <<
4) &
0x3F)
21427 temp = (uint8[uint8.length -
2] <<
8) + (uint8[uint8.length -
1])
21428 output += encode(temp
>> 10)
21429 output += encode((temp
>> 4) &
0x3F)
21430 output += encode((temp <<
2) &
0x3F)
21438 exports.toByteArray = b64ToByteArray
21439 exports.fromByteArray = uint8ToBase64
21440 }(typeof exports === 'undefined' ? (this.base64js = {}) : exports))
21442 },{}],
10:[function(_dereq_,module,exports){
21443 exports.read = function(buffer, offset, isLE, mLen, nBytes) {
21445 eLen = nBytes *
8 - mLen -
1,
21446 eMax = (
1 << eLen) -
1,
21449 i = isLE ? (nBytes -
1) :
0,
21451 s = buffer[offset + i];
21455 e = s & ((
1 << (-nBits)) -
1);
21458 for (; nBits
> 0; e = e *
256 + buffer[offset + i], i += d, nBits -=
8){};
21460 m = e & ((
1 << (-nBits)) -
1);
21463 for (; nBits
> 0; m = m *
256 + buffer[offset + i], i += d, nBits -=
8){};
21467 } else if (e === eMax) {
21468 return m ? NaN : ((s ? -
1 :
1) * Infinity);
21470 m = m + Math.pow(
2, mLen);
21473 return (s ? -
1 :
1) * m * Math.pow(
2, e - mLen);
21476 exports.write = function(buffer, value, offset, isLE, mLen, nBytes) {
21478 eLen = nBytes *
8 - mLen -
1,
21479 eMax = (
1 << eLen) -
1,
21481 rt = (mLen ===
23 ? Math.pow(
2, -
24) - Math.pow(
2, -
77) :
0),
21482 i = isLE ?
0 : (nBytes -
1),
21484 s = value <
0 || (value ===
0 &&
1 / value <
0) ?
1 :
0;
21486 value = Math.abs(value);
21488 if (isNaN(value) || value === Infinity) {
21489 m = isNaN(value) ?
1 :
0;
21492 e = Math.floor(Math.log(value) / Math.LN2);
21493 if (value * (c = Math.pow(
2, -e)) <
1) {
21497 if (e + eBias
>=
1) {
21500 value += rt * Math.pow(
2,
1 - eBias);
21502 if (value * c
>=
2) {
21507 if (e + eBias
>= eMax) {
21510 } else if (e + eBias
>=
1) {
21511 m = (value * c -
1) * Math.pow(
2, mLen);
21514 m = value * Math.pow(
2, eBias -
1) * Math.pow(
2, mLen);
21519 for (; mLen
>=
8; buffer[offset + i] = m &
0xff, i += d, m /=
256, mLen -=
8){};
21521 e = (e << mLen) | m;
21523 for (; eLen
> 0; buffer[offset + i] = e &
0xff, i += d, e /=
256, eLen -=
8){};
21525 buffer[offset + i - d] |= s *
128;
21528 },{}],
11:[function(_dereq_,module,exports){
21529 if (typeof Object.create === 'function') {
21530 // implementation from standard node.js 'util' module
21531 module.exports = function inherits(ctor, superCtor) {
21532 ctor.super_ = superCtor
21533 ctor.prototype = Object.create(superCtor.prototype, {
21543 // old school shim for old browsers
21544 module.exports = function inherits(ctor, superCtor) {
21545 ctor.super_ = superCtor
21546 var TempCtor = function () {}
21547 TempCtor.prototype = superCtor.prototype
21548 ctor.prototype = new TempCtor()
21549 ctor.prototype.constructor = ctor
21553 },{}],
12:[function(_dereq_,module,exports){
21554 // shim for using process in browser
21556 var process = module.exports = {};
21558 process.nextTick = (function () {
21559 var canSetImmediate = typeof window !== 'undefined'
21560 && window.setImmediate;
21561 var canPost = typeof window !== 'undefined'
21562 && window.postMessage && window.addEventListener
21565 if (canSetImmediate) {
21566 return function (f) { return window.setImmediate(f) };
21571 window.addEventListener('message', function (ev) {
21572 var source = ev.source;
21573 if ((source === window || source === null) && ev.data === 'process-tick') {
21574 ev.stopPropagation();
21575 if (queue.length
> 0) {
21576 var fn = queue.shift();
21582 return function nextTick(fn) {
21584 window.postMessage('process-tick', '*');
21588 return function nextTick(fn) {
21593 process.title = 'browser';
21594 process.browser = true;
21601 process.addListener = noop;
21602 process.once = noop;
21603 process.off = noop;
21604 process.removeListener = noop;
21605 process.removeAllListeners = noop;
21606 process.emit = noop;
21608 process.binding = function (name) {
21609 throw new Error('process.binding is not supported');
21613 process.cwd = function () { return '/' };
21614 process.chdir = function (dir) {
21615 throw new Error('process.chdir is not supported');
21618 },{}],
13:[function(_dereq_,module,exports){
21619 module.exports=_dereq_(
5)
21620 },{}],
14:[function(_dereq_,module,exports){
21621 module.exports=_dereq_(
6)
21622 },{
"./support/isBuffer":
13,
"FWaASH":
12,
"inherits":
11}],
15:[function(_dereq_,module,exports){
21623 (function (Buffer){
21624 // Base58 encoding/decoding
21625 // Originally written by Mike Hearn for BitcoinJ
21626 // Copyright (c)
2011 Google Inc
21627 // Ported to JavaScript by Stefan Thomas
21628 // Merged Buffer refactorings from base58-native by Stephen Pair
21629 // Copyright (c)
2013 BitPay Inc
21631 var assert = _dereq_('assert')
21632 var BigInteger = _dereq_('bigi')
21634 var ALPHABET = '
123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
21635 var ALPHABET_BUF = new Buffer(ALPHABET, 'ascii')
21636 var ALPHABET_MAP = {}
21637 for(var i =
0; i < ALPHABET.length; i++) {
21638 ALPHABET_MAP[ALPHABET.charAt(i)] = BigInteger.valueOf(i)
21640 var BASE = new BigInteger('
58')
21642 function encode(buffer) {
21643 var bi = BigInteger.fromBuffer(buffer)
21644 var result = new Buffer(buffer.length <<
1)
21646 var i = result.length -
1
21647 while (bi.signum()
> 0) {
21648 var remainder = bi.mod(BASE)
21649 bi = bi.divide(BASE)
21651 result[i] = ALPHABET_BUF[remainder.intValue()]
21655 // deal with leading zeros
21657 while (buffer[j] ===
0) {
21658 result[i] = ALPHABET_BUF[
0]
21663 return result.slice(i +
1, result.length).toString('ascii')
21666 function decode(string) {
21667 if (string.length ===
0) return new Buffer(
0)
21669 var num = BigInteger.ZERO
21671 for (var i =
0; i < string.length; i++) {
21672 num = num.multiply(BASE)
21674 var figure = ALPHABET_MAP[string.charAt(i)]
21675 assert.notEqual(figure, undefined, 'Non-base58 character')
21677 num = num.add(figure)
21680 // deal with leading zeros
21682 while ((j < string.length) && (string[j] === ALPHABET[
0])) {
21686 var buffer = num.toBuffer()
21687 var leadingZeros = new Buffer(j)
21688 leadingZeros.fill(
0)
21690 return Buffer.concat([leadingZeros, buffer])
21698 }).call(this,_dereq_(
"buffer").Buffer)
21699 },{
"assert":
4,
"bigi":
3,
"buffer":
8}],
16:[function(_dereq_,module,exports){
21700 (function (Buffer){
21701 var createHash = _dereq_('sha.js')
21703 var md5 = toConstructor(_dereq_('./md5'))
21704 var rmd160 = toConstructor(_dereq_('ripemd160'))
21706 function toConstructor (fn) {
21707 return function () {
21710 update: function (data, enc) {
21711 if(!Buffer.isBuffer(data)) data = new Buffer(data, enc)
21715 digest: function (enc) {
21716 var buf = Buffer.concat(buffers)
21719 return enc ? r.toString(enc) : r
21726 module.exports = function (alg) {
21727 if('md5' === alg) return new md5()
21728 if('rmd160' === alg) return new rmd160()
21729 return createHash(alg)
21732 }).call(this,_dereq_(
"buffer").Buffer)
21733 },{
"./md5":
20,
"buffer":
8,
"ripemd160":
21,
"sha.js":
23}],
17:[function(_dereq_,module,exports){
21734 (function (Buffer){
21735 var createHash = _dereq_('./create-hash')
21738 var zeroBuffer = new Buffer(blocksize); zeroBuffer.fill(
0)
21740 module.exports = Hmac
21742 function Hmac (alg, key) {
21743 if(!(this instanceof Hmac)) return new Hmac(alg, key)
21747 key = this._key = !Buffer.isBuffer(key) ? new Buffer(key) : key
21749 if(key.length
> blocksize) {
21750 key = createHash(alg).update(key).digest()
21751 } else if(key.length < blocksize) {
21752 key = Buffer.concat([key, zeroBuffer], blocksize)
21755 var ipad = this._ipad = new Buffer(blocksize)
21756 var opad = this._opad = new Buffer(blocksize)
21758 for(var i =
0; i < blocksize; i++) {
21759 ipad[i] = key[i] ^
0x36
21760 opad[i] = key[i] ^
0x5C
21763 this._hash = createHash(alg).update(ipad)
21766 Hmac.prototype.update = function (data, enc) {
21767 this._hash.update(data, enc)
21771 Hmac.prototype.digest = function (enc) {
21772 var h = this._hash.digest()
21773 return createHash(this._alg).update(this._opad).update(h).digest(enc)
21777 }).call(this,_dereq_("buffer").Buffer)
21778 },{"./create-hash":
16,"buffer":
8}],
18:[function(_dereq_,module,exports){
21779 (function (Buffer){
21781 var zeroBuffer = new Buffer(intSize); zeroBuffer.fill(
0);
21784 function toArray(buf, bigEndian) {
21785 if ((buf.length % intSize) !==
0) {
21786 var len = buf.length + (intSize - (buf.length % intSize));
21787 buf = Buffer.concat([buf, zeroBuffer], len);
21791 var fn = bigEndian ? buf.readInt32BE : buf.readInt32LE;
21792 for (var i =
0; i < buf.length; i += intSize) {
21793 arr.push(fn.call(buf, i));
21798 function toBuffer(arr, size, bigEndian) {
21799 var buf = new Buffer(size);
21800 var fn = bigEndian ? buf.writeInt32BE : buf.writeInt32LE;
21801 for (var i =
0; i < arr.length; i++) {
21802 fn.call(buf, arr[i], i *
4, true);
21807 function hash(buf, fn, hashSize, bigEndian) {
21808 if (!Buffer.isBuffer(buf)) buf = new Buffer(buf);
21809 var arr = fn(toArray(buf, bigEndian), buf.length * chrsz);
21810 return toBuffer(arr, hashSize, bigEndian);
21813 module.exports = { hash: hash };
21815 }).call(this,_dereq_("buffer").Buffer)
21816 },{"buffer":
8}],
19:[function(_dereq_,module,exports){
21817 (function (Buffer){
21818 var rng = _dereq_('./rng')
21820 function error () {
21821 var m = [].slice.call(arguments).join(' ')
21824 'we accept pull requests',
21825 'http://github.com/dominictarr/crypto-browserify'
21829 exports.createHash = _dereq_('./create-hash')
21831 exports.createHmac = _dereq_('./create-hmac')
21833 exports.randomBytes = function(size, callback) {
21834 if (callback && callback.call) {
21836 callback.call(this, undefined, new Buffer(rng(size)))
21837 } catch (err) { callback(err) }
21839 return new Buffer(rng(size))
21843 function each(a, f) {
21848 exports.getHashes = function () {
21849 return ['sha1', 'sha256', 'md5', 'rmd160']
21853 var p = _dereq_('./pbkdf2')(exports.createHmac)
21854 exports.pbkdf2 = p.pbkdf2
21855 exports.pbkdf2Sync = p.pbkdf2Sync
21858 // the least I can do is make error messages for the rest of the node.js/crypto api.
21859 each(['createCredentials'
21863 , 'createDecipheriv'
21866 , 'createDiffieHellman'
21867 ], function (name) {
21868 exports[name] = function () {
21869 error('sorry,', name, 'is not implemented yet')
21873 }).call(this,_dereq_("buffer").Buffer)
21874 },{"./create-hash":
16,"./create-hmac":
17,"./pbkdf2":
27,"./rng":
28,"buffer":
8}],
20:[function(_dereq_,module,exports){
21876 * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
21877 * Digest Algorithm, as defined in RFC
1321.
21878 * Version
2.1 Copyright (C) Paul Johnston
1999 -
2002.
21879 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
21880 * Distributed under the BSD License
21881 * See http://pajhome.org.uk/crypt/md5 for more info.
21884 var helpers = _dereq_('./helpers');
21887 * Calculate the MD5 of an array of little-endian words, and a bit length
21889 function core_md5(x, len)
21891 /* append padding */
21892 x[len
>> 5] |=
0x80 << ((len) %
32);
21893 x[(((len +
64)
>>> 9) <<
4) +
14] = len;
21895 var a =
1732584193;
21896 var b = -
271733879;
21897 var c = -
1732584194;
21900 for(var i =
0; i < x.length; i +=
16)
21907 a = md5_ff(a, b, c, d, x[i+
0],
7 , -
680876936);
21908 d = md5_ff(d, a, b, c, x[i+
1],
12, -
389564586);
21909 c = md5_ff(c, d, a, b, x[i+
2],
17,
606105819);
21910 b = md5_ff(b, c, d, a, x[i+
3],
22, -
1044525330);
21911 a = md5_ff(a, b, c, d, x[i+
4],
7 , -
176418897);
21912 d = md5_ff(d, a, b, c, x[i+
5],
12,
1200080426);
21913 c = md5_ff(c, d, a, b, x[i+
6],
17, -
1473231341);
21914 b = md5_ff(b, c, d, a, x[i+
7],
22, -
45705983);
21915 a = md5_ff(a, b, c, d, x[i+
8],
7 ,
1770035416);
21916 d = md5_ff(d, a, b, c, x[i+
9],
12, -
1958414417);
21917 c = md5_ff(c, d, a, b, x[i+
10],
17, -
42063);
21918 b = md5_ff(b, c, d, a, x[i+
11],
22, -
1990404162);
21919 a = md5_ff(a, b, c, d, x[i+
12],
7 ,
1804603682);
21920 d = md5_ff(d, a, b, c, x[i+
13],
12, -
40341101);
21921 c = md5_ff(c, d, a, b, x[i+
14],
17, -
1502002290);
21922 b = md5_ff(b, c, d, a, x[i+
15],
22,
1236535329);
21924 a = md5_gg(a, b, c, d, x[i+
1],
5 , -
165796510);
21925 d = md5_gg(d, a, b, c, x[i+
6],
9 , -
1069501632);
21926 c = md5_gg(c, d, a, b, x[i+
11],
14,
643717713);
21927 b = md5_gg(b, c, d, a, x[i+
0],
20, -
373897302);
21928 a = md5_gg(a, b, c, d, x[i+
5],
5 , -
701558691);
21929 d = md5_gg(d, a, b, c, x[i+
10],
9 ,
38016083);
21930 c = md5_gg(c, d, a, b, x[i+
15],
14, -
660478335);
21931 b = md5_gg(b, c, d, a, x[i+
4],
20, -
405537848);
21932 a = md5_gg(a, b, c, d, x[i+
9],
5 ,
568446438);
21933 d = md5_gg(d, a, b, c, x[i+
14],
9 , -
1019803690);
21934 c = md5_gg(c, d, a, b, x[i+
3],
14, -
187363961);
21935 b = md5_gg(b, c, d, a, x[i+
8],
20,
1163531501);
21936 a = md5_gg(a, b, c, d, x[i+
13],
5 , -
1444681467);
21937 d = md5_gg(d, a, b, c, x[i+
2],
9 , -
51403784);
21938 c = md5_gg(c, d, a, b, x[i+
7],
14,
1735328473);
21939 b = md5_gg(b, c, d, a, x[i+
12],
20, -
1926607734);
21941 a = md5_hh(a, b, c, d, x[i+
5],
4 , -
378558);
21942 d = md5_hh(d, a, b, c, x[i+
8],
11, -
2022574463);
21943 c = md5_hh(c, d, a, b, x[i+
11],
16,
1839030562);
21944 b = md5_hh(b, c, d, a, x[i+
14],
23, -
35309556);
21945 a = md5_hh(a, b, c, d, x[i+
1],
4 , -
1530992060);
21946 d = md5_hh(d, a, b, c, x[i+
4],
11,
1272893353);
21947 c = md5_hh(c, d, a, b, x[i+
7],
16, -
155497632);
21948 b = md5_hh(b, c, d, a, x[i+
10],
23, -
1094730640);
21949 a = md5_hh(a, b, c, d, x[i+
13],
4 ,
681279174);
21950 d = md5_hh(d, a, b, c, x[i+
0],
11, -
358537222);
21951 c = md5_hh(c, d, a, b, x[i+
3],
16, -
722521979);
21952 b = md5_hh(b, c, d, a, x[i+
6],
23,
76029189);
21953 a = md5_hh(a, b, c, d, x[i+
9],
4 , -
640364487);
21954 d = md5_hh(d, a, b, c, x[i+
12],
11, -
421815835);
21955 c = md5_hh(c, d, a, b, x[i+
15],
16,
530742520);
21956 b = md5_hh(b, c, d, a, x[i+
2],
23, -
995338651);
21958 a = md5_ii(a, b, c, d, x[i+
0],
6 , -
198630844);
21959 d = md5_ii(d, a, b, c, x[i+
7],
10,
1126891415);
21960 c = md5_ii(c, d, a, b, x[i+
14],
15, -
1416354905);
21961 b = md5_ii(b, c, d, a, x[i+
5],
21, -
57434055);
21962 a = md5_ii(a, b, c, d, x[i+
12],
6 ,
1700485571);
21963 d = md5_ii(d, a, b, c, x[i+
3],
10, -
1894986606);
21964 c = md5_ii(c, d, a, b, x[i+
10],
15, -
1051523);
21965 b = md5_ii(b, c, d, a, x[i+
1],
21, -
2054922799);
21966 a = md5_ii(a, b, c, d, x[i+
8],
6 ,
1873313359);
21967 d = md5_ii(d, a, b, c, x[i+
15],
10, -
30611744);
21968 c = md5_ii(c, d, a, b, x[i+
6],
15, -
1560198380);
21969 b = md5_ii(b, c, d, a, x[i+
13],
21,
1309151649);
21970 a = md5_ii(a, b, c, d, x[i+
4],
6 , -
145523070);
21971 d = md5_ii(d, a, b, c, x[i+
11],
10, -
1120210379);
21972 c = md5_ii(c, d, a, b, x[i+
2],
15,
718787259);
21973 b = md5_ii(b, c, d, a, x[i+
9],
21, -
343485551);
21975 a = safe_add(a, olda);
21976 b = safe_add(b, oldb);
21977 c = safe_add(c, oldc);
21978 d = safe_add(d, oldd);
21980 return Array(a, b, c, d);
21985 * These functions implement the four basic operations the algorithm uses.
21987 function md5_cmn(q, a, b, x, s, t)
21989 return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
21991 function md5_ff(a, b, c, d, x, s, t)
21993 return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
21995 function md5_gg(a, b, c, d, x, s, t)
21997 return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
21999 function md5_hh(a, b, c, d, x, s, t)
22001 return md5_cmn(b ^ c ^ d, a, b, x, s, t);
22003 function md5_ii(a, b, c, d, x, s, t)
22005 return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
22009 * Add integers, wrapping at
2^
32. This uses
16-bit operations internally
22010 * to work around bugs in some JS interpreters.
22012 function safe_add(x, y)
22014 var lsw = (x &
0xFFFF) + (y &
0xFFFF);
22015 var msw = (x
>> 16) + (y
>> 16) + (lsw
>> 16);
22016 return (msw <<
16) | (lsw &
0xFFFF);
22020 * Bitwise rotate a
32-bit number to the left.
22022 function bit_rol(num, cnt)
22024 return (num << cnt) | (num
>>> (
32 - cnt));
22027 module.exports = function md5(buf) {
22028 return helpers.hash(buf, core_md5,
16);
22031 },{"./helpers":
18}],
21:[function(_dereq_,module,exports){
22032 (function (Buffer){
22034 module.exports = ripemd160
22040 code.google.com/p/crypto-js
22041 (c)
2009-
2013 by Jeff Mott. All rights reserved.
22042 code.google.com/p/crypto-js/wiki/License
22045 (c)
2012 by Cédric Mesnil. All rights reserved.
22047 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
22049 - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
22050 - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
22052 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22057 0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
22058 7,
4,
13,
1,
10,
6,
15,
3,
12,
0,
9,
5,
2,
14,
11,
8,
22059 3,
10,
14,
4,
9,
15,
8,
1,
2,
7,
0,
6,
13,
11,
5,
12,
22060 1,
9,
11,
10,
0,
8,
12,
4,
13,
3,
7,
15,
14,
5,
6,
2,
22061 4,
0,
5,
9,
7,
12,
2,
10,
14,
1,
3,
8,
11,
6,
15,
13];
22063 5,
14,
7,
0,
9,
2,
11,
4,
13,
6,
15,
8,
1,
10,
3,
12,
22064 6,
11,
3,
7,
0,
13,
5,
10,
14,
15,
8,
12,
4,
9,
1,
2,
22065 15,
5,
1,
3,
7,
14,
6,
9,
11,
8,
12,
2,
10,
0,
4,
13,
22066 8,
6,
4,
1,
3,
11,
15,
0,
5,
12,
2,
13,
9,
7,
10,
14,
22067 12,
15,
10,
4,
1,
5,
8,
7,
6,
2,
13,
14,
0,
3,
9,
11];
22069 11,
14,
15,
12,
5,
8,
7,
9,
11,
13,
14,
15,
6,
7,
9,
8,
22070 7,
6,
8,
13,
11,
9,
7,
15,
7,
12,
15,
9,
11,
7,
13,
12,
22071 11,
13,
6,
7,
14,
9,
13,
15,
14,
8,
13,
6,
5,
12,
7,
5,
22072 11,
12,
14,
15,
14,
15,
9,
8,
9,
14,
5,
6,
8,
6,
5,
12,
22073 9,
15,
5,
11,
6,
8,
13,
12,
5,
12,
13,
14,
11,
8,
5,
6 ];
22075 8,
9,
9,
11,
13,
15,
15,
5,
7,
7,
8,
11,
14,
14,
12,
6,
22076 9,
13,
15,
7,
12,
8,
9,
11,
7,
7,
12,
7,
6,
15,
13,
11,
22077 9,
7,
15,
11,
8,
6,
6,
14,
12,
13,
5,
14,
13,
13,
7,
5,
22078 15,
5,
8,
11,
14,
14,
6,
14,
6,
9,
12,
9,
12,
5,
15,
8,
22079 8,
5,
12,
9,
12,
5,
14,
6,
8,
13,
6,
5,
15,
13,
11,
11 ];
22081 var hl = [
0x00000000,
0x5A827999,
0x6ED9EBA1,
0x8F1BBCDC,
0xA953FD4E];
22082 var hr = [
0x50A28BE6,
0x5C4DD124,
0x6D703EF3,
0x7A6D76E9,
0x00000000];
22084 var bytesToWords = function (bytes) {
22086 for (var i =
0, b =
0; i < bytes.length; i++, b +=
8) {
22087 words[b
>>> 5] |= bytes[i] << (
24 - b %
32);
22092 var wordsToBytes = function (words) {
22094 for (var b =
0; b < words.length *
32; b +=
8) {
22095 bytes.push((words[b
>>> 5]
>>> (
24 - b %
32)) &
0xFF);
22100 var processBlock = function (H, M, offset) {
22103 for (var i =
0; i <
16; i++) {
22104 var offset_i = offset + i;
22105 var M_offset_i = M[offset_i];
22109 (((M_offset_i <<
8) | (M_offset_i
>>> 24)) &
0x00ff00ff) |
22110 (((M_offset_i <<
24) | (M_offset_i
>>> 8)) &
0xff00ff00)
22114 // Working variables
22115 var al, bl, cl, dl, el;
22116 var ar, br, cr, dr, er;
22125 for (var i =
0; i <
80; i +=
1) {
22126 t = (al + M[offset+zl[i]])|
0;
22128 t += f1(bl,cl,dl) + hl[
0];
22130 t += f2(bl,cl,dl) + hl[
1];
22132 t += f3(bl,cl,dl) + hl[
2];
22134 t += f4(bl,cl,dl) + hl[
3];
22135 } else {// if (i
<80) {
22136 t += f5(bl,cl,dl) + hl[
4];
22147 t = (ar + M[offset+zr[i]])|
0;
22149 t += f5(br,cr,dr) + hr[
0];
22151 t += f4(br,cr,dr) + hr[
1];
22153 t += f3(br,cr,dr) + hr[
2];
22155 t += f2(br,cr,dr) + hr[
3];
22156 } else {// if (i
<80) {
22157 t += f1(br,cr,dr) + hr[
4];
22160 t = rotl(t,sr[i]) ;
22168 // Intermediate hash value
22169 t = (H[
1] + cl + dr)|
0;
22170 H[
1] = (H[
2] + dl + er)|
0;
22171 H[
2] = (H[
3] + el + ar)|
0;
22172 H[
3] = (H[
4] + al + br)|
0;
22173 H[
4] = (H[
0] + bl + cr)|
0;
22177 function f1(x, y, z) {
22178 return ((x) ^ (y) ^ (z));
22181 function f2(x, y, z) {
22182 return (((x)&(y)) | ((~x)&(z)));
22185 function f3(x, y, z) {
22186 return (((x) | (~(y))) ^ (z));
22189 function f4(x, y, z) {
22190 return (((x) & (z)) | ((y)&(~(z))));
22193 function f5(x, y, z) {
22194 return ((x) ^ ((y) |(~(z))));
22197 function rotl(x,n) {
22198 return (x<
<n) | (x
>>>(
32-n));
22201 function ripemd160(message) {
22202 var H = [
0x67452301,
0xEFCDAB89,
0x98BADCFE,
0x10325476,
0xC3D2E1F0];
22204 if (typeof message == 'string')
22205 message = new Buffer(message, 'utf8');
22207 var m = bytesToWords(message);
22209 var nBitsLeft = message.length *
8;
22210 var nBitsTotal = message.length *
8;
22213 m[nBitsLeft
>>> 5] |=
0x80 << (
24 - nBitsLeft %
32);
22214 m[(((nBitsLeft +
64)
>>> 9) <<
4) +
14] = (
22215 (((nBitsTotal <<
8) | (nBitsTotal
>>> 24)) &
0x00ff00ff) |
22216 (((nBitsTotal <<
24) | (nBitsTotal
>>> 8)) &
0xff00ff00)
22219 for (var i=
0 ; i
<m.length; i +=
16) {
22220 processBlock(H, m, i);
22224 for (var i =
0; i <
5; i++) {
22229 H[i] = (((H_i <<
8) | (H_i
>>> 24)) &
0x00ff00ff) |
22230 (((H_i <<
24) | (H_i
>>> 8)) &
0xff00ff00);
22233 var digestbytes = wordsToBytes(H);
22234 return new Buffer(digestbytes);
22239 }).call(this,_dereq_(
"buffer").Buffer)
22240 },{
"buffer":
8}],
22:[function(_dereq_,module,exports){
22241 var u = _dereq_('./util')
22242 var write = u.write
22243 var fill = u.zeroFill
22245 module.exports = function (Buffer) {
22247 //prototype class for hash functions
22248 function Hash (blockSize, finalSize) {
22249 this._block = new Buffer(blockSize) //new Uint32Array(blockSize/
4)
22250 this._finalSize = finalSize
22251 this._blockSize = blockSize
22256 Hash.prototype.init = function () {
22261 function lengthOf(data, enc) {
22262 if(enc == null) return data.byteLength || data.length
22263 if(enc == 'ascii' || enc == 'binary') return data.length
22264 if(enc == 'hex') return data.length/
2
22265 if(enc == 'base64') return data.length/
3
22268 Hash.prototype.update = function (data, enc) {
22269 var bl = this._blockSize
22271 //I'd rather do this with a streaming encoder, like the opposite of
22272 //http://nodejs.org/api/string_decoder.html
22274 if(!enc && 'string' === typeof data)
22278 if(enc === 'utf-
8')
22281 if(enc === 'base64' || enc === 'utf8')
22282 data = new Buffer(data, enc), enc = null
22284 length = lengthOf(data, enc)
22286 length = data.byteLength || data.length
22288 var l = this._len += length
22289 var s = this._s = (this._s ||
0)
22291 var buffer = this._block
22293 var t = Math.min(length, f + bl)
22294 write(buffer, data, enc, s%bl, f, t)
22299 this._update(buffer)
22307 Hash.prototype.digest = function (enc) {
22308 var bl = this._blockSize
22309 var fl = this._finalSize
22310 var len = this._len*
8
22312 var x = this._block
22314 var bits = len % (bl*
8)
22316 //add end marker, so that appending
0's creats a different hash.
22317 x[this._len % bl] =
0x80
22318 fill(this._block, this._len % bl +
1)
22321 this._update(this._block)
22322 u.zeroFill(this._block,
0)
22325 //TODO: handle case where the bit length is
> Math.pow(
2,
29)
22326 x.writeInt32BE(len, fl +
4) //big endian
22328 var hash = this._update(this._block) || this._hash()
22329 if(enc == null) return hash
22330 return hash.toString(enc)
22333 Hash.prototype._update = function () {
22334 throw new Error('_update must be implemented by subclass')
22340 },{"./util":
26}],
23:[function(_dereq_,module,exports){
22341 var exports = module.exports = function (alg) {
22342 var Alg = exports[alg]
22343 if(!Alg) throw new Error(alg + ' is not supported (we accept pull requests)')
22347 var Buffer = _dereq_('buffer').Buffer
22348 var Hash = _dereq_('./hash')(Buffer)
22351 exports.sha1 = _dereq_('./sha1')(Buffer, Hash)
22352 exports.sha256 = _dereq_('./sha256')(Buffer, Hash)
22354 },{"./hash":
22,"./sha1":
24,"./sha256":
25,"buffer":
8}],
24:[function(_dereq_,module,exports){
22356 * A JavaScript implementation of the Secure Hash Algorithm, SHA-
1, as defined
22357 * in FIPS PUB
180-
1
22358 * Version
2.1a Copyright Paul Johnston
2000 -
2002.
22359 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
22360 * Distributed under the BSD License
22361 * See http://pajhome.org.uk/crypt/md5 for details.
22363 module.exports = function (Buffer, Hash) {
22365 var inherits = _dereq_('util').inherits
22367 inherits(Sha1, Hash)
22378 var W = new Int32Array(
80)
22384 return POOL.pop().init()
22386 if(!(this instanceof Sha1)) return new Sha1()
22388 Hash.call(this,
16*
4,
14*
4)
22394 Sha1.prototype.init = function () {
22395 this._a =
0x67452301
22396 this._b =
0xefcdab89
22397 this._c =
0x98badcfe
22398 this._d =
0x10325476
22399 this._e =
0xc3d2e1f0
22401 Hash.prototype.init.call(this)
22405 Sha1.prototype._POOL = POOL
22407 // assume that array is a Uint32Array with length=
16,
22408 // and that if it is the last block, it already has the length and the
1 bit appended.
22411 var isDV = new Buffer(
1) instanceof DataView
22412 function readInt32BE (X, i) {
22414 ? X.getInt32(i, false)
22418 Sha1.prototype._update = function (array) {
22420 var X = this._block
22422 var a, b, c, d, e, _a, _b, _c, _d, _e
22432 for(var j =
0; j <
80; j++) {
22435 //? X.getInt32(j*
4, false)
22436 //? readInt32BE(X, j*
4) //*/ X.readInt32BE(j*
4) //*/
22437 ? X.readInt32BE(j*
4)
22438 : rol(w[j -
3] ^ w[j -
8] ^ w[j -
14] ^ w[j -
16],
1)
22442 add(rol(a,
5), sha1_ft(j, b, c, d)),
22443 add(add(e, W), sha1_kt(j))
22453 this._a = add(a, _a)
22454 this._b = add(b, _b)
22455 this._c = add(c, _c)
22456 this._d = add(d, _d)
22457 this._e = add(e, _e)
22460 Sha1.prototype._hash = function () {
22461 if(POOL.length <
100) POOL.push(this)
22462 var H = new Buffer(
20)
22463 //console.log(this._a|
0, this._b|
0, this._c|
0, this._d|
0, this._e|
0)
22464 H.writeInt32BE(this._a|
0, A)
22465 H.writeInt32BE(this._b|
0, B)
22466 H.writeInt32BE(this._c|
0, C)
22467 H.writeInt32BE(this._d|
0, D)
22468 H.writeInt32BE(this._e|
0, E)
22473 * Perform the appropriate triplet combination function for the current
22476 function sha1_ft(t, b, c, d) {
22477 if(t <
20) return (b & c) | ((~b) & d);
22478 if(t <
40) return b ^ c ^ d;
22479 if(t <
60) return (b & c) | (b & d) | (c & d);
22484 * Determine the appropriate additive constant for the current iteration
22486 function sha1_kt(t) {
22487 return (t <
20) ?
1518500249 : (t <
40) ?
1859775393 :
22488 (t <
60) ? -
1894007588 : -
899497514;
22492 * Add integers, wrapping at
2^
32. This uses
16-bit operations internally
22493 * to work around bugs in some JS interpreters.
22494 * //dominictarr: this is
10 years old, so maybe this can be dropped?)
22497 function add(x, y) {
22498 return (x + y ) |
0
22499 //lets see how this goes on testling.
22500 // var lsw = (x &
0xFFFF) + (y &
0xFFFF);
22501 // var msw = (x
>> 16) + (y
>> 16) + (lsw
>> 16);
22502 // return (msw <<
16) | (lsw &
0xFFFF);
22506 * Bitwise rotate a
32-bit number to the left.
22508 function rol(num, cnt) {
22509 return (num << cnt) | (num
>>> (
32 - cnt));
22515 },{"util":
14}],
25:[function(_dereq_,module,exports){
22518 * A JavaScript implementation of the Secure Hash Algorithm, SHA-
256, as defined
22520 * Version
2.2-beta Copyright Angel Marin, Paul Johnston
2000 -
2009.
22521 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
22525 var inherits = _dereq_('util').inherits
22528 var u = _dereq_('./util')
22530 module.exports = function (Buffer, Hash) {
22533 0x428A2F98,
0x71374491,
0xB5C0FBCF,
0xE9B5DBA5,
22534 0x3956C25B,
0x59F111F1,
0x923F82A4,
0xAB1C5ED5,
22535 0xD807AA98,
0x12835B01,
0x243185BE,
0x550C7DC3,
22536 0x72BE5D74,
0x80DEB1FE,
0x9BDC06A7,
0xC19BF174,
22537 0xE49B69C1,
0xEFBE4786,
0x0FC19DC6,
0x240CA1CC,
22538 0x2DE92C6F,
0x4A7484AA,
0x5CB0A9DC,
0x76F988DA,
22539 0x983E5152,
0xA831C66D,
0xB00327C8,
0xBF597FC7,
22540 0xC6E00BF3,
0xD5A79147,
0x06CA6351,
0x14292967,
22541 0x27B70A85,
0x2E1B2138,
0x4D2C6DFC,
0x53380D13,
22542 0x650A7354,
0x766A0ABB,
0x81C2C92E,
0x92722C85,
22543 0xA2BFE8A1,
0xA81A664B,
0xC24B8B70,
0xC76C51A3,
22544 0xD192E819,
0xD6990624,
0xF40E3585,
0x106AA070,
22545 0x19A4C116,
0x1E376C08,
0x2748774C,
0x34B0BCB5,
22546 0x391C0CB3,
0x4ED8AA4A,
0x5B9CCA4F,
0x682E6FF3,
22547 0x748F82EE,
0x78A5636F,
0x84C87814,
0x8CC70208,
22548 0x90BEFFFA,
0xA4506CEB,
0xBEF9A3F7,
0xC67178F2
22551 inherits(Sha256, Hash)
22552 var W = new Array(
64)
22554 function Sha256() {
22555 // Closure compiler warning - this code lacks side effects - thus commented out
22556 // if(POOL.length) {
22557 // return POOL.shift().init()
22559 //this._data = new Buffer(
32)
22563 this._w = W //new Array(
64)
22565 Hash.call(this,
16*
4,
14*
4)
22568 Sha256.prototype.init = function () {
22570 this._a =
0x6a09e667|
0
22571 this._b =
0xbb67ae85|
0
22572 this._c =
0x3c6ef372|
0
22573 this._d =
0xa54ff53a|
0
22574 this._e =
0x510e527f|
0
22575 this._f =
0x9b05688c|
0
22576 this._g =
0x1f83d9ab|
0
22577 this._h =
0x5be0cd19|
0
22579 this._len = this._s =
0
22584 var safe_add = function(x, y) {
22585 var lsw = (x &
0xFFFF) + (y &
0xFFFF);
22586 var msw = (x
>> 16) + (y
>> 16) + (lsw
>> 16);
22587 return (msw <<
16) | (lsw &
0xFFFF);
22590 function S (X, n) {
22591 return (X
>>> n) | (X << (
32 - n));
22594 function R (X, n) {
22598 function Ch (x, y, z) {
22599 return ((x & y) ^ ((~x) & z));
22602 function Maj (x, y, z) {
22603 return ((x & y) ^ (x & z) ^ (y & z));
22606 function Sigma0256 (x) {
22607 return (S(x,
2) ^ S(x,
13) ^ S(x,
22));
22610 function Sigma1256 (x) {
22611 return (S(x,
6) ^ S(x,
11) ^ S(x,
25));
22614 function Gamma0256 (x) {
22615 return (S(x,
7) ^ S(x,
18) ^ R(x,
3));
22618 function Gamma1256 (x) {
22619 return (S(x,
17) ^ S(x,
19) ^ R(x,
10));
22622 Sha256.prototype._update = function(m) {
22623 var M = this._block
22625 var a, b, c, d, e, f, g, h
22637 for (var j =
0; j <
64; j++) {
22638 var w = W[j] = j <
16
22639 ? M.readInt32BE(j *
4)
22640 : Gamma1256(W[j -
2]) + W[j -
7] + Gamma0256(W[j -
15]) + W[j -
16]
22642 T1 = h + Sigma1256(e) + Ch(e, f, g) + K[j] + w
22644 T2 = Sigma0256(a) + Maj(a, b, c);
22645 h = g; g = f; f = e; e = d + T1; d = c; c = b; b = a; a = T1 + T2;
22648 this._a = (a + this._a) |
0
22649 this._b = (b + this._b) |
0
22650 this._c = (c + this._c) |
0
22651 this._d = (d + this._d) |
0
22652 this._e = (e + this._e) |
0
22653 this._f = (f + this._f) |
0
22654 this._g = (g + this._g) |
0
22655 this._h = (h + this._h) |
0
22659 Sha256.prototype._hash = function () {
22660 if(POOL.length <
10)
22663 var H = new Buffer(
32)
22665 H.writeInt32BE(this._a,
0)
22666 H.writeInt32BE(this._b,
4)
22667 H.writeInt32BE(this._c,
8)
22668 H.writeInt32BE(this._d,
12)
22669 H.writeInt32BE(this._e,
16)
22670 H.writeInt32BE(this._f,
20)
22671 H.writeInt32BE(this._g,
24)
22672 H.writeInt32BE(this._h,
28)
22681 },{"./util":
26,"util":
14}],
26:[function(_dereq_,module,exports){
22682 exports.write = write
22683 exports.zeroFill = zeroFill
22685 exports.toString = toString
22687 function write (buffer, string, enc, start, from, to, LE) {
22688 var l = (to - from)
22689 if(enc === 'ascii' || enc === 'binary') {
22690 for( var i =
0; i < l; i++) {
22691 buffer[start + i] = string.charCodeAt(i + from)
22694 else if(enc == null) {
22695 for( var i =
0; i < l; i++) {
22696 buffer[start + i] = string[i + from]
22699 else if(enc === 'hex') {
22700 for(var i =
0; i < l; i++) {
22702 buffer[start + i] = parseInt(string[j*
2] + string[(j*
2)+
1],
16)
22705 else if(enc === 'base64') {
22706 throw new Error('base64 encoding not yet supported')
22709 throw new Error(enc +' encoding not yet supported')
22712 //always fill to the end!
22713 function zeroFill(buf, from) {
22714 for(var i = from; i < buf.length; i++)
22719 },{}],
27:[function(_dereq_,module,exports){
22720 (function (Buffer){
22721 // JavaScript PBKDF2 Implementation
22722 // Based on http://git.io/qsv2zw
22723 // Licensed under LGPL v3
22724 // Copyright (c)
2013 jduncanator
22727 var zeroBuffer = new Buffer(blocksize); zeroBuffer.fill(
0)
22729 module.exports = function (createHmac, exports) {
22730 exports = exports || {}
22732 exports.pbkdf2 = function(password, salt, iterations, keylen, cb) {
22733 if('function' !== typeof cb)
22734 throw new Error('No callback provided to pbkdf2');
22735 setTimeout(function () {
22736 cb(null, exports.pbkdf2Sync(password, salt, iterations, keylen))
22740 exports.pbkdf2Sync = function(key, salt, iterations, keylen) {
22741 if('number' !== typeof iterations)
22742 throw new TypeError('Iterations not a number')
22744 throw new TypeError('Bad iterations')
22745 if('number' !== typeof keylen)
22746 throw new TypeError('Key length not a number')
22748 throw new TypeError('Bad key length')
22750 //stretch key to the correct length that hmac wants it,
22751 //otherwise this will happen every time hmac is called
22752 //twice per iteration.
22753 var key = !Buffer.isBuffer(key) ? new Buffer(key) : key
22755 if(key.length
> blocksize) {
22756 key = createHash(alg).update(key).digest()
22757 } else if(key.length < blocksize) {
22758 key = Buffer.concat([key, zeroBuffer], blocksize)
22762 var cplen, p =
0, i =
1, itmp = new Buffer(
4), digtmp;
22763 var out = new Buffer(keylen);
22771 /* We are unlikely to ever use more than
256 blocks (
5120 bits!)
22772 * but just in case...
22774 itmp[
0] = (i
>> 24) &
0xff;
22775 itmp[
1] = (i
>> 16) &
0xff;
22776 itmp[
2] = (i
>> 8) &
0xff;
22777 itmp[
3] = i &
0xff;
22779 HMAC = createHmac('sha1', key);
22782 digtmp = HMAC.digest();
22783 digtmp.copy(out, p,
0, cplen);
22785 for(var j =
1; j < iterations; j++) {
22786 HMAC = createHmac('sha1', key);
22787 HMAC.update(digtmp);
22788 digtmp = HMAC.digest();
22789 for(var k =
0; k < cplen; k++) {
22790 out[k] ^= digtmp[k];
22804 }).call(this,_dereq_(
"buffer").Buffer)
22805 },{
"buffer":
8}],
28:[function(_dereq_,module,exports){
22806 (function (Buffer){
22807 // Original code adapted from Robert Kieffer.
22808 // details at https://github.com/broofa/node-uuid
22812 var _global = this;
22814 var mathRNG, whatwgRNG;
22816 // NOTE: Math.random() does not guarantee
"cryptographic quality"
22817 mathRNG = function(size) {
22818 var bytes = new Buffer(size);
22821 for (var i =
0, r; i < size; i++) {
22822 if ((i &
0x03) ==
0) r = Math.random() *
0x100000000;
22823 bytes[i] = r
>>> ((i &
0x03) <<
3) &
0xff;
22829 if (_global.crypto && crypto.getRandomValues) {
22830 whatwgRNG = function(size) {
22831 var bytes = new Buffer(size); //in browserify, this is an extended Uint8Array
22832 crypto.getRandomValues(bytes);
22837 module.exports = whatwgRNG || mathRNG;
22841 }).call(this,_dereq_("buffer").Buffer)
22842 },{"buffer":
8}],
29:[function(_dereq_,module,exports){
22843 ;(function (root, factory, undef) {
22844 if (typeof exports === "object") {
22846 module.exports = exports = factory(_dereq_("./core"), _dereq_("./enc-base64"), _dereq_("./md5"), _dereq_("./evpkdf"), _dereq_("./cipher-core"));
22848 else if (typeof define === "function" && define.amd) {
22850 define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
22853 // Global (browser)
22854 factory(root.CryptoJS);
22856 }(this, function (CryptoJS) {
22862 var BlockCipher = C_lib.BlockCipher;
22863 var C_algo = C.algo;
22868 var SUB_MIX_0 = [];
22869 var SUB_MIX_1 = [];
22870 var SUB_MIX_2 = [];
22871 var SUB_MIX_3 = [];
22872 var INV_SUB_MIX_0 = [];
22873 var INV_SUB_MIX_1 = [];
22874 var INV_SUB_MIX_2 = [];
22875 var INV_SUB_MIX_3 = [];
22877 // Compute lookup tables
22879 // Compute double table
22881 for (var i =
0; i <
256; i++) {
22885 d[i] = (i <<
1) ^
0x11b;
22892 for (var i =
0; i <
256; i++) {
22894 var sx = xi ^ (xi <<
1) ^ (xi <<
2) ^ (xi <<
3) ^ (xi <<
4);
22895 sx = (sx
>>> 8) ^ (sx &
0xff) ^
0x63;
22899 // Compute multiplication
22904 // Compute sub bytes, mix columns tables
22905 var t = (d[sx] *
0x101) ^ (sx *
0x1010100);
22906 SUB_MIX_0[x] = (t <<
24) | (t
>>> 8);
22907 SUB_MIX_1[x] = (t <<
16) | (t
>>> 16);
22908 SUB_MIX_2[x] = (t <<
8) | (t
>>> 24);
22911 // Compute inv sub bytes, inv mix columns tables
22912 var t = (x8 *
0x1010101) ^ (x4 *
0x10001) ^ (x2 *
0x101) ^ (x *
0x1010100);
22913 INV_SUB_MIX_0[sx] = (t <<
24) | (t
>>> 8);
22914 INV_SUB_MIX_1[sx] = (t <<
16) | (t
>>> 16);
22915 INV_SUB_MIX_2[sx] = (t <<
8) | (t
>>> 24);
22916 INV_SUB_MIX_3[sx] = t;
22918 // Compute next counter
22922 x = x2 ^ d[d[d[x8 ^ x2]]];
22928 // Precomputed Rcon lookup
22929 var RCON = [
0x00,
0x01,
0x02,
0x04,
0x08,
0x10,
0x20,
0x40,
0x80,
0x1b,
0x36];
22932 * AES block cipher algorithm.
22934 var AES = C_algo.AES = BlockCipher.extend({
22935 _doReset: function () {
22937 var key = this._key;
22938 var keyWords = key.words;
22939 var keySize = key.sigBytes /
4;
22941 // Compute number of rounds
22942 var nRounds = this._nRounds = keySize +
6
22944 // Compute number of key schedule rows
22945 var ksRows = (nRounds +
1) *
4;
22947 // Compute key schedule
22948 var keySchedule = this._keySchedule = [];
22949 for (var ksRow =
0; ksRow < ksRows; ksRow++) {
22950 if (ksRow < keySize) {
22951 keySchedule[ksRow] = keyWords[ksRow];
22953 var t = keySchedule[ksRow -
1];
22955 if (!(ksRow % keySize)) {
22957 t = (t <<
8) | (t
>>> 24);
22960 t = (SBOX[t
>>> 24] <<
24) | (SBOX[(t
>>> 16) &
0xff] <<
16) | (SBOX[(t
>>> 8) &
0xff] <<
8) | SBOX[t &
0xff];
22963 t ^= RCON[(ksRow / keySize) |
0] <<
24;
22964 } else if (keySize
> 6 && ksRow % keySize ==
4) {
22966 t = (SBOX[t
>>> 24] <<
24) | (SBOX[(t
>>> 16) &
0xff] <<
16) | (SBOX[(t
>>> 8) &
0xff] <<
8) | SBOX[t &
0xff];
22969 keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t;
22973 // Compute inv key schedule
22974 var invKeySchedule = this._invKeySchedule = [];
22975 for (var invKsRow =
0; invKsRow < ksRows; invKsRow++) {
22976 var ksRow = ksRows - invKsRow;
22978 if (invKsRow %
4) {
22979 var t = keySchedule[ksRow];
22981 var t = keySchedule[ksRow -
4];
22984 if (invKsRow <
4 || ksRow <=
4) {
22985 invKeySchedule[invKsRow] = t;
22987 invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t
>>> 24]] ^ INV_SUB_MIX_1[SBOX[(t
>>> 16) &
0xff]] ^
22988 INV_SUB_MIX_2[SBOX[(t
>>> 8) &
0xff]] ^ INV_SUB_MIX_3[SBOX[t &
0xff]];
22993 encryptBlock: function (M, offset) {
22994 this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX);
22997 decryptBlock: function (M, offset) {
22998 // Swap
2nd and
4th rows
22999 var t = M[offset +
1];
23000 M[offset +
1] = M[offset +
3];
23003 this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX);
23005 // Inv swap
2nd and
4th rows
23006 var t = M[offset +
1];
23007 M[offset +
1] = M[offset +
3];
23011 _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) {
23013 var nRounds = this._nRounds;
23015 // Get input, add round key
23016 var s0 = M[offset] ^ keySchedule[
0];
23017 var s1 = M[offset +
1] ^ keySchedule[
1];
23018 var s2 = M[offset +
2] ^ keySchedule[
2];
23019 var s3 = M[offset +
3] ^ keySchedule[
3];
23021 // Key schedule row counter
23025 for (var round =
1; round < nRounds; round++) {
23026 // Shift rows, sub bytes, mix columns, add round key
23027 var t0 = SUB_MIX_0[s0
>>> 24] ^ SUB_MIX_1[(s1
>>> 16) &
0xff] ^ SUB_MIX_2[(s2
>>> 8) &
0xff] ^ SUB_MIX_3[s3 &
0xff] ^ keySchedule[ksRow++];
23028 var t1 = SUB_MIX_0[s1
>>> 24] ^ SUB_MIX_1[(s2
>>> 16) &
0xff] ^ SUB_MIX_2[(s3
>>> 8) &
0xff] ^ SUB_MIX_3[s0 &
0xff] ^ keySchedule[ksRow++];
23029 var t2 = SUB_MIX_0[s2
>>> 24] ^ SUB_MIX_1[(s3
>>> 16) &
0xff] ^ SUB_MIX_2[(s0
>>> 8) &
0xff] ^ SUB_MIX_3[s1 &
0xff] ^ keySchedule[ksRow++];
23030 var t3 = SUB_MIX_0[s3
>>> 24] ^ SUB_MIX_1[(s0
>>> 16) &
0xff] ^ SUB_MIX_2[(s1
>>> 8) &
0xff] ^ SUB_MIX_3[s2 &
0xff] ^ keySchedule[ksRow++];
23039 // Shift rows, sub bytes, add round key
23040 var t0 = ((SBOX[s0
>>> 24] <<
24) | (SBOX[(s1
>>> 16) &
0xff] <<
16) | (SBOX[(s2
>>> 8) &
0xff] <<
8) | SBOX[s3 &
0xff]) ^ keySchedule[ksRow++];
23041 var t1 = ((SBOX[s1
>>> 24] <<
24) | (SBOX[(s2
>>> 16) &
0xff] <<
16) | (SBOX[(s3
>>> 8) &
0xff] <<
8) | SBOX[s0 &
0xff]) ^ keySchedule[ksRow++];
23042 var t2 = ((SBOX[s2
>>> 24] <<
24) | (SBOX[(s3
>>> 16) &
0xff] <<
16) | (SBOX[(s0
>>> 8) &
0xff] <<
8) | SBOX[s1 &
0xff]) ^ keySchedule[ksRow++];
23043 var t3 = ((SBOX[s3
>>> 24] <<
24) | (SBOX[(s0
>>> 16) &
0xff] <<
16) | (SBOX[(s1
>>> 8) &
0xff] <<
8) | SBOX[s2 &
0xff]) ^ keySchedule[ksRow++];
23047 M[offset +
1] = t1;
23048 M[offset +
2] = t2;
23049 M[offset +
3] = t3;
23056 * Shortcut functions to the cipher's object interface.
23060 * var ciphertext = CryptoJS.AES.encrypt(message, key, cfg);
23061 * var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg);
23063 C.AES = BlockCipher._createHelper(AES);
23067 return CryptoJS.AES;
23070 },{
"./cipher-core":
30,
"./core":
31,
"./enc-base64":
32,
"./evpkdf":
34,
"./md5":
39}],
30:[function(_dereq_,module,exports){
23071 ;(function (root, factory) {
23072 if (typeof exports ===
"object") {
23074 module.exports = exports = factory(_dereq_(
"./core"));
23076 else if (typeof define ===
"function" && define.amd) {
23078 define([
"./core"], factory);
23081 // Global (browser)
23082 factory(root.CryptoJS);
23084 }(this, function (CryptoJS) {
23087 * Cipher core components.
23089 CryptoJS.lib.Cipher || (function (undefined) {
23093 var Base = C_lib.Base;
23094 var WordArray = C_lib.WordArray;
23095 var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm;
23097 var Utf8 = C_enc.Utf8;
23098 var Base64 = C_enc.Base64;
23099 var C_algo = C.algo;
23100 var EvpKDF = C_algo.EvpKDF;
23103 * Abstract base cipher template.
23105 * @property {number} keySize This cipher's key size. Default:
4 (
128 bits)
23106 * @property {number} ivSize This cipher's IV size. Default:
4 (
128 bits)
23107 * @property {number} _ENC_XFORM_MODE A constant representing encryption mode.
23108 * @property {number} _DEC_XFORM_MODE A constant representing decryption mode.
23110 var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({
23112 * Configuration options.
23114 * @property {WordArray} iv The IV to use for this operation.
23116 cfg: Base.extend(),
23119 * Creates this cipher in encryption mode.
23121 * @param {WordArray} key The key.
23122 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23124 * @return {Cipher} A cipher instance.
23130 * var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray });
23132 createEncryptor: function (key, cfg) {
23133 return this.create(this._ENC_XFORM_MODE, key, cfg);
23137 * Creates this cipher in decryption mode.
23139 * @param {WordArray} key The key.
23140 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23142 * @return {Cipher} A cipher instance.
23148 * var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray });
23150 createDecryptor: function (key, cfg) {
23151 return this.create(this._DEC_XFORM_MODE, key, cfg);
23155 * Initializes a newly created cipher.
23157 * @param {number} xformMode Either the encryption or decryption transormation mode constant.
23158 * @param {WordArray} key The key.
23159 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23163 * var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray });
23165 init: function (xformMode, key, cfg) {
23166 // Apply config defaults
23167 this.cfg = this.cfg.extend(cfg);
23169 // Store transform mode and key
23170 this._xformMode = xformMode;
23173 // Set initial values
23178 * Resets this cipher to its initial state.
23184 reset: function () {
23185 // Reset data buffer
23186 BufferedBlockAlgorithm.reset.call(this);
23188 // Perform concrete-cipher logic
23193 * Adds data to be encrypted or decrypted.
23195 * @param {WordArray|string} dataUpdate The data to encrypt or decrypt.
23197 * @return {WordArray} The data after processing.
23201 * var encrypted = cipher.process('data');
23202 * var encrypted = cipher.process(wordArray);
23204 process: function (dataUpdate) {
23206 this._append(dataUpdate);
23208 // Process available blocks
23209 return this._process();
23213 * Finalizes the encryption or decryption process.
23214 * Note that the finalize operation is effectively a destructive, read-once operation.
23216 * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt.
23218 * @return {WordArray} The data after final processing.
23222 * var encrypted = cipher.finalize();
23223 * var encrypted = cipher.finalize('data');
23224 * var encrypted = cipher.finalize(wordArray);
23226 finalize: function (dataUpdate) {
23227 // Final data update
23229 this._append(dataUpdate);
23232 // Perform concrete-cipher logic
23233 var finalProcessedData = this._doFinalize();
23235 return finalProcessedData;
23242 _ENC_XFORM_MODE:
1,
23244 _DEC_XFORM_MODE:
2,
23247 * Creates shortcut functions to a cipher's object interface.
23249 * @param {Cipher} cipher The cipher to create a helper for.
23251 * @return {Object} An object with encrypt and decrypt shortcut functions.
23257 * var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES);
23259 _createHelper: (function () {
23260 function selectCipherStrategy(key) {
23261 if (typeof key == 'string') {
23262 return PasswordBasedCipher;
23264 return SerializableCipher;
23268 return function (cipher) {
23270 encrypt: function (message, key, cfg) {
23271 return selectCipherStrategy(key).encrypt(cipher, message, key, cfg);
23274 decrypt: function (ciphertext, key, cfg) {
23275 return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg);
23283 * Abstract base stream cipher template.
23285 * @property {number} blockSize The number of
32-bit words this cipher operates on. Default:
1 (
32 bits)
23287 var StreamCipher = C_lib.StreamCipher = Cipher.extend({
23288 _doFinalize: function () {
23289 // Process partial blocks
23290 var finalProcessedBlocks = this._process(!!'flush');
23292 return finalProcessedBlocks;
23301 var C_mode = C.mode = {};
23304 * Abstract base block cipher mode template.
23306 var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({
23308 * Creates this mode for encryption.
23310 * @param {Cipher} cipher A block cipher instance.
23311 * @param {Array} iv The IV words.
23317 * var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words);
23319 createEncryptor: function (cipher, iv) {
23320 return this.Encryptor.create(cipher, iv);
23324 * Creates this mode for decryption.
23326 * @param {Cipher} cipher A block cipher instance.
23327 * @param {Array} iv The IV words.
23333 * var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words);
23335 createDecryptor: function (cipher, iv) {
23336 return this.Decryptor.create(cipher, iv);
23340 * Initializes a newly created mode.
23342 * @param {Cipher} cipher A block cipher instance.
23343 * @param {Array} iv The IV words.
23347 * var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words);
23349 init: function (cipher, iv) {
23350 this._cipher = cipher;
23356 * Cipher Block Chaining mode.
23358 var CBC = C_mode.CBC = (function () {
23360 * Abstract base CBC mode.
23362 var CBC = BlockCipherMode.extend();
23367 CBC.Encryptor = CBC.extend({
23369 * Processes the data block at offset.
23371 * @param {Array} words The data words to operate on.
23372 * @param {number} offset The offset where the block starts.
23376 * mode.processBlock(data.words, offset);
23378 processBlock: function (words, offset) {
23380 var cipher = this._cipher;
23381 var blockSize = cipher.blockSize;
23384 xorBlock.call(this, words, offset, blockSize);
23385 cipher.encryptBlock(words, offset);
23387 // Remember this block to use with next block
23388 this._prevBlock = words.slice(offset, offset + blockSize);
23395 CBC.Decryptor = CBC.extend({
23397 * Processes the data block at offset.
23399 * @param {Array} words The data words to operate on.
23400 * @param {number} offset The offset where the block starts.
23404 * mode.processBlock(data.words, offset);
23406 processBlock: function (words, offset) {
23408 var cipher = this._cipher;
23409 var blockSize = cipher.blockSize;
23411 // Remember this block to use with next block
23412 var thisBlock = words.slice(offset, offset + blockSize);
23415 cipher.decryptBlock(words, offset);
23416 xorBlock.call(this, words, offset, blockSize);
23418 // This block becomes the previous block
23419 this._prevBlock = thisBlock;
23423 function xorBlock(words, offset, blockSize) {
23427 // Choose mixing block
23431 // Remove IV for subsequent blocks
23432 this._iv = undefined;
23434 var block = this._prevBlock;
23438 for (var i =
0; i < blockSize; i++) {
23439 words[offset + i] ^= block[i];
23447 * Padding namespace.
23449 var C_pad = C.pad = {};
23452 * PKCS #
5/
7 padding strategy.
23454 var Pkcs7 = C_pad.Pkcs7 = {
23456 * Pads data using the algorithm defined in PKCS #
5/
7.
23458 * @param {WordArray} data The data to pad.
23459 * @param {number} blockSize The multiple that the data should be padded to.
23465 * CryptoJS.pad.Pkcs7.pad(wordArray,
4);
23467 pad: function (data, blockSize) {
23469 var blockSizeBytes = blockSize *
4;
23471 // Count padding bytes
23472 var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
23474 // Create padding word
23475 var paddingWord = (nPaddingBytes <<
24) | (nPaddingBytes <<
16) | (nPaddingBytes <<
8) | nPaddingBytes;
23478 var paddingWords = [];
23479 for (var i =
0; i < nPaddingBytes; i +=
4) {
23480 paddingWords.push(paddingWord);
23482 var padding = WordArray.create(paddingWords, nPaddingBytes);
23485 data.concat(padding);
23489 * Unpads data that had been padded using the algorithm defined in PKCS #
5/
7.
23491 * @param {WordArray} data The data to unpad.
23497 * CryptoJS.pad.Pkcs7.unpad(wordArray);
23499 unpad: function (data) {
23500 // Get number of padding bytes from last byte
23501 var nPaddingBytes = data.words[(data.sigBytes -
1)
>>> 2] &
0xff;
23504 data.sigBytes -= nPaddingBytes;
23509 * Abstract base block cipher template.
23511 * @property {number} blockSize The number of
32-bit words this cipher operates on. Default:
4 (
128 bits)
23513 var BlockCipher = C_lib.BlockCipher = Cipher.extend({
23515 * Configuration options.
23517 * @property {Mode} mode The block mode to use. Default: CBC
23518 * @property {Padding} padding The padding strategy to use. Default: Pkcs7
23520 cfg: Cipher.cfg.extend({
23525 reset: function () {
23527 Cipher.reset.call(this);
23530 var cfg = this.cfg;
23532 var mode = cfg.mode;
23534 // Reset block mode
23535 if (this._xformMode == this._ENC_XFORM_MODE) {
23536 var modeCreator = mode.createEncryptor;
23537 } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
23538 var modeCreator = mode.createDecryptor;
23540 // Keep at least one block in the buffer for unpadding
23541 this._minBufferSize =
1;
23543 this._mode = modeCreator.call(mode, this, iv && iv.words);
23546 _doProcessBlock: function (words, offset) {
23547 this._mode.processBlock(words, offset);
23550 _doFinalize: function () {
23552 var padding = this.cfg.padding;
23555 if (this._xformMode == this._ENC_XFORM_MODE) {
23557 padding.pad(this._data, this.blockSize);
23559 // Process final blocks
23560 var finalProcessedBlocks = this._process(!!'flush');
23561 } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
23562 // Process final blocks
23563 var finalProcessedBlocks = this._process(!!'flush');
23566 padding.unpad(finalProcessedBlocks);
23569 return finalProcessedBlocks;
23576 * A collection of cipher parameters.
23578 * @property {WordArray} ciphertext The raw ciphertext.
23579 * @property {WordArray} key The key to this ciphertext.
23580 * @property {WordArray} iv The IV used in the ciphering operation.
23581 * @property {WordArray} salt The salt used with a key derivation function.
23582 * @property {Cipher} algorithm The cipher algorithm.
23583 * @property {Mode} mode The block mode used in the ciphering operation.
23584 * @property {Padding} padding The padding scheme used in the ciphering operation.
23585 * @property {number} blockSize The block size of the cipher.
23586 * @property {Format} formatter The default formatting strategy to convert this cipher params object to a string.
23588 var CipherParams = C_lib.CipherParams = Base.extend({
23590 * Initializes a newly created cipher params object.
23592 * @param {Object} cipherParams An object with any of the possible cipher parameters.
23596 * var cipherParams = CryptoJS.lib.CipherParams.create({
23597 * ciphertext: ciphertextWordArray,
23598 * key: keyWordArray,
23600 * salt: saltWordArray,
23601 * algorithm: CryptoJS.algo.AES,
23602 * mode: CryptoJS.mode.CBC,
23603 * padding: CryptoJS.pad.PKCS7,
23605 * formatter: CryptoJS.format.OpenSSL
23608 init: function (cipherParams) {
23609 this.mixIn(cipherParams);
23613 * Converts this cipher params object to a string.
23615 * @param {Format} formatter (Optional) The formatting strategy to use.
23617 * @return {string} The stringified cipher params.
23619 * @throws Error If neither the formatter nor the default formatter is set.
23623 * var string = cipherParams + '';
23624 * var string = cipherParams.toString();
23625 * var string = cipherParams.toString(CryptoJS.format.OpenSSL);
23627 toString: function (formatter) {
23628 return (formatter || this.formatter).stringify(this);
23633 * Format namespace.
23635 var C_format = C.format = {};
23638 * OpenSSL formatting strategy.
23640 var OpenSSLFormatter = C_format.OpenSSL = {
23642 * Converts a cipher params object to an OpenSSL-compatible string.
23644 * @param {CipherParams} cipherParams The cipher params object.
23646 * @return {string} The OpenSSL-compatible string.
23652 * var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams);
23654 stringify: function (cipherParams) {
23656 var ciphertext = cipherParams.ciphertext;
23657 var salt = cipherParams.salt;
23661 var wordArray = WordArray.create([
0x53616c74,
0x65645f5f]).concat(salt).concat(ciphertext);
23663 var wordArray = ciphertext;
23666 return wordArray.toString(Base64);
23670 * Converts an OpenSSL-compatible string to a cipher params object.
23672 * @param {string} openSSLStr The OpenSSL-compatible string.
23674 * @return {CipherParams} The cipher params object.
23680 * var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString);
23682 parse: function (openSSLStr) {
23684 var ciphertext = Base64.parse(openSSLStr);
23687 var ciphertextWords = ciphertext.words;
23690 if (ciphertextWords[
0] ==
0x53616c74 && ciphertextWords[
1] ==
0x65645f5f) {
23692 var salt = WordArray.create(ciphertextWords.slice(
2,
4));
23694 // Remove salt from ciphertext
23695 ciphertextWords.splice(
0,
4);
23696 ciphertext.sigBytes -=
16;
23699 return CipherParams.create({ ciphertext: ciphertext, salt: salt });
23704 * A cipher wrapper that returns ciphertext as a serializable cipher params object.
23706 var SerializableCipher = C_lib.SerializableCipher = Base.extend({
23708 * Configuration options.
23710 * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL
23713 format: OpenSSLFormatter
23717 * Encrypts a message.
23719 * @param {Cipher} cipher The cipher algorithm to use.
23720 * @param {WordArray|string} message The message to encrypt.
23721 * @param {WordArray} key The key.
23722 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23724 * @return {CipherParams} A cipher params object.
23730 * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key);
23731 * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv });
23732 * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL });
23734 encrypt: function (cipher, message, key, cfg) {
23735 // Apply config defaults
23736 cfg = this.cfg.extend(cfg);
23739 var encryptor = cipher.createEncryptor(key, cfg);
23740 var ciphertext = encryptor.finalize(message);
23743 var cipherCfg = encryptor.cfg;
23745 // Create and return serializable cipher params
23746 return CipherParams.create({
23747 ciphertext: ciphertext,
23751 mode: cipherCfg.mode,
23752 padding: cipherCfg.padding,
23753 blockSize: cipher.blockSize,
23754 formatter: cfg.format
23759 * Decrypts serialized ciphertext.
23761 * @param {Cipher} cipher The cipher algorithm to use.
23762 * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
23763 * @param {WordArray} key The key.
23764 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23766 * @return {WordArray} The plaintext.
23772 * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL });
23773 * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL });
23775 decrypt: function (cipher, ciphertext, key, cfg) {
23776 // Apply config defaults
23777 cfg = this.cfg.extend(cfg);
23779 // Convert string to CipherParams
23780 ciphertext = this._parse(ciphertext, cfg.format);
23783 var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext);
23789 * Converts serialized ciphertext to CipherParams,
23790 * else assumed CipherParams already and returns ciphertext unchanged.
23792 * @param {CipherParams|string} ciphertext The ciphertext.
23793 * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext.
23795 * @return {CipherParams} The unserialized ciphertext.
23801 * var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format);
23803 _parse: function (ciphertext, format) {
23804 if (typeof ciphertext == 'string') {
23805 return format.parse(ciphertext, this);
23813 * Key derivation function namespace.
23815 var C_kdf = C.kdf = {};
23818 * OpenSSL key derivation function.
23820 var OpenSSLKdf = C_kdf.OpenSSL = {
23822 * Derives a key and IV from a password.
23824 * @param {string} password The password to derive from.
23825 * @param {number} keySize The size in words of the key to generate.
23826 * @param {number} ivSize The size in words of the IV to generate.
23827 * @param {WordArray|string} salt (Optional) A
64-bit salt to use. If omitted, a salt will be generated randomly.
23829 * @return {CipherParams} A cipher params object with the key, IV, and salt.
23835 * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password',
256/
32,
128/
32);
23836 * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password',
256/
32,
128/
32, 'saltsalt');
23838 execute: function (password, keySize, ivSize, salt) {
23839 // Generate random salt
23841 salt = WordArray.random(
64/
8);
23844 // Derive key and IV
23845 var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt);
23847 // Separate key and IV
23848 var iv = WordArray.create(key.words.slice(keySize), ivSize *
4);
23849 key.sigBytes = keySize *
4;
23852 return CipherParams.create({ key: key, iv: iv, salt: salt });
23857 * A serializable cipher wrapper that derives the key from a password,
23858 * and returns ciphertext as a serializable cipher params object.
23860 var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({
23862 * Configuration options.
23864 * @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL
23866 cfg: SerializableCipher.cfg.extend({
23871 * Encrypts a message using a password.
23873 * @param {Cipher} cipher The cipher algorithm to use.
23874 * @param {WordArray|string} message The message to encrypt.
23875 * @param {string} password The password.
23876 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23878 * @return {CipherParams} A cipher params object.
23884 * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password');
23885 * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL });
23887 encrypt: function (cipher, message, password, cfg) {
23888 // Apply config defaults
23889 cfg = this.cfg.extend(cfg);
23891 // Derive key and other params
23892 var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize);
23894 // Add IV to config
23895 cfg.iv = derivedParams.iv;
23898 var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg);
23900 // Mix in derived params
23901 ciphertext.mixIn(derivedParams);
23907 * Decrypts serialized ciphertext using a password.
23909 * @param {Cipher} cipher The cipher algorithm to use.
23910 * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
23911 * @param {string} password The password.
23912 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23914 * @return {WordArray} The plaintext.
23920 * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL });
23921 * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL });
23923 decrypt: function (cipher, ciphertext, password, cfg) {
23924 // Apply config defaults
23925 cfg = this.cfg.extend(cfg);
23927 // Convert string to CipherParams
23928 ciphertext = this._parse(ciphertext, cfg.format);
23930 // Derive key and other params
23931 var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt);
23933 // Add IV to config
23934 cfg.iv = derivedParams.iv;
23937 var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg);
23946 },{
"./core":
31}],
31:[function(_dereq_,module,exports){
23947 ;(function (root, factory) {
23948 if (typeof exports ===
"object") {
23950 module.exports = exports = factory();
23952 else if (typeof define ===
"function" && define.amd) {
23954 define([], factory);
23957 // Global (browser)
23958 root.CryptoJS = factory();
23960 }(this, function () {
23963 * CryptoJS core components.
23965 var CryptoJS = CryptoJS || (function (Math, undefined) {
23967 * CryptoJS namespace.
23972 * Library namespace.
23974 var C_lib = C.lib = {};
23977 * Base object for prototypal inheritance.
23979 var Base = C_lib.Base = (function () {
23984 * Creates a new object that inherits from this object.
23986 * @param {Object} overrides Properties to copy into the new object.
23988 * @return {Object} The new object.
23994 * var MyType = CryptoJS.lib.Base.extend({
23997 * method: function () {
24001 extend: function (overrides) {
24003 F.prototype = this;
24004 var subtype = new F();
24008 subtype.mixIn(overrides);
24011 // Create default initializer
24012 if (!subtype.hasOwnProperty('init')) {
24013 subtype.init = function () {
24014 subtype.$super.init.apply(this, arguments);
24018 // Initializer's prototype is the subtype object
24019 subtype.init.prototype = subtype;
24021 // Reference supertype
24022 subtype.$super = this;
24028 * Extends this object and runs the init method.
24029 * Arguments to create() will be passed to init().
24031 * @return {Object} The new object.
24037 * var instance = MyType.create();
24039 create: function () {
24040 var instance = this.extend();
24041 instance.init.apply(instance, arguments);
24047 * Initializes a newly created object.
24048 * Override this method to add some logic when your objects are created.
24052 * var MyType = CryptoJS.lib.Base.extend({
24053 * init: function () {
24058 init: function () {
24062 * Copies properties into this object.
24064 * @param {Object} properties The properties to mix in.
24072 mixIn: function (properties) {
24073 for (var propertyName in properties) {
24074 if (properties.hasOwnProperty(propertyName)) {
24075 this[propertyName] = properties[propertyName];
24079 // IE won't copy toString using the loop above
24080 if (properties.hasOwnProperty('toString')) {
24081 this.toString = properties.toString;
24086 * Creates a copy of this object.
24088 * @return {Object} The clone.
24092 * var clone = instance.clone();
24094 clone: function () {
24095 return this.init.prototype.extend(this);
24101 * An array of
32-bit words.
24103 * @property {Array} words The array of
32-bit words.
24104 * @property {number} sigBytes The number of significant bytes in this word array.
24106 var WordArray = C_lib.WordArray = Base.extend({
24108 * Initializes a newly created word array.
24110 * @param {Array} words (Optional) An array of
32-bit words.
24111 * @param {number} sigBytes (Optional) The number of significant bytes in the words.
24115 * var wordArray = CryptoJS.lib.WordArray.create();
24116 * var wordArray = CryptoJS.lib.WordArray.create([
0x00010203,
0x04050607]);
24117 * var wordArray = CryptoJS.lib.WordArray.create([
0x00010203,
0x04050607],
6);
24119 init: function (words, sigBytes) {
24120 words = this.words = words || [];
24122 if (sigBytes != undefined) {
24123 this.sigBytes = sigBytes;
24125 this.sigBytes = words.length *
4;
24130 * Converts this word array to a string.
24132 * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
24134 * @return {string} The stringified word array.
24138 * var string = wordArray + '';
24139 * var string = wordArray.toString();
24140 * var string = wordArray.toString(CryptoJS.enc.Utf8);
24142 toString: function (encoder) {
24143 return (encoder || Hex).stringify(this);
24147 * Concatenates a word array to this word array.
24149 * @param {WordArray} wordArray The word array to append.
24151 * @return {WordArray} This word array.
24155 * wordArray1.concat(wordArray2);
24157 concat: function (wordArray) {
24159 var thisWords = this.words;
24160 var thatWords = wordArray.words;
24161 var thisSigBytes = this.sigBytes;
24162 var thatSigBytes = wordArray.sigBytes;
24164 // Clamp excess bits
24168 if (thisSigBytes %
4) {
24169 // Copy one byte at a time
24170 for (var i =
0; i < thatSigBytes; i++) {
24171 var thatByte = (thatWords[i
>>> 2]
>>> (
24 - (i %
4) *
8)) &
0xff;
24172 thisWords[(thisSigBytes + i)
>>> 2] |= thatByte << (
24 - ((thisSigBytes + i) %
4) *
8);
24174 } else if (thatWords.length
> 0xffff) {
24175 // Copy one word at a time
24176 for (var i =
0; i < thatSigBytes; i +=
4) {
24177 thisWords[(thisSigBytes + i)
>>> 2] = thatWords[i
>>> 2];
24180 // Copy all words at once
24181 thisWords.push.apply(thisWords, thatWords);
24183 this.sigBytes += thatSigBytes;
24190 * Removes insignificant bits.
24194 * wordArray.clamp();
24196 clamp: function () {
24198 var words = this.words;
24199 var sigBytes = this.sigBytes;
24202 words[sigBytes
>>> 2] &=
0xffffffff << (
32 - (sigBytes %
4) *
8);
24203 words.length = Math.ceil(sigBytes /
4);
24207 * Creates a copy of this word array.
24209 * @return {WordArray} The clone.
24213 * var clone = wordArray.clone();
24215 clone: function () {
24216 var clone = Base.clone.call(this);
24217 clone.words = this.words.slice(
0);
24223 * Creates a word array filled with random bytes.
24225 * @param {number} nBytes The number of random bytes to generate.
24227 * @return {WordArray} The random word array.
24233 * var wordArray = CryptoJS.lib.WordArray.random(
16);
24235 random: function (nBytes) {
24237 for (var i =
0; i < nBytes; i +=
4) {
24238 words.push((Math.random() *
0x100000000) |
0);
24241 return new WordArray.init(words, nBytes);
24246 * Encoder namespace.
24248 var C_enc = C.enc = {};
24251 * Hex encoding strategy.
24253 var Hex = C_enc.Hex = {
24255 * Converts a word array to a hex string.
24257 * @param {WordArray} wordArray The word array.
24259 * @return {string} The hex string.
24265 * var hexString = CryptoJS.enc.Hex.stringify(wordArray);
24267 stringify: function (wordArray) {
24269 var words = wordArray.words;
24270 var sigBytes = wordArray.sigBytes;
24274 for (var i =
0; i < sigBytes; i++) {
24275 var bite = (words[i
>>> 2]
>>> (
24 - (i %
4) *
8)) &
0xff;
24276 hexChars.push((bite
>>> 4).toString(
16));
24277 hexChars.push((bite &
0x0f).toString(
16));
24280 return hexChars.join('');
24284 * Converts a hex string to a word array.
24286 * @param {string} hexStr The hex string.
24288 * @return {WordArray} The word array.
24294 * var wordArray = CryptoJS.enc.Hex.parse(hexString);
24296 parse: function (hexStr) {
24298 var hexStrLength = hexStr.length;
24302 for (var i =
0; i < hexStrLength; i +=
2) {
24303 words[i
>>> 3] |= parseInt(hexStr.substr(i,
2),
16) << (
24 - (i %
8) *
4);
24306 return new WordArray.init(words, hexStrLength /
2);
24311 * Latin1 encoding strategy.
24313 var Latin1 = C_enc.Latin1 = {
24315 * Converts a word array to a Latin1 string.
24317 * @param {WordArray} wordArray The word array.
24319 * @return {string} The Latin1 string.
24325 * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
24327 stringify: function (wordArray) {
24329 var words = wordArray.words;
24330 var sigBytes = wordArray.sigBytes;
24333 var latin1Chars = [];
24334 for (var i =
0; i < sigBytes; i++) {
24335 var bite = (words[i
>>> 2]
>>> (
24 - (i %
4) *
8)) &
0xff;
24336 latin1Chars.push(String.fromCharCode(bite));
24339 return latin1Chars.join('');
24343 * Converts a Latin1 string to a word array.
24345 * @param {string} latin1Str The Latin1 string.
24347 * @return {WordArray} The word array.
24353 * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
24355 parse: function (latin1Str) {
24357 var latin1StrLength = latin1Str.length;
24361 for (var i =
0; i < latin1StrLength; i++) {
24362 words[i
>>> 2] |= (latin1Str.charCodeAt(i) &
0xff) << (
24 - (i %
4) *
8);
24365 return new WordArray.init(words, latin1StrLength);
24370 * UTF-
8 encoding strategy.
24372 var Utf8 = C_enc.Utf8 = {
24374 * Converts a word array to a UTF-
8 string.
24376 * @param {WordArray} wordArray The word array.
24378 * @return {string} The UTF-
8 string.
24384 * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
24386 stringify: function (wordArray) {
24388 return decodeURIComponent(escape(Latin1.stringify(wordArray)));
24390 throw new Error('Malformed UTF-
8 data');
24395 * Converts a UTF-
8 string to a word array.
24397 * @param {string} utf8Str The UTF-
8 string.
24399 * @return {WordArray} The word array.
24405 * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
24407 parse: function (utf8Str) {
24408 return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
24413 * Abstract buffered block algorithm template.
24415 * The property blockSize must be implemented in a concrete subtype.
24417 * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default:
0
24419 var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
24421 * Resets this block algorithm's data buffer to its initial state.
24425 * bufferedBlockAlgorithm.reset();
24427 reset: function () {
24429 this._data = new WordArray.init();
24430 this._nDataBytes =
0;
24434 * Adds new data to this block algorithm's buffer.
24436 * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-
8.
24440 * bufferedBlockAlgorithm._append('data');
24441 * bufferedBlockAlgorithm._append(wordArray);
24443 _append: function (data) {
24444 // Convert string to WordArray, else assume WordArray already
24445 if (typeof data == 'string') {
24446 data = Utf8.parse(data);
24450 this._data.concat(data);
24451 this._nDataBytes += data.sigBytes;
24455 * Processes available data blocks.
24457 * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
24459 * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
24461 * @return {WordArray} The processed data.
24465 * var processedData = bufferedBlockAlgorithm._process();
24466 * var processedData = bufferedBlockAlgorithm._process(!!'flush');
24468 _process: function (doFlush) {
24470 var data = this._data;
24471 var dataWords = data.words;
24472 var dataSigBytes = data.sigBytes;
24473 var blockSize = this.blockSize;
24474 var blockSizeBytes = blockSize *
4;
24476 // Count blocks ready
24477 var nBlocksReady = dataSigBytes / blockSizeBytes;
24479 // Round up to include partial blocks
24480 nBlocksReady = Math.ceil(nBlocksReady);
24482 // Round down to include only full blocks,
24483 // less the number of blocks that must remain in the buffer
24484 nBlocksReady = Math.max((nBlocksReady |
0) - this._minBufferSize,
0);
24487 // Count words ready
24488 var nWordsReady = nBlocksReady * blockSize;
24490 // Count bytes ready
24491 var nBytesReady = Math.min(nWordsReady *
4, dataSigBytes);
24495 for (var offset =
0; offset < nWordsReady; offset += blockSize) {
24496 // Perform concrete-algorithm logic
24497 this._doProcessBlock(dataWords, offset);
24500 // Remove processed words
24501 var processedWords = dataWords.splice(
0, nWordsReady);
24502 data.sigBytes -= nBytesReady;
24505 // Return processed words
24506 return new WordArray.init(processedWords, nBytesReady);
24510 * Creates a copy of this object.
24512 * @return {Object} The clone.
24516 * var clone = bufferedBlockAlgorithm.clone();
24518 clone: function () {
24519 var clone = Base.clone.call(this);
24520 clone._data = this._data.clone();
24529 * Abstract hasher template.
24531 * @property {number} blockSize The number of
32-bit words this hasher operates on. Default:
16 (
512 bits)
24533 var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
24535 * Configuration options.
24537 cfg: Base.extend(),
24540 * Initializes a newly created hasher.
24542 * @param {Object} cfg (Optional) The configuration options to use for this hash computation.
24546 * var hasher = CryptoJS.algo.SHA256.create();
24548 init: function (cfg) {
24549 // Apply config defaults
24550 this.cfg = this.cfg.extend(cfg);
24552 // Set initial values
24557 * Resets this hasher to its initial state.
24563 reset: function () {
24564 // Reset data buffer
24565 BufferedBlockAlgorithm.reset.call(this);
24567 // Perform concrete-hasher logic
24572 * Updates this hasher with a message.
24574 * @param {WordArray|string} messageUpdate The message to append.
24576 * @return {Hasher} This hasher.
24580 * hasher.update('message');
24581 * hasher.update(wordArray);
24583 update: function (messageUpdate) {
24585 this._append(messageUpdate);
24595 * Finalizes the hash computation.
24596 * Note that the finalize operation is effectively a destructive, read-once operation.
24598 * @param {WordArray|string} messageUpdate (Optional) A final message update.
24600 * @return {WordArray} The hash.
24604 * var hash = hasher.finalize();
24605 * var hash = hasher.finalize('message');
24606 * var hash = hasher.finalize(wordArray);
24608 finalize: function (messageUpdate) {
24609 // Final message update
24610 if (messageUpdate) {
24611 this._append(messageUpdate);
24614 // Perform concrete-hasher logic
24615 var hash = this._doFinalize();
24623 * Creates a shortcut function to a hasher's object interface.
24625 * @param {Hasher} hasher The hasher to create a helper for.
24627 * @return {Function} The shortcut function.
24633 * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
24635 _createHelper: function (hasher) {
24636 return function (message, cfg) {
24637 return new hasher.init(cfg).finalize(message);
24642 * Creates a shortcut function to the HMAC's object interface.
24644 * @param {Hasher} hasher The hasher to use in this HMAC helper.
24646 * @return {Function} The shortcut function.
24652 * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
24654 _createHmacHelper: function (hasher) {
24655 return function (message, key) {
24656 return new C_algo.HMAC.init(hasher, key).finalize(message);
24662 * Algorithm namespace.
24664 var C_algo = C.algo = {};
24673 },{}],
32:[function(_dereq_,module,exports){
24674 ;(function (root, factory) {
24675 if (typeof exports ===
"object") {
24677 module.exports = exports = factory(_dereq_(
"./core"));
24679 else if (typeof define ===
"function" && define.amd) {
24681 define([
"./core"], factory);
24684 // Global (browser)
24685 factory(root.CryptoJS);
24687 }(this, function (CryptoJS) {
24693 var WordArray = C_lib.WordArray;
24697 * Base64 encoding strategy.
24699 var Base64 = C_enc.Base64 = {
24701 * Converts a word array to a Base64 string.
24703 * @param {WordArray} wordArray The word array.
24705 * @return {string} The Base64 string.
24711 * var base64String = CryptoJS.enc.Base64.stringify(wordArray);
24713 stringify: function (wordArray) {
24715 var words = wordArray.words;
24716 var sigBytes = wordArray.sigBytes;
24717 var map = this._map;
24719 // Clamp excess bits
24723 var base64Chars = [];
24724 for (var i =
0; i < sigBytes; i +=
3) {
24725 var byte1 = (words[i
>>> 2]
>>> (
24 - (i %
4) *
8)) &
0xff;
24726 var byte2 = (words[(i +
1)
>>> 2]
>>> (
24 - ((i +
1) %
4) *
8)) &
0xff;
24727 var byte3 = (words[(i +
2)
>>> 2]
>>> (
24 - ((i +
2) %
4) *
8)) &
0xff;
24729 var triplet = (byte1 <<
16) | (byte2 <<
8) | byte3;
24731 for (var j =
0; (j <
4) && (i + j *
0.75 < sigBytes); j++) {
24732 base64Chars.push(map.charAt((triplet
>>> (
6 * (
3 - j))) &
0x3f));
24737 var paddingChar = map.charAt(
64);
24739 while (base64Chars.length %
4) {
24740 base64Chars.push(paddingChar);
24744 return base64Chars.join('');
24748 * Converts a Base64 string to a word array.
24750 * @param {string} base64Str The Base64 string.
24752 * @return {WordArray} The word array.
24758 * var wordArray = CryptoJS.enc.Base64.parse(base64String);
24760 parse: function (base64Str) {
24762 var base64StrLength = base64Str.length;
24763 var map = this._map;
24766 var paddingChar = map.charAt(
64);
24768 var paddingIndex = base64Str.indexOf(paddingChar);
24769 if (paddingIndex != -
1) {
24770 base64StrLength = paddingIndex;
24777 for (var i =
0; i < base64StrLength; i++) {
24779 var bits1 = map.indexOf(base64Str.charAt(i -
1)) << ((i %
4) *
2);
24780 var bits2 = map.indexOf(base64Str.charAt(i))
>>> (
6 - (i %
4) *
2);
24781 words[nBytes
>>> 2] |= (bits1 | bits2) << (
24 - (nBytes %
4) *
8);
24786 return WordArray.create(words, nBytes);
24789 _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
24794 return CryptoJS.enc.Base64;
24797 },{
"./core":
31}],
33:[function(_dereq_,module,exports){
24798 ;(function (root, factory) {
24799 if (typeof exports ===
"object") {
24801 module.exports = exports = factory(_dereq_(
"./core"));
24803 else if (typeof define ===
"function" && define.amd) {
24805 define([
"./core"], factory);
24808 // Global (browser)
24809 factory(root.CryptoJS);
24811 }(this, function (CryptoJS) {
24817 var WordArray = C_lib.WordArray;
24821 * UTF-
16 BE encoding strategy.
24823 var Utf16BE = C_enc.Utf16 = C_enc.Utf16BE = {
24825 * Converts a word array to a UTF-
16 BE string.
24827 * @param {WordArray} wordArray The word array.
24829 * @return {string} The UTF-
16 BE string.
24835 * var utf16String = CryptoJS.enc.Utf16.stringify(wordArray);
24837 stringify: function (wordArray) {
24839 var words = wordArray.words;
24840 var sigBytes = wordArray.sigBytes;
24843 var utf16Chars = [];
24844 for (var i =
0; i < sigBytes; i +=
2) {
24845 var codePoint = (words[i
>>> 2]
>>> (
16 - (i %
4) *
8)) &
0xffff;
24846 utf16Chars.push(String.fromCharCode(codePoint));
24849 return utf16Chars.join('');
24853 * Converts a UTF-
16 BE string to a word array.
24855 * @param {string} utf16Str The UTF-
16 BE string.
24857 * @return {WordArray} The word array.
24863 * var wordArray = CryptoJS.enc.Utf16.parse(utf16String);
24865 parse: function (utf16Str) {
24867 var utf16StrLength = utf16Str.length;
24871 for (var i =
0; i < utf16StrLength; i++) {
24872 words[i
>>> 1] |= utf16Str.charCodeAt(i) << (
16 - (i %
2) *
16);
24875 return WordArray.create(words, utf16StrLength *
2);
24880 * UTF-
16 LE encoding strategy.
24884 * Converts a word array to a UTF-
16 LE string.
24886 * @param {WordArray} wordArray The word array.
24888 * @return {string} The UTF-
16 LE string.
24894 * var utf16Str = CryptoJS.enc.Utf16LE.stringify(wordArray);
24896 stringify: function (wordArray) {
24898 var words = wordArray.words;
24899 var sigBytes = wordArray.sigBytes;
24902 var utf16Chars = [];
24903 for (var i =
0; i < sigBytes; i +=
2) {
24904 var codePoint = swapEndian((words[i
>>> 2]
>>> (
16 - (i %
4) *
8)) &
0xffff);
24905 utf16Chars.push(String.fromCharCode(codePoint));
24908 return utf16Chars.join('');
24912 * Converts a UTF-
16 LE string to a word array.
24914 * @param {string} utf16Str The UTF-
16 LE string.
24916 * @return {WordArray} The word array.
24922 * var wordArray = CryptoJS.enc.Utf16LE.parse(utf16Str);
24924 parse: function (utf16Str) {
24926 var utf16StrLength = utf16Str.length;
24930 for (var i =
0; i < utf16StrLength; i++) {
24931 words[i
>>> 1] |= swapEndian(utf16Str.charCodeAt(i) << (
16 - (i %
2) *
16));
24934 return WordArray.create(words, utf16StrLength *
2);
24938 function swapEndian(word) {
24939 return ((word <<
8) &
0xff00ff00) | ((word
>>> 8) &
0x00ff00ff);
24944 return CryptoJS.enc.Utf16;
24947 },{
"./core":
31}],
34:[function(_dereq_,module,exports){
24948 ;(function (root, factory, undef) {
24949 if (typeof exports ===
"object") {
24951 module.exports = exports = factory(_dereq_(
"./core"), _dereq_(
"./sha1"), _dereq_(
"./hmac"));
24953 else if (typeof define ===
"function" && define.amd) {
24955 define([
"./core",
"./sha1",
"./hmac"], factory);
24958 // Global (browser)
24959 factory(root.CryptoJS);
24961 }(this, function (CryptoJS) {
24967 var Base = C_lib.Base;
24968 var WordArray = C_lib.WordArray;
24969 var C_algo = C.algo;
24970 var MD5 = C_algo.MD5;
24973 * This key derivation function is meant to conform with EVP_BytesToKey.
24974 * www.openssl.org/docs/crypto/EVP_BytesToKey.html
24976 var EvpKDF = C_algo.EvpKDF = Base.extend({
24978 * Configuration options.
24980 * @property {number} keySize The key size in words to generate. Default:
4 (
128 bits)
24981 * @property {Hasher} hasher The hash algorithm to use. Default: MD5
24982 * @property {number} iterations The number of iterations to perform. Default:
1
24991 * Initializes a newly created key derivation function.
24993 * @param {Object} cfg (Optional) The configuration options to use for the derivation.
24997 * var kdf = CryptoJS.algo.EvpKDF.create();
24998 * var kdf = CryptoJS.algo.EvpKDF.create({ keySize:
8 });
24999 * var kdf = CryptoJS.algo.EvpKDF.create({ keySize:
8, iterations:
1000 });
25001 init: function (cfg) {
25002 this.cfg = this.cfg.extend(cfg);
25006 * Derives a key from a password.
25008 * @param {WordArray|string} password The password.
25009 * @param {WordArray|string} salt A salt.
25011 * @return {WordArray} The derived key.
25015 * var key = kdf.compute(password, salt);
25017 compute: function (password, salt) {
25019 var cfg = this.cfg;
25022 var hasher = cfg.hasher.create();
25025 var derivedKey = WordArray.create();
25028 var derivedKeyWords = derivedKey.words;
25029 var keySize = cfg.keySize;
25030 var iterations = cfg.iterations;
25033 while (derivedKeyWords.length < keySize) {
25035 hasher.update(block);
25037 var block = hasher.update(password).finalize(salt);
25041 for (var i =
1; i < iterations; i++) {
25042 block = hasher.finalize(block);
25046 derivedKey.concat(block);
25048 derivedKey.sigBytes = keySize *
4;
25055 * Derives a key from a password.
25057 * @param {WordArray|string} password The password.
25058 * @param {WordArray|string} salt A salt.
25059 * @param {Object} cfg (Optional) The configuration options to use for this computation.
25061 * @return {WordArray} The derived key.
25067 * var key = CryptoJS.EvpKDF(password, salt);
25068 * var key = CryptoJS.EvpKDF(password, salt, { keySize:
8 });
25069 * var key = CryptoJS.EvpKDF(password, salt, { keySize:
8, iterations:
1000 });
25071 C.EvpKDF = function (password, salt, cfg) {
25072 return EvpKDF.create(cfg).compute(password, salt);
25077 return CryptoJS.EvpKDF;
25080 },{
"./core":
31,
"./hmac":
36,
"./sha1":
55}],
35:[function(_dereq_,module,exports){
25081 ;(function (root, factory, undef) {
25082 if (typeof exports ===
"object") {
25084 module.exports = exports = factory(_dereq_(
"./core"), _dereq_(
"./cipher-core"));
25086 else if (typeof define ===
"function" && define.amd) {
25088 define([
"./core",
"./cipher-core"], factory);
25091 // Global (browser)
25092 factory(root.CryptoJS);
25094 }(this, function (CryptoJS) {
25096 (function (undefined) {
25100 var CipherParams = C_lib.CipherParams;
25102 var Hex = C_enc.Hex;
25103 var C_format = C.format;
25105 var HexFormatter = C_format.Hex = {
25107 * Converts the ciphertext of a cipher params object to a hexadecimally encoded string.
25109 * @param {CipherParams} cipherParams The cipher params object.
25111 * @return {string} The hexadecimally encoded string.
25117 * var hexString = CryptoJS.format.Hex.stringify(cipherParams);
25119 stringify: function (cipherParams) {
25120 return cipherParams.ciphertext.toString(Hex);
25124 * Converts a hexadecimally encoded ciphertext string to a cipher params object.
25126 * @param {string} input The hexadecimally encoded string.
25128 * @return {CipherParams} The cipher params object.
25134 * var cipherParams = CryptoJS.format.Hex.parse(hexString);
25136 parse: function (input) {
25137 var ciphertext = Hex.parse(input);
25138 return CipherParams.create({ ciphertext: ciphertext });
25144 return CryptoJS.format.Hex;
25147 },{
"./cipher-core":
30,
"./core":
31}],
36:[function(_dereq_,module,exports){
25148 ;(function (root, factory) {
25149 if (typeof exports ===
"object") {
25151 module.exports = exports = factory(_dereq_(
"./core"));
25153 else if (typeof define ===
"function" && define.amd) {
25155 define([
"./core"], factory);
25158 // Global (browser)
25159 factory(root.CryptoJS);
25161 }(this, function (CryptoJS) {
25167 var Base = C_lib.Base;
25169 var Utf8 = C_enc.Utf8;
25170 var C_algo = C.algo;
25175 var HMAC = C_algo.HMAC = Base.extend({
25177 * Initializes a newly created HMAC.
25179 * @param {Hasher} hasher The hash algorithm to use.
25180 * @param {WordArray|string} key The secret key.
25184 * var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
25186 init: function (hasher, key) {
25188 hasher = this._hasher = new hasher.init();
25190 // Convert string to WordArray, else assume WordArray already
25191 if (typeof key == 'string') {
25192 key = Utf8.parse(key);
25196 var hasherBlockSize = hasher.blockSize;
25197 var hasherBlockSizeBytes = hasherBlockSize *
4;
25199 // Allow arbitrary length keys
25200 if (key.sigBytes
> hasherBlockSizeBytes) {
25201 key = hasher.finalize(key);
25204 // Clamp excess bits
25207 // Clone key for inner and outer pads
25208 var oKey = this._oKey = key.clone();
25209 var iKey = this._iKey = key.clone();
25212 var oKeyWords = oKey.words;
25213 var iKeyWords = iKey.words;
25215 // XOR keys with pad constants
25216 for (var i =
0; i < hasherBlockSize; i++) {
25217 oKeyWords[i] ^=
0x5c5c5c5c;
25218 iKeyWords[i] ^=
0x36363636;
25220 oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes;
25222 // Set initial values
25227 * Resets this HMAC to its initial state.
25231 * hmacHasher.reset();
25233 reset: function () {
25235 var hasher = this._hasher;
25239 hasher.update(this._iKey);
25243 * Updates this HMAC with a message.
25245 * @param {WordArray|string} messageUpdate The message to append.
25247 * @return {HMAC} This HMAC instance.
25251 * hmacHasher.update('message');
25252 * hmacHasher.update(wordArray);
25254 update: function (messageUpdate) {
25255 this._hasher.update(messageUpdate);
25262 * Finalizes the HMAC computation.
25263 * Note that the finalize operation is effectively a destructive, read-once operation.
25265 * @param {WordArray|string} messageUpdate (Optional) A final message update.
25267 * @return {WordArray} The HMAC.
25271 * var hmac = hmacHasher.finalize();
25272 * var hmac = hmacHasher.finalize('message');
25273 * var hmac = hmacHasher.finalize(wordArray);
25275 finalize: function (messageUpdate) {
25277 var hasher = this._hasher;
25280 var innerHash = hasher.finalize(messageUpdate);
25282 var hmac = hasher.finalize(this._oKey.clone().concat(innerHash));
25291 },{"./core":
31}],
37:[function(_dereq_,module,exports){
25292 ;(function (root, factory, undef) {
25293 if (typeof exports === "object") {
25295 module.exports = exports = factory(_dereq_("./core"), _dereq_("./x64-core"), _dereq_("./lib-typedarrays"), _dereq_("./enc-utf16"), _dereq_("./enc-base64"), _dereq_("./md5"), _dereq_("./sha1"), _dereq_("./sha256"), _dereq_("./sha224"), _dereq_("./sha512"), _dereq_("./sha384"), _dereq_("./sha3"), _dereq_("./ripemd160"), _dereq_("./hmac"), _dereq_("./pbkdf2"), _dereq_("./evpkdf"), _dereq_("./cipher-core"), _dereq_("./mode-cfb"), _dereq_("./mode-ctr"), _dereq_("./mode-ctr-gladman"), _dereq_("./mode-ofb"), _dereq_("./mode-ecb"), _dereq_("./pad-ansix923"), _dereq_("./pad-iso10126"), _dereq_("./pad-iso97971"), _dereq_("./pad-zeropadding"), _dereq_("./pad-nopadding"), _dereq_("./format-hex"), _dereq_("./aes"), _dereq_("./tripledes"), _dereq_("./rc4"), _dereq_("./rabbit"), _dereq_("./rabbit-legacy"));
25297 else if (typeof define === "function" && define.amd) {
25299 define(["./core", "./x64-core", "./lib-typedarrays", "./enc-utf16", "./enc-base64", "./md5", "./sha1", "./sha256", "./sha224", "./sha512", "./sha384", "./sha3", "./ripemd160", "./hmac", "./pbkdf2", "./evpkdf", "./cipher-core", "./mode-cfb", "./mode-ctr", "./mode-ctr-gladman", "./mode-ofb", "./mode-ecb", "./pad-ansix923", "./pad-iso10126", "./pad-iso97971", "./pad-zeropadding", "./pad-nopadding", "./format-hex", "./aes", "./tripledes", "./rc4", "./rabbit", "./rabbit-legacy"], factory);
25302 // Global (browser)
25303 factory(root.CryptoJS);
25305 }(this, function (CryptoJS) {
25310 },{"./aes":
29,"./cipher-core":
30,"./core":
31,"./enc-base64":
32,"./enc-utf16":
33,"./evpkdf":
34,"./format-hex":
35,"./hmac":
36,"./lib-typedarrays":
38,"./md5":
39,"./mode-cfb":
40,"./mode-ctr":
42,"./mode-ctr-gladman":
41,"./mode-ecb":
43,"./mode-ofb":
44,"./pad-ansix923":
45,"./pad-iso10126":
46,"./pad-iso97971":
47,"./pad-nopadding":
48,"./pad-zeropadding":
49,"./pbkdf2":
50,"./rabbit":
52,"./rabbit-legacy":
51,"./rc4":
53,"./ripemd160":
54,"./sha1":
55,"./sha224":
56,"./sha256":
57,"./sha3":
58,"./sha384":
59,"./sha512":
60,"./tripledes":
61,"./x64-core":
62}],
38:[function(_dereq_,module,exports){
25311 ;(function (root, factory) {
25312 if (typeof exports === "object") {
25314 module.exports = exports = factory(_dereq_("./core"));
25316 else if (typeof define === "function" && define.amd) {
25318 define(["./core"], factory);
25321 // Global (browser)
25322 factory(root.CryptoJS);
25324 }(this, function (CryptoJS) {
25327 // Check if typed arrays are supported
25328 if (typeof ArrayBuffer != 'function') {
25335 var WordArray = C_lib.WordArray;
25337 // Reference original init
25338 var superInit = WordArray.init;
25340 // Augment WordArray.init to handle typed arrays
25341 var subInit = WordArray.init = function (typedArray) {
25342 // Convert buffers to uint8
25343 if (typedArray instanceof ArrayBuffer) {
25344 typedArray = new Uint8Array(typedArray);
25347 // Convert other array views to uint8
25349 typedArray instanceof Int8Array ||
25350 typedArray instanceof Uint8ClampedArray ||
25351 typedArray instanceof Int16Array ||
25352 typedArray instanceof Uint16Array ||
25353 typedArray instanceof Int32Array ||
25354 typedArray instanceof Uint32Array ||
25355 typedArray instanceof Float32Array ||
25356 typedArray instanceof Float64Array
25358 typedArray = new Uint8Array(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength);
25361 // Handle Uint8Array
25362 if (typedArray instanceof Uint8Array) {
25364 var typedArrayByteLength = typedArray.byteLength;
25368 for (var i =
0; i < typedArrayByteLength; i++) {
25369 words[i
>>> 2] |= typedArray[i] << (
24 - (i %
4) *
8);
25372 // Initialize this word array
25373 superInit.call(this, words, typedArrayByteLength);
25375 // Else call normal init
25376 superInit.apply(this, arguments);
25380 subInit.prototype = WordArray;
25384 return CryptoJS.lib.WordArray;
25387 },{
"./core":
31}],
39:[function(_dereq_,module,exports){
25388 ;(function (root, factory) {
25389 if (typeof exports ===
"object") {
25391 module.exports = exports = factory(_dereq_(
"./core"));
25393 else if (typeof define ===
"function" && define.amd) {
25395 define([
"./core"], factory);
25398 // Global (browser)
25399 factory(root.CryptoJS);
25401 }(this, function (CryptoJS) {
25407 var WordArray = C_lib.WordArray;
25408 var Hasher = C_lib.Hasher;
25409 var C_algo = C.algo;
25414 // Compute constants
25416 for (var i =
0; i <
64; i++) {
25417 T[i] = (Math.abs(Math.sin(i +
1)) *
0x100000000) |
0;
25422 * MD5 hash algorithm.
25424 var MD5 = C_algo.MD5 = Hasher.extend({
25425 _doReset: function () {
25426 this._hash = new WordArray.init([
25427 0x67452301,
0xefcdab89,
25428 0x98badcfe,
0x10325476
25432 _doProcessBlock: function (M, offset) {
25434 for (var i =
0; i <
16; i++) {
25436 var offset_i = offset + i;
25437 var M_offset_i = M[offset_i];
25440 (((M_offset_i <<
8) | (M_offset_i
>>> 24)) &
0x00ff00ff) |
25441 (((M_offset_i <<
24) | (M_offset_i
>>> 8)) &
0xff00ff00)
25446 var H = this._hash.words;
25448 var M_offset_0 = M[offset +
0];
25449 var M_offset_1 = M[offset +
1];
25450 var M_offset_2 = M[offset +
2];
25451 var M_offset_3 = M[offset +
3];
25452 var M_offset_4 = M[offset +
4];
25453 var M_offset_5 = M[offset +
5];
25454 var M_offset_6 = M[offset +
6];
25455 var M_offset_7 = M[offset +
7];
25456 var M_offset_8 = M[offset +
8];
25457 var M_offset_9 = M[offset +
9];
25458 var M_offset_10 = M[offset +
10];
25459 var M_offset_11 = M[offset +
11];
25460 var M_offset_12 = M[offset +
12];
25461 var M_offset_13 = M[offset +
13];
25462 var M_offset_14 = M[offset +
14];
25463 var M_offset_15 = M[offset +
15];
25465 // Working varialbes
25472 a = FF(a, b, c, d, M_offset_0,
7, T[
0]);
25473 d = FF(d, a, b, c, M_offset_1,
12, T[
1]);
25474 c = FF(c, d, a, b, M_offset_2,
17, T[
2]);
25475 b = FF(b, c, d, a, M_offset_3,
22, T[
3]);
25476 a = FF(a, b, c, d, M_offset_4,
7, T[
4]);
25477 d = FF(d, a, b, c, M_offset_5,
12, T[
5]);
25478 c = FF(c, d, a, b, M_offset_6,
17, T[
6]);
25479 b = FF(b, c, d, a, M_offset_7,
22, T[
7]);
25480 a = FF(a, b, c, d, M_offset_8,
7, T[
8]);
25481 d = FF(d, a, b, c, M_offset_9,
12, T[
9]);
25482 c = FF(c, d, a, b, M_offset_10,
17, T[
10]);
25483 b = FF(b, c, d, a, M_offset_11,
22, T[
11]);
25484 a = FF(a, b, c, d, M_offset_12,
7, T[
12]);
25485 d = FF(d, a, b, c, M_offset_13,
12, T[
13]);
25486 c = FF(c, d, a, b, M_offset_14,
17, T[
14]);
25487 b = FF(b, c, d, a, M_offset_15,
22, T[
15]);
25489 a = GG(a, b, c, d, M_offset_1,
5, T[
16]);
25490 d = GG(d, a, b, c, M_offset_6,
9, T[
17]);
25491 c = GG(c, d, a, b, M_offset_11,
14, T[
18]);
25492 b = GG(b, c, d, a, M_offset_0,
20, T[
19]);
25493 a = GG(a, b, c, d, M_offset_5,
5, T[
20]);
25494 d = GG(d, a, b, c, M_offset_10,
9, T[
21]);
25495 c = GG(c, d, a, b, M_offset_15,
14, T[
22]);
25496 b = GG(b, c, d, a, M_offset_4,
20, T[
23]);
25497 a = GG(a, b, c, d, M_offset_9,
5, T[
24]);
25498 d = GG(d, a, b, c, M_offset_14,
9, T[
25]);
25499 c = GG(c, d, a, b, M_offset_3,
14, T[
26]);
25500 b = GG(b, c, d, a, M_offset_8,
20, T[
27]);
25501 a = GG(a, b, c, d, M_offset_13,
5, T[
28]);
25502 d = GG(d, a, b, c, M_offset_2,
9, T[
29]);
25503 c = GG(c, d, a, b, M_offset_7,
14, T[
30]);
25504 b = GG(b, c, d, a, M_offset_12,
20, T[
31]);
25506 a = HH(a, b, c, d, M_offset_5,
4, T[
32]);
25507 d = HH(d, a, b, c, M_offset_8,
11, T[
33]);
25508 c = HH(c, d, a, b, M_offset_11,
16, T[
34]);
25509 b = HH(b, c, d, a, M_offset_14,
23, T[
35]);
25510 a = HH(a, b, c, d, M_offset_1,
4, T[
36]);
25511 d = HH(d, a, b, c, M_offset_4,
11, T[
37]);
25512 c = HH(c, d, a, b, M_offset_7,
16, T[
38]);
25513 b = HH(b, c, d, a, M_offset_10,
23, T[
39]);
25514 a = HH(a, b, c, d, M_offset_13,
4, T[
40]);
25515 d = HH(d, a, b, c, M_offset_0,
11, T[
41]);
25516 c = HH(c, d, a, b, M_offset_3,
16, T[
42]);
25517 b = HH(b, c, d, a, M_offset_6,
23, T[
43]);
25518 a = HH(a, b, c, d, M_offset_9,
4, T[
44]);
25519 d = HH(d, a, b, c, M_offset_12,
11, T[
45]);
25520 c = HH(c, d, a, b, M_offset_15,
16, T[
46]);
25521 b = HH(b, c, d, a, M_offset_2,
23, T[
47]);
25523 a = II(a, b, c, d, M_offset_0,
6, T[
48]);
25524 d = II(d, a, b, c, M_offset_7,
10, T[
49]);
25525 c = II(c, d, a, b, M_offset_14,
15, T[
50]);
25526 b = II(b, c, d, a, M_offset_5,
21, T[
51]);
25527 a = II(a, b, c, d, M_offset_12,
6, T[
52]);
25528 d = II(d, a, b, c, M_offset_3,
10, T[
53]);
25529 c = II(c, d, a, b, M_offset_10,
15, T[
54]);
25530 b = II(b, c, d, a, M_offset_1,
21, T[
55]);
25531 a = II(a, b, c, d, M_offset_8,
6, T[
56]);
25532 d = II(d, a, b, c, M_offset_15,
10, T[
57]);
25533 c = II(c, d, a, b, M_offset_6,
15, T[
58]);
25534 b = II(b, c, d, a, M_offset_13,
21, T[
59]);
25535 a = II(a, b, c, d, M_offset_4,
6, T[
60]);
25536 d = II(d, a, b, c, M_offset_11,
10, T[
61]);
25537 c = II(c, d, a, b, M_offset_2,
15, T[
62]);
25538 b = II(b, c, d, a, M_offset_9,
21, T[
63]);
25540 // Intermediate hash value
25541 H[
0] = (H[
0] + a) |
0;
25542 H[
1] = (H[
1] + b) |
0;
25543 H[
2] = (H[
2] + c) |
0;
25544 H[
3] = (H[
3] + d) |
0;
25547 _doFinalize: function () {
25549 var data = this._data;
25550 var dataWords = data.words;
25552 var nBitsTotal = this._nDataBytes *
8;
25553 var nBitsLeft = data.sigBytes *
8;
25556 dataWords[nBitsLeft
>>> 5] |=
0x80 << (
24 - nBitsLeft %
32);
25558 var nBitsTotalH = Math.floor(nBitsTotal /
0x100000000);
25559 var nBitsTotalL = nBitsTotal;
25560 dataWords[(((nBitsLeft +
64)
>>> 9) <<
4) +
15] = (
25561 (((nBitsTotalH <<
8) | (nBitsTotalH
>>> 24)) &
0x00ff00ff) |
25562 (((nBitsTotalH <<
24) | (nBitsTotalH
>>> 8)) &
0xff00ff00)
25564 dataWords[(((nBitsLeft +
64)
>>> 9) <<
4) +
14] = (
25565 (((nBitsTotalL <<
8) | (nBitsTotalL
>>> 24)) &
0x00ff00ff) |
25566 (((nBitsTotalL <<
24) | (nBitsTotalL
>>> 8)) &
0xff00ff00)
25569 data.sigBytes = (dataWords.length +
1) *
4;
25571 // Hash final blocks
25575 var hash = this._hash;
25576 var H = hash.words;
25579 for (var i =
0; i <
4; i++) {
25583 H[i] = (((H_i <<
8) | (H_i
>>> 24)) &
0x00ff00ff) |
25584 (((H_i <<
24) | (H_i
>>> 8)) &
0xff00ff00);
25587 // Return final computed hash
25591 clone: function () {
25592 var clone = Hasher.clone.call(this);
25593 clone._hash = this._hash.clone();
25599 function FF(a, b, c, d, x, s, t) {
25600 var n = a + ((b & c) | (~b & d)) + x + t;
25601 return ((n << s) | (n
>>> (
32 - s))) + b;
25604 function GG(a, b, c, d, x, s, t) {
25605 var n = a + ((b & d) | (c & ~d)) + x + t;
25606 return ((n << s) | (n
>>> (
32 - s))) + b;
25609 function HH(a, b, c, d, x, s, t) {
25610 var n = a + (b ^ c ^ d) + x + t;
25611 return ((n << s) | (n
>>> (
32 - s))) + b;
25614 function II(a, b, c, d, x, s, t) {
25615 var n = a + (c ^ (b | ~d)) + x + t;
25616 return ((n << s) | (n
>>> (
32 - s))) + b;
25620 * Shortcut function to the hasher's object interface.
25622 * @param {WordArray|string} message The message to hash.
25624 * @return {WordArray} The hash.
25630 * var hash = CryptoJS.MD5('message');
25631 * var hash = CryptoJS.MD5(wordArray);
25633 C.MD5 = Hasher._createHelper(MD5);
25636 * Shortcut function to the HMAC's object interface.
25638 * @param {WordArray|string} message The message to hash.
25639 * @param {WordArray|string} key The secret key.
25641 * @return {WordArray} The HMAC.
25647 * var hmac = CryptoJS.HmacMD5(message, key);
25649 C.HmacMD5 = Hasher._createHmacHelper(MD5);
25653 return CryptoJS.MD5;
25656 },{"./core":
31}],
40:[function(_dereq_,module,exports){
25657 ;(function (root, factory, undef) {
25658 if (typeof exports === "object") {
25660 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
25662 else if (typeof define === "function" && define.amd) {
25664 define(["./core", "./cipher-core"], factory);
25667 // Global (browser)
25668 factory(root.CryptoJS);
25670 }(this, function (CryptoJS) {
25673 * Cipher Feedback block mode.
25675 CryptoJS.mode.CFB = (function () {
25676 var CFB = CryptoJS.lib.BlockCipherMode.extend();
25678 CFB.Encryptor = CFB.extend({
25679 processBlock: function (words, offset) {
25681 var cipher = this._cipher;
25682 var blockSize = cipher.blockSize;
25684 generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
25686 // Remember this block to use with next block
25687 this._prevBlock = words.slice(offset, offset + blockSize);
25691 CFB.Decryptor = CFB.extend({
25692 processBlock: function (words, offset) {
25694 var cipher = this._cipher;
25695 var blockSize = cipher.blockSize;
25697 // Remember this block to use with next block
25698 var thisBlock = words.slice(offset, offset + blockSize);
25700 generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
25702 // This block becomes the previous block
25703 this._prevBlock = thisBlock;
25707 function generateKeystreamAndEncrypt(words, offset, blockSize, cipher) {
25711 // Generate keystream
25713 var keystream = iv.slice(
0);
25715 // Remove IV for subsequent blocks
25716 this._iv = undefined;
25718 var keystream = this._prevBlock;
25720 cipher.encryptBlock(keystream,
0);
25723 for (var i =
0; i < blockSize; i++) {
25724 words[offset + i] ^= keystream[i];
25732 return CryptoJS.mode.CFB;
25735 },{"./cipher-core":
30,"./core":
31}],
41:[function(_dereq_,module,exports){
25736 ;(function (root, factory, undef) {
25737 if (typeof exports === "object") {
25739 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
25741 else if (typeof define === "function" && define.amd) {
25743 define(["./core", "./cipher-core"], factory);
25746 // Global (browser)
25747 factory(root.CryptoJS);
25749 }(this, function (CryptoJS) {
25752 * Counter block mode compatible with Dr Brian Gladman fileenc.c
25753 * derived from CryptoJS.mode.CTR
25754 * Jan Hruby jhruby.web@gmail.com
25756 CryptoJS.mode.CTRGladman = (function () {
25757 var CTRGladman = CryptoJS.lib.BlockCipherMode.extend();
25759 function incWord(word)
25761 if (((word
>> 24) &
0xff) ===
0xff) { //overflow
25762 var b1 = (word
>> 16)
&0xff;
25763 var b2 = (word
>> 8)
&0xff;
25764 var b3 = word &
0xff;
25766 if (b1 ===
0xff) // overflow b1
25792 word += (b1 <<
16);
25798 word += (
0x01 <<
24);
25803 function incCounter(counter)
25805 if ((counter[
0] = incWord(counter[
0])) ===
0)
25807 // encr_data in fileenc.c from Dr Brian Gladman's counts only with DWORD j <
8
25808 counter[
1] = incWord(counter[
1]);
25813 var Encryptor = CTRGladman.Encryptor = CTRGladman.extend({
25814 processBlock: function (words, offset) {
25816 var cipher = this._cipher
25817 var blockSize = cipher.blockSize;
25819 var counter = this._counter;
25821 // Generate keystream
25823 counter = this._counter = iv.slice(
0);
25825 // Remove IV for subsequent blocks
25826 this._iv = undefined;
25829 incCounter(counter);
25831 var keystream = counter.slice(
0);
25832 cipher.encryptBlock(keystream,
0);
25835 for (var i =
0; i < blockSize; i++) {
25836 words[offset + i] ^= keystream[i];
25841 CTRGladman.Decryptor = Encryptor;
25849 return CryptoJS.mode.CTRGladman;
25852 },{
"./cipher-core":
30,
"./core":
31}],
42:[function(_dereq_,module,exports){
25853 ;(function (root, factory, undef) {
25854 if (typeof exports ===
"object") {
25856 module.exports = exports = factory(_dereq_(
"./core"), _dereq_(
"./cipher-core"));
25858 else if (typeof define ===
"function" && define.amd) {
25860 define([
"./core",
"./cipher-core"], factory);
25863 // Global (browser)
25864 factory(root.CryptoJS);
25866 }(this, function (CryptoJS) {
25869 * Counter block mode.
25871 CryptoJS.mode.CTR = (function () {
25872 var CTR = CryptoJS.lib.BlockCipherMode.extend();
25874 var Encryptor = CTR.Encryptor = CTR.extend({
25875 processBlock: function (words, offset) {
25877 var cipher = this._cipher
25878 var blockSize = cipher.blockSize;
25880 var counter = this._counter;
25882 // Generate keystream
25884 counter = this._counter = iv.slice(
0);
25886 // Remove IV for subsequent blocks
25887 this._iv = undefined;
25889 var keystream = counter.slice(
0);
25890 cipher.encryptBlock(keystream,
0);
25892 // Increment counter
25893 counter[blockSize -
1] = (counter[blockSize -
1] +
1) |
0
25896 for (var i =
0; i < blockSize; i++) {
25897 words[offset + i] ^= keystream[i];
25902 CTR.Decryptor = Encryptor;
25908 return CryptoJS.mode.CTR;
25911 },{
"./cipher-core":
30,
"./core":
31}],
43:[function(_dereq_,module,exports){
25912 ;(function (root, factory, undef) {
25913 if (typeof exports ===
"object") {
25915 module.exports = exports = factory(_dereq_(
"./core"), _dereq_(
"./cipher-core"));
25917 else if (typeof define ===
"function" && define.amd) {
25919 define([
"./core",
"./cipher-core"], factory);
25922 // Global (browser)
25923 factory(root.CryptoJS);
25925 }(this, function (CryptoJS) {
25928 * Electronic Codebook block mode.
25930 CryptoJS.mode.ECB = (function () {
25931 var ECB = CryptoJS.lib.BlockCipherMode.extend();
25933 ECB.Encryptor = ECB.extend({
25934 processBlock: function (words, offset) {
25935 this._cipher.encryptBlock(words, offset);
25939 ECB.Decryptor = ECB.extend({
25940 processBlock: function (words, offset) {
25941 this._cipher.decryptBlock(words, offset);
25949 return CryptoJS.mode.ECB;
25952 },{
"./cipher-core":
30,
"./core":
31}],
44:[function(_dereq_,module,exports){
25953 ;(function (root, factory, undef) {
25954 if (typeof exports ===
"object") {
25956 module.exports = exports = factory(_dereq_(
"./core"), _dereq_(
"./cipher-core"));
25958 else if (typeof define ===
"function" && define.amd) {
25960 define([
"./core",
"./cipher-core"], factory);
25963 // Global (browser)
25964 factory(root.CryptoJS);
25966 }(this, function (CryptoJS) {
25969 * Output Feedback block mode.
25971 CryptoJS.mode.OFB = (function () {
25972 var OFB = CryptoJS.lib.BlockCipherMode.extend();
25974 var Encryptor = OFB.Encryptor = OFB.extend({
25975 processBlock: function (words, offset) {
25977 var cipher = this._cipher
25978 var blockSize = cipher.blockSize;
25980 var keystream = this._keystream;
25982 // Generate keystream
25984 keystream = this._keystream = iv.slice(
0);
25986 // Remove IV for subsequent blocks
25987 this._iv = undefined;
25989 cipher.encryptBlock(keystream,
0);
25992 for (var i =
0; i < blockSize; i++) {
25993 words[offset + i] ^= keystream[i];
25998 OFB.Decryptor = Encryptor;
26004 return CryptoJS.mode.OFB;
26007 },{
"./cipher-core":
30,
"./core":
31}],
45:[function(_dereq_,module,exports){
26008 ;(function (root, factory, undef) {
26009 if (typeof exports ===
"object") {
26011 module.exports = exports = factory(_dereq_(
"./core"), _dereq_(
"./cipher-core"));
26013 else if (typeof define ===
"function" && define.amd) {
26015 define([
"./core",
"./cipher-core"], factory);
26018 // Global (browser)
26019 factory(root.CryptoJS);
26021 }(this, function (CryptoJS) {
26024 * ANSI X
.923 padding strategy.
26026 CryptoJS.pad.AnsiX923 = {
26027 pad: function (data, blockSize) {
26029 var dataSigBytes = data.sigBytes;
26030 var blockSizeBytes = blockSize *
4;
26032 // Count padding bytes
26033 var nPaddingBytes = blockSizeBytes - dataSigBytes % blockSizeBytes;
26035 // Compute last byte position
26036 var lastBytePos = dataSigBytes + nPaddingBytes -
1;
26040 data.words[lastBytePos
>>> 2] |= nPaddingBytes << (
24 - (lastBytePos %
4) *
8);
26041 data.sigBytes += nPaddingBytes;
26044 unpad: function (data) {
26045 // Get number of padding bytes from last byte
26046 var nPaddingBytes = data.words[(data.sigBytes -
1)
>>> 2] &
0xff;
26049 data.sigBytes -= nPaddingBytes;
26054 return CryptoJS.pad.Ansix923;
26057 },{
"./cipher-core":
30,
"./core":
31}],
46:[function(_dereq_,module,exports){
26058 ;(function (root, factory, undef) {
26059 if (typeof exports ===
"object") {
26061 module.exports = exports = factory(_dereq_(
"./core"), _dereq_(
"./cipher-core"));
26063 else if (typeof define ===
"function" && define.amd) {
26065 define([
"./core",
"./cipher-core"], factory);
26068 // Global (browser)
26069 factory(root.CryptoJS);
26071 }(this, function (CryptoJS) {
26074 * ISO
10126 padding strategy.
26076 CryptoJS.pad.Iso10126 = {
26077 pad: function (data, blockSize) {
26079 var blockSizeBytes = blockSize *
4;
26081 // Count padding bytes
26082 var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
26085 data.concat(CryptoJS.lib.WordArray.random(nPaddingBytes -
1)).
26086 concat(CryptoJS.lib.WordArray.create([nPaddingBytes <<
24],
1));
26089 unpad: function (data) {
26090 // Get number of padding bytes from last byte
26091 var nPaddingBytes = data.words[(data.sigBytes -
1)
>>> 2] &
0xff;
26094 data.sigBytes -= nPaddingBytes;
26099 return CryptoJS.pad.Iso10126;
26102 },{
"./cipher-core":
30,
"./core":
31}],
47:[function(_dereq_,module,exports){
26103 ;(function (root, factory, undef) {
26104 if (typeof exports ===
"object") {
26106 module.exports = exports = factory(_dereq_(
"./core"), _dereq_(
"./cipher-core"));
26108 else if (typeof define ===
"function" && define.amd) {
26110 define([
"./core",
"./cipher-core"], factory);
26113 // Global (browser)
26114 factory(root.CryptoJS);
26116 }(this, function (CryptoJS) {
26119 * ISO/IEC
9797-
1 Padding Method
2.
26121 CryptoJS.pad.Iso97971 = {
26122 pad: function (data, blockSize) {
26124 data.concat(CryptoJS.lib.WordArray.create([
0x80000000],
1));
26126 // Zero pad the rest
26127 CryptoJS.pad.ZeroPadding.pad(data, blockSize);
26130 unpad: function (data) {
26131 // Remove zero padding
26132 CryptoJS.pad.ZeroPadding.unpad(data);
26134 // Remove one more byte -- the
0x80 byte
26140 return CryptoJS.pad.Iso97971;
26143 },{
"./cipher-core":
30,
"./core":
31}],
48:[function(_dereq_,module,exports){
26144 ;(function (root, factory, undef) {
26145 if (typeof exports ===
"object") {
26147 module.exports = exports = factory(_dereq_(
"./core"), _dereq_(
"./cipher-core"));
26149 else if (typeof define ===
"function" && define.amd) {
26151 define([
"./core",
"./cipher-core"], factory);
26154 // Global (browser)
26155 factory(root.CryptoJS);
26157 }(this, function (CryptoJS) {
26160 * A noop padding strategy.
26162 CryptoJS.pad.NoPadding = {
26166 unpad: function () {
26171 return CryptoJS.pad.NoPadding;
26174 },{
"./cipher-core":
30,
"./core":
31}],
49:[function(_dereq_,module,exports){
26175 ;(function (root, factory, undef) {
26176 if (typeof exports ===
"object") {
26178 module.exports = exports = factory(_dereq_(
"./core"), _dereq_(
"./cipher-core"));
26180 else if (typeof define ===
"function" && define.amd) {
26182 define([
"./core",
"./cipher-core"], factory);
26185 // Global (browser)
26186 factory(root.CryptoJS);
26188 }(this, function (CryptoJS) {
26191 * Zero padding strategy.
26193 CryptoJS.pad.ZeroPadding = {
26194 pad: function (data, blockSize) {
26196 var blockSizeBytes = blockSize *
4;
26200 data.sigBytes += blockSizeBytes - ((data.sigBytes % blockSizeBytes) || blockSizeBytes);
26203 unpad: function (data) {
26205 var dataWords = data.words;
26208 var i = data.sigBytes -
1;
26209 while (!((dataWords[i
>>> 2]
>>> (
24 - (i %
4) *
8)) &
0xff)) {
26212 data.sigBytes = i +
1;
26217 return CryptoJS.pad.ZeroPadding;
26220 },{"./cipher-core":
30,"./core":
31}],
50:[function(_dereq_,module,exports){
26221 ;(function (root, factory, undef) {
26222 if (typeof exports === "object") {
26224 module.exports = exports = factory(_dereq_("./core"), _dereq_("./sha1"), _dereq_("./hmac"));
26226 else if (typeof define === "function" && define.amd) {
26228 define(["./core", "./sha1", "./hmac"], factory);
26231 // Global (browser)
26232 factory(root.CryptoJS);
26234 }(this, function (CryptoJS) {
26240 var Base = C_lib.Base;
26241 var WordArray = C_lib.WordArray;
26242 var C_algo = C.algo;
26243 var SHA1 = C_algo.SHA1;
26244 var HMAC = C_algo.HMAC;
26247 * Password-Based Key Derivation Function
2 algorithm.
26249 var PBKDF2 = C_algo.PBKDF2 = Base.extend({
26251 * Configuration options.
26253 * @property {number} keySize The key size in words to generate. Default:
4 (
128 bits)
26254 * @property {Hasher} hasher The hasher to use. Default: SHA1
26255 * @property {number} iterations The number of iterations to perform. Default:
1
26264 * Initializes a newly created key derivation function.
26266 * @param {Object} cfg (Optional) The configuration options to use for the derivation.
26270 * var kdf = CryptoJS.algo.PBKDF2.create();
26271 * var kdf = CryptoJS.algo.PBKDF2.create({ keySize:
8 });
26272 * var kdf = CryptoJS.algo.PBKDF2.create({ keySize:
8, iterations:
1000 });
26274 init: function (cfg) {
26275 this.cfg = this.cfg.extend(cfg);
26279 * Computes the Password-Based Key Derivation Function
2.
26281 * @param {WordArray|string} password The password.
26282 * @param {WordArray|string} salt A salt.
26284 * @return {WordArray} The derived key.
26288 * var key = kdf.compute(password, salt);
26290 compute: function (password, salt) {
26292 var cfg = this.cfg;
26295 var hmac = HMAC.create(cfg.hasher, password);
26298 var derivedKey = WordArray.create();
26299 var blockIndex = WordArray.create([
0x00000001]);
26302 var derivedKeyWords = derivedKey.words;
26303 var blockIndexWords = blockIndex.words;
26304 var keySize = cfg.keySize;
26305 var iterations = cfg.iterations;
26308 while (derivedKeyWords.length < keySize) {
26309 var block = hmac.update(salt).finalize(blockIndex);
26313 var blockWords = block.words;
26314 var blockWordsLength = blockWords.length;
26317 var intermediate = block;
26318 for (var i =
1; i < iterations; i++) {
26319 intermediate = hmac.finalize(intermediate);
26323 var intermediateWords = intermediate.words;
26325 // XOR intermediate with block
26326 for (var j =
0; j < blockWordsLength; j++) {
26327 blockWords[j] ^= intermediateWords[j];
26331 derivedKey.concat(block);
26332 blockIndexWords[
0]++;
26334 derivedKey.sigBytes = keySize *
4;
26341 * Computes the Password-Based Key Derivation Function
2.
26343 * @param {WordArray|string} password The password.
26344 * @param {WordArray|string} salt A salt.
26345 * @param {Object} cfg (Optional) The configuration options to use for this computation.
26347 * @return {WordArray} The derived key.
26353 * var key = CryptoJS.PBKDF2(password, salt);
26354 * var key = CryptoJS.PBKDF2(password, salt, { keySize:
8 });
26355 * var key = CryptoJS.PBKDF2(password, salt, { keySize:
8, iterations:
1000 });
26357 C.PBKDF2 = function (password, salt, cfg) {
26358 return PBKDF2.create(cfg).compute(password, salt);
26363 return CryptoJS.PBKDF2;
26366 },{"./core":
31,"./hmac":
36,"./sha1":
55}],
51:[function(_dereq_,module,exports){
26367 ;(function (root, factory, undef) {
26368 if (typeof exports === "object") {
26370 module.exports = exports = factory(_dereq_("./core"), _dereq_("./enc-base64"), _dereq_("./md5"), _dereq_("./evpkdf"), _dereq_("./cipher-core"));
26372 else if (typeof define === "function" && define.amd) {
26374 define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
26377 // Global (browser)
26378 factory(root.CryptoJS);
26380 }(this, function (CryptoJS) {
26386 var StreamCipher = C_lib.StreamCipher;
26387 var C_algo = C.algo;
26389 // Reusable objects
26395 * Rabbit stream cipher algorithm.
26397 * This is a legacy version that neglected to convert the key to little-endian.
26398 * This error doesn't affect the cipher's security,
26399 * but it does affect its compatibility with other implementations.
26401 var RabbitLegacy = C_algo.RabbitLegacy = StreamCipher.extend({
26402 _doReset: function () {
26404 var K = this._key.words;
26405 var iv = this.cfg.iv;
26407 // Generate initial state values
26408 var X = this._X = [
26409 K[
0], (K[
3] <<
16) | (K[
2]
>>> 16),
26410 K[
1], (K[
0] <<
16) | (K[
3]
>>> 16),
26411 K[
2], (K[
1] <<
16) | (K[
0]
>>> 16),
26412 K[
3], (K[
2] <<
16) | (K[
1]
>>> 16)
26415 // Generate initial counter values
26416 var C = this._C = [
26417 (K[
2] <<
16) | (K[
2]
>>> 16), (K[
0] &
0xffff0000) | (K[
1] &
0x0000ffff),
26418 (K[
3] <<
16) | (K[
3]
>>> 16), (K[
1] &
0xffff0000) | (K[
2] &
0x0000ffff),
26419 (K[
0] <<
16) | (K[
0]
>>> 16), (K[
2] &
0xffff0000) | (K[
3] &
0x0000ffff),
26420 (K[
1] <<
16) | (K[
1]
>>> 16), (K[
3] &
0xffff0000) | (K[
0] &
0x0000ffff)
26426 // Iterate the system four times
26427 for (var i =
0; i <
4; i++) {
26428 nextState.call(this);
26431 // Modify the counters
26432 for (var i =
0; i <
8; i++) {
26433 C[i] ^= X[(i +
4) &
7];
26443 // Generate four subvectors
26444 var i0 = (((IV_0 <<
8) | (IV_0
>>> 24)) &
0x00ff00ff) | (((IV_0 <<
24) | (IV_0
>>> 8)) &
0xff00ff00);
26445 var i2 = (((IV_1 <<
8) | (IV_1
>>> 24)) &
0x00ff00ff) | (((IV_1 <<
24) | (IV_1
>>> 8)) &
0xff00ff00);
26446 var i1 = (i0
>>> 16) | (i2 &
0xffff0000);
26447 var i3 = (i2 <<
16) | (i0 &
0x0000ffff);
26449 // Modify counter values
26459 // Iterate the system four times
26460 for (var i =
0; i <
4; i++) {
26461 nextState.call(this);
26466 _doProcessBlock: function (M, offset) {
26470 // Iterate the system
26471 nextState.call(this);
26473 // Generate four keystream words
26474 S[
0] = X[
0] ^ (X[
5]
>>> 16) ^ (X[
3] <<
16);
26475 S[
1] = X[
2] ^ (X[
7]
>>> 16) ^ (X[
5] <<
16);
26476 S[
2] = X[
4] ^ (X[
1]
>>> 16) ^ (X[
7] <<
16);
26477 S[
3] = X[
6] ^ (X[
3]
>>> 16) ^ (X[
1] <<
16);
26479 for (var i =
0; i <
4; i++) {
26481 S[i] = (((S[i] <<
8) | (S[i]
>>> 24)) &
0x00ff00ff) |
26482 (((S[i] <<
24) | (S[i]
>>> 8)) &
0xff00ff00);
26485 M[offset + i] ^= S[i];
26494 function nextState() {
26499 // Save old counter values
26500 for (var i =
0; i <
8; i++) {
26504 // Calculate new counter values
26505 C[
0] = (C[
0] +
0x4d34d34d + this._b) |
0;
26506 C[
1] = (C[
1] +
0xd34d34d3 + ((C[
0]
>>> 0) < (C_[
0]
>>> 0) ?
1 :
0)) |
0;
26507 C[
2] = (C[
2] +
0x34d34d34 + ((C[
1]
>>> 0) < (C_[
1]
>>> 0) ?
1 :
0)) |
0;
26508 C[
3] = (C[
3] +
0x4d34d34d + ((C[
2]
>>> 0) < (C_[
2]
>>> 0) ?
1 :
0)) |
0;
26509 C[
4] = (C[
4] +
0xd34d34d3 + ((C[
3]
>>> 0) < (C_[
3]
>>> 0) ?
1 :
0)) |
0;
26510 C[
5] = (C[
5] +
0x34d34d34 + ((C[
4]
>>> 0) < (C_[
4]
>>> 0) ?
1 :
0)) |
0;
26511 C[
6] = (C[
6] +
0x4d34d34d + ((C[
5]
>>> 0) < (C_[
5]
>>> 0) ?
1 :
0)) |
0;
26512 C[
7] = (C[
7] +
0xd34d34d3 + ((C[
6]
>>> 0) < (C_[
6]
>>> 0) ?
1 :
0)) |
0;
26513 this._b = (C[
7]
>>> 0) < (C_[
7]
>>> 0) ?
1 :
0;
26515 // Calculate the g-values
26516 for (var i =
0; i <
8; i++) {
26517 var gx = X[i] + C[i];
26519 // Construct high and low argument for squaring
26520 var ga = gx &
0xffff;
26521 var gb = gx
>>> 16;
26523 // Calculate high and low result of squaring
26524 var gh = ((((ga * ga)
>>> 17) + ga * gb)
>>> 15) + gb * gb;
26525 var gl = (((gx &
0xffff0000) * gx) |
0) + (((gx &
0x0000ffff) * gx) |
0);
26531 // Calculate new state values
26532 X[
0] = (G[
0] + ((G[
7] <<
16) | (G[
7]
>>> 16)) + ((G[
6] <<
16) | (G[
6]
>>> 16))) |
0;
26533 X[
1] = (G[
1] + ((G[
0] <<
8) | (G[
0]
>>> 24)) + G[
7]) |
0;
26534 X[
2] = (G[
2] + ((G[
1] <<
16) | (G[
1]
>>> 16)) + ((G[
0] <<
16) | (G[
0]
>>> 16))) |
0;
26535 X[
3] = (G[
3] + ((G[
2] <<
8) | (G[
2]
>>> 24)) + G[
1]) |
0;
26536 X[
4] = (G[
4] + ((G[
3] <<
16) | (G[
3]
>>> 16)) + ((G[
2] <<
16) | (G[
2]
>>> 16))) |
0;
26537 X[
5] = (G[
5] + ((G[
4] <<
8) | (G[
4]
>>> 24)) + G[
3]) |
0;
26538 X[
6] = (G[
6] + ((G[
5] <<
16) | (G[
5]
>>> 16)) + ((G[
4] <<
16) | (G[
4]
>>> 16))) |
0;
26539 X[
7] = (G[
7] + ((G[
6] <<
8) | (G[
6]
>>> 24)) + G[
5]) |
0;
26543 * Shortcut functions to the cipher's object interface.
26547 * var ciphertext = CryptoJS.RabbitLegacy.encrypt(message, key, cfg);
26548 * var plaintext = CryptoJS.RabbitLegacy.decrypt(ciphertext, key, cfg);
26550 C.RabbitLegacy = StreamCipher._createHelper(RabbitLegacy);
26554 return CryptoJS.RabbitLegacy;
26557 },{
"./cipher-core":
30,
"./core":
31,
"./enc-base64":
32,
"./evpkdf":
34,
"./md5":
39}],
52:[function(_dereq_,module,exports){
26558 ;(function (root, factory, undef) {
26559 if (typeof exports ===
"object") {
26561 module.exports = exports = factory(_dereq_(
"./core"), _dereq_(
"./enc-base64"), _dereq_(
"./md5"), _dereq_(
"./evpkdf"), _dereq_(
"./cipher-core"));
26563 else if (typeof define ===
"function" && define.amd) {
26565 define([
"./core",
"./enc-base64",
"./md5",
"./evpkdf",
"./cipher-core"], factory);
26568 // Global (browser)
26569 factory(root.CryptoJS);
26571 }(this, function (CryptoJS) {
26577 var StreamCipher = C_lib.StreamCipher;
26578 var C_algo = C.algo;
26580 // Reusable objects
26586 * Rabbit stream cipher algorithm
26588 var Rabbit = C_algo.Rabbit = StreamCipher.extend({
26589 _doReset: function () {
26591 var K = this._key.words;
26592 var iv = this.cfg.iv;
26595 for (var i =
0; i <
4; i++) {
26596 K[i] = (((K[i] <<
8) | (K[i]
>>> 24)) &
0x00ff00ff) |
26597 (((K[i] <<
24) | (K[i]
>>> 8)) &
0xff00ff00);
26600 // Generate initial state values
26601 var X = this._X = [
26602 K[
0], (K[
3] <<
16) | (K[
2]
>>> 16),
26603 K[
1], (K[
0] <<
16) | (K[
3]
>>> 16),
26604 K[
2], (K[
1] <<
16) | (K[
0]
>>> 16),
26605 K[
3], (K[
2] <<
16) | (K[
1]
>>> 16)
26608 // Generate initial counter values
26609 var C = this._C = [
26610 (K[
2] <<
16) | (K[
2]
>>> 16), (K[
0] &
0xffff0000) | (K[
1] &
0x0000ffff),
26611 (K[
3] <<
16) | (K[
3]
>>> 16), (K[
1] &
0xffff0000) | (K[
2] &
0x0000ffff),
26612 (K[
0] <<
16) | (K[
0]
>>> 16), (K[
2] &
0xffff0000) | (K[
3] &
0x0000ffff),
26613 (K[
1] <<
16) | (K[
1]
>>> 16), (K[
3] &
0xffff0000) | (K[
0] &
0x0000ffff)
26619 // Iterate the system four times
26620 for (var i =
0; i <
4; i++) {
26621 nextState.call(this);
26624 // Modify the counters
26625 for (var i =
0; i <
8; i++) {
26626 C[i] ^= X[(i +
4) &
7];
26636 // Generate four subvectors
26637 var i0 = (((IV_0 <<
8) | (IV_0
>>> 24)) &
0x00ff00ff) | (((IV_0 <<
24) | (IV_0
>>> 8)) &
0xff00ff00);
26638 var i2 = (((IV_1 <<
8) | (IV_1
>>> 24)) &
0x00ff00ff) | (((IV_1 <<
24) | (IV_1
>>> 8)) &
0xff00ff00);
26639 var i1 = (i0
>>> 16) | (i2 &
0xffff0000);
26640 var i3 = (i2 <<
16) | (i0 &
0x0000ffff);
26642 // Modify counter values
26652 // Iterate the system four times
26653 for (var i =
0; i <
4; i++) {
26654 nextState.call(this);
26659 _doProcessBlock: function (M, offset) {
26663 // Iterate the system
26664 nextState.call(this);
26666 // Generate four keystream words
26667 S[
0] = X[
0] ^ (X[
5]
>>> 16) ^ (X[
3] <<
16);
26668 S[
1] = X[
2] ^ (X[
7]
>>> 16) ^ (X[
5] <<
16);
26669 S[
2] = X[
4] ^ (X[
1]
>>> 16) ^ (X[
7] <<
16);
26670 S[
3] = X[
6] ^ (X[
3]
>>> 16) ^ (X[
1] <<
16);
26672 for (var i =
0; i <
4; i++) {
26674 S[i] = (((S[i] <<
8) | (S[i]
>>> 24)) &
0x00ff00ff) |
26675 (((S[i] <<
24) | (S[i]
>>> 8)) &
0xff00ff00);
26678 M[offset + i] ^= S[i];
26687 function nextState() {
26692 // Save old counter values
26693 for (var i =
0; i <
8; i++) {
26697 // Calculate new counter values
26698 C[
0] = (C[
0] +
0x4d34d34d + this._b) |
0;
26699 C[
1] = (C[
1] +
0xd34d34d3 + ((C[
0]
>>> 0) < (C_[
0]
>>> 0) ?
1 :
0)) |
0;
26700 C[
2] = (C[
2] +
0x34d34d34 + ((C[
1]
>>> 0) < (C_[
1]
>>> 0) ?
1 :
0)) |
0;
26701 C[
3] = (C[
3] +
0x4d34d34d + ((C[
2]
>>> 0) < (C_[
2]
>>> 0) ?
1 :
0)) |
0;
26702 C[
4] = (C[
4] +
0xd34d34d3 + ((C[
3]
>>> 0) < (C_[
3]
>>> 0) ?
1 :
0)) |
0;
26703 C[
5] = (C[
5] +
0x34d34d34 + ((C[
4]
>>> 0) < (C_[
4]
>>> 0) ?
1 :
0)) |
0;
26704 C[
6] = (C[
6] +
0x4d34d34d + ((C[
5]
>>> 0) < (C_[
5]
>>> 0) ?
1 :
0)) |
0;
26705 C[
7] = (C[
7] +
0xd34d34d3 + ((C[
6]
>>> 0) < (C_[
6]
>>> 0) ?
1 :
0)) |
0;
26706 this._b = (C[
7]
>>> 0) < (C_[
7]
>>> 0) ?
1 :
0;
26708 // Calculate the g-values
26709 for (var i =
0; i <
8; i++) {
26710 var gx = X[i] + C[i];
26712 // Construct high and low argument for squaring
26713 var ga = gx &
0xffff;
26714 var gb = gx
>>> 16;
26716 // Calculate high and low result of squaring
26717 var gh = ((((ga * ga)
>>> 17) + ga * gb)
>>> 15) + gb * gb;
26718 var gl = (((gx &
0xffff0000) * gx) |
0) + (((gx &
0x0000ffff) * gx) |
0);
26724 // Calculate new state values
26725 X[
0] = (G[
0] + ((G[
7] <<
16) | (G[
7]
>>> 16)) + ((G[
6] <<
16) | (G[
6]
>>> 16))) |
0;
26726 X[
1] = (G[
1] + ((G[
0] <<
8) | (G[
0]
>>> 24)) + G[
7]) |
0;
26727 X[
2] = (G[
2] + ((G[
1] <<
16) | (G[
1]
>>> 16)) + ((G[
0] <<
16) | (G[
0]
>>> 16))) |
0;
26728 X[
3] = (G[
3] + ((G[
2] <<
8) | (G[
2]
>>> 24)) + G[
1]) |
0;
26729 X[
4] = (G[
4] + ((G[
3] <<
16) | (G[
3]
>>> 16)) + ((G[
2] <<
16) | (G[
2]
>>> 16))) |
0;
26730 X[
5] = (G[
5] + ((G[
4] <<
8) | (G[
4]
>>> 24)) + G[
3]) |
0;
26731 X[
6] = (G[
6] + ((G[
5] <<
16) | (G[
5]
>>> 16)) + ((G[
4] <<
16) | (G[
4]
>>> 16))) |
0;
26732 X[
7] = (G[
7] + ((G[
6] <<
8) | (G[
6]
>>> 24)) + G[
5]) |
0;
26736 * Shortcut functions to the cipher's object interface.
26740 * var ciphertext = CryptoJS.Rabbit.encrypt(message, key, cfg);
26741 * var plaintext = CryptoJS.Rabbit.decrypt(ciphertext, key, cfg);
26743 C.Rabbit = StreamCipher._createHelper(Rabbit);
26747 return CryptoJS.Rabbit;
26750 },{
"./cipher-core":
30,
"./core":
31,
"./enc-base64":
32,
"./evpkdf":
34,
"./md5":
39}],
53:[function(_dereq_,module,exports){
26751 ;(function (root, factory, undef) {
26752 if (typeof exports ===
"object") {
26754 module.exports = exports = factory(_dereq_(
"./core"), _dereq_(
"./enc-base64"), _dereq_(
"./md5"), _dereq_(
"./evpkdf"), _dereq_(
"./cipher-core"));
26756 else if (typeof define ===
"function" && define.amd) {
26758 define([
"./core",
"./enc-base64",
"./md5",
"./evpkdf",
"./cipher-core"], factory);
26761 // Global (browser)
26762 factory(root.CryptoJS);
26764 }(this, function (CryptoJS) {
26770 var StreamCipher = C_lib.StreamCipher;
26771 var C_algo = C.algo;
26774 * RC4 stream cipher algorithm.
26776 var RC4 = C_algo.RC4 = StreamCipher.extend({
26777 _doReset: function () {
26779 var key = this._key;
26780 var keyWords = key.words;
26781 var keySigBytes = key.sigBytes;
26784 var S = this._S = [];
26785 for (var i =
0; i <
256; i++) {
26790 for (var i =
0, j =
0; i <
256; i++) {
26791 var keyByteIndex = i % keySigBytes;
26792 var keyByte = (keyWords[keyByteIndex
>>> 2]
>>> (
24 - (keyByteIndex %
4) *
8)) &
0xff;
26794 j = (j + S[i] + keyByte) %
256;
26803 this._i = this._j =
0;
26806 _doProcessBlock: function (M, offset) {
26807 M[offset] ^= generateKeystreamWord.call(this);
26815 function generateKeystreamWord() {
26821 // Generate keystream word
26822 var keystreamWord =
0;
26823 for (var n =
0; n <
4; n++) {
26825 j = (j + S[i]) %
256;
26832 keystreamWord |= S[(S[i] + S[j]) %
256] << (
24 - n *
8);
26839 return keystreamWord;
26843 * Shortcut functions to the cipher's object interface.
26847 * var ciphertext = CryptoJS.RC4.encrypt(message, key, cfg);
26848 * var plaintext = CryptoJS.RC4.decrypt(ciphertext, key, cfg);
26850 C.RC4 = StreamCipher._createHelper(RC4);
26853 * Modified RC4 stream cipher algorithm.
26855 var RC4Drop = C_algo.RC4Drop = RC4.extend({
26857 * Configuration options.
26859 * @property {number} drop The number of keystream words to drop. Default
192
26861 cfg: RC4.cfg.extend({
26865 _doReset: function () {
26866 RC4._doReset.call(this);
26869 for (var i = this.cfg.drop; i
> 0; i--) {
26870 generateKeystreamWord.call(this);
26876 * Shortcut functions to the cipher's object interface.
26880 * var ciphertext = CryptoJS.RC4Drop.encrypt(message, key, cfg);
26881 * var plaintext = CryptoJS.RC4Drop.decrypt(ciphertext, key, cfg);
26883 C.RC4Drop = StreamCipher._createHelper(RC4Drop);
26887 return CryptoJS.RC4;
26890 },{
"./cipher-core":
30,
"./core":
31,
"./enc-base64":
32,
"./evpkdf":
34,
"./md5":
39}],
54:[function(_dereq_,module,exports){
26891 ;(function (root, factory) {
26892 if (typeof exports ===
"object") {
26894 module.exports = exports = factory(_dereq_(
"./core"));
26896 else if (typeof define ===
"function" && define.amd) {
26898 define([
"./core"], factory);
26901 // Global (browser)
26902 factory(root.CryptoJS);
26904 }(this, function (CryptoJS) {
26907 (c)
2012 by Cédric Mesnil. All rights reserved.
26909 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
26911 - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
26912 - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
26914 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26921 var WordArray = C_lib.WordArray;
26922 var Hasher = C_lib.Hasher;
26923 var C_algo = C.algo;
26926 var _zl = WordArray.create([
26927 0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
26928 7,
4,
13,
1,
10,
6,
15,
3,
12,
0,
9,
5,
2,
14,
11,
8,
26929 3,
10,
14,
4,
9,
15,
8,
1,
2,
7,
0,
6,
13,
11,
5,
12,
26930 1,
9,
11,
10,
0,
8,
12,
4,
13,
3,
7,
15,
14,
5,
6,
2,
26931 4,
0,
5,
9,
7,
12,
2,
10,
14,
1,
3,
8,
11,
6,
15,
13]);
26932 var _zr = WordArray.create([
26933 5,
14,
7,
0,
9,
2,
11,
4,
13,
6,
15,
8,
1,
10,
3,
12,
26934 6,
11,
3,
7,
0,
13,
5,
10,
14,
15,
8,
12,
4,
9,
1,
2,
26935 15,
5,
1,
3,
7,
14,
6,
9,
11,
8,
12,
2,
10,
0,
4,
13,
26936 8,
6,
4,
1,
3,
11,
15,
0,
5,
12,
2,
13,
9,
7,
10,
14,
26937 12,
15,
10,
4,
1,
5,
8,
7,
6,
2,
13,
14,
0,
3,
9,
11]);
26938 var _sl = WordArray.create([
26939 11,
14,
15,
12,
5,
8,
7,
9,
11,
13,
14,
15,
6,
7,
9,
8,
26940 7,
6,
8,
13,
11,
9,
7,
15,
7,
12,
15,
9,
11,
7,
13,
12,
26941 11,
13,
6,
7,
14,
9,
13,
15,
14,
8,
13,
6,
5,
12,
7,
5,
26942 11,
12,
14,
15,
14,
15,
9,
8,
9,
14,
5,
6,
8,
6,
5,
12,
26943 9,
15,
5,
11,
6,
8,
13,
12,
5,
12,
13,
14,
11,
8,
5,
6 ]);
26944 var _sr = WordArray.create([
26945 8,
9,
9,
11,
13,
15,
15,
5,
7,
7,
8,
11,
14,
14,
12,
6,
26946 9,
13,
15,
7,
12,
8,
9,
11,
7,
7,
12,
7,
6,
15,
13,
11,
26947 9,
7,
15,
11,
8,
6,
6,
14,
12,
13,
5,
14,
13,
13,
7,
5,
26948 15,
5,
8,
11,
14,
14,
6,
14,
6,
9,
12,
9,
12,
5,
15,
8,
26949 8,
5,
12,
9,
12,
5,
14,
6,
8,
13,
6,
5,
15,
13,
11,
11 ]);
26951 var _hl = WordArray.create([
0x00000000,
0x5A827999,
0x6ED9EBA1,
0x8F1BBCDC,
0xA953FD4E]);
26952 var _hr = WordArray.create([
0x50A28BE6,
0x5C4DD124,
0x6D703EF3,
0x7A6D76E9,
0x00000000]);
26955 * RIPEMD160 hash algorithm.
26957 var RIPEMD160 = C_algo.RIPEMD160 = Hasher.extend({
26958 _doReset: function () {
26959 this._hash = WordArray.create([
0x67452301,
0xEFCDAB89,
0x98BADCFE,
0x10325476,
0xC3D2E1F0]);
26962 _doProcessBlock: function (M, offset) {
26965 for (var i =
0; i <
16; i++) {
26967 var offset_i = offset + i;
26968 var M_offset_i = M[offset_i];
26972 (((M_offset_i <<
8) | (M_offset_i
>>> 24)) &
0x00ff00ff) |
26973 (((M_offset_i <<
24) | (M_offset_i
>>> 8)) &
0xff00ff00)
26977 var H = this._hash.words;
26978 var hl = _hl.words;
26979 var hr = _hr.words;
26980 var zl = _zl.words;
26981 var zr = _zr.words;
26982 var sl = _sl.words;
26983 var sr = _sr.words;
26985 // Working variables
26986 var al, bl, cl, dl, el;
26987 var ar, br, cr, dr, er;
26996 for (var i =
0; i <
80; i +=
1) {
26997 t = (al + M[offset+zl[i]])|
0;
26999 t += f1(bl,cl,dl) + hl[
0];
27001 t += f2(bl,cl,dl) + hl[
1];
27003 t += f3(bl,cl,dl) + hl[
2];
27005 t += f4(bl,cl,dl) + hl[
3];
27006 } else {// if (i
<80) {
27007 t += f5(bl,cl,dl) + hl[
4];
27018 t = (ar + M[offset+zr[i]])|
0;
27020 t += f5(br,cr,dr) + hr[
0];
27022 t += f4(br,cr,dr) + hr[
1];
27024 t += f3(br,cr,dr) + hr[
2];
27026 t += f2(br,cr,dr) + hr[
3];
27027 } else {// if (i
<80) {
27028 t += f1(br,cr,dr) + hr[
4];
27031 t = rotl(t,sr[i]) ;
27039 // Intermediate hash value
27040 t = (H[
1] + cl + dr)|
0;
27041 H[
1] = (H[
2] + dl + er)|
0;
27042 H[
2] = (H[
3] + el + ar)|
0;
27043 H[
3] = (H[
4] + al + br)|
0;
27044 H[
4] = (H[
0] + bl + cr)|
0;
27048 _doFinalize: function () {
27050 var data = this._data;
27051 var dataWords = data.words;
27053 var nBitsTotal = this._nDataBytes *
8;
27054 var nBitsLeft = data.sigBytes *
8;
27057 dataWords[nBitsLeft
>>> 5] |=
0x80 << (
24 - nBitsLeft %
32);
27058 dataWords[(((nBitsLeft +
64)
>>> 9) <<
4) +
14] = (
27059 (((nBitsTotal <<
8) | (nBitsTotal
>>> 24)) &
0x00ff00ff) |
27060 (((nBitsTotal <<
24) | (nBitsTotal
>>> 8)) &
0xff00ff00)
27062 data.sigBytes = (dataWords.length +
1) *
4;
27064 // Hash final blocks
27068 var hash = this._hash;
27069 var H = hash.words;
27072 for (var i =
0; i <
5; i++) {
27077 H[i] = (((H_i <<
8) | (H_i
>>> 24)) &
0x00ff00ff) |
27078 (((H_i <<
24) | (H_i
>>> 8)) &
0xff00ff00);
27081 // Return final computed hash
27085 clone: function () {
27086 var clone = Hasher.clone.call(this);
27087 clone._hash = this._hash.clone();
27094 function f1(x, y, z) {
27095 return ((x) ^ (y) ^ (z));
27099 function f2(x, y, z) {
27100 return (((x)&(y)) | ((~x)&(z)));
27103 function f3(x, y, z) {
27104 return (((x) | (~(y))) ^ (z));
27107 function f4(x, y, z) {
27108 return (((x) & (z)) | ((y)&(~(z))));
27111 function f5(x, y, z) {
27112 return ((x) ^ ((y) |(~(z))));
27116 function rotl(x,n) {
27117 return (x<
<n) | (x
>>>(
32-n));
27122 * Shortcut function to the hasher's object interface.
27124 * @param {WordArray|string} message The message to hash.
27126 * @return {WordArray} The hash.
27132 * var hash = CryptoJS.RIPEMD160('message');
27133 * var hash = CryptoJS.RIPEMD160(wordArray);
27135 C.RIPEMD160 = Hasher._createHelper(RIPEMD160);
27138 * Shortcut function to the HMAC's object interface.
27140 * @param {WordArray|string} message The message to hash.
27141 * @param {WordArray|string} key The secret key.
27143 * @return {WordArray} The HMAC.
27149 * var hmac = CryptoJS.HmacRIPEMD160(message, key);
27151 C.HmacRIPEMD160 = Hasher._createHmacHelper(RIPEMD160);
27155 return CryptoJS.RIPEMD160;
27158 },{"./core":
31}],
55:[function(_dereq_,module,exports){
27159 ;(function (root, factory) {
27160 if (typeof exports === "object") {
27162 module.exports = exports = factory(_dereq_("./core"));
27164 else if (typeof define === "function" && define.amd) {
27166 define(["./core"], factory);
27169 // Global (browser)
27170 factory(root.CryptoJS);
27172 }(this, function (CryptoJS) {
27178 var WordArray = C_lib.WordArray;
27179 var Hasher = C_lib.Hasher;
27180 var C_algo = C.algo;
27186 * SHA-
1 hash algorithm.
27188 var SHA1 = C_algo.SHA1 = Hasher.extend({
27189 _doReset: function () {
27190 this._hash = new WordArray.init([
27191 0x67452301,
0xefcdab89,
27192 0x98badcfe,
0x10325476,
27197 _doProcessBlock: function (M, offset) {
27199 var H = this._hash.words;
27201 // Working variables
27209 for (var i =
0; i <
80; i++) {
27211 W[i] = M[offset + i] |
0;
27213 var n = W[i -
3] ^ W[i -
8] ^ W[i -
14] ^ W[i -
16];
27214 W[i] = (n <<
1) | (n
>>> 31);
27217 var t = ((a <<
5) | (a
>>> 27)) + e + W[i];
27219 t += ((b & c) | (~b & d)) +
0x5a827999;
27220 } else if (i <
40) {
27221 t += (b ^ c ^ d) +
0x6ed9eba1;
27222 } else if (i <
60) {
27223 t += ((b & c) | (b & d) | (c & d)) -
0x70e44324;
27224 } else /* if (i <
80) */ {
27225 t += (b ^ c ^ d) -
0x359d3e2a;
27230 c = (b <<
30) | (b
>>> 2);
27235 // Intermediate hash value
27236 H[
0] = (H[
0] + a) |
0;
27237 H[
1] = (H[
1] + b) |
0;
27238 H[
2] = (H[
2] + c) |
0;
27239 H[
3] = (H[
3] + d) |
0;
27240 H[
4] = (H[
4] + e) |
0;
27243 _doFinalize: function () {
27245 var data = this._data;
27246 var dataWords = data.words;
27248 var nBitsTotal = this._nDataBytes *
8;
27249 var nBitsLeft = data.sigBytes *
8;
27252 dataWords[nBitsLeft
>>> 5] |=
0x80 << (
24 - nBitsLeft %
32);
27253 dataWords[(((nBitsLeft +
64)
>>> 9) <<
4) +
14] = Math.floor(nBitsTotal /
0x100000000);
27254 dataWords[(((nBitsLeft +
64)
>>> 9) <<
4) +
15] = nBitsTotal;
27255 data.sigBytes = dataWords.length *
4;
27257 // Hash final blocks
27260 // Return final computed hash
27264 clone: function () {
27265 var clone = Hasher.clone.call(this);
27266 clone._hash = this._hash.clone();
27273 * Shortcut function to the hasher's object interface.
27275 * @param {WordArray|string} message The message to hash.
27277 * @return {WordArray} The hash.
27283 * var hash = CryptoJS.SHA1('message');
27284 * var hash = CryptoJS.SHA1(wordArray);
27286 C.SHA1 = Hasher._createHelper(SHA1);
27289 * Shortcut function to the HMAC's object interface.
27291 * @param {WordArray|string} message The message to hash.
27292 * @param {WordArray|string} key The secret key.
27294 * @return {WordArray} The HMAC.
27300 * var hmac = CryptoJS.HmacSHA1(message, key);
27302 C.HmacSHA1 = Hasher._createHmacHelper(SHA1);
27306 return CryptoJS.SHA1;
27309 },{
"./core":
31}],
56:[function(_dereq_,module,exports){
27310 ;(function (root, factory, undef) {
27311 if (typeof exports ===
"object") {
27313 module.exports = exports = factory(_dereq_(
"./core"), _dereq_(
"./sha256"));
27315 else if (typeof define ===
"function" && define.amd) {
27317 define([
"./core",
"./sha256"], factory);
27320 // Global (browser)
27321 factory(root.CryptoJS);
27323 }(this, function (CryptoJS) {
27329 var WordArray = C_lib.WordArray;
27330 var C_algo = C.algo;
27331 var SHA256 = C_algo.SHA256;
27334 * SHA-
224 hash algorithm.
27336 var SHA224 = C_algo.SHA224 = SHA256.extend({
27337 _doReset: function () {
27338 this._hash = new WordArray.init([
27339 0xc1059ed8,
0x367cd507,
0x3070dd17,
0xf70e5939,
27340 0xffc00b31,
0x68581511,
0x64f98fa7,
0xbefa4fa4
27344 _doFinalize: function () {
27345 var hash = SHA256._doFinalize.call(this);
27347 hash.sigBytes -=
4;
27354 * Shortcut function to the hasher's object interface.
27356 * @param {WordArray|string} message The message to hash.
27358 * @return {WordArray} The hash.
27364 * var hash = CryptoJS.SHA224('message');
27365 * var hash = CryptoJS.SHA224(wordArray);
27367 C.SHA224 = SHA256._createHelper(SHA224);
27370 * Shortcut function to the HMAC's object interface.
27372 * @param {WordArray|string} message The message to hash.
27373 * @param {WordArray|string} key The secret key.
27375 * @return {WordArray} The HMAC.
27381 * var hmac = CryptoJS.HmacSHA224(message, key);
27383 C.HmacSHA224 = SHA256._createHmacHelper(SHA224);
27387 return CryptoJS.SHA224;
27390 },{
"./core":
31,
"./sha256":
57}],
57:[function(_dereq_,module,exports){
27391 ;(function (root, factory) {
27392 if (typeof exports ===
"object") {
27394 module.exports = exports = factory(_dereq_(
"./core"));
27396 else if (typeof define ===
"function" && define.amd) {
27398 define([
"./core"], factory);
27401 // Global (browser)
27402 factory(root.CryptoJS);
27404 }(this, function (CryptoJS) {
27410 var WordArray = C_lib.WordArray;
27411 var Hasher = C_lib.Hasher;
27412 var C_algo = C.algo;
27414 // Initialization and round constants tables
27418 // Compute constants
27420 function isPrime(n) {
27421 var sqrtN = Math.sqrt(n);
27422 for (var factor =
2; factor <= sqrtN; factor++) {
27423 if (!(n % factor)) {
27431 function getFractionalBits(n) {
27432 return ((n - (n |
0)) *
0x100000000) |
0;
27437 while (nPrime <
64) {
27440 H[nPrime] = getFractionalBits(Math.pow(n,
1 /
2));
27442 K[nPrime] = getFractionalBits(Math.pow(n,
1 /
3));
27455 * SHA-
256 hash algorithm.
27457 var SHA256 = C_algo.SHA256 = Hasher.extend({
27458 _doReset: function () {
27459 this._hash = new WordArray.init(H.slice(
0));
27462 _doProcessBlock: function (M, offset) {
27464 var H = this._hash.words;
27466 // Working variables
27477 for (var i =
0; i <
64; i++) {
27479 W[i] = M[offset + i] |
0;
27481 var gamma0x = W[i -
15];
27482 var gamma0 = ((gamma0x <<
25) | (gamma0x
>>> 7)) ^
27483 ((gamma0x <<
14) | (gamma0x
>>> 18)) ^
27486 var gamma1x = W[i -
2];
27487 var gamma1 = ((gamma1x <<
15) | (gamma1x
>>> 17)) ^
27488 ((gamma1x <<
13) | (gamma1x
>>> 19)) ^
27491 W[i] = gamma0 + W[i -
7] + gamma1 + W[i -
16];
27494 var ch = (e & f) ^ (~e & g);
27495 var maj = (a & b) ^ (a & c) ^ (b & c);
27497 var sigma0 = ((a <<
30) | (a
>>> 2)) ^ ((a <<
19) | (a
>>> 13)) ^ ((a <<
10) | (a
>>> 22));
27498 var sigma1 = ((e <<
26) | (e
>>> 6)) ^ ((e <<
21) | (e
>>> 11)) ^ ((e <<
7) | (e
>>> 25));
27500 var t1 = h + sigma1 + ch + K[i] + W[i];
27501 var t2 = sigma0 + maj;
27513 // Intermediate hash value
27514 H[
0] = (H[
0] + a) |
0;
27515 H[
1] = (H[
1] + b) |
0;
27516 H[
2] = (H[
2] + c) |
0;
27517 H[
3] = (H[
3] + d) |
0;
27518 H[
4] = (H[
4] + e) |
0;
27519 H[
5] = (H[
5] + f) |
0;
27520 H[
6] = (H[
6] + g) |
0;
27521 H[
7] = (H[
7] + h) |
0;
27524 _doFinalize: function () {
27526 var data = this._data;
27527 var dataWords = data.words;
27529 var nBitsTotal = this._nDataBytes *
8;
27530 var nBitsLeft = data.sigBytes *
8;
27533 dataWords[nBitsLeft
>>> 5] |=
0x80 << (
24 - nBitsLeft %
32);
27534 dataWords[(((nBitsLeft +
64)
>>> 9) <<
4) +
14] = Math.floor(nBitsTotal /
0x100000000);
27535 dataWords[(((nBitsLeft +
64)
>>> 9) <<
4) +
15] = nBitsTotal;
27536 data.sigBytes = dataWords.length *
4;
27538 // Hash final blocks
27541 // Return final computed hash
27545 clone: function () {
27546 var clone = Hasher.clone.call(this);
27547 clone._hash = this._hash.clone();
27554 * Shortcut function to the hasher's object interface.
27556 * @param {WordArray|string} message The message to hash.
27558 * @return {WordArray} The hash.
27564 * var hash = CryptoJS.SHA256('message');
27565 * var hash = CryptoJS.SHA256(wordArray);
27567 C.SHA256 = Hasher._createHelper(SHA256);
27570 * Shortcut function to the HMAC's object interface.
27572 * @param {WordArray|string} message The message to hash.
27573 * @param {WordArray|string} key The secret key.
27575 * @return {WordArray} The HMAC.
27581 * var hmac = CryptoJS.HmacSHA256(message, key);
27583 C.HmacSHA256 = Hasher._createHmacHelper(SHA256);
27587 return CryptoJS.SHA256;
27590 },{
"./core":
31}],
58:[function(_dereq_,module,exports){
27591 ;(function (root, factory, undef) {
27592 if (typeof exports ===
"object") {
27594 module.exports = exports = factory(_dereq_(
"./core"), _dereq_(
"./x64-core"));
27596 else if (typeof define ===
"function" && define.amd) {
27598 define([
"./core",
"./x64-core"], factory);
27601 // Global (browser)
27602 factory(root.CryptoJS);
27604 }(this, function (CryptoJS) {
27610 var WordArray = C_lib.WordArray;
27611 var Hasher = C_lib.Hasher;
27613 var X64Word = C_x64.Word;
27614 var C_algo = C.algo;
27616 // Constants tables
27617 var RHO_OFFSETS = [];
27618 var PI_INDEXES = [];
27619 var ROUND_CONSTANTS = [];
27621 // Compute Constants
27623 // Compute rho offset constants
27625 for (var t =
0; t <
24; t++) {
27626 RHO_OFFSETS[x +
5 * y] = ((t +
1) * (t +
2) /
2) %
64;
27629 var newY = (
2 * x +
3 * y) %
5;
27634 // Compute pi index constants
27635 for (var x =
0; x <
5; x++) {
27636 for (var y =
0; y <
5; y++) {
27637 PI_INDEXES[x +
5 * y] = y + ((
2 * x +
3 * y) %
5) *
5;
27641 // Compute round constants
27643 for (var i =
0; i <
24; i++) {
27644 var roundConstantMsw =
0;
27645 var roundConstantLsw =
0;
27647 for (var j =
0; j <
7; j++) {
27649 var bitPosition = (
1 << j) -
1;
27650 if (bitPosition <
32) {
27651 roundConstantLsw ^=
1 << bitPosition;
27652 } else /* if (bitPosition
>=
32) */ {
27653 roundConstantMsw ^=
1 << (bitPosition -
32);
27657 // Compute next LFSR
27659 // Primitive polynomial over GF(
2): x^
8 + x^
6 + x^
5 + x^
4 +
1
27660 LFSR = (LFSR <<
1) ^
0x71;
27666 ROUND_CONSTANTS[i] = X64Word.create(roundConstantMsw, roundConstantLsw);
27670 // Reusable objects for temporary values
27673 for (var i =
0; i <
25; i++) {
27674 T[i] = X64Word.create();
27679 * SHA-
3 hash algorithm.
27681 var SHA3 = C_algo.SHA3 = Hasher.extend({
27683 * Configuration options.
27685 * @property {number} outputLength
27686 * The desired number of bits in the output hash.
27687 * Only values permitted are:
224,
256,
384,
512.
27690 cfg: Hasher.cfg.extend({
27694 _doReset: function () {
27695 var state = this._state = []
27696 for (var i =
0; i <
25; i++) {
27697 state[i] = new X64Word.init();
27700 this.blockSize = (
1600 -
2 * this.cfg.outputLength) /
32;
27703 _doProcessBlock: function (M, offset) {
27705 var state = this._state;
27706 var nBlockSizeLanes = this.blockSize /
2;
27709 for (var i =
0; i < nBlockSizeLanes; i++) {
27711 var M2i = M[offset +
2 * i];
27712 var M2i1 = M[offset +
2 * i +
1];
27716 (((M2i <<
8) | (M2i
>>> 24)) &
0x00ff00ff) |
27717 (((M2i <<
24) | (M2i
>>> 8)) &
0xff00ff00)
27720 (((M2i1 <<
8) | (M2i1
>>> 24)) &
0x00ff00ff) |
27721 (((M2i1 <<
24) | (M2i1
>>> 8)) &
0xff00ff00)
27724 // Absorb message into state
27725 var lane = state[i];
27731 for (var round =
0; round <
24; round++) {
27733 for (var x =
0; x <
5; x++) {
27734 // Mix column lanes
27735 var tMsw =
0, tLsw =
0;
27736 for (var y =
0; y <
5; y++) {
27737 var lane = state[x +
5 * y];
27742 // Temporary values
27747 for (var x =
0; x <
5; x++) {
27749 var Tx4 = T[(x +
4) %
5];
27750 var Tx1 = T[(x +
1) %
5];
27751 var Tx1Msw = Tx1.high;
27752 var Tx1Lsw = Tx1.low;
27754 // Mix surrounding columns
27755 var tMsw = Tx4.high ^ ((Tx1Msw <<
1) | (Tx1Lsw
>>> 31));
27756 var tLsw = Tx4.low ^ ((Tx1Lsw <<
1) | (Tx1Msw
>>> 31));
27757 for (var y =
0; y <
5; y++) {
27758 var lane = state[x +
5 * y];
27765 for (var laneIndex =
1; laneIndex <
25; laneIndex++) {
27767 var lane = state[laneIndex];
27768 var laneMsw = lane.high;
27769 var laneLsw = lane.low;
27770 var rhoOffset = RHO_OFFSETS[laneIndex];
27773 if (rhoOffset <
32) {
27774 var tMsw = (laneMsw << rhoOffset) | (laneLsw
>>> (
32 - rhoOffset));
27775 var tLsw = (laneLsw << rhoOffset) | (laneMsw
>>> (
32 - rhoOffset));
27776 } else /* if (rhoOffset
>=
32) */ {
27777 var tMsw = (laneLsw << (rhoOffset -
32)) | (laneMsw
>>> (
64 - rhoOffset));
27778 var tLsw = (laneMsw << (rhoOffset -
32)) | (laneLsw
>>> (
64 - rhoOffset));
27782 var TPiLane = T[PI_INDEXES[laneIndex]];
27783 TPiLane.high = tMsw;
27784 TPiLane.low = tLsw;
27787 // Rho pi at x = y =
0
27789 var state0 = state[
0];
27790 T0.high = state0.high;
27791 T0.low = state0.low;
27794 for (var x =
0; x <
5; x++) {
27795 for (var y =
0; y <
5; y++) {
27797 var laneIndex = x +
5 * y;
27798 var lane = state[laneIndex];
27799 var TLane = T[laneIndex];
27800 var Tx1Lane = T[((x +
1) %
5) +
5 * y];
27801 var Tx2Lane = T[((x +
2) %
5) +
5 * y];
27804 lane.high = TLane.high ^ (~Tx1Lane.high & Tx2Lane.high);
27805 lane.low = TLane.low ^ (~Tx1Lane.low & Tx2Lane.low);
27810 var lane = state[
0];
27811 var roundConstant = ROUND_CONSTANTS[round];
27812 lane.high ^= roundConstant.high;
27813 lane.low ^= roundConstant.low;;
27817 _doFinalize: function () {
27819 var data = this._data;
27820 var dataWords = data.words;
27821 var nBitsTotal = this._nDataBytes *
8;
27822 var nBitsLeft = data.sigBytes *
8;
27823 var blockSizeBits = this.blockSize *
32;
27826 dataWords[nBitsLeft
>>> 5] |=
0x1 << (
24 - nBitsLeft %
32);
27827 dataWords[((Math.ceil((nBitsLeft +
1) / blockSizeBits) * blockSizeBits)
>>> 5) -
1] |=
0x80;
27828 data.sigBytes = dataWords.length *
4;
27830 // Hash final blocks
27834 var state = this._state;
27835 var outputLengthBytes = this.cfg.outputLength /
8;
27836 var outputLengthLanes = outputLengthBytes /
8;
27839 var hashWords = [];
27840 for (var i =
0; i < outputLengthLanes; i++) {
27842 var lane = state[i];
27843 var laneMsw = lane.high;
27844 var laneLsw = lane.low;
27848 (((laneMsw <<
8) | (laneMsw
>>> 24)) &
0x00ff00ff) |
27849 (((laneMsw <<
24) | (laneMsw
>>> 8)) &
0xff00ff00)
27852 (((laneLsw <<
8) | (laneLsw
>>> 24)) &
0x00ff00ff) |
27853 (((laneLsw <<
24) | (laneLsw
>>> 8)) &
0xff00ff00)
27856 // Squeeze state to retrieve hash
27857 hashWords.push(laneLsw);
27858 hashWords.push(laneMsw);
27861 // Return final computed hash
27862 return new WordArray.init(hashWords, outputLengthBytes);
27865 clone: function () {
27866 var clone = Hasher.clone.call(this);
27868 var state = clone._state = this._state.slice(
0);
27869 for (var i =
0; i <
25; i++) {
27870 state[i] = state[i].clone();
27878 * Shortcut function to the hasher's object interface.
27880 * @param {WordArray|string} message The message to hash.
27882 * @return {WordArray} The hash.
27888 * var hash = CryptoJS.SHA3('message');
27889 * var hash = CryptoJS.SHA3(wordArray);
27891 C.SHA3 = Hasher._createHelper(SHA3);
27894 * Shortcut function to the HMAC's object interface.
27896 * @param {WordArray|string} message The message to hash.
27897 * @param {WordArray|string} key The secret key.
27899 * @return {WordArray} The HMAC.
27905 * var hmac = CryptoJS.HmacSHA3(message, key);
27907 C.HmacSHA3 = Hasher._createHmacHelper(SHA3);
27911 return CryptoJS.SHA3;
27914 },{
"./core":
31,
"./x64-core":
62}],
59:[function(_dereq_,module,exports){
27915 ;(function (root, factory, undef) {
27916 if (typeof exports ===
"object") {
27918 module.exports = exports = factory(_dereq_(
"./core"), _dereq_(
"./x64-core"), _dereq_(
"./sha512"));
27920 else if (typeof define ===
"function" && define.amd) {
27922 define([
"./core",
"./x64-core",
"./sha512"], factory);
27925 // Global (browser)
27926 factory(root.CryptoJS);
27928 }(this, function (CryptoJS) {
27934 var X64Word = C_x64.Word;
27935 var X64WordArray = C_x64.WordArray;
27936 var C_algo = C.algo;
27937 var SHA512 = C_algo.SHA512;
27940 * SHA-
384 hash algorithm.
27942 var SHA384 = C_algo.SHA384 = SHA512.extend({
27943 _doReset: function () {
27944 this._hash = new X64WordArray.init([
27945 new X64Word.init(
0xcbbb9d5d,
0xc1059ed8), new X64Word.init(
0x629a292a,
0x367cd507),
27946 new X64Word.init(
0x9159015a,
0x3070dd17), new X64Word.init(
0x152fecd8,
0xf70e5939),
27947 new X64Word.init(
0x67332667,
0xffc00b31), new X64Word.init(
0x8eb44a87,
0x68581511),
27948 new X64Word.init(
0xdb0c2e0d,
0x64f98fa7), new X64Word.init(
0x47b5481d,
0xbefa4fa4)
27952 _doFinalize: function () {
27953 var hash = SHA512._doFinalize.call(this);
27955 hash.sigBytes -=
16;
27962 * Shortcut function to the hasher's object interface.
27964 * @param {WordArray|string} message The message to hash.
27966 * @return {WordArray} The hash.
27972 * var hash = CryptoJS.SHA384('message');
27973 * var hash = CryptoJS.SHA384(wordArray);
27975 C.SHA384 = SHA512._createHelper(SHA384);
27978 * Shortcut function to the HMAC's object interface.
27980 * @param {WordArray|string} message The message to hash.
27981 * @param {WordArray|string} key The secret key.
27983 * @return {WordArray} The HMAC.
27989 * var hmac = CryptoJS.HmacSHA384(message, key);
27991 C.HmacSHA384 = SHA512._createHmacHelper(SHA384);
27995 return CryptoJS.SHA384;
27998 },{
"./core":
31,
"./sha512":
60,
"./x64-core":
62}],
60:[function(_dereq_,module,exports){
27999 ;(function (root, factory, undef) {
28000 if (typeof exports ===
"object") {
28002 module.exports = exports = factory(_dereq_(
"./core"), _dereq_(
"./x64-core"));
28004 else if (typeof define ===
"function" && define.amd) {
28006 define([
"./core",
"./x64-core"], factory);
28009 // Global (browser)
28010 factory(root.CryptoJS);
28012 }(this, function (CryptoJS) {
28018 var Hasher = C_lib.Hasher;
28020 var X64Word = C_x64.Word;
28021 var X64WordArray = C_x64.WordArray;
28022 var C_algo = C.algo;
28024 function X64Word_create() {
28025 return X64Word.create.apply(X64Word, arguments);
28030 X64Word_create(
0x428a2f98,
0xd728ae22), X64Word_create(
0x71374491,
0x23ef65cd),
28031 X64Word_create(
0xb5c0fbcf,
0xec4d3b2f), X64Word_create(
0xe9b5dba5,
0x8189dbbc),
28032 X64Word_create(
0x3956c25b,
0xf348b538), X64Word_create(
0x59f111f1,
0xb605d019),
28033 X64Word_create(
0x923f82a4,
0xaf194f9b), X64Word_create(
0xab1c5ed5,
0xda6d8118),
28034 X64Word_create(
0xd807aa98,
0xa3030242), X64Word_create(
0x12835b01,
0x45706fbe),
28035 X64Word_create(
0x243185be,
0x4ee4b28c), X64Word_create(
0x550c7dc3,
0xd5ffb4e2),
28036 X64Word_create(
0x72be5d74,
0xf27b896f), X64Word_create(
0x80deb1fe,
0x3b1696b1),
28037 X64Word_create(
0x9bdc06a7,
0x25c71235), X64Word_create(
0xc19bf174,
0xcf692694),
28038 X64Word_create(
0xe49b69c1,
0x9ef14ad2), X64Word_create(
0xefbe4786,
0x384f25e3),
28039 X64Word_create(
0x0fc19dc6,
0x8b8cd5b5), X64Word_create(
0x240ca1cc,
0x77ac9c65),
28040 X64Word_create(
0x2de92c6f,
0x592b0275), X64Word_create(
0x4a7484aa,
0x6ea6e483),
28041 X64Word_create(
0x5cb0a9dc,
0xbd41fbd4), X64Word_create(
0x76f988da,
0x831153b5),
28042 X64Word_create(
0x983e5152,
0xee66dfab), X64Word_create(
0xa831c66d,
0x2db43210),
28043 X64Word_create(
0xb00327c8,
0x98fb213f), X64Word_create(
0xbf597fc7,
0xbeef0ee4),
28044 X64Word_create(
0xc6e00bf3,
0x3da88fc2), X64Word_create(
0xd5a79147,
0x930aa725),
28045 X64Word_create(
0x06ca6351,
0xe003826f), X64Word_create(
0x14292967,
0x0a0e6e70),
28046 X64Word_create(
0x27b70a85,
0x46d22ffc), X64Word_create(
0x2e1b2138,
0x5c26c926),
28047 X64Word_create(
0x4d2c6dfc,
0x5ac42aed), X64Word_create(
0x53380d13,
0x9d95b3df),
28048 X64Word_create(
0x650a7354,
0x8baf63de), X64Word_create(
0x766a0abb,
0x3c77b2a8),
28049 X64Word_create(
0x81c2c92e,
0x47edaee6), X64Word_create(
0x92722c85,
0x1482353b),
28050 X64Word_create(
0xa2bfe8a1,
0x4cf10364), X64Word_create(
0xa81a664b,
0xbc423001),
28051 X64Word_create(
0xc24b8b70,
0xd0f89791), X64Word_create(
0xc76c51a3,
0x0654be30),
28052 X64Word_create(
0xd192e819,
0xd6ef5218), X64Word_create(
0xd6990624,
0x5565a910),
28053 X64Word_create(
0xf40e3585,
0x5771202a), X64Word_create(
0x106aa070,
0x32bbd1b8),
28054 X64Word_create(
0x19a4c116,
0xb8d2d0c8), X64Word_create(
0x1e376c08,
0x5141ab53),
28055 X64Word_create(
0x2748774c,
0xdf8eeb99), X64Word_create(
0x34b0bcb5,
0xe19b48a8),
28056 X64Word_create(
0x391c0cb3,
0xc5c95a63), X64Word_create(
0x4ed8aa4a,
0xe3418acb),
28057 X64Word_create(
0x5b9cca4f,
0x7763e373), X64Word_create(
0x682e6ff3,
0xd6b2b8a3),
28058 X64Word_create(
0x748f82ee,
0x5defb2fc), X64Word_create(
0x78a5636f,
0x43172f60),
28059 X64Word_create(
0x84c87814,
0xa1f0ab72), X64Word_create(
0x8cc70208,
0x1a6439ec),
28060 X64Word_create(
0x90befffa,
0x23631e28), X64Word_create(
0xa4506ceb,
0xde82bde9),
28061 X64Word_create(
0xbef9a3f7,
0xb2c67915), X64Word_create(
0xc67178f2,
0xe372532b),
28062 X64Word_create(
0xca273ece,
0xea26619c), X64Word_create(
0xd186b8c7,
0x21c0c207),
28063 X64Word_create(
0xeada7dd6,
0xcde0eb1e), X64Word_create(
0xf57d4f7f,
0xee6ed178),
28064 X64Word_create(
0x06f067aa,
0x72176fba), X64Word_create(
0x0a637dc5,
0xa2c898a6),
28065 X64Word_create(
0x113f9804,
0xbef90dae), X64Word_create(
0x1b710b35,
0x131c471b),
28066 X64Word_create(
0x28db77f5,
0x23047d84), X64Word_create(
0x32caab7b,
0x40c72493),
28067 X64Word_create(
0x3c9ebe0a,
0x15c9bebc), X64Word_create(
0x431d67c4,
0x9c100d4c),
28068 X64Word_create(
0x4cc5d4be,
0xcb3e42b6), X64Word_create(
0x597f299c,
0xfc657e2a),
28069 X64Word_create(
0x5fcb6fab,
0x3ad6faec), X64Word_create(
0x6c44198c,
0x4a475817)
28072 // Reusable objects
28075 for (var i =
0; i <
80; i++) {
28076 W[i] = X64Word_create();
28081 * SHA-
512 hash algorithm.
28083 var SHA512 = C_algo.SHA512 = Hasher.extend({
28084 _doReset: function () {
28085 this._hash = new X64WordArray.init([
28086 new X64Word.init(
0x6a09e667,
0xf3bcc908), new X64Word.init(
0xbb67ae85,
0x84caa73b),
28087 new X64Word.init(
0x3c6ef372,
0xfe94f82b), new X64Word.init(
0xa54ff53a,
0x5f1d36f1),
28088 new X64Word.init(
0x510e527f,
0xade682d1), new X64Word.init(
0x9b05688c,
0x2b3e6c1f),
28089 new X64Word.init(
0x1f83d9ab,
0xfb41bd6b), new X64Word.init(
0x5be0cd19,
0x137e2179)
28093 _doProcessBlock: function (M, offset) {
28095 var H = this._hash.words;
28123 // Working variables
28142 for (var i =
0; i <
80; i++) {
28148 var Wih = Wi.high = M[offset + i *
2] |
0;
28149 var Wil = Wi.low = M[offset + i *
2 +
1] |
0;
28152 var gamma0x = W[i -
15];
28153 var gamma0xh = gamma0x.high;
28154 var gamma0xl = gamma0x.low;
28155 var gamma0h = ((gamma0xh
>>> 1) | (gamma0xl <<
31)) ^ ((gamma0xh
>>> 8) | (gamma0xl <<
24)) ^ (gamma0xh
>>> 7);
28156 var gamma0l = ((gamma0xl
>>> 1) | (gamma0xh <<
31)) ^ ((gamma0xl
>>> 8) | (gamma0xh <<
24)) ^ ((gamma0xl
>>> 7) | (gamma0xh <<
25));
28159 var gamma1x = W[i -
2];
28160 var gamma1xh = gamma1x.high;
28161 var gamma1xl = gamma1x.low;
28162 var gamma1h = ((gamma1xh
>>> 19) | (gamma1xl <<
13)) ^ ((gamma1xh <<
3) | (gamma1xl
>>> 29)) ^ (gamma1xh
>>> 6);
28163 var gamma1l = ((gamma1xl
>>> 19) | (gamma1xh <<
13)) ^ ((gamma1xl <<
3) | (gamma1xh
>>> 29)) ^ ((gamma1xl
>>> 6) | (gamma1xh <<
26));
28165 // W[i] = gamma0 + W[i -
7] + gamma1 + W[i -
16]
28166 var Wi7 = W[i -
7];
28167 var Wi7h = Wi7.high;
28168 var Wi7l = Wi7.low;
28170 var Wi16 = W[i -
16];
28171 var Wi16h = Wi16.high;
28172 var Wi16l = Wi16.low;
28174 var Wil = gamma0l + Wi7l;
28175 var Wih = gamma0h + Wi7h + ((Wil
>>> 0) < (gamma0l
>>> 0) ?
1 :
0);
28176 var Wil = Wil + gamma1l;
28177 var Wih = Wih + gamma1h + ((Wil
>>> 0) < (gamma1l
>>> 0) ?
1 :
0);
28178 var Wil = Wil + Wi16l;
28179 var Wih = Wih + Wi16h + ((Wil
>>> 0) < (Wi16l
>>> 0) ?
1 :
0);
28185 var chh = (eh & fh) ^ (~eh & gh);
28186 var chl = (el & fl) ^ (~el & gl);
28187 var majh = (ah & bh) ^ (ah & ch) ^ (bh & ch);
28188 var majl = (al & bl) ^ (al & cl) ^ (bl & cl);
28190 var sigma0h = ((ah
>>> 28) | (al <<
4)) ^ ((ah <<
30) | (al
>>> 2)) ^ ((ah <<
25) | (al
>>> 7));
28191 var sigma0l = ((al
>>> 28) | (ah <<
4)) ^ ((al <<
30) | (ah
>>> 2)) ^ ((al <<
25) | (ah
>>> 7));
28192 var sigma1h = ((eh
>>> 14) | (el <<
18)) ^ ((eh
>>> 18) | (el <<
14)) ^ ((eh <<
23) | (el
>>> 9));
28193 var sigma1l = ((el
>>> 14) | (eh <<
18)) ^ ((el
>>> 18) | (eh <<
14)) ^ ((el <<
23) | (eh
>>> 9));
28195 // t1 = h + sigma1 + ch + K[i] + W[i]
28200 var t1l = hl + sigma1l;
28201 var t1h = hh + sigma1h + ((t1l
>>> 0) < (hl
>>> 0) ?
1 :
0);
28202 var t1l = t1l + chl;
28203 var t1h = t1h + chh + ((t1l
>>> 0) < (chl
>>> 0) ?
1 :
0);
28204 var t1l = t1l + Kil;
28205 var t1h = t1h + Kih + ((t1l
>>> 0) < (Kil
>>> 0) ?
1 :
0);
28206 var t1l = t1l + Wil;
28207 var t1h = t1h + Wih + ((t1l
>>> 0) < (Wil
>>> 0) ?
1 :
0);
28209 // t2 = sigma0 + maj
28210 var t2l = sigma0l + majl;
28211 var t2h = sigma0h + majh + ((t2l
>>> 0) < (sigma0l
>>> 0) ?
1 :
0);
28213 // Update working variables
28220 el = (dl + t1l) |
0;
28221 eh = (dh + t1h + ((el
>>> 0) < (dl
>>> 0) ?
1 :
0)) |
0;
28228 al = (t1l + t2l) |
0;
28229 ah = (t1h + t2h + ((al
>>> 0) < (t1l
>>> 0) ?
1 :
0)) |
0;
28232 // Intermediate hash value
28233 H0l = H0.low = (H0l + al);
28234 H0.high = (H0h + ah + ((H0l
>>> 0) < (al
>>> 0) ?
1 :
0));
28235 H1l = H1.low = (H1l + bl);
28236 H1.high = (H1h + bh + ((H1l
>>> 0) < (bl
>>> 0) ?
1 :
0));
28237 H2l = H2.low = (H2l + cl);
28238 H2.high = (H2h + ch + ((H2l
>>> 0) < (cl
>>> 0) ?
1 :
0));
28239 H3l = H3.low = (H3l + dl);
28240 H3.high = (H3h + dh + ((H3l
>>> 0) < (dl
>>> 0) ?
1 :
0));
28241 H4l = H4.low = (H4l + el);
28242 H4.high = (H4h + eh + ((H4l
>>> 0) < (el
>>> 0) ?
1 :
0));
28243 H5l = H5.low = (H5l + fl);
28244 H5.high = (H5h + fh + ((H5l
>>> 0) < (fl
>>> 0) ?
1 :
0));
28245 H6l = H6.low = (H6l + gl);
28246 H6.high = (H6h + gh + ((H6l
>>> 0) < (gl
>>> 0) ?
1 :
0));
28247 H7l = H7.low = (H7l + hl);
28248 H7.high = (H7h + hh + ((H7l
>>> 0) < (hl
>>> 0) ?
1 :
0));
28251 _doFinalize: function () {
28253 var data = this._data;
28254 var dataWords = data.words;
28256 var nBitsTotal = this._nDataBytes *
8;
28257 var nBitsLeft = data.sigBytes *
8;
28260 dataWords[nBitsLeft
>>> 5] |=
0x80 << (
24 - nBitsLeft %
32);
28261 dataWords[(((nBitsLeft +
128)
>>> 10) <<
5) +
30] = Math.floor(nBitsTotal /
0x100000000);
28262 dataWords[(((nBitsLeft +
128)
>>> 10) <<
5) +
31] = nBitsTotal;
28263 data.sigBytes = dataWords.length *
4;
28265 // Hash final blocks
28268 // Convert hash to
32-bit word array before returning
28269 var hash = this._hash.toX32();
28271 // Return final computed hash
28275 clone: function () {
28276 var clone = Hasher.clone.call(this);
28277 clone._hash = this._hash.clone();
28286 * Shortcut function to the hasher's object interface.
28288 * @param {WordArray|string} message The message to hash.
28290 * @return {WordArray} The hash.
28296 * var hash = CryptoJS.SHA512('message');
28297 * var hash = CryptoJS.SHA512(wordArray);
28299 C.SHA512 = Hasher._createHelper(SHA512);
28302 * Shortcut function to the HMAC's object interface.
28304 * @param {WordArray|string} message The message to hash.
28305 * @param {WordArray|string} key The secret key.
28307 * @return {WordArray} The HMAC.
28313 * var hmac = CryptoJS.HmacSHA512(message, key);
28315 C.HmacSHA512 = Hasher._createHmacHelper(SHA512);
28319 return CryptoJS.SHA512;
28322 },{
"./core":
31,
"./x64-core":
62}],
61:[function(_dereq_,module,exports){
28323 ;(function (root, factory, undef) {
28324 if (typeof exports ===
"object") {
28326 module.exports = exports = factory(_dereq_(
"./core"), _dereq_(
"./enc-base64"), _dereq_(
"./md5"), _dereq_(
"./evpkdf"), _dereq_(
"./cipher-core"));
28328 else if (typeof define ===
"function" && define.amd) {
28330 define([
"./core",
"./enc-base64",
"./md5",
"./evpkdf",
"./cipher-core"], factory);
28333 // Global (browser)
28334 factory(root.CryptoJS);
28336 }(this, function (CryptoJS) {
28342 var WordArray = C_lib.WordArray;
28343 var BlockCipher = C_lib.BlockCipher;
28344 var C_algo = C.algo;
28346 // Permuted Choice
1 constants
28348 57,
49,
41,
33,
25,
17,
9,
1,
28349 58,
50,
42,
34,
26,
18,
10,
2,
28350 59,
51,
43,
35,
27,
19,
11,
3,
28351 60,
52,
44,
36,
63,
55,
47,
39,
28352 31,
23,
15,
7,
62,
54,
46,
38,
28353 30,
22,
14,
6,
61,
53,
45,
37,
28354 29,
21,
13,
5,
28,
20,
12,
4
28357 // Permuted Choice
2 constants
28359 14,
17,
11,
24,
1,
5,
28360 3,
28,
15,
6,
21,
10,
28361 23,
19,
12,
4,
26,
8,
28362 16,
7,
27,
20,
13,
2,
28363 41,
52,
31,
37,
47,
55,
28364 30,
40,
51,
45,
33,
48,
28365 44,
49,
39,
56,
34,
53,
28366 46,
42,
50,
36,
29,
32
28369 // Cumulative bit shift constants
28370 var BIT_SHIFTS = [
1,
2,
4,
6,
8,
10,
12,
14,
15,
17,
19,
21,
23,
25,
27,
28];
28372 // SBOXes and round permutation constants
28376 0x10000000:
0x8000,
28377 0x20000000:
0x808002,
28380 0x50000000:
0x808202,
28381 0x60000000:
0x800202,
28382 0x70000000:
0x800000,
28384 0x90000000:
0x800200,
28385 0xa0000000:
0x8200,
28386 0xb0000000:
0x808000,
28387 0xc0000000:
0x8002,
28388 0xd0000000:
0x800002,
28390 0xf0000000:
0x8202,
28392 0x18000000:
0x808202,
28393 0x28000000:
0x8202,
28394 0x38000000:
0x8000,
28395 0x48000000:
0x808200,
28397 0x68000000:
0x808002,
28399 0x88000000:
0x800200,
28400 0x98000000:
0x8200,
28401 0xa8000000:
0x808000,
28402 0xb8000000:
0x800202,
28403 0xc8000000:
0x800002,
28404 0xd8000000:
0x8002,
28406 0xf8000000:
0x800000,
28409 0x20000001:
0x808200,
28410 0x30000001:
0x800000,
28411 0x40000001:
0x808002,
28412 0x50000001:
0x8200,
28414 0x70000001:
0x800202,
28415 0x80000001:
0x808202,
28416 0x90000001:
0x808000,
28417 0xa0000001:
0x800002,
28418 0xb0000001:
0x8202,
28420 0xd0000001:
0x800200,
28421 0xe0000001:
0x8002,
28423 0x8000001:
0x808202,
28424 0x18000001:
0x808000,
28425 0x28000001:
0x800000,
28427 0x48000001:
0x8000,
28428 0x58000001:
0x800002,
28430 0x78000001:
0x8202,
28431 0x88000001:
0x8002,
28432 0x98000001:
0x800202,
28434 0xb8000001:
0x808200,
28435 0xc8000001:
0x800200,
28437 0xe8000001:
0x8200,
28438 0xf8000001:
0x808002
28443 0x2000000:
0x80000,
28444 0x3000000:
0x40080010,
28445 0x4000000:
0x40000010,
28446 0x5000000:
0x40084000,
28447 0x6000000:
0x40004000,
28449 0x8000000:
0x84000,
28450 0x9000000:
0x40004010,
28451 0xa000000:
0x40000000,
28452 0xb000000:
0x84010,
28453 0xc000000:
0x80010,
28456 0xf000000:
0x40080000,
28457 0x800000:
0x40004000,
28458 0x1800000:
0x84010,
28460 0x3800000:
0x40004010,
28461 0x4800000:
0x40084010,
28462 0x5800000:
0x40000000,
28463 0x6800000:
0x80000,
28464 0x7800000:
0x40080010,
28465 0x8800000:
0x80010,
28468 0xb800000:
0x40080000,
28469 0xc800000:
0x40000010,
28470 0xd800000:
0x84000,
28471 0xe800000:
0x40084000,
28474 0x11000000:
0x40080010,
28475 0x12000000:
0x40004010,
28476 0x13000000:
0x40084000,
28477 0x14000000:
0x40080000,
28479 0x16000000:
0x84010,
28480 0x17000000:
0x4000,
28481 0x18000000:
0x4010,
28482 0x19000000:
0x80000,
28483 0x1a000000:
0x80010,
28484 0x1b000000:
0x40000010,
28485 0x1c000000:
0x84000,
28486 0x1d000000:
0x40004000,
28487 0x1e000000:
0x40000000,
28488 0x1f000000:
0x40084010,
28489 0x10800000:
0x84010,
28490 0x11800000:
0x80000,
28491 0x12800000:
0x40080000,
28492 0x13800000:
0x4000,
28493 0x14800000:
0x40004000,
28494 0x15800000:
0x40084010,
28496 0x17800000:
0x40000000,
28497 0x18800000:
0x40084000,
28498 0x19800000:
0x40000010,
28499 0x1a800000:
0x40004010,
28500 0x1b800000:
0x80010,
28502 0x1d800000:
0x4010,
28503 0x1e800000:
0x40080010,
28504 0x1f800000:
0x84000
28509 0x200000:
0x4000100,
28512 0x500000:
0x4000004,
28513 0x600000:
0x4010104,
28514 0x700000:
0x4010000,
28515 0x800000:
0x4000000,
28516 0x900000:
0x4010100,
28518 0xb00000:
0x4010004,
28519 0xc00000:
0x4000104,
28523 0x80000:
0x4010100,
28524 0x180000:
0x4010004,
28526 0x380000:
0x4000100,
28527 0x480000:
0x4000004,
28533 0xa80000:
0x4010000,
28536 0xd80000:
0x4000104,
28537 0xe80000:
0x4010104,
28538 0xf80000:
0x4000000,
28539 0x1000000:
0x4010100,
28540 0x1100000:
0x10004,
28541 0x1200000:
0x10000,
28542 0x1300000:
0x4000100,
28544 0x1500000:
0x4010104,
28545 0x1600000:
0x4000004,
28547 0x1800000:
0x4000104,
28548 0x1900000:
0x4000000,
28550 0x1b00000:
0x10100,
28551 0x1c00000:
0x4010000,
28553 0x1e00000:
0x10104,
28554 0x1f00000:
0x4010004,
28555 0x1080000:
0x4000000,
28557 0x1280000:
0x4010100,
28559 0x1480000:
0x10004,
28560 0x1580000:
0x4000100,
28562 0x1780000:
0x4010004,
28563 0x1880000:
0x10000,
28564 0x1980000:
0x4010104,
28565 0x1a80000:
0x10104,
28566 0x1b80000:
0x4000004,
28567 0x1c80000:
0x4000104,
28568 0x1d80000:
0x4010000,
28574 0x10000:
0x80001040,
28576 0x30000:
0x80400000,
28579 0x60000:
0x80000040,
28581 0x80000:
0x80000000,
28584 0xb0000:
0x80001000,
28585 0xc0000:
0x80400040,
28588 0xf0000:
0x80401040,
28589 0x8000:
0x80001040,
28591 0x28000:
0x80400040,
28592 0x38000:
0x80001000,
28594 0x58000:
0x80401040,
28596 0x78000:
0x80400000,
28598 0x98000:
0x80401000,
28601 0xc8000:
0x80000000,
28604 0xf8000:
0x80000040,
28605 0x100000:
0x400040,
28606 0x110000:
0x401000,
28607 0x120000:
0x80000040,
28610 0x150000:
0x80400040,
28611 0x160000:
0x80401000,
28612 0x170000:
0x80001040,
28613 0x180000:
0x80401040,
28614 0x190000:
0x80000000,
28615 0x1a0000:
0x80400000,
28616 0x1b0000:
0x401040,
28617 0x1c0000:
0x80001000,
28618 0x1d0000:
0x400000,
28621 0x108000:
0x80400000,
28622 0x118000:
0x80401040,
28624 0x138000:
0x401000,
28625 0x148000:
0x400040,
28626 0x158000:
0x80000000,
28627 0x168000:
0x80001040,
28629 0x188000:
0x80000040,
28631 0x1a8000:
0x80001000,
28632 0x1b8000:
0x80400040,
28634 0x1d8000:
0x80401000,
28635 0x1e8000:
0x400000,
28642 0x3000:
0x20000000,
28643 0x4000:
0x20040080,
28645 0x6000:
0x21000080,
28648 0x9000:
0x20040000,
28649 0xa000:
0x20000080,
28650 0xb000:
0x21040080,
28651 0xc000:
0x21040000,
28654 0xf000:
0x21000000,
28656 0x1800:
0x21000080,
28660 0x5800:
0x20040080,
28661 0x6800:
0x21040000,
28662 0x7800:
0x20000000,
28663 0x8800:
0x20040000,
28665 0xa800:
0x21040080,
28667 0xc800:
0x20000080,
28668 0xd800:
0x21000000,
28673 0x12000:
0x20000000,
28674 0x13000:
0x21000080,
28675 0x14000:
0x1000080,
28676 0x15000:
0x21040000,
28677 0x16000:
0x20040080,
28678 0x17000:
0x1000000,
28679 0x18000:
0x21040080,
28680 0x19000:
0x21000000,
28681 0x1a000:
0x1040000,
28682 0x1b000:
0x20040000,
28684 0x1d000:
0x20000080,
28686 0x1f000:
0x1040080,
28687 0x10800:
0x21000080,
28688 0x11800:
0x1000000,
28689 0x12800:
0x1040000,
28690 0x13800:
0x20040080,
28691 0x14800:
0x20000000,
28692 0x15800:
0x1040080,
28694 0x17800:
0x21040000,
28696 0x19800:
0x21040080,
28698 0x1b800:
0x21000000,
28699 0x1c800:
0x1000080,
28701 0x1e800:
0x20040000,
28702 0x1f800:
0x20000080
28737 0x1000:
0x10002000,
28738 0x1100:
0x10200008,
28739 0x1200:
0x10202008,
28742 0x1500:
0x10000000,
28743 0x1600:
0x10000008,
28748 0x1b00:
0x10200000,
28750 0x1d00:
0x10002008,
28751 0x1e00:
0x10202000,
28756 0x1380:
0x10000008,
28757 0x1480:
0x10002000,
28759 0x1680:
0x10202008,
28760 0x1780:
0x10200000,
28761 0x1880:
0x10202000,
28762 0x1980:
0x10200008,
28767 0x1e80:
0x10000000,
28854 0x80000001:
0x8020820,
28855 0x80000002:
0x8000820,
28856 0x80000003:
0x8000000,
28857 0x80000004:
0x8020000,
28858 0x80000005:
0x20800,
28859 0x80000006:
0x20820,
28861 0x80000008:
0x8000020,
28863 0x8000000a:
0x20020,
28864 0x8000000b:
0x8020800,
28866 0x8000000d:
0x8020020,
28867 0x8000000e:
0x8000800,
28868 0x8000000f:
0x20000,
28885 0x80000010:
0x20000,
28887 0x80000012:
0x8020020,
28888 0x80000013:
0x20820,
28890 0x80000015:
0x8020000,
28891 0x80000016:
0x8000000,
28892 0x80000017:
0x8000820,
28893 0x80000018:
0x8020820,
28894 0x80000019:
0x8000020,
28895 0x8000001a:
0x8000800,
28897 0x8000001c:
0x20800,
28899 0x8000001e:
0x20020,
28900 0x8000001f:
0x8020800
28904 // Masks that select the SBOX input
28906 0xf8000001,
0x1f800000,
0x01f80000,
0x001f8000,
28907 0x0001f800,
0x00001f80,
0x000001f8,
0x8000001f
28911 * DES block cipher algorithm.
28913 var DES = C_algo.DES = BlockCipher.extend({
28914 _doReset: function () {
28916 var key = this._key;
28917 var keyWords = key.words;
28919 // Select
56 bits according to PC1
28921 for (var i =
0; i <
56; i++) {
28922 var keyBitPos = PC1[i] -
1;
28923 keyBits[i] = (keyWords[keyBitPos
>>> 5]
>>> (
31 - keyBitPos %
32)) &
1;
28926 // Assemble
16 subkeys
28927 var subKeys = this._subKeys = [];
28928 for (var nSubKey =
0; nSubKey <
16; nSubKey++) {
28930 var subKey = subKeys[nSubKey] = [];
28933 var bitShift = BIT_SHIFTS[nSubKey];
28935 // Select
48 bits according to PC2
28936 for (var i =
0; i <
24; i++) {
28937 // Select from the left
28 key bits
28938 subKey[(i /
6) |
0] |= keyBits[((PC2[i] -
1) + bitShift) %
28] << (
31 - i %
6);
28940 // Select from the right
28 key bits
28941 subKey[
4 + ((i /
6) |
0)] |= keyBits[
28 + (((PC2[i +
24] -
1) + bitShift) %
28)] << (
31 - i %
6);
28944 // Since each subkey is applied to an expanded
32-bit input,
28945 // the subkey can be broken into
8 values scaled to
32-bits,
28946 // which allows the key to be used without expansion
28947 subKey[
0] = (subKey[
0] <<
1) | (subKey[
0]
>>> 31);
28948 for (var i =
1; i <
7; i++) {
28949 subKey[i] = subKey[i]
>>> ((i -
1) *
4 +
3);
28951 subKey[
7] = (subKey[
7] <<
5) | (subKey[
7]
>>> 27);
28954 // Compute inverse subkeys
28955 var invSubKeys = this._invSubKeys = [];
28956 for (var i =
0; i <
16; i++) {
28957 invSubKeys[i] = subKeys[
15 - i];
28961 encryptBlock: function (M, offset) {
28962 this._doCryptBlock(M, offset, this._subKeys);
28965 decryptBlock: function (M, offset) {
28966 this._doCryptBlock(M, offset, this._invSubKeys);
28969 _doCryptBlock: function (M, offset, subKeys) {
28971 this._lBlock = M[offset];
28972 this._rBlock = M[offset +
1];
28974 // Initial permutation
28975 exchangeLR.call(this,
4,
0x0f0f0f0f);
28976 exchangeLR.call(this,
16,
0x0000ffff);
28977 exchangeRL.call(this,
2,
0x33333333);
28978 exchangeRL.call(this,
8,
0x00ff00ff);
28979 exchangeLR.call(this,
1,
0x55555555);
28982 for (var round =
0; round <
16; round++) {
28984 var subKey = subKeys[round];
28985 var lBlock = this._lBlock;
28986 var rBlock = this._rBlock;
28988 // Feistel function
28990 for (var i =
0; i <
8; i++) {
28991 f |= SBOX_P[i][((rBlock ^ subKey[i]) & SBOX_MASK[i])
>>> 0];
28993 this._lBlock = rBlock;
28994 this._rBlock = lBlock ^ f;
28997 // Undo swap from last round
28998 var t = this._lBlock;
28999 this._lBlock = this._rBlock;
29002 // Final permutation
29003 exchangeLR.call(this,
1,
0x55555555);
29004 exchangeRL.call(this,
8,
0x00ff00ff);
29005 exchangeRL.call(this,
2,
0x33333333);
29006 exchangeLR.call(this,
16,
0x0000ffff);
29007 exchangeLR.call(this,
4,
0x0f0f0f0f);
29010 M[offset] = this._lBlock;
29011 M[offset +
1] = this._rBlock;
29021 // Swap bits across the left and right words
29022 function exchangeLR(offset, mask) {
29023 var t = ((this._lBlock
>>> offset) ^ this._rBlock) & mask;
29025 this._lBlock ^= t << offset;
29028 function exchangeRL(offset, mask) {
29029 var t = ((this._rBlock
>>> offset) ^ this._lBlock) & mask;
29031 this._rBlock ^= t << offset;
29035 * Shortcut functions to the cipher's object interface.
29039 * var ciphertext = CryptoJS.DES.encrypt(message, key, cfg);
29040 * var plaintext = CryptoJS.DES.decrypt(ciphertext, key, cfg);
29042 C.DES = BlockCipher._createHelper(DES);
29045 * Triple-DES block cipher algorithm.
29047 var TripleDES = C_algo.TripleDES = BlockCipher.extend({
29048 _doReset: function () {
29050 var key = this._key;
29051 var keyWords = key.words;
29053 // Create DES instances
29054 this._des1 = DES.createEncryptor(WordArray.create(keyWords.slice(
0,
2)));
29055 this._des2 = DES.createEncryptor(WordArray.create(keyWords.slice(
2,
4)));
29056 this._des3 = DES.createEncryptor(WordArray.create(keyWords.slice(
4,
6)));
29059 encryptBlock: function (M, offset) {
29060 this._des1.encryptBlock(M, offset);
29061 this._des2.decryptBlock(M, offset);
29062 this._des3.encryptBlock(M, offset);
29065 decryptBlock: function (M, offset) {
29066 this._des3.decryptBlock(M, offset);
29067 this._des2.encryptBlock(M, offset);
29068 this._des1.decryptBlock(M, offset);
29079 * Shortcut functions to the cipher's object interface.
29083 * var ciphertext = CryptoJS.TripleDES.encrypt(message, key, cfg);
29084 * var plaintext = CryptoJS.TripleDES.decrypt(ciphertext, key, cfg);
29086 C.TripleDES = BlockCipher._createHelper(TripleDES);
29090 return CryptoJS.TripleDES;
29093 },{"./cipher-core":
30,"./core":
31,"./enc-base64":
32,"./evpkdf":
34,"./md5":
39}],
62:[function(_dereq_,module,exports){
29094 ;(function (root, factory) {
29095 if (typeof exports === "object") {
29097 module.exports = exports = factory(_dereq_("./core"));
29099 else if (typeof define === "function" && define.amd) {
29101 define(["./core"], factory);
29104 // Global (browser)
29105 factory(root.CryptoJS);
29107 }(this, function (CryptoJS) {
29109 (function (undefined) {
29113 var Base = C_lib.Base;
29114 var X32WordArray = C_lib.WordArray;
29119 var C_x64 = C.x64 = {};
29124 var X64Word = C_x64.Word = Base.extend({
29126 * Initializes a newly created
64-bit word.
29128 * @param {number} high The high
32 bits.
29129 * @param {number} low The low
32 bits.
29133 * var x64Word = CryptoJS.x64.Word.create(
0x00010203,
0x04050607);
29135 init: function (high, low) {
29141 * Bitwise NOTs this word.
29143 * @return {X64Word} A new x64-Word object after negating.
29147 * var negated = x64Word.not();
29149 // not: function () {
29150 // var high = ~this.high;
29151 // var low = ~this.low;
29153 // return X64Word.create(high, low);
29157 * Bitwise ANDs this word with the passed word.
29159 * @param {X64Word} word The x64-Word to AND with this word.
29161 * @return {X64Word} A new x64-Word object after ANDing.
29165 * var anded = x64Word.and(anotherX64Word);
29167 // and: function (word) {
29168 // var high = this.high & word.high;
29169 // var low = this.low & word.low;
29171 // return X64Word.create(high, low);
29175 * Bitwise ORs this word with the passed word.
29177 * @param {X64Word} word The x64-Word to OR with this word.
29179 * @return {X64Word} A new x64-Word object after ORing.
29183 * var ored = x64Word.or(anotherX64Word);
29185 // or: function (word) {
29186 // var high = this.high | word.high;
29187 // var low = this.low | word.low;
29189 // return X64Word.create(high, low);
29193 * Bitwise XORs this word with the passed word.
29195 * @param {X64Word} word The x64-Word to XOR with this word.
29197 * @return {X64Word} A new x64-Word object after XORing.
29201 * var xored = x64Word.xor(anotherX64Word);
29203 // xor: function (word) {
29204 // var high = this.high ^ word.high;
29205 // var low = this.low ^ word.low;
29207 // return X64Word.create(high, low);
29211 * Shifts this word n bits to the left.
29213 * @param {number} n The number of bits to shift.
29215 * @return {X64Word} A new x64-Word object after shifting.
29219 * var shifted = x64Word.shiftL(
25);
29221 // shiftL: function (n) {
29223 // var high = (this.high << n) | (this.low
>>> (
32 - n));
29224 // var low = this.low << n;
29226 // var high = this.low << (n -
32);
29230 // return X64Word.create(high, low);
29234 * Shifts this word n bits to the right.
29236 * @param {number} n The number of bits to shift.
29238 * @return {X64Word} A new x64-Word object after shifting.
29242 * var shifted = x64Word.shiftR(
7);
29244 // shiftR: function (n) {
29246 // var low = (this.low
>>> n) | (this.high << (
32 - n));
29247 // var high = this.high
>>> n;
29249 // var low = this.high
>>> (n -
32);
29253 // return X64Word.create(high, low);
29257 * Rotates this word n bits to the left.
29259 * @param {number} n The number of bits to rotate.
29261 * @return {X64Word} A new x64-Word object after rotating.
29265 * var rotated = x64Word.rotL(
25);
29267 // rotL: function (n) {
29268 // return this.shiftL(n).or(this.shiftR(
64 - n));
29272 * Rotates this word n bits to the right.
29274 * @param {number} n The number of bits to rotate.
29276 * @return {X64Word} A new x64-Word object after rotating.
29280 * var rotated = x64Word.rotR(
7);
29282 // rotR: function (n) {
29283 // return this.shiftR(n).or(this.shiftL(
64 - n));
29287 * Adds this word with the passed word.
29289 * @param {X64Word} word The x64-Word to add with this word.
29291 * @return {X64Word} A new x64-Word object after adding.
29295 * var added = x64Word.add(anotherX64Word);
29297 // add: function (word) {
29298 // var low = (this.low + word.low) |
0;
29299 // var carry = (low
>>> 0) < (this.low
>>> 0) ?
1 :
0;
29300 // var high = (this.high + word.high + carry) |
0;
29302 // return X64Word.create(high, low);
29307 * An array of
64-bit words.
29309 * @property {Array} words The array of CryptoJS.x64.Word objects.
29310 * @property {number} sigBytes The number of significant bytes in this word array.
29312 var X64WordArray = C_x64.WordArray = Base.extend({
29314 * Initializes a newly created word array.
29316 * @param {Array} words (Optional) An array of CryptoJS.x64.Word objects.
29317 * @param {number} sigBytes (Optional) The number of significant bytes in the words.
29321 * var wordArray = CryptoJS.x64.WordArray.create();
29323 * var wordArray = CryptoJS.x64.WordArray.create([
29324 * CryptoJS.x64.Word.create(
0x00010203,
0x04050607),
29325 * CryptoJS.x64.Word.create(
0x18191a1b,
0x1c1d1e1f)
29328 * var wordArray = CryptoJS.x64.WordArray.create([
29329 * CryptoJS.x64.Word.create(
0x00010203,
0x04050607),
29330 * CryptoJS.x64.Word.create(
0x18191a1b,
0x1c1d1e1f)
29333 init: function (words, sigBytes) {
29334 words = this.words = words || [];
29336 if (sigBytes != undefined) {
29337 this.sigBytes = sigBytes;
29339 this.sigBytes = words.length *
8;
29344 * Converts this
64-bit word array to a
32-bit word array.
29346 * @return {CryptoJS.lib.WordArray} This word array's data as a
32-bit word array.
29350 * var x32WordArray = x64WordArray.toX32();
29352 toX32: function () {
29354 var x64Words = this.words;
29355 var x64WordsLength = x64Words.length;
29359 for (var i =
0; i < x64WordsLength; i++) {
29360 var x64Word = x64Words[i];
29361 x32Words.push(x64Word.high);
29362 x32Words.push(x64Word.low);
29365 return X32WordArray.create(x32Words, this.sigBytes);
29369 * Creates a copy of this word array.
29371 * @return {X64WordArray} The clone.
29375 * var clone = x64WordArray.clone();
29377 clone: function () {
29378 var clone = Base.clone.call(this);
29380 // Clone
"words" array
29381 var words = clone.words = this.words.slice(
0);
29383 // Clone each X64Word object
29384 var wordsLength = words.length;
29385 for (var i =
0; i < wordsLength; i++) {
29386 words[i] = words[i].clone();
29398 },{
"./core":
31}],
63:[function(_dereq_,module,exports){
29399 var assert = _dereq_('assert')
29400 var BigInteger = _dereq_('bigi')
29402 var Point = _dereq_('./point')
29404 function Curve(p, a, b, Gx, Gy, n, h) {
29408 this.G = Point.fromAffine(this, Gx, Gy)
29412 this.infinity = new Point(this, null, null, BigInteger.ZERO)
29415 this.pOverFour = p.add(BigInteger.ONE).shiftRight(
2)
29418 Curve.prototype.pointFromX = function(isOdd, x) {
29419 var alpha = x.pow(
3).add(this.a.multiply(x)).add(this.b).mod(this.p)
29420 var beta = alpha.modPow(this.pOverFour, this.p)
29423 if (beta.isEven() ^ !isOdd) {
29424 y = this.p.subtract(y) // -y % p
29427 return Point.fromAffine(this, x, y)
29430 Curve.prototype.isInfinity = function(Q) {
29431 if (Q === this.infinity) return true
29433 return Q.z.signum() ===
0 && Q.y.signum() !==
0
29436 Curve.prototype.isOnCurve = function(Q) {
29437 if (this.isInfinity(Q)) return true
29445 // Check that xQ and yQ are integers in the interval [
0, p -
1]
29446 if (x.signum() <
0 || x.compareTo(p)
>=
0) return false
29447 if (y.signum() <
0 || y.compareTo(p)
>=
0) return false
29449 // and check that y^
2 = x^
3 + ax + b (mod p)
29450 var lhs = y.square().mod(p)
29451 var rhs = x.pow(
3).add(a.multiply(x)).add(b).mod(p)
29452 return lhs.equals(rhs)
29456 * Validate an elliptic curve point.
29458 * See SEC
1, section
3.2.2.1: Elliptic Curve Public Key Validation Primitive
29460 Curve.prototype.validate = function(Q) {
29462 assert(!this.isInfinity(Q), 'Point is at infinity')
29463 assert(this.isOnCurve(Q), 'Point is not on the curve')
29465 // Check nQ = O (where Q is a scalar multiple of G)
29466 var nQ = Q.multiply(this.n)
29467 assert(this.isInfinity(nQ), 'Point is not a scalar multiple of G')
29472 module.exports = Curve
29474 },{"./point":
67,"assert":
4,"bigi":
3}],
64:[function(_dereq_,module,exports){
29477 "p": "fffffffdffffffffffffffffffffffff",
29478 "a": "fffffffdfffffffffffffffffffffffc",
29479 "b": "e87579c11079f43dd824993c2cee5ed3",
29480 "n": "fffffffe0000000075a30d1b9038a115",
29482 "Gx": "
161ff7528b899b2d0c28607ca52c5b86",
29483 "Gy": "cf5ac8395bafeb13c02da292dded7a83"
29486 "p": "fffffffffffffffffffffffffffffffeffffac73",
29489 "n": "
0100000000000000000001b8fa16dfab9aca16b6b3",
29491 "Gx": "
3b4c382ce37aa192a4019e763036f4f5dd4d7ebb",
29492 "Gy": "
938cf935318fdced6bc28286531733c3f03c4fee"
29495 "p": "ffffffffffffffffffffffffffffffff7fffffff",
29496 "a": "ffffffffffffffffffffffffffffffff7ffffffc",
29497 "b": "
1c97befc54bd7a8b65acf89f81d4d4adc565fa45",
29498 "n": "
0100000000000000000001f4c8f927aed3ca752257",
29500 "Gx": "
4a96b5688ef573284664698968c38bb913cbfc82",
29501 "Gy": "
23a628553168947d59dcc912042351377ac5fb32"
29504 "p": "fffffffffffffffffffffffffffffffffffffffeffffee37",
29507 "n": "fffffffffffffffffffffffe26f2fc170f69466a74defd8d",
29509 "Gx": "db4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d",
29510 "Gy": "
9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d"
29513 "p": "fffffffffffffffffffffffffffffffeffffffffffffffff",
29514 "a": "fffffffffffffffffffffffffffffffefffffffffffffffc",
29515 "b": "
64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1",
29516 "n": "ffffffffffffffffffffffff99def836146bc9b1b4d22831",
29518 "Gx": "
188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012",
29519 "Gy": "
07192b95ffc8da78631011ed6b24cdd573f977a11e794811"
29522 "p": "ffffffffffffffffffffffffffffffff000000000000000000000001",
29523 "a": "fffffffffffffffffffffffffffffffefffffffffffffffffffffffe",
29524 "b": "b4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4",
29525 "n": "ffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3d",
29527 "Gx": "b70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21",
29528 "Gy": "bd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34"
29531 "p": "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f",
29534 "n": "fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",
29536 "Gx": "
79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",
29537 "Gy": "
483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"
29540 "p": "ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",
29541 "a": "ffffffff00000001000000000000000000000000fffffffffffffffffffffffc",
29542 "b": "
5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b",
29543 "n": "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",
29545 "Gx": "
6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296",
29546 "Gy": "
4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"
29550 },{}],
65:[function(_dereq_,module,exports){
29551 var Point = _dereq_('./point')
29552 var Curve = _dereq_('./curve')
29554 var getCurveByName = _dereq_('./names')
29559 getCurveByName: getCurveByName
29562 },{"./curve":
63,"./names":
66,"./point":
67}],
66:[function(_dereq_,module,exports){
29563 var BigInteger = _dereq_('bigi')
29565 var curves = _dereq_('./curves')
29566 var Curve = _dereq_('./curve')
29568 function getCurveByName(name) {
29569 var curve = curves[name]
29570 if (!curve) return null
29572 var p = new BigInteger(curve.p,
16)
29573 var a = new BigInteger(curve.a,
16)
29574 var b = new BigInteger(curve.b,
16)
29575 var n = new BigInteger(curve.n,
16)
29576 var h = new BigInteger(curve.h,
16)
29577 var Gx = new BigInteger(curve.Gx,
16)
29578 var Gy = new BigInteger(curve.Gy,
16)
29580 return new Curve(p, a, b, Gx, Gy, n, h)
29583 module.exports = getCurveByName
29585 },{"./curve":
63,"./curves":
64,"bigi":
3}],
67:[function(_dereq_,module,exports){
29586 (function (Buffer){
29587 var assert = _dereq_('assert')
29588 var BigInteger = _dereq_('bigi')
29590 var THREE = BigInteger.valueOf(
3)
29592 function Point(curve, x, y, z) {
29593 assert.notStrictEqual(z, undefined, 'Missing Z coordinate')
29601 this.compressed = true
29604 Object.defineProperty(Point.prototype, 'zInv', {
29606 if (this._zInv === null) {
29607 this._zInv = this.z.modInverse(this.curve.p)
29614 Object.defineProperty(Point.prototype, 'affineX', {
29616 return this.x.multiply(this.zInv).mod(this.curve.p)
29620 Object.defineProperty(Point.prototype, 'affineY', {
29622 return this.y.multiply(this.zInv).mod(this.curve.p)
29626 Point.fromAffine = function(curve, x, y) {
29627 return new Point(curve, x, y, BigInteger.ONE)
29630 Point.prototype.equals = function(other) {
29631 if (other === this) return true
29632 if (this.curve.isInfinity(this)) return this.curve.isInfinity(other)
29633 if (this.curve.isInfinity(other)) return this.curve.isInfinity(this)
29635 // u = Y2 * Z1 - Y1 * Z2
29636 var u = other.y.multiply(this.z).subtract(this.y.multiply(other.z)).mod(this.curve.p)
29638 if (u.signum() !==
0) return false
29640 // v = X2 * Z1 - X1 * Z2
29641 var v = other.x.multiply(this.z).subtract(this.x.multiply(other.z)).mod(this.curve.p)
29643 return v.signum() ===
0
29646 Point.prototype.negate = function() {
29647 var y = this.curve.p.subtract(this.y)
29649 return new Point(this.curve, this.x, y, this.z)
29652 Point.prototype.add = function(b) {
29653 if (this.curve.isInfinity(this)) return b
29654 if (this.curve.isInfinity(b)) return this
29661 // u = Y2 * Z1 - Y1 * Z2
29662 var u = y2.multiply(this.z).subtract(y1.multiply(b.z)).mod(this.curve.p)
29663 // v = X2 * Z1 - X1 * Z2
29664 var v = x2.multiply(this.z).subtract(x1.multiply(b.z)).mod(this.curve.p)
29666 if (v.signum() ===
0) {
29667 if (u.signum() ===
0) {
29668 return this.twice() // this == b, so double
29671 return this.curve.infinity // this = -b, so infinity
29674 var v2 = v.square()
29675 var v3 = v2.multiply(v)
29676 var x1v2 = x1.multiply(v2)
29677 var zu2 = u.square().multiply(this.z)
29679 // x3 = v * (z2 * (z1 * u^
2 -
2 * x1 * v^
2) - v^
3)
29680 var x3 = zu2.subtract(x1v2.shiftLeft(
1)).multiply(b.z).subtract(v3).multiply(v).mod(this.curve.p)
29681 // y3 = z2 * (
3 * x1 * u * v^
2 - y1 * v^
3 - z1 * u^
3) + u * v^
3
29682 var y3 = x1v2.multiply(THREE).multiply(u).subtract(y1.multiply(v3)).subtract(zu2.multiply(u)).multiply(b.z).add(u.multiply(v3)).mod(this.curve.p)
29683 // z3 = v^
3 * z1 * z2
29684 var z3 = v3.multiply(this.z).multiply(b.z).mod(this.curve.p)
29686 return new Point(this.curve, x3, y3, z3)
29689 Point.prototype.twice = function() {
29690 if (this.curve.isInfinity(this)) return this
29691 if (this.y.signum() ===
0) return this.curve.infinity
29696 var y1z1 = y1.multiply(this.z)
29697 var y1sqz1 = y1z1.multiply(y1).mod(this.curve.p)
29698 var a = this.curve.a
29700 // w =
3 * x1^
2 + a * z1^
2
29701 var w = x1.square().multiply(THREE)
29703 if (a.signum() !==
0) {
29704 w = w.add(this.z.square().multiply(a))
29707 w = w.mod(this.curve.p)
29708 // x3 =
2 * y1 * z1 * (w^
2 -
8 * x1 * y1^
2 * z1)
29709 var x3 = w.square().subtract(x1.shiftLeft(
3).multiply(y1sqz1)).shiftLeft(
1).multiply(y1z1).mod(this.curve.p)
29710 // y3 =
4 * y1^
2 * z1 * (
3 * w * x1 -
2 * y1^
2 * z1) - w^
3
29711 var y3 = w.multiply(THREE).multiply(x1).subtract(y1sqz1.shiftLeft(
1)).shiftLeft(
2).multiply(y1sqz1).subtract(w.pow(
3)).mod(this.curve.p)
29712 // z3 =
8 * (y1 * z1)^
3
29713 var z3 = y1z1.pow(
3).shiftLeft(
3).mod(this.curve.p)
29715 return new Point(this.curve, x3, y3, z3)
29718 // Simple NAF (Non-Adjacent Form) multiplication algorithm
29719 // TODO: modularize the multiplication algorithm
29720 Point.prototype.multiply = function(k) {
29721 if (this.curve.isInfinity(this)) return this
29722 if (k.signum() ===
0) return this.curve.infinity
29725 var h = e.multiply(THREE)
29727 var neg = this.negate()
29730 for (var i = h.bitLength() -
2; i
> 0; --i) {
29733 var hBit = h.testBit(i)
29734 var eBit = e.testBit(i)
29736 if (hBit != eBit) {
29737 R = R.add(hBit ? this : neg)
29744 // Compute this*j + x*k (simultaneous multiplication)
29745 Point.prototype.multiplyTwo = function(j, x, k) {
29748 if (j.bitLength()
> k.bitLength())
29749 i = j.bitLength() -
1
29751 i = k.bitLength() -
1
29753 var R = this.curve.infinity
29754 var both = this.add(x)
29759 var jBit = j.testBit(i)
29760 var kBit = k.testBit(i)
29781 Point.prototype.getEncoded = function(compressed) {
29782 if (compressed == undefined) compressed = this.compressed
29783 if (this.curve.isInfinity(this)) return new Buffer('
00', 'hex') // Infinity point encoded is simply '
00'
29785 var x = this.affineX
29786 var y = this.affineY
29790 // Determine size of q in bytes
29791 var byteLength = Math.floor((this.curve.p.bitLength() +
7) /
8)
29795 buffer = new Buffer(
1 + byteLength)
29796 buffer.writeUInt8(y.isEven() ?
0x02 :
0x03,
0)
29800 buffer = new Buffer(
1 + byteLength + byteLength)
29801 buffer.writeUInt8(
0x04,
0)
29803 y.toBuffer(byteLength).copy(buffer,
1 + byteLength)
29806 x.toBuffer(byteLength).copy(buffer,
1)
29811 Point.decodeFrom = function(curve, buffer) {
29812 var type = buffer.readUInt8(
0)
29813 var compressed = (type !==
4)
29815 var x = BigInteger.fromBuffer(buffer.slice(
1,
33))
29816 var byteLength = Math.floor((curve.p.bitLength() +
7) /
8)
29820 assert.equal(buffer.length, byteLength +
1, 'Invalid sequence length')
29821 assert(type ===
0x02 || type ===
0x03, 'Invalid sequence tag')
29823 var isOdd = (type ===
0x03)
29824 Q = curve.pointFromX(isOdd, x)
29827 assert.equal(buffer.length,
1 + byteLength + byteLength, 'Invalid sequence length')
29829 var y = BigInteger.fromBuffer(buffer.slice(
1 + byteLength))
29830 Q = Point.fromAffine(curve, x, y)
29833 Q.compressed = compressed
29837 Point.prototype.toString = function () {
29838 if (this.curve.isInfinity(this)) return '(INFINITY)'
29840 return '(' + this.affineX.toString() + ',' + this.affineY.toString() + ')'
29843 module.exports = Point
29845 }).call(this,_dereq_("buffer").Buffer)
29846 },{"assert":
4,"bigi":
3,"buffer":
8}],
68:[function(_dereq_,module,exports){
29847 (function (process,Buffer){
29848 // Closure compiler error - result of 'not' operator not being used
29849 //!function(globals){
29850 (function(globals){
29854 if (typeof define !== 'undefined' && define.amd) { //require.js / AMD
29855 define([], function() {
29856 return secureRandom
29858 } else if (typeof module !== 'undefined' && module.exports) { //CommonJS
29859 module.exports = secureRandom
29860 } else { //script / browser
29861 globals.secureRandom = secureRandom
29865 //options.type is the only valid option
29866 function secureRandom(count, options) {
29867 options = options || {type: 'Array'}
29868 //we check for process.pid to prevent browserify from tricking us
29869 if (typeof process != 'undefined' && typeof process.pid == 'number') {
29870 return nodeRandom(count, options)
29872 var crypto = window.crypto || window.msCrypto
29873 if (!crypto) throw new Error("Your browser does not support window.crypto.")
29874 return browserRandom(count, options)
29878 function nodeRandom(count, options) {
29879 var crypto = _dereq_('crypto')
29880 var buf = crypto.randomBytes(count)
29882 switch (options.type) {
29884 return [].slice.call(buf)
29888 var arr = new Uint8Array(count)
29889 for (var i =
0; i < count; ++i) { arr[i] = buf.readUInt8(i) }
29892 throw new Error(options.type + " is unsupported.")
29896 function browserRandom(count, options) {
29897 var nativeArr = new Uint8Array(count)
29898 var crypto = window.crypto || window.msCrypto
29899 crypto.getRandomValues(nativeArr)
29901 switch (options.type) {
29903 return [].slice.call(nativeArr)
29905 try { var b = new Buffer(
1) } catch(e) { throw new Error('Buffer not supported in this environment. Use Node.js or Browserify for browser support.')}
29906 return new Buffer(nativeArr)
29910 throw new Error(options.type + " is unsupported.")
29914 secureRandom.randomArray = function(byteCount) {
29915 return secureRandom(byteCount, {type: 'Array'})
29918 secureRandom.randomUint8Array = function(byteCount) {
29919 return secureRandom(byteCount, {type: 'Uint8Array'})
29922 secureRandom.randomBuffer = function(byteCount) {
29923 return secureRandom(byteCount, {type: 'Buffer'})
29929 }).call(this,_dereq_("FWaASH"),_dereq_("buffer").Buffer)
29930 },{"FWaASH":
12,"buffer":
8,"crypto":
7}],
69:[function(_dereq_,module,exports){
29931 (function (Buffer){
29932 var assert = _dereq_('assert')
29933 var base58check = _dereq_('./base58check')
29934 var networks = _dereq_('./networks')
29935 var scripts = _dereq_('./scripts')
29937 function findScriptTypeByVersion(version) {
29938 for (var networkName in networks) {
29939 var network = networks[networkName]
29941 if (version === network.pubKeyHash) return 'pubkeyhash'
29942 if (version === network.scriptHash) return 'scripthash'
29946 function Address(hash, version) {
29947 assert(Buffer.isBuffer(hash), 'Expected Buffer, got ' + hash)
29948 assert.strictEqual(hash.length,
20, 'Invalid hash length')
29949 assert.strictEqual(version &
0xff, version, 'Invalid version byte')
29952 this.version = version
29955 // Import functions
29956 Address.fromBase58Check = function(string) {
29957 var payload = base58check.decode(string)
29958 var version = payload.readUInt8(
0)
29959 var hash = payload.slice(
1)
29961 return new Address(hash, version)
29964 Address.fromOutputScript = function(script, network) {
29965 network = network || networks.bitcoin
29967 var type = scripts.classifyOutput(script)
29969 if (type === 'pubkeyhash') return new Address(script.chunks[
2], network.pubKeyHash)
29970 if (type === 'scripthash') return new Address(script.chunks[
1], network.scriptHash)
29972 assert(false, type + ' has no matching Address')
29975 // Export functions
29976 Address.prototype.toBase58Check = function () {
29977 var payload = new Buffer(
21)
29978 payload.writeUInt8(this.version,
0)
29979 this.hash.copy(payload,
1)
29981 return base58check.encode(payload)
29984 Address.prototype.toOutputScript = function() {
29985 var scriptType = findScriptTypeByVersion(this.version)
29987 if (scriptType === 'pubkeyhash') return scripts.pubKeyHashOutput(this.hash)
29988 if (scriptType === 'scripthash') return scripts.scriptHashOutput(this.hash)
29990 assert(false, this.toString() + ' has no matching Script')
29993 Address.prototype.toString = Address.prototype.toBase58Check
29995 module.exports = Address
29997 }).call(this,_dereq_("buffer").Buffer)
29998 },{"./base58check":
70,"./networks":
81,"./scripts":
84,"assert":
4,"buffer":
8}],
70:[function(_dereq_,module,exports){
29999 (function (Buffer){
30000 // https://en.bitcoin.it/wiki/Base58Check_encoding
30001 var assert = _dereq_('assert')
30002 var base58 = _dereq_('bs58')
30003 var crypto = _dereq_('./crypto')
30005 // Encode a buffer as a base58-check-encoded string
30006 function encode(payload) {
30007 var checksum = crypto.hash256(payload).slice(
0,
4)
30009 return base58.encode(Buffer.concat([
30015 // Decode a base58-check-encoded string to a buffer
30016 function decode(string) {
30017 var buffer = base58.decode(string)
30019 var payload = buffer.slice(
0, -
4)
30020 var checksum = buffer.slice(-
4)
30021 var newChecksum = crypto.hash256(payload).slice(
0,
4)
30023 assert.deepEqual(newChecksum, checksum, 'Invalid checksum')
30033 }).call(this,_dereq_("buffer").Buffer)
30034 },{"./crypto":
73,"assert":
4,"bs58":
15,"buffer":
8}],
71:[function(_dereq_,module,exports){
30035 var assert = _dereq_('assert')
30036 var opcodes = _dereq_('./opcodes')
30038 // https://github.com/feross/buffer/blob/master/index.js#L1127
30039 function verifuint(value, max) {
30040 assert(typeof value === 'number', 'cannot write a non-number as a number')
30041 assert(value
>=
0, 'specified a negative value for writing an unsigned value')
30042 assert(value <= max, 'value is larger than maximum value for type')
30043 assert(Math.floor(value) === value, 'value has a fractional component')
30046 function pushDataSize(i) {
30047 return i < opcodes.OP_PUSHDATA1 ?
1
30053 function readPushDataInt(buffer, offset) {
30054 var opcode = buffer.readUInt8(offset)
30058 if (opcode < opcodes.OP_PUSHDATA1) {
30063 } else if (opcode === opcodes.OP_PUSHDATA1) {
30064 number = buffer.readUInt8(offset +
1)
30068 } else if (opcode === opcodes.OP_PUSHDATA2) {
30069 number = buffer.readUInt16LE(offset +
1)
30074 assert.equal(opcode, opcodes.OP_PUSHDATA4, 'Unexpected opcode')
30076 number = buffer.readUInt32LE(offset +
1)
30088 function readUInt64LE(buffer, offset) {
30089 var a = buffer.readUInt32LE(offset)
30090 var b = buffer.readUInt32LE(offset +
4)
30093 verifuint(b + a,
0x001fffffffffffff)
30098 function readVarInt(buffer, offset) {
30099 var t = buffer.readUInt8(offset)
30108 } else if (t <
254) {
30109 number = buffer.readUInt16LE(offset +
1)
30113 } else if (t <
255) {
30114 number = buffer.readUInt32LE(offset +
1)
30119 number = readUInt64LE(buffer, offset +
1)
30129 function writePushDataInt(buffer, number, offset) {
30130 var size = pushDataSize(number)
30134 buffer.writeUInt8(number, offset)
30137 } else if (size ===
2) {
30138 buffer.writeUInt8(opcodes.OP_PUSHDATA1, offset)
30139 buffer.writeUInt8(number, offset +
1)
30142 } else if (size ===
3) {
30143 buffer.writeUInt8(opcodes.OP_PUSHDATA2, offset)
30144 buffer.writeUInt16LE(number, offset +
1)
30148 buffer.writeUInt8(opcodes.OP_PUSHDATA4, offset)
30149 buffer.writeUInt32LE(number, offset +
1)
30156 function writeUInt64LE(buffer, value, offset) {
30157 verifuint(value,
0x001fffffffffffff)
30159 buffer.writeInt32LE(value & -
1, offset)
30160 buffer.writeUInt32LE(Math.floor(value /
0x100000000), offset +
4)
30163 function varIntSize(i) {
30166 : i <
0x100000000 ?
5
30170 function writeVarInt(buffer, number, offset) {
30171 var size = varIntSize(number)
30175 buffer.writeUInt8(number, offset)
30178 } else if (size ===
3) {
30179 buffer.writeUInt8(
253, offset)
30180 buffer.writeUInt16LE(number, offset +
1)
30183 } else if (size ===
5) {
30184 buffer.writeUInt8(
254, offset)
30185 buffer.writeUInt32LE(number, offset +
1)
30189 buffer.writeUInt8(
255, offset)
30190 writeUInt64LE(buffer, number, offset +
1)
30197 pushDataSize: pushDataSize,
30198 readPushDataInt: readPushDataInt,
30199 readUInt64LE: readUInt64LE,
30200 readVarInt: readVarInt,
30201 varIntSize: varIntSize,
30202 writePushDataInt: writePushDataInt,
30203 writeUInt64LE: writeUInt64LE,
30204 writeVarInt: writeVarInt
30207 },{"./opcodes":
82,"assert":
4}],
72:[function(_dereq_,module,exports){
30208 (function (Buffer){
30209 var assert = _dereq_('assert')
30210 var Crypto = _dereq_('crypto-js')
30211 var WordArray = Crypto.lib.WordArray
30213 function bufferToWordArray(buffer) {
30214 assert(Buffer.isBuffer(buffer), 'Expected Buffer, got', buffer)
30217 for (var i =
0, b =
0; i < buffer.length; i++, b +=
8) {
30218 words[b
>>> 5] |= buffer[i] << (
24 - b %
32)
30221 return new WordArray.init(words, buffer.length)
30224 function wordArrayToBuffer(wordArray) {
30225 assert(Array.isArray(wordArray.words), 'Expected WordArray, got' + wordArray)
30227 var words = wordArray.words
30228 var buffer = new Buffer(words.length *
4)
30230 words.forEach(function(value, i) {
30231 buffer.writeInt32BE(value & -
1, i *
4)
30238 bufferToWordArray: bufferToWordArray,
30239 wordArrayToBuffer: wordArrayToBuffer
30242 }).call(this,_dereq_(
"buffer").Buffer)
30243 },{
"assert":
4,
"buffer":
8,
"crypto-js":
37}],
73:[function(_dereq_,module,exports){
30244 (function (Buffer){
30245 // Crypto, crypto, where art thou crypto
30246 var assert = _dereq_('assert')
30247 var CryptoJS = _dereq_('crypto-js')
30248 var crypto = _dereq_('crypto')
30249 var convert = _dereq_('./convert')
30251 function hash160(buffer) {
30252 return ripemd160(sha256(buffer))
30255 function hash256(buffer) {
30256 return sha256(sha256(buffer))
30259 function ripemd160(buffer) {
30260 return crypto.createHash('rmd160').update(buffer).digest()
30263 function sha1(buffer) {
30264 return crypto.createHash('sha1').update(buffer).digest()
30267 function sha256(buffer) {
30268 return crypto.createHash('sha256').update(buffer).digest()
30271 // FIXME: Name not consistent with others
30272 function HmacSHA256(buffer, secret) {
30273 return crypto.createHmac('sha256', secret).update(buffer).digest()
30276 function HmacSHA512(data, secret) {
30277 assert(Buffer.isBuffer(data), 'Expected Buffer for data, got ' + data)
30278 assert(Buffer.isBuffer(secret), 'Expected Buffer for secret, got ' + secret)
30280 var dataWords = convert.bufferToWordArray(data)
30281 var secretWords = convert.bufferToWordArray(secret)
30283 var hash = CryptoJS.HmacSHA512(dataWords, secretWords)
30285 return convert.wordArrayToBuffer(hash)
30289 ripemd160: ripemd160,
30294 HmacSHA256: HmacSHA256,
30295 HmacSHA512: HmacSHA512
30298 }).call(this,_dereq_(
"buffer").Buffer)
30299 },{
"./convert":
72,
"assert":
4,
"buffer":
8,
"crypto":
19,
"crypto-js":
37}],
74:[function(_dereq_,module,exports){
30300 (function (Buffer){
30301 var assert = _dereq_('assert')
30302 var crypto = _dereq_('./crypto')
30304 var BigInteger = _dereq_('bigi')
30305 var ECSignature = _dereq_('./ecsignature')
30306 var Point = _dereq_('ecurve').Point
30308 // https://tools.ietf.org/html/rfc6979#section-
3.2
30309 function deterministicGenerateK(curve, hash, d) {
30310 assert(Buffer.isBuffer(hash), 'Hash must be a Buffer, not ' + hash)
30311 assert.equal(hash.length,
32, 'Hash must be
256 bit')
30312 assert(d instanceof BigInteger, 'Private key must be a BigInteger')
30314 var x = d.toBuffer(
32)
30315 var k = new Buffer(
32)
30316 var v = new Buffer(
32)
30325 k = crypto.HmacSHA256(Buffer.concat([v, new Buffer([
0]), x, hash]), k)
30328 v = crypto.HmacSHA256(v, k)
30331 k = crypto.HmacSHA256(Buffer.concat([v, new Buffer([
1]), x, hash]), k)
30334 v = crypto.HmacSHA256(v, k)
30336 // Step H1/H2a, ignored as tlen === qlen (
256 bit)
30338 v = crypto.HmacSHA256(v, k)
30340 var T = BigInteger.fromBuffer(v)
30342 // Step H3, repeat until T is within the interval [
1, n -
1]
30343 while ((T.signum() <=
0) || (T.compareTo(curve.n)
>=
0)) {
30344 k = crypto.HmacSHA256(Buffer.concat([v, new Buffer([
0])]), k)
30345 v = crypto.HmacSHA256(v, k)
30347 T = BigInteger.fromBuffer(v)
30353 function sign(curve, hash, d) {
30354 var k = deterministicGenerateK(curve, hash, d)
30358 var Q = G.multiply(k)
30359 var e = BigInteger.fromBuffer(hash)
30361 var r = Q.affineX.mod(n)
30362 assert.notEqual(r.signum(),
0, 'Invalid R value')
30364 var s = k.modInverse(n).multiply(e.add(d.multiply(r))).mod(n)
30365 assert.notEqual(s.signum(),
0, 'Invalid S value')
30367 var N_OVER_TWO = n.shiftRight(
1)
30369 // enforce low S values, see bip62: 'low s values in signatures'
30370 if (s.compareTo(N_OVER_TWO)
> 0) {
30374 return new ECSignature(r, s)
30377 function verify(curve, hash, signature, Q) {
30378 var e = BigInteger.fromBuffer(hash)
30380 return verifyRaw(curve, e, signature, Q)
30383 function verifyRaw(curve, e, signature, Q) {
30387 var r = signature.r
30388 var s = signature.s
30390 if (r.signum() ===
0 || r.compareTo(n)
>=
0) return false
30391 if (s.signum() ===
0 || s.compareTo(n)
>=
0) return false
30393 var c = s.modInverse(n)
30395 var u1 = e.multiply(c).mod(n)
30396 var u2 = r.multiply(c).mod(n)
30398 var point = G.multiplyTwo(u1, Q, u2)
30399 var v = point.affineX.mod(n)
30405 * Recover a public key from a signature.
30407 * See SEC
1: Elliptic Curve Cryptography, section
4.1.6, "Public
30408 * Key Recovery Operation".
30410 * http://www.secg.org/download/aid-
780/sec1-v2.pdf
30412 function recoverPubKey(curve, e, signature, i) {
30413 assert.strictEqual(i &
3, i, 'Recovery param is more than two bits')
30415 var r = signature.r
30416 var s = signature.s
30418 // A set LSB signifies that the y-coordinate is odd
30421 // The more significant bit specifies whether we should use the
30422 // first or second candidate key.
30423 var isSecondKey = i
>> 1
30428 //
1.1 Let x = r + jn
30429 var x = isSecondKey ? r.add(n) : r
30430 var R = curve.pointFromX(isYOdd, x)
30432 //
1.4 Check that nR is at infinity
30433 var nR = R.multiply(n)
30434 assert(curve.isInfinity(nR), 'nR is not a valid curve point')
30436 // Compute -e from e
30437 var eNeg = e.negate().mod(n)
30439 //
1.6.1 Compute Q = r^-
1 (sR - eG)
30440 // Q = r^-
1 (sR + -eG)
30441 var rInv = r.modInverse(n)
30443 var Q = R.multiplyTwo(s, G, eNeg).multiply(rInv)
30450 * Calculate pubkey extraction parameter.
30452 * When extracting a pubkey from a signature, we have to
30453 * distinguish four different cases. Rather than putting this
30454 * burden on the verifier, Bitcoin includes a
2-bit value with the
30457 * This function simply tries all four cases and returns the value
30458 * that resulted in a successful pubkey recovery.
30460 function calcPubKeyRecoveryParam(curve, e, signature, Q) {
30461 for (var i =
0; i <
4; i++) {
30462 var Qprime = recoverPubKey(curve, e, signature, i)
30465 if (Qprime.equals(Q)) {
30470 throw new Error('Unable to find valid recovery factor')
30474 calcPubKeyRecoveryParam: calcPubKeyRecoveryParam,
30475 deterministicGenerateK: deterministicGenerateK,
30476 recoverPubKey: recoverPubKey,
30479 verifyRaw: verifyRaw
30482 }).call(this,_dereq_(
"buffer").Buffer)
30483 },{
"./crypto":
73,
"./ecsignature":
77,
"assert":
4,
"bigi":
3,
"buffer":
8,
"ecurve":
65}],
75:[function(_dereq_,module,exports){
30484 (function (Buffer){
30485 var assert = _dereq_('assert')
30486 var base58check = _dereq_('./base58check')
30487 var ecdsa = _dereq_('./ecdsa')
30488 var networks = _dereq_('./networks')
30489 var secureRandom = _dereq_('secure-random')
30491 var BigInteger = _dereq_('bigi')
30492 var ECPubKey = _dereq_('./ecpubkey')
30494 var ecurve = _dereq_('ecurve')
30495 var curve = ecurve.getCurveByName('secp256k1')
30497 function ECKey(d, compressed) {
30498 assert(d.signum()
> 0, 'Private key must be greater than
0')
30499 assert(d.compareTo(curve.n) <
0, 'Private key must be less than the curve order')
30501 var Q = curve.G.multiply(d)
30504 this.pub = new ECPubKey(Q, compressed)
30507 // Static constructors
30508 ECKey.fromWIF = function(string) {
30509 var payload = base58check.decode(string)
30510 var compressed = false
30512 // Ignore the version byte
30513 payload = payload.slice(
1)
30515 if (payload.length ===
33) {
30516 assert.strictEqual(payload[
32],
0x01, 'Invalid compression flag')
30518 // Truncate the compression flag
30519 payload = payload.slice(
0, -
1)
30523 assert.equal(payload.length,
32, 'Invalid WIF payload length')
30525 var d = BigInteger.fromBuffer(payload)
30526 return new ECKey(d, compressed)
30529 ECKey.makeRandom = function(compressed, rng) {
30530 rng = rng || secureRandom.randomBuffer
30532 var buffer = rng(
32)
30533 assert(Buffer.isBuffer(buffer), 'Expected Buffer, got ' + buffer)
30535 var d = BigInteger.fromBuffer(buffer)
30538 return new ECKey(d, compressed)
30541 // Export functions
30542 ECKey.prototype.toWIF = function(network) {
30543 network = network || networks.bitcoin
30545 var bufferLen = this.pub.compressed ?
34 :
33
30546 var buffer = new Buffer(bufferLen)
30548 buffer.writeUInt8(network.wif,
0)
30549 this.d.toBuffer(
32).copy(buffer,
1)
30551 if (this.pub.compressed) {
30552 buffer.writeUInt8(
0x01,
33)
30555 return base58check.encode(buffer)
30559 ECKey.prototype.sign = function(hash) {
30560 return ecdsa.sign(curve, hash, this.d)
30563 module.exports = ECKey
30565 }).call(this,_dereq_(
"buffer").Buffer)
30566 },{
"./base58check":
70,
"./ecdsa":
74,
"./ecpubkey":
76,
"./networks":
81,
"assert":
4,
"bigi":
3,
"buffer":
8,
"ecurve":
65,
"secure-random":
68}],
76:[function(_dereq_,module,exports){
30567 (function (Buffer){
30568 var assert = _dereq_('assert')
30569 var crypto = _dereq_('./crypto')
30570 var ecdsa = _dereq_('./ecdsa')
30571 var networks = _dereq_('./networks')
30573 var Address = _dereq_('./address')
30575 var ecurve = _dereq_('ecurve')
30576 var curve = ecurve.getCurveByName('secp256k1')
30578 function ECPubKey(Q, compressed) {
30579 assert(Q instanceof ecurve.Point, 'Expected Point, got ' + Q)
30581 if (compressed == undefined) compressed = true
30582 assert.strictEqual(typeof compressed, 'boolean', 'Expected boolean, got ' + compressed)
30584 this.compressed = compressed
30588 // Static constructors
30589 ECPubKey.fromBuffer = function(buffer) {
30590 var Q = ecurve.Point.decodeFrom(curve, buffer)
30591 return new ECPubKey(Q, Q.compressed)
30594 ECPubKey.fromHex = function(hex) {
30595 return ECPubKey.fromBuffer(new Buffer(hex, 'hex'))
30599 ECPubKey.prototype.getAddress = function(network) {
30600 network = network || networks.bitcoin
30602 return new Address(crypto.hash160(this.toBuffer()), network.pubKeyHash)
30605 ECPubKey.prototype.verify = function(hash, signature) {
30606 return ecdsa.verify(curve, hash, signature, this.Q)
30609 // Export functions
30610 ECPubKey.prototype.toBuffer = function() {
30611 return this.Q.getEncoded(this.compressed)
30614 ECPubKey.prototype.toHex = function() {
30615 return this.toBuffer().toString('hex')
30618 module.exports = ECPubKey
30620 }).call(this,_dereq_(
"buffer").Buffer)
30621 },{
"./address":
69,
"./crypto":
73,
"./ecdsa":
74,
"./networks":
81,
"assert":
4,
"buffer":
8,
"ecurve":
65}],
77:[function(_dereq_,module,exports){
30622 (function (Buffer){
30623 var assert = _dereq_('assert')
30624 var BigInteger = _dereq_('bigi')
30626 function ECSignature(r, s) {
30627 assert(r instanceof BigInteger, 'Expected BigInteger, got ' + r)
30628 assert(s instanceof BigInteger, 'Expected BigInteger, got ' + s)
30633 // Import operations
30634 ECSignature.parseCompact = function(buffer) {
30635 assert.equal(buffer.length,
65, 'Invalid signature length')
30636 var i = buffer.readUInt8(
0) -
27
30639 assert.equal(i, i &
7, 'Invalid signature parameter')
30640 var compressed = !!(i &
4)
30642 // Recovery param only
30645 var r = BigInteger.fromBuffer(buffer.slice(
1,
33))
30646 var s = BigInteger.fromBuffer(buffer.slice(
33))
30649 compressed: compressed,
30651 signature: new ECSignature(r, s)
30655 ECSignature.fromDER = function(buffer) {
30656 assert.equal(buffer.readUInt8(
0),
0x30, 'Not a DER sequence')
30657 assert.equal(buffer.readUInt8(
1), buffer.length -
2, 'Invalid sequence length')
30658 assert.equal(buffer.readUInt8(
2),
0x02, 'Expected a DER integer')
30660 var rLen = buffer.readUInt8(
3)
30661 assert(rLen
> 0, 'R length is zero')
30663 var offset =
4 + rLen
30664 assert.equal(buffer.readUInt8(offset),
0x02, 'Expected a DER integer (
2)')
30666 var sLen = buffer.readUInt8(offset +
1)
30667 assert(sLen
> 0, 'S length is zero')
30669 var rB = buffer.slice(
4, offset)
30670 var sB = buffer.slice(offset +
2)
30673 if (rLen
> 1 && rB.readUInt8(
0) ===
0x00) {
30674 assert(rB.readUInt8(
1) &
0x80, 'R value excessively padded')
30677 if (sLen
> 1 && sB.readUInt8(
0) ===
0x00) {
30678 assert(sB.readUInt8(
1) &
0x80, 'S value excessively padded')
30681 assert.equal(offset, buffer.length, 'Invalid DER encoding')
30682 var r = BigInteger.fromDERInteger(rB)
30683 var s = BigInteger.fromDERInteger(sB)
30685 assert(r.signum()
>=
0, 'R value is negative')
30686 assert(s.signum()
>=
0, 'S value is negative')
30688 return new ECSignature(r, s)
30691 // FIXME:
0x00,
0x04,
0x80 are SIGHASH_* boundary constants, importing Transaction causes a circular dependency
30692 ECSignature.parseScriptSignature = function(buffer) {
30693 var hashType = buffer.readUInt8(buffer.length -
1)
30694 var hashTypeMod = hashType & ~
0x80
30696 assert(hashTypeMod
> 0x00 && hashTypeMod <
0x04, 'Invalid hashType')
30699 signature: ECSignature.fromDER(buffer.slice(
0, -
1)),
30704 // Export operations
30705 ECSignature.prototype.toCompact = function(i, compressed) {
30706 if (compressed) i +=
4
30709 var buffer = new Buffer(
65)
30710 buffer.writeUInt8(i,
0)
30712 this.r.toBuffer(
32).copy(buffer,
1)
30713 this.s.toBuffer(
32).copy(buffer,
33)
30718 ECSignature.prototype.toDER = function() {
30719 var rBa = this.r.toDERInteger()
30720 var sBa = this.s.toDERInteger()
30723 sequence.push(
0x02) // INTEGER
30724 sequence.push(rBa.length)
30725 sequence = sequence.concat(rBa)
30727 sequence.push(
0x02) // INTEGER
30728 sequence.push(sBa.length)
30729 sequence = sequence.concat(sBa)
30731 sequence.unshift(sequence.length)
30732 sequence.unshift(
0x30) // SEQUENCE
30734 return new Buffer(sequence)
30737 ECSignature.prototype.toScriptSignature = function(hashType) {
30738 var hashTypeBuffer = new Buffer(
1)
30739 hashTypeBuffer.writeUInt8(hashType,
0)
30741 return Buffer.concat([this.toDER(), hashTypeBuffer])
30744 module.exports = ECSignature
30746 }).call(this,_dereq_(
"buffer").Buffer)
30747 },{
"assert":
4,
"bigi":
3,
"buffer":
8}],
78:[function(_dereq_,module,exports){
30748 (function (Buffer){
30749 var assert = _dereq_('assert')
30750 var base58check = _dereq_('./base58check')
30751 var crypto = _dereq_('./crypto')
30752 var networks = _dereq_('./networks')
30754 var BigInteger = _dereq_('bigi')
30755 var ECKey = _dereq_('./eckey')
30756 var ECPubKey = _dereq_('./ecpubkey')
30758 var ecurve = _dereq_('ecurve')
30759 var curve = ecurve.getCurveByName('secp256k1')
30761 function findBIP32ParamsByVersion(version) {
30762 for (var name in networks) {
30763 var network = networks[name]
30765 for (var type in network.bip32) {
30766 if (version != network.bip32[type]) continue
30769 isPrivate: (type === 'private'),
30775 assert(false, 'Could not find version ' + version.toString(
16))
30778 function HDNode(K, chainCode, network) {
30779 network = network || networks.bitcoin
30781 assert(Buffer.isBuffer(chainCode), 'Expected Buffer, got ' + chainCode)
30782 assert(network.bip32, 'Unknown BIP32 constants for network')
30784 this.chainCode = chainCode
30787 this.network = network
30789 if (K instanceof BigInteger) {
30790 this.privKey = new ECKey(K, true)
30791 this.pubKey = this.privKey.pub
30793 this.pubKey = new ECPubKey(K, true)
30797 HDNode.MASTER_SECRET = new Buffer('Bitcoin seed')
30798 HDNode.HIGHEST_BIT =
0x80000000
30801 HDNode.fromSeedBuffer = function(seed, network) {
30802 var I = crypto.HmacSHA512(seed, HDNode.MASTER_SECRET)
30803 var IL = I.slice(
0,
32)
30804 var IR = I.slice(
32)
30806 // In case IL is
0 or
>= n, the master key is invalid
30807 // This is handled by `new ECKey` in the HDNode constructor
30808 var pIL = BigInteger.fromBuffer(IL)
30810 return new HDNode(pIL, IR, network)
30813 HDNode.fromSeedHex = function(hex, network) {
30814 return HDNode.fromSeedBuffer(new Buffer(hex, 'hex'), network)
30817 HDNode.fromBase58 = function(string) {
30818 return HDNode.fromBuffer(base58check.decode(string))
30821 HDNode.fromBuffer = function(buffer) {
30822 assert.strictEqual(buffer.length, HDNode.LENGTH, 'Invalid buffer length')
30824 //
4 byte: version bytes
30825 var version = buffer.readUInt32BE(
0)
30826 var params = findBIP32ParamsByVersion(version)
30828 //
1 byte: depth:
0x00 for master nodes,
0x01 for level-
1 descendants, ...
30829 var depth = buffer.readUInt8(
4)
30831 //
4 bytes: the fingerprint of the parent's key (
0x00000000 if master key)
30832 var parentFingerprint = buffer.readUInt32BE(
5)
30834 assert.strictEqual(parentFingerprint,
0x00000000, 'Invalid parent fingerprint')
30837 //
4 bytes: child number. This is the number i in xi = xpar/i, with xi the key being serialized.
30838 // This is encoded in MSB order. (
0x00000000 if master key)
30839 var index = buffer.readUInt32BE(
9)
30840 assert(depth
> 0 || index ===
0, 'Invalid index')
30842 //
32 bytes: the chain code
30843 var chainCode = buffer.slice(
13,
45)
30846 //
33 bytes: private key data (
0x00 + k)
30847 if (params.isPrivate) {
30848 assert.strictEqual(buffer.readUInt8(
45),
0x00, 'Invalid private key')
30849 var data = buffer.slice(
46,
78)
30850 var d = BigInteger.fromBuffer(data)
30851 hd = new HDNode(d, chainCode, params.network)
30853 //
33 bytes: public key data (
0x02 + X or
0x03 + X)
30855 var data = buffer.slice(
45,
78)
30856 var Q = ecurve.Point.decodeFrom(curve, data)
30857 assert.equal(Q.compressed, true, 'Invalid public key')
30859 // Verify that the X coordinate in the public point corresponds to a point on the curve.
30860 // If not, the extended public key is invalid.
30863 hd = new HDNode(Q, chainCode, params.network)
30868 hd.parentFingerprint = parentFingerprint
30873 HDNode.fromHex = function(hex) {
30874 return HDNode.fromBuffer(new Buffer(hex, 'hex'))
30877 HDNode.prototype.getIdentifier = function() {
30878 return crypto.hash160(this.pubKey.toBuffer())
30881 HDNode.prototype.getFingerprint = function() {
30882 return this.getIdentifier().slice(
0,
4)
30885 HDNode.prototype.getAddress = function() {
30886 return this.pubKey.getAddress(this.network)
30889 HDNode.prototype.toBase58 = function(isPrivate) {
30890 return base58check.encode(this.toBuffer(isPrivate))
30893 HDNode.prototype.toBuffer = function(isPrivate) {
30894 if (isPrivate == undefined) isPrivate = !!this.privKey
30897 var version = isPrivate ? this.network.bip32.private : this.network.bip32.public
30898 var buffer = new Buffer(HDNode.LENGTH)
30900 //
4 bytes: version bytes
30901 buffer.writeUInt32BE(version,
0)
30904 //
1 byte: depth:
0x00 for master nodes,
0x01 for level-
1 descendants, ....
30905 buffer.writeUInt8(this.depth,
4)
30907 //
4 bytes: the fingerprint of the parent's key (
0x00000000 if master key)
30908 var fingerprint = (this.depth ===
0) ?
0x00000000 : this.parentFingerprint
30909 buffer.writeUInt32BE(fingerprint,
5)
30911 //
4 bytes: child number. This is the number i in xi = xpar/i, with xi the key being serialized.
30912 // This is encoded in Big endian. (
0x00000000 if master key)
30913 buffer.writeUInt32BE(this.index,
9)
30915 //
32 bytes: the chain code
30916 this.chainCode.copy(buffer,
13)
30918 //
33 bytes: the public key or private key data
30920 assert(this.privKey, 'Missing private key')
30922 //
0x00 + k for private keys
30923 buffer.writeUInt8(
0,
45)
30924 this.privKey.d.toBuffer(
32).copy(buffer,
46)
30927 // X9.62 encoding for public keys
30928 this.pubKey.toBuffer().copy(buffer,
45)
30934 HDNode.prototype.toHex = function(isPrivate) {
30935 return this.toBuffer(isPrivate).toString('hex')
30938 // https://github.com/bitcoin/bips/blob/master/bip-
0032.mediawiki#child-key-derivation-ckd-functions
30939 HDNode.prototype.derive = function(index) {
30940 var isHardened = index
>= HDNode.HIGHEST_BIT
30941 var indexBuffer = new Buffer(
4)
30942 indexBuffer.writeUInt32BE(index,
0)
30948 assert(this.privKey, 'Could not derive hardened child key')
30950 // data =
0x00 || ser256(kpar) || ser32(index)
30951 data = Buffer.concat([
30952 this.privKey.d.toBuffer(
33),
30958 // data = serP(point(kpar)) || ser32(index)
30959 // = serP(Kpar) || ser32(index)
30960 data = Buffer.concat([
30961 this.pubKey.toBuffer(),
30966 var I = crypto.HmacSHA512(data, this.chainCode)
30967 var IL = I.slice(
0,
32)
30968 var IR = I.slice(
32)
30970 var pIL = BigInteger.fromBuffer(IL)
30972 // In case parse256(IL)
>= n, proceed with the next value for i
30973 if (pIL.compareTo(curve.n)
>=
0) {
30974 return this.derive(index +
1)
30977 // Private parent key -
> private child key
30979 if (this.privKey) {
30980 // ki = parse256(IL) + kpar (mod n)
30981 var ki = pIL.add(this.privKey.d).mod(curve.n)
30983 // In case ki ==
0, proceed with the next value for i
30984 if (ki.signum() ===
0) {
30985 return this.derive(index +
1)
30988 hd = new HDNode(ki, IR, this.network)
30990 // Public parent key -
> public child key
30992 // Ki = point(parse256(IL)) + Kpar
30994 var Ki = curve.G.multiply(pIL).add(this.pubKey.Q)
30996 // In case Ki is the point at infinity, proceed with the next value for i
30997 if (curve.isInfinity(Ki)) {
30998 return this.derive(index +
1)
31001 hd = new HDNode(Ki, IR, this.network)
31004 hd.depth = this.depth +
1
31006 hd.parentFingerprint = this.getFingerprint().readUInt32BE(
0)
31011 HDNode.prototype.deriveHardened = function(index) {
31012 // Only derives hardened private keys by default
31013 return this.derive(index + HDNode.HIGHEST_BIT)
31016 HDNode.prototype.toString = HDNode.prototype.toBase58
31018 module.exports = HDNode
31020 }).call(this,_dereq_("buffer").Buffer)
31021 },{"./base58check":
70,"./crypto":
73,"./eckey":
75,"./ecpubkey":
76,"./networks":
81,"assert":
4,"bigi":
3,"buffer":
8,"ecurve":
65}],
79:[function(_dereq_,module,exports){
31023 Address: _dereq_('./address'),
31024 base58check: _dereq_('./base58check'),
31025 bufferutils: _dereq_('./bufferutils'),
31026 convert: _dereq_('./convert'),
31027 crypto: _dereq_('./crypto'),
31028 ecdsa: _dereq_('./ecdsa'),
31029 ECKey: _dereq_('./eckey'),
31030 ECPubKey: _dereq_('./ecpubkey'),
31031 ECSignature: _dereq_('./ecsignature'),
31032 Message: _dereq_('./message'),
31033 opcodes: _dereq_('./opcodes'),
31034 HDNode: _dereq_('./hdnode'),
31035 Script: _dereq_('./script'),
31036 scripts: _dereq_('./scripts'),
31037 Transaction: _dereq_('./transaction'),
31038 networks: _dereq_('./networks'),
31039 Wallet: _dereq_('./wallet')
31042 },{"./address":
69,"./base58check":
70,"./bufferutils":
71,"./convert":
72,"./crypto":
73,"./ecdsa":
74,"./eckey":
75,"./ecpubkey":
76,"./ecsignature":
77,"./hdnode":
78,"./message":
80,"./networks":
81,"./opcodes":
82,"./script":
83,"./scripts":
84,"./transaction":
85,"./wallet":
86}],
80:[function(_dereq_,module,exports){
31043 (function (Buffer){
31044 /// Implements Bitcoin's feature for signing arbitrary messages.
31045 var Address = _dereq_('./address')
31046 var BigInteger = _dereq_('bigi')
31047 var bufferutils = _dereq_('./bufferutils')
31048 var crypto = _dereq_('./crypto')
31049 var ecdsa = _dereq_('./ecdsa')
31050 var networks = _dereq_('./networks')
31052 var Address = _dereq_('./address')
31053 var ECPubKey = _dereq_('./ecpubkey')
31054 var ECSignature = _dereq_('./ecsignature')
31056 var ecurve = _dereq_('ecurve')
31057 var ecparams = ecurve.getCurveByName('secp256k1')
31059 function magicHash(message, network) {
31060 var magicPrefix = new Buffer(network.magicPrefix)
31061 var messageBuffer = new Buffer(message)
31062 var lengthBuffer = new Buffer(bufferutils.varIntSize(messageBuffer.length))
31063 bufferutils.writeVarInt(lengthBuffer, messageBuffer.length,
0)
31065 var buffer = Buffer.concat([magicPrefix, lengthBuffer, messageBuffer])
31066 return crypto.hash256(buffer)
31069 function sign(privKey, message, network) {
31070 network = network || networks.bitcoin
31072 var hash = magicHash(message, network)
31073 var signature = privKey.sign(hash)
31074 var e = BigInteger.fromBuffer(hash)
31075 var i = ecdsa.calcPubKeyRecoveryParam(ecparams, e, signature, privKey.pub.Q)
31077 return signature.toCompact(i, privKey.pub.compressed)
31080 // TODO: network could be implied from address
31081 function verify(address, signatureBuffer, message, network) {
31082 if (address instanceof Address) {
31083 address = address.toString()
31085 network = network || networks.bitcoin
31087 var hash = magicHash(message, network)
31088 var parsed = ECSignature.parseCompact(signatureBuffer)
31089 var e = BigInteger.fromBuffer(hash)
31090 var Q = ecdsa.recoverPubKey(ecparams, e, parsed.signature, parsed.i)
31092 var pubKey = new ECPubKey(Q, parsed.compressed)
31093 return pubKey.getAddress(network).toString() === address
31097 magicHash: magicHash,
31102 }).call(this,_dereq_("buffer").Buffer)
31103 },{"./address":
69,"./bufferutils":
71,"./crypto":
73,"./ecdsa":
74,"./ecpubkey":
76,"./ecsignature":
77,"./networks":
81,"bigi":
3,"buffer":
8,"ecurve":
65}],
81:[function(_dereq_,module,exports){
31104 // https://en.bitcoin.it/wiki/List_of_address_prefixes
31105 // Dogecoin BIP32 is a proposed standard: https://bitcointalk.org/index.php?topic=
409731
31109 magicPrefix: '\x18Bitcoin Signed Message:\n',
31111 public:
0x0488b21e,
31112 private:
0x0488ade4
31117 dustThreshold:
546, // https://github.com/bitcoin/bitcoin/blob/v0.9
.2/src/core.h#L151-L162
31118 feePerKb:
10000, // https://github.com/bitcoin/bitcoin/blob/v0.9
.2/src/main.cpp#L53
31119 estimateFee: estimateFee('bitcoin')
31122 magicPrefix: '\x19Dogecoin Signed Message:\n',
31124 public:
0x02facafd,
31125 private:
0x02fac398
31130 dustThreshold:
0, // https://github.com/dogecoin/dogecoin/blob/v1.7
.1/src/core.h#L155-L160
31131 dustSoftThreshold:
100000000, // https://github.com/dogecoin/dogecoin/blob/v1.7
.1/src/main.h#L62
31132 feePerKb:
100000000, // https://github.com/dogecoin/dogecoin/blob/v1.7
.1/src/main.cpp#L58
31133 estimateFee: estimateFee('dogecoin')
31136 magicPrefix: '\x19Litecoin Signed Message:\n',
31138 public:
0x019da462,
31139 private:
0x019d9cfe
31144 dustThreshold:
0, // https://github.com/litecoin-project/litecoin/blob/v0.8
.7.2/src/main.cpp#L360-L365
31145 dustSoftThreshold:
100000, // https://github.com/litecoin-project/litecoin/blob/v0.8
.7.2/src/main.h#L53
31146 feePerKb:
100000, // https://github.com/litecoin-project/litecoin/blob/v0.8
.7.2/src/main.cpp#L56
31147 estimateFee: estimateFee('litecoin')
31150 magicPrefix: '\x18Bitcoin Signed Message:\n',
31152 public:
0x043587cf,
31153 private:
0x04358394
31158 dustThreshold:
546,
31160 estimateFee: estimateFee('testnet')
31164 function estimateFee(type) {
31165 return function(tx) {
31166 var network = networks[type]
31167 var baseFee = network.feePerKb
31168 var byteSize = tx.toBuffer().length
31170 var fee = baseFee * Math.ceil(byteSize /
1000)
31171 if (network.dustSoftThreshold == undefined) return fee
31173 tx.outs.forEach(function(e){
31174 if (e.value < network.dustSoftThreshold) {
31183 module.exports = networks
31185 },{}],
82:[function(_dereq_,module,exports){
31226 OP_TOALTSTACK :
107,
31227 OP_FROMALTSTACK :
108,
31259 OP_EQUALVERIFY :
136,
31260 OP_RESERVED1 :
137,
31261 OP_RESERVED2 :
138,
31271 OP_0NOTEQUAL :
146,
31284 OP_NUMEQUALVERIFY :
157,
31285 OP_NUMNOTEQUAL :
158,
31287 OP_GREATERTHAN :
160,
31288 OP_LESSTHANOREQUAL :
161,
31289 OP_GREATERTHANOREQUAL :
162,
31296 OP_RIPEMD160 :
166,
31301 OP_CODESEPARATOR :
171,
31303 OP_CHECKSIGVERIFY :
173,
31304 OP_CHECKMULTISIG :
174,
31305 OP_CHECKMULTISIGVERIFY :
175,
31319 // template matching params
31320 OP_PUBKEYHASH :
253,
31322 OP_INVALIDOPCODE :
255
31325 },{}],
83:[function(_dereq_,module,exports){
31326 (function (Buffer){
31327 var assert = _dereq_('assert')
31328 var bufferutils = _dereq_('./bufferutils')
31329 var crypto = _dereq_('./crypto')
31330 var opcodes = _dereq_('./opcodes')
31332 function Script(buffer, chunks) {
31333 assert(Buffer.isBuffer(buffer), 'Expected Buffer, got ' + buffer)
31334 assert(Array.isArray(chunks), 'Expected Array, got ' + chunks)
31336 this.buffer = buffer
31337 this.chunks = chunks
31340 // Import operations
31341 Script.fromASM = function(asm) {
31342 var strChunks = asm.split(' ')
31344 var chunks = strChunks.map(function(strChunk) {
31345 if (strChunk in opcodes) {
31346 return opcodes[strChunk]
31349 return new Buffer(strChunk, 'hex')
31353 return Script.fromChunks(chunks)
31356 Script.fromBuffer = function(buffer) {
31361 while (i < buffer.length) {
31362 var opcode = buffer.readUInt8(i)
31364 if ((opcode
> opcodes.OP_0) && (opcode <= opcodes.OP_PUSHDATA4)) {
31365 var d = bufferutils.readPushDataInt(buffer, i)
31368 var data = buffer.slice(i, i + d.number)
31374 chunks.push(opcode)
31380 return new Script(buffer, chunks)
31383 Script.fromChunks = function(chunks) {
31384 assert(Array.isArray(chunks), 'Expected Array, got ' + chunks)
31386 var bufferSize = chunks.reduce(function(accum, chunk) {
31387 if (Buffer.isBuffer(chunk)) {
31388 return accum + bufferutils.pushDataSize(chunk.length) + chunk.length
31394 var buffer = new Buffer(bufferSize)
31397 chunks.forEach(function(chunk) {
31398 if (Buffer.isBuffer(chunk)) {
31399 offset += bufferutils.writePushDataInt(buffer, chunk.length, offset)
31401 chunk.copy(buffer, offset)
31402 offset += chunk.length
31405 buffer.writeUInt8(chunk, offset)
31410 assert.equal(offset, buffer.length, 'Could not decode chunks')
31411 return new Script(buffer, chunks)
31414 Script.fromHex = function(hex) {
31415 return Script.fromBuffer(new Buffer(hex, 'hex'))
31419 Script.EMPTY = Script.fromChunks([])
31422 Script.prototype.getHash = function() {
31423 return crypto.hash160(this.buffer)
31426 // FIXME: doesn't work for data chunks, maybe time to use buffertools.compare...
31427 Script.prototype.without = function(needle) {
31428 return Script.fromChunks(this.chunks.filter(function(op) {
31429 return op !== needle
31433 // Export operations
31434 var reverseOps = []
31435 for (var op in opcodes) {
31436 var code = opcodes[op]
31437 reverseOps[code] = op
31440 Script.prototype.toASM = function() {
31441 return this.chunks.map(function(chunk) {
31442 if (Buffer.isBuffer(chunk)) {
31443 return chunk.toString('hex')
31446 return reverseOps[chunk]
31451 Script.prototype.toBuffer = function() {
31455 Script.prototype.toHex = function() {
31456 return this.toBuffer().toString('hex')
31459 module.exports = Script
31461 }).call(this,_dereq_("buffer").Buffer)
31462 },{"./bufferutils":
71,"./crypto":
73,"./opcodes":
82,"assert":
4,"buffer":
8}],
84:[function(_dereq_,module,exports){
31463 (function (Buffer){
31464 var assert = _dereq_('assert')
31465 var opcodes = _dereq_('./opcodes')
31467 // FIXME: use ECPubKey, currently the circular dependency breaks everything.
31470 // * Remove ECPubKey.getAddress
31471 // - Minimal change, but likely unpopular
31472 // * Move all script related functionality out of Address
31473 // - Means a lot of changes to Transaction/Wallet
31474 // * Ignore it (existing solution)
31475 // * Some form of hackery with commonjs
31477 var ecurve = _dereq_('ecurve')
31478 var curve = ecurve.getCurveByName('secp256k1')
31480 var ECSignature = _dereq_('./ecsignature')
31481 var Script = _dereq_('./script')
31483 function classifyOutput(script) {
31484 assert(script instanceof Script, 'Expected Script, got ', script)
31486 if (isPubKeyHashOutput.call(script)) {
31487 return 'pubkeyhash'
31488 } else if (isScriptHashOutput.call(script)) {
31489 return 'scripthash'
31490 } else if (isMultisigOutput.call(script)) {
31492 } else if (isPubKeyOutput.call(script)) {
31494 } else if (isNulldataOutput.call(script)) {
31497 return 'nonstandard'
31501 function classifyInput(script) {
31502 assert(script instanceof Script, 'Expected Script, got ', script)
31504 if (isPubKeyHashInput.call(script)) {
31505 return 'pubkeyhash'
31506 } else if (isScriptHashInput.call(script)) {
31507 return 'scripthash'
31508 } else if (isMultisigInput.call(script)) {
31510 } else if (isPubKeyInput.call(script)) {
31513 return 'nonstandard'
31517 function isCanonicalPubKey(buffer) {
31518 if (!Buffer.isBuffer(buffer)) return false
31522 ecurve.Point.decodeFrom(curve, buffer)
31524 if (!(e.message.match(/Invalid sequence (length|tag)/))) throw e
31532 function isCanonicalSignature(buffer) {
31533 if (!Buffer.isBuffer(buffer)) return false
31536 ECSignature.parseScriptSignature(buffer)
31538 if (!(e.message.match(/Not a DER sequence|Invalid sequence length|Expected a DER integer|R length is zero|S length is zero|R value excessively padded|S value excessively padded|R value is negative|S value is negative|Invalid hashType/))) throw e
31546 function isPubKeyHashInput() {
31547 return this.chunks.length ===
2 &&
31548 isCanonicalSignature(this.chunks[
0]) &&
31549 isCanonicalPubKey(this.chunks[
1])
31552 function isPubKeyHashOutput() {
31553 return this.chunks.length ===
5 &&
31554 this.chunks[
0] === opcodes.OP_DUP &&
31555 this.chunks[
1] === opcodes.OP_HASH160 &&
31556 Buffer.isBuffer(this.chunks[
2]) &&
31557 this.chunks[
2].length ===
20 &&
31558 this.chunks[
3] === opcodes.OP_EQUALVERIFY &&
31559 this.chunks[
4] === opcodes.OP_CHECKSIG
31562 function isPubKeyInput() {
31563 return this.chunks.length ===
1 &&
31564 isCanonicalSignature(this.chunks[
0])
31567 function isPubKeyOutput() {
31568 return this.chunks.length ===
2 &&
31569 isCanonicalPubKey(this.chunks[
0]) &&
31570 this.chunks[
1] === opcodes.OP_CHECKSIG
31573 function isScriptHashInput() {
31574 if (this.chunks.length <
2) return false
31575 var lastChunk = this.chunks[this.chunks.length -
1]
31577 if (!Buffer.isBuffer(lastChunk)) return false
31579 var scriptSig = Script.fromChunks(this.chunks.slice(
0, -
1))
31580 var scriptPubKey = Script.fromBuffer(lastChunk)
31582 return classifyInput(scriptSig) === classifyOutput(scriptPubKey)
31585 function isScriptHashOutput() {
31586 return this.chunks.length ===
3 &&
31587 this.chunks[
0] === opcodes.OP_HASH160 &&
31588 Buffer.isBuffer(this.chunks[
1]) &&
31589 this.chunks[
1].length ===
20 &&
31590 this.chunks[
2] === opcodes.OP_EQUAL
31593 function isMultisigInput() {
31594 return this.chunks[
0] === opcodes.OP_0 &&
31595 this.chunks.slice(
1).every(isCanonicalSignature)
31598 function isMultisigOutput() {
31599 if (this.chunks <
4) return false
31600 if (this.chunks[this.chunks.length -
1] !== opcodes.OP_CHECKMULTISIG) return false
31602 var mOp = this.chunks[
0]
31603 if (mOp === opcodes.OP_0) return false
31604 if (mOp < opcodes.OP_1) return false
31605 if (mOp
> opcodes.OP_16) return false
31607 var nOp = this.chunks[this.chunks.length -
2]
31608 if (nOp === opcodes.OP_0) return false
31609 if (nOp < opcodes.OP_1) return false
31610 if (nOp
> opcodes.OP_16) return false
31612 var m = mOp - (opcodes.OP_1 -
1)
31613 var n = nOp - (opcodes.OP_1 -
1)
31614 if (n < m) return false
31616 var pubKeys = this.chunks.slice(
1, -
2)
31617 if (n < pubKeys.length) return false
31619 return pubKeys.every(isCanonicalPubKey)
31622 function isNulldataOutput() {
31623 return this.chunks[
0] === opcodes.OP_RETURN
31626 // Standard Script Templates
31627 // {pubKey} OP_CHECKSIG
31628 function pubKeyOutput(pubKey) {
31629 return Script.fromChunks([
31631 opcodes.OP_CHECKSIG
31635 // OP_DUP OP_HASH160 {pubKeyHash} OP_EQUALVERIFY OP_CHECKSIG
31636 function pubKeyHashOutput(hash) {
31637 assert(Buffer.isBuffer(hash), 'Expected Buffer, got ' + hash)
31639 return Script.fromChunks([
31641 opcodes.OP_HASH160,
31643 opcodes.OP_EQUALVERIFY,
31644 opcodes.OP_CHECKSIG
31648 // OP_HASH160 {scriptHash} OP_EQUAL
31649 function scriptHashOutput(hash) {
31650 assert(Buffer.isBuffer(hash), 'Expected Buffer, got ' + hash)
31652 return Script.fromChunks([
31653 opcodes.OP_HASH160,
31659 // m [pubKeys ...] n OP_CHECKMULTISIG
31660 function multisigOutput(m, pubKeys) {
31661 assert(Array.isArray(pubKeys), 'Expected Array, got ' + pubKeys)
31662 assert(pubKeys.length
>= m, 'Not enough pubKeys provided')
31664 var pubKeyBuffers = pubKeys.map(function(pubKey) {
31665 return pubKey.toBuffer()
31667 var n = pubKeys.length
31669 return Script.fromChunks([].concat(
31670 (opcodes.OP_1 -
1) + m,
31672 (opcodes.OP_1 -
1) + n,
31673 opcodes.OP_CHECKMULTISIG
31678 function pubKeyInput(signature) {
31679 assert(Buffer.isBuffer(signature), 'Expected Buffer, got ' + signature)
31681 return Script.fromChunks([signature])
31684 // {signature} {pubKey}
31685 function pubKeyHashInput(signature, pubKey) {
31686 assert(Buffer.isBuffer(signature), 'Expected Buffer, got ' + signature)
31688 return Script.fromChunks([signature, pubKey.toBuffer()])
31691 //
<scriptSig> {serialized scriptPubKey script}
31692 function scriptHashInput(scriptSig, scriptPubKey) {
31693 return Script.fromChunks([].concat(
31695 scriptPubKey.toBuffer()
31699 // OP_0 [signatures ...]
31700 function multisigInput(signatures, scriptPubKey) {
31701 if (scriptPubKey) {
31702 assert(isMultisigOutput.call(scriptPubKey))
31704 var m = scriptPubKey.chunks[
0]
31705 var k = m - (opcodes.OP_1 -
1)
31706 assert(k <= signatures.length, 'Not enough signatures provided')
31709 return Script.fromChunks([].concat(opcodes.OP_0, signatures))
31713 classifyInput: classifyInput,
31714 classifyOutput: classifyOutput,
31715 multisigInput: multisigInput,
31716 multisigOutput: multisigOutput,
31717 pubKeyHashInput: pubKeyHashInput,
31718 pubKeyHashOutput: pubKeyHashOutput,
31719 pubKeyInput: pubKeyInput,
31720 pubKeyOutput: pubKeyOutput,
31721 scriptHashInput: scriptHashInput,
31722 scriptHashOutput: scriptHashOutput
31725 }).call(this,_dereq_("buffer").Buffer)
31726 },{"./ecsignature":
77,"./opcodes":
82,"./script":
83,"assert":
4,"buffer":
8,"ecurve":
65}],
85:[function(_dereq_,module,exports){
31727 (function (Buffer){
31728 var assert = _dereq_('assert')
31729 var bufferutils = _dereq_('./bufferutils')
31730 var crypto = _dereq_('./crypto')
31731 var opcodes = _dereq_('./opcodes')
31732 var scripts = _dereq_('./scripts')
31734 var Address = _dereq_('./address')
31735 var ECKey = _dereq_('./eckey')
31736 var ECSignature = _dereq_('./ecsignature')
31737 var Script = _dereq_('./script')
31739 Transaction.DEFAULT_SEQUENCE =
0xffffffff
31740 Transaction.SIGHASH_ALL =
0x01
31741 Transaction.SIGHASH_NONE =
0x02
31742 Transaction.SIGHASH_SINGLE =
0x03
31743 Transaction.SIGHASH_ANYONECANPAY =
0x80
31745 function Transaction() {
31753 * Create a new txin.
31755 * Can be called with any of:
31757 * - A transaction and an index
31758 * - A transaction hash and an index
31760 * Note that this method does not sign the created input.
31762 Transaction.prototype.addInput = function(tx, index, sequence) {
31763 if (sequence == undefined) sequence = Transaction.DEFAULT_SEQUENCE
31767 if (typeof tx === 'string') {
31768 hash = new Buffer(tx, 'hex')
31770 // TxId hex is big-endian, we need little-endian
31771 Array.prototype.reverse.call(hash)
31773 } else if (tx instanceof Transaction) {
31774 hash = tx.getHash()
31780 assert(Buffer.isBuffer(hash), 'Expected Transaction, txId or txHash, got ' + tx)
31781 assert.equal(hash.length,
32, 'Expected hash length of
32, got ' + hash.length)
31782 assert.equal(typeof index, 'number', 'Expected number index, got ' + index)
31784 return (this.ins.push({
31787 script: Script.EMPTY,
31793 * Create a new txout.
31795 * Can be called with:
31797 * - A base58 address string and a value
31798 * - An Address object and a value
31799 * - A scriptPubKey Script and a value
31801 Transaction.prototype.addOutput = function(scriptPubKey, value) {
31802 // Attempt to get a valid address if it's a base58 address string
31803 if (typeof scriptPubKey === 'string') {
31804 scriptPubKey = Address.fromBase58Check(scriptPubKey)
31807 // Attempt to get a valid script if it's an Address object
31808 if (scriptPubKey instanceof Address) {
31809 var address = scriptPubKey
31811 scriptPubKey = address.toOutputScript()
31814 return (this.outs.push({
31815 script: scriptPubKey,
31820 Transaction.prototype.toBuffer = function () {
31821 var txInSize = this.ins.reduce(function(a, x) {
31822 return a + (
40 + bufferutils.varIntSize(x.script.buffer.length) + x.script.buffer.length)
31825 var txOutSize = this.outs.reduce(function(a, x) {
31826 return a + (
8 + bufferutils.varIntSize(x.script.buffer.length) + x.script.buffer.length)
31829 var buffer = new Buffer(
31831 bufferutils.varIntSize(this.ins.length) +
31832 bufferutils.varIntSize(this.outs.length) +
31838 function writeSlice(slice) {
31839 slice.copy(buffer, offset)
31840 offset += slice.length
31842 function writeUInt32(i) {
31843 buffer.writeUInt32LE(i, offset)
31846 function writeUInt64(i) {
31847 bufferutils.writeUInt64LE(buffer, i, offset)
31850 function writeVarInt(i) {
31851 var n = bufferutils.writeVarInt(buffer, i, offset)
31855 writeUInt32(this.version)
31856 writeVarInt(this.ins.length)
31858 this.ins.forEach(function(txin) {
31859 writeSlice(txin.hash)
31860 writeUInt32(txin.index)
31861 writeVarInt(txin.script.buffer.length)
31862 writeSlice(txin.script.buffer)
31863 writeUInt32(txin.sequence)
31866 writeVarInt(this.outs.length)
31867 this.outs.forEach(function(txout) {
31868 writeUInt64(txout.value)
31869 writeVarInt(txout.script.buffer.length)
31870 writeSlice(txout.script.buffer)
31873 writeUInt32(this.locktime)
31878 Transaction.prototype.toHex = function() {
31879 return this.toBuffer().toString('hex')
31883 * Hash transaction for signing a specific input.
31885 * Bitcoin uses a different hash for each signed transaction input. This
31886 * method copies the transaction, makes the necessary changes based on the
31887 * hashType, serializes and finally hashes the result. This hash can then be
31888 * used to sign the transaction input in question.
31890 Transaction.prototype.hashForSignature = function(prevOutScript, inIndex, hashType) {
31891 assert(inIndex
>=
0, 'Invalid vin index')
31892 assert(inIndex < this.ins.length, 'Invalid vin index')
31893 assert(prevOutScript instanceof Script, 'Invalid Script object')
31895 var txTmp = this.clone()
31896 var hashScript = prevOutScript.without(opcodes.OP_CODESEPARATOR)
31898 // Blank out other inputs' signatures
31899 txTmp.ins.forEach(function(txin) {
31900 txin.script = Script.EMPTY
31902 txTmp.ins[inIndex].script = hashScript
31904 var hashTypeModifier = hashType &
0x1f
31905 if (hashTypeModifier === Transaction.SIGHASH_NONE) {
31906 assert(false, 'SIGHASH_NONE not yet supported')
31908 } else if (hashTypeModifier === Transaction.SIGHASH_SINGLE) {
31909 assert(false, 'SIGHASH_SINGLE not yet supported')
31913 if (hashType & Transaction.SIGHASH_ANYONECANPAY) {
31914 assert(false, 'SIGHASH_ANYONECANPAY not yet supported')
31917 var hashTypeBuffer = new Buffer(
4)
31918 hashTypeBuffer.writeInt32LE(hashType,
0)
31920 var buffer = Buffer.concat([txTmp.toBuffer(), hashTypeBuffer])
31921 return crypto.hash256(buffer)
31924 Transaction.prototype.getHash = function () {
31925 return crypto.hash256(this.toBuffer())
31928 Transaction.prototype.getId = function () {
31929 var buffer = this.getHash()
31931 // Big-endian is used for TxHash
31932 Array.prototype.reverse.call(buffer)
31934 return buffer.toString('hex')
31937 Transaction.prototype.clone = function () {
31938 var newTx = new Transaction()
31939 newTx.version = this.version
31940 newTx.locktime = this.locktime
31942 newTx.ins = this.ins.map(function(txin) {
31946 script: txin.script,
31947 sequence: txin.sequence
31951 newTx.outs = this.outs.map(function(txout) {
31953 script: txout.script,
31961 Transaction.fromBuffer = function(buffer) {
31963 function readSlice(n) {
31965 return buffer.slice(offset - n, offset)
31967 function readUInt32() {
31968 var i = buffer.readUInt32LE(offset)
31972 function readUInt64() {
31973 var i = bufferutils.readUInt64LE(buffer, offset)
31977 function readVarInt() {
31978 var vi = bufferutils.readVarInt(buffer, offset)
31983 var tx = new Transaction()
31984 tx.version = readUInt32()
31986 var vinLen = readVarInt()
31987 for (var i =
0; i < vinLen; ++i) {
31988 var hash = readSlice(
32)
31989 var vout = readUInt32()
31990 var scriptLen = readVarInt()
31991 var script = readSlice(scriptLen)
31992 var sequence = readUInt32()
31997 script: Script.fromBuffer(script),
32002 var voutLen = readVarInt()
32003 for (i =
0; i < voutLen; ++i) {
32004 var value = readUInt64()
32005 var scriptLen = readVarInt()
32006 var script = readSlice(scriptLen)
32010 script: Script.fromBuffer(script)
32014 tx.locktime = readUInt32()
32015 assert.equal(offset, buffer.length, 'Transaction has unexpected data')
32020 Transaction.fromHex = function(hex) {
32021 return Transaction.fromBuffer(new Buffer(hex, 'hex'))
32025 * Signs a pubKeyHash output at some index with the given key
32027 Transaction.prototype.sign = function(index, privKey, hashType) {
32028 var prevOutScript = privKey.pub.getAddress().toOutputScript()
32029 var signature = this.signInput(index, prevOutScript, privKey, hashType)
32031 // FIXME: Assumed prior TX was pay-to-pubkey-hash
32032 var scriptSig = scripts.pubKeyHashInput(signature, privKey.pub)
32033 this.setInputScript(index, scriptSig)
32036 Transaction.prototype.signInput = function(index, prevOutScript, privKey, hashType) {
32037 hashType = hashType || Transaction.SIGHASH_ALL
32039 var hash = this.hashForSignature(prevOutScript, index, hashType)
32040 var signature = privKey.sign(hash)
32042 return signature.toScriptSignature(hashType)
32045 Transaction.prototype.setInputScript = function(index, script) {
32046 this.ins[index].script = script
32049 // FIXME: could be validateInput(index, prevTxOut, pub)
32050 Transaction.prototype.validateInput = function(index, prevOutScript, pubKey, buffer) {
32051 var parsed = ECSignature.parseScriptSignature(buffer)
32052 var hash = this.hashForSignature(prevOutScript, index, parsed.hashType)
32054 return pubKey.verify(hash, parsed.signature)
32057 module.exports = Transaction
32059 }).call(this,_dereq_("buffer").Buffer)
32060 },{"./address":
69,"./bufferutils":
71,"./crypto":
73,"./eckey":
75,"./ecsignature":
77,"./opcodes":
82,"./script":
83,"./scripts":
84,"assert":
4,"buffer":
8}],
86:[function(_dereq_,module,exports){
32061 (function (Buffer){
32062 var assert = _dereq_('assert')
32063 var networks = _dereq_('./networks')
32064 var rng = _dereq_('secure-random')
32066 var Address = _dereq_('./address')
32067 var HDNode = _dereq_('./hdnode')
32068 var Transaction = _dereq_('./transaction')
32070 function Wallet(seed, network) {
32071 network = network || networks.bitcoin
32073 // Stored in a closure to make accidental serialization less likely
32074 var masterkey = null
32076 var accountZero = null
32077 var internalAccount = null
32078 var externalAccount = null
32081 this.addresses = []
32082 this.changeAddresses = []
32084 // Transaction output data
32087 // Make a new master key
32088 this.newMasterKey = function(seed) {
32089 seed = seed || new Buffer(rng(
32))
32090 masterkey = HDNode.fromSeedBuffer(seed, network)
32092 // HD first-level child derivation method should be hardened
32093 // See https://bitcointalk.org/index.php?topic=
405179.msg4415254#msg4415254
32094 accountZero = masterkey.deriveHardened(
0)
32095 externalAccount = accountZero.derive(
0)
32096 internalAccount = accountZero.derive(
1)
32099 me.changeAddresses = []
32104 this.newMasterKey(seed)
32106 this.generateAddress = function() {
32107 var key = externalAccount.derive(this.addresses.length)
32108 this.addresses.push(key.getAddress().toString())
32109 return this.addresses[this.addresses.length -
1]
32112 this.generateChangeAddress = function() {
32113 var key = internalAccount.derive(this.changeAddresses.length)
32114 this.changeAddresses.push(key.getAddress().toString())
32115 return this.changeAddresses[this.changeAddresses.length -
1]
32118 this.getBalance = function() {
32119 return this.getUnspentOutputs().reduce(function(memo, output){
32120 return memo + output.value
32124 this.getUnspentOutputs = function() {
32127 for(var key in this.outputs){
32128 var output = this.outputs[key]
32129 if(!output.to) utxo.push(outputToUnspentOutput(output))
32135 this.setUnspentOutputs = function(utxo) {
32138 utxo.forEach(function(uo){
32139 validateUnspentOutput(uo)
32140 var o = unspentOutputToOutput(uo)
32141 outputs[o.from] = o
32144 this.outputs = outputs
32147 function outputToUnspentOutput(output){
32148 var hashAndIndex = output.from.split(":")
32151 hash: hashAndIndex[
0],
32152 outputIndex: parseInt(hashAndIndex[
1]),
32153 address: output.address,
32154 value: output.value,
32155 pending: output.pending
32159 function unspentOutputToOutput(o) {
32161 var key = hash + ":" + o.outputIndex
32164 address: o.address,
32170 function validateUnspentOutput(uo) {
32173 if (isNullOrUndefined(uo.hash)) {
32174 missingField = "hash"
32177 var requiredKeys = ['outputIndex', 'address', 'value']
32178 requiredKeys.forEach(function (key) {
32179 if (isNullOrUndefined(uo[key])){
32184 if (missingField) {
32186 'Invalid unspent output: key', missingField, 'is missing.',
32187 'A valid unspent output must contain'
32189 message.push(requiredKeys.join(', '))
32190 message.push("and hash")
32191 throw new Error(message.join(' '))
32195 function isNullOrUndefined(value) {
32196 return value == undefined
32199 this.processPendingTx = function(tx){
32200 processTx(tx, true)
32203 this.processConfirmedTx = function(tx){
32204 processTx(tx, false)
32207 function processTx(tx, isPending) {
32208 var txid = tx.getId()
32210 tx.outs.forEach(function(txOut, i) {
32214 address = Address.fromOutputScript(txOut.script, network).toString()
32216 if (!(e.message.match(/has no matching Address/))) throw e
32219 if (isMyAddress(address)) {
32220 var output = txid + ':' + i
32222 me.outputs[output] = {
32224 value: txOut.value,
32231 tx.ins.forEach(function(txIn, i) {
32232 // copy and convert to big-endian hex
32233 var txinId = new Buffer(txIn.hash)
32234 Array.prototype.reverse.call(txinId)
32235 txinId = txinId.toString('hex')
32237 var output = txinId + ':' + txIn.index
32239 if (!(output in me.outputs)) return
32242 me.outputs[output].to = txid + ':' + i
32243 me.outputs[output].pending = true
32245 delete me.outputs[output]
32250 this.createTx = function(to, value, fixedFee, changeAddress) {
32251 assert(value
> network.dustThreshold, value + ' must be above dust threshold (' + network.dustThreshold + ' Satoshis)')
32253 var utxos = getCandidateOutputs(value)
32255 var subTotal = value
32258 var tx = new Transaction()
32259 tx.addOutput(to, value)
32261 for (var i =
0; i < utxos.length; ++i) {
32262 var utxo = utxos[i]
32263 addresses.push(utxo.address)
32265 var outpoint = utxo.from.split(':')
32266 tx.addInput(outpoint[
0], parseInt(outpoint[
1]))
32268 var fee = fixedFee == undefined ? estimateFeePadChangeOutput(tx) : fixedFee
32270 accum += utxo.value
32271 subTotal = value + fee
32272 if (accum
>= subTotal) {
32273 var change = accum - subTotal
32275 if (change
> network.dustThreshold) {
32276 tx.addOutput(changeAddress || getChangeAddress(), change)
32283 assert(accum
>= subTotal, 'Not enough funds (incl. fee): ' + accum + ' < ' + subTotal)
32285 this.signWith(tx, addresses)
32289 function getCandidateOutputs() {
32292 for (var key in me.outputs) {
32293 var output = me.outputs[key]
32294 if (!output.pending) unspent.push(output)
32297 var sortByValueDesc = unspent.sort(function(o1, o2){
32298 return o2.value - o1.value
32301 return sortByValueDesc
32304 function estimateFeePadChangeOutput(tx) {
32305 var tmpTx = tx.clone()
32306 tmpTx.addOutput(getChangeAddress(), network.dustSoftThreshold ||
0)
32308 return network.estimateFee(tmpTx)
32311 function getChangeAddress() {
32312 if(me.changeAddresses.length ===
0) me.generateChangeAddress();
32313 return me.changeAddresses[me.changeAddresses.length -
1]
32316 this.signWith = function(tx, addresses) {
32317 assert.equal(tx.ins.length, addresses.length, 'Number of addresses must match number of transaction inputs')
32319 addresses.forEach(function(address, i) {
32320 var key = me.getPrivateKeyForAddress(address)
32328 this.getMasterKey = function() { return masterkey }
32329 this.getAccountZero = function() { return accountZero }
32330 this.getInternalAccount = function() { return internalAccount }
32331 this.getExternalAccount = function() { return externalAccount }
32333 this.getPrivateKey = function(index) {
32334 return externalAccount.derive(index).privKey
32337 this.getInternalPrivateKey = function(index) {
32338 return internalAccount.derive(index).privKey
32341 this.getPrivateKeyForAddress = function(address) {
32343 if((index = this.addresses.indexOf(address))
> -
1) {
32344 return this.getPrivateKey(index)
32345 } else if((index = this.changeAddresses.indexOf(address))
> -
1) {
32346 return this.getInternalPrivateKey(index)
32348 throw new Error('Unknown address. Make sure the address is from the keychain and has been generated.')
32352 function isReceiveAddress(address){
32353 return me.addresses.indexOf(address)
> -
1
32356 function isChangeAddress(address){
32357 return me.changeAddresses.indexOf(address)
> -
1
32360 function isMyAddress(address) {
32361 return isReceiveAddress(address) || isChangeAddress(address)
32365 module.exports = Wallet
32367 }).call(this,_dereq_("buffer").Buffer)
32368 },{"./address":
69,"./hdnode":
78,"./networks":
81,"./transaction":
85,"assert":
4,"buffer":
8,"secure-random":
68}]},{},[
79])
32373 // Select components from sjcl to suit the crypto operations bip39 requires.
32377 /** @fileOverview Javascript cryptography implementation.
32379 * Crush to remove comments, shorten variable names and
32380 * generally reduce transmission size.
32382 * @author Emily Stark
32383 * @author Mike Hamburg
32384 * @author Dan Boneh
32388 /*jslint indent:
2, bitwise: false, nomen: false, plusplus: false, white: false, regexp: false */
32389 /*global document, window, escape, unescape, module, require, Uint32Array */
32391 /** @namespace The Stanford Javascript Crypto Library, top-level namespace. */
32393 /** @namespace Symmetric ciphers. */
32396 /** @namespace Hash functions. Right now only SHA256 is implemented. */
32399 /** @namespace Key exchange functions. Right now only SRP is implemented. */
32402 /** @namespace Block cipher modes of operation. */
32405 /** @namespace Miscellaneous. HMAC and PBKDF2. */
32409 * @namespace Bit array encoders and decoders.
32412 * The members of this namespace are functions which translate between
32413 * SJCL's bitArrays and other objects (usually strings). Because it
32414 * isn't always clear which direction is encoding and which is decoding,
32415 * the method names are "fromBits" and "toBits".
32419 /** @namespace Exceptions. */
32421 /** @constructor Ciphertext is corrupt. */
32422 corrupt: function(message) {
32423 this.toString = function() { return "CORRUPT: "+this.message; };
32424 this.message = message;
32427 /** @constructor Invalid parameter. */
32428 invalid: function(message) {
32429 this.toString = function() { return "INVALID: "+this.message; };
32430 this.message = message;
32433 /** @constructor Bug or missing feature in SJCL. @constructor */
32434 bug: function(message) {
32435 this.toString = function() { return "BUG: "+this.message; };
32436 this.message = message;
32439 /** @constructor Something isn't ready. */
32440 notReady: function(message) {
32441 this.toString = function() { return "NOT READY: "+this.message; };
32442 this.message = message;
32447 if(typeof module !== 'undefined' && module.exports){
32448 module.exports = sjcl;
32450 if (typeof define === "function") {
32451 define([], function () {
32459 /** @fileOverview Arrays of bits, encoded as arrays of Numbers.
32461 * @author Emily Stark
32462 * @author Mike Hamburg
32463 * @author Dan Boneh
32466 /** @namespace Arrays of bits, encoded as arrays of Numbers.
32470 * These objects are the currency accepted by SJCL's crypto functions.
32474 * Most of our crypto primitives operate on arrays of
4-byte words internally,
32475 * but many of them can take arguments that are not a multiple of
4 bytes.
32476 * This library encodes arrays of bits (whose size need not be a multiple of
8
32477 * bits) as arrays of
32-bit words. The bits are packed, big-endian, into an
32478 * array of words,
32 bits at a time. Since the words are double-precision
32479 * floating point numbers, they fit some extra data. We use this (in a private,
32480 * possibly-changing manner) to encode the number of bits actually present
32481 * in the last word of the array.
32485 * Because bitwise ops clear this out-of-band data, these arrays can be passed
32486 * to ciphers like AES which want arrays of words.
32491 * Array slices in units of bits.
32492 * @param {bitArray} a The array to slice.
32493 * @param {Number} bstart The offset to the start of the slice, in bits.
32494 * @param {Number} bend The offset to the end of the slice, in bits. If this is undefined,
32495 * slice until the end of the array.
32496 * @return {bitArray} The requested slice.
32498 bitSlice: function (a, bstart, bend) {
32499 a = sjcl.bitArray._shiftRight(a.slice(bstart/
32),
32 - (bstart &
31)).slice(
1);
32500 return (bend === undefined) ? a : sjcl.bitArray.clamp(a, bend-bstart);
32504 * Extract a number packed into a bit array.
32505 * @param {bitArray} a The array to slice.
32506 * @param {Number} bstart The offset to the start of the slice, in bits.
32507 * @param {Number} length The length of the number to extract.
32508 * @return {Number} The requested slice.
32510 extract: function(a, bstart, blength) {
32511 // FIXME: this Math.floor is not necessary at all, but for some reason
32512 // seems to suppress a bug in the Chromium JIT.
32513 var x, sh = Math.floor((-bstart-blength) &
31);
32514 if ((bstart + blength -
1 ^ bstart) & -
32) {
32515 // it crosses a boundary
32516 x = (a[bstart/
32|
0] << (
32 - sh)) ^ (a[bstart/
32+
1|
0]
>>> sh);
32518 // within a single word
32519 x = a[bstart/
32|
0]
>>> sh;
32521 return x & ((
1<
<blength) -
1);
32525 * Concatenate two bit arrays.
32526 * @param {bitArray} a1 The first array.
32527 * @param {bitArray} a2 The second array.
32528 * @return {bitArray} The concatenation of a1 and a2.
32530 concat: function (a1, a2) {
32531 if (a1.length ===
0 || a2.length ===
0) {
32532 return a1.concat(a2);
32535 var last = a1[a1.length-
1], shift = sjcl.bitArray.getPartial(last);
32536 if (shift ===
32) {
32537 return a1.concat(a2);
32539 return sjcl.bitArray._shiftRight(a2, shift, last|
0, a1.slice(
0,a1.length-
1));
32544 * Find the length of an array of bits.
32545 * @param {bitArray} a The array.
32546 * @return {Number} The length of a, in bits.
32548 bitLength: function (a) {
32549 var l = a.length, x;
32550 if (l ===
0) { return
0; }
32552 return (l-
1) *
32 + sjcl.bitArray.getPartial(x);
32556 * Truncate an array.
32557 * @param {bitArray} a The array.
32558 * @param {Number} len The length to truncate to, in bits.
32559 * @return {bitArray} A new array, truncated to len bits.
32561 clamp: function (a, len) {
32562 if (a.length *
32 < len) { return a; }
32563 a = a.slice(
0, Math.ceil(len /
32));
32566 if (l
> 0 && len) {
32567 a[l-
1] = sjcl.bitArray.partial(len, a[l-
1] &
0x80000000 >> (len-
1),
1);
32573 * Make a partial word for a bit array.
32574 * @param {Number} len The number of bits in the word.
32575 * @param {Number} x The bits.
32576 * @param {Number} [
0] _end Pass
1 if x has already been shifted to the high side.
32577 * @return {Number} The partial word.
32579 partial: function (len, x, _end) {
32580 if (len ===
32) { return x; }
32581 return (_end ? x|
0 : x << (
32-len)) + len *
0x10000000000;
32585 * Get the number of bits used by a partial word.
32586 * @param {Number} x The partial word.
32587 * @return {Number} The number of bits used by the partial word.
32589 getPartial: function (x) {
32590 return Math.round(x/
0x10000000000) ||
32;
32594 * Compare two arrays for equality in a predictable amount of time.
32595 * @param {bitArray} a The first array.
32596 * @param {bitArray} b The second array.
32597 * @return {boolean} true if a == b; false otherwise.
32599 equal: function (a, b) {
32600 if (sjcl.bitArray.bitLength(a) !== sjcl.bitArray.bitLength(b)) {
32604 for (i=
0; i
<a.length; i++) {
32610 /** Shift an array right.
32611 * @param {bitArray} a The array to shift.
32612 * @param {Number} shift The number of bits to shift.
32613 * @param {Number} [carry=
0] A byte to carry in
32614 * @param {bitArray} [out=[]] An array to prepend to the output.
32617 _shiftRight: function (a, shift, carry, out) {
32618 var i, last2=
0, shift2;
32619 if (out === undefined) { out = []; }
32621 for (; shift
>=
32; shift -=
32) {
32626 return out.concat(a);
32629 for (i=
0; i
<a.length; i++) {
32630 out.push(carry | a[i]
>>>shift);
32631 carry = a[i] << (
32-shift);
32633 last2 = a.length ? a[a.length-
1] :
0;
32634 shift2 = sjcl.bitArray.getPartial(last2);
32635 out.push(sjcl.bitArray.partial(shift+shift2 &
31, (shift + shift2
> 32) ? carry : out.pop(),
1));
32639 /** xor a block of
4 words together.
32642 _xor4: function(x,y) {
32643 return [x[
0]^y[
0],x[
1]^y[
1],x[
2]^y[
2],x[
3]^y[
3]];
32646 /** byteswap a word array inplace.
32647 * (does not handle partial words)
32648 * @param {sjcl.bitArray} a word array
32649 * @return {sjcl.bitArray} byteswapped array
32651 byteswapM: function(a) {
32652 var i, v, m =
0xff00;
32653 for (i =
0; i < a.length; ++i) {
32655 a[i] = (v
>>> 24) | ((v
>>> 8) & m) | ((v & m) <<
8) | (v <<
24);
32662 //// codecString.js
32664 /** @fileOverview Bit array codec implementations.
32666 * @author Emily Stark
32667 * @author Mike Hamburg
32668 * @author Dan Boneh
32671 /** @namespace UTF-
8 strings */
32672 sjcl.codec.utf8String = {
32673 /** Convert from a bitArray to a UTF-
8 string. */
32674 fromBits: function (arr) {
32675 var out =
"", bl = sjcl.bitArray.bitLength(arr), i, tmp;
32676 for (i=
0; i
<bl/
8; i++) {
32680 out += String.fromCharCode(tmp
>>> 24);
32683 return decodeURIComponent(escape(out));
32686 /** Convert from a UTF-
8 string to a bitArray. */
32687 toBits: function (str) {
32688 str = unescape(encodeURIComponent(str));
32689 var out = [], i, tmp=
0;
32690 for (i=
0; i
<str.length; i++) {
32691 tmp = tmp <<
8 | str.charCodeAt(i);
32698 out.push(sjcl.bitArray.partial(
8*(i&
3), tmp));
32707 /** @fileOverview Bit array codec implementations.
32709 * @author Emily Stark
32710 * @author Mike Hamburg
32711 * @author Dan Boneh
32714 /** @namespace Hexadecimal */
32716 /** Convert from a bitArray to a hex string. */
32717 fromBits: function (arr) {
32719 for (i=
0; i
<arr.length; i++) {
32720 out += ((arr[i]|
0)+
0xF00000000000).toString(
16).substr(
4);
32722 return out.substr(
0, sjcl.bitArray.bitLength(arr)/
4);//.replace(/(.{
8})/g,
"$1 ");
32724 /** Convert from a hex string to a bitArray. */
32725 toBits: function (str) {
32726 var i, out=[], len;
32727 str = str.replace(/\s|
0x/g,
"");
32729 str = str +
"00000000";
32730 for (i=
0; i
<str.length; i+=
8) {
32731 out.push(parseInt(str.substr(i,
8),
16)^
0);
32733 return sjcl.bitArray.clamp(out, len*
4);
32740 /** @fileOverview Javascript SHA-
512 implementation.
32742 * This implementation was written for CryptoJS by Jeff Mott and adapted for
32743 * SJCL by Stefan Thomas.
32745 * CryptoJS (c)
2009–
2012 by Jeff Mott. All rights reserved.
32746 * Released with New BSD License
32748 * @author Emily Stark
32749 * @author Mike Hamburg
32750 * @author Dan Boneh
32751 * @author Jeff Mott
32752 * @author Stefan Thomas
32756 * Context for a SHA-
512 operation in progress.
32758 * @class Secure Hash Algorithm,
512 bits.
32760 sjcl.hash.sha512 = function (hash) {
32761 if (!this._key[
0]) { this._precompute(); }
32763 this._h = hash._h.slice(
0);
32764 this._buffer = hash._buffer.slice(
0);
32765 this._length = hash._length;
32772 * Hash a string or an array of words.
32774 * @param {bitArray|String} data the data to hash.
32775 * @return {bitArray} The hash value, an array of
16 big-endian words.
32777 sjcl.hash.sha512.hash = function (data) {
32778 return (new sjcl.hash.sha512()).update(data).finalize();
32781 sjcl.hash.sha512.prototype = {
32783 * The hash's block size, in bits.
32789 * Reset the hash state.
32792 reset:function () {
32793 this._h = this._init.slice(
0);
32800 * Input several words to the hash.
32801 * @param {bitArray|String} data the data to hash.
32804 update: function (data) {
32805 if (typeof data ===
"string") {
32806 data = sjcl.codec.utf8String.toBits(data);
32808 var i, b = this._buffer = sjcl.bitArray.concat(this._buffer, data),
32810 nl = this._length = ol + sjcl.bitArray.bitLength(data);
32811 for (i =
1024+ol & -
1024; i <= nl; i+=
1024) {
32812 this._block(b.splice(
0,
32));
32818 * Complete hashing and output the hash value.
32819 * @return {bitArray} The hash value, an array of
16 big-endian words.
32821 finalize:function () {
32822 var i, b = this._buffer, h = this._h;
32824 // Round out and push the buffer
32825 b = sjcl.bitArray.concat(b, [sjcl.bitArray.partial(
1,
1)]);
32827 // Round out the buffer to a multiple of
32 words, less the
4 length words.
32828 for (i = b.length +
4; i &
31; i++) {
32832 // append the length
32835 b.push(Math.floor(this._length /
0x100000000));
32836 b.push(this._length |
0);
32839 this._block(b.splice(
0,
32));
32847 * The SHA-
512 initialization vector, to be precomputed.
32853 * Least significant
24 bits of SHA512 initialization values.
32855 * Javascript only has
53 bits of precision, so we compute the
40 most
32856 * significant bits and add the remaining
24 bits as constants.
32860 _initr: [
0xbcc908,
0xcaa73b,
0x94f82b,
0x1d36f1,
0xe682d1,
0x3e6c1f,
0x41bd6b,
0x7e2179 ],
32864 [
0x6a09e667,
0xf3bcc908,
0xbb67ae85,
0x84caa73b,
0x3c6ef372,
0xfe94f82b,
0xa54ff53a,
0x5f1d36f1,
32865 0x510e527f,
0xade682d1,
0x9b05688c,
0x2b3e6c1f,
0x1f83d9ab,
0xfb41bd6b,
0x5be0cd19,
0x137e2179],
32869 * The SHA-
512 hash key, to be precomputed.
32875 * Least significant
24 bits of SHA512 key values.
32879 [
0x28ae22,
0xef65cd,
0x4d3b2f,
0x89dbbc,
0x48b538,
0x05d019,
0x194f9b,
0x6d8118,
32880 0x030242,
0x706fbe,
0xe4b28c,
0xffb4e2,
0x7b896f,
0x1696b1,
0xc71235,
0x692694,
32881 0xf14ad2,
0x4f25e3,
0x8cd5b5,
0xac9c65,
0x2b0275,
0xa6e483,
0x41fbd4,
0x1153b5,
32882 0x66dfab,
0xb43210,
0xfb213f,
0xef0ee4,
0xa88fc2,
0x0aa725,
0x03826f,
0x0e6e70,
32883 0xd22ffc,
0x26c926,
0xc42aed,
0x95b3df,
0xaf63de,
0x77b2a8,
0xedaee6,
0x82353b,
32884 0xf10364,
0x423001,
0xf89791,
0x54be30,
0xef5218,
0x65a910,
0x71202a,
0xbbd1b8,
32885 0xd2d0c8,
0x41ab53,
0x8eeb99,
0x9b48a8,
0xc95a63,
0x418acb,
0x63e373,
0xb2b8a3,
32886 0xefb2fc,
0x172f60,
0xf0ab72,
0x6439ec,
0x631e28,
0x82bde9,
0xc67915,
0x72532b,
32887 0x26619c,
0xc0c207,
0xe0eb1e,
0x6ed178,
0x176fba,
0xc898a6,
0xf90dae,
0x1c471b,
32888 0x047d84,
0xc72493,
0xc9bebc,
0x100d4c,
0x3e42b6,
0x657e2a,
0xd6faec,
0x475817],
32892 [
0x428a2f98,
0xd728ae22,
0x71374491,
0x23ef65cd,
0xb5c0fbcf,
0xec4d3b2f,
0xe9b5dba5,
0x8189dbbc,
32893 0x3956c25b,
0xf348b538,
0x59f111f1,
0xb605d019,
0x923f82a4,
0xaf194f9b,
0xab1c5ed5,
0xda6d8118,
32894 0xd807aa98,
0xa3030242,
0x12835b01,
0x45706fbe,
0x243185be,
0x4ee4b28c,
0x550c7dc3,
0xd5ffb4e2,
32895 0x72be5d74,
0xf27b896f,
0x80deb1fe,
0x3b1696b1,
0x9bdc06a7,
0x25c71235,
0xc19bf174,
0xcf692694,
32896 0xe49b69c1,
0x9ef14ad2,
0xefbe4786,
0x384f25e3,
0x0fc19dc6,
0x8b8cd5b5,
0x240ca1cc,
0x77ac9c65,
32897 0x2de92c6f,
0x592b0275,
0x4a7484aa,
0x6ea6e483,
0x5cb0a9dc,
0xbd41fbd4,
0x76f988da,
0x831153b5,
32898 0x983e5152,
0xee66dfab,
0xa831c66d,
0x2db43210,
0xb00327c8,
0x98fb213f,
0xbf597fc7,
0xbeef0ee4,
32899 0xc6e00bf3,
0x3da88fc2,
0xd5a79147,
0x930aa725,
0x06ca6351,
0xe003826f,
0x14292967,
0x0a0e6e70,
32900 0x27b70a85,
0x46d22ffc,
0x2e1b2138,
0x5c26c926,
0x4d2c6dfc,
0x5ac42aed,
0x53380d13,
0x9d95b3df,
32901 0x650a7354,
0x8baf63de,
0x766a0abb,
0x3c77b2a8,
0x81c2c92e,
0x47edaee6,
0x92722c85,
0x1482353b,
32902 0xa2bfe8a1,
0x4cf10364,
0xa81a664b,
0xbc423001,
0xc24b8b70,
0xd0f89791,
0xc76c51a3,
0x0654be30,
32903 0xd192e819,
0xd6ef5218,
0xd6990624,
0x5565a910,
0xf40e3585,
0x5771202a,
0x106aa070,
0x32bbd1b8,
32904 0x19a4c116,
0xb8d2d0c8,
0x1e376c08,
0x5141ab53,
0x2748774c,
0xdf8eeb99,
0x34b0bcb5,
0xe19b48a8,
32905 0x391c0cb3,
0xc5c95a63,
0x4ed8aa4a,
0xe3418acb,
0x5b9cca4f,
0x7763e373,
0x682e6ff3,
0xd6b2b8a3,
32906 0x748f82ee,
0x5defb2fc,
0x78a5636f,
0x43172f60,
0x84c87814,
0xa1f0ab72,
0x8cc70208,
0x1a6439ec,
32907 0x90befffa,
0x23631e28,
0xa4506ceb,
0xde82bde9,
0xbef9a3f7,
0xb2c67915,
0xc67178f2,
0xe372532b,
32908 0xca273ece,
0xea26619c,
0xd186b8c7,
0x21c0c207,
0xeada7dd6,
0xcde0eb1e,
0xf57d4f7f,
0xee6ed178,
32909 0x06f067aa,
0x72176fba,
0x0a637dc5,
0xa2c898a6,
0x113f9804,
0xbef90dae,
0x1b710b35,
0x131c471b,
32910 0x28db77f5,
0x23047d84,
0x32caab7b,
0x40c72493,
0x3c9ebe0a,
0x15c9bebc,
0x431d67c4,
0x9c100d4c,
32911 0x4cc5d4be,
0xcb3e42b6,
0x597f299c,
0xfc657e2a,
0x5fcb6fab,
0x3ad6faec,
0x6c44198c,
0x4a475817],
32915 * Function to precompute _init and _key.
32918 _precompute: function () {
32919 // XXX: This code is for precomputing the SHA256 constants, change for
32920 // SHA512 and re-enable.
32921 var i =
0, prime =
2, factor;
32923 function frac(x) { return (x-Math.floor(x)) *
0x100000000 |
0; }
32924 function frac2(x) { return (x-Math.floor(x)) *
0x10000000000 &
0xff; }
32926 outer: for (; i
<80; prime++) {
32927 for (factor=
2; factor*factor <= prime; factor++) {
32928 if (prime % factor ===
0) {
32935 this._init[i*
2] = frac(Math.pow(prime,
1/
2));
32936 this._init[i*
2+
1] = (frac2(Math.pow(prime,
1/
2)) <<
24) | this._initr[i];
32938 this._key[i*
2] = frac(Math.pow(prime,
1/
3));
32939 this._key[i*
2+
1] = (frac2(Math.pow(prime,
1/
3)) <<
24) | this._keyr[i];
32945 * Perform one cycle of SHA-
512.
32946 * @param {bitArray} words one block of words.
32949 _block:function (words) {
32951 w = words.slice(
0),
32954 h0h = h[
0], h0l = h[
1], h1h = h[
2], h1l = h[
3],
32955 h2h = h[
4], h2l = h[
5], h3h = h[
6], h3l = h[
7],
32956 h4h = h[
8], h4l = h[
9], h5h = h[
10], h5l = h[
11],
32957 h6h = h[
12], h6l = h[
13], h7h = h[
14], h7l = h[
15];
32959 // Working variables
32960 var ah = h0h, al = h0l, bh = h1h, bl = h1l,
32961 ch = h2h, cl = h2l, dh = h3h, dl = h3l,
32962 eh = h4h, el = h4l, fh = h5h, fl = h5l,
32963 gh = h6h, gl = h6l, hh = h7h, hl = h7l;
32965 for (i=
0; i
<80; i++) {
32966 // load up the input word for this round
32969 wrl = w[i *
2 +
1];
32972 var gamma0xh = w[(i-
15) *
2];
32973 var gamma0xl = w[(i-
15) *
2 +
1];
32975 ((gamma0xl <<
31) | (gamma0xh
>>> 1)) ^
32976 ((gamma0xl <<
24) | (gamma0xh
>>> 8)) ^
32979 ((gamma0xh <<
31) | (gamma0xl
>>> 1)) ^
32980 ((gamma0xh <<
24) | (gamma0xl
>>> 8)) ^
32981 ((gamma0xh <<
25) | (gamma0xl
>>> 7));
32984 var gamma1xh = w[(i-
2) *
2];
32985 var gamma1xl = w[(i-
2) *
2 +
1];
32987 ((gamma1xl <<
13) | (gamma1xh
>>> 19)) ^
32988 ((gamma1xh <<
3) | (gamma1xl
>>> 29)) ^
32991 ((gamma1xh <<
13) | (gamma1xl
>>> 19)) ^
32992 ((gamma1xl <<
3) | (gamma1xh
>>> 29)) ^
32993 ((gamma1xh <<
26) | (gamma1xl
>>> 6));
32996 var wr7h = w[(i-
7) *
2];
32997 var wr7l = w[(i-
7) *
2 +
1];
32999 var wr16h = w[(i-
16) *
2];
33000 var wr16l = w[(i-
16) *
2 +
1];
33002 // W(round) = gamma0 + W(round -
7) + gamma1 + W(round -
16)
33003 wrl = gamma0l + wr7l;
33004 wrh = gamma0h + wr7h + ((wrl
>>> 0) < (gamma0l
>>> 0) ?
1 :
0);
33006 wrh += gamma1h + ((wrl
>>> 0) < (gamma1l
>>> 0) ?
1 :
0);
33008 wrh += wr16h + ((wrl
>>> 0) < (wr16l
>>> 0) ?
1 :
0);
33012 w[i*
2 +
1] = wrl |=
0;
33015 var chh = (eh & fh) ^ (~eh & gh);
33016 var chl = (el & fl) ^ (~el & gl);
33019 var majh = (ah & bh) ^ (ah & ch) ^ (bh & ch);
33020 var majl = (al & bl) ^ (al & cl) ^ (bl & cl);
33023 var sigma0h = ((al <<
4) | (ah
>>> 28)) ^ ((ah <<
30) | (al
>>> 2)) ^ ((ah <<
25) | (al
>>> 7));
33024 var sigma0l = ((ah <<
4) | (al
>>> 28)) ^ ((al <<
30) | (ah
>>> 2)) ^ ((al <<
25) | (ah
>>> 7));
33027 var sigma1h = ((el <<
18) | (eh
>>> 14)) ^ ((el <<
14) | (eh
>>> 18)) ^ ((eh <<
23) | (el
>>> 9));
33028 var sigma1l = ((eh <<
18) | (el
>>> 14)) ^ ((eh <<
14) | (el
>>> 18)) ^ ((el <<
23) | (eh
>>> 9));
33032 var krl = k[i*
2+
1];
33034 // t1 = h + sigma1 + ch + K(round) + W(round)
33035 var t1l = hl + sigma1l;
33036 var t1h = hh + sigma1h + ((t1l
>>> 0) < (hl
>>> 0) ?
1 :
0);
33038 t1h += chh + ((t1l
>>> 0) < (chl
>>> 0) ?
1 :
0);
33040 t1h += krh + ((t1l
>>> 0) < (krl
>>> 0) ?
1 :
0);
33041 t1l = t1l + wrl|
0; // FF32..FF34 perf issue https://bugzilla.mozilla.org/show_bug.cgi?id=
1054972
33042 t1h += wrh + ((t1l
>>> 0) < (wrl
>>> 0) ?
1 :
0);
33044 // t2 = sigma0 + maj
33045 var t2l = sigma0l + majl;
33046 var t2h = sigma0h + majh + ((t2l
>>> 0) < (sigma0l
>>> 0) ?
1 :
0);
33048 // Update working variables
33055 el = (dl + t1l) |
0;
33056 eh = (dh + t1h + ((el
>>> 0) < (dl
>>> 0) ?
1 :
0)) |
0;
33063 al = (t1l + t2l) |
0;
33064 ah = (t1h + t2h + ((al
>>> 0) < (t1l
>>> 0) ?
1 :
0)) |
0;
33067 // Intermediate hash
33068 h0l = h[
1] = (h0l + al) |
0;
33069 h[
0] = (h0h + ah + ((h0l
>>> 0) < (al
>>> 0) ?
1 :
0)) |
0;
33070 h1l = h[
3] = (h1l + bl) |
0;
33071 h[
2] = (h1h + bh + ((h1l
>>> 0) < (bl
>>> 0) ?
1 :
0)) |
0;
33072 h2l = h[
5] = (h2l + cl) |
0;
33073 h[
4] = (h2h + ch + ((h2l
>>> 0) < (cl
>>> 0) ?
1 :
0)) |
0;
33074 h3l = h[
7] = (h3l + dl) |
0;
33075 h[
6] = (h3h + dh + ((h3l
>>> 0) < (dl
>>> 0) ?
1 :
0)) |
0;
33076 h4l = h[
9] = (h4l + el) |
0;
33077 h[
8] = (h4h + eh + ((h4l
>>> 0) < (el
>>> 0) ?
1 :
0)) |
0;
33078 h5l = h[
11] = (h5l + fl) |
0;
33079 h[
10] = (h5h + fh + ((h5l
>>> 0) < (fl
>>> 0) ?
1 :
0)) |
0;
33080 h6l = h[
13] = (h6l + gl) |
0;
33081 h[
12] = (h6h + gh + ((h6l
>>> 0) < (gl
>>> 0) ?
1 :
0)) |
0;
33082 h7l = h[
15] = (h7l + hl) |
0;
33083 h[
14] = (h7h + hh + ((h7l
>>> 0) < (hl
>>> 0) ?
1 :
0)) |
0;
33090 /** @fileOverview HMAC implementation.
33092 * @author Emily Stark
33093 * @author Mike Hamburg
33094 * @author Dan Boneh
33097 /** HMAC with the specified hash function.
33099 * @param {bitArray} key the key for HMAC.
33100 * @param {Object} [hash=sjcl.hash.sha256] The hash function to use.
33102 sjcl.misc.hmac = function (key, Hash) {
33103 this._hash = Hash = Hash || sjcl.hash.sha256;
33104 var exKey = [[],[]], i,
33105 bs = Hash.prototype.blockSize /
32;
33106 this._baseHash = [new Hash(), new Hash()];
33108 if (key.length
> bs) {
33109 key = Hash.hash(key);
33112 for (i=
0; i
<bs; i++) {
33113 exKey[
0][i] = key[i]^
0x36363636;
33114 exKey[
1][i] = key[i]^
0x5C5C5C5C;
33117 this._baseHash[
0].update(exKey[
0]);
33118 this._baseHash[
1].update(exKey[
1]);
33119 this._resultHash = new Hash(this._baseHash[
0]);
33122 /** HMAC with the specified hash function. Also called encrypt since it's a prf.
33123 * @param {bitArray|String} data The data to mac.
33125 sjcl.misc.hmac.prototype.encrypt = sjcl.misc.hmac.prototype.mac = function (data) {
33126 if (!this._updated) {
33128 return this.digest(data);
33130 throw new sjcl.exception.invalid(
"encrypt on already updated hmac called!");
33134 sjcl.misc.hmac.prototype.reset = function () {
33135 this._resultHash = new this._hash(this._baseHash[
0]);
33136 this._updated = false;
33139 sjcl.misc.hmac.prototype.update = function (data) {
33140 this._updated = true;
33141 this._resultHash.update(data);
33144 sjcl.misc.hmac.prototype.digest = function () {
33145 var w = this._resultHash.finalize(), result = new (this._hash)(this._baseHash[
1]).update(w).finalize();
33156 /** @fileOverview Password-based key-derivation function, version
2.0.
33158 * @author Emily Stark
33159 * @author Mike Hamburg
33160 * @author Dan Boneh
33163 /** Password-Based Key-Derivation Function, version
2.0.
33165 * Generate keys from passwords using PBKDF2-HMAC-SHA256.
33167 * This is the method specified by RSA's PKCS #
5 standard.
33169 * @param {bitArray|String} password The password.
33170 * @param {bitArray|String} salt The salt. Should have lots of entropy.
33171 * @param {Number} [count=
1000] The number of iterations. Higher numbers make the function slower but more secure.
33172 * @param {Number} [length] The length of the derived key. Defaults to the
33173 output size of the hash function.
33174 * @param {Object} [Prff=sjcl.misc.hmac] The pseudorandom function family.
33175 * @return {bitArray} the derived key.
33177 sjcl.misc.pbkdf2 = function (password, salt, count, length, Prff) {
33178 count = count ||
1000;
33180 if (length <
0 || count <
0) {
33181 throw sjcl.exception.invalid(
"invalid params to pbkdf2");
33184 if (typeof password ===
"string") {
33185 password = sjcl.codec.utf8String.toBits(password);
33188 if (typeof salt ===
"string") {
33189 salt = sjcl.codec.utf8String.toBits(salt);
33192 Prff = Prff || sjcl.misc.hmac;
33194 var prf = new Prff(password),
33195 u, ui, i, j, k, out = [], b = sjcl.bitArray;
33197 for (k =
1;
32 * out.length < (length ||
1); k++) {
33198 u = ui = prf.encrypt(b.concat(salt,[k]));
33200 for (i=
1; i
<count; i++) {
33201 ui = prf.encrypt(ui);
33202 for (j=
0; j
<ui.length; j++) {
33207 out = out.concat(u);
33210 if (length) { out = b.clamp(out, length); }
33218 /** @fileOverview Javascript SHA-
256 implementation.
33220 * An older version of this implementation is available in the public
33221 * domain, but this one is (c) Emily Stark, Mike Hamburg, Dan Boneh,
33222 * Stanford University
2008-
2010 and BSD-licensed for liability
33225 * Special thanks to Aldo Cortesi for pointing out several bugs in
33228 * @author Emily Stark
33229 * @author Mike Hamburg
33230 * @author Dan Boneh
33234 * Context for a SHA-
256 operation in progress.
33236 * @class Secure Hash Algorithm,
256 bits.
33238 sjcl.hash.sha256 = function (hash) {
33239 if (!this._key[
0]) { this._precompute(); }
33241 this._h = hash._h.slice(
0);
33242 this._buffer = hash._buffer.slice(
0);
33243 this._length = hash._length;
33250 * Hash a string or an array of words.
33252 * @param {bitArray|String} data the data to hash.
33253 * @return {bitArray} The hash value, an array of
16 big-endian words.
33255 sjcl.hash.sha256.hash = function (data) {
33256 return (new sjcl.hash.sha256()).update(data).finalize();
33259 sjcl.hash.sha256.prototype = {
33261 * The hash's block size, in bits.
33267 * Reset the hash state.
33270 reset:function () {
33271 this._h = this._init.slice(
0);
33278 * Input several words to the hash.
33279 * @param {bitArray|String} data the data to hash.
33282 update: function (data) {
33283 if (typeof data ===
"string") {
33284 data = sjcl.codec.utf8String.toBits(data);
33286 var i, b = this._buffer = sjcl.bitArray.concat(this._buffer, data),
33288 nl = this._length = ol + sjcl.bitArray.bitLength(data);
33289 for (i =
512+ol & -
512; i <= nl; i+=
512) {
33290 this._block(b.splice(
0,
16));
33296 * Complete hashing and output the hash value.
33297 * @return {bitArray} The hash value, an array of
8 big-endian words.
33299 finalize:function () {
33300 var i, b = this._buffer, h = this._h;
33302 // Round out and push the buffer
33303 b = sjcl.bitArray.concat(b, [sjcl.bitArray.partial(
1,
1)]);
33305 // Round out the buffer to a multiple of
16 words, less the
2 length words.
33306 for (i = b.length +
2; i &
15; i++) {
33310 // append the length
33311 b.push(Math.floor(this._length /
0x100000000));
33312 b.push(this._length |
0);
33315 this._block(b.splice(
0,
16));
33323 * The SHA-
256 initialization vector, to be precomputed.
33328 _init:[
0x6a09e667,
0xbb67ae85,
0x3c6ef372,
0xa54ff53a,
0x510e527f,
0x9b05688c,
0x1f83d9ab,
0x5be0cd19],
33332 * The SHA-
256 hash key, to be precomputed.
33338 [
0x428a2f98,
0x71374491,
0xb5c0fbcf,
0xe9b5dba5,
0x3956c25b,
0x59f111f1,
0x923f82a4,
0xab1c5ed5,
33339 0xd807aa98,
0x12835b01,
0x243185be,
0x550c7dc3,
0x72be5d74,
0x80deb1fe,
0x9bdc06a7,
0xc19bf174,
33340 0xe49b69c1,
0xefbe4786,
0x0fc19dc6,
0x240ca1cc,
0x2de92c6f,
0x4a7484aa,
0x5cb0a9dc,
0x76f988da,
33341 0x983e5152,
0xa831c66d,
0xb00327c8,
0xbf597fc7,
0xc6e00bf3,
0xd5a79147,
0x06ca6351,
0x14292967,
33342 0x27b70a85,
0x2e1b2138,
0x4d2c6dfc,
0x53380d13,
0x650a7354,
0x766a0abb,
0x81c2c92e,
0x92722c85,
33343 0xa2bfe8a1,
0xa81a664b,
0xc24b8b70,
0xc76c51a3,
0xd192e819,
0xd6990624,
0xf40e3585,
0x106aa070,
33344 0x19a4c116,
0x1e376c08,
0x2748774c,
0x34b0bcb5,
0x391c0cb3,
0x4ed8aa4a,
0x5b9cca4f,
0x682e6ff3,
33345 0x748f82ee,
0x78a5636f,
0x84c87814,
0x8cc70208,
0x90befffa,
0xa4506ceb,
0xbef9a3f7,
0xc67178f2],
33350 * Function to precompute _init and _key.
33353 _precompute: function () {
33354 var i =
0, prime =
2, factor;
33356 function frac(x) { return (x-Math.floor(x)) *
0x100000000 |
0; }
33358 outer: for (; i
<64; prime++) {
33359 for (factor=
2; factor*factor <= prime; factor++) {
33360 if (prime % factor ===
0) {
33367 this._init[i] = frac(Math.pow(prime,
1/
2));
33369 this._key[i] = frac(Math.pow(prime,
1/
3));
33375 * Perform one cycle of SHA-
256.
33376 * @param {bitArray} words one block of words.
33379 _block:function (words) {
33381 w = words.slice(
0),
33384 h0 = h[
0], h1 = h[
1], h2 = h[
2], h3 = h[
3],
33385 h4 = h[
4], h5 = h[
5], h6 = h[
6], h7 = h[
7];
33387 /* Rationale for placement of |
0 :
33388 * If a value can overflow is original
32 bits by a factor of more than a few
33389 * million (
2^
23 ish), there is a possibility that it might overflow the
33390 *
53-bit mantissa and lose precision.
33392 * To avoid this, we clamp back to
32 bits by |'ing with
0 on any value that
33393 * propagates around the loop, and on the hash state h[]. I don't believe
33394 * that the clamps on h4 and on h0 are strictly necessary, but it's close
33395 * (for h4 anyway), and better safe than sorry.
33397 * The clamps on h[] are necessary for the output to be correct even in the
33398 * common case and for short inputs.
33400 for (i=
0; i
<64; i++) {
33401 // load up the input word for this round
33405 a = w[(i+
1 ) &
15];
33406 b = w[(i+
14) &
15];
33407 tmp = w[i&
15] = ((a
>>>7 ^ a
>>>18 ^ a
>>>3 ^ a<
<25 ^ a<
<14) +
33408 (b
>>>17 ^ b
>>>19 ^ b
>>>10 ^ b<
<15 ^ b<
<13) +
33409 w[i&
15] + w[(i+
9) &
15]) |
0;
33412 tmp = (tmp + h7 + (h4
>>>6 ^ h4
>>>11 ^ h4
>>>25 ^ h4<
<26 ^ h4<
<21 ^ h4<
<7) + (h6 ^ h4&(h5^h6)) + k[i]); // |
0;
33415 h7 = h6; h6 = h5; h5 = h4;
33417 h3 = h2; h2 = h1; h1 = h0;
33419 h0 = (tmp + ((h1&h2) ^ (h3&(h1^h2))) + (h1
>>>2 ^ h1
>>>13 ^ h1
>>>22 ^ h1<
<30 ^ h1<
<19 ^ h1<
<10)) |
0;
33422 h[
0] = h[
0]+h0 |
0;
33423 h[
1] = h[
1]+h1 |
0;
33424 h[
2] = h[
2]+h2 |
0;
33425 h[
3] = h[
3]+h3 |
0;
33426 h[
4] = h[
4]+h4 |
0;
33427 h[
5] = h[
5]+h5 |
0;
33428 h[
6] = h[
6]+h6 |
0;
33429 h[
7] = h[
7]+h7 |
0;
33434 WORDLISTS = typeof WORDLISTS == "undefined" ? {} : WORDLISTS;
33435 WORDLISTS["english"] = [
33436 "abandon","ability","able","about","above","absent","absorb","abstract","absurd","abuse",
33437 "access","accident","account","accuse","achieve","acid","acoustic","acquire","across","act",
33438 "action","actor","actress","actual","adapt","add","addict","address","adjust","admit",
33439 "adult","advance","advice","aerobic","affair","afford","afraid","again","age","agent",
33440 "agree","ahead","aim","air","airport","aisle","alarm","album","alcohol","alert",
33441 "alien","all","alley","allow","almost","alone","alpha","already","also","alter",
33442 "always","amateur","amazing","among","amount","amused","analyst","anchor","ancient","anger",
33443 "angle","angry","animal","ankle","announce","annual","another","answer","antenna","antique",
33444 "anxiety","any","apart","apology","appear","apple","approve","april","arch","arctic",
33445 "area","arena","argue","arm","armed","armor","army","around","arrange","arrest",
33446 "arrive","arrow","art","artefact","artist","artwork","ask","aspect","assault","asset",
33447 "assist","assume","asthma","athlete","atom","attack","attend","attitude","attract","auction",
33448 "audit","august","aunt","author","auto","autumn","average","avocado","avoid","awake",
33449 "aware","away","awesome","awful","awkward","axis","baby","bachelor","bacon","badge",
33450 "bag","balance","balcony","ball","bamboo","banana","banner","bar","barely","bargain",
33451 "barrel","base","basic","basket","battle","beach","bean","beauty","because","become",
33452 "beef","before","begin","behave","behind","believe","below","belt","bench","benefit",
33453 "best","betray","better","between","beyond","bicycle","bid","bike","bind","biology",
33454 "bird","birth","bitter","black","blade","blame","blanket","blast","bleak","bless",
33455 "blind","blood","blossom","blouse","blue","blur","blush","board","boat","body",
33456 "boil","bomb","bone","bonus","book","boost","border","boring","borrow","boss",
33457 "bottom","bounce","box","boy","bracket","brain","brand","brass","brave","bread",
33458 "breeze","brick","bridge","brief","bright","bring","brisk","broccoli","broken","bronze",
33459 "broom","brother","brown","brush","bubble","buddy","budget","buffalo","build","bulb",
33460 "bulk","bullet","bundle","bunker","burden","burger","burst","bus","business","busy",
33461 "butter","buyer","buzz","cabbage","cabin","cable","cactus","cage","cake","call",
33462 "calm","camera","camp","can","canal","cancel","candy","cannon","canoe","canvas",
33463 "canyon","capable","capital","captain","car","carbon","card","cargo","carpet","carry",
33464 "cart","case","cash","casino","castle","casual","cat","catalog","catch","category",
33465 "cattle","caught","cause","caution","cave","ceiling","celery","cement","census","century",
33466 "cereal","certain","chair","chalk","champion","change","chaos","chapter","charge","chase",
33467 "chat","cheap","check","cheese","chef","cherry","chest","chicken","chief","child",
33468 "chimney","choice","choose","chronic","chuckle","chunk","churn","cigar","cinnamon","circle",
33469 "citizen","city","civil","claim","clap","clarify","claw","clay","clean","clerk",
33470 "clever","click","client","cliff","climb","clinic","clip","clock","clog","close",
33471 "cloth","cloud","clown","club","clump","cluster","clutch","coach","coast","coconut",
33472 "code","coffee","coil","coin","collect","color","column","combine","come","comfort",
33473 "comic","common","company","concert","conduct","confirm","congress","connect","consider","control",
33474 "convince","cook","cool","copper","copy","coral","core","corn","correct","cost",
33475 "cotton","couch","country","couple","course","cousin","cover","coyote","crack","cradle",
33476 "craft","cram","crane","crash","crater","crawl","crazy","cream","credit","creek",
33477 "crew","cricket","crime","crisp","critic","crop","cross","crouch","crowd","crucial",
33478 "cruel","cruise","crumble","crunch","crush","cry","crystal","cube","culture","cup",
33479 "cupboard","curious","current","curtain","curve","cushion","custom","cute","cycle","dad",
33480 "damage","damp","dance","danger","daring","dash","daughter","dawn","day","deal",
33481 "debate","debris","decade","december","decide","decline","decorate","decrease","deer","defense",
33482 "define","defy","degree","delay","deliver","demand","demise","denial","dentist","deny",
33483 "depart","depend","deposit","depth","deputy","derive","describe","desert","design","desk",
33484 "despair","destroy","detail","detect","develop","device","devote","diagram","dial","diamond",
33485 "diary","dice","diesel","diet","differ","digital","dignity","dilemma","dinner","dinosaur",
33486 "direct","dirt","disagree","discover","disease","dish","dismiss","disorder","display","distance",
33487 "divert","divide","divorce","dizzy","doctor","document","dog","doll","dolphin","domain",
33488 "donate","donkey","donor","door","dose","double","dove","draft","dragon","drama",
33489 "drastic","draw","dream","dress","drift","drill","drink","drip","drive","drop",
33490 "drum","dry","duck","dumb","dune","during","dust","dutch","duty","dwarf",
33491 "dynamic","eager","eagle","early","earn","earth","easily","east","easy","echo",
33492 "ecology","economy","edge","edit","educate","effort","egg","eight","either","elbow",
33493 "elder","electric","elegant","element","elephant","elevator","elite","else","embark","embody",
33494 "embrace","emerge","emotion","employ","empower","empty","enable","enact","end","endless",
33495 "endorse","enemy","energy","enforce","engage","engine","enhance","enjoy","enlist","enough",
33496 "enrich","enroll","ensure","enter","entire","entry","envelope","episode","equal","equip",
33497 "era","erase","erode","erosion","error","erupt","escape","essay","essence","estate",
33498 "eternal","ethics","evidence","evil","evoke","evolve","exact","example","excess","exchange",
33499 "excite","exclude","excuse","execute","exercise","exhaust","exhibit","exile","exist","exit",
33500 "exotic","expand","expect","expire","explain","expose","express","extend","extra","eye",
33501 "eyebrow","fabric","face","faculty","fade","faint","faith","fall","false","fame",
33502 "family","famous","fan","fancy","fantasy","farm","fashion","fat","fatal","father",
33503 "fatigue","fault","favorite","feature","february","federal","fee","feed","feel","female",
33504 "fence","festival","fetch","fever","few","fiber","fiction","field","figure","file",
33505 "film","filter","final","find","fine","finger","finish","fire","firm","first",
33506 "fiscal","fish","fit","fitness","fix","flag","flame","flash","flat","flavor",
33507 "flee","flight","flip","float","flock","floor","flower","fluid","flush","fly",
33508 "foam","focus","fog","foil","fold","follow","food","foot","force","forest",
33509 "forget","fork","fortune","forum","forward","fossil","foster","found","fox","fragile",
33510 "frame","frequent","fresh","friend","fringe","frog","front","frost","frown","frozen",
33511 "fruit","fuel","fun","funny","furnace","fury","future","gadget","gain","galaxy",
33512 "gallery","game","gap","garage","garbage","garden","garlic","garment","gas","gasp",
33513 "gate","gather","gauge","gaze","general","genius","genre","gentle","genuine","gesture",
33514 "ghost","giant","gift","giggle","ginger","giraffe","girl","give","glad","glance",
33515 "glare","glass","glide","glimpse","globe","gloom","glory","glove","glow","glue",
33516 "goat","goddess","gold","good","goose","gorilla","gospel","gossip","govern","gown",
33517 "grab","grace","grain","grant","grape","grass","gravity","great","green","grid",
33518 "grief","grit","grocery","group","grow","grunt","guard","guess","guide","guilt",
33519 "guitar","gun","gym","habit","hair","half","hammer","hamster","hand","happy",
33520 "harbor","hard","harsh","harvest","hat","have","hawk","hazard","head","health",
33521 "heart","heavy","hedgehog","height","hello","helmet","help","hen","hero","hidden",
33522 "high","hill","hint","hip","hire","history","hobby","hockey","hold","hole",
33523 "holiday","hollow","home","honey","hood","hope","horn","horror","horse","hospital",
33524 "host","hotel","hour","hover","hub","huge","human","humble","humor","hundred",
33525 "hungry","hunt","hurdle","hurry","hurt","husband","hybrid","ice","icon","idea",
33526 "identify","idle","ignore","ill","illegal","illness","image","imitate","immense","immune",
33527 "impact","impose","improve","impulse","inch","include","income","increase","index","indicate",
33528 "indoor","industry","infant","inflict","inform","inhale","inherit","initial","inject","injury",
33529 "inmate","inner","innocent","input","inquiry","insane","insect","inside","inspire","install",
33530 "intact","interest","into","invest","invite","involve","iron","island","isolate","issue",
33531 "item","ivory","jacket","jaguar","jar","jazz","jealous","jeans","jelly","jewel",
33532 "job","join","joke","journey","joy","judge","juice","jump","jungle","junior",
33533 "junk","just","kangaroo","keen","keep","ketchup","key","kick","kid","kidney",
33534 "kind","kingdom","kiss","kit","kitchen","kite","kitten","kiwi","knee","knife",
33535 "knock","know","lab","label","labor","ladder","lady","lake","lamp","language",
33536 "laptop","large","later","latin","laugh","laundry","lava","law","lawn","lawsuit",
33537 "layer","lazy","leader","leaf","learn","leave","lecture","left","leg","legal",
33538 "legend","leisure","lemon","lend","length","lens","leopard","lesson","letter","level",
33539 "liar","liberty","library","license","life","lift","light","like","limb","limit",
33540 "link","lion","liquid","list","little","live","lizard","load","loan","lobster",
33541 "local","lock","logic","lonely","long","loop","lottery","loud","lounge","love",
33542 "loyal","lucky","luggage","lumber","lunar","lunch","luxury","lyrics","machine","mad",
33543 "magic","magnet","maid","mail","main","major","make","mammal","man","manage",
33544 "mandate","mango","mansion","manual","maple","marble","march","margin","marine","market",
33545 "marriage","mask","mass","master","match","material","math","matrix","matter","maximum",
33546 "maze","meadow","mean","measure","meat","mechanic","medal","media","melody","melt",
33547 "member","memory","mention","menu","mercy","merge","merit","merry","mesh","message",
33548 "metal","method","middle","midnight","milk","million","mimic","mind","minimum","minor",
33549 "minute","miracle","mirror","misery","miss","mistake","mix","mixed","mixture","mobile",
33550 "model","modify","mom","moment","monitor","monkey","monster","month","moon","moral",
33551 "more","morning","mosquito","mother","motion","motor","mountain","mouse","move","movie",
33552 "much","muffin","mule","multiply","muscle","museum","mushroom","music","must","mutual",
33553 "myself","mystery","myth","naive","name","napkin","narrow","nasty","nation","nature",
33554 "near","neck","need","negative","neglect","neither","nephew","nerve","nest","net",
33555 "network","neutral","never","news","next","nice","night","noble","noise","nominee",
33556 "noodle","normal","north","nose","notable","note","nothing","notice","novel","now",
33557 "nuclear","number","nurse","nut","oak","obey","object","oblige","obscure","observe",
33558 "obtain","obvious","occur","ocean","october","odor","off","offer","office","often",
33559 "oil","okay","old","olive","olympic","omit","once","one","onion","online",
33560 "only","open","opera","opinion","oppose","option","orange","orbit","orchard","order",
33561 "ordinary","organ","orient","original","orphan","ostrich","other","outdoor","outer","output",
33562 "outside","oval","oven","over","own","owner","oxygen","oyster","ozone","pact",
33563 "paddle","page","pair","palace","palm","panda","panel","panic","panther","paper",
33564 "parade","parent","park","parrot","party","pass","patch","path","patient","patrol",
33565 "pattern","pause","pave","payment","peace","peanut","pear","peasant","pelican","pen",
33566 "penalty","pencil","people","pepper","perfect","permit","person","pet","phone","photo",
33567 "phrase","physical","piano","picnic","picture","piece","pig","pigeon","pill","pilot",
33568 "pink","pioneer","pipe","pistol","pitch","pizza","place","planet","plastic","plate",
33569 "play","please","pledge","pluck","plug","plunge","poem","poet","point","polar",
33570 "pole","police","pond","pony","pool","popular","portion","position","possible","post",
33571 "potato","pottery","poverty","powder","power","practice","praise","predict","prefer","prepare",
33572 "present","pretty","prevent","price","pride","primary","print","priority","prison","private",
33573 "prize","problem","process","produce","profit","program","project","promote","proof","property",
33574 "prosper","protect","proud","provide","public","pudding","pull","pulp","pulse","pumpkin",
33575 "punch","pupil","puppy","purchase","purity","purpose","purse","push","put","puzzle",
33576 "pyramid","quality","quantum","quarter","question","quick","quit","quiz","quote","rabbit",
33577 "raccoon","race","rack","radar","radio","rail","rain","raise","rally","ramp",
33578 "ranch","random","range","rapid","rare","rate","rather","raven","raw","razor",
33579 "ready","real","reason","rebel","rebuild","recall","receive","recipe","record","recycle",
33580 "reduce","reflect","reform","refuse","region","regret","regular","reject","relax","release",
33581 "relief","rely","remain","remember","remind","remove","render","renew","rent","reopen",
33582 "repair","repeat","replace","report","require","rescue","resemble","resist","resource","response",
33583 "result","retire","retreat","return","reunion","reveal","review","reward","rhythm","rib",
33584 "ribbon","rice","rich","ride","ridge","rifle","right","rigid","ring","riot",
33585 "ripple","risk","ritual","rival","river","road","roast","robot","robust","rocket",
33586 "romance","roof","rookie","room","rose","rotate","rough","round","route","royal",
33587 "rubber","rude","rug","rule","run","runway","rural","sad","saddle","sadness",
33588 "safe","sail","salad","salmon","salon","salt","salute","same","sample","sand",
33589 "satisfy","satoshi","sauce","sausage","save","say","scale","scan","scare","scatter",
33590 "scene","scheme","school","science","scissors","scorpion","scout","scrap","screen","script",
33591 "scrub","sea","search","season","seat","second","secret","section","security","seed",
33592 "seek","segment","select","sell","seminar","senior","sense","sentence","series","service",
33593 "session","settle","setup","seven","shadow","shaft","shallow","share","shed","shell",
33594 "sheriff","shield","shift","shine","ship","shiver","shock","shoe","shoot","shop",
33595 "short","shoulder","shove","shrimp","shrug","shuffle","shy","sibling","sick","side",
33596 "siege","sight","sign","silent","silk","silly","silver","similar","simple","since",
33597 "sing","siren","sister","situate","six","size","skate","sketch","ski","skill",
33598 "skin","skirt","skull","slab","slam","sleep","slender","slice","slide","slight",
33599 "slim","slogan","slot","slow","slush","small","smart","smile","smoke","smooth",
33600 "snack","snake","snap","sniff","snow","soap","soccer","social","sock","soda",
33601 "soft","solar","soldier","solid","solution","solve","someone","song","soon","sorry",
33602 "sort","soul","sound","soup","source","south","space","spare","spatial","spawn",
33603 "speak","special","speed","spell","spend","sphere","spice","spider","spike","spin",
33604 "spirit","split","spoil","sponsor","spoon","sport","spot","spray","spread","spring",
33605 "spy","square","squeeze","squirrel","stable","stadium","staff","stage","stairs","stamp",
33606 "stand","start","state","stay","steak","steel","stem","step","stereo","stick",
33607 "still","sting","stock","stomach","stone","stool","story","stove","strategy","street",
33608 "strike","strong","struggle","student","stuff","stumble","style","subject","submit","subway",
33609 "success","such","sudden","suffer","sugar","suggest","suit","summer","sun","sunny",
33610 "sunset","super","supply","supreme","sure","surface","surge","surprise","surround","survey",
33611 "suspect","sustain","swallow","swamp","swap","swarm","swear","sweet","swift","swim",
33612 "swing","switch","sword","symbol","symptom","syrup","system","table","tackle","tag",
33613 "tail","talent","talk","tank","tape","target","task","taste","tattoo","taxi",
33614 "teach","team","tell","ten","tenant","tennis","tent","term","test","text",
33615 "thank","that","theme","then","theory","there","they","thing","this","thought",
33616 "three","thrive","throw","thumb","thunder","ticket","tide","tiger","tilt","timber",
33617 "time","tiny","tip","tired","tissue","title","toast","tobacco","today","toddler",
33618 "toe","together","toilet","token","tomato","tomorrow","tone","tongue","tonight","tool",
33619 "tooth","top","topic","topple","torch","tornado","tortoise","toss","total","tourist",
33620 "toward","tower","town","toy","track","trade","traffic","tragic","train","transfer",
33621 "trap","trash","travel","tray","treat","tree","trend","trial","tribe","trick",
33622 "trigger","trim","trip","trophy","trouble","truck","true","truly","trumpet","trust",
33623 "truth","try","tube","tuition","tumble","tuna","tunnel","turkey","turn","turtle",
33624 "twelve","twenty","twice","twin","twist","two","type","typical","ugly","umbrella",
33625 "unable","unaware","uncle","uncover","under","undo","unfair","unfold","unhappy","uniform",
33626 "unique","unit","universe","unknown","unlock","until","unusual","unveil","update","upgrade",
33627 "uphold","upon","upper","upset","urban","urge","usage","use","used","useful",
33628 "useless","usual","utility","vacant","vacuum","vague","valid","valley","valve","van",
33629 "vanish","vapor","various","vast","vault","vehicle","velvet","vendor","venture","venue",
33630 "verb","verify","version","very","vessel","veteran","viable","vibrant","vicious","victory",
33631 "video","view","village","vintage","violin","virtual","virus","visa","visit","visual",
33632 "vital","vivid","vocal","voice","void","volcano","volume","vote","voyage","wage",
33633 "wagon","wait","walk","wall","walnut","want","warfare","warm","warrior","wash",
33634 "wasp","waste","water","wave","way","wealth","weapon","wear","weasel","weather",
33635 "web","wedding","weekend","weird","welcome","west","wet","whale","what","wheat",
33636 "wheel","when","where","whip","whisper","wide","width","wife","wild","will",
33637 "win","window","wine","wing","wink","winner","winter","wire","wisdom","wise",
33638 "wish","witness","wolf","woman","wonder","wood","wool","word","work","world",
33639 "worry","worth","wrap","wreck","wrestle","wrist","write","wrong","yard","year",
33640 "yellow","you","young","youth","zebra","zero","zone","zoo"]
33644 * Copyright (c)
2013 Pavol Rusnak
33646 * Permission is hereby granted, free of charge, to any person obtaining a copy of
33647 * this software and associated documentation files (the "Software"), to deal in
33648 * the Software without restriction, including without limitation the rights to
33649 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
33650 * of the Software, and to permit persons to whom the Software is furnished to do
33651 * so, subject to the following conditions:
33653 * The above copyright notice and this permission notice shall be included in all
33654 * copies or substantial portions of the Software.
33656 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
33657 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33658 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
33659 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
33660 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
33661 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33665 * Javascript port from python by Ian Coleman
33667 * Requires code from sjcl
33668 * https://github.com/bitwiseshiftleft/sjcl
33671 var Mnemonic = function(language) {
33673 var PBKDF2_ROUNDS =
2048;
33679 var hmacSHA512 = function(key) {
33680 var hasher = new sjcl.misc.hmac(key, sjcl.hash.sha512);
33681 this.encrypt = function() {
33682 return hasher.encrypt.apply(hasher, arguments);
33687 wordlist = WORDLISTS[language];
33688 if (wordlist.length != RADIX) {
33689 err = 'Wordlist should contain ' + RADIX + ' words, but it contains ' + wordlist.length + ' words.';
33694 self.generate = function(strength) {
33695 strength = strength ||
128;
33696 var r = strength %
32;
33698 throw 'Strength should be divisible by
32, but it is not (' + r + ').';
33700 var hasStrongCrypto = 'crypto' in window && window['crypto'] !== null;
33701 if (!hasStrongCrypto) {
33702 throw 'Mnemonic should be generated with strong randomness, but crypto.getRandomValues is unavailable';
33704 var buffer = new Uint8Array(strength /
8);
33705 var data = crypto.getRandomValues(buffer);
33706 return self.toMnemonic(data);
33709 self.toMnemonic = function(byteArray) {
33710 if (byteArray.length %
4 > 0) {
33711 throw 'Data length in bits should be divisible by
32, but it is not (' + byteArray.length + ' bytes = ' + byteArray.length*
8 + ' bits).'
33714 //h = hashlib.sha256(data).hexdigest()
33715 var data = byteArrayToWordArray(byteArray);
33716 var hash = sjcl.hash.sha256.hash(data);
33717 var h = sjcl.codec.hex.fromBits(hash);
33719 // b is a binary string, eg '
00111010101100...'
33720 //b = bin(int(binascii.hexlify(data),
16))[
2:].zfill(len(data) *
8) + \
33721 // bin(int(h,
16))[
2:].zfill(
256)[:len(data) *
8 /
32]
33723 // a = bin(int(binascii.hexlify(data),
16))[
2:].zfill(len(data) *
8)
33724 // c = bin(int(h,
16))[
2:].zfill(
256)
33725 // d = c[:len(data) *
8 /
32]
33726 var a = byteArrayToBinaryString(byteArray);
33727 var c = zfill(hexStringToBinaryString(h),
256);
33728 var d = c.substring(
0, byteArray.length *
8 /
32);
33729 // b = line1 + line2
33733 var blen = b.length /
11;
33734 for (var i=
0; i
<blen; i++) {
33735 var idx = parseInt(b.substring(i *
11, (i +
1) *
11),
2);
33736 result.push(wordlist[idx]);
33738 return result.join(' ');
33741 self.check = function(mnemonic) {
33742 var mnemonic = mnemonic.split(' ')
33743 if (mnemonic.length %
3 > 0) {
33746 // idx = map(lambda x: bin(self.wordlist.index(x))[
2:].zfill(
11), mnemonic)
33748 for (var i=
0; i
<mnemonic.length; i++) {
33749 var word = mnemonic[i];
33750 var wordIndex = wordlist.indexOf(word);
33751 if (wordIndex == -
1) {
33754 var binaryIndex = zfill(wordIndex.toString(
2),
11);
33755 idx.push(binaryIndex);
33757 var b = idx.join('');
33759 //d = b[:l /
33 *
32]
33761 var d = b.substring(
0, l /
33 *
32);
33762 var h = b.substring(l - l /
33, l);
33763 //nd = binascii.unhexlify(hex(int(d,
2))[
2:].rstrip('L').zfill(l /
33 *
8))
33764 var nd = binaryStringToWordArray(d);
33765 //nh = bin(int(hashlib.sha256(nd).hexdigest(),
16))[
2:].zfill(
256)[:l /
33]
33766 var ndHash = sjcl.hash.sha256.hash(nd);
33767 var ndHex = sjcl.codec.hex.fromBits(ndHash);
33768 var ndBstr = zfill(hexStringToBinaryString(ndHex),
256);
33769 var nh = ndBstr.substring(
0,l/
33);
33773 self.toSeed = function(mnemonic, passphrase) {
33774 passphrase = passphrase || '';
33775 mnemonic = self.normalizeString(mnemonic)
33776 passphrase = self.normalizeString(passphrase)
33777 passphrase =
"mnemonic" + passphrase;
33778 var mnemonicBits = sjcl.codec.utf8String.toBits(mnemonic);
33779 var passphraseBits = sjcl.codec.utf8String.toBits(passphrase);
33780 var result = sjcl.misc.pbkdf2(mnemonicBits, passphraseBits, PBKDF2_ROUNDS,
512, hmacSHA512);
33781 var hashHex = sjcl.codec.hex.fromBits(result);
33785 self.normalizeString = function(str) {
33786 if (typeof str.normalize ==
"function") {
33787 return str.normalize(
"NFKD");
33790 // TODO decide how to handle this in the future.
33791 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize
33796 function byteArrayToWordArray(data) {
33798 for (var i=
0; i
<data.length/
4; i++) {
33800 v += data[i*
4 +
0] <<
8 *
3;
33801 v += data[i*
4 +
1] <<
8 *
2;
33802 v += data[i*
4 +
2] <<
8 *
1;
33803 v += data[i*
4 +
3] <<
8 *
0;
33809 function byteArrayToBinaryString(data) {
33811 for (var i=
0; i
<data.length; i++) {
33812 bin += zfill(data[i].toString(
2),
8);
33817 function hexStringToBinaryString(hexString) {
33819 for (var i=
0; i
<hexString.length; i++) {
33820 binaryString += zfill(parseInt(hexString[i],
16).toString(
2),
4);
33822 return binaryString;
33825 function binaryStringToWordArray(binary) {
33826 var aLen = binary.length /
32;
33828 for (var i=
0; i
<aLen; i++) {
33829 var valueStr = binary.substring(
0,
32);
33830 var value = parseInt(valueStr,
2);
33832 binary = binary.slice(
32);
33837 // Pad a numeric string on the left with zero digits until the given width
33839 // Note this differs to the python implementation because it does not
33840 // handle numbers starting with a sign.
33841 function zfill(source, length) {
33842 source = source.toString();
33843 while (source.length < length) {
33844 source = '
0' + source;
33856 var mnemonic = new Mnemonic("english");
33857 var bip32RootKey = null;
33858 var bip32ExtendedKey = null;
33859 var network = Bitcoin.networks.bitcoin;
33860 var addressRowTemplate = $("#address-row-template");
33862 var showIndex = true;
33863 var showAddress = true;
33864 var showPrivKey = true;
33866 var phraseChangeTimeoutEvent = null;
33869 DOM.network = $(".network");
33870 DOM.phraseNetwork = $("#network-phrase");
33871 DOM.phrase = $(".phrase");
33872 DOM.passphrase = $(".passphrase");
33873 DOM.generate = $(".generate");
33874 DOM.rootKey = $(".root-key");
33875 DOM.extendedPrivKey = $(".extended-priv-key");
33876 DOM.extendedPubKey = $(".extended-pub-key");
33877 DOM.bip32tab = $("#bip32-tab");
33878 DOM.bip44tab = $("#bip44-tab");
33879 DOM.bip32panel = $("#bip32");
33880 DOM.bip44panel = $("#bip44");
33881 DOM.bip32path = $("#bip32-path");
33882 DOM.bip44path = $("#bip44-path");
33883 DOM.bip44purpose = $("#bip44 .purpose");
33884 DOM.bip44coin = $("#bip44 .coin");
33885 DOM.bip44account = $("#bip44 .account");
33886 DOM.bip44change = $("#bip44 .change");
33887 DOM.strength = $(".strength");
33888 DOM.addresses = $(".addresses");
33889 DOM.rowsToAdd = $(".rows-to-add");
33890 DOM.more = $(".more");
33891 DOM.feedback = $(".feedback");
33892 DOM.tab = $(".derivation-type a");
33893 DOM.indexToggle = $(".index-toggle");
33894 DOM.addressToggle = $(".address-toggle");
33895 DOM.privateKeyToggle = $(".private-key-toggle");
33896 DOM.myceliumPath = $("#mycelium-path");
33898 var derivationPath = $(".tab-pane.active .path").val();
33902 DOM.network.on("change", networkChanged);
33903 DOM.phrase.on("input", delayedPhraseChanged);
33904 DOM.passphrase.on("input", delayedPhraseChanged);
33905 DOM.generate.on("click", generateClicked);
33906 DOM.more.on("click", showMore);
33907 DOM.bip32path.on("input", bip32Changed);
33908 DOM.bip44purpose.on("input", bip44Changed);
33909 DOM.bip44coin.on("input", bip44Changed);
33910 DOM.bip44account.on("input", bip44Changed);
33911 DOM.bip44change.on("input", bip44Changed);
33912 DOM.tab.on("click", tabClicked);
33913 DOM.indexToggle.on("click", toggleIndexes);
33914 DOM.addressToggle.on("click", toggleAddresses);
33915 DOM.privateKeyToggle.on("click", togglePrivateKeys);
33918 hideValidationError();
33923 function networkChanged(e) {
33924 var n = e.target.value;
33925 if (n == "bitcoin") {
33926 network = Bitcoin.networks.bitcoin;
33927 DOM.bip44coin.val(
0);
33928 DOM.myceliumPath.val("m/
44'/
0'/
0'/
0");
33930 else if (n == "bitcoin-testnet") {
33931 network = Bitcoin.networks.testnet;
33932 DOM.bip44coin.val(
1);
33933 DOM.myceliumPath.val("m/
44'/
1'/
0'/
0");
33935 else if (n == "litecoin") {
33936 network = Bitcoin.networks.litecoin;
33937 DOM.bip44coin.val(
2);
33939 else if (n == "dogecoin") {
33940 network = Bitcoin.networks.dogecoin;
33941 DOM.bip44coin.val(
3);
33943 setBip44DerivationPath();
33944 delayedPhraseChanged();
33947 function delayedPhraseChanged() {
33948 hideValidationError();
33950 if (phraseChangeTimeoutEvent != null) {
33951 clearTimeout(phraseChangeTimeoutEvent);
33953 phraseChangeTimeoutEvent = setTimeout(phraseChanged,
400);
33956 function phraseChanged() {
33958 hideValidationError();
33959 // Get the mnemonic phrase
33960 var phrase = DOM.phrase.val();
33961 var passphrase = DOM.passphrase.val();
33962 var errorText = findPhraseErrors(phrase);
33964 showValidationError(errorText);
33967 // Get the derivation path
33968 var errorText = findDerivationPathErrors();
33970 showValidationError(errorText);
33973 // Calculate and display
33974 calcBip32Seed(phrase, passphrase, derivationPath);
33975 displayBip32Info();
33979 function generateClicked() {
33982 setTimeout(function() {
33983 var phrase = generateRandomPhrase();
33991 function tabClicked(e) {
33992 var activePath = $(e.target.getAttribute("href") + " .path");
33993 derivationPath = activePath.val();
33994 derivationChanged();
33997 function derivationChanged() {
33998 delayedPhraseChanged();
34001 function bip32Changed() {
34002 derivationPath = DOM.bip32path.val();
34003 derivationChanged();
34006 function bip44Changed() {
34007 setBip44DerivationPath();
34008 derivationPath = DOM.bip44path.val();
34009 derivationChanged();
34012 function toggleIndexes() {
34013 showIndex = !showIndex;
34014 $("td.index span").toggleClass("invisible");
34017 function toggleAddresses() {
34018 showAddress = !showAddress;
34019 $("td.address span").toggleClass("invisible");
34022 function togglePrivateKeys() {
34023 showPrivKey = !showPrivKey;
34024 $("td.privkey span").toggleClass("invisible");
34029 function generateRandomPhrase() {
34030 if (!hasStrongRandom()) {
34031 var errorText = "This browser does not support strong randomness";
34032 showValidationError(errorText);
34035 var numWords = parseInt(DOM.strength.val());
34036 // Check strength is an integer
34037 if (isNaN(numWords)) {
34038 DOM.strength.val("
12");
34041 // Check strength is a multiple of
32, if not round it down
34042 if (numWords %
3 !=
0) {
34043 numWords = Math.floor(numWords /
3) *
3;
34044 DOM.strength.val(numWords);
34046 // Check strength is at least
32
34047 if (numWords ==
0) {
34049 DOM.strength.val(numWords);
34051 var strength = numWords /
3 *
32;
34052 var words = mnemonic.generate(strength);
34053 DOM.phrase.val(words);
34057 function calcBip32Seed(phrase, passphrase, path) {
34058 var seed = mnemonic.toSeed(phrase, passphrase);
34059 bip32RootKey = Bitcoin.HDNode.fromSeedHex(seed, network);
34060 bip32ExtendedKey = bip32RootKey;
34061 // Derive the key from the path
34062 var pathBits = path.split("/");
34063 for (var i=
0; i
<pathBits.length; i++) {
34064 var bit = pathBits[i];
34065 var index = parseInt(bit);
34066 if (isNaN(index)) {
34069 var hardened = bit[bit.length-
1] ==
"'";
34071 bip32ExtendedKey = bip32ExtendedKey.deriveHardened(index);
34074 bip32ExtendedKey = bip32ExtendedKey.derive(index);
34079 function showValidationError(errorText) {
34085 function hideValidationError() {
34091 function findPhraseErrors(phrase) {
34092 // TODO make this right
34093 // Preprocess the words
34094 phrase = mnemonic.normalizeString(phrase);
34095 var parts = phrase.split(
" ");
34097 for (var i=
0; i
<parts.length; i++) {
34098 var part = parts[i];
34099 if (part.length
> 0) {
34100 // TODO check that lowercasing is always valid to do
34101 proper.push(part.toLowerCase());
34104 // TODO some levenstein on the words
34105 var properPhrase = proper.join(' ');
34106 // Check the words are valid
34107 var isValid = mnemonic.check(properPhrase);
34109 return
"Invalid mnemonic";
34114 function findDerivationPathErrors(path) {
34119 function displayBip32Info() {
34121 var rootKey = bip32RootKey.toBase58();
34122 DOM.rootKey.val(rootKey);
34123 var extendedPrivKey = bip32ExtendedKey.toBase58();
34124 DOM.extendedPrivKey.val(extendedPrivKey);
34125 var extendedPubKey = bip32ExtendedKey.toBase58(false);
34126 DOM.extendedPubKey.val(extendedPubKey);
34127 // Display the addresses and privkeys
34128 clearAddressesList();
34129 displayAddresses(
0,
20);
34132 function displayAddresses(start, total) {
34133 for (var i=
0; i
<total; i++) {
34134 var index = i + start;
34135 new TableRow(index);
34139 function TableRow(index) {
34145 function calculateValues() {
34146 setTimeout(function() {
34147 var key = bip32ExtendedKey.derive(index);
34148 var address = key.getAddress().toString();
34149 var privkey = key.privKey.toWIF(network);
34150 addAddressToList(index, address, privkey);
34158 function showMore() {
34159 var start = DOM.addresses.children().length;
34160 var rowsToAdd = parseInt(DOM.rowsToAdd.val());
34161 if (isNaN(rowsToAdd)) {
34163 DOM.rowsToAdd.val(
"20");
34165 if (rowsToAdd
> 200) {
34166 var msg =
"Generating " + rowsToAdd +
" rows could take a while. ";
34167 msg +=
"Do you want to continue?";
34168 if (!confirm(msg)) {
34172 displayAddresses(start, rowsToAdd);
34175 function clearDisplay() {
34176 clearAddressesList();
34178 hideValidationError();
34181 function clearAddressesList() {
34182 DOM.addresses.empty();
34185 function clearKey() {
34186 DOM.rootKey.val(
"");
34187 DOM.extendedPrivKey.val(
"");
34188 DOM.extendedPubKey.val(
"");
34191 function addAddressToList(index, address, privkey) {
34192 var row = $(addressRowTemplate.html());
34194 var indexCell = row.find(
".index span");
34195 var addressCell = row.find(
".address span");
34196 var privkeyCell = row.find(
".privkey span");
34198 indexCell.text(index);
34199 addressCell.text(address);
34200 privkeyCell.text(privkey);
34203 indexCell.addClass(
"invisible");
34205 if (!showAddress) {
34206 addressCell.addClass(
"invisible");
34208 if (!showPrivKey) {
34209 privkeCell.addClass(
"invisible");
34211 DOM.addresses.append(row);
34214 function hasStrongRandom() {
34215 return 'crypto' in window && window['crypto'] !== null;
34218 function disableForms() {
34219 $(
"form").on(
"submit", function(e) {
34220 e.preventDefault();
34224 function setBip44DerivationPath() {
34225 var purpose = parseIntNoNaN(DOM.bip44purpose.val(),
44);
34226 var coin = parseIntNoNaN(DOM.bip44coin.val(),
0);
34227 var account = parseIntNoNaN(DOM.bip44account.val(),
0);
34228 var change = parseIntNoNaN(DOM.bip44change.val(),
0);
34230 path += purpose +
"'/";
34231 path += coin +
"'/";
34232 path += account +
"'/";
34234 DOM.bip44path.val(path);
34237 function parseIntNoNaN(val, defaultVal) {
34238 var v = parseInt(val);
34245 function showPending() {
34247 .text(
"Calculating...")
34251 function hidePending() {