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=
"root-key" class=
"col-sm-2 control-label">BIP32 Root Key
</label>
6283 <div class=
"col-sm-10">
6284 <textarea id=
"root-key" class=
"root-key form-control" readonly=
"readonly"></textarea>
6294 <div class=
"col-md-12">
6295 <h2>Derivation Path
</h2>
6296 <ul class=
"derivation-type nav nav-tabs" role=
"tablist">
6298 <a href=
"#bip44" role=
"tab" data-toggle=
"tab">BIP44
</a></li>
6299 <li><a href=
"#bip32" role=
"tab" data-toggle=
"tab">BIP32
</a></li>
6301 <div class=
"derivation-type tab-content">
6302 <div id=
"bip44" class=
"tab-pane active">
6303 <form class=
"form-horizontal" role=
"form">
6305 <div class=
"col-sm-2"></div>
6306 <div class=
"col-sm-10">
6307 <p>For more info see the
<a href=
"https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki" target=
"_blank">BIP44 spec
</a></p>
6309 <div class=
"form-group">
6310 <label for=
"purpose" class=
"col-sm-2 control-label">
6311 <a href=
"https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#purpose" target=
"_blank">Purpose
</a>
6313 <div class=
"col-sm-10">
6314 <input id=
"purpose" type=
"text" class=
"purpose form-control" value=
"44">
6317 <div class=
"form-group">
6318 <label for=
"coin" class=
"col-sm-2 control-label">
6319 <a href=
"https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#registered-coin-types" target=
"_blank">Coin
</a>
6321 <div class=
"col-sm-10">
6322 <input id=
"coin" type=
"text" class=
"coin form-control" value=
"0">
6325 <div class=
"form-group">
6326 <label for=
"account" class=
"col-sm-2 control-label">
6327 <a href=
"https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#account" target=
"_blank">Account
</a>
6329 <div class=
"col-sm-10">
6330 <input id=
"account" type=
"text" class=
"account form-control" value=
"0">
6333 <div class=
"form-group">
6334 <label for=
"change" class=
"col-sm-2 control-label">
6335 <a href=
"https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#change" target=
"_blank">External / Internal
</a>
6337 <div class=
"col-sm-10">
6338 <input id=
"change" type=
"text" class=
"change form-control" value=
"0">
6341 <div class=
"form-group">
6342 <label for=
"bip44-path" class=
"col-sm-2 control-label">BIP32 Derivation Path
</label>
6343 <div class=
"col-sm-10">
6344 <input id=
"bip44-path" type=
"text" class=
"path form-control" value=
"m/44'/0'/0'/0" readonly=
"readonly">
6349 <div id=
"bip32" class=
"tab-pane">
6350 <form class=
"form-horizontal" role=
"form">
6352 <div class=
"col-sm-2"></div>
6353 <div class=
"col-sm-10">
6354 <p>For more info see the
<a href=
"https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki" target=
"_blank">BIP32 spec
</a></p>
6356 <div class=
"form-group">
6357 <label for=
"bip32-path" class=
"col-sm-2 control-label">BIP32 Derivation Path
</label>
6358 <div class=
"col-sm-10">
6359 <input id=
"bip32-path" type=
"text" class=
"path form-control" value=
"m/0">
6365 <form class=
"form-horizontal" role=
"form">
6366 <div class=
"form-group">
6367 <label for=
"extended-priv-key" class=
"col-sm-2 control-label">BIP32 Extended Key
</label>
6368 <div class=
"col-sm-10">
6369 <textarea id=
"extended-priv-key" class=
"extended-priv-key form-control" readonly=
"readonly"></textarea>
6372 <div class=
"form-group">
6373 <label for=
"extended-pub-key" class=
"col-sm-2 control-label">BIP32 Extended Key (addresses only)
</label>
6374 <div class=
"col-sm-10">
6375 <textarea id=
"extended-pub-key" class=
"extended-pub-key form-control" readonly=
"readonly"></textarea>
6385 <div class=
"col-md-12">
6386 <h2>Derived Addresses
</h2>
6387 <p>Note these addreses are derived from the
<strong>BIP32 Extended Key
</strong></p>
6388 <table class=
"table table-striped">
6391 <div class=
"input-group">
6393 <button class=
"index-toggle">Toggle
</button>
6397 <div class=
"input-group">
6399 <button class=
"address-toggle">Toggle
</button>
6403 <div class=
"input-group">
6404 Private Key
6405 <button class=
"private-key-toggle">Toggle
</button>
6409 <tbody class=
"addresses">
6410 <tr><td> </td><td> </td><td> </td></tr>
6411 <tr><td> </td><td> </td><td> </td></tr>
6412 <tr><td> </td><td> </td><td> </td></tr>
6413 <tr><td> </td><td> </td><td> </td></tr>
6414 <tr><td> </td><td> </td><td> </td></tr>
6419 <span>Show next
</button>
6420 <input type=
"number" class=
"rows-to-add" value=
"20">
6421 <button class=
"more">Show
</button>
6426 <div class=
"col-md-12">
6428 <h3>BIP39
<span class=
"small">Mnemonic code for generating deterministic keys
</span></h3>
6431 <a href=
"https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki">official BIP39 spec
</a>
6433 <h3>BIP32
<span class=
"small">Hierarchical Deterministic Wallets
</span></h3>
6436 <a href=
"https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki" target=
"_blank">official BIP32 spec
</a>
6438 <a href=
"http://bip32.org/" target=
"_blank">bip32.org
</a>
6440 <h3>BIP44
<span class=
"small">Multi-Account Hierarchy for Deterministic Wallets
</span></h3>
6443 <a href=
"https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki" target=
"_blank">official BIP44 spec
</a>
6445 <h3>Private Keys
</h3>
6448 <a href=
"https://brainwallet.github.io/" target=
"_blank">brainwallet.org
</a>,
6449 but be careful - it can be easy to make mistakes if you
6450 don't know what you're doing
6458 <div class=
"col-md-12">
6460 <h2>Offline Usage
</h2>
6463 You can use this tool without having to be online.
6466 In your browser, select file save-as, and save this page
6470 Double-click that file to open it in a browser
6471 on any offline computer.
6474 Alternatively, download it from
6475 <a href=
"https://github.com/dcpos/bip39">
6476 https://github.com/dcpos/bip39
6485 <div class=
"col-md-12">
6487 <h2>This project is
100% open-source code
</h2>
6490 <span>Get the source code at -
</span>
6491 <a href=
"https://github.com/dcpos/bip39" target=
"_blank">
6492 https://github.com/dcpos/bip39
6499 <span>BitcoinJS -
</span>
6500 <a href=
"https://github.com/bitcoinjs/bitcoinjs-lib" target=
"_blank">
6501 https://github.com/bitcoinjs/bitcoinjs-lib
6506 <span>jsBIP39 -
</span>
6507 <a href=
"https://github.com/iancoleman/jsbip39" target=
"_blank">
6508 https://github.com/iancoleman/jsbip39
6513 <span>asmCrypto -
</span>
6514 <a href=
"https://github.com/vibornoff/asmcrypto.js" target=
"_blank">
6515 https://github.com/vibornoff/asmcrypto.js
6520 <span>jQuery -
</span>
6521 <a href=
"https://jquery.com/" target=
"_blank">
6527 <span>Twitter Bootstrap -
</span>
6528 <a href=
"http://getbootstrap.com/" target=
"_blank">
6529 http://getbootstrap.com/
6538 <div class=
"feedback-container">
6539 <div class=
"feedback">Loading...
</div>
6542 <script type=
"text/template" id=
"address-row-template">
6544 <td class=
"index"><span></span></td>
6545 <td class=
"address"><span></span></td>
6546 <td class=
"privkey"><span></span></td>
6551 * jQuery JavaScript Library v2.1
.1
6552 * http://jquery.com/
6554 * Includes Sizzle.js
6555 * http://sizzlejs.com/
6557 * Copyright
2005,
2014 jQuery Foundation, Inc. and other contributors
6558 * Released under the MIT license
6559 * http://jquery.org/license
6561 * Date:
2014-
05-
01T17:
11Z
6564 (function( global, factory ) {
6566 if ( typeof module === "object" && typeof module.exports === "object" ) {
6567 // For CommonJS and CommonJS-like environments where a proper window is present,
6568 // execute the factory and get jQuery
6569 // For environments that do not inherently posses a window with a document
6570 // (such as Node.js), expose a jQuery-making factory as module.exports
6571 // This accentuates the need for the creation of a real window
6572 // e.g. var jQuery = require("jquery")(window);
6573 // See ticket #
14549 for more info
6574 module.exports = global.document ?
6575 factory( global, true ) :
6577 if ( !w.document ) {
6578 throw new Error( "jQuery requires a window with a document" );
6580 return factory( w );
6586 // Pass this if window is not defined yet
6587 }(typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
6589 // Can't do this because several apps including ASP.NET trace
6590 // the stack via arguments.caller.callee and Firefox dies if
6591 // you try to trace through "use strict" call chains. (#
13335)
6592 // Support: Firefox
18+
6597 var slice = arr.slice;
6599 var concat = arr.concat;
6601 var push = arr.push;
6603 var indexOf = arr.indexOf;
6605 var class2type = {};
6607 var toString = class2type.toString;
6609 var hasOwn = class2type.hasOwnProperty;
6616 // Use the correct document accordingly with window argument (sandbox)
6617 document = window.document,
6621 // Define a local copy of jQuery
6622 jQuery = function( selector, context ) {
6623 // The jQuery object is actually just the init constructor 'enhanced'
6624 // Need init if jQuery is called (just allow error to be thrown if not included)
6625 return new jQuery.fn.init( selector, context );
6628 // Support: Android
<4.1
6629 // Make sure we trim BOM and NBSP
6630 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
6632 // Matches dashed string for camelizing
6633 rmsPrefix = /^-ms-/,
6634 rdashAlpha = /-([\da-z])/gi,
6636 // Used by jQuery.camelCase as callback to replace()
6637 fcamelCase = function( all, letter ) {
6638 return letter.toUpperCase();
6641 jQuery.fn = jQuery.prototype = {
6642 // The current version of jQuery being used
6645 constructor: jQuery,
6647 // Start with an empty selector
6650 // The default length of a jQuery object is
0
6653 toArray: function() {
6654 return slice.call( this );
6657 // Get the Nth element in the matched element set OR
6658 // Get the whole matched element set as a clean array
6659 get: function( num ) {
6660 return num != null ?
6662 // Return just the one element from the set
6663 ( num <
0 ? this[ num + this.length ] : this[ num ] ) :
6665 // Return all the elements in a clean array
6669 // Take an array of elements and push it onto the stack
6670 // (returning the new matched element set)
6671 pushStack: function( elems ) {
6673 // Build a new jQuery matched element set
6674 var ret = jQuery.merge( this.constructor(), elems );
6676 // Add the old object onto the stack (as a reference)
6677 ret.prevObject = this;
6678 ret.context = this.context;
6680 // Return the newly-formed element set
6684 // Execute a callback for every element in the matched set.
6685 // (You can seed the arguments with an array of args, but this is
6686 // only used internally.)
6687 each: function( callback, args ) {
6688 return jQuery.each( this, callback, args );
6691 map: function( callback ) {
6692 return this.pushStack( jQuery.map(this, function( elem, i ) {
6693 return callback.call( elem, i, elem );
6698 return this.pushStack( slice.apply( this, arguments ) );
6702 return this.eq(
0 );
6706 return this.eq( -
1 );
6710 var len = this.length,
6711 j = +i + ( i <
0 ? len :
0 );
6712 return this.pushStack( j
>=
0 && j < len ? [ this[j] ] : [] );
6716 return this.prevObject || this.constructor(null);
6719 // For internal use only.
6720 // Behaves like an Array's method, not like a jQuery method.
6726 jQuery.extend = jQuery.fn.extend = function() {
6727 var options, name, src, copy, copyIsArray, clone,
6728 target = arguments[
0] || {},
6730 length = arguments.length,
6733 // Handle a deep copy situation
6734 if ( typeof target === "boolean" ) {
6737 // skip the boolean and the target
6738 target = arguments[ i ] || {};
6742 // Handle case when target is a string or something (possible in deep copy)
6743 if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
6747 // extend jQuery itself if only one argument is passed
6748 if ( i === length ) {
6753 for ( ; i < length; i++ ) {
6754 // Only deal with non-null/undefined values
6755 if ( (options = arguments[ i ]) != null ) {
6756 // Extend the base object
6757 for ( name in options ) {
6758 src = target[ name ];
6759 copy = options[ name ];
6761 // Prevent never-ending loop
6762 if ( target === copy ) {
6766 // Recurse if we're merging plain objects or arrays
6767 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
6768 if ( copyIsArray ) {
6769 copyIsArray = false;
6770 clone = src && jQuery.isArray(src) ? src : [];
6773 clone = src && jQuery.isPlainObject(src) ? src : {};
6776 // Never move original objects, clone them
6777 target[ name ] = jQuery.extend( deep, clone, copy );
6779 // Don't bring in undefined values
6780 } else if ( copy !== undefined ) {
6781 target[ name ] = copy;
6787 // Return the modified object
6792 // Unique for each copy of jQuery on the page
6793 expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
6795 // Assume jQuery is ready without the ready module
6798 error: function( msg ) {
6799 throw new Error( msg );
6802 noop: function() {},
6804 // See test/unit/core.js for details concerning isFunction.
6805 // Since version
1.3, DOM methods and functions like alert
6806 // aren't supported. They return false on IE (#
2968).
6807 isFunction: function( obj ) {
6808 return jQuery.type(obj) === "function";
6811 isArray: Array.isArray,
6813 isWindow: function( obj ) {
6814 return obj != null && obj === obj.window;
6817 isNumeric: function( obj ) {
6818 // parseFloat NaNs numeric-cast false positives (null|true|false|"")
6819 // ...but misinterprets leading-number strings, particularly hex literals ("
0x...")
6820 // subtraction forces infinities to NaN
6821 return !jQuery.isArray( obj ) && obj - parseFloat( obj )
>=
0;
6824 isPlainObject: function( obj ) {
6825 // Not plain objects:
6826 // - Any object or value whose internal [[Class]] property is not "[object Object]"
6829 if ( jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
6833 if ( obj.constructor &&
6834 !hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) {
6838 // If the function hasn't returned already, we're confident that
6839 // |obj| is a plain object, created by {} or constructed with new Object
6843 isEmptyObject: function( obj ) {
6845 for ( name in obj ) {
6851 type: function( obj ) {
6852 if ( obj == null ) {
6855 // Support: Android <
4.0, iOS <
6 (functionish RegExp)
6856 return typeof obj === "object" || typeof obj === "function" ?
6857 class2type[ toString.call(obj) ] || "object" :
6861 // Evaluates a script in a global context
6862 globalEval: function( code ) {
6866 code = jQuery.trim( code );
6869 // If the code includes a valid, prologue position
6870 // strict mode pragma, execute code by injecting a
6871 // script tag into the document.
6872 if ( code.indexOf("use strict") ===
1 ) {
6873 script = document.createElement("script");
6875 document.head.appendChild( script ).parentNode.removeChild( script );
6877 // Otherwise, avoid the DOM node creation, insertion
6878 // and removal by using an indirect global eval
6884 // Convert dashed to camelCase; used by the css and data modules
6885 // Microsoft forgot to hump their vendor prefix (#
9572)
6886 camelCase: function( string ) {
6887 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
6890 nodeName: function( elem, name ) {
6891 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
6894 // args is for internal usage only
6895 each: function( obj, callback, args ) {
6898 length = obj.length,
6899 isArray = isArraylike( obj );
6903 for ( ; i < length; i++ ) {
6904 value = callback.apply( obj[ i ], args );
6906 if ( value === false ) {
6912 value = callback.apply( obj[ i ], args );
6914 if ( value === false ) {
6920 // A special, fast, case for the most common use of each
6923 for ( ; i < length; i++ ) {
6924 value = callback.call( obj[ i ], i, obj[ i ] );
6926 if ( value === false ) {
6932 value = callback.call( obj[ i ], i, obj[ i ] );
6934 if ( value === false ) {
6944 // Support: Android
<4.1
6945 trim: function( text ) {
6946 return text == null ?
6948 ( text +
"" ).replace( rtrim,
"" );
6951 // results is for internal usage only
6952 makeArray: function( arr, results ) {
6953 var ret = results || [];
6955 if ( arr != null ) {
6956 if ( isArraylike( Object(arr) ) ) {
6958 typeof arr ===
"string" ?
6962 push.call( ret, arr );
6969 inArray: function( elem, arr, i ) {
6970 return arr == null ? -
1 : indexOf.call( arr, elem, i );
6973 merge: function( first, second ) {
6974 var len = +second.length,
6978 for ( ; j < len; j++ ) {
6979 first[ i++ ] = second[ j ];
6987 grep: function( elems, callback, invert ) {
6988 var callbackInverse,
6991 length = elems.length,
6992 callbackExpect = !invert;
6994 // Go through the array, only saving the items
6995 // that pass the validator function
6996 for ( ; i < length; i++ ) {
6997 callbackInverse = !callback( elems[ i ], i );
6998 if ( callbackInverse !== callbackExpect ) {
6999 matches.push( elems[ i ] );
7006 // arg is for internal usage only
7007 map: function( elems, callback, arg ) {
7010 length = elems.length,
7011 isArray = isArraylike( elems ),
7014 // Go through the array, translating each of the items to their new values
7016 for ( ; i < length; i++ ) {
7017 value = callback( elems[ i ], i, arg );
7019 if ( value != null ) {
7024 // Go through every key on the object,
7026 for ( i in elems ) {
7027 value = callback( elems[ i ], i, arg );
7029 if ( value != null ) {
7035 // Flatten any nested arrays
7036 return concat.apply( [], ret );
7039 // A global GUID counter for objects
7042 // Bind a function to a context, optionally partially applying any
7044 proxy: function( fn, context ) {
7045 var tmp, args, proxy;
7047 if ( typeof context ===
"string" ) {
7048 tmp = fn[ context ];
7053 // Quick check to determine if target is callable, in the spec
7054 // this throws a TypeError, but we will just return undefined.
7055 if ( !jQuery.isFunction( fn ) ) {
7060 args = slice.call( arguments,
2 );
7061 proxy = function() {
7062 return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
7065 // Set the guid of unique handler to the same of original handler, so it can be removed
7066 proxy.guid = fn.guid = fn.guid || jQuery.guid++;
7073 // jQuery.support is not used in Core but other projects attach their
7074 // properties to it so it needs to exist.
7078 // Populate the class2type map
7079 jQuery.each(
"Boolean Number String Function Array Date RegExp Object Error".split(
" "), function(i, name) {
7080 class2type[
"[object " + name +
"]" ] = name.toLowerCase();
7083 function isArraylike( obj ) {
7084 var length = obj.length,
7085 type = jQuery.type( obj );
7087 if ( type ===
"function" || jQuery.isWindow( obj ) ) {
7091 if ( obj.nodeType ===
1 && length ) {
7095 return type ===
"array" || length ===
0 ||
7096 typeof length ===
"number" && length
> 0 && ( length -
1 ) in obj;
7100 * Sizzle CSS Selector Engine v1.10
.19
7101 * http://sizzlejs.com/
7103 * Copyright
2013 jQuery Foundation, Inc. and other contributors
7104 * Released under the MIT license
7105 * http://jquery.org/license
7109 (function( window ) {
7123 // Local document vars
7133 // Instance-specific data
7134 expando =
"sizzle" + -(new Date()),
7135 preferredDoc = window.document,
7138 classCache = createCache(),
7139 tokenCache = createCache(),
7140 compilerCache = createCache(),
7141 sortOrder = function( a, b ) {
7143 hasDuplicate = true;
7148 // General-purpose constants
7149 strundefined = typeof undefined,
7150 MAX_NEGATIVE =
1 <<
31,
7153 hasOwn = ({}).hasOwnProperty,
7156 push_native = arr.push,
7159 // Use a stripped-down indexOf if we can't use a native one
7160 indexOf = arr.indexOf || function( elem ) {
7163 for ( ; i < len; i++ ) {
7164 if ( this[i] === elem ) {
7171 booleans =
"checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
7173 // Regular expressions
7175 // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
7176 whitespace =
"[\\x20\\t\\r\\n\\f]",
7177 // http://www.w3.org/TR/css3-syntax/#characters
7178 characterEncoding =
"(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
7180 // Loosely modeled on CSS identifier characters
7181 // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors
7182 // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
7183 identifier = characterEncoding.replace(
"w",
"w#" ),
7185 // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
7186 attributes =
"\\[" + whitespace +
"*(" + characterEncoding +
")(?:" + whitespace +
7187 // Operator (capture
2)
7188 "*([*^$|!~]?=)" + whitespace +
7189 //
"Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
7190 "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\
"])*)\"|(
" + identifier + "))|)
" + whitespace +
7193 pseudos = ":(
" + characterEncoding + ")(?:\\((
" +
7194 // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
7195 // 1. quoted (capture 3; capture 4 or capture 5)
7196 "('((?:\\\\.|[^\\\\'])*)'|\
"((?:\\\\.|[^\\\\\"])*)\
")|" +
7197 //
2. simple (capture
6)
7198 "((?:\\\\.|[^\\\\()[\\]]|" + attributes +
")*)|" +
7199 //
3. anything else (capture
2)
7203 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
7204 rtrim = new RegExp(
"^" + whitespace +
"+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace +
"+$",
"g" ),
7206 rcomma = new RegExp(
"^" + whitespace +
"*," + whitespace +
"*" ),
7207 rcombinators = new RegExp(
"^" + whitespace +
"*([>+~]|" + whitespace +
")" + whitespace +
"*" ),
7209 rattributeQuotes = new RegExp(
"=" + whitespace +
"*([^\\]'\"]*?)
" + whitespace + "*\\]
", "g
" ),
7211 rpseudo = new RegExp( pseudos ),
7212 ridentifier = new RegExp( "^
" + identifier + "$
" ),
7215 "ID
": new RegExp( "^#(
" + characterEncoding + ")
" ),
7216 "CLASS
": new RegExp( "^\\.(
" + characterEncoding + ")
" ),
7217 "TAG
": new RegExp( "^(
" + characterEncoding.replace( "w
", "w*
" ) + ")
" ),
7218 "ATTR
": new RegExp( "^
" + attributes ),
7219 "PSEUDO
": new RegExp( "^
" + pseudos ),
7220 "CHILD
": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(
" + whitespace +
7221 "*(even|odd|(([+-]|)(\\d*)n|)
" + whitespace + "*(?:([+-]|)
" + whitespace +
7222 "*(\\d+)|))
" + whitespace + "*\\)|)
", "i
" ),
7223 "bool
": new RegExp( "^(?:
" + booleans + ")$
", "i
" ),
7224 // For use in libraries implementing .is()
7225 // We use this for POS matching in `select`
7226 "needsContext
": new RegExp( "^
" + whitespace + "*[
>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
7227 whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
7230 rinputs = /^(?:input|select|textarea|button)$/i,
7233 rnative = /^[^{]+\{\s*\[native \w/,
7235 // Easily-parseable/retrievable ID or TAG or CLASS selectors
7236 rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
7241 // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
7242 runescape = new RegExp( "\\\\([\\da-f]{
1,
6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
7243 funescape = function( _, escaped, escapedWhitespace ) {
7244 var high = "
0x" + escaped -
0x10000;
7245 // NaN means non-codepoint
7246 // Support: Firefox
<24
7247 // Workaround erroneous numeric interpretation of +
"0x"
7248 return high !== high || escapedWhitespace ?
7252 String.fromCharCode( high +
0x10000 ) :
7253 // Supplemental Plane codepoint (surrogate pair)
7254 String.fromCharCode( high
>> 10 |
0xD800, high &
0x3FF |
0xDC00 );
7257 // Optimize for push.apply( _, NodeList )
7260 (arr = slice.call( preferredDoc.childNodes )),
7261 preferredDoc.childNodes
7263 // Support: Android
<4.0
7264 // Detect silently failing push.apply
7265 arr[ preferredDoc.childNodes.length ].nodeType;
7267 push = { apply: arr.length ?
7269 // Leverage slice if possible
7270 function( target, els ) {
7271 push_native.apply( target, slice.call(els) );
7275 // Otherwise append directly
7276 function( target, els ) {
7277 var j = target.length,
7279 // Can't trust NodeList.length
7280 while ( (target[j++] = els[i++]) ) {}
7281 target.length = j -
1;
7286 function Sizzle( selector, context, results, seed ) {
7287 var match, elem, m, nodeType,
7289 i, groups, old, nid, newContext, newSelector;
7291 if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
7292 setDocument( context );
7295 context = context || document;
7296 results = results || [];
7298 if ( !selector || typeof selector !==
"string" ) {
7302 if ( (nodeType = context.nodeType) !==
1 && nodeType !==
9 ) {
7306 if ( documentIsHTML && !seed ) {
7309 if ( (match = rquickExpr.exec( selector )) ) {
7310 // Speed-up: Sizzle(
"#ID")
7311 if ( (m = match[
1]) ) {
7312 if ( nodeType ===
9 ) {
7313 elem = context.getElementById( m );
7314 // Check parentNode to catch when Blackberry
4.6 returns
7315 // nodes that are no longer in the document (jQuery #
6963)
7316 if ( elem && elem.parentNode ) {
7317 // Handle the case where IE, Opera, and Webkit return items
7318 // by name instead of ID
7319 if ( elem.id === m ) {
7320 results.push( elem );
7327 // Context is not a document
7328 if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
7329 contains( context, elem ) && elem.id === m ) {
7330 results.push( elem );
7335 // Speed-up: Sizzle(
"TAG")
7336 } else if ( match[
2] ) {
7337 push.apply( results, context.getElementsByTagName( selector ) );
7340 // Speed-up: Sizzle(
".CLASS")
7341 } else if ( (m = match[
3]) && support.getElementsByClassName && context.getElementsByClassName ) {
7342 push.apply( results, context.getElementsByClassName( m ) );
7348 if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
7349 nid = old = expando;
7350 newContext = context;
7351 newSelector = nodeType ===
9 && selector;
7353 // qSA works strangely on Element-rooted queries
7354 // We can work around this by specifying an extra ID on the root
7355 // and working up from there (Thanks to Andrew Dupont for the technique)
7356 // IE
8 doesn't work on object elements
7357 if ( nodeType ===
1 && context.nodeName.toLowerCase() !==
"object" ) {
7358 groups = tokenize( selector );
7360 if ( (old = context.getAttribute(
"id")) ) {
7361 nid = old.replace( rescape,
"\\$&" );
7363 context.setAttribute(
"id", nid );
7365 nid =
"[id='" + nid +
"'] ";
7369 groups[i] = nid + toSelector( groups[i] );
7371 newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context;
7372 newSelector = groups.join(
",");
7375 if ( newSelector ) {
7377 push.apply( results,
7378 newContext.querySelectorAll( newSelector )
7384 context.removeAttribute(
"id");
7392 return select( selector.replace( rtrim,
"$1" ), context, results, seed );
7396 * Create key-value caches of limited size
7397 * @returns {Function(string, Object)} Returns the Object data after storing it on itself with
7398 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
7399 * deleting the oldest entry
7401 function createCache() {
7404 function cache( key, value ) {
7405 // Use (key +
" ") to avoid collision with native prototype properties (see Issue #
157)
7406 if ( keys.push( key +
" " )
> Expr.cacheLength ) {
7407 // Only keep the most recent entries
7408 delete cache[ keys.shift() ];
7410 return (cache[ key + " " ] = value);
7416 * Mark a function for special use by Sizzle
7417 * @param {Function} fn The function to mark
7419 function markFunction( fn ) {
7420 fn[ expando ] = true;
7425 * Support testing using an element
7426 * @param {Function} fn Passed the created div and expects a boolean result
7428 function assert( fn ) {
7429 var div = document.createElement("div");
7436 // Remove from its parent by default
7437 if ( div.parentNode ) {
7438 div.parentNode.removeChild( div );
7440 // release memory in IE
7446 * Adds the same handler for all of the specified attrs
7447 * @param {String} attrs Pipe-separated list of attributes
7448 * @param {Function} handler The method that will be applied
7450 function addHandle( attrs, handler ) {
7451 var arr = attrs.split("|"),
7455 Expr.attrHandle[ arr[i] ] = handler;
7460 * Checks document order of two siblings
7461 * @param {Element} a
7462 * @param {Element} b
7463 * @returns {Number} Returns less than
0 if a precedes b, greater than
0 if a follows b
7465 function siblingCheck( a, b ) {
7467 diff = cur && a.nodeType ===
1 && b.nodeType ===
1 &&
7468 ( ~b.sourceIndex || MAX_NEGATIVE ) -
7469 ( ~a.sourceIndex || MAX_NEGATIVE );
7471 // Use IE sourceIndex if available on both nodes
7476 // Check if b follows a
7478 while ( (cur = cur.nextSibling) ) {
7489 * Returns a function to use in pseudos for input types
7490 * @param {String} type
7492 function createInputPseudo( type ) {
7493 return function( elem ) {
7494 var name = elem.nodeName.toLowerCase();
7495 return name === "input" && elem.type === type;
7500 * Returns a function to use in pseudos for buttons
7501 * @param {String} type
7503 function createButtonPseudo( type ) {
7504 return function( elem ) {
7505 var name = elem.nodeName.toLowerCase();
7506 return (name === "input" || name === "button") && elem.type === type;
7511 * Returns a function to use in pseudos for positionals
7512 * @param {Function} fn
7514 function createPositionalPseudo( fn ) {
7515 return markFunction(function( argument ) {
7516 argument = +argument;
7517 return markFunction(function( seed, matches ) {
7519 matchIndexes = fn( [], seed.length, argument ),
7520 i = matchIndexes.length;
7522 // Match elements found at the specified indexes
7524 if ( seed[ (j = matchIndexes[i]) ] ) {
7525 seed[j] = !(matches[j] = seed[j]);
7533 * Checks a node for validity as a Sizzle context
7534 * @param {Element|Object=} context
7535 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
7537 function testContext( context ) {
7538 return context && typeof context.getElementsByTagName !== strundefined && context;
7541 // Expose support vars for convenience
7542 support = Sizzle.support = {};
7546 * @param {Element|Object} elem An element or a document
7547 * @returns {Boolean} True iff elem is a non-HTML XML node
7549 isXML = Sizzle.isXML = function( elem ) {
7550 // documentElement is verified for cases where it doesn't yet exist
7551 // (such as loading iframes in IE - #
4833)
7552 var documentElement = elem && (elem.ownerDocument || elem).documentElement;
7553 return documentElement ? documentElement.nodeName !== "HTML" : false;
7557 * Sets document-related variables once based on the current document
7558 * @param {Element|Object} [doc] An element or document object to use to set the document
7559 * @returns {Object} Returns the current document
7561 setDocument = Sizzle.setDocument = function( node ) {
7563 doc = node ? node.ownerDocument || node : preferredDoc,
7564 parent = doc.defaultView;
7566 // If no document and documentElement is available, return
7567 if ( doc === document || doc.nodeType !==
9 || !doc.documentElement ) {
7573 docElem = doc.documentElement;
7576 documentIsHTML = !isXML( doc );
7579 // If iframe document is assigned to
"document" variable and if iframe has been reloaded,
7580 // IE will throw
"permission denied" error when accessing
"document" variable, see jQuery #
13936
7581 // IE6-
8 do not support the defaultView property so parent will be undefined
7582 if ( parent && parent !== parent.top ) {
7583 // IE11 does not have attachEvent, so all must suffer
7584 if ( parent.addEventListener ) {
7585 parent.addEventListener(
"unload", function() {
7588 } else if ( parent.attachEvent ) {
7589 parent.attachEvent(
"onunload", function() {
7596 ---------------------------------------------------------------------- */
7599 // Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans)
7600 support.attributes = assert(function( div ) {
7601 div.className =
"i";
7602 return !div.getAttribute(
"className");
7606 ---------------------------------------------------------------------- */
7608 // Check if getElementsByTagName(
"*") returns only elements
7609 support.getElementsByTagName = assert(function( div ) {
7610 div.appendChild( doc.createComment(
"") );
7611 return !div.getElementsByTagName(
"*").length;
7614 // Check if getElementsByClassName can be trusted
7615 support.getElementsByClassName = rnative.test( doc.getElementsByClassName ) && assert(function( div ) {
7616 div.innerHTML =
"<div class='a'></div><div class='a i'></div>";
7618 // Support: Safari
<4
7619 // Catch class over-caching
7620 div.firstChild.className =
"i";
7621 // Support: Opera
<10
7622 // Catch gEBCN failure to find non-leading classes
7623 return div.getElementsByClassName(
"i").length ===
2;
7627 // Check if getElementById returns elements by name
7628 // The broken getElementById methods don't pick up programatically-set names,
7629 // so use a roundabout getElementsByName test
7630 support.getById = assert(function( div ) {
7631 docElem.appendChild( div ).id = expando;
7632 return !doc.getElementsByName || !doc.getElementsByName( expando ).length;
7635 // ID find and filter
7636 if ( support.getById ) {
7637 Expr.find[
"ID"] = function( id, context ) {
7638 if ( typeof context.getElementById !== strundefined && documentIsHTML ) {
7639 var m = context.getElementById( id );
7640 // Check parentNode to catch when Blackberry
4.6 returns
7641 // nodes that are no longer in the document #
6963
7642 return m && m.parentNode ? [ m ] : [];
7645 Expr.filter[
"ID"] = function( id ) {
7646 var attrId = id.replace( runescape, funescape );
7647 return function( elem ) {
7648 return elem.getAttribute(
"id") === attrId;
7653 // getElementById is not reliable as a find shortcut
7654 delete Expr.find[
"ID"];
7656 Expr.filter[
"ID"] = function( id ) {
7657 var attrId = id.replace( runescape, funescape );
7658 return function( elem ) {
7659 var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode(
"id");
7660 return node && node.value === attrId;
7666 Expr.find[
"TAG"] = support.getElementsByTagName ?
7667 function( tag, context ) {
7668 if ( typeof context.getElementsByTagName !== strundefined ) {
7669 return context.getElementsByTagName( tag );
7672 function( tag, context ) {
7676 results = context.getElementsByTagName( tag );
7678 // Filter out possible comments
7679 if ( tag ===
"*" ) {
7680 while ( (elem = results[i++]) ) {
7681 if ( elem.nodeType ===
1 ) {
7692 Expr.find[
"CLASS"] = support.getElementsByClassName && function( className, context ) {
7693 if ( typeof context.getElementsByClassName !== strundefined && documentIsHTML ) {
7694 return context.getElementsByClassName( className );
7698 /* QSA/matchesSelector
7699 ---------------------------------------------------------------------- */
7701 // QSA and matchesSelector support
7703 // matchesSelector(:active) reports false when true (IE9/Opera
11.5)
7706 // qSa(:focus) reports false when true (Chrome
21)
7707 // We allow this because of a bug in IE8/
9 that throws an error
7708 // whenever `document.activeElement` is accessed on an iframe
7709 // So, we allow :focus to pass through QSA all the time to avoid the IE error
7710 // See http://bugs.jquery.com/ticket/
13378
7713 if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) {
7715 // Regex strategy adopted from Diego Perini
7716 assert(function( div ) {
7717 // Select is set to empty string on purpose
7718 // This is to test IE's treatment of not explicitly
7719 // setting a boolean content attribute,
7720 // since its presence should be enough
7721 // http://bugs.jquery.com/ticket/
12359
7722 div.innerHTML =
"<select msallowclip=''><option selected=''></option></select>";
7724 // Support: IE8, Opera
11-
12.16
7725 // Nothing should be selected when empty strings follow ^= or $= or *=
7726 // The test attribute must be unknown in Opera but
"safe" for WinRT
7727 // http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
7728 if ( div.querySelectorAll(
"[msallowclip^='']").length ) {
7729 rbuggyQSA.push(
"[*^$]=" + whitespace +
"*(?:''|\"\
")" );
7733 // Boolean attributes and
"value" are not treated correctly
7734 if ( !div.querySelectorAll(
"[selected]").length ) {
7735 rbuggyQSA.push(
"\\[" + whitespace +
"*(?:value|" + booleans +
")" );
7738 // Webkit/Opera - :checked should return selected option elements
7739 // http://www.w3.org/TR/
2011/REC-css3-selectors-
20110929/#checked
7740 // IE8 throws error here and will not see later tests
7741 if ( !div.querySelectorAll(
":checked").length ) {
7742 rbuggyQSA.push(
":checked");
7746 assert(function( div ) {
7747 // Support: Windows
8 Native Apps
7748 // The type and name attributes are restricted during .innerHTML assignment
7749 var input = doc.createElement(
"input");
7750 input.setAttribute(
"type",
"hidden" );
7751 div.appendChild( input ).setAttribute(
"name",
"D" );
7754 // Enforce case-sensitivity of name attribute
7755 if ( div.querySelectorAll(
"[name=d]").length ) {
7756 rbuggyQSA.push(
"name" + whitespace +
"*[*^$|!~]?=" );
7759 // FF
3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
7760 // IE8 throws error here and will not see later tests
7761 if ( !div.querySelectorAll(
":enabled").length ) {
7762 rbuggyQSA.push(
":enabled",
":disabled" );
7765 // Opera
10-
11 does not throw on post-comma invalid pseudos
7766 div.querySelectorAll(
"*,:x");
7767 rbuggyQSA.push(
",.*:");
7771 if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
7772 docElem.webkitMatchesSelector ||
7773 docElem.mozMatchesSelector ||
7774 docElem.oMatchesSelector ||
7775 docElem.msMatchesSelector) )) ) {
7777 assert(function( div ) {
7778 // Check to see if it's possible to do matchesSelector
7779 // on a disconnected node (IE
9)
7780 support.disconnectedMatch = matches.call( div,
"div" );
7782 // This should fail with an exception
7783 // Gecko does not error, returns false instead
7784 matches.call( div,
"[s!='']:x" );
7785 rbuggyMatches.push(
"!=", pseudos );
7789 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join(
"|") );
7790 rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join(
"|") );
7793 ---------------------------------------------------------------------- */
7794 hasCompare = rnative.test( docElem.compareDocumentPosition );
7796 // Element contains another
7797 // Purposefully does not implement inclusive descendent
7798 // As in, an element does not contain itself
7799 contains = hasCompare || rnative.test( docElem.contains ) ?
7801 var adown = a.nodeType ===
9 ? a.documentElement : a,
7802 bup = b && b.parentNode;
7803 return a === bup || !!( bup && bup.nodeType ===
1 && (
7805 adown.contains( bup ) :
7806 a.compareDocumentPosition && a.compareDocumentPosition( bup ) &
16
7811 while ( (b = b.parentNode) ) {
7821 ---------------------------------------------------------------------- */
7823 // Document order sorting
7824 sortOrder = hasCompare ?
7827 // Flag for duplicate removal
7829 hasDuplicate = true;
7833 // Sort on method existence if only one input has compareDocumentPosition
7834 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
7839 // Calculate position if both inputs belong to the same document
7840 compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
7841 a.compareDocumentPosition( b ) :
7843 // Otherwise we know they are disconnected
7846 // Disconnected nodes
7848 (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
7850 // Choose the first element that is related to our preferred document
7851 if ( a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
7854 if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
7858 // Maintain original order
7860 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
7864 return compare &
4 ? -
1 :
1;
7867 // Exit early if the nodes are identical
7869 hasDuplicate = true;
7880 // Parentless nodes are either documents or disconnected
7881 if ( !aup || !bup ) {
7882 return a === doc ? -
1 :
7887 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
7890 // If the nodes are siblings, we can do a quick check
7891 } else if ( aup === bup ) {
7892 return siblingCheck( a, b );
7895 // Otherwise we need full lists of their ancestors for comparison
7897 while ( (cur = cur.parentNode) ) {
7901 while ( (cur = cur.parentNode) ) {
7905 // Walk down the tree looking for a discrepancy
7906 while ( ap[i] === bp[i] ) {
7911 // Do a sibling check if the nodes have a common ancestor
7912 siblingCheck( ap[i], bp[i] ) :
7914 // Otherwise nodes in our document sort first
7915 ap[i] === preferredDoc ? -
1 :
7916 bp[i] === preferredDoc ?
1 :
7923 Sizzle.matches = function( expr, elements ) {
7924 return Sizzle( expr, null, null, elements );
7927 Sizzle.matchesSelector = function( elem, expr ) {
7928 // Set document vars if needed
7929 if ( ( elem.ownerDocument || elem ) !== document ) {
7930 setDocument( elem );
7933 // Make sure that attribute selectors are quoted
7934 expr = expr.replace( rattributeQuotes,
"='$1']" );
7936 if ( support.matchesSelector && documentIsHTML &&
7937 ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
7938 ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
7941 var ret = matches.call( elem, expr );
7943 // IE
9's matchesSelector returns false on disconnected nodes
7944 if ( ret || support.disconnectedMatch ||
7945 // As well, disconnected nodes are said to be in a document
7947 elem.document && elem.document.nodeType !==
11 ) {
7953 return Sizzle( expr, document, null, [ elem ] ).length
> 0;
7956 Sizzle.contains = function( context, elem ) {
7957 // Set document vars if needed
7958 if ( ( context.ownerDocument || context ) !== document ) {
7959 setDocument( context );
7961 return contains( context, elem );
7964 Sizzle.attr = function( elem, name ) {
7965 // Set document vars if needed
7966 if ( ( elem.ownerDocument || elem ) !== document ) {
7967 setDocument( elem );
7970 var fn = Expr.attrHandle[ name.toLowerCase() ],
7971 // Don't get fooled by Object.prototype properties (jQuery #
13807)
7972 val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
7973 fn( elem, name, !documentIsHTML ) :
7976 return val !== undefined ?
7978 support.attributes || !documentIsHTML ?
7979 elem.getAttribute( name ) :
7980 (val = elem.getAttributeNode(name)) && val.specified ?
7985 Sizzle.error = function( msg ) {
7986 throw new Error(
"Syntax error, unrecognized expression: " + msg );
7990 * Document sorting and removing duplicates
7991 * @param {ArrayLike} results
7993 Sizzle.uniqueSort = function( results ) {
7999 // Unless we *know* we can detect duplicates, assume their presence
8000 hasDuplicate = !support.detectDuplicates;
8001 sortInput = !support.sortStable && results.slice(
0 );
8002 results.sort( sortOrder );
8004 if ( hasDuplicate ) {
8005 while ( (elem = results[i++]) ) {
8006 if ( elem === results[ i ] ) {
8007 j = duplicates.push( i );
8011 results.splice( duplicates[ j ],
1 );
8015 // Clear input after sorting to release objects
8016 // See https://github.com/jquery/sizzle/pull/
225
8023 * Utility function for retrieving the text value of an array of DOM nodes
8024 * @param {Array|Element} elem
8026 getText = Sizzle.getText = function( elem ) {
8030 nodeType = elem.nodeType;
8033 // If no nodeType, this is expected to be an array
8034 while ( (node = elem[i++]) ) {
8035 // Do not traverse comment nodes
8036 ret += getText( node );
8038 } else if ( nodeType ===
1 || nodeType ===
9 || nodeType ===
11 ) {
8039 // Use textContent for elements
8040 // innerText usage removed for consistency of new lines (jQuery #
11153)
8041 if ( typeof elem.textContent ===
"string" ) {
8042 return elem.textContent;
8044 // Traverse its children
8045 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
8046 ret += getText( elem );
8049 } else if ( nodeType ===
3 || nodeType ===
4 ) {
8050 return elem.nodeValue;
8052 // Do not include comment or processing instruction nodes
8057 Expr = Sizzle.selectors = {
8059 // Can be adjusted by the user
8062 createPseudo: markFunction,
8071 ">": { dir:
"parentNode", first: true },
8072 " ": { dir:
"parentNode" },
8073 "+": { dir:
"previousSibling", first: true },
8074 "~": { dir:
"previousSibling" }
8078 "ATTR": function( match ) {
8079 match[
1] = match[
1].replace( runescape, funescape );
8081 // Move the given value to match[
3] whether quoted or unquoted
8082 match[
3] = ( match[
3] || match[
4] || match[
5] ||
"" ).replace( runescape, funescape );
8084 if ( match[
2] ===
"~=" ) {
8085 match[
3] =
" " + match[
3] +
" ";
8088 return match.slice(
0,
4 );
8091 "CHILD": function( match ) {
8092 /* matches from matchExpr[
"CHILD"]
8093 1 type (only|nth|...)
8094 2 what (child|of-type)
8095 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
8096 4 xn-component of xn+y argument ([+-]?\d*n|)
8097 5 sign of xn-component
8099 7 sign of y-component
8102 match[
1] = match[
1].toLowerCase();
8104 if ( match[
1].slice(
0,
3 ) ===
"nth" ) {
8105 // nth-* requires argument
8107 Sizzle.error( match[
0] );
8110 // numeric x and y parameters for Expr.filter.CHILD
8111 // remember that false/true cast respectively to
0/
1
8112 match[
4] = +( match[
4] ? match[
5] + (match[
6] ||
1) :
2 * ( match[
3] ===
"even" || match[
3] ===
"odd" ) );
8113 match[
5] = +( ( match[
7] + match[
8] ) || match[
3] ===
"odd" );
8115 // other types prohibit arguments
8116 } else if ( match[
3] ) {
8117 Sizzle.error( match[
0] );
8123 "PSEUDO": function( match ) {
8125 unquoted = !match[
6] && match[
2];
8127 if ( matchExpr[
"CHILD"].test( match[
0] ) ) {
8131 // Accept quoted arguments as-is
8133 match[
2] = match[
4] || match[
5] ||
"";
8135 // Strip excess characters from unquoted arguments
8136 } else if ( unquoted && rpseudo.test( unquoted ) &&
8137 // Get excess from tokenize (recursively)
8138 (excess = tokenize( unquoted, true )) &&
8139 // advance to the next closing parenthesis
8140 (excess = unquoted.indexOf(
")", unquoted.length - excess ) - unquoted.length) ) {
8142 // excess is a negative index
8143 match[
0] = match[
0].slice(
0, excess );
8144 match[
2] = unquoted.slice(
0, excess );
8147 // Return only captures needed by the pseudo filter method (type and argument)
8148 return match.slice(
0,
3 );
8154 "TAG": function( nodeNameSelector ) {
8155 var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
8156 return nodeNameSelector ===
"*" ?
8157 function() { return true; } :
8159 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
8163 "CLASS": function( className ) {
8164 var pattern = classCache[ className +
" " ];
8167 (pattern = new RegExp(
"(^|" + whitespace +
")" + className +
"(" + whitespace +
"|$)" )) &&
8168 classCache( className, function( elem ) {
8169 return pattern.test( typeof elem.className ===
"string" && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute(
"class") ||
"" );
8173 "ATTR": function( name, operator, check ) {
8174 return function( elem ) {
8175 var result = Sizzle.attr( elem, name );
8177 if ( result == null ) {
8178 return operator ===
"!=";
8186 return operator ===
"=" ? result === check :
8187 operator ===
"!=" ? result !== check :
8188 operator ===
"^=" ? check && result.indexOf( check ) ===
0 :
8189 operator ===
"*=" ? check && result.indexOf( check )
> -
1 :
8190 operator === "$=" ? check && result.slice( -check.length ) === check :
8191 operator === "~=" ? ( " " + result + " " ).indexOf( check )
> -
1 :
8192 operator === "|=" ? result === check || result.slice(
0, check.length +
1 ) === check + "-" :
8197 "CHILD": function( type, what, argument, first, last ) {
8198 var simple = type.slice(
0,
3 ) !== "nth",
8199 forward = type.slice( -
4 ) !== "last",
8200 ofType = what === "of-type";
8202 return first ===
1 && last ===
0 ?
8204 // Shortcut for :nth-*(n)
8206 return !!elem.parentNode;
8209 function( elem, context, xml ) {
8210 var cache, outerCache, node, diff, nodeIndex, start,
8211 dir = simple !== forward ? "nextSibling" : "previousSibling",
8212 parent = elem.parentNode,
8213 name = ofType && elem.nodeName.toLowerCase(),
8214 useCache = !xml && !ofType;
8218 // :(first|last|only)-(child|of-type)
8222 while ( (node = node[ dir ]) ) {
8223 if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType ===
1 ) {
8227 // Reverse direction for :only-* (if we haven't yet done so)
8228 start = dir = type === "only" && !start && "nextSibling";
8233 start = [ forward ? parent.firstChild : parent.lastChild ];
8235 // non-xml :nth-child(...) stores cache data on `parent`
8236 if ( forward && useCache ) {
8237 // Seek `elem` from a previously-cached index
8238 outerCache = parent[ expando ] || (parent[ expando ] = {});
8239 cache = outerCache[ type ] || [];
8240 nodeIndex = cache[
0] === dirruns && cache[
1];
8241 diff = cache[
0] === dirruns && cache[
2];
8242 node = nodeIndex && parent.childNodes[ nodeIndex ];
8244 while ( (node = ++nodeIndex && node && node[ dir ] ||
8246 // Fallback to seeking `elem` from the start
8247 (diff = nodeIndex =
0) || start.pop()) ) {
8249 // When found, cache indexes on `parent` and break
8250 if ( node.nodeType ===
1 && ++diff && node === elem ) {
8251 outerCache[ type ] = [ dirruns, nodeIndex, diff ];
8256 // Use previously-cached element index if available
8257 } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[
0] === dirruns ) {
8260 // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
8262 // Use the same loop as above to seek `elem` from the start
8263 while ( (node = ++nodeIndex && node && node[ dir ] ||
8264 (diff = nodeIndex =
0) || start.pop()) ) {
8266 if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType ===
1 ) && ++diff ) {
8267 // Cache the index of each encountered element
8269 (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ];
8272 if ( node === elem ) {
8279 // Incorporate the offset, then check against cycle size
8281 return diff === first || ( diff % first ===
0 && diff / first
>=
0 );
8286 "PSEUDO": function( pseudo, argument ) {
8287 // pseudo-class names are case-insensitive
8288 // http://www.w3.org/TR/selectors/#pseudo-classes
8289 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
8290 // Remember that setFilters inherits from pseudos
8292 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
8293 Sizzle.error( "unsupported pseudo: " + pseudo );
8295 // The user may use createPseudo to indicate that
8296 // arguments are needed to create the filter function
8297 // just as Sizzle does
8298 if ( fn[ expando ] ) {
8299 return fn( argument );
8302 // But maintain support for old signatures
8303 if ( fn.length
> 1 ) {
8304 args = [ pseudo, pseudo,
"", argument ];
8305 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
8306 markFunction(function( seed, matches ) {
8308 matched = fn( seed, argument ),
8311 idx = indexOf.call( seed, matched[i] );
8312 seed[ idx ] = !( matches[ idx ] = matched[i] );
8316 return fn( elem,
0, args );
8325 // Potentially complex pseudos
8326 "not": markFunction(function( selector ) {
8327 // Trim the selector passed to compile
8328 // to avoid treating leading and trailing
8329 // spaces as combinators
8332 matcher = compile( selector.replace( rtrim,
"$1" ) );
8334 return matcher[ expando ] ?
8335 markFunction(function( seed, matches, context, xml ) {
8337 unmatched = matcher( seed, null, xml, [] ),
8340 // Match elements unmatched by `matcher`
8342 if ( (elem = unmatched[i]) ) {
8343 seed[i] = !(matches[i] = elem);
8347 function( elem, context, xml ) {
8349 matcher( input, null, xml, results );
8350 return !results.pop();
8354 "has": markFunction(function( selector ) {
8355 return function( elem ) {
8356 return Sizzle( selector, elem ).length
> 0;
8360 "contains": markFunction(function( text ) {
8361 return function( elem ) {
8362 return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text )
> -
1;
8366 // "Whether an element is represented by a :lang() selector
8367 // is based solely on the element's language value
8368 // being equal to the identifier C,
8369 // or beginning with the identifier C immediately followed by "-".
8370 // The matching of C against the element's language value is performed case-insensitively.
8371 // The identifier C does not have to be a valid language name."
8372 // http://www.w3.org/TR/selectors/#lang-pseudo
8373 "lang": markFunction( function( lang ) {
8374 // lang value must be a valid identifier
8375 if ( !ridentifier.test(lang || "") ) {
8376 Sizzle.error( "unsupported lang: " + lang );
8378 lang = lang.replace( runescape, funescape ).toLowerCase();
8379 return function( elem ) {
8382 if ( (elemLang = documentIsHTML ?
8384 elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
8386 elemLang = elemLang.toLowerCase();
8387 return elemLang === lang || elemLang.indexOf( lang + "-" ) ===
0;
8389 } while ( (elem = elem.parentNode) && elem.nodeType ===
1 );
8395 "target": function( elem ) {
8396 var hash = window.location && window.location.hash;
8397 return hash && hash.slice(
1 ) === elem.id;
8400 "root": function( elem ) {
8401 return elem === docElem;
8404 "focus": function( elem ) {
8405 return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
8408 // Boolean properties
8409 "enabled": function( elem ) {
8410 return elem.disabled === false;
8413 "disabled": function( elem ) {
8414 return elem.disabled === true;
8417 "checked": function( elem ) {
8418 // In CSS3, :checked should return both checked and selected elements
8419 // http://www.w3.org/TR/
2011/REC-css3-selectors-
20110929/#checked
8420 var nodeName = elem.nodeName.toLowerCase();
8421 return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
8424 "selected": function( elem ) {
8425 // Accessing this property makes selected-by-default
8426 // options in Safari work properly
8427 if ( elem.parentNode ) {
8428 elem.parentNode.selectedIndex;
8431 return elem.selected === true;
8435 "empty": function( elem ) {
8436 // http://www.w3.org/TR/selectors/#empty-pseudo
8437 // :empty is negated by element (
1) or content nodes (text:
3; cdata:
4; entity ref:
5),
8438 // but not by others (comment:
8; processing instruction:
7; etc.)
8439 // nodeType <
6 works because attributes (
2) do not appear as children
8440 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
8441 if ( elem.nodeType <
6 ) {
8448 "parent": function( elem ) {
8449 return !Expr.pseudos["empty"]( elem );
8452 // Element/input types
8453 "header": function( elem ) {
8454 return rheader.test( elem.nodeName );
8457 "input": function( elem ) {
8458 return rinputs.test( elem.nodeName );
8461 "button": function( elem ) {
8462 var name = elem.nodeName.toLowerCase();
8463 return name === "input" && elem.type === "button" || name === "button";
8466 "text": function( elem ) {
8468 return elem.nodeName.toLowerCase() === "input" &&
8469 elem.type === "text" &&
8472 // New HTML5 attribute values (e.g.,
"search") appear with elem.type ===
"text"
8473 ( (attr = elem.getAttribute(
"type")) == null || attr.toLowerCase() ===
"text" );
8476 // Position-in-collection
8477 "first": createPositionalPseudo(function() {
8481 "last": createPositionalPseudo(function( matchIndexes, length ) {
8482 return [ length -
1 ];
8485 "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
8486 return [ argument <
0 ? argument + length : argument ];
8489 "even": createPositionalPseudo(function( matchIndexes, length ) {
8491 for ( ; i < length; i +=
2 ) {
8492 matchIndexes.push( i );
8494 return matchIndexes;
8497 "odd": createPositionalPseudo(function( matchIndexes, length ) {
8499 for ( ; i < length; i +=
2 ) {
8500 matchIndexes.push( i );
8502 return matchIndexes;
8505 "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
8506 var i = argument <
0 ? argument + length : argument;
8507 for ( ; --i
>=
0; ) {
8508 matchIndexes.push( i );
8510 return matchIndexes;
8513 "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
8514 var i = argument <
0 ? argument + length : argument;
8515 for ( ; ++i < length; ) {
8516 matchIndexes.push( i );
8518 return matchIndexes;
8523 Expr.pseudos["nth"] = Expr.pseudos["eq"];
8525 // Add button/input type pseudos
8526 for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
8527 Expr.pseudos[ i ] = createInputPseudo( i );
8529 for ( i in { submit: true, reset: true } ) {
8530 Expr.pseudos[ i ] = createButtonPseudo( i );
8533 // Easy API for creating new setFilters
8534 function setFilters() {}
8535 setFilters.prototype = Expr.filters = Expr.pseudos;
8536 Expr.setFilters = new setFilters();
8538 tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
8539 var matched, match, tokens, type,
8540 soFar, groups, preFilters,
8541 cached = tokenCache[ selector + " " ];
8544 return parseOnly ?
0 : cached.slice(
0 );
8549 preFilters = Expr.preFilter;
8553 // Comma and first run
8554 if ( !matched || (match = rcomma.exec( soFar )) ) {
8556 // Don't consume trailing commas as valid
8557 soFar = soFar.slice( match[
0].length ) || soFar;
8559 groups.push( (tokens = []) );
8565 if ( (match = rcombinators.exec( soFar )) ) {
8566 matched = match.shift();
8569 // Cast descendant combinators to space
8570 type: match[
0].replace( rtrim, " " )
8572 soFar = soFar.slice( matched.length );
8576 for ( type in Expr.filter ) {
8577 if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
8578 (match = preFilters[ type ]( match ))) ) {
8579 matched = match.shift();
8585 soFar = soFar.slice( matched.length );
8594 // Return the length of the invalid excess
8595 // if we're just parsing
8596 // Otherwise, throw an error or return tokens
8600 Sizzle.error( selector ) :
8602 tokenCache( selector, groups ).slice(
0 );
8605 function toSelector( tokens ) {
8607 len = tokens.length,
8609 for ( ; i < len; i++ ) {
8610 selector += tokens[i].value;
8615 function addCombinator( matcher, combinator, base ) {
8616 var dir = combinator.dir,
8617 checkNonElements = base && dir === "parentNode",
8620 return combinator.first ?
8621 // Check against closest ancestor/preceding element
8622 function( elem, context, xml ) {
8623 while ( (elem = elem[ dir ]) ) {
8624 if ( elem.nodeType ===
1 || checkNonElements ) {
8625 return matcher( elem, context, xml );
8630 // Check against all ancestor/preceding elements
8631 function( elem, context, xml ) {
8632 var oldCache, outerCache,
8633 newCache = [ dirruns, doneName ];
8635 // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
8637 while ( (elem = elem[ dir ]) ) {
8638 if ( elem.nodeType ===
1 || checkNonElements ) {
8639 if ( matcher( elem, context, xml ) ) {
8645 while ( (elem = elem[ dir ]) ) {
8646 if ( elem.nodeType ===
1 || checkNonElements ) {
8647 outerCache = elem[ expando ] || (elem[ expando ] = {});
8648 if ( (oldCache = outerCache[ dir ]) &&
8649 oldCache[
0 ] === dirruns && oldCache[
1 ] === doneName ) {
8651 // Assign to newCache so results back-propagate to previous elements
8652 return (newCache[
2 ] = oldCache[
2 ]);
8654 // Reuse newcache so results back-propagate to previous elements
8655 outerCache[ dir ] = newCache;
8657 // A match means we're done; a fail means we have to keep checking
8658 if ( (newCache[
2 ] = matcher( elem, context, xml )) ) {
8668 function elementMatcher( matchers ) {
8669 return matchers.length
> 1 ?
8670 function( elem, context, xml ) {
8671 var i = matchers.length;
8673 if ( !matchers[i]( elem, context, xml ) ) {
8682 function multipleContexts( selector, contexts, results ) {
8684 len = contexts.length;
8685 for ( ; i < len; i++ ) {
8686 Sizzle( selector, contexts[i], results );
8691 function condense( unmatched, map, filter, context, xml ) {
8695 len = unmatched.length,
8696 mapped = map != null;
8698 for ( ; i < len; i++ ) {
8699 if ( (elem = unmatched[i]) ) {
8700 if ( !filter || filter( elem, context, xml ) ) {
8701 newUnmatched.push( elem );
8709 return newUnmatched;
8712 function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
8713 if ( postFilter && !postFilter[ expando ] ) {
8714 postFilter = setMatcher( postFilter );
8716 if ( postFinder && !postFinder[ expando ] ) {
8717 postFinder = setMatcher( postFinder, postSelector );
8719 return markFunction(function( seed, results, context, xml ) {
8723 preexisting = results.length,
8725 // Get initial elements from seed or context
8726 elems = seed || multipleContexts( selector ||
"*", context.nodeType ? [ context ] : context, [] ),
8728 // Prefilter to get matcher input, preserving a map for seed-results synchronization
8729 matcherIn = preFilter && ( seed || !selector ) ?
8730 condense( elems, preMap, preFilter, context, xml ) :
8733 matcherOut = matcher ?
8734 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
8735 postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
8737 // ...intermediate processing is necessary
8740 // ...otherwise use results directly
8744 // Find primary matches
8746 matcher( matcherIn, matcherOut, context, xml );
8751 temp = condense( matcherOut, postMap );
8752 postFilter( temp, [], context, xml );
8754 // Un-match failing elements by moving them back to matcherIn
8757 if ( (elem = temp[i]) ) {
8758 matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
8764 if ( postFinder || preFilter ) {
8766 // Get the final matcherOut by condensing this intermediate into postFinder contexts
8768 i = matcherOut.length;
8770 if ( (elem = matcherOut[i]) ) {
8771 // Restore matcherIn since elem is not yet a final match
8772 temp.push( (matcherIn[i] = elem) );
8775 postFinder( null, (matcherOut = []), temp, xml );
8778 // Move matched elements from seed to results to keep them synchronized
8779 i = matcherOut.length;
8781 if ( (elem = matcherOut[i]) &&
8782 (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i])
> -
1 ) {
8784 seed[temp] = !(results[temp] = elem);
8789 // Add elements to results, through postFinder if defined
8791 matcherOut = condense(
8792 matcherOut === results ?
8793 matcherOut.splice( preexisting, matcherOut.length ) :
8797 postFinder( null, results, matcherOut, xml );
8799 push.apply( results, matcherOut );
8805 function matcherFromTokens( tokens ) {
8806 var checkContext, matcher, j,
8807 len = tokens.length,
8808 leadingRelative = Expr.relative[ tokens[
0].type ],
8809 implicitRelative = leadingRelative || Expr.relative[" "],
8810 i = leadingRelative ?
1 :
0,
8812 // The foundational matcher ensures that elements are reachable from top-level context(s)
8813 matchContext = addCombinator( function( elem ) {
8814 return elem === checkContext;
8815 }, implicitRelative, true ),
8816 matchAnyContext = addCombinator( function( elem ) {
8817 return indexOf.call( checkContext, elem )
> -
1;
8818 }, implicitRelative, true ),
8819 matchers = [ function( elem, context, xml ) {
8820 return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
8821 (checkContext = context).nodeType ?
8822 matchContext( elem, context, xml ) :
8823 matchAnyContext( elem, context, xml ) );
8826 for ( ; i < len; i++ ) {
8827 if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
8828 matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
8830 matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
8832 // Return special upon seeing a positional matcher
8833 if ( matcher[ expando ] ) {
8834 // Find the next relative operator (if any) for proper handling
8836 for ( ; j < len; j++ ) {
8837 if ( Expr.relative[ tokens[j].type ] ) {
8842 i
> 1 && elementMatcher( matchers ),
8843 i
> 1 && toSelector(
8844 // If the preceding token was a descendant combinator, insert an implicit any-element `*`
8845 tokens.slice(
0, i -
1 ).concat({ value: tokens[ i -
2 ].type ===
" " ?
"*" :
"" })
8846 ).replace( rtrim,
"$1" ),
8848 i < j && matcherFromTokens( tokens.slice( i, j ) ),
8849 j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
8850 j < len && toSelector( tokens )
8853 matchers.push( matcher );
8857 return elementMatcher( matchers );
8860 function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
8861 var bySet = setMatchers.length
> 0,
8862 byElement = elementMatchers.length
> 0,
8863 superMatcher = function( seed, context, xml, results, outermost ) {
8864 var elem, j, matcher,
8867 unmatched = seed && [],
8869 contextBackup = outermostContext,
8870 // We must always have either seed elements or outermost context
8871 elems = seed || byElement && Expr.find[
"TAG"](
"*", outermost ),
8872 // Use integer dirruns iff this is the outermost matcher
8873 dirrunsUnique = (dirruns += contextBackup == null ?
1 : Math.random() ||
0.1),
8877 outermostContext = context !== document && context;
8880 // Add elements passing elementMatchers directly to results
8881 // Keep `i` a string if there are no elements so `matchedCount` will be
"00" below
8882 // Support: IE
<9, Safari
8883 // Tolerate NodeList properties (IE:
"length"; Safari:
<number>) matching elements by id
8884 for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
8885 if ( byElement && elem ) {
8887 while ( (matcher = elementMatchers[j++]) ) {
8888 if ( matcher( elem, context, xml ) ) {
8889 results.push( elem );
8894 dirruns = dirrunsUnique;
8898 // Track unmatched elements for set filters
8900 // They will have gone through all possible matchers
8901 if ( (elem = !matcher && elem) ) {
8905 // Lengthen the array for every element, matched or not
8907 unmatched.push( elem );
8912 // Apply set filters to unmatched elements
8914 if ( bySet && i !== matchedCount ) {
8916 while ( (matcher = setMatchers[j++]) ) {
8917 matcher( unmatched, setMatched, context, xml );
8921 // Reintegrate element matches to eliminate the need for sorting
8922 if ( matchedCount
> 0 ) {
8924 if ( !(unmatched[i] || setMatched[i]) ) {
8925 setMatched[i] = pop.call( results );
8930 // Discard index placeholder values to get only actual matches
8931 setMatched = condense( setMatched );
8934 // Add matches to results
8935 push.apply( results, setMatched );
8937 // Seedless set matches succeeding multiple successful matchers stipulate sorting
8938 if ( outermost && !seed && setMatched.length
> 0 &&
8939 ( matchedCount + setMatchers.length )
> 1 ) {
8941 Sizzle.uniqueSort( results );
8945 // Override manipulation of globals by nested matchers
8947 dirruns = dirrunsUnique;
8948 outermostContext = contextBackup;
8955 markFunction( superMatcher ) :
8959 compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
8962 elementMatchers = [],
8963 cached = compilerCache[ selector +
" " ];
8966 // Generate a function of recursive functions that can be used to check each element
8968 match = tokenize( selector );
8972 cached = matcherFromTokens( match[i] );
8973 if ( cached[ expando ] ) {
8974 setMatchers.push( cached );
8976 elementMatchers.push( cached );
8980 // Cache the compiled function
8981 cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
8983 // Save selector and tokenization
8984 cached.selector = selector;
8990 * A low-level selection function that works with Sizzle's compiled
8991 * selector functions
8992 * @param {String|Function} selector A selector or a pre-compiled
8993 * selector function built with Sizzle.compile
8994 * @param {Element} context
8995 * @param {Array} [results]
8996 * @param {Array} [seed] A set of elements to match against
8998 select = Sizzle.select = function( selector, context, results, seed ) {
8999 var i, tokens, token, type, find,
9000 compiled = typeof selector ===
"function" && selector,
9001 match = !seed && tokenize( (selector = compiled.selector || selector) );
9003 results = results || [];
9005 // Try to minimize operations if there is no seed and only one group
9006 if ( match.length ===
1 ) {
9008 // Take a shortcut and set the context if the root selector is an ID
9009 tokens = match[
0] = match[
0].slice(
0 );
9010 if ( tokens.length
> 2 && (token = tokens[
0]).type ===
"ID" &&
9011 support.getById && context.nodeType ===
9 && documentIsHTML &&
9012 Expr.relative[ tokens[
1].type ] ) {
9014 context = ( Expr.find[
"ID"]( token.matches[
0].replace(runescape, funescape), context ) || [] )[
0];
9018 // Precompiled matchers will still verify ancestry, so step up a level
9019 } else if ( compiled ) {
9020 context = context.parentNode;
9023 selector = selector.slice( tokens.shift().value.length );
9026 // Fetch a seed set for right-to-left matching
9027 i = matchExpr[
"needsContext"].test( selector ) ?
0 : tokens.length;
9031 // Abort if we hit a combinator
9032 if ( Expr.relative[ (type = token.type) ] ) {
9035 if ( (find = Expr.find[ type ]) ) {
9036 // Search, expanding context for leading sibling combinators
9038 token.matches[
0].replace( runescape, funescape ),
9039 rsibling.test( tokens[
0].type ) && testContext( context.parentNode ) || context
9042 // If seed is empty or no tokens remain, we can return early
9043 tokens.splice( i,
1 );
9044 selector = seed.length && toSelector( tokens );
9046 push.apply( results, seed );
9056 // Compile and execute a filtering function if one is not provided
9057 // Provide `match` to avoid retokenization if we modified the selector above
9058 ( compiled || compile( selector, match ) )(
9063 rsibling.test( selector ) && testContext( context.parentNode ) || context
9068 // One-time assignments
9071 support.sortStable = expando.split(
"").sort( sortOrder ).join(
"") === expando;
9073 // Support: Chrome
<14
9074 // Always assume duplicates if they aren't passed to the comparison function
9075 support.detectDuplicates = !!hasDuplicate;
9077 // Initialize against the default document
9080 // Support: Webkit
<537.32 - Safari
6.0.3/Chrome
25 (fixed in Chrome
27)
9081 // Detached nodes confoundingly follow *each other*
9082 support.sortDetached = assert(function( div1 ) {
9083 // Should return
1, but returns
4 (following)
9084 return div1.compareDocumentPosition( document.createElement(
"div") ) &
1;
9088 // Prevent attribute/property
"interpolation"
9089 // http://msdn.microsoft.com/en-us/library/ms536429%
28VS
.85%
29.aspx
9090 if ( !assert(function( div ) {
9091 div.innerHTML =
"<a href='#'></a>";
9092 return div.firstChild.getAttribute(
"href") ===
"#" ;
9094 addHandle(
"type|href|height|width", function( elem, name, isXML ) {
9096 return elem.getAttribute( name, name.toLowerCase() ===
"type" ?
1 :
2 );
9102 // Use defaultValue in place of getAttribute(
"value")
9103 if ( !support.attributes || !assert(function( div ) {
9104 div.innerHTML =
"<input/>";
9105 div.firstChild.setAttribute(
"value",
"" );
9106 return div.firstChild.getAttribute(
"value" ) ===
"";
9108 addHandle(
"value", function( elem, name, isXML ) {
9109 if ( !isXML && elem.nodeName.toLowerCase() ===
"input" ) {
9110 return elem.defaultValue;
9116 // Use getAttributeNode to fetch booleans when getAttribute lies
9117 if ( !assert(function( div ) {
9118 return div.getAttribute(
"disabled") == null;
9120 addHandle( booleans, function( elem, name, isXML ) {
9123 return elem[ name ] === true ? name.toLowerCase() :
9124 (val = elem.getAttributeNode( name )) && val.specified ?
9137 jQuery.find = Sizzle;
9138 jQuery.expr = Sizzle.selectors;
9139 jQuery.expr[
":"] = jQuery.expr.pseudos;
9140 jQuery.unique = Sizzle.uniqueSort;
9141 jQuery.text = Sizzle.getText;
9142 jQuery.isXMLDoc = Sizzle.isXML;
9143 jQuery.contains = Sizzle.contains;
9147 var rneedsContext = jQuery.expr.match.needsContext;
9149 var rsingleTag = (/^<(\w+)\s*\/
?>(?:<\/\
1>|)$/);
9153 var risSimple = /^.[^:#\[\.,]*$/;
9155 // Implement the identical functionality for filter and not
9156 function winnow( elements, qualifier, not ) {
9157 if ( jQuery.isFunction( qualifier ) ) {
9158 return jQuery.grep( elements, function( elem, i ) {
9160 return !!qualifier.call( elem, i, elem ) !== not;
9165 if ( qualifier.nodeType ) {
9166 return jQuery.grep( elements, function( elem ) {
9167 return ( elem === qualifier ) !== not;
9172 if ( typeof qualifier === "string" ) {
9173 if ( risSimple.test( qualifier ) ) {
9174 return jQuery.filter( qualifier, elements, not );
9177 qualifier = jQuery.filter( qualifier, elements );
9180 return jQuery.grep( elements, function( elem ) {
9181 return ( indexOf.call( qualifier, elem )
>=
0 ) !== not;
9185 jQuery.filter = function( expr, elems, not ) {
9186 var elem = elems[
0 ];
9189 expr = ":not(" + expr + ")";
9192 return elems.length ===
1 && elem.nodeType ===
1 ?
9193 jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
9194 jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
9195 return elem.nodeType ===
1;
9200 find: function( selector ) {
9206 if ( typeof selector !== "string" ) {
9207 return this.pushStack( jQuery( selector ).filter(function() {
9208 for ( i =
0; i < len; i++ ) {
9209 if ( jQuery.contains( self[ i ], this ) ) {
9216 for ( i =
0; i < len; i++ ) {
9217 jQuery.find( selector, self[ i ], ret );
9220 // Needed because $( selector, context ) becomes $( context ).find( selector )
9221 ret = this.pushStack( len
> 1 ? jQuery.unique( ret ) : ret );
9222 ret.selector = this.selector ? this.selector +
" " + selector : selector;
9225 filter: function( selector ) {
9226 return this.pushStack( winnow(this, selector || [], false) );
9228 not: function( selector ) {
9229 return this.pushStack( winnow(this, selector || [], true) );
9231 is: function( selector ) {
9235 // If this is a positional/relative selector, check membership in the returned set
9236 // so $(
"p:first").is(
"p:last") won't return true for a doc with two
"p".
9237 typeof selector ===
"string" && rneedsContext.test( selector ) ?
9238 jQuery( selector ) :
9246 // Initialize a jQuery object
9249 // A central reference to the root jQuery(document)
9252 // A simple way to check for HTML strings
9253 // Prioritize #id over
<tag> to avoid XSS via location.hash (#
9521)
9254 // Strict HTML recognition (#
11290: must start with <)
9255 rquickExpr = /^(?:\s*(<[\w\W]+
>)[^
>]*|#([\w-]*))$/,
9257 init = jQuery.fn.init = function( selector, context ) {
9260 // HANDLE: $(""), $(null), $(undefined), $(false)
9265 // Handle HTML strings
9266 if ( typeof selector === "string" ) {
9267 if ( selector[
0] === "<" && selector[ selector.length -
1 ] === "
>" && selector.length >= 3 ) {
9268 // Assume that strings that start and end with <> are HTML and skip the regex check
9269 match = [ null, selector, null ];
9272 match = rquickExpr.exec( selector );
9275 // Match html or make sure no context is specified for #id
9276 if ( match && (match[1] || !context) ) {
9278 // HANDLE: $(html) -> $(array)
9280 context = context instanceof jQuery ? context[0] : context;
9282 // scripts is true for back-compat
9283 // Intentionally let the error be thrown if parseHTML is not present
9284 jQuery.merge( this, jQuery.parseHTML(
9286 context && context.nodeType ? context.ownerDocument || context : document,
9290 // HANDLE: $(html, props)
9291 if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
9292 for ( match in context ) {
9293 // Properties of context are called as methods if possible
9294 if ( jQuery.isFunction( this[ match ] ) ) {
9295 this[ match ]( context[ match ] );
9297 // ...and otherwise set as attributes
9299 this.attr( match, context[ match ] );
9308 elem = document.getElementById( match[2] );
9310 // Check parentNode to catch when Blackberry 4.6 returns
9311 // nodes that are no longer in the document #6963
9312 if ( elem && elem.parentNode ) {
9313 // Inject the element directly into the jQuery object
9318 this.context = document;
9319 this.selector = selector;
9323 // HANDLE: $(expr, $(...))
9324 } else if ( !context || context.jquery ) {
9325 return ( context || rootjQuery ).find( selector );
9327 // HANDLE: $(expr, context)
9328 // (which is just equivalent to: $(context).find(expr)
9330 return this.constructor( context ).find( selector );
9333 // HANDLE: $(DOMElement)
9334 } else if ( selector.nodeType ) {
9335 this.context = this[0] = selector;
9339 // HANDLE: $(function)
9340 // Shortcut for document ready
9341 } else if ( jQuery.isFunction( selector ) ) {
9342 return typeof rootjQuery.ready !== "undefined" ?
9343 rootjQuery.ready( selector ) :
9344 // Execute immediately if ready is not present
9348 if ( selector.selector !== undefined ) {
9349 this.selector = selector.selector;
9350 this.context = selector.context;
9353 return jQuery.makeArray( selector, this );
9356 // Give the init function the jQuery prototype for later instantiation
9357 init.prototype = jQuery.fn;
9359 // Initialize central reference
9360 rootjQuery = jQuery( document );
9363 var rparentsprev = /^(?:parents|prev(?:Until|All))/,
9364 // methods guaranteed to produce a unique set when starting from a unique set
9365 guaranteedUnique = {
9373 dir: function( elem, dir, until ) {
9375 truncate = until !== undefined;
9377 while ( (elem = elem[ dir ]) && elem.nodeType !==
9 ) {
9378 if ( elem.nodeType ===
1 ) {
9379 if ( truncate && jQuery( elem ).is( until ) ) {
9382 matched.push( elem );
9388 sibling: function( n, elem ) {
9391 for ( ; n; n = n.nextSibling ) {
9392 if ( n.nodeType ===
1 && n !== elem ) {
9402 has: function( target ) {
9403 var targets = jQuery( target, this ),
9406 return this.filter(function() {
9408 for ( ; i < l; i++ ) {
9409 if ( jQuery.contains( this, targets[i] ) ) {
9416 closest: function( selectors, context ) {
9421 pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
9422 jQuery( selectors, context || this.context ) :
9425 for ( ; i < l; i++ ) {
9426 for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) {
9427 // Always skip document fragments
9428 if ( cur.nodeType <
11 && (pos ?
9429 pos.index(cur)
> -
1 :
9431 // Don't pass non-elements to Sizzle
9432 cur.nodeType ===
1 &&
9433 jQuery.find.matchesSelector(cur, selectors)) ) {
9435 matched.push( cur );
9441 return this.pushStack( matched.length
> 1 ? jQuery.unique( matched ) : matched );
9444 // Determine the position of an element within
9445 // the matched set of elements
9446 index: function( elem ) {
9448 // No argument, return index in parent
9450 return ( this[
0 ] && this[
0 ].parentNode ) ? this.first().prevAll().length : -
1;
9453 // index in selector
9454 if ( typeof elem ===
"string" ) {
9455 return indexOf.call( jQuery( elem ), this[
0 ] );
9458 // Locate the position of the desired element
9459 return indexOf.call( this,
9461 // If it receives a jQuery object, the first element is used
9462 elem.jquery ? elem[
0 ] : elem
9466 add: function( selector, context ) {
9467 return this.pushStack(
9469 jQuery.merge( this.get(), jQuery( selector, context ) )
9474 addBack: function( selector ) {
9475 return this.add( selector == null ?
9476 this.prevObject : this.prevObject.filter(selector)
9481 function sibling( cur, dir ) {
9482 while ( (cur = cur[dir]) && cur.nodeType !==
1 ) {}
9487 parent: function( elem ) {
9488 var parent = elem.parentNode;
9489 return parent && parent.nodeType !==
11 ? parent : null;
9491 parents: function( elem ) {
9492 return jQuery.dir( elem,
"parentNode" );
9494 parentsUntil: function( elem, i, until ) {
9495 return jQuery.dir( elem,
"parentNode", until );
9497 next: function( elem ) {
9498 return sibling( elem,
"nextSibling" );
9500 prev: function( elem ) {
9501 return sibling( elem,
"previousSibling" );
9503 nextAll: function( elem ) {
9504 return jQuery.dir( elem,
"nextSibling" );
9506 prevAll: function( elem ) {
9507 return jQuery.dir( elem,
"previousSibling" );
9509 nextUntil: function( elem, i, until ) {
9510 return jQuery.dir( elem,
"nextSibling", until );
9512 prevUntil: function( elem, i, until ) {
9513 return jQuery.dir( elem,
"previousSibling", until );
9515 siblings: function( elem ) {
9516 return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
9518 children: function( elem ) {
9519 return jQuery.sibling( elem.firstChild );
9521 contents: function( elem ) {
9522 return elem.contentDocument || jQuery.merge( [], elem.childNodes );
9524 }, function( name, fn ) {
9525 jQuery.fn[ name ] = function( until, selector ) {
9526 var matched = jQuery.map( this, fn, until );
9528 if ( name.slice( -
5 ) !==
"Until" ) {
9532 if ( selector && typeof selector ===
"string" ) {
9533 matched = jQuery.filter( selector, matched );
9536 if ( this.length
> 1 ) {
9537 // Remove duplicates
9538 if ( !guaranteedUnique[ name ] ) {
9539 jQuery.unique( matched );
9542 // Reverse order for parents* and prev-derivatives
9543 if ( rparentsprev.test( name ) ) {
9548 return this.pushStack( matched );
9551 var rnotwhite = (/\S+/g);
9555 // String to Object options format cache
9556 var optionsCache = {};
9558 // Convert String-formatted options into Object-formatted ones and store in cache
9559 function createOptions( options ) {
9560 var object = optionsCache[ options ] = {};
9561 jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) {
9562 object[ flag ] = true;
9568 * Create a callback list using the following parameters:
9570 * options: an optional list of space-separated options that will change how
9571 * the callback list behaves or a more traditional option object
9573 * By default a callback list will act like an event callback list and can be
9574 *
"fired" multiple times.
9578 * once: will ensure the callback list can only be fired once (like a Deferred)
9580 * memory: will keep track of previous values and will call any callback added
9581 * after the list has been fired right away with the latest
"memorized"
9582 * values (like a Deferred)
9584 * unique: will ensure a callback can only be added once (no duplicate in the list)
9586 * stopOnFalse: interrupt callings when a callback returns false
9589 jQuery.Callbacks = function( options ) {
9591 // Convert options from String-formatted to Object-formatted if needed
9592 // (we check in cache first)
9593 options = typeof options ===
"string" ?
9594 ( optionsCache[ options ] || createOptions( options ) ) :
9595 jQuery.extend( {}, options );
9597 var // Last fire value (for non-forgettable lists)
9599 // Flag to know if list was already fired
9601 // Flag to know if list is currently firing
9603 // First callback to fire (used internally by add and fireWith)
9605 // End of the loop when firing
9607 // Index of currently firing callback (modified by remove if needed)
9609 // Actual callback list
9611 // Stack of fire calls for repeatable lists
9612 stack = !options.once && [],
9614 fire = function( data ) {
9615 memory = options.memory && data;
9617 firingIndex = firingStart ||
0;
9619 firingLength = list.length;
9621 for ( ; list && firingIndex < firingLength; firingIndex++ ) {
9622 if ( list[ firingIndex ].apply( data[
0 ], data[
1 ] ) === false && options.stopOnFalse ) {
9623 memory = false; // To prevent further calls using add
9630 if ( stack.length ) {
9631 fire( stack.shift() );
9633 } else if ( memory ) {
9640 // Actual Callbacks object
9642 // Add a callback or a collection of callbacks to the list
9645 // First, we save the current length
9646 var start = list.length;
9647 (function add( args ) {
9648 jQuery.each( args, function( _, arg ) {
9649 var type = jQuery.type( arg );
9650 if ( type ===
"function" ) {
9651 if ( !options.unique || !self.has( arg ) ) {
9654 } else if ( arg && arg.length && type !==
"string" ) {
9655 // Inspect recursively
9660 // Do we need to add the callbacks to the
9661 // current firing batch?
9663 firingLength = list.length;
9664 // With memory, if we're not firing then
9665 // we should call right away
9666 } else if ( memory ) {
9667 firingStart = start;
9673 // Remove a callback from the list
9674 remove: function() {
9676 jQuery.each( arguments, function( _, arg ) {
9678 while ( ( index = jQuery.inArray( arg, list, index ) )
> -
1 ) {
9679 list.splice( index,
1 );
9680 // Handle firing indexes
9682 if ( index <= firingLength ) {
9685 if ( index <= firingIndex ) {
9694 // Check if a given callback is in the list.
9695 // If no argument is given, return whether or not list has callbacks attached.
9696 has: function( fn ) {
9697 return fn ? jQuery.inArray( fn, list )
> -
1 : !!( list && list.length );
9699 // Remove all callbacks from the list
9705 // Have the list do nothing anymore
9706 disable: function() {
9707 list = stack = memory = undefined;
9711 disabled: function() {
9714 // Lock the list in its current state
9723 locked: function() {
9726 // Call all callbacks with the given context and arguments
9727 fireWith: function( context, args ) {
9728 if ( list && ( !fired || stack ) ) {
9730 args = [ context, args.slice ? args.slice() : args ];
9739 // Call all the callbacks with the given arguments
9741 self.fireWith( this, arguments );
9744 // To know if the callbacks have already been called at least once
9756 Deferred: function( func ) {
9758 // action, add listener, listener list, final state
9759 [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
9760 [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
9761 [ "notify", "progress", jQuery.Callbacks("memory") ]
9768 always: function() {
9769 deferred.done( arguments ).fail( arguments );
9772 then: function( /* fnDone, fnFail, fnProgress */ ) {
9773 var fns = arguments;
9774 return jQuery.Deferred(function( newDefer ) {
9775 jQuery.each( tuples, function( i, tuple ) {
9776 var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
9777 // deferred[ done | fail | progress ] for forwarding actions to newDefer
9778 deferred[ tuple[
1] ](function() {
9779 var returned = fn && fn.apply( this, arguments );
9780 if ( returned && jQuery.isFunction( returned.promise ) ) {
9782 .done( newDefer.resolve )
9783 .fail( newDefer.reject )
9784 .progress( newDefer.notify );
9786 newDefer[ tuple[
0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments );
9793 // Get a promise for this deferred
9794 // If obj is provided, the promise aspect is added to the object
9795 promise: function( obj ) {
9796 return obj != null ? jQuery.extend( obj, promise ) : promise;
9801 // Keep pipe for back-compat
9802 promise.pipe = promise.then;
9804 // Add list-specific methods
9805 jQuery.each( tuples, function( i, tuple ) {
9806 var list = tuple[
2 ],
9807 stateString = tuple[
3 ];
9809 // promise[ done | fail | progress ] = list.add
9810 promise[ tuple[
1] ] = list.add;
9813 if ( stateString ) {
9814 list.add(function() {
9815 // state = [ resolved | rejected ]
9816 state = stateString;
9818 // [ reject_list | resolve_list ].disable; progress_list.lock
9819 }, tuples[ i ^
1 ][
2 ].disable, tuples[
2 ][
2 ].lock );
9822 // deferred[ resolve | reject | notify ]
9823 deferred[ tuple[
0] ] = function() {
9824 deferred[ tuple[
0] + "With" ]( this === deferred ? promise : this, arguments );
9827 deferred[ tuple[
0] + "With" ] = list.fireWith;
9830 // Make the deferred a promise
9831 promise.promise( deferred );
9833 // Call given func if any
9835 func.call( deferred, deferred );
9843 when: function( subordinate /* , ..., subordinateN */ ) {
9845 resolveValues = slice.call( arguments ),
9846 length = resolveValues.length,
9848 // the count of uncompleted subordinates
9849 remaining = length !==
1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length :
0,
9851 // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
9852 deferred = remaining ===
1 ? subordinate : jQuery.Deferred(),
9854 // Update function for both resolve and progress values
9855 updateFunc = function( i, contexts, values ) {
9856 return function( value ) {
9857 contexts[ i ] = this;
9858 values[ i ] = arguments.length
> 1 ? slice.call( arguments ) : value;
9859 if ( values === progressValues ) {
9860 deferred.notifyWith( contexts, values );
9861 } else if ( !( --remaining ) ) {
9862 deferred.resolveWith( contexts, values );
9867 progressValues, progressContexts, resolveContexts;
9869 // add listeners to Deferred subordinates; treat others as resolved
9871 progressValues = new Array( length );
9872 progressContexts = new Array( length );
9873 resolveContexts = new Array( length );
9874 for ( ; i < length; i++ ) {
9875 if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
9876 resolveValues[ i ].promise()
9877 .done( updateFunc( i, resolveContexts, resolveValues ) )
9878 .fail( deferred.reject )
9879 .progress( updateFunc( i, progressContexts, progressValues ) );
9886 // if we're not waiting on anything, resolve the master
9888 deferred.resolveWith( resolveContexts, resolveValues );
9891 return deferred.promise();
9896 // The deferred used on DOM ready
9899 jQuery.fn.ready = function( fn ) {
9901 jQuery.ready.promise().done( fn );
9907 // Is the DOM ready to be used? Set to true once it occurs.
9910 // A counter to track how many items to wait for before
9911 // the ready event fires. See #
6781
9914 // Hold (or release) the ready event
9915 holdReady: function( hold ) {
9919 jQuery.ready( true );
9923 // Handle when the DOM is ready
9924 ready: function( wait ) {
9926 // Abort if there are pending holds or we're already ready
9927 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
9931 // Remember that the DOM is ready
9932 jQuery.isReady = true;
9934 // If a normal DOM Ready event fired, decrement, and wait if need be
9935 if ( wait !== true && --jQuery.readyWait
> 0 ) {
9939 // If there are functions bound, to execute
9940 readyList.resolveWith( document, [ jQuery ] );
9942 // Trigger any bound ready events
9943 if ( jQuery.fn.triggerHandler ) {
9944 jQuery( document ).triggerHandler(
"ready" );
9945 jQuery( document ).off(
"ready" );
9951 * The ready event handler and self cleanup method
9953 function completed() {
9954 document.removeEventListener(
"DOMContentLoaded", completed, false );
9955 window.removeEventListener(
"load", completed, false );
9959 jQuery.ready.promise = function( obj ) {
9962 readyList = jQuery.Deferred();
9964 // Catch cases where $(document).ready() is called after the browser event has already occurred.
9965 // we once tried to use readyState
"interactive" here, but it caused issues like the one
9966 // discovered by ChrisS here: http://bugs.jquery.com/ticket/
12282#comment:
15
9967 if ( document.readyState ===
"complete" ) {
9968 // Handle it asynchronously to allow scripts the opportunity to delay ready
9969 setTimeout( jQuery.ready );
9973 // Use the handy event callback
9974 document.addEventListener(
"DOMContentLoaded", completed, false );
9976 // A fallback to window.onload, that will always work
9977 window.addEventListener(
"load", completed, false );
9980 return readyList.promise( obj );
9983 // Kick off the DOM ready check even if the user does not
9984 jQuery.ready.promise();
9989 // Multifunctional method to get and set values of a collection
9990 // The value/s can optionally be executed if it's a function
9991 var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
9997 if ( jQuery.type( key ) ===
"object" ) {
10000 jQuery.access( elems, fn, i, key[i], true, emptyGet, raw );
10004 } else if ( value !== undefined ) {
10007 if ( !jQuery.isFunction( value ) ) {
10012 // Bulk operations run against the entire set
10014 fn.call( elems, value );
10017 // ...except when executing function values
10020 fn = function( elem, key, value ) {
10021 return bulk.call( jQuery( elem ), value );
10027 for ( ; i < len; i++ ) {
10028 fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) );
10039 len ? fn( elems[
0], key ) : emptyGet;
10044 * Determines whether an object can have data
10046 jQuery.acceptData = function( owner ) {
10049 // - Node.ELEMENT_NODE
10050 // - Node.DOCUMENT_NODE
10054 return owner.nodeType ===
1 || owner.nodeType ===
9 || !( +owner.nodeType );
10059 // Support: Android <
4,
10060 // Old WebKit does not have Object.preventExtensions/freeze method,
10061 // return new empty object instead with no [[set]] accessor
10062 Object.defineProperty( this.cache = {},
0, {
10068 this.expando = jQuery.expando + Math.random();
10072 Data.accepts = jQuery.acceptData;
10075 key: function( owner ) {
10076 // We can accept data for non-element nodes in modern browsers,
10077 // but we should not, see #
8335.
10078 // Always return the key for a frozen object.
10079 if ( !Data.accepts( owner ) ) {
10083 var descriptor = {},
10084 // Check if the owner object already has a cache key
10085 unlock = owner[ this.expando ];
10087 // If not, create one
10089 unlock = Data.uid++;
10091 // Secure it in a non-enumerable, non-writable property
10093 descriptor[ this.expando ] = { value: unlock };
10094 Object.defineProperties( owner, descriptor );
10096 // Support: Android <
4
10097 // Fallback to a less secure definition
10099 descriptor[ this.expando ] = unlock;
10100 jQuery.extend( owner, descriptor );
10104 // Ensure the cache object
10105 if ( !this.cache[ unlock ] ) {
10106 this.cache[ unlock ] = {};
10111 set: function( owner, data, value ) {
10113 // There may be an unlock assigned to this node,
10114 // if there is no entry for this
"owner", create one inline
10115 // and set the unlock as though an owner entry had always existed
10116 unlock = this.key( owner ),
10117 cache = this.cache[ unlock ];
10119 // Handle: [ owner, key, value ] args
10120 if ( typeof data ===
"string" ) {
10121 cache[ data ] = value;
10123 // Handle: [ owner, { properties } ] args
10125 // Fresh assignments by object are shallow copied
10126 if ( jQuery.isEmptyObject( cache ) ) {
10127 jQuery.extend( this.cache[ unlock ], data );
10128 // Otherwise, copy the properties one-by-one to the cache object
10130 for ( prop in data ) {
10131 cache[ prop ] = data[ prop ];
10137 get: function( owner, key ) {
10138 // Either a valid cache is found, or will be created.
10139 // New caches will be created and the unlock returned,
10140 // allowing direct access to the newly created
10141 // empty data object. A valid owner object must be provided.
10142 var cache = this.cache[ this.key( owner ) ];
10144 return key === undefined ?
10145 cache : cache[ key ];
10147 access: function( owner, key, value ) {
10149 // In cases where either:
10151 //
1. No key was specified
10152 //
2. A string key was specified, but no value provided
10154 // Take the
"read" path and allow the get method to determine
10155 // which value to return, respectively either:
10157 //
1. The entire cache object
10158 //
2. The data stored at the key
10160 if ( key === undefined ||
10161 ((key && typeof key ===
"string") && value === undefined) ) {
10163 stored = this.get( owner, key );
10165 return stored !== undefined ?
10166 stored : this.get( owner, jQuery.camelCase(key) );
10169 // [*]When the key is not a string, or both a key and value
10170 // are specified, set or extend (existing objects) with either:
10172 //
1. An object of properties
10173 //
2. A key and value
10175 this.set( owner, key, value );
10177 // Since the
"set" path can have two possible entry points
10178 // return the expected data based on which path was taken[*]
10179 return value !== undefined ? value : key;
10181 remove: function( owner, key ) {
10182 var i, name, camel,
10183 unlock = this.key( owner ),
10184 cache = this.cache[ unlock ];
10186 if ( key === undefined ) {
10187 this.cache[ unlock ] = {};
10190 // Support array or space separated string of keys
10191 if ( jQuery.isArray( key ) ) {
10192 // If
"name" is an array of keys...
10193 // When data is initially created, via (
"key",
"val") signature,
10194 // keys will be converted to camelCase.
10195 // Since there is no way to tell _how_ a key was added, remove
10196 // both plain key and camelCase key. #
12786
10197 // This will only penalize the array argument path.
10198 name = key.concat( key.map( jQuery.camelCase ) );
10200 camel = jQuery.camelCase( key );
10201 // Try the string as a key before any manipulation
10202 if ( key in cache ) {
10203 name = [ key, camel ];
10205 // If a key with the spaces exists, use it.
10206 // Otherwise, create an array by matching non-whitespace
10208 name = name in cache ?
10209 [ name ] : ( name.match( rnotwhite ) || [] );
10215 delete cache[ name[ i ] ];
10219 hasData: function( owner ) {
10220 return !jQuery.isEmptyObject(
10221 this.cache[ owner[ this.expando ] ] || {}
10224 discard: function( owner ) {
10225 if ( owner[ this.expando ] ) {
10226 delete this.cache[ owner[ this.expando ] ];
10230 var data_priv = new Data();
10232 var data_user = new Data();
10237 Implementation Summary
10239 1. Enforce API surface and semantic compatibility with
1.9.x branch
10240 2. Improve the module's maintainability by reducing the storage
10241 paths to a single mechanism.
10242 3. Use the same single mechanism to support
"private" and
"user" data.
10243 4. _Never_ expose
"private" data to user code (TODO: Drop _data, _removeData)
10244 5. Avoid exposing implementation details on user objects (eg. expando properties)
10245 6. Provide a clear path for implementation upgrade to WeakMap in
2014
10247 var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
10248 rmultiDash = /([A-Z])/g;
10250 function dataAttr( elem, key, data ) {
10253 // If nothing was found internally, try to fetch any
10254 // data from the HTML5 data-* attribute
10255 if ( data === undefined && elem.nodeType ===
1 ) {
10256 name =
"data-" + key.replace( rmultiDash,
"-$1" ).toLowerCase();
10257 data = elem.getAttribute( name );
10259 if ( typeof data ===
"string" ) {
10261 data = data ===
"true" ? true :
10262 data ===
"false" ? false :
10263 data ===
"null" ? null :
10264 // Only convert to a number if it doesn't change the string
10265 +data +
"" === data ? +data :
10266 rbrace.test( data ) ? jQuery.parseJSON( data ) :
10270 // Make sure we set the data so it isn't changed later
10271 data_user.set( elem, key, data );
10280 hasData: function( elem ) {
10281 return data_user.hasData( elem ) || data_priv.hasData( elem );
10284 data: function( elem, name, data ) {
10285 return data_user.access( elem, name, data );
10288 removeData: function( elem, name ) {
10289 data_user.remove( elem, name );
10292 // TODO: Now that all calls to _data and _removeData have been replaced
10293 // with direct calls to data_priv methods, these can be deprecated.
10294 _data: function( elem, name, data ) {
10295 return data_priv.access( elem, name, data );
10298 _removeData: function( elem, name ) {
10299 data_priv.remove( elem, name );
10304 data: function( key, value ) {
10307 attrs = elem && elem.attributes;
10310 if ( key === undefined ) {
10311 if ( this.length ) {
10312 data = data_user.get( elem );
10314 if ( elem.nodeType ===
1 && !data_priv.get( elem,
"hasDataAttrs" ) ) {
10319 // The attrs elements can be null (#
14894)
10320 if ( attrs[ i ] ) {
10321 name = attrs[ i ].name;
10322 if ( name.indexOf(
"data-" ) ===
0 ) {
10323 name = jQuery.camelCase( name.slice(
5) );
10324 dataAttr( elem, name, data[ name ] );
10328 data_priv.set( elem,
"hasDataAttrs", true );
10335 // Sets multiple values
10336 if ( typeof key ===
"object" ) {
10337 return this.each(function() {
10338 data_user.set( this, key );
10342 return access( this, function( value ) {
10344 camelKey = jQuery.camelCase( key );
10346 // The calling jQuery object (element matches) is not empty
10347 // (and therefore has an element appears at this[
0 ]) and the
10348 // `value` parameter was not undefined. An empty jQuery object
10349 // will result in `undefined` for elem = this[
0 ] which will
10350 // throw an exception if an attempt to read a data cache is made.
10351 if ( elem && value === undefined ) {
10352 // Attempt to get data from the cache
10353 // with the key as-is
10354 data = data_user.get( elem, key );
10355 if ( data !== undefined ) {
10359 // Attempt to get data from the cache
10360 // with the key camelized
10361 data = data_user.get( elem, camelKey );
10362 if ( data !== undefined ) {
10366 // Attempt to
"discover" the data in
10367 // HTML5 custom data-* attrs
10368 data = dataAttr( elem, camelKey, undefined );
10369 if ( data !== undefined ) {
10373 // We tried really hard, but the data doesn't exist.
10378 this.each(function() {
10379 // First, attempt to store a copy or reference of any
10380 // data that might've been store with a camelCased key.
10381 var data = data_user.get( this, camelKey );
10383 // For HTML5 data-* attribute interop, we have to
10384 // store property names with dashes in a camelCase form.
10385 // This might not apply to all properties...*
10386 data_user.set( this, camelKey, value );
10388 // *... In the case of properties that might _actually_
10389 // have dashes, we need to also store a copy of that
10390 // unchanged property.
10391 if ( key.indexOf(
"-") !== -
1 && data !== undefined ) {
10392 data_user.set( this, key, value );
10395 }, null, value, arguments.length
> 1, null, true );
10398 removeData: function( key ) {
10399 return this.each(function() {
10400 data_user.remove( this, key );
10407 queue: function( elem, type, data ) {
10411 type = ( type ||
"fx" ) +
"queue";
10412 queue = data_priv.get( elem, type );
10414 // Speed up dequeue by getting out quickly if this is just a lookup
10416 if ( !queue || jQuery.isArray( data ) ) {
10417 queue = data_priv.access( elem, type, jQuery.makeArray(data) );
10419 queue.push( data );
10422 return queue || [];
10426 dequeue: function( elem, type ) {
10427 type = type ||
"fx";
10429 var queue = jQuery.queue( elem, type ),
10430 startLength = queue.length,
10431 fn = queue.shift(),
10432 hooks = jQuery._queueHooks( elem, type ),
10433 next = function() {
10434 jQuery.dequeue( elem, type );
10437 // If the fx queue is dequeued, always remove the progress sentinel
10438 if ( fn ===
"inprogress" ) {
10439 fn = queue.shift();
10445 // Add a progress sentinel to prevent the fx queue from being
10446 // automatically dequeued
10447 if ( type ===
"fx" ) {
10448 queue.unshift(
"inprogress" );
10451 // clear up the last queue stop function
10453 fn.call( elem, next, hooks );
10456 if ( !startLength && hooks ) {
10457 hooks.empty.fire();
10461 // not intended for public consumption - generates a queueHooks object, or returns the current one
10462 _queueHooks: function( elem, type ) {
10463 var key = type +
"queueHooks";
10464 return data_priv.get( elem, key ) || data_priv.access( elem, key, {
10465 empty: jQuery.Callbacks(
"once memory").add(function() {
10466 data_priv.remove( elem, [ type +
"queue", key ] );
10473 queue: function( type, data ) {
10476 if ( typeof type !==
"string" ) {
10482 if ( arguments.length < setter ) {
10483 return jQuery.queue( this[
0], type );
10486 return data === undefined ?
10488 this.each(function() {
10489 var queue = jQuery.queue( this, type, data );
10491 // ensure a hooks for this queue
10492 jQuery._queueHooks( this, type );
10494 if ( type ===
"fx" && queue[
0] !==
"inprogress" ) {
10495 jQuery.dequeue( this, type );
10499 dequeue: function( type ) {
10500 return this.each(function() {
10501 jQuery.dequeue( this, type );
10504 clearQueue: function( type ) {
10505 return this.queue( type ||
"fx", [] );
10507 // Get a promise resolved when queues of a certain type
10508 // are emptied (fx is the type by default)
10509 promise: function( type, obj ) {
10512 defer = jQuery.Deferred(),
10515 resolve = function() {
10516 if ( !( --count ) ) {
10517 defer.resolveWith( elements, [ elements ] );
10521 if ( typeof type !==
"string" ) {
10525 type = type ||
"fx";
10528 tmp = data_priv.get( elements[ i ], type +
"queueHooks" );
10529 if ( tmp && tmp.empty ) {
10531 tmp.empty.add( resolve );
10535 return defer.promise( obj );
10538 var pnum = (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source;
10540 var cssExpand = [
"Top",
"Right",
"Bottom",
"Left" ];
10542 var isHidden = function( elem, el ) {
10543 // isHidden might be called from jQuery#filter function;
10544 // in that case, element will be second argument
10546 return jQuery.css( elem,
"display" ) ===
"none" || !jQuery.contains( elem.ownerDocument, elem );
10549 var rcheckableType = (/^(?:checkbox|radio)$/i);
10554 var fragment = document.createDocumentFragment(),
10555 div = fragment.appendChild( document.createElement(
"div" ) ),
10556 input = document.createElement(
"input" );
10558 // #
11217 - WebKit loses check when the name is after the checked attribute
10559 // Support: Windows Web Apps (WWA)
10560 // `name` and `type` need .setAttribute for WWA
10561 input.setAttribute(
"type",
"radio" );
10562 input.setAttribute(
"checked",
"checked" );
10563 input.setAttribute(
"name",
"t" );
10565 div.appendChild( input );
10567 // Support: Safari
5.1, iOS
5.1, Android
4.x, Android
2.3
10568 // old WebKit doesn't clone checked state correctly in fragments
10569 support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
10571 // Make sure textarea (and checkbox) defaultValue is properly cloned
10572 // Support: IE9-IE11+
10573 div.innerHTML =
"<textarea>x</textarea>";
10574 support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
10576 var strundefined = typeof undefined;
10580 support.focusinBubbles =
"onfocusin" in window;
10584 rkeyEvent = /^key/,
10585 rmouseEvent = /^(?:mouse|pointer|contextmenu)|click/,
10586 rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
10587 rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
10589 function returnTrue() {
10593 function returnFalse() {
10597 function safeActiveElement() {
10599 return document.activeElement;
10600 } catch ( err ) { }
10604 * Helper functions for managing events -- not part of the public interface.
10605 * Props to Dean Edwards' addEvent library for many of the ideas.
10611 add: function( elem, types, handler, data, selector ) {
10613 var handleObjIn, eventHandle, tmp,
10614 events, t, handleObj,
10615 special, handlers, type, namespaces, origType,
10616 elemData = data_priv.get( elem );
10618 // Don't attach events to noData or text/comment nodes (but allow plain objects)
10623 // Caller can pass in an object of custom data in lieu of the handler
10624 if ( handler.handler ) {
10625 handleObjIn = handler;
10626 handler = handleObjIn.handler;
10627 selector = handleObjIn.selector;
10630 // Make sure that the handler has a unique ID, used to find/remove it later
10631 if ( !handler.guid ) {
10632 handler.guid = jQuery.guid++;
10635 // Init the element's event structure and main handler, if this is the first
10636 if ( !(events = elemData.events) ) {
10637 events = elemData.events = {};
10639 if ( !(eventHandle = elemData.handle) ) {
10640 eventHandle = elemData.handle = function( e ) {
10641 // Discard the second event of a jQuery.event.trigger() and
10642 // when an event is called after a page has unloaded
10643 return typeof jQuery !== strundefined && jQuery.event.triggered !== e.type ?
10644 jQuery.event.dispatch.apply( elem, arguments ) : undefined;
10648 // Handle multiple events separated by a space
10649 types = ( types ||
"" ).match( rnotwhite ) || [
"" ];
10652 tmp = rtypenamespace.exec( types[t] ) || [];
10653 type = origType = tmp[
1];
10654 namespaces = ( tmp[
2] ||
"" ).split(
"." ).sort();
10656 // There *must* be a type, no attaching namespace-only handlers
10661 // If event changes its type, use the special event handlers for the changed type
10662 special = jQuery.event.special[ type ] || {};
10664 // If selector defined, determine special event api type, otherwise given type
10665 type = ( selector ? special.delegateType : special.bindType ) || type;
10667 // Update special based on newly reset type
10668 special = jQuery.event.special[ type ] || {};
10670 // handleObj is passed to all event handlers
10671 handleObj = jQuery.extend({
10673 origType: origType,
10676 guid: handler.guid,
10677 selector: selector,
10678 needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
10679 namespace: namespaces.join(
".")
10682 // Init the event handler queue if we're the first
10683 if ( !(handlers = events[ type ]) ) {
10684 handlers = events[ type ] = [];
10685 handlers.delegateCount =
0;
10687 // Only use addEventListener if the special events handler returns false
10688 if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
10689 if ( elem.addEventListener ) {
10690 elem.addEventListener( type, eventHandle, false );
10695 if ( special.add ) {
10696 special.add.call( elem, handleObj );
10698 if ( !handleObj.handler.guid ) {
10699 handleObj.handler.guid = handler.guid;
10703 // Add to the element's handler list, delegates in front
10705 handlers.splice( handlers.delegateCount++,
0, handleObj );
10707 handlers.push( handleObj );
10710 // Keep track of which events have ever been used, for event optimization
10711 jQuery.event.global[ type ] = true;
10716 // Detach an event or set of events from an element
10717 remove: function( elem, types, handler, selector, mappedTypes ) {
10719 var j, origCount, tmp,
10720 events, t, handleObj,
10721 special, handlers, type, namespaces, origType,
10722 elemData = data_priv.hasData( elem ) && data_priv.get( elem );
10724 if ( !elemData || !(events = elemData.events) ) {
10728 // Once for each type.namespace in types; type may be omitted
10729 types = ( types ||
"" ).match( rnotwhite ) || [
"" ];
10732 tmp = rtypenamespace.exec( types[t] ) || [];
10733 type = origType = tmp[
1];
10734 namespaces = ( tmp[
2] ||
"" ).split(
"." ).sort();
10736 // Unbind all events (on this namespace, if provided) for the element
10738 for ( type in events ) {
10739 jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
10744 special = jQuery.event.special[ type ] || {};
10745 type = ( selector ? special.delegateType : special.bindType ) || type;
10746 handlers = events[ type ] || [];
10747 tmp = tmp[
2] && new RegExp(
"(^|\\.)" + namespaces.join(
"\\.(?:.*\\.|)") +
"(\\.|$)" );
10749 // Remove matching events
10750 origCount = j = handlers.length;
10752 handleObj = handlers[ j ];
10754 if ( ( mappedTypes || origType === handleObj.origType ) &&
10755 ( !handler || handler.guid === handleObj.guid ) &&
10756 ( !tmp || tmp.test( handleObj.namespace ) ) &&
10757 ( !selector || selector === handleObj.selector || selector ===
"**" && handleObj.selector ) ) {
10758 handlers.splice( j,
1 );
10760 if ( handleObj.selector ) {
10761 handlers.delegateCount--;
10763 if ( special.remove ) {
10764 special.remove.call( elem, handleObj );
10769 // Remove generic event handler if we removed something and no more handlers exist
10770 // (avoids potential for endless recursion during removal of special event handlers)
10771 if ( origCount && !handlers.length ) {
10772 if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
10773 jQuery.removeEvent( elem, type, elemData.handle );
10776 delete events[ type ];
10780 // Remove the expando if it's no longer used
10781 if ( jQuery.isEmptyObject( events ) ) {
10782 delete elemData.handle;
10783 data_priv.remove( elem,
"events" );
10787 trigger: function( event, data, elem, onlyHandlers ) {
10789 var i, cur, tmp, bubbleType, ontype, handle, special,
10790 eventPath = [ elem || document ],
10791 type = hasOwn.call( event,
"type" ) ? event.type : event,
10792 namespaces = hasOwn.call( event,
"namespace" ) ? event.namespace.split(
".") : [];
10794 cur = tmp = elem = elem || document;
10796 // Don't do events on text and comment nodes
10797 if ( elem.nodeType ===
3 || elem.nodeType ===
8 ) {
10801 // focus/blur morphs to focusin/out; ensure we're not firing them right now
10802 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
10806 if ( type.indexOf(
".")
>=
0 ) {
10807 // Namespaced trigger; create a regexp to match event type in handle()
10808 namespaces = type.split(".");
10809 type = namespaces.shift();
10812 ontype = type.indexOf(":") <
0 && "on" + type;
10814 // Caller can pass in a jQuery.Event object, Object, or just an event type string
10815 event = event[ jQuery.expando ] ?
10817 new jQuery.Event( type, typeof event === "object" && event );
10819 // Trigger bitmask: &
1 for native handlers; &
2 for jQuery (always true)
10820 event.isTrigger = onlyHandlers ?
2 :
3;
10821 event.namespace = namespaces.join(".");
10822 event.namespace_re = event.namespace ?
10823 new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
10826 // Clean up the event in case it is being reused
10827 event.result = undefined;
10828 if ( !event.target ) {
10829 event.target = elem;
10832 // Clone any incoming data and prepend the event, creating the handler arg list
10833 data = data == null ?
10835 jQuery.makeArray( data, [ event ] );
10837 // Allow special events to draw outside the lines
10838 special = jQuery.event.special[ type ] || {};
10839 if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
10843 // Determine event propagation path in advance, per W3C events spec (#
9951)
10844 // Bubble up to document, then to window; watch for a global ownerDocument var (#
9724)
10845 if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
10847 bubbleType = special.delegateType || type;
10848 if ( !rfocusMorph.test( bubbleType + type ) ) {
10849 cur = cur.parentNode;
10851 for ( ; cur; cur = cur.parentNode ) {
10852 eventPath.push( cur );
10856 // Only add window if we got to document (e.g., not plain obj or detached DOM)
10857 if ( tmp === (elem.ownerDocument || document) ) {
10858 eventPath.push( tmp.defaultView || tmp.parentWindow || window );
10862 // Fire handlers on the event path
10864 while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) {
10866 event.type = i
> 1 ?
10868 special.bindType || type;
10871 handle = ( data_priv.get( cur,
"events" ) || {} )[ event.type ] && data_priv.get( cur,
"handle" );
10873 handle.apply( cur, data );
10877 handle = ontype && cur[ ontype ];
10878 if ( handle && handle.apply && jQuery.acceptData( cur ) ) {
10879 event.result = handle.apply( cur, data );
10880 if ( event.result === false ) {
10881 event.preventDefault();
10887 // If nobody prevented the default action, do it now
10888 if ( !onlyHandlers && !event.isDefaultPrevented() ) {
10890 if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) &&
10891 jQuery.acceptData( elem ) ) {
10893 // Call a native DOM method on the target with the same name name as the event.
10894 // Don't do default actions on window, that's where global variables be (#
6170)
10895 if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) {
10897 // Don't re-trigger an onFOO event when we call its FOO() method
10898 tmp = elem[ ontype ];
10901 elem[ ontype ] = null;
10904 // Prevent re-triggering of the same event, since we already bubbled it above
10905 jQuery.event.triggered = type;
10907 jQuery.event.triggered = undefined;
10910 elem[ ontype ] = tmp;
10916 return event.result;
10919 dispatch: function( event ) {
10921 // Make a writable jQuery.Event from the native event object
10922 event = jQuery.event.fix( event );
10924 var i, j, ret, matched, handleObj,
10926 args = slice.call( arguments ),
10927 handlers = ( data_priv.get( this,
"events" ) || {} )[ event.type ] || [],
10928 special = jQuery.event.special[ event.type ] || {};
10930 // Use the fix-ed jQuery.Event rather than the (read-only) native event
10932 event.delegateTarget = this;
10934 // Call the preDispatch hook for the mapped type, and let it bail if desired
10935 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
10939 // Determine handlers
10940 handlerQueue = jQuery.event.handlers.call( this, event, handlers );
10942 // Run delegates first; they may want to stop propagation beneath us
10944 while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) {
10945 event.currentTarget = matched.elem;
10948 while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) {
10950 // Triggered event must either
1) have no namespace, or
10951 //
2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
10952 if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) {
10954 event.handleObj = handleObj;
10955 event.data = handleObj.data;
10957 ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
10958 .apply( matched.elem, args );
10960 if ( ret !== undefined ) {
10961 if ( (event.result = ret) === false ) {
10962 event.preventDefault();
10963 event.stopPropagation();
10970 // Call the postDispatch hook for the mapped type
10971 if ( special.postDispatch ) {
10972 special.postDispatch.call( this, event );
10975 return event.result;
10978 handlers: function( event, handlers ) {
10979 var i, matches, sel, handleObj,
10981 delegateCount = handlers.delegateCount,
10982 cur = event.target;
10984 // Find delegate handlers
10985 // Black-hole SVG
<use> instance trees (#
13180)
10986 // Avoid non-left-click bubbling in Firefox (#
3861)
10987 if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) {
10989 for ( ; cur !== this; cur = cur.parentNode || this ) {
10991 // Don't process clicks on disabled elements (#
6911, #
8165, #
11382, #
11764)
10992 if ( cur.disabled !== true || event.type !== "click" ) {
10994 for ( i =
0; i < delegateCount; i++ ) {
10995 handleObj = handlers[ i ];
10997 // Don't conflict with Object.prototype properties (#
13203)
10998 sel = handleObj.selector + " ";
11000 if ( matches[ sel ] === undefined ) {
11001 matches[ sel ] = handleObj.needsContext ?
11002 jQuery( sel, this ).index( cur )
>=
0 :
11003 jQuery.find( sel, this, null, [ cur ] ).length;
11005 if ( matches[ sel ] ) {
11006 matches.push( handleObj );
11009 if ( matches.length ) {
11010 handlerQueue.push({ elem: cur, handlers: matches });
11016 // Add the remaining (directly-bound) handlers
11017 if ( delegateCount < handlers.length ) {
11018 handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) });
11021 return handlerQueue;
11024 // Includes some event props shared by KeyEvent and MouseEvent
11025 props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
11030 props: "char charCode key keyCode".split(" "),
11031 filter: function( event, original ) {
11033 // Add which for key events
11034 if ( event.which == null ) {
11035 event.which = original.charCode != null ? original.charCode : original.keyCode;
11043 props: "button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
11044 filter: function( event, original ) {
11045 var eventDoc, doc, body,
11046 button = original.button;
11048 // Calculate pageX/Y if missing and clientX/Y available
11049 if ( event.pageX == null && original.clientX != null ) {
11050 eventDoc = event.target.ownerDocument || document;
11051 doc = eventDoc.documentElement;
11052 body = eventDoc.body;
11054 event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft ||
0 ) - ( doc && doc.clientLeft || body && body.clientLeft ||
0 );
11055 event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop ||
0 ) - ( doc && doc.clientTop || body && body.clientTop ||
0 );
11058 // Add which for click:
1 === left;
2 === middle;
3 === right
11059 // Note: button is not normalized, so don't use it
11060 if ( !event.which && button !== undefined ) {
11061 event.which = ( button &
1 ?
1 : ( button &
2 ?
3 : ( button &
4 ?
2 :
0 ) ) );
11068 fix: function( event ) {
11069 if ( event[ jQuery.expando ] ) {
11073 // Create a writable copy of the event object and normalize some properties
11076 originalEvent = event,
11077 fixHook = this.fixHooks[ type ];
11080 this.fixHooks[ type ] = fixHook =
11081 rmouseEvent.test( type ) ? this.mouseHooks :
11082 rkeyEvent.test( type ) ? this.keyHooks :
11085 copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
11087 event = new jQuery.Event( originalEvent );
11092 event[ prop ] = originalEvent[ prop ];
11095 // Support: Cordova
2.5 (WebKit) (#
13255)
11096 // All events should have a target; Cordova deviceready doesn't
11097 if ( !event.target ) {
11098 event.target = document;
11101 // Support: Safari
6.0+, Chrome <
28
11102 // Target should not be a text node (#
504, #
13143)
11103 if ( event.target.nodeType ===
3 ) {
11104 event.target = event.target.parentNode;
11107 return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
11112 // Prevent triggered image.load events from bubbling to window.load
11116 // Fire native event if possible so blur/focus sequence is correct
11117 trigger: function() {
11118 if ( this !== safeActiveElement() && this.focus ) {
11123 delegateType: "focusin"
11126 trigger: function() {
11127 if ( this === safeActiveElement() && this.blur ) {
11132 delegateType: "focusout"
11135 // For checkbox, fire native event so checked state will be right
11136 trigger: function() {
11137 if ( this.type === "checkbox" && this.click && jQuery.nodeName( this, "input" ) ) {
11143 // For cross-browser consistency, don't fire native .click() on links
11144 _default: function( event ) {
11145 return jQuery.nodeName( event.target, "a" );
11150 postDispatch: function( event ) {
11152 // Support: Firefox
20+
11153 // Firefox doesn't alert if the returnValue field is not set.
11154 if ( event.result !== undefined && event.originalEvent ) {
11155 event.originalEvent.returnValue = event.result;
11161 simulate: function( type, elem, event, bubble ) {
11162 // Piggyback on a donor event to simulate a different one.
11163 // Fake originalEvent to avoid donor's stopPropagation, but if the
11164 // simulated event prevents default then we do the same on the donor.
11165 var e = jQuery.extend(
11166 new jQuery.Event(),
11175 jQuery.event.trigger( e, null, elem );
11177 jQuery.event.dispatch.call( elem, e );
11179 if ( e.isDefaultPrevented() ) {
11180 event.preventDefault();
11185 jQuery.removeEvent = function( elem, type, handle ) {
11186 if ( elem.removeEventListener ) {
11187 elem.removeEventListener( type, handle, false );
11191 jQuery.Event = function( src, props ) {
11192 // Allow instantiation without the 'new' keyword
11193 if ( !(this instanceof jQuery.Event) ) {
11194 return new jQuery.Event( src, props );
11198 if ( src && src.type ) {
11199 this.originalEvent = src;
11200 this.type = src.type;
11202 // Events bubbling up the document may have been marked as prevented
11203 // by a handler lower down the tree; reflect the correct value.
11204 this.isDefaultPrevented = src.defaultPrevented ||
11205 src.defaultPrevented === undefined &&
11206 // Support: Android <
4.0
11207 src.returnValue === false ?
11216 // Put explicitly provided properties onto the event object
11218 jQuery.extend( this, props );
11221 // Create a timestamp if incoming event doesn't have one
11222 this.timeStamp = src && src.timeStamp || jQuery.now();
11224 // Mark it as fixed
11225 this[ jQuery.expando ] = true;
11228 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
11229 // http://www.w3.org/TR/
2003/WD-DOM-Level-
3-Events-
20030331/ecma-script-binding.html
11230 jQuery.Event.prototype = {
11231 isDefaultPrevented: returnFalse,
11232 isPropagationStopped: returnFalse,
11233 isImmediatePropagationStopped: returnFalse,
11235 preventDefault: function() {
11236 var e = this.originalEvent;
11238 this.isDefaultPrevented = returnTrue;
11240 if ( e && e.preventDefault ) {
11241 e.preventDefault();
11244 stopPropagation: function() {
11245 var e = this.originalEvent;
11247 this.isPropagationStopped = returnTrue;
11249 if ( e && e.stopPropagation ) {
11250 e.stopPropagation();
11253 stopImmediatePropagation: function() {
11254 var e = this.originalEvent;
11256 this.isImmediatePropagationStopped = returnTrue;
11258 if ( e && e.stopImmediatePropagation ) {
11259 e.stopImmediatePropagation();
11262 this.stopPropagation();
11266 // Create mouseenter/leave events using mouseover/out and event-time checks
11267 // Support: Chrome
15+
11269 mouseenter: "mouseover",
11270 mouseleave: "mouseout",
11271 pointerenter: "pointerover",
11272 pointerleave: "pointerout"
11273 }, function( orig, fix ) {
11274 jQuery.event.special[ orig ] = {
11278 handle: function( event ) {
11281 related = event.relatedTarget,
11282 handleObj = event.handleObj;
11284 // For mousenter/leave call the handler if related is outside the target.
11285 // NB: No relatedTarget if the mouse left/entered the browser window
11286 if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
11287 event.type = handleObj.origType;
11288 ret = handleObj.handler.apply( this, arguments );
11296 // Create "bubbling" focus and blur events
11297 // Support: Firefox, Chrome, Safari
11298 if ( !support.focusinBubbles ) {
11299 jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
11301 // Attach a single capturing handler on the document while someone wants focusin/focusout
11302 var handler = function( event ) {
11303 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
11306 jQuery.event.special[ fix ] = {
11307 setup: function() {
11308 var doc = this.ownerDocument || this,
11309 attaches = data_priv.access( doc, fix );
11312 doc.addEventListener( orig, handler, true );
11314 data_priv.access( doc, fix, ( attaches ||
0 ) +
1 );
11316 teardown: function() {
11317 var doc = this.ownerDocument || this,
11318 attaches = data_priv.access( doc, fix ) -
1;
11321 doc.removeEventListener( orig, handler, true );
11322 data_priv.remove( doc, fix );
11325 data_priv.access( doc, fix, attaches );
11334 on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
11337 // Types can be a map of types/handlers
11338 if ( typeof types === "object" ) {
11339 // ( types-Object, selector, data )
11340 if ( typeof selector !== "string" ) {
11341 // ( types-Object, data )
11342 data = data || selector;
11343 selector = undefined;
11345 for ( type in types ) {
11346 this.on( type, selector, data, types[ type ], one );
11351 if ( data == null && fn == null ) {
11354 data = selector = undefined;
11355 } else if ( fn == null ) {
11356 if ( typeof selector === "string" ) {
11357 // ( types, selector, fn )
11361 // ( types, data, fn )
11364 selector = undefined;
11367 if ( fn === false ) {
11369 } else if ( !fn ) {
11375 fn = function( event ) {
11376 // Can use an empty set, since event contains the info
11377 jQuery().off( event );
11378 return origFn.apply( this, arguments );
11380 // Use same guid so caller can remove using origFn
11381 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
11383 return this.each( function() {
11384 jQuery.event.add( this, types, fn, data, selector );
11387 one: function( types, selector, data, fn ) {
11388 return this.on( types, selector, data, fn,
1 );
11390 off: function( types, selector, fn ) {
11391 var handleObj, type;
11392 if ( types && types.preventDefault && types.handleObj ) {
11393 // ( event ) dispatched jQuery.Event
11394 handleObj = types.handleObj;
11395 jQuery( types.delegateTarget ).off(
11396 handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
11397 handleObj.selector,
11402 if ( typeof types === "object" ) {
11403 // ( types-object [, selector] )
11404 for ( type in types ) {
11405 this.off( type, selector, types[ type ] );
11409 if ( selector === false || typeof selector === "function" ) {
11410 // ( types [, fn] )
11412 selector = undefined;
11414 if ( fn === false ) {
11417 return this.each(function() {
11418 jQuery.event.remove( this, types, fn, selector );
11422 trigger: function( type, data ) {
11423 return this.each(function() {
11424 jQuery.event.trigger( type, data, this );
11427 triggerHandler: function( type, data ) {
11428 var elem = this[
0];
11430 return jQuery.event.trigger( type, data, elem, true );
11437 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^
>]*)\
/>/gi,
11438 rtagName = /<([\w:]+)/,
11439 rhtml = /<|&#?\w+;/,
11440 rnoInnerhtml = /<(?:script|style|link)/i,
11441 //
checked="checked" or checked
11442 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
11443 rscriptType = /^$|\/(?:java|ecma)script/i,
11444 rscriptTypeMasked = /^true\/(.*)/,
11445 rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)
>\s*$/g,
11447 // We have to close these tags to support XHTML (#
13200)
11451 option: [
1, "
<select multiple='multiple'
>", "</select>" ],
11453 thead: [ 1, "<table>", "</table>" ],
11454 col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
11455 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
11456 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
11458 _default: [ 0, "", "" ]
11462 wrapMap.optgroup = wrapMap.option;
11464 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
11465 wrapMap.th = wrapMap.td;
11467 // Support: 1.x compatibility
11468 // Manipulating tables requires a tbody
11469 function manipulationTarget( elem, content ) {
11470 return jQuery.nodeName( elem, "table
" ) &&
11471 jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr
" ) ?
11473 elem.getElementsByTagName("tbody
")[0] ||
11474 elem.appendChild( elem.ownerDocument.createElement("tbody
") ) :
11478 // Replace/restore the type attribute of script elements for safe DOM manipulation
11479 function disableScript( elem ) {
11480 elem.type = (elem.getAttribute("type
") !== null) + "/
" + elem.type;
11483 function restoreScript( elem ) {
11484 var match = rscriptTypeMasked.exec( elem.type );
11487 elem.type = match[ 1 ];
11489 elem.removeAttribute("type
");
11495 // Mark scripts as having already been evaluated
11496 function setGlobalEval( elems, refElements ) {
11500 for ( ; i < l; i++ ) {
11502 elems[ i ], "globalEval
", !refElements || data_priv.get( refElements[ i ], "globalEval
" )
11507 function cloneCopyEvent( src, dest ) {
11508 var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
11510 if ( dest.nodeType !== 1 ) {
11514 // 1. Copy private data: events, handlers, etc.
11515 if ( data_priv.hasData( src ) ) {
11516 pdataOld = data_priv.access( src );
11517 pdataCur = data_priv.set( dest, pdataOld );
11518 events = pdataOld.events;
11521 delete pdataCur.handle;
11522 pdataCur.events = {};
11524 for ( type in events ) {
11525 for ( i = 0, l = events[ type ].length; i < l; i++ ) {
11526 jQuery.event.add( dest, type, events[ type ][ i ] );
11532 // 2. Copy user data
11533 if ( data_user.hasData( src ) ) {
11534 udataOld = data_user.access( src );
11535 udataCur = jQuery.extend( {}, udataOld );
11537 data_user.set( dest, udataCur );
11541 function getAll( context, tag ) {
11542 var ret = context.getElementsByTagName ? context.getElementsByTagName( tag || "*
" ) :
11543 context.querySelectorAll ? context.querySelectorAll( tag || "*
" ) :
11546 return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
11547 jQuery.merge( [ context ], ret ) :
11551 // Support: IE >= 9
11552 function fixInput( src, dest ) {
11553 var nodeName = dest.nodeName.toLowerCase();
11555 // Fails to persist the checked state of a cloned checkbox or radio button.
11556 if ( nodeName === "input
" && rcheckableType.test( src.type ) ) {
11557 dest.checked = src.checked;
11559 // Fails to return the selected option to the default selected state when cloning options
11560 } else if ( nodeName === "input
" || nodeName === "textarea
" ) {
11561 dest.defaultValue = src.defaultValue;
11566 clone: function( elem, dataAndEvents, deepDataAndEvents ) {
11567 var i, l, srcElements, destElements,
11568 clone = elem.cloneNode( true ),
11569 inPage = jQuery.contains( elem.ownerDocument, elem );
11571 // Support: IE >= 9
11572 // Fix Cloning issues
11573 if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
11574 !jQuery.isXMLDoc( elem ) ) {
11576 // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
11577 destElements = getAll( clone );
11578 srcElements = getAll( elem );
11580 for ( i = 0, l = srcElements.length; i < l; i++ ) {
11581 fixInput( srcElements[ i ], destElements[ i ] );
11585 // Copy the events from the original to the clone
11586 if ( dataAndEvents ) {
11587 if ( deepDataAndEvents ) {
11588 srcElements = srcElements || getAll( elem );
11589 destElements = destElements || getAll( clone );
11591 for ( i = 0, l = srcElements.length; i < l; i++ ) {
11592 cloneCopyEvent( srcElements[ i ], destElements[ i ] );
11595 cloneCopyEvent( elem, clone );
11599 // Preserve script evaluation history
11600 destElements = getAll( clone, "script
" );
11601 if ( destElements.length > 0 ) {
11602 setGlobalEval( destElements, !inPage && getAll( elem, "script
" ) );
11605 // Return the cloned set
11609 buildFragment: function( elems, context, scripts, selection ) {
11610 var elem, tmp, tag, wrap, contains, j,
11611 fragment = context.createDocumentFragment(),
11616 for ( ; i < l; i++ ) {
11619 if ( elem || elem === 0 ) {
11621 // Add nodes directly
11622 if ( jQuery.type( elem ) === "object
" ) {
11623 // Support: QtWebKit
11624 // jQuery.merge because push.apply(_, arraylike) throws
11625 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
11627 // Convert non-html into a text node
11628 } else if ( !rhtml.test( elem ) ) {
11629 nodes.push( context.createTextNode( elem ) );
11631 // Convert html into DOM nodes
11633 tmp = tmp || fragment.appendChild( context.createElement("div
") );
11635 // Deserialize a standard representation
11636 tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
11637 wrap = wrapMap[ tag ] || wrapMap._default;
11638 tmp.innerHTML = wrap[ 1 ] + elem.replace( rxhtmlTag, "<$
1></$
2>" ) + wrap[ 2 ];
11640 // Descend through wrappers to the right content
11643 tmp = tmp.lastChild;
11646 // Support: QtWebKit
11647 // jQuery.merge because push.apply(_, arraylike) throws
11648 jQuery.merge( nodes, tmp.childNodes );
11650 // Remember the top-level container
11651 tmp = fragment.firstChild;
11654 // Support: Webkit, IE
11655 tmp.textContent = "";
11660 // Remove wrapper from fragment
11661 fragment.textContent = "";
11664 while ( (elem = nodes[ i++ ]) ) {
11666 // #4087 - If origin and destination elements are the same, and this is
11667 // that element, do not do anything
11668 if ( selection && jQuery.inArray( elem, selection ) !== -1 ) {
11672 contains = jQuery.contains( elem.ownerDocument, elem );
11674 // Append to fragment
11675 tmp = getAll( fragment.appendChild( elem ), "script
" );
11677 // Preserve script evaluation history
11679 setGlobalEval( tmp );
11682 // Capture executables
11685 while ( (elem = tmp[ j++ ]) ) {
11686 if ( rscriptType.test( elem.type || "" ) ) {
11687 scripts.push( elem );
11696 cleanData: function( elems ) {
11697 var data, elem, type, key,
11698 special = jQuery.event.special,
11701 for ( ; (elem = elems[ i ]) !== undefined; i++ ) {
11702 if ( jQuery.acceptData( elem ) ) {
11703 key = elem[ data_priv.expando ];
11705 if ( key && (data = data_priv.cache[ key ]) ) {
11706 if ( data.events ) {
11707 for ( type in data.events ) {
11708 if ( special[ type ] ) {
11709 jQuery.event.remove( elem, type );
11711 // This is a shortcut to avoid jQuery.event.remove's overhead
11713 jQuery.removeEvent( elem, type, data.handle );
11717 if ( data_priv.cache[ key ] ) {
11718 // Discard any remaining `private` data
11719 delete data_priv.cache[ key ];
11723 // Discard any remaining `user` data
11724 delete data_user.cache[ elem[ data_user.expando ] ];
11730 text: function( value ) {
11731 return access( this, function( value ) {
11732 return value === undefined ?
11733 jQuery.text( this ) :
11734 this.empty().each(function() {
11735 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
11736 this.textContent = value;
11739 }, null, value, arguments.length );
11742 append: function() {
11743 return this.domManip( arguments, function( elem ) {
11744 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
11745 var target = manipulationTarget( this, elem );
11746 target.appendChild( elem );
11751 prepend: function() {
11752 return this.domManip( arguments, function( elem ) {
11753 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
11754 var target = manipulationTarget( this, elem );
11755 target.insertBefore( elem, target.firstChild );
11760 before: function() {
11761 return this.domManip( arguments, function( elem ) {
11762 if ( this.parentNode ) {
11763 this.parentNode.insertBefore( elem, this );
11768 after: function() {
11769 return this.domManip( arguments, function( elem ) {
11770 if ( this.parentNode ) {
11771 this.parentNode.insertBefore( elem, this.nextSibling );
11776 remove: function( selector, keepData /* Internal Use Only */ ) {
11778 elems = selector ? jQuery.filter( selector, this ) : this,
11781 for ( ; (elem = elems[i]) != null; i++ ) {
11782 if ( !keepData && elem.nodeType === 1 ) {
11783 jQuery.cleanData( getAll( elem ) );
11786 if ( elem.parentNode ) {
11787 if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
11788 setGlobalEval( getAll( elem, "script
" ) );
11790 elem.parentNode.removeChild( elem );
11797 empty: function() {
11801 for ( ; (elem = this[i]) != null; i++ ) {
11802 if ( elem.nodeType === 1 ) {
11804 // Prevent memory leaks
11805 jQuery.cleanData( getAll( elem, false ) );
11807 // Remove any remaining nodes
11808 elem.textContent = "";
11815 clone: function( dataAndEvents, deepDataAndEvents ) {
11816 dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
11817 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
11819 return this.map(function() {
11820 return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
11824 html: function( value ) {
11825 return access( this, function( value ) {
11826 var elem = this[ 0 ] || {},
11830 if ( value === undefined && elem.nodeType === 1 ) {
11831 return elem.innerHTML;
11834 // See if we can take a shortcut and just use innerHTML
11835 if ( typeof value === "string
" && !rnoInnerhtml.test( value ) &&
11836 !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
11838 value = value.replace( rxhtmlTag, "<$
1></$
2>" );
11841 for ( ; i < l; i++ ) {
11842 elem = this[ i ] || {};
11844 // Remove element nodes and prevent memory leaks
11845 if ( elem.nodeType === 1 ) {
11846 jQuery.cleanData( getAll( elem, false ) );
11847 elem.innerHTML = value;
11853 // If using innerHTML throws an exception, use the fallback method
11858 this.empty().append( value );
11860 }, null, value, arguments.length );
11863 replaceWith: function() {
11864 var arg = arguments[ 0 ];
11866 // Make the changes, replacing each context element with the new content
11867 this.domManip( arguments, function( elem ) {
11868 arg = this.parentNode;
11870 jQuery.cleanData( getAll( this ) );
11873 arg.replaceChild( elem, this );
11877 // Force removal if there was no new content (e.g., from empty arguments)
11878 return arg && (arg.length || arg.nodeType) ? this : this.remove();
11881 detach: function( selector ) {
11882 return this.remove( selector, true );
11885 domManip: function( args, callback ) {
11887 // Flatten any nested arrays
11888 args = concat.apply( [], args );
11890 var fragment, first, scripts, hasScripts, node, doc,
11896 isFunction = jQuery.isFunction( value );
11898 // We can't cloneNode fragments that contain checked, in WebKit
11900 ( l > 1 && typeof value === "string
" &&
11901 !support.checkClone && rchecked.test( value ) ) ) {
11902 return this.each(function( index ) {
11903 var self = set.eq( index );
11904 if ( isFunction ) {
11905 args[ 0 ] = value.call( this, index, self.html() );
11907 self.domManip( args, callback );
11912 fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this );
11913 first = fragment.firstChild;
11915 if ( fragment.childNodes.length === 1 ) {
11920 scripts = jQuery.map( getAll( fragment, "script
" ), disableScript );
11921 hasScripts = scripts.length;
11923 // Use the original fragment for the last item instead of the first because it can end up
11924 // being emptied incorrectly in certain situations (#8070).
11925 for ( ; i < l; i++ ) {
11928 if ( i !== iNoClone ) {
11929 node = jQuery.clone( node, true, true );
11931 // Keep references to cloned scripts for later restoration
11932 if ( hasScripts ) {
11933 // Support: QtWebKit
11934 // jQuery.merge because push.apply(_, arraylike) throws
11935 jQuery.merge( scripts, getAll( node, "script
" ) );
11939 callback.call( this[ i ], node, i );
11942 if ( hasScripts ) {
11943 doc = scripts[ scripts.length - 1 ].ownerDocument;
11945 // Reenable scripts
11946 jQuery.map( scripts, restoreScript );
11948 // Evaluate executable scripts on first document insertion
11949 for ( i = 0; i < hasScripts; i++ ) {
11950 node = scripts[ i ];
11951 if ( rscriptType.test( node.type || "" ) &&
11952 !data_priv.access( node, "globalEval
" ) && jQuery.contains( doc, node ) ) {
11955 // Optional AJAX dependency, but won't run scripts if not present
11956 if ( jQuery._evalUrl ) {
11957 jQuery._evalUrl( node.src );
11960 jQuery.globalEval( node.textContent.replace( rcleanScript, "" ) );
11973 appendTo: "append
",
11974 prependTo: "prepend
",
11975 insertBefore: "before
",
11976 insertAfter: "after
",
11977 replaceAll: "replaceWith
"
11978 }, function( name, original ) {
11979 jQuery.fn[ name ] = function( selector ) {
11982 insert = jQuery( selector ),
11983 last = insert.length - 1,
11986 for ( ; i <= last; i++ ) {
11987 elems = i === last ? this : this.clone( true );
11988 jQuery( insert[ i ] )[ original ]( elems );
11990 // Support: QtWebKit
11991 // .get() because push.apply(_, arraylike) throws
11992 push.apply( ret, elems.get() );
11995 return this.pushStack( ret );
12004 * Retrieve the actual display of a element
12005 * @param {String} name nodeName of the element
12006 * @param {Object} doc Document object
12008 // Called only from within defaultDisplay
12009 function actualDisplay( name, doc ) {
12011 elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
12013 // getDefaultComputedStyle might be reliably used only on attached element
12014 display = window.getDefaultComputedStyle && ( style = window.getDefaultComputedStyle( elem[ 0 ] ) ) ?
12016 // Use of this method is a temporary fix (more like optmization) until something better comes along,
12017 // since it was removed from specification and supported only in FF
12018 style.display : jQuery.css( elem[ 0 ], "display
" );
12020 // We don't have any data stored on the element,
12021 // so use "detach
" method as fast way to get rid of the element
12028 * Try to determine the default display value of an element
12029 * @param {String} nodeName
12031 function defaultDisplay( nodeName ) {
12032 var doc = document,
12033 display = elemdisplay[ nodeName ];
12036 display = actualDisplay( nodeName, doc );
12038 // If the simple way fails, read from inside an iframe
12039 if ( display === "none
" || !display ) {
12041 // Use the already-created iframe if possible
12042 iframe = (iframe || jQuery( "<iframe frameborder='
0' width='
0' height='
0'
/>" )).appendTo( doc.documentElement );
12044 // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
12045 doc = iframe[ 0 ].contentDocument;
12051 display = actualDisplay( nodeName, doc );
12055 // Store the correct default display
12056 elemdisplay[ nodeName ] = display;
12061 var rmargin = (/^margin/);
12063 var rnumnonpx = new RegExp( "^(
" + pnum + ")(?!px)[a-z%]+$
", "i
" );
12065 var getStyles = function( elem ) {
12066 return elem.ownerDocument.defaultView.getComputedStyle( elem, null );
12071 function curCSS( elem, name, computed ) {
12072 var width, minWidth, maxWidth, ret,
12073 style = elem.style;
12075 computed = computed || getStyles( elem );
12078 // getPropertyValue is only needed for .css('filter') in IE9, see #12537
12080 ret = computed.getPropertyValue( name ) || computed[ name ];
12085 if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
12086 ret = jQuery.style( elem, name );
12089 // Support: iOS < 6
12090 // A tribute to the "awesome hack by Dean Edwards
"
12091 // iOS < 6 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
12092 // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
12093 if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
12095 // Remember the original values
12096 width = style.width;
12097 minWidth = style.minWidth;
12098 maxWidth = style.maxWidth;
12100 // Put in the new values to get a computed value out
12101 style.minWidth = style.maxWidth = style.width = ret;
12102 ret = computed.width;
12104 // Revert the changed values
12105 style.width = width;
12106 style.minWidth = minWidth;
12107 style.maxWidth = maxWidth;
12111 return ret !== undefined ?
12113 // IE returns zIndex value as an integer.
12119 function addGetHookIf( conditionFn, hookFn ) {
12120 // Define the hook, we'll check on the first run if it's really needed.
12123 if ( conditionFn() ) {
12124 // Hook not needed (or it's not possible to use it due to missing dependency),
12126 // Since there are no other hooks for marginRight, remove the whole object.
12131 // Hook needed; redefine it so that the support test is not executed again.
12133 return (this.get = hookFn).apply( this, arguments );
12140 var pixelPositionVal, boxSizingReliableVal,
12141 docElem = document.documentElement,
12142 container = document.createElement( "div
" ),
12143 div = document.createElement( "div
" );
12145 if ( !div.style ) {
12149 div.style.backgroundClip = "content-box
";
12150 div.cloneNode( true ).style.backgroundClip = "";
12151 support.clearCloneStyle = div.style.backgroundClip === "content-box
";
12153 container.style.cssText = "border:
0;width:
0;height:
0;top:
0;left:-
9999px;margin-top:
1px;
" +
12154 "position:absolute
";
12155 container.appendChild( div );
12157 // Executing both pixelPosition & boxSizingReliable tests require only one layout
12158 // so they're executed at the same time to save the second computation.
12159 function computePixelPositionAndBoxSizingReliable() {
12160 div.style.cssText =
12161 // Support: Firefox<29, Android 2.3
12162 // Vendor-prefix box-sizing
12163 "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;
" +
12164 "box-sizing:border-box;display:block;margin-top:
1%;top:
1%;
" +
12165 "border:
1px;padding:
1px;width:
4px;position:absolute
";
12166 div.innerHTML = "";
12167 docElem.appendChild( container );
12169 var divStyle = window.getComputedStyle( div, null );
12170 pixelPositionVal = divStyle.top !== "1%
";
12171 boxSizingReliableVal = divStyle.width === "4px
";
12173 docElem.removeChild( container );
12176 // Support: node.js jsdom
12177 // Don't assume that getComputedStyle is a property of the global object
12178 if ( window.getComputedStyle ) {
12179 jQuery.extend( support, {
12180 pixelPosition: function() {
12181 // This test is executed only once but we still do memoizing
12182 // since we can use the boxSizingReliable pre-computing.
12183 // No need to check if the test was already performed, though.
12184 computePixelPositionAndBoxSizingReliable();
12185 return pixelPositionVal;
12187 boxSizingReliable: function() {
12188 if ( boxSizingReliableVal == null ) {
12189 computePixelPositionAndBoxSizingReliable();
12191 return boxSizingReliableVal;
12193 reliableMarginRight: function() {
12194 // Support: Android 2.3
12195 // Check if div with explicit width and no margin-right incorrectly
12196 // gets computed margin-right based on width of container. (#3333)
12197 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
12198 // This support function is only executed once so no memoizing is needed.
12200 marginDiv = div.appendChild( document.createElement( "div
" ) );
12202 // Reset CSS: box-sizing; display; margin; border; padding
12203 marginDiv.style.cssText = div.style.cssText =
12204 // Support: Firefox<29, Android 2.3
12205 // Vendor-prefix box-sizing
12206 "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;
" +
12207 "box-sizing:content-box;display:block;margin:
0;border:
0;padding:
0";
12208 marginDiv.style.marginRight = marginDiv.style.width = "0";
12209 div.style.width = "1px
";
12210 docElem.appendChild( container );
12212 ret = !parseFloat( window.getComputedStyle( marginDiv, null ).marginRight );
12214 docElem.removeChild( container );
12223 // A method for quickly swapping in/out CSS properties to get correct calculations.
12224 jQuery.swap = function( elem, options, callback, args ) {
12228 // Remember the old values, and insert the new ones
12229 for ( name in options ) {
12230 old[ name ] = elem.style[ name ];
12231 elem.style[ name ] = options[ name ];
12234 ret = callback.apply( elem, args || [] );
12236 // Revert the old values
12237 for ( name in options ) {
12238 elem.style[ name ] = old[ name ];
12246 // swappable if display is none or starts with table except "table
", "table-cell
", or "table-caption
"
12247 // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
12248 rdisplayswap = /^(none|table(?!-c[ea]).+)/,
12249 rnumsplit = new RegExp( "^(
" + pnum + ")(.*)$
", "i
" ),
12250 rrelNum = new RegExp( "^([+-])=(
" + pnum + ")
", "i
" ),
12252 cssShow = { position: "absolute
", visibility: "hidden
", display: "block
" },
12253 cssNormalTransform = {
12254 letterSpacing: "0",
12258 cssPrefixes = [ "Webkit
", "O
", "Moz
", "ms
" ];
12260 // return a css property mapped to a potentially vendor prefixed property
12261 function vendorPropName( style, name ) {
12263 // shortcut for names that are not vendor prefixed
12264 if ( name in style ) {
12268 // check for vendor prefixed names
12269 var capName = name[0].toUpperCase() + name.slice(1),
12271 i = cssPrefixes.length;
12274 name = cssPrefixes[ i ] + capName;
12275 if ( name in style ) {
12283 function setPositiveNumber( elem, value, subtract ) {
12284 var matches = rnumsplit.exec( value );
12286 // Guard against undefined "subtract
", e.g., when used as in cssHooks
12287 Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px
" ) :
12291 function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
12292 var i = extra === ( isBorderBox ? "border
" : "content
" ) ?
12293 // If we already have the right measurement, avoid augmentation
12295 // Otherwise initialize for horizontal or vertical properties
12296 name === "width
" ? 1 : 0,
12300 for ( ; i < 4; i += 2 ) {
12301 // both box models exclude margin, so add it if we want it
12302 if ( extra === "margin
" ) {
12303 val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
12306 if ( isBorderBox ) {
12307 // border-box includes padding, so remove it if we want content
12308 if ( extra === "content
" ) {
12309 val -= jQuery.css( elem, "padding
" + cssExpand[ i ], true, styles );
12312 // at this point, extra isn't border nor margin, so remove border
12313 if ( extra !== "margin
" ) {
12314 val -= jQuery.css( elem, "border
" + cssExpand[ i ] + "Width
", true, styles );
12317 // at this point, extra isn't content, so add padding
12318 val += jQuery.css( elem, "padding
" + cssExpand[ i ], true, styles );
12320 // at this point, extra isn't content nor padding, so add border
12321 if ( extra !== "padding
" ) {
12322 val += jQuery.css( elem, "border
" + cssExpand[ i ] + "Width
", true, styles );
12330 function getWidthOrHeight( elem, name, extra ) {
12332 // Start with offset property, which is equivalent to the border-box value
12333 var valueIsBorderBox = true,
12334 val = name === "width
" ? elem.offsetWidth : elem.offsetHeight,
12335 styles = getStyles( elem ),
12336 isBorderBox = jQuery.css( elem, "boxSizing
", false, styles ) === "border-box
";
12338 // some non-html elements return undefined for offsetWidth, so check for null/undefined
12339 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
12340 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
12341 if ( val <= 0 || val == null ) {
12342 // Fall back to computed then uncomputed css if necessary
12343 val = curCSS( elem, name, styles );
12344 if ( val < 0 || val == null ) {
12345 val = elem.style[ name ];
12348 // Computed unit is not pixels. Stop here and return.
12349 if ( rnumnonpx.test(val) ) {
12353 // we need the check for style in case a browser which returns unreliable values
12354 // for getComputedStyle silently falls back to the reliable elem.style
12355 valueIsBorderBox = isBorderBox &&
12356 ( support.boxSizingReliable() || val === elem.style[ name ] );
12358 // Normalize "", auto, and prepare for extra
12359 val = parseFloat( val ) || 0;
12362 // use the active box-sizing model to add/subtract irrelevant styles
12364 augmentWidthOrHeight(
12367 extra || ( isBorderBox ? "border
" : "content
" ),
12374 function showHide( elements, show ) {
12375 var display, elem, hidden,
12378 length = elements.length;
12380 for ( ; index < length; index++ ) {
12381 elem = elements[ index ];
12382 if ( !elem.style ) {
12386 values[ index ] = data_priv.get( elem, "olddisplay
" );
12387 display = elem.style.display;
12389 // Reset the inline display of this element to learn if it is
12390 // being hidden by cascaded rules or not
12391 if ( !values[ index ] && display === "none
" ) {
12392 elem.style.display = "";
12395 // Set elements which have been overridden with display: none
12396 // in a stylesheet to whatever the default browser style is
12397 // for such an element
12398 if ( elem.style.display === "" && isHidden( elem ) ) {
12399 values[ index ] = data_priv.access( elem, "olddisplay
", defaultDisplay(elem.nodeName) );
12402 hidden = isHidden( elem );
12404 if ( display !== "none
" || !hidden ) {
12405 data_priv.set( elem, "olddisplay
", hidden ? display : jQuery.css( elem, "display
" ) );
12410 // Set the display of most of the elements in a second loop
12411 // to avoid the constant reflow
12412 for ( index = 0; index < length; index++ ) {
12413 elem = elements[ index ];
12414 if ( !elem.style ) {
12417 if ( !show || elem.style.display === "none
" || elem.style.display === "" ) {
12418 elem.style.display = show ? values[ index ] || "" : "none
";
12426 // Add in style property hooks for overriding the default
12427 // behavior of getting and setting a style property
12430 get: function( elem, computed ) {
12432 // We should always get a number back from opacity
12433 var ret = curCSS( elem, "opacity
" );
12434 return ret === "" ? "1" : ret;
12440 // Don't automatically add "px
" to these possibly-unitless properties
12442 "columnCount
": true,
12443 "fillOpacity
": true,
12445 "flexShrink
": true,
12446 "fontWeight
": true,
12447 "lineHeight
": true,
12456 // Add in properties whose names you wish to fix before
12457 // setting or getting the value
12459 // normalize float css property
12460 "float
": "cssFloat
"
12463 // Get and set the style property on a DOM Node
12464 style: function( elem, name, value, extra ) {
12465 // Don't set styles on text and comment nodes
12466 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
12470 // Make sure that we're working with the right name
12471 var ret, type, hooks,
12472 origName = jQuery.camelCase( name ),
12473 style = elem.style;
12475 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
12477 // gets hook for the prefixed version
12478 // followed by the unprefixed version
12479 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
12481 // Check if we're setting a value
12482 if ( value !== undefined ) {
12483 type = typeof value;
12485 // convert relative number strings (+= or -=) to relative numbers. #7345
12486 if ( type === "string
" && (ret = rrelNum.exec( value )) ) {
12487 value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
12492 // Make sure that null and NaN values aren't set. See: #7116
12493 if ( value == null || value !== value ) {
12497 // If a number was passed in, add 'px' to the (except for certain CSS properties)
12498 if ( type === "number
" && !jQuery.cssNumber[ origName ] ) {
12502 // Fixes #8908, it can be done more correctly by specifying setters in cssHooks,
12503 // but it would mean to define eight (for every problematic property) identical functions
12504 if ( !support.clearCloneStyle && value === "" && name.indexOf( "background
" ) === 0 ) {
12505 style[ name ] = "inherit
";
12508 // If a hook was provided, use that value, otherwise just set the specified value
12509 if ( !hooks || !("set
" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
12510 style[ name ] = value;
12514 // If a hook was provided get the non-computed value from there
12515 if ( hooks && "get
" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
12519 // Otherwise just get the value from the style object
12520 return style[ name ];
12524 css: function( elem, name, extra, styles ) {
12525 var val, num, hooks,
12526 origName = jQuery.camelCase( name );
12528 // Make sure that we're working with the right name
12529 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
12531 // gets hook for the prefixed version
12532 // followed by the unprefixed version
12533 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
12535 // If a hook was provided get the computed value from there
12536 if ( hooks && "get
" in hooks ) {
12537 val = hooks.get( elem, true, extra );
12540 // Otherwise, if a way to get the computed value exists, use that
12541 if ( val === undefined ) {
12542 val = curCSS( elem, name, styles );
12545 //convert "normal
" to computed value
12546 if ( val === "normal
" && name in cssNormalTransform ) {
12547 val = cssNormalTransform[ name ];
12550 // Return, converting to number if forced or a qualifier was provided and val looks numeric
12551 if ( extra === "" || extra ) {
12552 num = parseFloat( val );
12553 return extra === true || jQuery.isNumeric( num ) ? num || 0 : val;
12559 jQuery.each([ "height
", "width
" ], function( i, name ) {
12560 jQuery.cssHooks[ name ] = {
12561 get: function( elem, computed, extra ) {
12563 // certain elements can have dimension info if we invisibly show them
12564 // however, it must have a current display style that would benefit from this
12565 return rdisplayswap.test( jQuery.css( elem, "display
" ) ) && elem.offsetWidth === 0 ?
12566 jQuery.swap( elem, cssShow, function() {
12567 return getWidthOrHeight( elem, name, extra );
12569 getWidthOrHeight( elem, name, extra );
12573 set: function( elem, value, extra ) {
12574 var styles = extra && getStyles( elem );
12575 return setPositiveNumber( elem, value, extra ?
12576 augmentWidthOrHeight(
12580 jQuery.css( elem, "boxSizing
", false, styles ) === "border-box
",
12588 // Support: Android 2.3
12589 jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
12590 function( elem, computed ) {
12592 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
12593 // Work around by temporarily setting element display to inline-block
12594 return jQuery.swap( elem, { "display
": "inline-block
" },
12595 curCSS, [ elem, "marginRight
" ] );
12600 // These hooks are used by animate to expand properties
12605 }, function( prefix, suffix ) {
12606 jQuery.cssHooks[ prefix + suffix ] = {
12607 expand: function( value ) {
12611 // assumes a single number if not a string
12612 parts = typeof value === "string
" ? value.split(" ") : [ value ];
12614 for ( ; i < 4; i++ ) {
12615 expanded[ prefix + cssExpand[ i ] + suffix ] =
12616 parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
12623 if ( !rmargin.test( prefix ) ) {
12624 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
12629 css: function( name, value ) {
12630 return access( this, function( elem, name, value ) {
12635 if ( jQuery.isArray( name ) ) {
12636 styles = getStyles( elem );
12639 for ( ; i < len; i++ ) {
12640 map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
12646 return value !== undefined ?
12647 jQuery.style( elem, name, value ) :
12648 jQuery.css( elem, name );
12649 }, name, value, arguments.length > 1 );
12652 return showHide( this, true );
12655 return showHide( this );
12657 toggle: function( state ) {
12658 if ( typeof state === "boolean
" ) {
12659 return state ? this.show() : this.hide();
12662 return this.each(function() {
12663 if ( isHidden( this ) ) {
12664 jQuery( this ).show();
12666 jQuery( this ).hide();
12673 function Tween( elem, options, prop, end, easing ) {
12674 return new Tween.prototype.init( elem, options, prop, end, easing );
12676 jQuery.Tween = Tween;
12678 Tween.prototype = {
12679 constructor: Tween,
12680 init: function( elem, options, prop, end, easing, unit ) {
12683 this.easing = easing || "swing
";
12684 this.options = options;
12685 this.start = this.now = this.cur();
12687 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px
" );
12690 var hooks = Tween.propHooks[ this.prop ];
12692 return hooks && hooks.get ?
12693 hooks.get( this ) :
12694 Tween.propHooks._default.get( this );
12696 run: function( percent ) {
12698 hooks = Tween.propHooks[ this.prop ];
12700 if ( this.options.duration ) {
12701 this.pos = eased = jQuery.easing[ this.easing ](
12702 percent, this.options.duration * percent, 0, 1, this.options.duration
12705 this.pos = eased = percent;
12707 this.now = ( this.end - this.start ) * eased + this.start;
12709 if ( this.options.step ) {
12710 this.options.step.call( this.elem, this.now, this );
12713 if ( hooks && hooks.set ) {
12716 Tween.propHooks._default.set( this );
12722 Tween.prototype.init.prototype = Tween.prototype;
12724 Tween.propHooks = {
12726 get: function( tween ) {
12729 if ( tween.elem[ tween.prop ] != null &&
12730 (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
12731 return tween.elem[ tween.prop ];
12734 // passing an empty string as a 3rd parameter to .css will automatically
12735 // attempt a parseFloat and fallback to a string if the parse fails
12736 // so, simple values such as "10px
" are parsed to Float.
12737 // complex values such as "rotate(
1rad)
" are returned as is.
12738 result = jQuery.css( tween.elem, tween.prop, "" );
12739 // Empty strings, null, undefined and "auto
" are converted to 0.
12740 return !result || result === "auto
" ? 0 : result;
12742 set: function( tween ) {
12743 // use step hook for back compat - use cssHook if its there - use .style if its
12744 // available and use plain properties where available
12745 if ( jQuery.fx.step[ tween.prop ] ) {
12746 jQuery.fx.step[ tween.prop ]( tween );
12747 } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
12748 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
12750 tween.elem[ tween.prop ] = tween.now;
12757 // Panic based approach to setting things on disconnected nodes
12759 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
12760 set: function( tween ) {
12761 if ( tween.elem.nodeType && tween.elem.parentNode ) {
12762 tween.elem[ tween.prop ] = tween.now;
12768 linear: function( p ) {
12771 swing: function( p ) {
12772 return 0.5 - Math.cos( p * Math.PI ) / 2;
12776 jQuery.fx = Tween.prototype.init;
12778 // Back Compat <1.8 extension point
12779 jQuery.fx.step = {};
12786 rfxtypes = /^(?:toggle|show|hide)$/,
12787 rfxnum = new RegExp( "^(?:([+-])=|)(
" + pnum + ")([a-z%]*)$
", "i
" ),
12788 rrun = /queueHooks$/,
12789 animationPrefilters = [ defaultPrefilter ],
12791 "*
": [ function( prop, value ) {
12792 var tween = this.createTween( prop, value ),
12793 target = tween.cur(),
12794 parts = rfxnum.exec( value ),
12795 unit = parts && parts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px
" ),
12797 // Starting value computation is required for potential unit mismatches
12798 start = ( jQuery.cssNumber[ prop ] || unit !== "px
" && +target ) &&
12799 rfxnum.exec( jQuery.css( tween.elem, prop ) ),
12801 maxIterations = 20;
12803 if ( start && start[ 3 ] !== unit ) {
12804 // Trust units reported by jQuery.css
12805 unit = unit || start[ 3 ];
12807 // Make sure we update the tween properties later on
12808 parts = parts || [];
12810 // Iteratively approximate from a nonzero starting point
12811 start = +target || 1;
12814 // If previous iteration zeroed out, double until we get *something*
12815 // Use a string for doubling factor so we don't accidentally see scale as unchanged below
12816 scale = scale || ".5";
12818 // Adjust and apply
12819 start = start / scale;
12820 jQuery.style( tween.elem, prop, start + unit );
12822 // Update scale, tolerating zero or NaN from tween.cur()
12823 // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
12824 } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
12827 // Update tween properties
12829 start = tween.start = +start || +target || 0;
12831 // If a +=/-= token was provided, we're doing a relative animation
12832 tween.end = parts[ 1 ] ?
12833 start + ( parts[ 1 ] + 1 ) * parts[ 2 ] :
12841 // Animations created synchronously will run synchronously
12842 function createFxNow() {
12843 setTimeout(function() {
12846 return ( fxNow = jQuery.now() );
12849 // Generate parameters to create a standard animation
12850 function genFx( type, includeWidth ) {
12853 attrs = { height: type };
12855 // if we include width, step value is 1 to do all cssExpand values,
12856 // if we don't include width, step value is 2 to skip over Left and Right
12857 includeWidth = includeWidth ? 1 : 0;
12858 for ( ; i < 4 ; i += 2 - includeWidth ) {
12859 which = cssExpand[ i ];
12860 attrs[ "margin
" + which ] = attrs[ "padding
" + which ] = type;
12863 if ( includeWidth ) {
12864 attrs.opacity = attrs.width = type;
12870 function createTween( value, prop, animation ) {
12872 collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*
" ] ),
12874 length = collection.length;
12875 for ( ; index < length; index++ ) {
12876 if ( (tween = collection[ index ].call( animation, prop, value )) ) {
12878 // we're done with this property
12884 function defaultPrefilter( elem, props, opts ) {
12885 /* jshint validthis: true */
12886 var prop, value, toggle, tween, hooks, oldfire, display, checkDisplay,
12889 style = elem.style,
12890 hidden = elem.nodeType && isHidden( elem ),
12891 dataShow = data_priv.get( elem, "fxshow
" );
12893 // handle queue: false promises
12894 if ( !opts.queue ) {
12895 hooks = jQuery._queueHooks( elem, "fx
" );
12896 if ( hooks.unqueued == null ) {
12897 hooks.unqueued = 0;
12898 oldfire = hooks.empty.fire;
12899 hooks.empty.fire = function() {
12900 if ( !hooks.unqueued ) {
12907 anim.always(function() {
12908 // doing this makes sure that the complete handler will be called
12909 // before this completes
12910 anim.always(function() {
12912 if ( !jQuery.queue( elem, "fx
" ).length ) {
12913 hooks.empty.fire();
12919 // height/width overflow pass
12920 if ( elem.nodeType === 1 && ( "height
" in props || "width
" in props ) ) {
12921 // Make sure that nothing sneaks out
12922 // Record all 3 overflow attributes because IE9-10 do not
12923 // change the overflow attribute when overflowX and
12924 // overflowY are set to the same value
12925 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
12927 // Set display property to inline-block for height/width
12928 // animations on inline elements that are having width/height animated
12929 display = jQuery.css( elem, "display
" );
12931 // Test default display if display is currently "none
"
12932 checkDisplay = display === "none
" ?
12933 data_priv.get( elem, "olddisplay
" ) || defaultDisplay( elem.nodeName ) : display;
12935 if ( checkDisplay === "inline
" && jQuery.css( elem, "float
" ) === "none
" ) {
12936 style.display = "inline-block
";
12940 if ( opts.overflow ) {
12941 style.overflow = "hidden
";
12942 anim.always(function() {
12943 style.overflow = opts.overflow[ 0 ];
12944 style.overflowX = opts.overflow[ 1 ];
12945 style.overflowY = opts.overflow[ 2 ];
12950 for ( prop in props ) {
12951 value = props[ prop ];
12952 if ( rfxtypes.exec( value ) ) {
12953 delete props[ prop ];
12954 toggle = toggle || value === "toggle
";
12955 if ( value === ( hidden ? "hide
" : "show
" ) ) {
12957 // 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
12958 if ( value === "show
" && dataShow && dataShow[ prop ] !== undefined ) {
12964 orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
12966 // Any non-fx value stops us from restoring the original display value
12968 display = undefined;
12972 if ( !jQuery.isEmptyObject( orig ) ) {
12974 if ( "hidden
" in dataShow ) {
12975 hidden = dataShow.hidden;
12978 dataShow = data_priv.access( elem, "fxshow
", {} );
12981 // store state if its toggle - enables .stop().toggle() to "reverse
"
12983 dataShow.hidden = !hidden;
12986 jQuery( elem ).show();
12988 anim.done(function() {
12989 jQuery( elem ).hide();
12992 anim.done(function() {
12995 data_priv.remove( elem, "fxshow
" );
12996 for ( prop in orig ) {
12997 jQuery.style( elem, prop, orig[ prop ] );
13000 for ( prop in orig ) {
13001 tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
13003 if ( !( prop in dataShow ) ) {
13004 dataShow[ prop ] = tween.start;
13006 tween.end = tween.start;
13007 tween.start = prop === "width
" || prop === "height
" ? 1 : 0;
13012 // If this is a noop like .hide().hide(), restore an overwritten display value
13013 } else if ( (display === "none
" ? defaultDisplay( elem.nodeName ) : display) === "inline
" ) {
13014 style.display = display;
13018 function propFilter( props, specialEasing ) {
13019 var index, name, easing, value, hooks;
13021 // camelCase, specialEasing and expand cssHook pass
13022 for ( index in props ) {
13023 name = jQuery.camelCase( index );
13024 easing = specialEasing[ name ];
13025 value = props[ index ];
13026 if ( jQuery.isArray( value ) ) {
13027 easing = value[ 1 ];
13028 value = props[ index ] = value[ 0 ];
13031 if ( index !== name ) {
13032 props[ name ] = value;
13033 delete props[ index ];
13036 hooks = jQuery.cssHooks[ name ];
13037 if ( hooks && "expand
" in hooks ) {
13038 value = hooks.expand( value );
13039 delete props[ name ];
13041 // not quite $.extend, this wont overwrite keys already present.
13042 // also - reusing 'index' from above because we have the correct "name
"
13043 for ( index in value ) {
13044 if ( !( index in props ) ) {
13045 props[ index ] = value[ index ];
13046 specialEasing[ index ] = easing;
13050 specialEasing[ name ] = easing;
13055 function Animation( elem, properties, options ) {
13059 length = animationPrefilters.length,
13060 deferred = jQuery.Deferred().always( function() {
13061 // don't match elem in the :animated selector
13064 tick = function() {
13068 var currentTime = fxNow || createFxNow(),
13069 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
13070 // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
13071 temp = remaining / animation.duration || 0,
13072 percent = 1 - temp,
13074 length = animation.tweens.length;
13076 for ( ; index < length ; index++ ) {
13077 animation.tweens[ index ].run( percent );
13080 deferred.notifyWith( elem, [ animation, percent, remaining ]);
13082 if ( percent < 1 && length ) {
13085 deferred.resolveWith( elem, [ animation ] );
13089 animation = deferred.promise({
13091 props: jQuery.extend( {}, properties ),
13092 opts: jQuery.extend( true, { specialEasing: {} }, options ),
13093 originalProperties: properties,
13094 originalOptions: options,
13095 startTime: fxNow || createFxNow(),
13096 duration: options.duration,
13098 createTween: function( prop, end ) {
13099 var tween = jQuery.Tween( elem, animation.opts, prop, end,
13100 animation.opts.specialEasing[ prop ] || animation.opts.easing );
13101 animation.tweens.push( tween );
13104 stop: function( gotoEnd ) {
13106 // if we are going to the end, we want to run all the tweens
13107 // otherwise we skip this part
13108 length = gotoEnd ? animation.tweens.length : 0;
13113 for ( ; index < length ; index++ ) {
13114 animation.tweens[ index ].run( 1 );
13117 // resolve when we played the last frame
13118 // otherwise, reject
13120 deferred.resolveWith( elem, [ animation, gotoEnd ] );
13122 deferred.rejectWith( elem, [ animation, gotoEnd ] );
13127 props = animation.props;
13129 propFilter( props, animation.opts.specialEasing );
13131 for ( ; index < length ; index++ ) {
13132 result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
13138 jQuery.map( props, createTween, animation );
13140 if ( jQuery.isFunction( animation.opts.start ) ) {
13141 animation.opts.start.call( elem, animation );
13145 jQuery.extend( tick, {
13148 queue: animation.opts.queue
13152 // attach callbacks from options
13153 return animation.progress( animation.opts.progress )
13154 .done( animation.opts.done, animation.opts.complete )
13155 .fail( animation.opts.fail )
13156 .always( animation.opts.always );
13159 jQuery.Animation = jQuery.extend( Animation, {
13161 tweener: function( props, callback ) {
13162 if ( jQuery.isFunction( props ) ) {
13166 props = props.split(" ");
13171 length = props.length;
13173 for ( ; index < length ; index++ ) {
13174 prop = props[ index ];
13175 tweeners[ prop ] = tweeners[ prop ] || [];
13176 tweeners[ prop ].unshift( callback );
13180 prefilter: function( callback, prepend ) {
13182 animationPrefilters.unshift( callback );
13184 animationPrefilters.push( callback );
13189 jQuery.speed = function( speed, easing, fn ) {
13190 var opt = speed && typeof speed === "object
" ? jQuery.extend( {}, speed ) : {
13191 complete: fn || !fn && easing ||
13192 jQuery.isFunction( speed ) && speed,
13194 easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
13197 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number
" ? opt.duration :
13198 opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
13200 // normalize opt.queue - true/undefined/null -> "fx
"
13201 if ( opt.queue == null || opt.queue === true ) {
13206 opt.old = opt.complete;
13208 opt.complete = function() {
13209 if ( jQuery.isFunction( opt.old ) ) {
13210 opt.old.call( this );
13214 jQuery.dequeue( this, opt.queue );
13222 fadeTo: function( speed, to, easing, callback ) {
13224 // show any hidden elements after setting opacity to 0
13225 return this.filter( isHidden ).css( "opacity
", 0 ).show()
13227 // animate to the value specified
13228 .end().animate({ opacity: to }, speed, easing, callback );
13230 animate: function( prop, speed, easing, callback ) {
13231 var empty = jQuery.isEmptyObject( prop ),
13232 optall = jQuery.speed( speed, easing, callback ),
13233 doAnimation = function() {
13234 // Operate on a copy of prop so per-property easing won't be lost
13235 var anim = Animation( this, jQuery.extend( {}, prop ), optall );
13237 // Empty animations, or finishing resolves immediately
13238 if ( empty || data_priv.get( this, "finish
" ) ) {
13242 doAnimation.finish = doAnimation;
13244 return empty || optall.queue === false ?
13245 this.each( doAnimation ) :
13246 this.queue( optall.queue, doAnimation );
13248 stop: function( type, clearQueue, gotoEnd ) {
13249 var stopQueue = function( hooks ) {
13250 var stop = hooks.stop;
13255 if ( typeof type !== "string
" ) {
13256 gotoEnd = clearQueue;
13260 if ( clearQueue && type !== false ) {
13261 this.queue( type || "fx
", [] );
13264 return this.each(function() {
13265 var dequeue = true,
13266 index = type != null && type + "queueHooks
",
13267 timers = jQuery.timers,
13268 data = data_priv.get( this );
13271 if ( data[ index ] && data[ index ].stop ) {
13272 stopQueue( data[ index ] );
13275 for ( index in data ) {
13276 if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
13277 stopQueue( data[ index ] );
13282 for ( index = timers.length; index--; ) {
13283 if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
13284 timers[ index ].anim.stop( gotoEnd );
13286 timers.splice( index, 1 );
13290 // start the next in the queue if the last step wasn't forced
13291 // timers currently will call their complete callbacks, which will dequeue
13292 // but only if they were gotoEnd
13293 if ( dequeue || !gotoEnd ) {
13294 jQuery.dequeue( this, type );
13298 finish: function( type ) {
13299 if ( type !== false ) {
13300 type = type || "fx
";
13302 return this.each(function() {
13304 data = data_priv.get( this ),
13305 queue = data[ type + "queue
" ],
13306 hooks = data[ type + "queueHooks
" ],
13307 timers = jQuery.timers,
13308 length = queue ? queue.length : 0;
13310 // enable finishing flag on private data
13311 data.finish = true;
13313 // empty the queue first
13314 jQuery.queue( this, type, [] );
13316 if ( hooks && hooks.stop ) {
13317 hooks.stop.call( this, true );
13320 // look for any active animations, and finish them
13321 for ( index = timers.length; index--; ) {
13322 if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
13323 timers[ index ].anim.stop( true );
13324 timers.splice( index, 1 );
13328 // look for any animations in the old queue and finish them
13329 for ( index = 0; index < length; index++ ) {
13330 if ( queue[ index ] && queue[ index ].finish ) {
13331 queue[ index ].finish.call( this );
13335 // turn off finishing flag
13336 delete data.finish;
13341 jQuery.each([ "toggle
", "show
", "hide
" ], function( i, name ) {
13342 var cssFn = jQuery.fn[ name ];
13343 jQuery.fn[ name ] = function( speed, easing, callback ) {
13344 return speed == null || typeof speed === "boolean
" ?
13345 cssFn.apply( this, arguments ) :
13346 this.animate( genFx( name, true ), speed, easing, callback );
13350 // Generate shortcuts for custom animations
13352 slideDown: genFx("show
"),
13353 slideUp: genFx("hide
"),
13354 slideToggle: genFx("toggle
"),
13355 fadeIn: { opacity: "show
" },
13356 fadeOut: { opacity: "hide
" },
13357 fadeToggle: { opacity: "toggle
" }
13358 }, function( name, props ) {
13359 jQuery.fn[ name ] = function( speed, easing, callback ) {
13360 return this.animate( props, speed, easing, callback );
13364 jQuery.timers = [];
13365 jQuery.fx.tick = function() {
13368 timers = jQuery.timers;
13370 fxNow = jQuery.now();
13372 for ( ; i < timers.length; i++ ) {
13373 timer = timers[ i ];
13374 // Checks the timer has not already been removed
13375 if ( !timer() && timers[ i ] === timer ) {
13376 timers.splice( i--, 1 );
13380 if ( !timers.length ) {
13386 jQuery.fx.timer = function( timer ) {
13387 jQuery.timers.push( timer );
13391 jQuery.timers.pop();
13395 jQuery.fx.interval = 13;
13397 jQuery.fx.start = function() {
13399 timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
13403 jQuery.fx.stop = function() {
13404 clearInterval( timerId );
13408 jQuery.fx.speeds = {
13416 // Based off of the plugin by Clint Helfers, with permission.
13417 // http://blindsignals.com/index.php/2009/07/jquery-delay/
13418 jQuery.fn.delay = function( time, type ) {
13419 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
13420 type = type || "fx
";
13422 return this.queue( type, function( next, hooks ) {
13423 var timeout = setTimeout( next, time );
13424 hooks.stop = function() {
13425 clearTimeout( timeout );
13432 var input = document.createElement( "input
" ),
13433 select = document.createElement( "select
" ),
13434 opt = select.appendChild( document.createElement( "option
" ) );
13436 input.type = "checkbox
";
13438 // Support: iOS 5.1, Android 4.x, Android 2.3
13439 // Check the default checkbox/radio value ("" on old WebKit; "on
" elsewhere)
13440 support.checkOn = input.value !== "";
13442 // Must access the parent to make an option select properly
13443 // Support: IE9, IE10
13444 support.optSelected = opt.selected;
13446 // Make sure that the options inside disabled selects aren't marked as disabled
13447 // (WebKit marks them as disabled)
13448 select.disabled = true;
13449 support.optDisabled = !opt.disabled;
13451 // Check if an input maintains its value after becoming a radio
13452 // Support: IE9, IE10
13453 input = document.createElement( "input
" );
13455 input.type = "radio
";
13456 support.radioValue = input.value === "t
";
13460 var nodeHook, boolHook,
13461 attrHandle = jQuery.expr.attrHandle;
13464 attr: function( name, value ) {
13465 return access( this, jQuery.attr, name, value, arguments.length > 1 );
13468 removeAttr: function( name ) {
13469 return this.each(function() {
13470 jQuery.removeAttr( this, name );
13476 attr: function( elem, name, value ) {
13478 nType = elem.nodeType;
13480 // don't get/set attributes on text, comment and attribute nodes
13481 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
13485 // Fallback to prop when attributes are not supported
13486 if ( typeof elem.getAttribute === strundefined ) {
13487 return jQuery.prop( elem, name, value );
13490 // All attributes are lowercase
13491 // Grab necessary hook if one is defined
13492 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
13493 name = name.toLowerCase();
13494 hooks = jQuery.attrHooks[ name ] ||
13495 ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook );
13498 if ( value !== undefined ) {
13500 if ( value === null ) {
13501 jQuery.removeAttr( elem, name );
13503 } else if ( hooks && "set
" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
13507 elem.setAttribute( name, value + "" );
13511 } else if ( hooks && "get
" in hooks && (ret = hooks.get( elem, name )) !== null ) {
13515 ret = jQuery.find.attr( elem, name );
13517 // Non-existent attributes return null, we normalize to undefined
13518 return ret == null ?
13524 removeAttr: function( elem, value ) {
13525 var name, propName,
13527 attrNames = value && value.match( rnotwhite );
13529 if ( attrNames && elem.nodeType === 1 ) {
13530 while ( (name = attrNames[i++]) ) {
13531 propName = jQuery.propFix[ name ] || name;
13533 // Boolean attributes get special treatment (#10870)
13534 if ( jQuery.expr.match.bool.test( name ) ) {
13535 // Set corresponding property to false
13536 elem[ propName ] = false;
13539 elem.removeAttribute( name );
13546 set: function( elem, value ) {
13547 if ( !support.radioValue && value === "radio
" &&
13548 jQuery.nodeName( elem, "input
" ) ) {
13549 // Setting the type on a radio button after the value resets the value in IE6-9
13550 // Reset value to default in case type is set after value during creation
13551 var val = elem.value;
13552 elem.setAttribute( "type
", value );
13563 // Hooks for boolean attributes
13565 set: function( elem, value, name ) {
13566 if ( value === false ) {
13567 // Remove boolean attributes when set to false
13568 jQuery.removeAttr( elem, name );
13570 elem.setAttribute( name, name );
13575 jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
13576 var getter = attrHandle[ name ] || jQuery.find.attr;
13578 attrHandle[ name ] = function( elem, name, isXML ) {
13581 // Avoid an infinite loop by temporarily removing this function from the getter
13582 handle = attrHandle[ name ];
13583 attrHandle[ name ] = ret;
13584 ret = getter( elem, name, isXML ) != null ?
13585 name.toLowerCase() :
13587 attrHandle[ name ] = handle;
13596 var rfocusable = /^(?:input|select|textarea|button)$/i;
13599 prop: function( name, value ) {
13600 return access( this, jQuery.prop, name, value, arguments.length > 1 );
13603 removeProp: function( name ) {
13604 return this.each(function() {
13605 delete this[ jQuery.propFix[ name ] || name ];
13613 "class
": "className
"
13616 prop: function( elem, name, value ) {
13617 var ret, hooks, notxml,
13618 nType = elem.nodeType;
13620 // don't get/set properties on text, comment and attribute nodes
13621 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
13625 notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
13628 // Fix name and attach hooks
13629 name = jQuery.propFix[ name ] || name;
13630 hooks = jQuery.propHooks[ name ];
13633 if ( value !== undefined ) {
13634 return hooks && "set
" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ?
13636 ( elem[ name ] = value );
13639 return hooks && "get
" in hooks && (ret = hooks.get( elem, name )) !== null ?
13647 get: function( elem ) {
13648 return elem.hasAttribute( "tabindex
" ) || rfocusable.test( elem.nodeName ) || elem.href ?
13657 // Selectedness for an option in an optgroup can be inaccurate
13658 if ( !support.optSelected ) {
13659 jQuery.propHooks.selected = {
13660 get: function( elem ) {
13661 var parent = elem.parentNode;
13662 if ( parent && parent.parentNode ) {
13663 parent.parentNode.selectedIndex;
13682 jQuery.propFix[ this.toLowerCase() ] = this;
13688 var rclass = /[\t\r\n\f]/g;
13691 addClass: function( value ) {
13692 var classes, elem, cur, clazz, j, finalValue,
13693 proceed = typeof value === "string
" && value,
13697 if ( jQuery.isFunction( value ) ) {
13698 return this.each(function( j ) {
13699 jQuery( this ).addClass( value.call( this, j, this.className ) );
13704 // The disjunction here is for better compressibility (see removeClass)
13705 classes = ( value || "" ).match( rnotwhite ) || [];
13707 for ( ; i < len; i++ ) {
13709 cur = elem.nodeType === 1 && ( elem.className ?
13710 ( " " + elem.className + " " ).replace( rclass, " " ) :
13716 while ( (clazz = classes[j++]) ) {
13717 if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
13718 cur += clazz + " ";
13722 // only assign if different to avoid unneeded rendering.
13723 finalValue = jQuery.trim( cur );
13724 if ( elem.className !== finalValue ) {
13725 elem.className = finalValue;
13734 removeClass: function( value ) {
13735 var classes, elem, cur, clazz, j, finalValue,
13736 proceed = arguments.length === 0 || typeof value === "string
" && value,
13740 if ( jQuery.isFunction( value ) ) {
13741 return this.each(function( j ) {
13742 jQuery( this ).removeClass( value.call( this, j, this.className ) );
13746 classes = ( value || "" ).match( rnotwhite ) || [];
13748 for ( ; i < len; i++ ) {
13750 // This expression is here for better compressibility (see addClass)
13751 cur = elem.nodeType === 1 && ( elem.className ?
13752 ( " " + elem.className + " " ).replace( rclass, " " ) :
13758 while ( (clazz = classes[j++]) ) {
13759 // Remove *all* instances
13760 while ( cur.indexOf( " " + clazz + " " ) >= 0 ) {
13761 cur = cur.replace( " " + clazz + " ", " " );
13765 // only assign if different to avoid unneeded rendering.
13766 finalValue = value ? jQuery.trim( cur ) : "";
13767 if ( elem.className !== finalValue ) {
13768 elem.className = finalValue;
13777 toggleClass: function( value, stateVal ) {
13778 var type = typeof value;
13780 if ( typeof stateVal === "boolean
" && type === "string
" ) {
13781 return stateVal ? this.addClass( value ) : this.removeClass( value );
13784 if ( jQuery.isFunction( value ) ) {
13785 return this.each(function( i ) {
13786 jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
13790 return this.each(function() {
13791 if ( type === "string
" ) {
13792 // toggle individual class names
13795 self = jQuery( this ),
13796 classNames = value.match( rnotwhite ) || [];
13798 while ( (className = classNames[ i++ ]) ) {
13799 // check each className given, space separated list
13800 if ( self.hasClass( className ) ) {
13801 self.removeClass( className );
13803 self.addClass( className );
13807 // Toggle whole class name
13808 } else if ( type === strundefined || type === "boolean
" ) {
13809 if ( this.className ) {
13810 // store className if set
13811 data_priv.set( this, "__className__
", this.className );
13814 // If the element has a class name or if we're passed "false
",
13815 // then remove the whole classname (if there was one, the above saved it).
13816 // Otherwise bring back whatever was previously saved (if anything),
13817 // falling back to the empty string if nothing was stored.
13818 this.className = this.className || value === false ? "" : data_priv.get( this, "__className__
" ) || "";
13823 hasClass: function( selector ) {
13824 var className = " " + selector + " ",
13827 for ( ; i < l; i++ ) {
13828 if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
13840 var rreturn = /\r/g;
13843 val: function( value ) {
13844 var hooks, ret, isFunction,
13847 if ( !arguments.length ) {
13849 hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
13851 if ( hooks && "get
" in hooks && (ret = hooks.get( elem, "value
" )) !== undefined ) {
13857 return typeof ret === "string
" ?
13858 // handle most common string cases
13859 ret.replace(rreturn, "") :
13860 // handle cases where value is null/undef or number
13861 ret == null ? "" : ret;
13867 isFunction = jQuery.isFunction( value );
13869 return this.each(function( i ) {
13872 if ( this.nodeType !== 1 ) {
13876 if ( isFunction ) {
13877 val = value.call( this, i, jQuery( this ).val() );
13882 // Treat null/undefined as ""; convert numbers to string
13883 if ( val == null ) {
13886 } else if ( typeof val === "number
" ) {
13889 } else if ( jQuery.isArray( val ) ) {
13890 val = jQuery.map( val, function( value ) {
13891 return value == null ? "" : value + "";
13895 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
13897 // If set returns undefined, fall back to normal setting
13898 if ( !hooks || !("set
" in hooks) || hooks.set( this, val, "value
" ) === undefined ) {
13908 get: function( elem ) {
13909 var val = jQuery.find.attr( elem, "value
" );
13910 return val != null ?
13912 // Support: IE10-11+
13913 // option.text throws exceptions (#14686, #14858)
13914 jQuery.trim( jQuery.text( elem ) );
13918 get: function( elem ) {
13920 options = elem.options,
13921 index = elem.selectedIndex,
13922 one = elem.type === "select-one
" || index < 0,
13923 values = one ? null : [],
13924 max = one ? index + 1 : options.length,
13929 // Loop through all the selected options
13930 for ( ; i < max; i++ ) {
13931 option = options[ i ];
13933 // IE6-9 doesn't update selected after form reset (#2551)
13934 if ( ( option.selected || i === index ) &&
13935 // Don't return options that are disabled or in a disabled optgroup
13936 ( support.optDisabled ? !option.disabled : option.getAttribute( "disabled
" ) === null ) &&
13937 ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup
" ) ) ) {
13939 // Get the specific value for the option
13940 value = jQuery( option ).val();
13942 // We don't need an array for one selects
13947 // Multi-Selects return an array
13948 values.push( value );
13955 set: function( elem, value ) {
13956 var optionSet, option,
13957 options = elem.options,
13958 values = jQuery.makeArray( value ),
13959 i = options.length;
13962 option = options[ i ];
13963 if ( (option.selected = jQuery.inArray( option.value, values ) >= 0) ) {
13968 // force browsers to behave consistently when non-matching value is set
13969 if ( !optionSet ) {
13970 elem.selectedIndex = -1;
13978 // Radios and checkboxes getter/setter
13979 jQuery.each([ "radio
", "checkbox
" ], function() {
13980 jQuery.valHooks[ this ] = {
13981 set: function( elem, value ) {
13982 if ( jQuery.isArray( value ) ) {
13983 return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
13987 if ( !support.checkOn ) {
13988 jQuery.valHooks[ this ].get = function( elem ) {
13990 // "" is returned instead of "on
" if a value isn't specified
13991 return elem.getAttribute("value
") === null ? "on
" : elem.value;
13999 // Return jQuery for attributes-only inclusion
14002 jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick
" +
14003 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave
" +
14004 "change select submit keydown keypress keyup error contextmenu
").split(" "), function( i, name ) {
14006 // Handle event binding
14007 jQuery.fn[ name ] = function( data, fn ) {
14008 return arguments.length > 0 ?
14009 this.on( name, null, data, fn ) :
14010 this.trigger( name );
14015 hover: function( fnOver, fnOut ) {
14016 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
14019 bind: function( types, data, fn ) {
14020 return this.on( types, null, data, fn );
14022 unbind: function( types, fn ) {
14023 return this.off( types, null, fn );
14026 delegate: function( selector, types, data, fn ) {
14027 return this.on( types, selector, data, fn );
14029 undelegate: function( selector, types, fn ) {
14030 // ( namespace ) or ( selector, types [, fn] )
14031 return arguments.length === 1 ? this.off( selector, "**
" ) : this.off( types, selector || "**
", fn );
14036 var nonce = jQuery.now();
14038 var rquery = (/\?/);
14042 // Support: Android 2.3
14043 // Workaround failure to string-cast null input
14044 jQuery.parseJSON = function( data ) {
14045 return JSON.parse( data + "" );
14049 // Cross-browser xml parsing
14050 jQuery.parseXML = function( data ) {
14052 if ( !data || typeof data !== "string
" ) {
14058 tmp = new DOMParser();
14059 xml = tmp.parseFromString( data, "text/xml
" );
14064 if ( !xml || xml.getElementsByTagName( "parsererror
" ).length ) {
14065 jQuery.error( "Invalid XML:
" + data );
14072 // Document location
14077 rts = /([?&])_=[^&]*/,
14078 rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
14079 // #7653, #8125, #8152: local protocol detection
14080 rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
14081 rnoContent = /^(?:GET|HEAD)$/,
14082 rprotocol = /^\/\//,
14083 rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,
14086 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
14087 * 2) These are called:
14088 * - BEFORE asking for a transport
14089 * - AFTER param serialization (s.data is a string if s.processData is true)
14090 * 3) key is the dataType
14091 * 4) the catchall symbol "*
" can be used
14092 * 5) execution will start with transport dataType and THEN continue down to "*
" if needed
14096 /* Transports bindings
14097 * 1) key is the dataType
14098 * 2) the catchall symbol "*
" can be used
14099 * 3) selection will start with transport dataType and THEN go to "*
" if needed
14103 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
14104 allTypes = "*/
".concat("*
");
14106 // #8138, IE may throw an exception when accessing
14107 // a field from window.location if document.domain has been set
14109 ajaxLocation = location.href;
14111 // Use the href attribute of an A element
14112 // since IE will modify it given document.location
14113 ajaxLocation = document.createElement( "a
" );
14114 ajaxLocation.href = "";
14115 ajaxLocation = ajaxLocation.href;
14118 // Segment location into parts
14119 ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
14121 // Base "constructor
" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
14122 function addToPrefiltersOrTransports( structure ) {
14124 // dataTypeExpression is optional and defaults to "*
"
14125 return function( dataTypeExpression, func ) {
14127 if ( typeof dataTypeExpression !== "string
" ) {
14128 func = dataTypeExpression;
14129 dataTypeExpression = "*
";
14134 dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || [];
14136 if ( jQuery.isFunction( func ) ) {
14137 // For each dataType in the dataTypeExpression
14138 while ( (dataType = dataTypes[i++]) ) {
14139 // Prepend if requested
14140 if ( dataType[0] === "+
" ) {
14141 dataType = dataType.slice( 1 ) || "*
";
14142 (structure[ dataType ] = structure[ dataType ] || []).unshift( func );
14144 // Otherwise append
14146 (structure[ dataType ] = structure[ dataType ] || []).push( func );
14153 // Base inspection function for prefilters and transports
14154 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
14156 var inspected = {},
14157 seekingTransport = ( structure === transports );
14159 function inspect( dataType ) {
14161 inspected[ dataType ] = true;
14162 jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
14163 var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
14164 if ( typeof dataTypeOrTransport === "string
" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
14165 options.dataTypes.unshift( dataTypeOrTransport );
14166 inspect( dataTypeOrTransport );
14168 } else if ( seekingTransport ) {
14169 return !( selected = dataTypeOrTransport );
14175 return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*
" ] && inspect( "*
" );
14178 // A special extend for ajax options
14179 // that takes "flat
" options (not to be deep extended)
14181 function ajaxExtend( target, src ) {
14183 flatOptions = jQuery.ajaxSettings.flatOptions || {};
14185 for ( key in src ) {
14186 if ( src[ key ] !== undefined ) {
14187 ( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ];
14191 jQuery.extend( true, target, deep );
14197 /* Handles responses to an ajax request:
14198 * - finds the right dataType (mediates between content-type and expected dataType)
14199 * - returns the corresponding response
14201 function ajaxHandleResponses( s, jqXHR, responses ) {
14203 var ct, type, finalDataType, firstDataType,
14204 contents = s.contents,
14205 dataTypes = s.dataTypes;
14207 // Remove auto dataType and get content-type in the process
14208 while ( dataTypes[ 0 ] === "*
" ) {
14210 if ( ct === undefined ) {
14211 ct = s.mimeType || jqXHR.getResponseHeader("Content-Type
");
14215 // Check if we're dealing with a known content-type
14217 for ( type in contents ) {
14218 if ( contents[ type ] && contents[ type ].test( ct ) ) {
14219 dataTypes.unshift( type );
14225 // Check to see if we have a response for the expected dataType
14226 if ( dataTypes[ 0 ] in responses ) {
14227 finalDataType = dataTypes[ 0 ];
14229 // Try convertible dataTypes
14230 for ( type in responses ) {
14231 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
14232 finalDataType = type;
14235 if ( !firstDataType ) {
14236 firstDataType = type;
14239 // Or just use first one
14240 finalDataType = finalDataType || firstDataType;
14243 // If we found a dataType
14244 // We add the dataType to the list if needed
14245 // and return the corresponding response
14246 if ( finalDataType ) {
14247 if ( finalDataType !== dataTypes[ 0 ] ) {
14248 dataTypes.unshift( finalDataType );
14250 return responses[ finalDataType ];
14254 /* Chain conversions given the request and the original response
14255 * Also sets the responseXXX fields on the jqXHR instance
14257 function ajaxConvert( s, response, jqXHR, isSuccess ) {
14258 var conv2, current, conv, tmp, prev,
14260 // Work with a copy of dataTypes in case we need to modify it for conversion
14261 dataTypes = s.dataTypes.slice();
14263 // Create converters map with lowercased keys
14264 if ( dataTypes[ 1 ] ) {
14265 for ( conv in s.converters ) {
14266 converters[ conv.toLowerCase() ] = s.converters[ conv ];
14270 current = dataTypes.shift();
14272 // Convert to each sequential dataType
14273 while ( current ) {
14275 if ( s.responseFields[ current ] ) {
14276 jqXHR[ s.responseFields[ current ] ] = response;
14279 // Apply the dataFilter if provided
14280 if ( !prev && isSuccess && s.dataFilter ) {
14281 response = s.dataFilter( response, s.dataType );
14285 current = dataTypes.shift();
14289 // There's only work to do if current dataType is non-auto
14290 if ( current === "*
" ) {
14294 // Convert response if prev dataType is non-auto and differs from current
14295 } else if ( prev !== "*
" && prev !== current ) {
14297 // Seek a direct converter
14298 conv = converters[ prev + " " + current ] || converters[ "*
" + current ];
14300 // If none found, seek a pair
14302 for ( conv2 in converters ) {
14304 // If conv2 outputs current
14305 tmp = conv2.split( " " );
14306 if ( tmp[ 1 ] === current ) {
14308 // If prev can be converted to accepted input
14309 conv = converters[ prev + " " + tmp[ 0 ] ] ||
14310 converters[ "*
" + tmp[ 0 ] ];
14312 // Condense equivalence converters
14313 if ( conv === true ) {
14314 conv = converters[ conv2 ];
14316 // Otherwise, insert the intermediate dataType
14317 } else if ( converters[ conv2 ] !== true ) {
14318 current = tmp[ 0 ];
14319 dataTypes.unshift( tmp[ 1 ] );
14327 // Apply converter (if not an equivalence)
14328 if ( conv !== true ) {
14330 // Unless errors are allowed to bubble, catch and return them
14331 if ( conv && s[ "throws
" ] ) {
14332 response = conv( response );
14335 response = conv( response );
14337 return { state: "parsererror
", error: conv ? e : "No conversion from
" + prev + " to
" + current };
14345 return { state: "success
", data: response };
14350 // Counter for holding the number of active queries
14353 // Last-Modified header cache for next request
14360 isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
14364 contentType: "application/x-www-form-urlencoded; charset=UTF-
8",
14373 traditional: false,
14379 text: "text/plain
",
14381 xml: "application/xml, text/xml
",
14382 json: "application/json, text/javascript
"
14392 xml: "responseXML
",
14393 text: "responseText
",
14394 json: "responseJSON
"
14398 // Keys separate source (or catchall "*
") and destination types with a single space
14401 // Convert anything to text
14404 // Text to html (true = no transformation)
14407 // Evaluate text as a json expression
14408 "text json
": jQuery.parseJSON,
14410 // Parse text as xml
14411 "text xml
": jQuery.parseXML
14414 // For options that shouldn't be deep extended:
14415 // you can add your own custom options here if
14416 // and when you create one that shouldn't be
14417 // deep extended (see ajaxExtend)
14424 // Creates a full fledged settings object into target
14425 // with both ajaxSettings and settings fields.
14426 // If target is omitted, writes into ajaxSettings.
14427 ajaxSetup: function( target, settings ) {
14430 // Building a settings object
14431 ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
14433 // Extending ajaxSettings
14434 ajaxExtend( jQuery.ajaxSettings, target );
14437 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
14438 ajaxTransport: addToPrefiltersOrTransports( transports ),
14441 ajax: function( url, options ) {
14443 // If url is an object, simulate pre-1.5 signature
14444 if ( typeof url === "object
" ) {
14449 // Force options to be an object
14450 options = options || {};
14453 // URL without anti-cache param
14455 // Response headers
14456 responseHeadersString,
14460 // Cross-domain detection vars
14462 // To know if global events are to be dispatched
14466 // Create the final options object
14467 s = jQuery.ajaxSetup( {}, options ),
14468 // Callbacks context
14469 callbackContext = s.context || s,
14470 // Context for global events is callbackContext if it is a DOM node or jQuery collection
14471 globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ?
14472 jQuery( callbackContext ) :
14475 deferred = jQuery.Deferred(),
14476 completeDeferred = jQuery.Callbacks("once memory
"),
14477 // Status-dependent callbacks
14478 statusCode = s.statusCode || {},
14479 // Headers (they are sent all at once)
14480 requestHeaders = {},
14481 requestHeadersNames = {},
14484 // Default abort message
14485 strAbort = "canceled
",
14490 // Builds headers hashtable if needed
14491 getResponseHeader: function( key ) {
14493 if ( state === 2 ) {
14494 if ( !responseHeaders ) {
14495 responseHeaders = {};
14496 while ( (match = rheaders.exec( responseHeadersString )) ) {
14497 responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
14500 match = responseHeaders[ key.toLowerCase() ];
14502 return match == null ? null : match;
14506 getAllResponseHeaders: function() {
14507 return state === 2 ? responseHeadersString : null;
14510 // Caches the header
14511 setRequestHeader: function( name, value ) {
14512 var lname = name.toLowerCase();
14514 name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
14515 requestHeaders[ name ] = value;
14520 // Overrides response content-type header
14521 overrideMimeType: function( type ) {
14528 // Status-dependent callbacks
14529 statusCode: function( map ) {
14533 for ( code in map ) {
14534 // Lazy-add the new callback in a way that preserves old ones
14535 statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
14538 // Execute the appropriate callbacks
14539 jqXHR.always( map[ jqXHR.status ] );
14545 // Cancel the request
14546 abort: function( statusText ) {
14547 var finalText = statusText || strAbort;
14549 transport.abort( finalText );
14551 done( 0, finalText );
14556 // Attach deferreds
14557 deferred.promise( jqXHR ).complete = completeDeferred.add;
14558 jqXHR.success = jqXHR.done;
14559 jqXHR.error = jqXHR.fail;
14561 // Remove hash character (#7531: and string promotion)
14562 // Add protocol if not provided (prefilters might expect it)
14563 // Handle falsy url in the settings object (#10093: consistency with old signature)
14564 // We also use the url parameter if available
14565 s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" )
14566 .replace( rprotocol, ajaxLocParts[ 1 ] + "//
" );
14568 // Alias method option to type as per ticket #12004
14569 s.type = options.method || options.type || s.method || s.type;
14571 // Extract dataTypes list
14572 s.dataTypes = jQuery.trim( s.dataType || "*
" ).toLowerCase().match( rnotwhite ) || [ "" ];
14574 // A cross-domain request is in order when we have a protocol:host:port mismatch
14575 if ( s.crossDomain == null ) {
14576 parts = rurl.exec( s.url.toLowerCase() );
14577 s.crossDomain = !!( parts &&
14578 ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
14579 ( parts[ 3 ] || ( parts[ 1 ] === "http:
" ? "80" : "443" ) ) !==
14580 ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:
" ? "80" : "443" ) ) )
14584 // Convert data if not already a string
14585 if ( s.data && s.processData && typeof s.data !== "string
" ) {
14586 s.data = jQuery.param( s.data, s.traditional );
14589 // Apply prefilters
14590 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
14592 // If request was aborted inside a prefilter, stop there
14593 if ( state === 2 ) {
14597 // We can fire global events as of now if asked to
14598 fireGlobals = s.global;
14600 // Watch for a new set of requests
14601 if ( fireGlobals && jQuery.active++ === 0 ) {
14602 jQuery.event.trigger("ajaxStart
");
14605 // Uppercase the type
14606 s.type = s.type.toUpperCase();
14608 // Determine if request has content
14609 s.hasContent = !rnoContent.test( s.type );
14611 // Save the URL in case we're toying with the If-Modified-Since
14612 // and/or If-None-Match header later on
14615 // More options handling for requests with no content
14616 if ( !s.hasContent ) {
14618 // If data is available, append data to url
14620 cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&
" : "?
" ) + s.data );
14621 // #9682: remove data so that it's not used in an eventual retry
14625 // Add anti-cache in url if needed
14626 if ( s.cache === false ) {
14627 s.url = rts.test( cacheURL ) ?
14629 // If there is already a '_' parameter, set its value
14630 cacheURL.replace( rts, "$
1_=
" + nonce++ ) :
14632 // Otherwise add one to the end
14633 cacheURL + ( rquery.test( cacheURL ) ? "&
" : "?
" ) + "_=
" + nonce++;
14637 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
14638 if ( s.ifModified ) {
14639 if ( jQuery.lastModified[ cacheURL ] ) {
14640 jqXHR.setRequestHeader( "If-Modified-Since
", jQuery.lastModified[ cacheURL ] );
14642 if ( jQuery.etag[ cacheURL ] ) {
14643 jqXHR.setRequestHeader( "If-None-Match
", jQuery.etag[ cacheURL ] );
14647 // Set the correct header, if data is being sent
14648 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
14649 jqXHR.setRequestHeader( "Content-Type
", s.contentType );
14652 // Set the Accepts header for the server, depending on the dataType
14653 jqXHR.setRequestHeader(
14655 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
14656 s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*
" ? ",
" + allTypes + "; q=
0.01" : "" ) :
14660 // Check for headers option
14661 for ( i in s.headers ) {
14662 jqXHR.setRequestHeader( i, s.headers[ i ] );
14665 // Allow custom headers/mimetypes and early abort
14666 if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
14667 // Abort if not done already and return
14668 return jqXHR.abort();
14671 // aborting is no longer a cancellation
14672 strAbort = "abort
";
14674 // Install callbacks on deferreds
14675 for ( i in { success: 1, error: 1, complete: 1 } ) {
14676 jqXHR[ i ]( s[ i ] );
14680 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
14682 // If no transport, we auto-abort
14683 if ( !transport ) {
14684 done( -1, "No Transport
" );
14686 jqXHR.readyState = 1;
14688 // Send global event
14689 if ( fireGlobals ) {
14690 globalEventContext.trigger( "ajaxSend
", [ jqXHR, s ] );
14693 if ( s.async && s.timeout > 0 ) {
14694 timeoutTimer = setTimeout(function() {
14695 jqXHR.abort("timeout
");
14701 transport.send( requestHeaders, done );
14703 // Propagate exception as error if not done
14706 // Simply rethrow otherwise
14713 // Callback for when everything is done
14714 function done( status, nativeStatusText, responses, headers ) {
14715 var isSuccess, success, error, response, modified,
14716 statusText = nativeStatusText;
14719 if ( state === 2 ) {
14723 // State is "done
" now
14726 // Clear timeout if it exists
14727 if ( timeoutTimer ) {
14728 clearTimeout( timeoutTimer );
14731 // Dereference transport for early garbage collection
14732 // (no matter how long the jqXHR object will be used)
14733 transport = undefined;
14735 // Cache response headers
14736 responseHeadersString = headers || "";
14739 jqXHR.readyState = status > 0 ? 4 : 0;
14741 // Determine if successful
14742 isSuccess = status >= 200 && status < 300 || status === 304;
14744 // Get response data
14746 response = ajaxHandleResponses( s, jqXHR, responses );
14749 // Convert no matter what (that way responseXXX fields are always set)
14750 response = ajaxConvert( s, response, jqXHR, isSuccess );
14752 // If successful, handle type chaining
14755 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
14756 if ( s.ifModified ) {
14757 modified = jqXHR.getResponseHeader("Last-Modified
");
14759 jQuery.lastModified[ cacheURL ] = modified;
14761 modified = jqXHR.getResponseHeader("etag
");
14763 jQuery.etag[ cacheURL ] = modified;
14768 if ( status === 204 || s.type === "HEAD
" ) {
14769 statusText = "nocontent
";
14772 } else if ( status === 304 ) {
14773 statusText = "notmodified
";
14775 // If we have data, let's convert it
14777 statusText = response.state;
14778 success = response.data;
14779 error = response.error;
14780 isSuccess = !error;
14783 // We extract error from statusText
14784 // then normalize statusText and status for non-aborts
14785 error = statusText;
14786 if ( status || !statusText ) {
14787 statusText = "error
";
14788 if ( status < 0 ) {
14794 // Set data for the fake xhr object
14795 jqXHR.status = status;
14796 jqXHR.statusText = ( nativeStatusText || statusText ) + "";
14800 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
14802 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
14805 // Status-dependent callbacks
14806 jqXHR.statusCode( statusCode );
14807 statusCode = undefined;
14809 if ( fireGlobals ) {
14810 globalEventContext.trigger( isSuccess ? "ajaxSuccess
" : "ajaxError
",
14811 [ jqXHR, s, isSuccess ? success : error ] );
14815 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
14817 if ( fireGlobals ) {
14818 globalEventContext.trigger( "ajaxComplete
", [ jqXHR, s ] );
14819 // Handle the global AJAX counter
14820 if ( !( --jQuery.active ) ) {
14821 jQuery.event.trigger("ajaxStop
");
14829 getJSON: function( url, data, callback ) {
14830 return jQuery.get( url, data, callback, "json
" );
14833 getScript: function( url, callback ) {
14834 return jQuery.get( url, undefined, callback, "script
" );
14838 jQuery.each( [ "get
", "post
" ], function( i, method ) {
14839 jQuery[ method ] = function( url, data, callback, type ) {
14840 // shift arguments if data argument was omitted
14841 if ( jQuery.isFunction( data ) ) {
14842 type = type || callback;
14847 return jQuery.ajax({
14857 // Attach a bunch of functions for handling common AJAX events
14858 jQuery.each( [ "ajaxStart
", "ajaxStop
", "ajaxComplete
", "ajaxError
", "ajaxSuccess
", "ajaxSend
" ], function( i, type ) {
14859 jQuery.fn[ type ] = function( fn ) {
14860 return this.on( type, fn );
14865 jQuery._evalUrl = function( url ) {
14866 return jQuery.ajax({
14869 dataType: "script
",
14878 wrapAll: function( html ) {
14881 if ( jQuery.isFunction( html ) ) {
14882 return this.each(function( i ) {
14883 jQuery( this ).wrapAll( html.call(this, i) );
14889 // The elements to wrap the target around
14890 wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
14892 if ( this[ 0 ].parentNode ) {
14893 wrap.insertBefore( this[ 0 ] );
14896 wrap.map(function() {
14899 while ( elem.firstElementChild ) {
14900 elem = elem.firstElementChild;
14910 wrapInner: function( html ) {
14911 if ( jQuery.isFunction( html ) ) {
14912 return this.each(function( i ) {
14913 jQuery( this ).wrapInner( html.call(this, i) );
14917 return this.each(function() {
14918 var self = jQuery( this ),
14919 contents = self.contents();
14921 if ( contents.length ) {
14922 contents.wrapAll( html );
14925 self.append( html );
14930 wrap: function( html ) {
14931 var isFunction = jQuery.isFunction( html );
14933 return this.each(function( i ) {
14934 jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
14938 unwrap: function() {
14939 return this.parent().each(function() {
14940 if ( !jQuery.nodeName( this, "body
" ) ) {
14941 jQuery( this ).replaceWith( this.childNodes );
14948 jQuery.expr.filters.hidden = function( elem ) {
14949 // Support: Opera <= 12.12
14950 // Opera reports offsetWidths and offsetHeights less than zero on some elements
14951 return elem.offsetWidth <= 0 && elem.offsetHeight <= 0;
14953 jQuery.expr.filters.visible = function( elem ) {
14954 return !jQuery.expr.filters.hidden( elem );
14961 rbracket = /\[\]$/,
14963 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
14964 rsubmittable = /^(?:input|select|textarea|keygen)/i;
14966 function buildParams( prefix, obj, traditional, add ) {
14969 if ( jQuery.isArray( obj ) ) {
14970 // Serialize array item.
14971 jQuery.each( obj, function( i, v ) {
14972 if ( traditional || rbracket.test( prefix ) ) {
14973 // Treat each array item as a scalar.
14977 // Item is non-scalar (array or object), encode its numeric index.
14978 buildParams( prefix + "[
" + ( typeof v === "object
" ? i : "" ) + "]
", v, traditional, add );
14982 } else if ( !traditional && jQuery.type( obj ) === "object
" ) {
14983 // Serialize object item.
14984 for ( name in obj ) {
14985 buildParams( prefix + "[
" + name + "]
", obj[ name ], traditional, add );
14989 // Serialize scalar item.
14990 add( prefix, obj );
14994 // Serialize an array of form elements or a set of
14995 // key/values into a query string
14996 jQuery.param = function( a, traditional ) {
14999 add = function( key, value ) {
15000 // If value is a function, invoke it and return its value
15001 value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
15002 s[ s.length ] = encodeURIComponent( key ) + "=
" + encodeURIComponent( value );
15005 // Set traditional to true for jQuery <= 1.3.2 behavior.
15006 if ( traditional === undefined ) {
15007 traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
15010 // If an array was passed in, assume that it is an array of form elements.
15011 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
15012 // Serialize the form elements
15013 jQuery.each( a, function() {
15014 add( this.name, this.value );
15018 // If traditional, encode the "old
" way (the way 1.3.2 or older
15019 // did it), otherwise encode params recursively.
15020 for ( prefix in a ) {
15021 buildParams( prefix, a[ prefix ], traditional, add );
15025 // Return the resulting serialization
15026 return s.join( "&
" ).replace( r20, "+
" );
15030 serialize: function() {
15031 return jQuery.param( this.serializeArray() );
15033 serializeArray: function() {
15034 return this.map(function() {
15035 // Can add propHook for "elements
" to filter or add form elements
15036 var elements = jQuery.prop( this, "elements
" );
15037 return elements ? jQuery.makeArray( elements ) : this;
15039 .filter(function() {
15040 var type = this.type;
15042 // Use .is( ":disabled
" ) so that fieldset[disabled] works
15043 return this.name && !jQuery( this ).is( ":disabled
" ) &&
15044 rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
15045 ( this.checked || !rcheckableType.test( type ) );
15047 .map(function( i, elem ) {
15048 var val = jQuery( this ).val();
15050 return val == null ?
15052 jQuery.isArray( val ) ?
15053 jQuery.map( val, function( val ) {
15054 return { name: elem.name, value: val.replace( rCRLF, "\r\n
" ) };
15056 { name: elem.name, value: val.replace( rCRLF, "\r\n
" ) };
15062 jQuery.ajaxSettings.xhr = function() {
15064 return new XMLHttpRequest();
15070 xhrSuccessStatus = {
15071 // file protocol always yields status code 0, assume 200
15074 // #1450: sometimes IE returns 1223 when it should be 204
15077 xhrSupported = jQuery.ajaxSettings.xhr();
15080 // Open requests must be manually aborted on unload (#5280)
15081 if ( window.ActiveXObject ) {
15082 jQuery( window ).on( "unload
", function() {
15083 for ( var key in xhrCallbacks ) {
15084 xhrCallbacks[ key ]();
15089 support.cors = !!xhrSupported && ( "withCredentials
" in xhrSupported );
15090 support.ajax = xhrSupported = !!xhrSupported;
15092 jQuery.ajaxTransport(function( options ) {
15095 // Cross domain only allowed if supported through XMLHttpRequest
15096 if ( support.cors || xhrSupported && !options.crossDomain ) {
15098 send: function( headers, complete ) {
15100 xhr = options.xhr(),
15103 xhr.open( options.type, options.url, options.async, options.username, options.password );
15105 // Apply custom fields if provided
15106 if ( options.xhrFields ) {
15107 for ( i in options.xhrFields ) {
15108 xhr[ i ] = options.xhrFields[ i ];
15112 // Override mime type if needed
15113 if ( options.mimeType && xhr.overrideMimeType ) {
15114 xhr.overrideMimeType( options.mimeType );
15117 // X-Requested-With header
15118 // For cross-domain requests, seeing as conditions for a preflight are
15119 // akin to a jigsaw puzzle, we simply never set it to be sure.
15120 // (it can always be set on a per-request basis or even using ajaxSetup)
15121 // For same-domain requests, won't change header if already provided.
15122 if ( !options.crossDomain && !headers["X-Requested-With
"] ) {
15123 headers["X-Requested-With
"] = "XMLHttpRequest
";
15127 for ( i in headers ) {
15128 xhr.setRequestHeader( i, headers[ i ] );
15132 callback = function( type ) {
15133 return function() {
15135 delete xhrCallbacks[ id ];
15136 callback = xhr.onload = xhr.onerror = null;
15138 if ( type === "abort
" ) {
15140 } else if ( type === "error
" ) {
15142 // file: protocol always yields status 0; see #8605, #14207
15148 xhrSuccessStatus[ xhr.status ] || xhr.status,
15151 // Accessing binary-data responseText throws an exception
15153 typeof xhr.responseText === "string
" ? {
15154 text: xhr.responseText
15156 xhr.getAllResponseHeaders()
15163 // Listen to events
15164 xhr.onload = callback();
15165 xhr.onerror = callback("error
");
15167 // Create the abort callback
15168 callback = xhrCallbacks[ id ] = callback("abort
");
15171 // Do send the request (this may raise an exception)
15172 xhr.send( options.hasContent && options.data || null );
15174 // #14683: Only rethrow if this hasn't been notified as an error yet
15181 abort: function() {
15193 // Install script dataType
15196 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript
"
15199 script: /(?:java|ecma)script/
15202 "text script
": function( text ) {
15203 jQuery.globalEval( text );
15209 // Handle cache's special case and crossDomain
15210 jQuery.ajaxPrefilter( "script
", function( s ) {
15211 if ( s.cache === undefined ) {
15214 if ( s.crossDomain ) {
15219 // Bind script tag hack transport
15220 jQuery.ajaxTransport( "script
", function( s ) {
15221 // This transport only deals with cross domain requests
15222 if ( s.crossDomain ) {
15223 var script, callback;
15225 send: function( _, complete ) {
15226 script = jQuery("<script>").prop({
15228 charset: s.scriptCharset,
15232 callback = function( evt ) {
15236 complete( evt.type === "error
" ? 404 : 200, evt.type );
15240 document.head.appendChild( script[ 0 ] );
15242 abort: function() {
15254 var oldCallbacks = [],
15255 rjsonp = /(=)\?(?=&|$)|\?\?/;
15257 // Default jsonp settings
15260 jsonpCallback: function() {
15261 var callback = oldCallbacks.pop() || ( jQuery.expando + "_
" + ( nonce++ ) );
15262 this[ callback ] = true;
15267 // Detect, normalize options and install callbacks for jsonp requests
15268 jQuery.ajaxPrefilter( "json jsonp
", function( s, originalSettings, jqXHR ) {
15270 var callbackName, overwritten, responseContainer,
15271 jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
15273 typeof s.data === "string
" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded
") && rjsonp.test( s.data ) && "data
"
15276 // Handle iff the expected data type is "jsonp
" or we have a parameter to set
15277 if ( jsonProp || s.dataTypes[ 0 ] === "jsonp
" ) {
15279 // Get callback name, remembering preexisting value associated with it
15280 callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
15281 s.jsonpCallback() :
15284 // Insert callback into url or form data
15286 s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$
1" + callbackName );
15287 } else if ( s.jsonp !== false ) {
15288 s.url += ( rquery.test( s.url ) ? "&
" : "?
" ) + s.jsonp + "=
" + callbackName;
15291 // Use data converter to retrieve json after script execution
15292 s.converters["script json
"] = function() {
15293 if ( !responseContainer ) {
15294 jQuery.error( callbackName + " was not called
" );
15296 return responseContainer[ 0 ];
15299 // force json dataType
15300 s.dataTypes[ 0 ] = "json
";
15302 // Install callback
15303 overwritten = window[ callbackName ];
15304 window[ callbackName ] = function() {
15305 responseContainer = arguments;
15308 // Clean-up function (fires after converters)
15309 jqXHR.always(function() {
15310 // Restore preexisting value
15311 window[ callbackName ] = overwritten;
15313 // Save back as free
15314 if ( s[ callbackName ] ) {
15315 // make sure that re-using the options doesn't screw things around
15316 s.jsonpCallback = originalSettings.jsonpCallback;
15318 // save the callback name for future use
15319 oldCallbacks.push( callbackName );
15322 // Call if it was a function and we have a response
15323 if ( responseContainer && jQuery.isFunction( overwritten ) ) {
15324 overwritten( responseContainer[ 0 ] );
15327 responseContainer = overwritten = undefined;
15330 // Delegate to script
15338 // data: string of html
15339 // context (optional): If specified, the fragment will be created in this context, defaults to document
15340 // keepScripts (optional): If true, will include scripts passed in the html string
15341 jQuery.parseHTML = function( data, context, keepScripts ) {
15342 if ( !data || typeof data !== "string
" ) {
15345 if ( typeof context === "boolean
" ) {
15346 keepScripts = context;
15349 context = context || document;
15351 var parsed = rsingleTag.exec( data ),
15352 scripts = !keepScripts && [];
15356 return [ context.createElement( parsed[1] ) ];
15359 parsed = jQuery.buildFragment( [ data ], context, scripts );
15361 if ( scripts && scripts.length ) {
15362 jQuery( scripts ).remove();
15365 return jQuery.merge( [], parsed.childNodes );
15369 // Keep a copy of the old load method
15370 var _load = jQuery.fn.load;
15373 * Load a url into a page
15375 jQuery.fn.load = function( url, params, callback ) {
15376 if ( typeof url !== "string
" && _load ) {
15377 return _load.apply( this, arguments );
15380 var selector, type, response,
15382 off = url.indexOf(" ");
15385 selector = jQuery.trim( url.slice( off ) );
15386 url = url.slice( 0, off );
15389 // If it's a function
15390 if ( jQuery.isFunction( params ) ) {
15392 // We assume that it's the callback
15394 params = undefined;
15396 // Otherwise, build a param string
15397 } else if ( params && typeof params === "object
" ) {
15401 // If we have elements to modify, make the request
15402 if ( self.length > 0 ) {
15406 // if "type
" variable is undefined, then "GET
" method will be used
15410 }).done(function( responseText ) {
15412 // Save response for use in complete callback
15413 response = arguments;
15415 self.html( selector ?
15417 // If a selector was specified, locate the right elements in a dummy div
15418 // Exclude scripts to avoid IE 'Permission Denied' errors
15419 jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) :
15421 // Otherwise use the full result
15424 }).complete( callback && function( jqXHR, status ) {
15425 self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
15435 jQuery.expr.filters.animated = function( elem ) {
15436 return jQuery.grep(jQuery.timers, function( fn ) {
15437 return elem === fn.elem;
15444 var docElem = window.document.documentElement;
15447 * Gets a window from an element
15449 function getWindow( elem ) {
15450 return jQuery.isWindow( elem ) ? elem : elem.nodeType === 9 && elem.defaultView;
15454 setOffset: function( elem, options, i ) {
15455 var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
15456 position = jQuery.css( elem, "position
" ),
15457 curElem = jQuery( elem ),
15460 // Set position first, in-case top/left are set even on static elem
15461 if ( position === "static
" ) {
15462 elem.style.position = "relative
";
15465 curOffset = curElem.offset();
15466 curCSSTop = jQuery.css( elem, "top
" );
15467 curCSSLeft = jQuery.css( elem, "left
" );
15468 calculatePosition = ( position === "absolute
" || position === "fixed
" ) &&
15469 ( curCSSTop + curCSSLeft ).indexOf("auto
") > -1;
15471 // Need to be able to calculate position if either top or left is auto and position is either absolute or fixed
15472 if ( calculatePosition ) {
15473 curPosition = curElem.position();
15474 curTop = curPosition.top;
15475 curLeft = curPosition.left;
15478 curTop = parseFloat( curCSSTop ) || 0;
15479 curLeft = parseFloat( curCSSLeft ) || 0;
15482 if ( jQuery.isFunction( options ) ) {
15483 options = options.call( elem, i, curOffset );
15486 if ( options.top != null ) {
15487 props.top = ( options.top - curOffset.top ) + curTop;
15489 if ( options.left != null ) {
15490 props.left = ( options.left - curOffset.left ) + curLeft;
15493 if ( "using
" in options ) {
15494 options.using.call( elem, props );
15497 curElem.css( props );
15503 offset: function( options ) {
15504 if ( arguments.length ) {
15505 return options === undefined ?
15507 this.each(function( i ) {
15508 jQuery.offset.setOffset( this, options, i );
15514 box = { top: 0, left: 0 },
15515 doc = elem && elem.ownerDocument;
15521 docElem = doc.documentElement;
15523 // Make sure it's not a disconnected DOM node
15524 if ( !jQuery.contains( docElem, elem ) ) {
15528 // If we don't have gBCR, just use 0,0 rather than error
15529 // BlackBerry 5, iOS 3 (original iPhone)
15530 if ( typeof elem.getBoundingClientRect !== strundefined ) {
15531 box = elem.getBoundingClientRect();
15533 win = getWindow( doc );
15535 top: box.top + win.pageYOffset - docElem.clientTop,
15536 left: box.left + win.pageXOffset - docElem.clientLeft
15540 position: function() {
15541 if ( !this[ 0 ] ) {
15545 var offsetParent, offset,
15547 parentOffset = { top: 0, left: 0 };
15549 // Fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is its only offset parent
15550 if ( jQuery.css( elem, "position
" ) === "fixed
" ) {
15551 // We assume that getBoundingClientRect is available when computed position is fixed
15552 offset = elem.getBoundingClientRect();
15555 // Get *real* offsetParent
15556 offsetParent = this.offsetParent();
15558 // Get correct offsets
15559 offset = this.offset();
15560 if ( !jQuery.nodeName( offsetParent[ 0 ], "html
" ) ) {
15561 parentOffset = offsetParent.offset();
15564 // Add offsetParent borders
15565 parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth
", true );
15566 parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth
", true );
15569 // Subtract parent offsets and element margins
15571 top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop
", true ),
15572 left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft
", true )
15576 offsetParent: function() {
15577 return this.map(function() {
15578 var offsetParent = this.offsetParent || docElem;
15580 while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html
" ) && jQuery.css( offsetParent, "position
" ) === "static
" ) ) {
15581 offsetParent = offsetParent.offsetParent;
15584 return offsetParent || docElem;
15589 // Create scrollLeft and scrollTop methods
15590 jQuery.each( { scrollLeft: "pageXOffset
", scrollTop: "pageYOffset
" }, function( method, prop ) {
15591 var top = "pageYOffset
" === prop;
15593 jQuery.fn[ method ] = function( val ) {
15594 return access( this, function( elem, method, val ) {
15595 var win = getWindow( elem );
15597 if ( val === undefined ) {
15598 return win ? win[ prop ] : elem[ method ];
15603 !top ? val : window.pageXOffset,
15604 top ? val : window.pageYOffset
15608 elem[ method ] = val;
15610 }, method, val, arguments.length, null );
15614 // Add the top/left cssHooks using jQuery.fn.position
15615 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
15616 // getComputedStyle returns percent when specified for top/left/bottom/right
15617 // rather than make the css module depend on the offset module, we just check for it here
15618 jQuery.each( [ "top
", "left
" ], function( i, prop ) {
15619 jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
15620 function( elem, computed ) {
15622 computed = curCSS( elem, prop );
15623 // if curCSS returns percentage, fallback to offset
15624 return rnumnonpx.test( computed ) ?
15625 jQuery( elem ).position()[ prop ] + "px
" :
15633 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
15634 jQuery.each( { Height: "height
", Width: "width
" }, function( name, type ) {
15635 jQuery.each( { padding: "inner
" + name, content: type, "": "outer
" + name }, function( defaultExtra, funcName ) {
15636 // margin is only for outerHeight, outerWidth
15637 jQuery.fn[ funcName ] = function( margin, value ) {
15638 var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean
" ),
15639 extra = defaultExtra || ( margin === true || value === true ? "margin
" : "border
" );
15641 return access( this, function( elem, type, value ) {
15644 if ( jQuery.isWindow( elem ) ) {
15645 // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
15646 // isn't a whole lot we can do. See pull request at this URL for discussion:
15647 // https://github.com/jquery/jquery/pull/764
15648 return elem.document.documentElement[ "client
" + name ];
15651 // Get document width or height
15652 if ( elem.nodeType === 9 ) {
15653 doc = elem.documentElement;
15655 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
15656 // whichever is greatest
15658 elem.body[ "scroll
" + name ], doc[ "scroll
" + name ],
15659 elem.body[ "offset
" + name ], doc[ "offset
" + name ],
15660 doc[ "client
" + name ]
15664 return value === undefined ?
15665 // Get width or height on the element, requesting but not forcing parseFloat
15666 jQuery.css( elem, type, extra ) :
15668 // Set width or height on the element
15669 jQuery.style( elem, type, value, extra );
15670 }, type, chainable ? margin : undefined, chainable, null );
15676 // The number of elements contained in the matched element set
15677 jQuery.fn.size = function() {
15678 return this.length;
15681 jQuery.fn.andSelf = jQuery.fn.addBack;
15686 // Register as a named AMD module, since jQuery can be concatenated with other
15687 // files that may use define, but not via a proper concatenation script that
15688 // understands anonymous AMD modules. A named AMD is safest and most robust
15689 // way to register. Lowercase jquery is used because AMD module names are
15690 // derived from file names, and jQuery is normally delivered in a lowercase
15691 // file name. Do this after creating the global so that if an AMD module wants
15692 // to call noConflict to hide this version of jQuery, it will work.
15694 // Note that for maximum portability, libraries that are not jQuery should
15695 // declare themselves as anonymous modules, and avoid setting a global if an
15696 // AMD loader is present. jQuery is a special case. For more information, see
15697 // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
15699 if ( typeof define === "function
" && define.amd ) {
15700 define( "jquery
", [], function() {
15709 // Map over jQuery in case of overwrite
15710 _jQuery = window.jQuery,
15712 // Map over the $ in case of overwrite
15715 jQuery.noConflict = function( deep ) {
15716 if ( window.$ === jQuery ) {
15720 if ( deep && window.jQuery === jQuery ) {
15721 window.jQuery = _jQuery;
15727 // Expose jQuery and $ identifiers, even in
15728 // AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
15729 // and CommonJS for browser emulators (#13566)
15730 if ( typeof noGlobal === strundefined ) {
15731 window.jQuery = window.$ = jQuery;
15743 * Bootstrap v3.2.0 (http://getbootstrap.com)
15744 * Copyright 2011-2014 Twitter, Inc.
15745 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
15748 if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript requires jQuery') }
15750 /* ========================================================================
15751 * Bootstrap: transition.js v3.2.0
15752 * http://getbootstrap.com/javascript/#transitions
15753 * ========================================================================
15754 * Copyright 2011-2014 Twitter, Inc.
15755 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
15756 * ======================================================================== */
15762 // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
15763 // ============================================================
15765 function transitionEnd() {
15766 var el = document.createElement('bootstrap')
15768 var transEndEventNames = {
15769 WebkitTransition : 'webkitTransitionEnd',
15770 MozTransition : 'transitionend',
15771 OTransition : 'oTransitionEnd otransitionend',
15772 transition : 'transitionend'
15775 for (var name in transEndEventNames) {
15776 if (el.style[name] !== undefined) {
15777 return { end: transEndEventNames[name] }
15781 return false // explicit for ie8 ( ._.)
15784 // http://blog.alexmaccaw.com/css-transitions
15785 $.fn.emulateTransitionEnd = function (duration) {
15788 $(this).one('bsTransitionEnd', function () { called = true })
15789 var callback = function () { if (!called) $($el).trigger($.support.transition.end) }
15790 setTimeout(callback, duration)
15795 $.support.transition = transitionEnd()
15797 if (!$.support.transition) return
15799 $.event.special.bsTransitionEnd = {
15800 bindType: $.support.transition.end,
15801 delegateType: $.support.transition.end,
15802 handle: function (e) {
15803 if ($(e.target).is(this)) return e.handleObj.handler.apply(this, arguments)
15810 /* ========================================================================
15811 * Bootstrap: alert.js v3.2.0
15812 * http://getbootstrap.com/javascript/#alerts
15813 * ========================================================================
15814 * Copyright 2011-2014 Twitter, Inc.
15815 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
15816 * ======================================================================== */
15822 // ALERT CLASS DEFINITION
15823 // ======================
15825 var dismiss = '[data-dismiss="alert"]'
15826 var Alert = function (el) {
15827 $(el).on('click', dismiss, this.close)
15830 Alert.VERSION = '
3.2.0'
15832 Alert.prototype.close = function (e) {
15833 var $this = $(this)
15834 var selector = $this.attr('data-target')
15837 selector = $this.attr('href')
15838 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
15841 var $parent = $(selector)
15843 if (e) e.preventDefault()
15845 if (!$parent.length) {
15846 $parent = $this.hasClass('alert') ? $this : $this.parent()
15849 $parent.trigger(e = $.Event('close.bs.alert'))
15851 if (e.isDefaultPrevented()) return
15853 $parent.removeClass('in')
15855 function removeElement() {
15856 // detach from parent, fire event then clean up data
15857 $parent.detach().trigger('closed.bs.alert').remove()
15860 $.support.transition && $parent.hasClass('fade') ?
15862 .one('bsTransitionEnd', removeElement)
15863 .emulateTransitionEnd(
150) :
15868 // ALERT PLUGIN DEFINITION
15869 // =======================
15871 function Plugin(option) {
15872 return this.each(function () {
15873 var $this = $(this)
15874 var data = $this.data('bs.alert')
15876 if (!data) $this.data('bs.alert', (data = new Alert(this)))
15877 if (typeof option == 'string') data[option].call($this)
15881 var old = $.fn.alert
15883 $.fn.alert = Plugin
15884 $.fn.alert.Constructor = Alert
15887 // ALERT NO CONFLICT
15888 // =================
15890 $.fn.alert.noConflict = function () {
15899 $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close)
15903 /* ========================================================================
15904 * Bootstrap: button.js v3.2
.0
15905 * http://getbootstrap.com/javascript/#buttons
15906 * ========================================================================
15907 * Copyright
2011-
2014 Twitter, Inc.
15908 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
15909 * ======================================================================== */
15915 // BUTTON PUBLIC CLASS DEFINITION
15916 // ==============================
15918 var Button = function (element, options) {
15919 this.$element = $(element)
15920 this.options = $.extend({}, Button.DEFAULTS, options)
15921 this.isLoading = false
15924 Button.VERSION = '
3.2.0'
15926 Button.DEFAULTS = {
15927 loadingText: 'loading...'
15930 Button.prototype.setState = function (state) {
15932 var $el = this.$element
15933 var val = $el.is('input') ? 'val' : 'html'
15934 var data = $el.data()
15936 state = state + 'Text'
15938 if (data.resetText == null) $el.data('resetText', $el[val]())
15940 $el[val](data[state] == null ? this.options[state] : data[state])
15942 // push to event loop to allow forms to submit
15943 setTimeout($.proxy(function () {
15944 if (state == 'loadingText') {
15945 this.isLoading = true
15946 $el.addClass(d).attr(d, d)
15947 } else if (this.isLoading) {
15948 this.isLoading = false
15949 $el.removeClass(d).removeAttr(d)
15954 Button.prototype.toggle = function () {
15956 var $parent = this.$element.closest('[
data-toggle="buttons"]')
15958 if ($parent.length) {
15959 var $input = this.$element.find('input')
15960 if ($input.prop('type') == 'radio') {
15961 if ($input.prop('checked') && this.$element.hasClass('active')) changed = false
15962 else $parent.find('.active').removeClass('active')
15964 if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change')
15967 if (changed) this.$element.toggleClass('active')
15971 // BUTTON PLUGIN DEFINITION
15972 // ========================
15974 function Plugin(option) {
15975 return this.each(function () {
15976 var $this = $(this)
15977 var data = $this.data('bs.button')
15978 var options = typeof option == 'object' && option
15980 if (!data) $this.data('bs.button', (data = new Button(this, options)))
15982 if (option == 'toggle') data.toggle()
15983 else if (option) data.setState(option)
15987 var old = $.fn.button
15989 $.fn.button = Plugin
15990 $.fn.button.Constructor = Button
15993 // BUTTON NO CONFLICT
15994 // ==================
15996 $.fn.button.noConflict = function () {
16005 $(document).on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) {
16006 var $btn = $(e.target)
16007 if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
16008 Plugin.call($btn, 'toggle')
16014 /* ========================================================================
16015 * Bootstrap: carousel.js v3.2
.0
16016 * http://getbootstrap.com/javascript/#carousel
16017 * ========================================================================
16018 * Copyright
2011-
2014 Twitter, Inc.
16019 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
16020 * ======================================================================== */
16026 // CAROUSEL CLASS DEFINITION
16027 // =========================
16029 var Carousel = function (element, options) {
16030 this.$element = $(element).on('keydown.bs.carousel', $.proxy(this.keydown, this))
16031 this.$indicators = this.$element.find('.carousel-indicators')
16032 this.options = options
16039 this.options.pause == 'hover' && this.$element
16040 .on('mouseenter.bs.carousel', $.proxy(this.pause, this))
16041 .on('mouseleave.bs.carousel', $.proxy(this.cycle, this))
16044 Carousel.VERSION = '
3.2.0'
16046 Carousel.DEFAULTS = {
16052 Carousel.prototype.keydown = function (e) {
16054 case
37: this.prev(); break
16055 case
39: this.next(); break
16062 Carousel.prototype.cycle = function (e) {
16063 e || (this.paused = false)
16065 this.interval && clearInterval(this.interval)
16067 this.options.interval
16069 && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
16074 Carousel.prototype.getItemIndex = function (item) {
16075 this.$items = item.parent().children('.item')
16076 return this.$items.index(item || this.$active)
16079 Carousel.prototype.to = function (pos) {
16081 var activeIndex = this.getItemIndex(this.$active = this.$element.find('.item.active'))
16083 if (pos
> (this.$items.length -
1) || pos <
0) return
16085 if (this.sliding) return this.$element.one('slid.bs.carousel', function () { that.to(pos) }) // yes, "slid"
16086 if (activeIndex == pos) return this.pause().cycle()
16088 return this.slide(pos
> activeIndex ? 'next' : 'prev', $(this.$items[pos]))
16091 Carousel.prototype.pause = function (e) {
16092 e || (this.paused = true)
16094 if (this.$element.find('.next, .prev').length && $.support.transition) {
16095 this.$element.trigger($.support.transition.end)
16099 this.interval = clearInterval(this.interval)
16104 Carousel.prototype.next = function () {
16105 if (this.sliding) return
16106 return this.slide('next')
16109 Carousel.prototype.prev = function () {
16110 if (this.sliding) return
16111 return this.slide('prev')
16114 Carousel.prototype.slide = function (type, next) {
16115 var $active = this.$element.find('.item.active')
16116 var $next = next || $active[type]()
16117 var isCycling = this.interval
16118 var direction = type == 'next' ? 'left' : 'right'
16119 var fallback = type == 'next' ? 'first' : 'last'
16122 if (!$next.length) {
16123 if (!this.options.wrap) return
16124 $next = this.$element.find('.item')[fallback]()
16127 if ($next.hasClass('active')) return (this.sliding = false)
16129 var relatedTarget = $next[
0]
16130 var slideEvent = $.Event('slide.bs.carousel', {
16131 relatedTarget: relatedTarget,
16132 direction: direction
16134 this.$element.trigger(slideEvent)
16135 if (slideEvent.isDefaultPrevented()) return
16137 this.sliding = true
16139 isCycling && this.pause()
16141 if (this.$indicators.length) {
16142 this.$indicators.find('.active').removeClass('active')
16143 var $nextIndicator = $(this.$indicators.children()[this.getItemIndex($next)])
16144 $nextIndicator && $nextIndicator.addClass('active')
16147 var slidEvent = $.Event('slid.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) // yes, "slid"
16148 if ($.support.transition && this.$element.hasClass('slide')) {
16149 $next.addClass(type)
16150 $next[
0].offsetWidth // force reflow
16151 $active.addClass(direction)
16152 $next.addClass(direction)
16154 .one('bsTransitionEnd', function () {
16155 $next.removeClass([type, direction].join(' ')).addClass('active')
16156 $active.removeClass(['active', direction].join(' '))
16157 that.sliding = false
16158 setTimeout(function () {
16159 that.$element.trigger(slidEvent)
16162 .emulateTransitionEnd($active.css('transition-duration').slice(
0, -
1) *
1000)
16164 $active.removeClass('active')
16165 $next.addClass('active')
16166 this.sliding = false
16167 this.$element.trigger(slidEvent)
16170 isCycling && this.cycle()
16176 // CAROUSEL PLUGIN DEFINITION
16177 // ==========================
16179 function Plugin(option) {
16180 return this.each(function () {
16181 var $this = $(this)
16182 var data = $this.data('bs.carousel')
16183 var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option)
16184 var action = typeof option == 'string' ? option : options.slide
16186 if (!data) $this.data('bs.carousel', (data = new Carousel(this, options)))
16187 if (typeof option == 'number') data.to(option)
16188 else if (action) data[action]()
16189 else if (options.interval) data.pause().cycle()
16193 var old = $.fn.carousel
16195 $.fn.carousel = Plugin
16196 $.fn.carousel.Constructor = Carousel
16199 // CAROUSEL NO CONFLICT
16200 // ====================
16202 $.fn.carousel.noConflict = function () {
16203 $.fn.carousel = old
16208 // CAROUSEL DATA-API
16209 // =================
16211 $(document).on('click.bs.carousel.data-api', '[data-slide], [data-slide-to]', function (e) {
16213 var $this = $(this)
16214 var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) // strip for ie7
16215 if (!$target.hasClass('carousel')) return
16216 var options = $.extend({}, $target.data(), $this.data())
16217 var slideIndex = $this.attr('data-slide-to')
16218 if (slideIndex) options.interval = false
16220 Plugin.call($target, options)
16223 $target.data('bs.carousel').to(slideIndex)
16229 $(window).on('load', function () {
16230 $('[
data-ride="carousel"]').each(function () {
16231 var $carousel = $(this)
16232 Plugin.call($carousel, $carousel.data())
16238 /* ========================================================================
16239 * Bootstrap: collapse.js v3.2
.0
16240 * http://getbootstrap.com/javascript/#collapse
16241 * ========================================================================
16242 * Copyright
2011-
2014 Twitter, Inc.
16243 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
16244 * ======================================================================== */
16250 // COLLAPSE PUBLIC CLASS DEFINITION
16251 // ================================
16253 var Collapse = function (element, options) {
16254 this.$element = $(element)
16255 this.options = $.extend({}, Collapse.DEFAULTS, options)
16256 this.transitioning = null
16258 if (this.options.parent) this.$parent = $(this.options.parent)
16259 if (this.options.toggle) this.toggle()
16262 Collapse.VERSION = '
3.2.0'
16264 Collapse.DEFAULTS = {
16268 Collapse.prototype.dimension = function () {
16269 var hasWidth = this.$element.hasClass('width')
16270 return hasWidth ? 'width' : 'height'
16273 Collapse.prototype.show = function () {
16274 if (this.transitioning || this.$element.hasClass('in')) return
16276 var startEvent = $.Event('show.bs.collapse')
16277 this.$element.trigger(startEvent)
16278 if (startEvent.isDefaultPrevented()) return
16280 var actives = this.$parent && this.$parent.find('
> .panel
> .in')
16282 if (actives && actives.length) {
16283 var hasData = actives.data('bs.collapse')
16284 if (hasData && hasData.transitioning) return
16285 Plugin.call(actives, 'hide')
16286 hasData || actives.data('bs.collapse', null)
16289 var dimension = this.dimension()
16292 .removeClass('collapse')
16293 .addClass('collapsing')[dimension](
0)
16295 this.transitioning =
1
16297 var complete = function () {
16299 .removeClass('collapsing')
16300 .addClass('collapse in')[dimension]('')
16301 this.transitioning =
0
16303 .trigger('shown.bs.collapse')
16306 if (!$.support.transition) return complete.call(this)
16308 var scrollSize = $.camelCase(['scroll', dimension].join('-'))
16311 .one('bsTransitionEnd', $.proxy(complete, this))
16312 .emulateTransitionEnd(
350)[dimension](this.$element[
0][scrollSize])
16315 Collapse.prototype.hide = function () {
16316 if (this.transitioning || !this.$element.hasClass('in')) return
16318 var startEvent = $.Event('hide.bs.collapse')
16319 this.$element.trigger(startEvent)
16320 if (startEvent.isDefaultPrevented()) return
16322 var dimension = this.dimension()
16324 this.$element[dimension](this.$element[dimension]())[
0].offsetHeight
16327 .addClass('collapsing')
16328 .removeClass('collapse')
16331 this.transitioning =
1
16333 var complete = function () {
16334 this.transitioning =
0
16336 .trigger('hidden.bs.collapse')
16337 .removeClass('collapsing')
16338 .addClass('collapse')
16341 if (!$.support.transition) return complete.call(this)
16345 .one('bsTransitionEnd', $.proxy(complete, this))
16346 .emulateTransitionEnd(
350)
16349 Collapse.prototype.toggle = function () {
16350 this[this.$element.hasClass('in') ? 'hide' : 'show']()
16354 // COLLAPSE PLUGIN DEFINITION
16355 // ==========================
16357 function Plugin(option) {
16358 return this.each(function () {
16359 var $this = $(this)
16360 var data = $this.data('bs.collapse')
16361 var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option)
16363 if (!data && options.toggle && option == 'show') option = !option
16364 if (!data) $this.data('bs.collapse', (data = new Collapse(this, options)))
16365 if (typeof option == 'string') data[option]()
16369 var old = $.fn.collapse
16371 $.fn.collapse = Plugin
16372 $.fn.collapse.Constructor = Collapse
16375 // COLLAPSE NO CONFLICT
16376 // ====================
16378 $.fn.collapse.noConflict = function () {
16379 $.fn.collapse = old
16384 // COLLAPSE DATA-API
16385 // =================
16387 $(document).on('click.bs.collapse.data-api', '[
data-toggle="collapse"]', function (e) {
16389 var $this = $(this)
16390 var target = $this.attr('data-target')
16391 || e.preventDefault()
16392 || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') // strip for ie7
16393 var $target = $(target)
16394 var data = $target.data('bs.collapse')
16395 var option = data ? 'toggle' : $this.data()
16396 var parent = $this.attr('data-parent')
16397 var $parent = parent && $(parent)
16399 if (!data || !data.transitioning) {
16400 if ($parent) $parent.find('[
data-toggle="collapse"][
data-parent="' + parent + '"]').not($this).addClass('collapsed')
16401 $this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
16404 Plugin.call($target, option)
16409 /* ========================================================================
16410 * Bootstrap: dropdown.js v3.2
.0
16411 * http://getbootstrap.com/javascript/#dropdowns
16412 * ========================================================================
16413 * Copyright
2011-
2014 Twitter, Inc.
16414 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
16415 * ======================================================================== */
16421 // DROPDOWN CLASS DEFINITION
16422 // =========================
16424 var backdrop = '.dropdown-backdrop'
16425 var toggle = '[
data-toggle="dropdown"]'
16426 var Dropdown = function (element) {
16427 $(element).on('click.bs.dropdown', this.toggle)
16430 Dropdown.VERSION = '
3.2.0'
16432 Dropdown.prototype.toggle = function (e) {
16433 var $this = $(this)
16435 if ($this.is('.disabled, :disabled')) return
16437 var $parent = getParent($this)
16438 var isActive = $parent.hasClass('open')
16443 if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {
16444 // if mobile we use a backdrop because click events don't delegate
16445 $('
<div class=
"dropdown-backdrop"/>').insertAfter($(this)).on('click', clearMenus)
16448 var relatedTarget = { relatedTarget: this }
16449 $parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget))
16451 if (e.isDefaultPrevented()) return
16453 $this.trigger('focus')
16456 .toggleClass('open')
16457 .trigger('shown.bs.dropdown', relatedTarget)
16463 Dropdown.prototype.keydown = function (e) {
16464 if (!/(
38|
40|
27)/.test(e.keyCode)) return
16466 var $this = $(this)
16469 e.stopPropagation()
16471 if ($this.is('.disabled, :disabled')) return
16473 var $parent = getParent($this)
16474 var isActive = $parent.hasClass('open')
16476 if (!isActive || (isActive && e.keyCode ==
27)) {
16477 if (e.which ==
27) $parent.find(toggle).trigger('focus')
16478 return $this.trigger('click')
16481 var desc = ' li:not(.divider):visible a'
16482 var $items = $parent.find('[
role="menu"]' + desc + ', [
role="listbox"]' + desc)
16484 if (!$items.length) return
16486 var index = $items.index($items.filter(':focus'))
16488 if (e.keyCode ==
38 && index
> 0) index-- // up
16489 if (e.keyCode ==
40 && index < $items.length -
1) index++ // down
16490 if (!~index) index =
0
16492 $items.eq(index).trigger('focus')
16495 function clearMenus(e) {
16496 if (e && e.which ===
3) return
16497 $(backdrop).remove()
16498 $(toggle).each(function () {
16499 var $parent = getParent($(this))
16500 var relatedTarget = { relatedTarget: this }
16501 if (!$parent.hasClass('open')) return
16502 $parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
16503 if (e.isDefaultPrevented()) return
16504 $parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget)
16508 function getParent($this) {
16509 var selector = $this.attr('data-target')
16512 selector = $this.attr('href')
16513 selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
16516 var $parent = selector && $(selector)
16518 return $parent && $parent.length ? $parent : $this.parent()
16522 // DROPDOWN PLUGIN DEFINITION
16523 // ==========================
16525 function Plugin(option) {
16526 return this.each(function () {
16527 var $this = $(this)
16528 var data = $this.data('bs.dropdown')
16530 if (!data) $this.data('bs.dropdown', (data = new Dropdown(this)))
16531 if (typeof option == 'string') data[option].call($this)
16535 var old = $.fn.dropdown
16537 $.fn.dropdown = Plugin
16538 $.fn.dropdown.Constructor = Dropdown
16541 // DROPDOWN NO CONFLICT
16542 // ====================
16544 $.fn.dropdown.noConflict = function () {
16545 $.fn.dropdown = old
16550 // APPLY TO STANDARD DROPDOWN ELEMENTS
16551 // ===================================
16554 .on('click.bs.dropdown.data-api', clearMenus)
16555 .on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
16556 .on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle)
16557 .on('keydown.bs.dropdown.data-api', toggle + ', [
role=
"menu"], [
role=
"listbox"]', Dropdown.prototype.keydown)
16561 /* ========================================================================
16562 * Bootstrap: modal.js v3.2
.0
16563 * http://getbootstrap.com/javascript/#modals
16564 * ========================================================================
16565 * Copyright
2011-
2014 Twitter, Inc.
16566 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
16567 * ======================================================================== */
16573 // MODAL CLASS DEFINITION
16574 // ======================
16576 var Modal = function (element, options) {
16577 this.options = options
16578 this.$body = $(document.body)
16579 this.$element = $(element)
16581 this.isShown = null
16582 this.scrollbarWidth =
0
16584 if (this.options.remote) {
16586 .find('.modal-content')
16587 .load(this.options.remote, $.proxy(function () {
16588 this.$element.trigger('loaded.bs.modal')
16593 Modal.VERSION = '
3.2.0'
16601 Modal.prototype.toggle = function (_relatedTarget) {
16602 return this.isShown ? this.hide() : this.show(_relatedTarget)
16605 Modal.prototype.show = function (_relatedTarget) {
16607 var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })
16609 this.$element.trigger(e)
16611 if (this.isShown || e.isDefaultPrevented()) return
16613 this.isShown = true
16615 this.checkScrollbar()
16616 this.$body.addClass('modal-open')
16618 this.setScrollbar()
16621 this.$element.on('click.dismiss.bs.modal', '[
data-dismiss=
"modal"]', $.proxy(this.hide, this))
16623 this.backdrop(function () {
16624 var transition = $.support.transition && that.$element.hasClass('fade')
16626 if (!that.$element.parent().length) {
16627 that.$element.appendTo(that.$body) // don't move modals dom position
16635 that.$element[
0].offsetWidth // force reflow
16640 .attr('aria-hidden', false)
16642 that.enforceFocus()
16644 var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget })
16647 that.$element.find('.modal-dialog') // wait for modal to slide in
16648 .one('bsTransitionEnd', function () {
16649 that.$element.trigger('focus').trigger(e)
16651 .emulateTransitionEnd(
300) :
16652 that.$element.trigger('focus').trigger(e)
16656 Modal.prototype.hide = function (e) {
16657 if (e) e.preventDefault()
16659 e = $.Event('hide.bs.modal')
16661 this.$element.trigger(e)
16663 if (!this.isShown || e.isDefaultPrevented()) return
16665 this.isShown = false
16667 this.$body.removeClass('modal-open')
16669 this.resetScrollbar()
16672 $(document).off('focusin.bs.modal')
16676 .attr('aria-hidden', true)
16677 .off('click.dismiss.bs.modal')
16679 $.support.transition && this.$element.hasClass('fade') ?
16681 .one('bsTransitionEnd', $.proxy(this.hideModal, this))
16682 .emulateTransitionEnd(
300) :
16686 Modal.prototype.enforceFocus = function () {
16688 .off('focusin.bs.modal') // guard against infinite focus loop
16689 .on('focusin.bs.modal', $.proxy(function (e) {
16690 if (this.$element[
0] !== e.target && !this.$element.has(e.target).length) {
16691 this.$element.trigger('focus')
16696 Modal.prototype.escape = function () {
16697 if (this.isShown && this.options.keyboard) {
16698 this.$element.on('keyup.dismiss.bs.modal', $.proxy(function (e) {
16699 e.which ==
27 && this.hide()
16701 } else if (!this.isShown) {
16702 this.$element.off('keyup.dismiss.bs.modal')
16706 Modal.prototype.hideModal = function () {
16708 this.$element.hide()
16709 this.backdrop(function () {
16710 that.$element.trigger('hidden.bs.modal')
16714 Modal.prototype.removeBackdrop = function () {
16715 this.$backdrop && this.$backdrop.remove()
16716 this.$backdrop = null
16719 Modal.prototype.backdrop = function (callback) {
16721 var animate = this.$element.hasClass('fade') ? 'fade' : ''
16723 if (this.isShown && this.options.backdrop) {
16724 var doAnimate = $.support.transition && animate
16726 this.$backdrop = $('
<div class=
"modal-backdrop ' + animate + '" />')
16727 .appendTo(this.$body)
16729 this.$element.on('click.dismiss.bs.modal', $.proxy(function (e) {
16730 if (e.target !== e.currentTarget) return
16731 this.options.backdrop == 'static'
16732 ? this.$element[
0].focus.call(this.$element[
0])
16733 : this.hide.call(this)
16736 if (doAnimate) this.$backdrop[
0].offsetWidth // force reflow
16738 this.$backdrop.addClass('in')
16740 if (!callback) return
16744 .one('bsTransitionEnd', callback)
16745 .emulateTransitionEnd(
150) :
16748 } else if (!this.isShown && this.$backdrop) {
16749 this.$backdrop.removeClass('in')
16751 var callbackRemove = function () {
16752 that.removeBackdrop()
16753 callback && callback()
16755 $.support.transition && this.$element.hasClass('fade') ?
16757 .one('bsTransitionEnd', callbackRemove)
16758 .emulateTransitionEnd(
150) :
16761 } else if (callback) {
16766 Modal.prototype.checkScrollbar = function () {
16767 if (document.body.clientWidth
>= window.innerWidth) return
16768 this.scrollbarWidth = this.scrollbarWidth || this.measureScrollbar()
16771 Modal.prototype.setScrollbar = function () {
16772 var bodyPad = parseInt((this.$body.css('padding-right') ||
0),
10)
16773 if (this.scrollbarWidth) this.$body.css('padding-right', bodyPad + this.scrollbarWidth)
16776 Modal.prototype.resetScrollbar = function () {
16777 this.$body.css('padding-right', '')
16780 Modal.prototype.measureScrollbar = function () { // thx walsh
16781 var scrollDiv = document.createElement('div')
16782 scrollDiv.className = 'modal-scrollbar-measure'
16783 this.$body.append(scrollDiv)
16784 var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth
16785 this.$body[
0].removeChild(scrollDiv)
16786 return scrollbarWidth
16790 // MODAL PLUGIN DEFINITION
16791 // =======================
16793 function Plugin(option, _relatedTarget) {
16794 return this.each(function () {
16795 var $this = $(this)
16796 var data = $this.data('bs.modal')
16797 var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)
16799 if (!data) $this.data('bs.modal', (data = new Modal(this, options)))
16800 if (typeof option == 'string') data[option](_relatedTarget)
16801 else if (options.show) data.show(_relatedTarget)
16805 var old = $.fn.modal
16807 $.fn.modal = Plugin
16808 $.fn.modal.Constructor = Modal
16811 // MODAL NO CONFLICT
16812 // =================
16814 $.fn.modal.noConflict = function () {
16823 $(document).on('click.bs.modal.data-api', '[
data-toggle="modal"]', function (e) {
16824 var $this = $(this)
16825 var href = $this.attr('href')
16826 var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) // strip for ie7
16827 var option = $target.data('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
16829 if ($this.is('a')) e.preventDefault()
16831 $target.one('show.bs.modal', function (showEvent) {
16832 if (showEvent.isDefaultPrevented()) return // only register focus restorer if modal will actually get shown
16833 $target.one('hidden.bs.modal', function () {
16834 $this.is(':visible') && $this.trigger('focus')
16837 Plugin.call($target, option, this)
16842 /* ========================================================================
16843 * Bootstrap: tooltip.js v3.2
.0
16844 * http://getbootstrap.com/javascript/#tooltip
16845 * Inspired by the original jQuery.tipsy by Jason Frame
16846 * ========================================================================
16847 * Copyright
2011-
2014 Twitter, Inc.
16848 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
16849 * ======================================================================== */
16855 // TOOLTIP PUBLIC CLASS DEFINITION
16856 // ===============================
16858 var Tooltip = function (element, options) {
16864 this.$element = null
16866 this.init('tooltip', element, options)
16869 Tooltip.VERSION = '
3.2.0'
16871 Tooltip.DEFAULTS = {
16875 template: '
<div class=
"tooltip" role=
"tooltip"><div class=
"tooltip-arrow"></div><div class=
"tooltip-inner"></div></div>',
16876 trigger: 'hover focus',
16887 Tooltip.prototype.init = function (type, element, options) {
16888 this.enabled = true
16890 this.$element = $(element)
16891 this.options = this.getOptions(options)
16892 this.$viewport = this.options.viewport && $(this.options.viewport.selector || this.options.viewport)
16894 var triggers = this.options.trigger.split(' ')
16896 for (var i = triggers.length; i--;) {
16897 var trigger = triggers[i]
16899 if (trigger == 'click') {
16900 this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
16901 } else if (trigger != 'manual') {
16902 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin'
16903 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout'
16905 this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
16906 this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
16910 this.options.selector ?
16911 (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
16915 Tooltip.prototype.getDefaults = function () {
16916 return Tooltip.DEFAULTS
16919 Tooltip.prototype.getOptions = function (options) {
16920 options = $.extend({}, this.getDefaults(), this.$element.data(), options)
16922 if (options.delay && typeof options.delay == 'number') {
16924 show: options.delay,
16925 hide: options.delay
16932 Tooltip.prototype.getDelegateOptions = function () {
16934 var defaults = this.getDefaults()
16936 this._options && $.each(this._options, function (key, value) {
16937 if (defaults[key] != value) options[key] = value
16943 Tooltip.prototype.enter = function (obj) {
16944 var self = obj instanceof this.constructor ?
16945 obj : $(obj.currentTarget).data('bs.' + this.type)
16948 self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
16949 $(obj.currentTarget).data('bs.' + this.type, self)
16952 clearTimeout(self.timeout)
16954 self.hoverState = 'in'
16956 if (!self.options.delay || !self.options.delay.show) return self.show()
16958 self.timeout = setTimeout(function () {
16959 if (self.hoverState == 'in') self.show()
16960 }, self.options.delay.show)
16963 Tooltip.prototype.leave = function (obj) {
16964 var self = obj instanceof this.constructor ?
16965 obj : $(obj.currentTarget).data('bs.' + this.type)
16968 self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
16969 $(obj.currentTarget).data('bs.' + this.type, self)
16972 clearTimeout(self.timeout)
16974 self.hoverState = 'out'
16976 if (!self.options.delay || !self.options.delay.hide) return self.hide()
16978 self.timeout = setTimeout(function () {
16979 if (self.hoverState == 'out') self.hide()
16980 }, self.options.delay.hide)
16983 Tooltip.prototype.show = function () {
16984 var e = $.Event('show.bs.' + this.type)
16986 if (this.hasContent() && this.enabled) {
16987 this.$element.trigger(e)
16989 var inDom = $.contains(document.documentElement, this.$element[
0])
16990 if (e.isDefaultPrevented() || !inDom) return
16993 var $tip = this.tip()
16995 var tipId = this.getUID(this.type)
16998 $tip.attr('id', tipId)
16999 this.$element.attr('aria-describedby', tipId)
17001 if (this.options.animation) $tip.addClass('fade')
17003 var placement = typeof this.options.placement == 'function' ?
17004 this.options.placement.call(this, $tip[
0], this.$element[
0]) :
17005 this.options.placement
17007 var autoToken = /\s?auto?\s?/i
17008 var autoPlace = autoToken.test(placement)
17009 if (autoPlace) placement = placement.replace(autoToken, '') || 'top'
17013 .css({ top:
0, left:
0, display: 'block' })
17014 .addClass(placement)
17015 .data('bs.' + this.type, this)
17017 this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
17019 var pos = this.getPosition()
17020 var actualWidth = $tip[
0].offsetWidth
17021 var actualHeight = $tip[
0].offsetHeight
17024 var orgPlacement = placement
17025 var $parent = this.$element.parent()
17026 var parentDim = this.getPosition($parent)
17028 placement = placement == 'bottom' && pos.top + pos.height + actualHeight - parentDim.scroll
> parentDim.height ? 'top' :
17029 placement == 'top' && pos.top - parentDim.scroll - actualHeight <
0 ? 'bottom' :
17030 placement == 'right' && pos.right + actualWidth
> parentDim.width ? 'left' :
17031 placement == 'left' && pos.left - actualWidth < parentDim.left ? 'right' :
17035 .removeClass(orgPlacement)
17036 .addClass(placement)
17039 var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight)
17041 this.applyPlacement(calculatedOffset, placement)
17043 var complete = function () {
17044 that.$element.trigger('shown.bs.' + that.type)
17045 that.hoverState = null
17048 $.support.transition && this.$tip.hasClass('fade') ?
17050 .one('bsTransitionEnd', complete)
17051 .emulateTransitionEnd(
150) :
17056 Tooltip.prototype.applyPlacement = function (offset, placement) {
17057 var $tip = this.tip()
17058 var width = $tip[
0].offsetWidth
17059 var height = $tip[
0].offsetHeight
17061 // manually read margins because getBoundingClientRect includes difference
17062 var marginTop = parseInt($tip.css('margin-top'),
10)
17063 var marginLeft = parseInt($tip.css('margin-left'),
10)
17065 // we must check for NaN for ie
8/
9
17066 if (isNaN(marginTop)) marginTop =
0
17067 if (isNaN(marginLeft)) marginLeft =
0
17069 offset.top = offset.top + marginTop
17070 offset.left = offset.left + marginLeft
17072 // $.fn.offset doesn't round pixel values
17073 // so we use setOffset directly with our own function B-
0
17074 $.offset.setOffset($tip[
0], $.extend({
17075 using: function (props) {
17077 top: Math.round(props.top),
17078 left: Math.round(props.left)
17083 $tip.addClass('in')
17085 // check to see if placing tip in new offset caused the tip to resize itself
17086 var actualWidth = $tip[
0].offsetWidth
17087 var actualHeight = $tip[
0].offsetHeight
17089 if (placement == 'top' && actualHeight != height) {
17090 offset.top = offset.top + height - actualHeight
17093 var delta = this.getViewportAdjustedDelta(placement, offset, actualWidth, actualHeight)
17095 if (delta.left) offset.left += delta.left
17096 else offset.top += delta.top
17098 var arrowDelta = delta.left ? delta.left *
2 - width + actualWidth : delta.top *
2 - height + actualHeight
17099 var arrowPosition = delta.left ? 'left' : 'top'
17100 var arrowOffsetPosition = delta.left ? 'offsetWidth' : 'offsetHeight'
17102 $tip.offset(offset)
17103 this.replaceArrow(arrowDelta, $tip[
0][arrowOffsetPosition], arrowPosition)
17106 Tooltip.prototype.replaceArrow = function (delta, dimension, position) {
17107 this.arrow().css(position, delta ? (
50 * (
1 - delta / dimension) + '%') : '')
17110 Tooltip.prototype.setContent = function () {
17111 var $tip = this.tip()
17112 var title = this.getTitle()
17114 $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
17115 $tip.removeClass('fade in top bottom left right')
17118 Tooltip.prototype.hide = function () {
17120 var $tip = this.tip()
17121 var e = $.Event('hide.bs.' + this.type)
17123 this.$element.removeAttr('aria-describedby')
17125 function complete() {
17126 if (that.hoverState != 'in') $tip.detach()
17127 that.$element.trigger('hidden.bs.' + that.type)
17130 this.$element.trigger(e)
17132 if (e.isDefaultPrevented()) return
17134 $tip.removeClass('in')
17136 $.support.transition && this.$tip.hasClass('fade') ?
17138 .one('bsTransitionEnd', complete)
17139 .emulateTransitionEnd(
150) :
17142 this.hoverState = null
17147 Tooltip.prototype.fixTitle = function () {
17148 var $e = this.$element
17149 if ($e.attr('title') || typeof ($e.attr('data-original-title')) != 'string') {
17150 $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
17154 Tooltip.prototype.hasContent = function () {
17155 return this.getTitle()
17158 Tooltip.prototype.getPosition = function ($element) {
17159 $element = $element || this.$element
17160 var el = $element[
0]
17161 var isBody = el.tagName == 'BODY'
17162 return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : null, {
17163 scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop(),
17164 width: isBody ? $(window).width() : $element.outerWidth(),
17165 height: isBody ? $(window).height() : $element.outerHeight()
17166 }, isBody ? { top:
0, left:
0 } : $element.offset())
17169 Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {
17170 return placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width /
2 - actualWidth /
2 } :
17171 placement == 'top' ? { top: pos.top - actualHeight, left: pos.left + pos.width /
2 - actualWidth /
2 } :
17172 placement == 'left' ? { top: pos.top + pos.height /
2 - actualHeight /
2, left: pos.left - actualWidth } :
17173 /* placement == 'right' */ { top: pos.top + pos.height /
2 - actualHeight /
2, left: pos.left + pos.width }
17177 Tooltip.prototype.getViewportAdjustedDelta = function (placement, pos, actualWidth, actualHeight) {
17178 var delta = { top:
0, left:
0 }
17179 if (!this.$viewport) return delta
17181 var viewportPadding = this.options.viewport && this.options.viewport.padding ||
0
17182 var viewportDimensions = this.getPosition(this.$viewport)
17184 if (/right|left/.test(placement)) {
17185 var topEdgeOffset = pos.top - viewportPadding - viewportDimensions.scroll
17186 var bottomEdgeOffset = pos.top + viewportPadding - viewportDimensions.scroll + actualHeight
17187 if (topEdgeOffset < viewportDimensions.top) { // top overflow
17188 delta.top = viewportDimensions.top - topEdgeOffset
17189 } else if (bottomEdgeOffset
> viewportDimensions.top + viewportDimensions.height) { // bottom overflow
17190 delta.top = viewportDimensions.top + viewportDimensions.height - bottomEdgeOffset
17193 var leftEdgeOffset = pos.left - viewportPadding
17194 var rightEdgeOffset = pos.left + viewportPadding + actualWidth
17195 if (leftEdgeOffset < viewportDimensions.left) { // left overflow
17196 delta.left = viewportDimensions.left - leftEdgeOffset
17197 } else if (rightEdgeOffset
> viewportDimensions.width) { // right overflow
17198 delta.left = viewportDimensions.left + viewportDimensions.width - rightEdgeOffset
17205 Tooltip.prototype.getTitle = function () {
17207 var $e = this.$element
17208 var o = this.options
17210 title = $e.attr('data-original-title')
17211 || (typeof o.title == 'function' ? o.title.call($e[
0]) : o.title)
17216 Tooltip.prototype.getUID = function (prefix) {
17217 do prefix += ~~(Math.random() *
1000000)
17218 while (document.getElementById(prefix))
17222 Tooltip.prototype.tip = function () {
17223 return (this.$tip = this.$tip || $(this.options.template))
17226 Tooltip.prototype.arrow = function () {
17227 return (this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow'))
17230 Tooltip.prototype.validate = function () {
17231 if (!this.$element[
0].parentNode) {
17233 this.$element = null
17234 this.options = null
17238 Tooltip.prototype.enable = function () {
17239 this.enabled = true
17242 Tooltip.prototype.disable = function () {
17243 this.enabled = false
17246 Tooltip.prototype.toggleEnabled = function () {
17247 this.enabled = !this.enabled
17250 Tooltip.prototype.toggle = function (e) {
17253 self = $(e.currentTarget).data('bs.' + this.type)
17255 self = new this.constructor(e.currentTarget, this.getDelegateOptions())
17256 $(e.currentTarget).data('bs.' + this.type, self)
17260 self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
17263 Tooltip.prototype.destroy = function () {
17264 clearTimeout(this.timeout)
17265 this.hide().$element.off('.' + this.type).removeData('bs.' + this.type)
17269 // TOOLTIP PLUGIN DEFINITION
17270 // =========================
17272 function Plugin(option) {
17273 return this.each(function () {
17274 var $this = $(this)
17275 var data = $this.data('bs.tooltip')
17276 var options = typeof option == 'object' && option
17278 if (!data && option == 'destroy') return
17279 if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
17280 if (typeof option == 'string') data[option]()
17284 var old = $.fn.tooltip
17286 $.fn.tooltip = Plugin
17287 $.fn.tooltip.Constructor = Tooltip
17290 // TOOLTIP NO CONFLICT
17291 // ===================
17293 $.fn.tooltip.noConflict = function () {
17300 /* ========================================================================
17301 * Bootstrap: popover.js v3.2
.0
17302 * http://getbootstrap.com/javascript/#popovers
17303 * ========================================================================
17304 * Copyright
2011-
2014 Twitter, Inc.
17305 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
17306 * ======================================================================== */
17312 // POPOVER PUBLIC CLASS DEFINITION
17313 // ===============================
17315 var Popover = function (element, options) {
17316 this.init('popover', element, options)
17319 if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js')
17321 Popover.VERSION = '
3.2.0'
17323 Popover.DEFAULTS = $.extend({}, $.fn.tooltip.Constructor.DEFAULTS, {
17324 placement: 'right',
17327 template: '
<div class=
"popover" role=
"tooltip"><div class=
"arrow"></div><h3 class=
"popover-title"></h3><div class=
"popover-content"></div></div>'
17331 // NOTE: POPOVER EXTENDS tooltip.js
17332 // ================================
17334 Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype)
17336 Popover.prototype.constructor = Popover
17338 Popover.prototype.getDefaults = function () {
17339 return Popover.DEFAULTS
17342 Popover.prototype.setContent = function () {
17343 var $tip = this.tip()
17344 var title = this.getTitle()
17345 var content = this.getContent()
17347 $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
17348 $tip.find('.popover-content').empty()[ // we use append for html objects to maintain js events
17349 this.options.html ? (typeof content == 'string' ? 'html' : 'append') : 'text'
17352 $tip.removeClass('fade top bottom left right in')
17354 // IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do
17355 // this manually by checking the contents.
17356 if (!$tip.find('.popover-title').html()) $tip.find('.popover-title').hide()
17359 Popover.prototype.hasContent = function () {
17360 return this.getTitle() || this.getContent()
17363 Popover.prototype.getContent = function () {
17364 var $e = this.$element
17365 var o = this.options
17367 return $e.attr('data-content')
17368 || (typeof o.content == 'function' ?
17369 o.content.call($e[
0]) :
17373 Popover.prototype.arrow = function () {
17374 return (this.$arrow = this.$arrow || this.tip().find('.arrow'))
17377 Popover.prototype.tip = function () {
17378 if (!this.$tip) this.$tip = $(this.options.template)
17383 // POPOVER PLUGIN DEFINITION
17384 // =========================
17386 function Plugin(option) {
17387 return this.each(function () {
17388 var $this = $(this)
17389 var data = $this.data('bs.popover')
17390 var options = typeof option == 'object' && option
17392 if (!data && option == 'destroy') return
17393 if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
17394 if (typeof option == 'string') data[option]()
17398 var old = $.fn.popover
17400 $.fn.popover = Plugin
17401 $.fn.popover.Constructor = Popover
17404 // POPOVER NO CONFLICT
17405 // ===================
17407 $.fn.popover.noConflict = function () {
17414 /* ========================================================================
17415 * Bootstrap: scrollspy.js v3.2
.0
17416 * http://getbootstrap.com/javascript/#scrollspy
17417 * ========================================================================
17418 * Copyright
2011-
2014 Twitter, Inc.
17419 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
17420 * ======================================================================== */
17426 // SCROLLSPY CLASS DEFINITION
17427 // ==========================
17429 function ScrollSpy(element, options) {
17430 var process = $.proxy(this.process, this)
17432 this.$body = $('body')
17433 this.$scrollElement = $(element).is('body') ? $(window) : $(element)
17434 this.options = $.extend({}, ScrollSpy.DEFAULTS, options)
17435 this.selector = (this.options.target || '') + ' .nav li
> a'
17438 this.activeTarget = null
17439 this.scrollHeight =
0
17441 this.$scrollElement.on('scroll.bs.scrollspy', process)
17446 ScrollSpy.VERSION = '
3.2.0'
17448 ScrollSpy.DEFAULTS = {
17452 ScrollSpy.prototype.getScrollHeight = function () {
17453 return this.$scrollElement[
0].scrollHeight || Math.max(this.$body[
0].scrollHeight, document.documentElement.scrollHeight)
17456 ScrollSpy.prototype.refresh = function () {
17457 var offsetMethod = 'offset'
17460 if (!$.isWindow(this.$scrollElement[
0])) {
17461 offsetMethod = 'position'
17462 offsetBase = this.$scrollElement.scrollTop()
17467 this.scrollHeight = this.getScrollHeight()
17472 .find(this.selector)
17475 var href = $el.data('target') || $el.attr('href')
17476 var $href = /^#./.test(href) && $(href)
17480 && $href.is(':visible')
17481 && [[$href[offsetMethod]().top + offsetBase, href]]) || null
17483 .sort(function (a, b) { return a[
0] - b[
0] })
17484 .each(function () {
17485 self.offsets.push(this[
0])
17486 self.targets.push(this[
1])
17490 ScrollSpy.prototype.process = function () {
17491 var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
17492 var scrollHeight = this.getScrollHeight()
17493 var maxScroll = this.options.offset + scrollHeight - this.$scrollElement.height()
17494 var offsets = this.offsets
17495 var targets = this.targets
17496 var activeTarget = this.activeTarget
17499 if (this.scrollHeight != scrollHeight) {
17503 if (scrollTop
>= maxScroll) {
17504 return activeTarget != (i = targets[targets.length -
1]) && this.activate(i)
17507 if (activeTarget && scrollTop <= offsets[
0]) {
17508 return activeTarget != (i = targets[
0]) && this.activate(i)
17511 for (i = offsets.length; i--;) {
17512 activeTarget != targets[i]
17513 && scrollTop
>= offsets[i]
17514 && (!offsets[i +
1] || scrollTop <= offsets[i +
1])
17515 && this.activate(targets[i])
17519 ScrollSpy.prototype.activate = function (target) {
17520 this.activeTarget = target
17523 .parentsUntil(this.options.target, '.active')
17524 .removeClass('active')
17526 var selector = this.selector +
17527 '[
data-target="' + target + '"],' +
17528 this.selector + '[
href="' + target + '"]'
17530 var active = $(selector)
17532 .addClass('active')
17534 if (active.parent('.dropdown-menu').length) {
17536 .closest('li.dropdown')
17537 .addClass('active')
17540 active.trigger('activate.bs.scrollspy')
17544 // SCROLLSPY PLUGIN DEFINITION
17545 // ===========================
17547 function Plugin(option) {
17548 return this.each(function () {
17549 var $this = $(this)
17550 var data = $this.data('bs.scrollspy')
17551 var options = typeof option == 'object' && option
17553 if (!data) $this.data('bs.scrollspy', (data = new ScrollSpy(this, options)))
17554 if (typeof option == 'string') data[option]()
17558 var old = $.fn.scrollspy
17560 $.fn.scrollspy = Plugin
17561 $.fn.scrollspy.Constructor = ScrollSpy
17564 // SCROLLSPY NO CONFLICT
17565 // =====================
17567 $.fn.scrollspy.noConflict = function () {
17568 $.fn.scrollspy = old
17573 // SCROLLSPY DATA-API
17574 // ==================
17576 $(window).on('load.bs.scrollspy.data-api', function () {
17577 $('[
data-spy="scroll"]').each(function () {
17579 Plugin.call($spy, $spy.data())
17585 /* ========================================================================
17586 * Bootstrap: tab.js v3.2
.0
17587 * http://getbootstrap.com/javascript/#tabs
17588 * ========================================================================
17589 * Copyright
2011-
2014 Twitter, Inc.
17590 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
17591 * ======================================================================== */
17597 // TAB CLASS DEFINITION
17598 // ====================
17600 var Tab = function (element) {
17601 this.element = $(element)
17604 Tab.VERSION = '
3.2.0'
17606 Tab.prototype.show = function () {
17607 var $this = this.element
17608 var $ul = $this.closest('ul:not(.dropdown-menu)')
17609 var selector = $this.data('target')
17612 selector = $this.attr('href')
17613 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
17616 if ($this.parent('li').hasClass('active')) return
17618 var previous = $ul.find('.active:last a')[
0]
17619 var e = $.Event('show.bs.tab', {
17620 relatedTarget: previous
17625 if (e.isDefaultPrevented()) return
17627 var $target = $(selector)
17629 this.activate($this.closest('li'), $ul)
17630 this.activate($target, $target.parent(), function () {
17632 type: 'shown.bs.tab',
17633 relatedTarget: previous
17638 Tab.prototype.activate = function (element, container, callback) {
17639 var $active = container.find('
> .active')
17640 var transition = callback
17641 && $.support.transition
17642 && $active.hasClass('fade')
17646 .removeClass('active')
17647 .find('
> .dropdown-menu
> .active')
17648 .removeClass('active')
17650 element.addClass('active')
17653 element[
0].offsetWidth // reflow for transition
17654 element.addClass('in')
17656 element.removeClass('fade')
17659 if (element.parent('.dropdown-menu')) {
17660 element.closest('li.dropdown').addClass('active')
17663 callback && callback()
17668 .one('bsTransitionEnd', next)
17669 .emulateTransitionEnd(
150) :
17672 $active.removeClass('in')
17676 // TAB PLUGIN DEFINITION
17677 // =====================
17679 function Plugin(option) {
17680 return this.each(function () {
17681 var $this = $(this)
17682 var data = $this.data('bs.tab')
17684 if (!data) $this.data('bs.tab', (data = new Tab(this)))
17685 if (typeof option == 'string') data[option]()
17692 $.fn.tab.Constructor = Tab
17698 $.fn.tab.noConflict = function () {
17707 $(document).on('click.bs.tab.data-api', '[
data-toggle="tab"], [
data-toggle="pill"]', function (e) {
17709 Plugin.call($(this), 'show')
17714 /* ========================================================================
17715 * Bootstrap: affix.js v3.2
.0
17716 * http://getbootstrap.com/javascript/#affix
17717 * ========================================================================
17718 * Copyright
2011-
2014 Twitter, Inc.
17719 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
17720 * ======================================================================== */
17726 // AFFIX CLASS DEFINITION
17727 // ======================
17729 var Affix = function (element, options) {
17730 this.options = $.extend({}, Affix.DEFAULTS, options)
17732 this.$target = $(this.options.target)
17733 .on('scroll.bs.affix.data-api', $.proxy(this.checkPosition, this))
17734 .on('click.bs.affix.data-api', $.proxy(this.checkPositionWithEventLoop, this))
17736 this.$element = $(element)
17739 this.pinnedOffset = null
17741 this.checkPosition()
17744 Affix.VERSION = '
3.2.0'
17746 Affix.RESET = 'affix affix-top affix-bottom'
17753 Affix.prototype.getPinnedOffset = function () {
17754 if (this.pinnedOffset) return this.pinnedOffset
17755 this.$element.removeClass(Affix.RESET).addClass('affix')
17756 var scrollTop = this.$target.scrollTop()
17757 var position = this.$element.offset()
17758 return (this.pinnedOffset = position.top - scrollTop)
17761 Affix.prototype.checkPositionWithEventLoop = function () {
17762 setTimeout($.proxy(this.checkPosition, this),
1)
17765 Affix.prototype.checkPosition = function () {
17766 if (!this.$element.is(':visible')) return
17768 var scrollHeight = $(document).height()
17769 var scrollTop = this.$target.scrollTop()
17770 var position = this.$element.offset()
17771 var offset = this.options.offset
17772 var offsetTop = offset.top
17773 var offsetBottom = offset.bottom
17775 if (typeof offset != 'object') offsetBottom = offsetTop = offset
17776 if (typeof offsetTop == 'function') offsetTop = offset.top(this.$element)
17777 if (typeof offsetBottom == 'function') offsetBottom = offset.bottom(this.$element)
17779 var affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ? false :
17780 offsetBottom != null && (position.top + this.$element.height()
>= scrollHeight - offsetBottom) ? 'bottom' :
17781 offsetTop != null && (scrollTop <= offsetTop) ? 'top' : false
17783 if (this.affixed === affix) return
17784 if (this.unpin != null) this.$element.css('top', '')
17786 var affixType = 'affix' + (affix ? '-' + affix : '')
17787 var e = $.Event(affixType + '.bs.affix')
17789 this.$element.trigger(e)
17791 if (e.isDefaultPrevented()) return
17793 this.affixed = affix
17794 this.unpin = affix == 'bottom' ? this.getPinnedOffset() : null
17797 .removeClass(Affix.RESET)
17798 .addClass(affixType)
17799 .trigger($.Event(affixType.replace('affix', 'affixed')))
17801 if (affix == 'bottom') {
17802 this.$element.offset({
17803 top: scrollHeight - this.$element.height() - offsetBottom
17809 // AFFIX PLUGIN DEFINITION
17810 // =======================
17812 function Plugin(option) {
17813 return this.each(function () {
17814 var $this = $(this)
17815 var data = $this.data('bs.affix')
17816 var options = typeof option == 'object' && option
17818 if (!data) $this.data('bs.affix', (data = new Affix(this, options)))
17819 if (typeof option == 'string') data[option]()
17823 var old = $.fn.affix
17825 $.fn.affix = Plugin
17826 $.fn.affix.Constructor = Affix
17829 // AFFIX NO CONFLICT
17830 // =================
17832 $.fn.affix.noConflict = function () {
17841 $(window).on('load', function () {
17842 $('[
data-spy="affix"]').each(function () {
17844 var data = $spy.data()
17846 data.offset = data.offset || {}
17848 if (data.offsetBottom) data.offset.bottom = data.offsetBottom
17849 if (data.offsetTop) data.offset.top = data.offsetTop
17851 Plugin.call($spy, data)
17858 (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){
17859 var assert = _dereq_('assert')
17861 module.exports = BigInteger
17863 // JavaScript engine analysis
17864 var canary =
0xdeadbeefcafe;
17865 var j_lm = ((canary&
0xffffff)==
0xefcafe);
17867 // (public) Constructor
17868 function BigInteger(a,b,c) {
17869 if (!(this instanceof BigInteger)) {
17870 return new BigInteger(a, b, c);
17874 if(
"number" == typeof a) this.fromNumber(a,b,c);
17875 else if(b == null &&
"string" != typeof a) this.fromString(a,
256);
17876 else this.fromString(a,b);
17880 var proto = BigInteger.prototype;
17882 // return new, unset BigInteger
17883 function nbi() { return new BigInteger(null); }
17888 // am: Compute w_j += (x*this_i), propagate carries,
17889 // c is initial carry, returns final carry.
17890 // c <
3*dvalue, x <
2*dvalue, this_i < dvalue
17891 // We need to select the fastest one that works in this environment.
17893 // am1: use a single mult and divide to get the high bits,
17894 // max digit bits should be
26 because
17895 // max internal value =
2*dvalue^
2-
2*dvalue (<
2^
53)
17896 function am1(i,x,w,j,c,n) {
17898 var v = x*this[i++]+w[j]+c;
17899 c = Math.floor(v/
0x4000000);
17900 w[j++] = v
&0x3ffffff;
17904 // am2 avoids a big mult-and-extract completely.
17905 // Max digit bits should be <=
30 because we do bitwise ops
17906 // on values up to
2*hdvalue^
2-hdvalue-
1 (<
2^
31)
17907 function am2(i,x,w,j,c,n) {
17908 var xl = x&
0x7fff, xh = x
>>15;
17910 var l = this[i]
&0x7fff;
17911 var h = this[i++]
>>15;
17913 l = xl*l+((m&
0x7fff)<
<15)+w[j]+(c&
0x3fffffff);
17914 c = (l
>>>30)+(m
>>>15)+xh*h+(c
>>>30);
17915 w[j++] = l
&0x3fffffff;
17919 // Alternately, set max digit bits to
28 since some
17920 // browsers slow down when dealing with
32-bit numbers.
17921 function am3(i,x,w,j,c,n) {
17922 var xl = x&
0x3fff, xh = x
>>14;
17924 var l = this[i]
&0x3fff;
17925 var h = this[i++]
>>14;
17927 l = xl*l+((m&
0x3fff)<
<14)+w[j]+c;
17928 c = (l
>>28)+(m
>>14)+xh*h;
17929 w[j++] = l
&0xfffffff;
17935 BigInteger.prototype.am = am1;
17939 if(j_lm && (navigator.appName ==
"Microsoft Internet Explorer")) {
17940 BigInteger.prototype.am = am2;
17943 else if(j_lm && (navigator.appName !=
"Netscape")) {
17944 BigInteger.prototype.am = am1;
17947 else { // Mozilla/Netscape seems to prefer am3
17948 BigInteger.prototype.am = am3;
17953 BigInteger.prototype.DB = dbits;
17954 BigInteger.prototype.DM = ((
1<
<dbits)-
1);
17955 var DV = BigInteger.prototype.DV = (
1<
<dbits);
17958 BigInteger.prototype.FV = Math.pow(
2,BI_FP);
17959 BigInteger.prototype.F1 = BI_FP-dbits;
17960 BigInteger.prototype.F2 =
2*dbits-BI_FP;
17962 // Digit conversions
17963 var BI_RM =
"0123456789abcdefghijklmnopqrstuvwxyz";
17964 var BI_RC = new Array();
17966 rr =
"0".charCodeAt(
0);
17967 for(vv =
0; vv <=
9; ++vv) BI_RC[rr++] = vv;
17968 rr =
"a".charCodeAt(
0);
17969 for(vv =
10; vv <
36; ++vv) BI_RC[rr++] = vv;
17970 rr =
"A".charCodeAt(
0);
17971 for(vv =
10; vv <
36; ++vv) BI_RC[rr++] = vv;
17973 function int2char(n) { return BI_RM.charAt(n); }
17974 function intAt(s,i) {
17975 var c = BI_RC[s.charCodeAt(i)];
17976 return (c==null)?-
1:c;
17979 // (protected) copy this to r
17980 function bnpCopyTo(r) {
17981 for(var i = this.t-
1; i
>=
0; --i) r[i] = this[i];
17986 // (protected) set from integer value x, -DV <= x < DV
17987 function bnpFromInt(x) {
17989 this.s = (x
<0)?-
1:
0;
17990 if(x
> 0) this[
0] = x;
17991 else if(x < -
1) this[
0] = x+DV;
17995 // return bigint initialized to value
17996 function nbv(i) { var r = nbi(); r.fromInt(i); return r; }
17998 // (protected) set from string and radix
17999 function bnpFromString(s,b) {
18004 else if(b ==
8) k =
3;
18005 else if(b ==
256) k =
8; // byte array
18006 else if(b ==
2) k =
1;
18007 else if(b ==
32) k =
5;
18008 else if(b ==
4) k =
2;
18009 else { self.fromRadix(s,b); return; }
18012 var i = s.length, mi = false, sh =
0;
18014 var x = (k==
8)?s[i]&
0xff:intAt(s,i);
18016 if(s.charAt(i) == "-") mi = true;
18021 self[self.t++] = x;
18022 else if(sh+k
> self.DB) {
18023 self[self.t-
1] |= (x&((
1<<(self.DB-sh))-
1))<
<sh;
18024 self[self.t++] = (x
>>(self.DB-sh));
18027 self[self.t-
1] |= x<
<sh;
18029 if(sh
>= self.DB) sh -= self.DB;
18031 if(k ==
8 && (s[
0]&
0x80) !=
0) {
18033 if(sh
> 0) self[self.t-
1] |= ((
1<<(self.DB-sh))-
1)<
<sh;
18036 if(mi) BigInteger.ZERO.subTo(self,self);
18039 // (protected) clamp off excess high words
18040 function bnpClamp() {
18041 var c = this.s&this.DM;
18042 while(this.t
> 0 && this[this.t-
1] == c) --this.t;
18045 // (public) return string representation in given radix
18046 function bnToString(b) {
18048 if(self.s <
0) return
"-"+self.negate().toString(b);
18051 else if(b ==
8) k =
3;
18052 else if(b ==
2) k =
1;
18053 else if(b ==
32) k =
5;
18054 else if(b ==
4) k =
2;
18055 else return self.toRadix(b);
18056 var km = (
1<
<k)-
1, d, m = false, r =
"", i = self.t;
18057 var p = self.DB-(i*self.DB)%k;
18059 if(p < self.DB && (d = self[i]
>>p)
> 0) { m = true; r = int2char(d); }
18062 d = (self[i]&((
1<
<p)-
1))<<(k-p);
18063 d |= self[--i]
>>(p+=self.DB-k);
18066 d = (self[i]
>>(p-=k))
&km;
18067 if(p <=
0) { p += self.DB; --i; }
18069 if(d
> 0) m = true;
18070 if(m) r += int2char(d);
18077 function bnNegate() { var r = nbi(); BigInteger.ZERO.subTo(this,r); return r; }
18080 function bnAbs() { return (this.s
<0)?this.negate():this; }
18082 // (public) return + if this
> a, - if this < a,
0 if equal
18083 function bnCompareTo(a) {
18084 var r = this.s-a.s;
18085 if(r !=
0) return r;
18088 if(r !=
0) return (this.s
<0)?-r:r;
18089 while(--i
>=
0) if((r=this[i]-a[i]) !=
0) return r;
18093 // returns bit length of the integer x
18094 function nbits(x) {
18096 if((t=x
>>>16) !=
0) { x = t; r +=
16; }
18097 if((t=x
>>8) !=
0) { x = t; r +=
8; }
18098 if((t=x
>>4) !=
0) { x = t; r +=
4; }
18099 if((t=x
>>2) !=
0) { x = t; r +=
2; }
18100 if((t=x
>>1) !=
0) { x = t; r +=
1; }
18104 // (public) return the number of bits in
"this"
18105 function bnBitLength() {
18106 if(this.t <=
0) return
0;
18107 return this.DB*(this.t-
1)+nbits(this[this.t-
1]^(this.s&this.DM));
18110 // (protected) r = this << n*DB
18111 function bnpDLShiftTo(n,r) {
18113 for(i = this.t-
1; i
>=
0; --i) r[i+n] = this[i];
18114 for(i = n-
1; i
>=
0; --i) r[i] =
0;
18119 // (protected) r = this
>> n*DB
18120 function bnpDRShiftTo(n,r) {
18121 for(var i = n; i < this.t; ++i) r[i-n] = this[i];
18122 r.t = Math.max(this.t-n,
0);
18126 // (protected) r = this << n
18127 function bnpLShiftTo(n,r) {
18129 var bs = n%self.DB;
18130 var cbs = self.DB-bs;
18131 var bm = (
1<
<cbs)-
1;
18132 var ds = Math.floor(n/self.DB), c = (self.s<
<bs)&self.DM, i;
18133 for(i = self.t-
1; i
>=
0; --i) {
18134 r[i+ds+
1] = (self[i]
>>cbs)|c;
18135 c = (self[i]&bm)<
<bs;
18137 for(i = ds-
1; i
>=
0; --i) r[i] =
0;
18144 // (protected) r = this
>> n
18145 function bnpRShiftTo(n,r) {
18148 var ds = Math.floor(n/self.DB);
18149 if(ds
>= self.t) { r.t =
0; return; }
18150 var bs = n%self.DB;
18151 var cbs = self.DB-bs;
18152 var bm = (
1<
<bs)-
1;
18153 r[
0] = self[ds]
>>bs;
18154 for(var i = ds+
1; i < self.t; ++i) {
18155 r[i-ds-
1] |= (self[i]&bm)<
<cbs;
18156 r[i-ds] = self[i]
>>bs;
18158 if(bs
> 0) r[self.t-ds-
1] |= (self.s&bm)<
<cbs;
18163 // (protected) r = this - a
18164 function bnpSubTo(a,r) {
18166 var i =
0, c =
0, m = Math.min(a.t,self.t);
18169 r[i++] = c&self.DM;
18174 while(i < self.t) {
18176 r[i++] = c&self.DM;
18185 r[i++] = c&self.DM;
18191 if(c < -
1) r[i++] = self.DV+c;
18192 else if(c
> 0) r[i++] = c;
18197 // (protected) r = this * a, r != this,a (HAC
14.12)
18198 //
"this" should be the larger one if appropriate.
18199 function bnpMultiplyTo(a,r) {
18200 var x = this.abs(), y = a.abs();
18203 while(--i
>=
0) r[i] =
0;
18204 for(i =
0; i < y.t; ++i) r[i+x.t] = x.am(
0,y[i],r,i,
0,x.t);
18207 if(this.s != a.s) BigInteger.ZERO.subTo(r,r);
18210 // (protected) r = this^
2, r != this (HAC
14.16)
18211 function bnpSquareTo(r) {
18212 var x = this.abs();
18213 var i = r.t =
2*x.t;
18214 while(--i
>=
0) r[i] =
0;
18215 for(i =
0; i < x.t-
1; ++i) {
18216 var c = x.am(i,x[i],r,
2*i,
0,
1);
18217 if((r[i+x.t]+=x.am(i+
1,
2*x[i],r,
2*i+
1,c,x.t-i-
1))
>= x.DV) {
18222 if(r.t
> 0) r[r.t-
1] += x.am(i,x[i],r,
2*i,
0,
1);
18227 // (protected) divide this by m, quotient and remainder to q, r (HAC
14.20)
18228 // r != q, this != m. q or r may be null.
18229 function bnpDivRemTo(m,q,r) {
18232 if(pm.t <=
0) return;
18233 var pt = self.abs();
18235 if(q != null) q.fromInt(
0);
18236 if(r != null) self.copyTo(r);
18239 if(r == null) r = nbi();
18240 var y = nbi(), ts = self.s, ms = m.s;
18241 var nsh = self.DB-nbits(pm[pm.t-
1]); // normalize modulus
18242 if(nsh
> 0) { pm.lShiftTo(nsh,y); pt.lShiftTo(nsh,r); }
18243 else { pm.copyTo(y); pt.copyTo(r); }
18246 if(y0 ==
0) return;
18247 var yt = y0*(
1<
<self.F1)+((ys
>1)?y[ys-
2]
>>self.F2:
0);
18248 var d1 = self.FV/yt, d2 = (
1<
<self.F1)/yt, e =
1<
<self.F2;
18249 var i = r.t, j = i-ys, t = (q==null)?nbi():q;
18251 if(r.compareTo(t)
>=
0) {
18255 BigInteger.ONE.dlShiftTo(ys,t);
18256 t.subTo(y,y); // "negative" y so we can replace sub with am later
18257 while(y.t < ys) y[y.t++] =
0;
18259 // Estimate quotient digit
18260 var qd = (r[--i]==y0)?self.DM:Math.floor(r[i]*d1+(r[i-
1]+e)*d2);
18261 if((r[i]+=y.am(
0,qd,r,j,
0,ys)) < qd) { // Try it out
18264 while(r[i] < --qd) r.subTo(t,r);
18269 if(ts != ms) BigInteger.ZERO.subTo(q,q);
18273 if(nsh
> 0) r.rShiftTo(nsh,r); // Denormalize remainder
18274 if(ts <
0) BigInteger.ZERO.subTo(r,r);
18277 // (public) this mod a
18278 function bnMod(a) {
18280 this.abs().divRemTo(a,null,r);
18281 if(this.s <
0 && r.compareTo(BigInteger.ZERO)
> 0) a.subTo(r,r);
18285 // Modular reduction using
"classic" algorithm
18286 function Classic(m) { this.m = m; }
18287 function cConvert(x) {
18288 if(x.s <
0 || x.compareTo(this.m)
>=
0) return x.mod(this.m);
18291 function cRevert(x) { return x; }
18292 function cReduce(x) { x.divRemTo(this.m,null,x); }
18293 function cMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
18294 function cSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
18296 Classic.prototype.convert = cConvert;
18297 Classic.prototype.revert = cRevert;
18298 Classic.prototype.reduce = cReduce;
18299 Classic.prototype.mulTo = cMulTo;
18300 Classic.prototype.sqrTo = cSqrTo;
18302 // (protected) return "-
1/this %
2^DB"; useful for Mont. reduction
18306 // xy(
2-xy) = (
1+km)(
1-km)
18307 // x[y(
2-xy)] =
1-k^
2m^
2
18308 // x[y(
2-xy)] ==
1 (mod m^
2)
18309 // if y is
1/x mod m, then y(
2-xy) is
1/x mod m^
2
18310 // should reduce x and y(
2-xy) by m^
2 at each step to keep size bounded.
18311 // JS multiply "overflows" differently from C/C++, so care is needed here.
18312 function bnpInvDigit() {
18313 if(this.t <
1) return
0;
18315 if((x&
1) ==
0) return
0;
18316 var y = x
&3; // y ==
1/x mod
2^
2
18317 y = (y*(
2-(x&
0xf)*y))
&0xf; // y ==
1/x mod
2^
4
18318 y = (y*(
2-(x&
0xff)*y))
&0xff; // y ==
1/x mod
2^
8
18319 y = (y*(
2-(((x&
0xffff)*y)&
0xffff)))
&0xffff; // y ==
1/x mod
2^
16
18320 // last step - calculate inverse mod DV directly;
18321 // assumes
16 < DB <=
32 and assumes ability to handle
48-bit ints
18322 y = (y*(
2-x*y%this.DV))%this.DV; // y ==
1/x mod
2^dbits
18323 // we really want the negative inverse, and -DV < y < DV
18324 return (y
>0)?this.DV-y:-y;
18327 // Montgomery reduction
18328 function Montgomery(m) {
18330 this.mp = m.invDigit();
18331 this.mpl = this.mp
&0x7fff;
18332 this.mph = this.mp
>>15;
18333 this.um = (
1<<(m.DB-
15))-
1;
18338 function montConvert(x) {
18340 x.abs().dlShiftTo(this.m.t,r);
18341 r.divRemTo(this.m,null,r);
18342 if(x.s <
0 && r.compareTo(BigInteger.ZERO)
> 0) this.m.subTo(r,r);
18347 function montRevert(x) {
18354 // x = x/R mod m (HAC
14.32)
18355 function montReduce(x) {
18356 while(x.t <= this.mt2) // pad x so am has enough room later
18358 for(var i =
0; i < this.m.t; ++i) {
18359 // faster way of calculating u0 = x[i]*mp mod DV
18360 var j = x[i]
&0x7fff;
18361 var u0 = (j*this.mpl+(((j*this.mph+(x[i]
>>15)*this.mpl)&this.um)<
<15))&x.DM;
18362 // use am to combine the multiply-shift-add into one call
18364 x[j] += this.m.am(
0,u0,x,i,
0,this.m.t);
18366 while(x[j]
>= x.DV) { x[j] -= x.DV; x[++j]++; }
18369 x.drShiftTo(this.m.t,x);
18370 if(x.compareTo(this.m)
>=
0) x.subTo(this.m,x);
18373 // r = "x^
2/R mod m"; x != r
18374 function montSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
18376 // r = "xy/R mod m"; x,y != r
18377 function montMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
18379 Montgomery.prototype.convert = montConvert;
18380 Montgomery.prototype.revert = montRevert;
18381 Montgomery.prototype.reduce = montReduce;
18382 Montgomery.prototype.mulTo = montMulTo;
18383 Montgomery.prototype.sqrTo = montSqrTo;
18385 // (protected) true iff this is even
18386 function bnpIsEven() { return ((this.t
>0)?(this[
0]&
1):this.s) ==
0; }
18388 // (protected) this^e, e <
2^
32, doing sqr and mul with
"r" (HAC
14.79)
18389 function bnpExp(e,z) {
18390 if(e
> 0xffffffff || e <
1) return BigInteger.ONE;
18391 var r = nbi(), r2 = nbi(), g = z.convert(this), i = nbits(e)-
1;
18395 if((e&(
1<
<i))
> 0) z.mulTo(r2,g,r);
18396 else { var t = r; r = r2; r2 = t; }
18398 return z.revert(r);
18401 // (public) this^e % m,
0 <= e <
2^
32
18402 function bnModPowInt(e,m) {
18404 if(e <
256 || m.isEven()) z = new Classic(m); else z = new Montgomery(m);
18405 return this.exp(e,z);
18409 proto.copyTo = bnpCopyTo;
18410 proto.fromInt = bnpFromInt;
18411 proto.fromString = bnpFromString;
18412 proto.clamp = bnpClamp;
18413 proto.dlShiftTo = bnpDLShiftTo;
18414 proto.drShiftTo = bnpDRShiftTo;
18415 proto.lShiftTo = bnpLShiftTo;
18416 proto.rShiftTo = bnpRShiftTo;
18417 proto.subTo = bnpSubTo;
18418 proto.multiplyTo = bnpMultiplyTo;
18419 proto.squareTo = bnpSquareTo;
18420 proto.divRemTo = bnpDivRemTo;
18421 proto.invDigit = bnpInvDigit;
18422 proto.isEven = bnpIsEven;
18423 proto.exp = bnpExp;
18426 proto.toString = bnToString;
18427 proto.negate = bnNegate;
18429 proto.compareTo = bnCompareTo;
18430 proto.bitLength = bnBitLength;
18432 proto.modPowInt = bnModPowInt;
18436 function nbi() { return new BigInteger(null); }
18439 function bnClone() { var r = nbi(); this.copyTo(r); return r; }
18441 // (public) return value as integer
18442 function bnIntValue() {
18444 if(this.t ==
1) return this[
0]-this.DV;
18445 else if(this.t ==
0) return -
1;
18447 else if(this.t ==
1) return this[
0];
18448 else if(this.t ==
0) return
0;
18449 // assumes
16 < DB <
32
18450 return ((this[
1]&((
1<<(
32-this.DB))-
1))<
<this.DB)|this[
0];
18453 // (public) return value as byte
18454 function bnByteValue() { return (this.t==
0)?this.s:(this[
0]<
<24)
>>24; }
18456 // (public) return value as short (assumes DB
>=
16)
18457 function bnShortValue() { return (this.t==
0)?this.s:(this[
0]<
<16)
>>16; }
18459 // (protected) return x s.t. r^x < DV
18460 function bnpChunkSize(r) { return Math.floor(Math.LN2*this.DB/Math.log(r)); }
18462 // (public)
0 if this ==
0,
1 if this
> 0
18463 function bnSigNum() {
18464 if(this.s <
0) return -
1;
18465 else if(this.t <=
0 || (this.t ==
1 && this[
0] <=
0)) return
0;
18469 // (protected) convert to radix string
18470 function bnpToRadix(b) {
18471 if(b == null) b =
10;
18472 if(this.signum() ==
0 || b <
2 || b
> 36) return
"0";
18473 var cs = this.chunkSize(b);
18474 var a = Math.pow(b,cs);
18475 var d = nbv(a), y = nbi(), z = nbi(), r =
"";
18476 this.divRemTo(d,y,z);
18477 while(y.signum()
> 0) {
18478 r = (a+z.intValue()).toString(b).substr(
1) + r;
18481 return z.intValue().toString(b) + r;
18484 // (protected) convert from radix string
18485 function bnpFromRadix(s,b) {
18488 if(b == null) b =
10;
18489 var cs = self.chunkSize(b);
18490 var d = Math.pow(b,cs), mi = false, j =
0, w =
0;
18491 for(var i =
0; i < s.length; ++i) {
18492 var x = intAt(s,i);
18494 if(s.charAt(i) ==
"-" && self.signum() ==
0) mi = true;
18500 self.dAddOffset(w,
0);
18506 self.dMultiply(Math.pow(b,j));
18507 self.dAddOffset(w,
0);
18509 if(mi) BigInteger.ZERO.subTo(self,self);
18512 // (protected) alternate constructor
18513 function bnpFromNumber(a,b,c) {
18515 if(
"number" == typeof b) {
18516 // new BigInteger(int,int,RNG)
18517 if(a <
2) self.fromInt(
1);
18519 self.fromNumber(a,c);
18520 if(!self.testBit(a-
1)) // force MSB set
18521 self.bitwiseTo(BigInteger.ONE.shiftLeft(a-
1),op_or,self);
18522 if(self.isEven()) self.dAddOffset(
1,
0); // force odd
18523 while(!self.isProbablePrime(b)) {
18524 self.dAddOffset(
2,
0);
18525 if(self.bitLength()
> a) self.subTo(BigInteger.ONE.shiftLeft(a-
1),self);
18530 // new BigInteger(int,RNG)
18531 var x = new Array(), t = a
&7;
18532 x.length = (a
>>3)+
1;
18534 if(t
> 0) x[
0] &= ((
1<
<t)-
1); else x[
0] =
0;
18535 self.fromString(x,
256);
18539 // (public) convert to bigendian byte array
18540 function bnToByteArray() {
18542 var i = self.t, r = new Array();
18544 var p = self.DB-(i*self.DB)%
8, d, k =
0;
18546 if(p < self.DB && (d = self[i]
>>p) != (self.s&self.DM)
>>p)
18547 r[k++] = d|(self.s<<(self.DB-p));
18550 d = (self[i]&((
1<
<p)-
1))<<(
8-p);
18551 d |= self[--i]
>>(p+=self.DB-
8);
18554 d = (self[i]
>>(p-=
8))
&0xff;
18555 if(p <=
0) { p += self.DB; --i; }
18557 if((d&
0x80) !=
0) d |= -
256;
18558 if(k ===
0 && (self.s&
0x80) != (d&
0x80)) ++k;
18559 if(k
> 0 || d != self.s) r[k++] = d;
18565 function bnEquals(a) { return(this.compareTo(a)==
0); }
18566 function bnMin(a) { return(this.compareTo(a)
<0)?this:a; }
18567 function bnMax(a) { return(this.compareTo(a)
>0)?this:a; }
18569 // (protected) r = this op a (bitwise)
18570 function bnpBitwiseTo(a,op,r) {
18572 var i, f, m = Math.min(a.t,self.t);
18573 for(i =
0; i < m; ++i) r[i] = op(self[i],a[i]);
18576 for(i = m; i < self.t; ++i) r[i] = op(self[i],f);
18580 f = self.s&self.DM;
18581 for(i = m; i < a.t; ++i) r[i] = op(f,a[i]);
18584 r.s = op(self.s,a.s);
18588 // (public) this & a
18589 function op_and(x,y) { return x
&y; }
18590 function bnAnd(a) { var r = nbi(); this.bitwiseTo(a,op_and,r); return r; }
18592 // (public) this | a
18593 function op_or(x,y) { return x|y; }
18594 function bnOr(a) { var r = nbi(); this.bitwiseTo(a,op_or,r); return r; }
18596 // (public) this ^ a
18597 function op_xor(x,y) { return x^y; }
18598 function bnXor(a) { var r = nbi(); this.bitwiseTo(a,op_xor,r); return r; }
18600 // (public) this & ~a
18601 function op_andnot(x,y) { return x&~y; }
18602 function bnAndNot(a) { var r = nbi(); this.bitwiseTo(a,op_andnot,r); return r; }
18607 for(var i =
0; i < this.t; ++i) r[i] = this.DM&~this[i];
18613 // (public) this << n
18614 function bnShiftLeft(n) {
18616 if(n <
0) this.rShiftTo(-n,r); else this.lShiftTo(n,r);
18620 // (public) this
>> n
18621 function bnShiftRight(n) {
18623 if(n <
0) this.lShiftTo(-n,r); else this.rShiftTo(n,r);
18627 // return index of lowest
1-bit in x, x <
2^
31
18629 if(x ==
0) return -
1;
18631 if((x&
0xffff) ==
0) { x
>>=
16; r +=
16; }
18632 if((x&
0xff) ==
0) { x
>>=
8; r +=
8; }
18633 if((x&
0xf) ==
0) { x
>>=
4; r +=
4; }
18634 if((x&
3) ==
0) { x
>>=
2; r +=
2; }
18635 if((x&
1) ==
0) ++r;
18639 // (public) returns index of lowest
1-bit (or -
1 if none)
18640 function bnGetLowestSetBit() {
18641 for(var i =
0; i < this.t; ++i)
18642 if(this[i] !=
0) return i*this.DB+lbit(this[i]);
18643 if(this.s <
0) return this.t*this.DB;
18647 // return number of
1 bits in x
18650 while(x !=
0) { x &= x-
1; ++r; }
18654 // (public) return number of set bits
18655 function bnBitCount() {
18656 var r =
0, x = this.s&this.DM;
18657 for(var i =
0; i < this.t; ++i) r += cbit(this[i]^x);
18661 // (public) true iff nth bit is set
18662 function bnTestBit(n) {
18663 var j = Math.floor(n/this.DB);
18664 if(j
>= this.t) return(this.s!=
0);
18665 return((this[j]&(
1<<(n%this.DB)))!=
0);
18668 // (protected) this op (
1<
<n)
18669 function bnpChangeBit(n,op) {
18670 var r = BigInteger.ONE.shiftLeft(n);
18671 this.bitwiseTo(r,op,r);
18675 // (public) this | (
1<
<n)
18676 function bnSetBit(n) { return this.changeBit(n,op_or); }
18678 // (public) this & ~(
1<
<n)
18679 function bnClearBit(n) { return this.changeBit(n,op_andnot); }
18681 // (public) this ^ (
1<
<n)
18682 function bnFlipBit(n) { return this.changeBit(n,op_xor); }
18684 // (protected) r = this + a
18685 function bnpAddTo(a,r) {
18688 var i =
0, c =
0, m = Math.min(a.t,self.t);
18691 r[i++] = c&self.DM;
18696 while(i < self.t) {
18698 r[i++] = c&self.DM;
18707 r[i++] = c&self.DM;
18713 if(c
> 0) r[i++] = c;
18714 else if(c < -
1) r[i++] = self.DV+c;
18719 // (public) this + a
18720 function bnAdd(a) { var r = nbi(); this.addTo(a,r); return r; }
18722 // (public) this - a
18723 function bnSubtract(a) { var r = nbi(); this.subTo(a,r); return r; }
18725 // (public) this * a
18726 function bnMultiply(a) { var r = nbi(); this.multiplyTo(a,r); return r; }
18729 function bnSquare() { var r = nbi(); this.squareTo(r); return r; }
18731 // (public) this / a
18732 function bnDivide(a) { var r = nbi(); this.divRemTo(a,r,null); return r; }
18734 // (public) this % a
18735 function bnRemainder(a) { var r = nbi(); this.divRemTo(a,null,r); return r; }
18737 // (public) [this/a,this%a]
18738 function bnDivideAndRemainder(a) {
18739 var q = nbi(), r = nbi();
18740 this.divRemTo(a,q,r);
18741 return new Array(q,r);
18744 // (protected) this *= n, this
>=
0,
1 < n < DV
18745 function bnpDMultiply(n) {
18746 this[this.t] = this.am(
0,n-
1,this,
0,
0,this.t);
18751 // (protected) this += n << w words, this
>=
0
18752 function bnpDAddOffset(n,w) {
18754 while(this.t <= w) this[this.t++] =
0;
18756 while(this[w]
>= this.DV) {
18757 this[w] -= this.DV;
18758 if(++w
>= this.t) this[this.t++] =
0;
18763 // A "null" reducer
18764 function NullExp() {}
18765 function nNop(x) { return x; }
18766 function nMulTo(x,y,r) { x.multiplyTo(y,r); }
18767 function nSqrTo(x,r) { x.squareTo(r); }
18769 NullExp.prototype.convert = nNop;
18770 NullExp.prototype.revert = nNop;
18771 NullExp.prototype.mulTo = nMulTo;
18772 NullExp.prototype.sqrTo = nSqrTo;
18775 function bnPow(e) { return this.exp(e,new NullExp()); }
18777 // (protected) r = lower n words of "this * a", a.t <= n
18778 // "this" should be the larger one if appropriate.
18779 function bnpMultiplyLowerTo(a,n,r) {
18780 var i = Math.min(this.t+a.t,n);
18781 r.s =
0; // assumes a,this
>=
0
18783 while(i
> 0) r[--i] =
0;
18785 for(j = r.t-this.t; i < j; ++i) r[i+this.t] = this.am(
0,a[i],r,i,
0,this.t);
18786 for(j = Math.min(a.t,n); i < j; ++i) this.am(
0,a[i],r,i,
0,n-i);
18790 // (protected) r =
"this * a" without lower n words, n
> 0
18791 //
"this" should be the larger one if appropriate.
18792 function bnpMultiplyUpperTo(a,n,r) {
18794 var i = r.t = this.t+a.t-n;
18795 r.s =
0; // assumes a,this
>=
0
18796 while(--i
>=
0) r[i] =
0;
18797 for(i = Math.max(n-this.t,
0); i < a.t; ++i)
18798 r[this.t+i-n] = this.am(n-i,a[i],r,
0,
0,this.t+i-n);
18803 // Barrett modular reduction
18804 function Barrett(m) {
18808 BigInteger.ONE.dlShiftTo(
2*m.t,this.r2);
18809 this.mu = this.r2.divide(m);
18813 function barrettConvert(x) {
18814 if(x.s <
0 || x.t
> 2*this.m.t) return x.mod(this.m);
18815 else if(x.compareTo(this.m) <
0) return x;
18816 else { var r = nbi(); x.copyTo(r); this.reduce(r); return r; }
18819 function barrettRevert(x) { return x; }
18821 // x = x mod m (HAC
14.42)
18822 function barrettReduce(x) {
18824 x.drShiftTo(self.m.t-
1,self.r2);
18825 if(x.t
> self.m.t+
1) { x.t = self.m.t+
1; x.clamp(); }
18826 self.mu.multiplyUpperTo(self.r2,self.m.t+
1,self.q3);
18827 self.m.multiplyLowerTo(self.q3,self.m.t+
1,self.r2);
18828 while(x.compareTo(self.r2) <
0) x.dAddOffset(
1,self.m.t+
1);
18829 x.subTo(self.r2,x);
18830 while(x.compareTo(self.m)
>=
0) x.subTo(self.m,x);
18833 // r = x^
2 mod m; x != r
18834 function barrettSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
18836 // r = x*y mod m; x,y != r
18837 function barrettMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
18839 Barrett.prototype.convert = barrettConvert;
18840 Barrett.prototype.revert = barrettRevert;
18841 Barrett.prototype.reduce = barrettReduce;
18842 Barrett.prototype.mulTo = barrettMulTo;
18843 Barrett.prototype.sqrTo = barrettSqrTo;
18845 // (public) this^e % m (HAC
14.85)
18846 function bnModPow(e,m) {
18847 var i = e.bitLength(), k, r = nbv(
1), z;
18848 if(i <=
0) return r;
18849 else if(i <
18) k =
1;
18850 else if(i <
48) k =
3;
18851 else if(i <
144) k =
4;
18852 else if(i <
768) k =
5;
18855 z = new Classic(m);
18856 else if(m.isEven())
18857 z = new Barrett(m);
18859 z = new Montgomery(m);
18862 var g = new Array(), n =
3, k1 = k-
1, km = (
1<
<k)-
1;
18863 g[
1] = z.convert(this);
18869 z.mulTo(g2,g[n-
2],g[n]);
18874 var j = e.t-
1, w, is1 = true, r2 = nbi(), t;
18877 if(i
>= k1) w = (e[j]
>>(i-k1))
&km;
18879 w = (e[j]&((
1<<(i+
1))-
1))<<(k1-i);
18880 if(j
> 0) w |= e[j-
1]
>>(this.DB+i-k1);
18884 while((w&
1) ==
0) { w
>>=
1; --n; }
18885 if((i -= n) <
0) { i += this.DB; --j; }
18886 if(is1) { // ret ==
1, don't bother squaring or multiplying it
18891 while(n
> 1) { z.sqrTo(r,r2); z.sqrTo(r2,r); n -=
2; }
18892 if(n
> 0) z.sqrTo(r,r2); else { t = r; r = r2; r2 = t; }
18893 z.mulTo(r2,g[w],r);
18896 while(j
>=
0 && (e[j]&(
1<
<i)) ==
0) {
18897 z.sqrTo(r,r2); t = r; r = r2; r2 = t;
18898 if(--i <
0) { i = this.DB-
1; --j; }
18901 return z.revert(r);
18904 // (public) gcd(this,a) (HAC
14.54)
18905 function bnGCD(a) {
18906 var x = (this.s
<0)?this.negate():this.clone();
18907 var y = (a.s
<0)?a.negate():a.clone();
18908 if(x.compareTo(y) <
0) { var t = x; x = y; y = t; }
18909 var i = x.getLowestSetBit(), g = y.getLowestSetBit();
18910 if(g <
0) return x;
18916 while(x.signum()
> 0) {
18917 if((i = x.getLowestSetBit())
> 0) x.rShiftTo(i,x);
18918 if((i = y.getLowestSetBit())
> 0) y.rShiftTo(i,y);
18919 if(x.compareTo(y)
>=
0) {
18928 if(g
> 0) y.lShiftTo(g,y);
18932 // (protected) this % n, n <
2^
26
18933 function bnpModInt(n) {
18934 if(n <=
0) return
0;
18935 var d = this.DV%n, r = (this.s
<0)?n-
1:
0;
18937 if(d ==
0) r = this[
0]%n;
18938 else for(var i = this.t-
1; i
>=
0; --i) r = (d*r+this[i])%n;
18942 // (public)
1/this % m (HAC
14.61)
18943 function bnModInverse(m) {
18944 var ac = m.isEven();
18945 if((this.isEven() && ac) || m.signum() ==
0) return BigInteger.ZERO;
18946 var u = m.clone(), v = this.clone();
18947 var a = nbv(
1), b = nbv(
0), c = nbv(
0), d = nbv(
1);
18948 while(u.signum() !=
0) {
18949 while(u.isEven()) {
18952 if(!a.isEven() || !b.isEven()) { a.addTo(this,a); b.subTo(m,b); }
18955 else if(!b.isEven()) b.subTo(m,b);
18958 while(v.isEven()) {
18961 if(!c.isEven() || !d.isEven()) { c.addTo(this,c); d.subTo(m,d); }
18964 else if(!d.isEven()) d.subTo(m,d);
18967 if(u.compareTo(v)
>=
0) {
18969 if(ac) a.subTo(c,a);
18974 if(ac) c.subTo(a,c);
18978 if(v.compareTo(BigInteger.ONE) !=
0) return BigInteger.ZERO;
18979 if(d.compareTo(m)
>=
0) return d.subtract(m);
18980 if(d.signum() <
0) d.addTo(m,d); else return d;
18981 if(d.signum() <
0) return d.add(m); else return d;
18985 proto.chunkSize = bnpChunkSize;
18986 proto.toRadix = bnpToRadix;
18987 proto.fromRadix = bnpFromRadix;
18988 proto.fromNumber = bnpFromNumber;
18989 proto.bitwiseTo = bnpBitwiseTo;
18990 proto.changeBit = bnpChangeBit;
18991 proto.addTo = bnpAddTo;
18992 proto.dMultiply = bnpDMultiply;
18993 proto.dAddOffset = bnpDAddOffset;
18994 proto.multiplyLowerTo = bnpMultiplyLowerTo;
18995 proto.multiplyUpperTo = bnpMultiplyUpperTo;
18996 proto.modInt = bnpModInt;
18999 proto.clone = bnClone;
19000 proto.intValue = bnIntValue;
19001 proto.byteValue = bnByteValue;
19002 proto.shortValue = bnShortValue;
19003 proto.signum = bnSigNum;
19004 proto.toByteArray = bnToByteArray;
19005 proto.equals = bnEquals;
19011 proto.andNot = bnAndNot;
19013 proto.shiftLeft = bnShiftLeft;
19014 proto.shiftRight = bnShiftRight;
19015 proto.getLowestSetBit = bnGetLowestSetBit;
19016 proto.bitCount = bnBitCount;
19017 proto.testBit = bnTestBit;
19018 proto.setBit = bnSetBit;
19019 proto.clearBit = bnClearBit;
19020 proto.flipBit = bnFlipBit;
19022 proto.subtract = bnSubtract;
19023 proto.multiply = bnMultiply;
19024 proto.divide = bnDivide;
19025 proto.remainder = bnRemainder;
19026 proto.divideAndRemainder = bnDivideAndRemainder;
19027 proto.modPow = bnModPow;
19028 proto.modInverse = bnModInverse;
19032 // JSBN-specific extension
19033 proto.square = bnSquare;
19035 // BigInteger interfaces not implemented in jsbn:
19037 // BigInteger(int signum, byte[] magnitude)
19038 // double doubleValue()
19039 // float floatValue()
19041 // long longValue()
19042 // static BigInteger valueOf(long val)
19045 BigInteger.ZERO = nbv(
0);
19046 BigInteger.ONE = nbv(
1);
19047 BigInteger.valueOf = nbv;
19049 },{"assert":
4}],
2:[function(_dereq_,module,exports){
19050 (function (Buffer){
19051 // FIXME: Kind of a weird way to throw exceptions, consider removing
19052 var assert = _dereq_('assert')
19053 var BigInteger = _dereq_('./bigi')
19056 * Turns a byte array into a big integer.
19058 * This function will interpret a byte array as a big integer in big
19061 BigInteger.fromByteArrayUnsigned = function(byteArray) {
19062 // BigInteger expects a DER integer conformant byte array
19063 if (byteArray[
0] &
0x80) {
19064 return new BigInteger([
0].concat(byteArray))
19067 return new BigInteger(byteArray)
19071 * Returns a byte array representation of the big integer.
19073 * This returns the absolute of the contained value in big endian
19074 * form. A value of zero results in an empty array.
19076 BigInteger.prototype.toByteArrayUnsigned = function() {
19077 var byteArray = this.toByteArray()
19078 return byteArray[
0] ===
0 ? byteArray.slice(
1) : byteArray
19081 BigInteger.fromDERInteger = function(byteArray) {
19082 return new BigInteger(byteArray)
19086 * Converts BigInteger to a DER integer representation.
19088 * The format for this value uses the most significant bit as a sign
19089 * bit. If the most significant bit is already set and the integer is
19090 * positive, a
0x00 is prepended.
19105 *
62300 =
> 0x00f35c
19108 BigInteger.prototype.toDERInteger = BigInteger.prototype.toByteArray
19110 BigInteger.fromBuffer = function(buffer) {
19111 // BigInteger expects a DER integer conformant byte array
19112 if (buffer[
0] &
0x80) {
19113 var byteArray = Array.prototype.slice.call(buffer)
19115 return new BigInteger([
0].concat(byteArray))
19118 return new BigInteger(buffer)
19121 BigInteger.fromHex = function(hex) {
19122 if (hex === '') return BigInteger.ZERO
19124 assert.equal(hex, hex.match(/^[A-Fa-f0-
9]+/), 'Invalid hex string')
19125 assert.equal(hex.length %
2,
0, 'Incomplete hex')
19126 return new BigInteger(hex,
16)
19129 BigInteger.prototype.toBuffer = function(size) {
19130 var byteArray = this.toByteArrayUnsigned()
19133 var padding = size - byteArray.length
19134 while (zeros.length < padding) zeros.push(
0)
19136 return new Buffer(zeros.concat(byteArray))
19139 BigInteger.prototype.toHex = function(size) {
19140 return this.toBuffer(size).toString('hex')
19143 }).call(this,_dereq_(
"buffer").Buffer)
19144 },{
"./bigi":
1,
"assert":
4,
"buffer":
8}],
3:[function(_dereq_,module,exports){
19145 var BigInteger = _dereq_('./bigi')
19148 _dereq_('./convert')
19150 module.exports = BigInteger
19151 },{
"./bigi":
1,
"./convert":
2}],
4:[function(_dereq_,module,exports){
19152 // http://wiki.commonjs.org/wiki/Unit_Testing/
1.0
19154 // THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
19156 // Originally from narwhal.js (http://narwhaljs.org)
19157 // Copyright (c)
2009 Thomas Robinson
<280north.com
>
19159 // Permission is hereby granted, free of charge, to any person obtaining a copy
19160 // of this software and associated documentation files (the 'Software'), to
19161 // deal in the Software without restriction, including without limitation the
19162 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
19163 // sell copies of the Software, and to permit persons to whom the Software is
19164 // furnished to do so, subject to the following conditions:
19166 // The above copyright notice and this permission notice shall be included in
19167 // all copies or substantial portions of the Software.
19169 // THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19170 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19171 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19172 // AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19173 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
19174 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19176 // when used in node, this will actually load the util module we depend on
19177 // versus loading the builtin util module as happens otherwise
19178 // this is a bug in node module loading as far as I am concerned
19179 var util = _dereq_('util/');
19181 var pSlice = Array.prototype.slice;
19182 var hasOwn = Object.prototype.hasOwnProperty;
19184 //
1. The assert module provides functions that throw
19185 // AssertionError's when particular conditions are not met. The
19186 // assert module must conform to the following interface.
19188 var assert = module.exports = ok;
19190 //
2. The AssertionError is defined in assert.
19191 // new assert.AssertionError({ message: message,
19193 // expected: expected })
19195 assert.AssertionError = function AssertionError(options) {
19196 this.name = 'AssertionError';
19197 this.actual = options.actual;
19198 this.expected = options.expected;
19199 this.operator = options.operator;
19200 if (options.message) {
19201 this.message = options.message;
19202 this.generatedMessage = false;
19204 this.message = getMessage(this);
19205 this.generatedMessage = true;
19207 var stackStartFunction = options.stackStartFunction || fail;
19209 if (Error.captureStackTrace) {
19210 Error.captureStackTrace(this, stackStartFunction);
19213 // non v8 browsers so we can have a stacktrace
19214 var err = new Error();
19216 var out = err.stack;
19218 // try to strip useless frames
19219 var fn_name = stackStartFunction.name;
19220 var idx = out.indexOf('\n' + fn_name);
19222 // once we have located the function frame
19223 // we need to strip out everything before it (and its line)
19224 var next_line = out.indexOf('\n', idx +
1);
19225 out = out.substring(next_line +
1);
19233 // assert.AssertionError instanceof Error
19234 util.inherits(assert.AssertionError, Error);
19236 function replacer(key, value) {
19237 if (util.isUndefined(value)) {
19240 if (util.isNumber(value) && (isNaN(value) || !isFinite(value))) {
19241 return value.toString();
19243 if (util.isFunction(value) || util.isRegExp(value)) {
19244 return value.toString();
19249 function truncate(s, n) {
19250 if (util.isString(s)) {
19251 return s.length < n ? s : s.slice(
0, n);
19257 function getMessage(self) {
19258 return truncate(JSON.stringify(self.actual, replacer),
128) + ' ' +
19259 self.operator + ' ' +
19260 truncate(JSON.stringify(self.expected, replacer),
128);
19263 // At present only the three keys mentioned above are used and
19264 // understood by the spec. Implementations or sub modules can pass
19265 // other keys to the AssertionError's constructor - they will be
19268 //
3. All of the following functions must throw an AssertionError
19269 // when a corresponding condition is not met, with a message that
19270 // may be undefined if not provided. All assertion methods provide
19271 // both the actual and expected values to the assertion error for
19272 // display purposes.
19274 function fail(actual, expected, message, operator, stackStartFunction) {
19275 throw new assert.AssertionError({
19278 expected: expected,
19279 operator: operator,
19280 stackStartFunction: stackStartFunction
19284 // EXTENSION! allows for well behaved errors defined elsewhere.
19285 assert.fail = fail;
19287 //
4. Pure assertion tests whether a value is truthy, as determined
19289 // assert.ok(guard, message_opt);
19290 // This statement is equivalent to assert.equal(true, !!guard,
19291 // message_opt);. To test strictly for the value true, use
19292 // assert.strictEqual(true, guard, message_opt);.
19294 function ok(value, message) {
19295 if (!value) fail(value, true, message, '==', assert.ok);
19299 //
5. The equality assertion tests shallow, coercive equality with
19301 // assert.equal(actual, expected, message_opt);
19303 assert.equal = function equal(actual, expected, message) {
19304 if (actual != expected) fail(actual, expected, message, '==', assert.equal);
19307 //
6. The non-equality assertion tests for whether two objects are not equal
19308 // with != assert.notEqual(actual, expected, message_opt);
19310 assert.notEqual = function notEqual(actual, expected, message) {
19311 if (actual == expected) {
19312 fail(actual, expected, message, '!=', assert.notEqual);
19316 //
7. The equivalence assertion tests a deep equality relation.
19317 // assert.deepEqual(actual, expected, message_opt);
19319 assert.deepEqual = function deepEqual(actual, expected, message) {
19320 if (!_deepEqual(actual, expected)) {
19321 fail(actual, expected, message, 'deepEqual', assert.deepEqual);
19325 function _deepEqual(actual, expected) {
19326 //
7.1. All identical values are equivalent, as determined by ===.
19327 if (actual === expected) {
19330 } else if (util.isBuffer(actual) && util.isBuffer(expected)) {
19331 if (actual.length != expected.length) return false;
19333 for (var i =
0; i < actual.length; i++) {
19334 if (actual[i] !== expected[i]) return false;
19339 //
7.2. If the expected value is a Date object, the actual value is
19340 // equivalent if it is also a Date object that refers to the same time.
19341 } else if (util.isDate(actual) && util.isDate(expected)) {
19342 return actual.getTime() === expected.getTime();
19344 //
7.3 If the expected value is a RegExp object, the actual value is
19345 // equivalent if it is also a RegExp object with the same source and
19346 // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
19347 } else if (util.isRegExp(actual) && util.isRegExp(expected)) {
19348 return actual.source === expected.source &&
19349 actual.global === expected.global &&
19350 actual.multiline === expected.multiline &&
19351 actual.lastIndex === expected.lastIndex &&
19352 actual.ignoreCase === expected.ignoreCase;
19354 //
7.4. Other pairs that do not both pass typeof value == 'object',
19355 // equivalence is determined by ==.
19356 } else if (!util.isObject(actual) && !util.isObject(expected)) {
19357 return actual == expected;
19359 //
7.5 For all other Object pairs, including Array objects, equivalence is
19360 // determined by having the same number of owned properties (as verified
19361 // with Object.prototype.hasOwnProperty.call), the same set of keys
19362 // (although not necessarily the same order), equivalent values for every
19363 // corresponding key, and an identical 'prototype' property. Note: this
19364 // accounts for both named and indexed properties on Arrays.
19366 return objEquiv(actual, expected);
19370 function isArguments(object) {
19371 return Object.prototype.toString.call(object) == '[object Arguments]';
19374 function objEquiv(a, b) {
19375 if (util.isNullOrUndefined(a) || util.isNullOrUndefined(b))
19377 // an identical 'prototype' property.
19378 if (a.prototype !== b.prototype) return false;
19379 //~~~I've managed to break Object.keys through screwy arguments passing.
19380 // Converting to array solves the problem.
19381 if (isArguments(a)) {
19382 if (!isArguments(b)) {
19385 a = pSlice.call(a);
19386 b = pSlice.call(b);
19387 return _deepEqual(a, b);
19390 var ka = objectKeys(a),
19391 kb = objectKeys(b),
19393 } catch (e) {//happens when one is a string literal and the other isn't
19396 // having the same number of owned properties (keys incorporates
19398 if (ka.length != kb.length)
19400 //the same set of keys (although not necessarily the same order),
19403 //~~~cheap key test
19404 for (i = ka.length -
1; i
>=
0; i--) {
19405 if (ka[i] != kb[i])
19408 //equivalent values for every corresponding key, and
19409 //~~~possibly expensive deep test
19410 for (i = ka.length -
1; i
>=
0; i--) {
19412 if (!_deepEqual(a[key], b[key])) return false;
19417 //
8. The non-equivalence assertion tests for any deep inequality.
19418 // assert.notDeepEqual(actual, expected, message_opt);
19420 assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
19421 if (_deepEqual(actual, expected)) {
19422 fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
19426 //
9. The strict equality assertion tests strict equality, as determined by ===.
19427 // assert.strictEqual(actual, expected, message_opt);
19429 assert.strictEqual = function strictEqual(actual, expected, message) {
19430 if (actual !== expected) {
19431 fail(actual, expected, message, '===', assert.strictEqual);
19435 //
10. The strict non-equality assertion tests for strict inequality, as
19436 // determined by !==. assert.notStrictEqual(actual, expected, message_opt);
19438 assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
19439 if (actual === expected) {
19440 fail(actual, expected, message, '!==', assert.notStrictEqual);
19444 function expectedException(actual, expected) {
19445 if (!actual || !expected) {
19449 if (Object.prototype.toString.call(expected) == '[object RegExp]') {
19450 return expected.test(actual);
19451 } else if (actual instanceof expected) {
19453 } else if (expected.call({}, actual) === true) {
19460 function _throws(shouldThrow, block, expected, message) {
19463 if (util.isString(expected)) {
19464 message = expected;
19474 message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
19475 (message ? ' ' + message : '.');
19477 if (shouldThrow && !actual) {
19478 fail(actual, expected, 'Missing expected exception' + message);
19481 if (!shouldThrow && expectedException(actual, expected)) {
19482 fail(actual, expected, 'Got unwanted exception' + message);
19485 if ((shouldThrow && actual && expected &&
19486 !expectedException(actual, expected)) || (!shouldThrow && actual)) {
19491 //
11. Expected to throw an error:
19492 // assert.throws(block, Error_opt, message_opt);
19494 assert.throws = function(block, /*optional*/error, /*optional*/message) {
19495 _throws.apply(this, [true].concat(pSlice.call(arguments)));
19498 // EXTENSION! This is annoying to write outside this module.
19499 assert.doesNotThrow = function(block, /*optional*/message) {
19500 _throws.apply(this, [false].concat(pSlice.call(arguments)));
19503 assert.ifError = function(err) { if (err) {throw err;}};
19505 var objectKeys = Object.keys || function (obj) {
19507 for (var key in obj) {
19508 if (hasOwn.call(obj, key)) keys.push(key);
19513 },{"util/":
6}],
5:[function(_dereq_,module,exports){
19514 module.exports = function isBuffer(arg) {
19515 return arg && typeof arg === 'object'
19516 && typeof arg.copy === 'function'
19517 && typeof arg.fill === 'function'
19518 && typeof arg.readUInt8 === 'function';
19520 },{}],
6:[function(_dereq_,module,exports){
19521 (function (process,global){
19522 // Copyright Joyent, Inc. and other Node contributors.
19524 // Permission is hereby granted, free of charge, to any person obtaining a
19525 // copy of this software and associated documentation files (the
19526 // "Software"), to deal in the Software without restriction, including
19527 // without limitation the rights to use, copy, modify, merge, publish,
19528 // distribute, sublicense, and/or sell copies of the Software, and to permit
19529 // persons to whom the Software is furnished to do so, subject to the
19530 // following conditions:
19532 // The above copyright notice and this permission notice shall be included
19533 // in all copies or substantial portions of the Software.
19535 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19536 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19537 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
19538 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
19539 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19540 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
19541 // USE OR OTHER DEALINGS IN THE SOFTWARE.
19543 var formatRegExp = /%[sdj%]/g;
19544 exports.format = function(f) {
19545 if (!isString(f)) {
19547 for (var i =
0; i < arguments.length; i++) {
19548 objects.push(inspect(arguments[i]));
19550 return objects.join(' ');
19554 var args = arguments;
19555 var len = args.length;
19556 var str = String(f).replace(formatRegExp, function(x) {
19557 if (x === '%%') return '%';
19558 if (i
>= len) return x;
19560 case '%s': return String(args[i++]);
19561 case '%d': return Number(args[i++]);
19564 return JSON.stringify(args[i++]);
19566 return '[Circular]';
19572 for (var x = args[i]; i < len; x = args[++i]) {
19573 if (isNull(x) || !isObject(x)) {
19576 str += ' ' + inspect(x);
19583 // Mark that a method should not be used.
19584 // Returns a modified function which warns once by default.
19585 // If --no-deprecation is set, then it is a no-op.
19586 exports.deprecate = function(fn, msg) {
19587 // Allow for deprecating things in the process of starting up.
19588 if (isUndefined(global.process)) {
19589 return function() {
19590 return exports.deprecate(fn, msg).apply(this, arguments);
19594 if (process.noDeprecation === true) {
19598 var warned = false;
19599 function deprecated() {
19601 if (process.throwDeprecation) {
19602 throw new Error(msg);
19603 } else if (process.traceDeprecation) {
19604 console.trace(msg);
19606 console.error(msg);
19610 return fn.apply(this, arguments);
19619 exports.debuglog = function(set) {
19620 if (isUndefined(debugEnviron))
19621 debugEnviron = process.env.NODE_DEBUG || '';
19622 set = set.toUpperCase();
19623 if (!debugs[set]) {
19624 if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
19625 var pid = process.pid;
19626 debugs[set] = function() {
19627 var msg = exports.format.apply(exports, arguments);
19628 console.error('%s %d: %s', set, pid, msg);
19631 debugs[set] = function() {};
19634 return debugs[set];
19639 * Echos the value of a value. Trys to print the value out
19640 * in the best way possible given the different types.
19642 * @param {Object} obj The object to print out.
19643 * @param {Object} opts Optional options object that alters the output.
19645 /* legacy: obj, showHidden, depth, colors*/
19646 function inspect(obj, opts) {
19650 stylize: stylizeNoColor
19653 if (arguments.length
>=
3) ctx.depth = arguments[
2];
19654 if (arguments.length
>=
4) ctx.colors = arguments[
3];
19655 if (isBoolean(opts)) {
19657 ctx.showHidden = opts;
19659 // got an "options" object
19660 exports._extend(ctx, opts);
19662 // set default options
19663 if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
19664 if (isUndefined(ctx.depth)) ctx.depth =
2;
19665 if (isUndefined(ctx.colors)) ctx.colors = false;
19666 if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
19667 if (ctx.colors) ctx.stylize = stylizeWithColor;
19668 return formatValue(ctx, obj, ctx.depth);
19670 exports.inspect = inspect;
19673 // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
19676 'italic' : [
3,
23],
19677 'underline' : [
4,
24],
19678 'inverse' : [
7,
27],
19679 'white' : [
37,
39],
19681 'black' : [
30,
39],
19684 'green' : [
32,
39],
19685 'magenta' : [
35,
39],
19687 'yellow' : [
33,
39]
19690 // Don't use 'blue' not visible on cmd.exe
19693 'number': 'yellow',
19694 'boolean': 'yellow',
19695 'undefined': 'grey',
19699 // "name": intentionally not styling
19704 function stylizeWithColor(str, styleType) {
19705 var style = inspect.styles[styleType];
19708 return '\u001b[' + inspect.colors[style][
0] + 'm' + str +
19709 '\u001b[' + inspect.colors[style][
1] + 'm';
19716 function stylizeNoColor(str, styleType) {
19721 function arrayToHash(array) {
19724 array.forEach(function(val, idx) {
19732 function formatValue(ctx, value, recurseTimes) {
19733 // Provide a hook for user-specified inspect functions.
19734 // Check that value is an object with an inspect function on it
19735 if (ctx.customInspect &&
19737 isFunction(value.inspect) &&
19738 // Filter out the util module, it's inspect function is special
19739 value.inspect !== exports.inspect &&
19740 // Also filter out any prototype objects using the circular check.
19741 !(value.constructor && value.constructor.prototype === value)) {
19742 var ret = value.inspect(recurseTimes, ctx);
19743 if (!isString(ret)) {
19744 ret = formatValue(ctx, ret, recurseTimes);
19749 // Primitive types cannot have properties
19750 var primitive = formatPrimitive(ctx, value);
19755 // Look up the keys of the object.
19756 var keys = Object.keys(value);
19757 var visibleKeys = arrayToHash(keys);
19759 if (ctx.showHidden) {
19760 keys = Object.getOwnPropertyNames(value);
19763 // IE doesn't make error fields non-enumerable
19764 // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs
.94).aspx
19766 && (keys.indexOf('message')
>=
0 || keys.indexOf('description')
>=
0)) {
19767 return formatError(value);
19770 // Some type of object without properties can be shortcutted.
19771 if (keys.length ===
0) {
19772 if (isFunction(value)) {
19773 var name = value.name ? ': ' + value.name : '';
19774 return ctx.stylize('[Function' + name + ']', 'special');
19776 if (isRegExp(value)) {
19777 return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
19779 if (isDate(value)) {
19780 return ctx.stylize(Date.prototype.toString.call(value), 'date');
19782 if (isError(value)) {
19783 return formatError(value);
19787 var base = '', array = false, braces = ['{', '}'];
19789 // Make Array say that they are Array
19790 if (isArray(value)) {
19792 braces = ['[', ']'];
19795 // Make functions say that they are functions
19796 if (isFunction(value)) {
19797 var n = value.name ? ': ' + value.name : '';
19798 base = ' [Function' + n + ']';
19801 // Make RegExps say that they are RegExps
19802 if (isRegExp(value)) {
19803 base = ' ' + RegExp.prototype.toString.call(value);
19806 // Make dates with properties first say the date
19807 if (isDate(value)) {
19808 base = ' ' + Date.prototype.toUTCString.call(value);
19811 // Make error with message first say the error
19812 if (isError(value)) {
19813 base = ' ' + formatError(value);
19816 if (keys.length ===
0 && (!array || value.length ==
0)) {
19817 return braces[
0] + base + braces[
1];
19820 if (recurseTimes <
0) {
19821 if (isRegExp(value)) {
19822 return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
19824 return ctx.stylize('[Object]', 'special');
19828 ctx.seen.push(value);
19832 output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
19834 output = keys.map(function(key) {
19835 return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
19841 return reduceToSingleString(output, base, braces);
19845 function formatPrimitive(ctx, value) {
19846 if (isUndefined(value))
19847 return ctx.stylize('undefined', 'undefined');
19848 if (isString(value)) {
19849 var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
19850 .replace(/'/g, "\\'")
19851 .replace(/\\"/g, '"') + '\'';
19852 return ctx.stylize(simple, 'string');
19854 if (isNumber(value))
19855 return ctx.stylize('' + value, 'number');
19856 if (isBoolean(value))
19857 return ctx.stylize('' + value, 'boolean');
19858 // For some reason typeof null is "object", so special case here.
19860 return ctx.stylize('null', 'null');
19864 function formatError(value) {
19865 return '[' + Error.prototype.toString.call(value) + ']';
19869 function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
19871 for (var i =
0, l = value.length; i < l; ++i) {
19872 if (hasOwnProperty(value, String(i))) {
19873 output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
19879 keys.forEach(function(key) {
19880 if (!key.match(/^\d+$/)) {
19881 output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
19889 function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
19890 var name, str, desc;
19891 desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
19894 str = ctx.stylize('[Getter/Setter]', 'special');
19896 str = ctx.stylize('[Getter]', 'special');
19900 str = ctx.stylize('[Setter]', 'special');
19903 if (!hasOwnProperty(visibleKeys, key)) {
19904 name = '[' + key + ']';
19907 if (ctx.seen.indexOf(desc.value) <
0) {
19908 if (isNull(recurseTimes)) {
19909 str = formatValue(ctx, desc.value, null);
19911 str = formatValue(ctx, desc.value, recurseTimes -
1);
19913 if (str.indexOf('\n')
> -
1) {
19915 str = str.split('\n').map(function(line) {
19917 }).join('\n').substr(
2);
19919 str = '\n' + str.split('\n').map(function(line) {
19925 str = ctx.stylize('[Circular]', 'special');
19928 if (isUndefined(name)) {
19929 if (array && key.match(/^\d+$/)) {
19932 name = JSON.stringify('' + key);
19933 if (name.match(/^"([a-zA-Z_][a-zA-Z_0-
9]*)"$/)) {
19934 name = name.substr(
1, name.length -
2);
19935 name = ctx.stylize(name, 'name');
19937 name = name.replace(/'/g, "\\'")
19938 .replace(/\\"/g, '"')
19939 .replace(/(^"|"$)/g, "'");
19940 name = ctx.stylize(name, 'string');
19944 return name + ': ' + str;
19948 function reduceToSingleString(output, base, braces) {
19949 var numLinesEst =
0;
19950 var length = output.reduce(function(prev, cur) {
19952 if (cur.indexOf('\n')
>=
0) numLinesEst++;
19953 return prev + cur.replace(/\u001b\[\d\d?m/g, '').length +
1;
19958 (base === '' ? '' : base + '\n ') +
19960 output.join(',\n ') +
19965 return braces[
0] + base + ' ' + output.join(', ') + ' ' + braces[
1];
19969 // NOTE: These type checking functions intentionally don't use `instanceof`
19970 // because it is fragile and can be easily faked with `Object.create()`.
19971 function isArray(ar) {
19972 return Array.isArray(ar);
19974 exports.isArray = isArray;
19976 function isBoolean(arg) {
19977 return typeof arg === 'boolean';
19979 exports.isBoolean = isBoolean;
19981 function isNull(arg) {
19982 return arg === null;
19984 exports.isNull = isNull;
19986 function isNullOrUndefined(arg) {
19987 return arg == null;
19989 exports.isNullOrUndefined = isNullOrUndefined;
19991 function isNumber(arg) {
19992 return typeof arg === 'number';
19994 exports.isNumber = isNumber;
19996 function isString(arg) {
19997 return typeof arg === 'string';
19999 exports.isString = isString;
20001 function isSymbol(arg) {
20002 return typeof arg === 'symbol';
20004 exports.isSymbol = isSymbol;
20006 function isUndefined(arg) {
20007 return arg === void
0;
20009 exports.isUndefined = isUndefined;
20011 function isRegExp(re) {
20012 return isObject(re) && objectToString(re) === '[object RegExp]';
20014 exports.isRegExp = isRegExp;
20016 function isObject(arg) {
20017 return typeof arg === 'object' && arg !== null;
20019 exports.isObject = isObject;
20021 function isDate(d) {
20022 return isObject(d) && objectToString(d) === '[object Date]';
20024 exports.isDate = isDate;
20026 function isError(e) {
20027 return isObject(e) &&
20028 (objectToString(e) === '[object Error]' || e instanceof Error);
20030 exports.isError = isError;
20032 function isFunction(arg) {
20033 return typeof arg === 'function';
20035 exports.isFunction = isFunction;
20037 function isPrimitive(arg) {
20038 return arg === null ||
20039 typeof arg === 'boolean' ||
20040 typeof arg === 'number' ||
20041 typeof arg === 'string' ||
20042 typeof arg === 'symbol' || // ES6 symbol
20043 typeof arg === 'undefined';
20045 exports.isPrimitive = isPrimitive;
20047 exports.isBuffer = _dereq_('./support/isBuffer');
20049 function objectToString(o) {
20050 return Object.prototype.toString.call(o);
20055 return n <
10 ? '
0' + n.toString(
10) : n.toString(
10);
20059 var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
20060 'Oct', 'Nov', 'Dec'];
20063 function timestamp() {
20064 var d = new Date();
20065 var time = [pad(d.getHours()),
20066 pad(d.getMinutes()),
20067 pad(d.getSeconds())].join(':');
20068 return [d.getDate(), months[d.getMonth()], time].join(' ');
20072 // log is just a thin wrapper to console.log that prepends a timestamp
20073 exports.log = function() {
20074 console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
20079 * Inherit the prototype methods from one constructor into another.
20081 * The Function.prototype.inherits from lang.js rewritten as a standalone
20082 * function (not on Function.prototype). NOTE: If this file is to be loaded
20083 * during bootstrapping this function needs to be rewritten using some native
20084 * functions as prototype setup using normal JavaScript does not work as
20085 * expected during bootstrapping (see mirror.js in r114903).
20087 * @param {function} ctor Constructor function which needs to inherit the
20089 * @param {function} superCtor Constructor function to inherit prototype from.
20091 exports.inherits = _dereq_('inherits');
20093 exports._extend = function(origin, add) {
20094 // Don't do anything if add isn't an object
20095 if (!add || !isObject(add)) return origin;
20097 var keys = Object.keys(add);
20098 var i = keys.length;
20100 origin[keys[i]] = add[keys[i]];
20105 function hasOwnProperty(obj, prop) {
20106 return Object.prototype.hasOwnProperty.call(obj, prop);
20109 }).call(this,_dereq_(
"FWaASH"),typeof self !==
"undefined" ? self : typeof window !==
"undefined" ? window : {})
20110 },{
"./support/isBuffer":
5,
"FWaASH":
12,
"inherits":
11}],
7:[function(_dereq_,module,exports){
20112 },{}],
8:[function(_dereq_,module,exports){
20114 * The buffer module from node.js, for the browser.
20116 * at author Feross Aboukhadijeh
<feross@feross.org
> <http://feross.org
>
20120 var base64 = _dereq_('base64-js')
20121 var ieee754 = _dereq_('ieee754')
20123 exports.Buffer = Buffer
20124 exports.SlowBuffer = Buffer
20125 exports.INSPECT_MAX_BYTES =
50
20126 Buffer.poolSize =
8192
20129 * If `Buffer._useTypedArrays`:
20130 * === true Use Uint8Array implementation (fastest)
20131 * === false Use Object implementation (compatible down to IE6)
20133 Buffer._useTypedArrays = (function () {
20134 // Detect if browser supports Typed Arrays. Supported browsers are IE
10+, Firefox
4+,
20135 // Chrome
7+, Safari
5.1+, Opera
11.6+, iOS
4.2+. If the browser does not support adding
20136 // properties to `Uint8Array` instances, then that's the same as no `Uint8Array` support
20137 // because we need to be able to add all the node Buffer API methods. This is an issue
20138 // in Firefox
4-
29. Now fixed: https://bugzilla.mozilla.org/show_bug.cgi?id=
695438
20140 var buf = new ArrayBuffer(
0)
20141 var arr = new Uint8Array(buf)
20142 arr.foo = function () { return
42 }
20143 return
42 === arr.foo() &&
20144 typeof arr.subarray === 'function' // Chrome
9-
10 lack `subarray`
20154 * The Buffer constructor returns instances of `Uint8Array` that are augmented
20155 * with function properties for all the node `Buffer` API functions. We use
20156 * `Uint8Array` so that square bracket notation works as expected -- it returns
20159 * By augmenting the instances, we can avoid modifying the `Uint8Array`
20162 function Buffer (subject, encoding, noZero) {
20163 if (!(this instanceof Buffer))
20164 return new Buffer(subject, encoding, noZero)
20166 var type = typeof subject
20168 if (encoding === 'base64' && type === 'string') {
20169 subject = base64clean(subject)
20174 if (type === 'number')
20175 length = coerce(subject)
20176 else if (type === 'string')
20177 length = Buffer.byteLength(subject, encoding)
20178 else if (type === 'object')
20179 length = coerce(subject.length) // assume that object is array-like
20181 throw new Error('First argument needs to be a number, array or string.')
20184 if (Buffer._useTypedArrays) {
20185 // Preferred: Return an augmented `Uint8Array` instance for best performance
20186 buf = Buffer._augment(new Uint8Array(length))
20188 // Fallback: Return THIS instance of Buffer (created by `new`)
20190 buf.length = length
20191 buf._isBuffer = true
20195 if (Buffer._useTypedArrays && typeof subject.byteLength === 'number') {
20196 // Speed optimization -- use set if we're copying from a typed array
20198 } else if (isArrayish(subject)) {
20199 // Treat array-ish objects as a byte array
20200 if (Buffer.isBuffer(subject)) {
20201 for (i =
0; i < length; i++)
20202 buf[i] = subject.readUInt8(i)
20204 for (i =
0; i < length; i++)
20205 buf[i] = ((subject[i] %
256) +
256) %
256
20207 } else if (type === 'string') {
20208 buf.write(subject,
0, encoding)
20209 } else if (type === 'number' && !Buffer._useTypedArrays && !noZero) {
20210 for (i =
0; i < length; i++) {
20221 Buffer.isEncoding = function (encoding) {
20222 switch (String(encoding).toLowerCase()) {
20240 Buffer.isBuffer = function (b) {
20241 return !!(b !== null && b !== undefined && b._isBuffer)
20244 Buffer.byteLength = function (str, encoding) {
20246 str = str.toString()
20247 switch (encoding || 'utf8') {
20249 ret = str.length /
2
20253 ret = utf8ToBytes(str).length
20261 ret = base64ToBytes(str).length
20267 ret = str.length *
2
20270 throw new Error('Unknown encoding')
20275 Buffer.concat = function (list, totalLength) {
20276 assert(isArray(list), 'Usage: Buffer.concat(list[, length])')
20278 if (list.length ===
0) {
20279 return new Buffer(
0)
20280 } else if (list.length ===
1) {
20285 if (totalLength === undefined) {
20287 for (i =
0; i < list.length; i++) {
20288 totalLength += list[i].length
20292 var buf = new Buffer(totalLength)
20294 for (i =
0; i < list.length; i++) {
20296 item.copy(buf, pos)
20302 Buffer.compare = function (a, b) {
20303 assert(Buffer.isBuffer(a) && Buffer.isBuffer(b), 'Arguments must be Buffers')
20306 for (var i =
0, len = Math.min(x, y); i < len && a[i] === b[i]; i++) {}
20320 // BUFFER INSTANCE METHODS
20321 // =======================
20323 function hexWrite (buf, string, offset, length) {
20324 offset = Number(offset) ||
0
20325 var remaining = buf.length - offset
20329 length = Number(length)
20330 if (length
> remaining) {
20335 // must be an even number of digits
20336 var strLen = string.length
20337 assert(strLen %
2 ===
0, 'Invalid hex string')
20339 if (length
> strLen /
2) {
20340 length = strLen /
2
20342 for (var i =
0; i < length; i++) {
20343 var byte = parseInt(string.substr(i *
2,
2),
16)
20344 assert(!isNaN(byte), 'Invalid hex string')
20345 buf[offset + i] = byte
20350 function utf8Write (buf, string, offset, length) {
20351 var charsWritten = blitBuffer(utf8ToBytes(string), buf, offset, length)
20352 return charsWritten
20355 function asciiWrite (buf, string, offset, length) {
20356 var charsWritten = blitBuffer(asciiToBytes(string), buf, offset, length)
20357 return charsWritten
20360 function binaryWrite (buf, string, offset, length) {
20361 return asciiWrite(buf, string, offset, length)
20364 function base64Write (buf, string, offset, length) {
20365 var charsWritten = blitBuffer(base64ToBytes(string), buf, offset, length)
20366 return charsWritten
20369 function utf16leWrite (buf, string, offset, length) {
20370 var charsWritten = blitBuffer(utf16leToBytes(string), buf, offset, length)
20371 return charsWritten
20374 Buffer.prototype.write = function (string, offset, length, encoding) {
20375 // Support both (string, offset, length, encoding)
20376 // and the legacy (string, encoding, offset, length)
20377 if (isFinite(offset)) {
20378 if (!isFinite(length)) {
20383 var swap = encoding
20389 offset = Number(offset) ||
0
20390 var remaining = this.length - offset
20394 length = Number(length)
20395 if (length
> remaining) {
20399 encoding = String(encoding || 'utf8').toLowerCase()
20402 switch (encoding) {
20404 ret = hexWrite(this, string, offset, length)
20408 ret = utf8Write(this, string, offset, length)
20411 ret = asciiWrite(this, string, offset, length)
20414 ret = binaryWrite(this, string, offset, length)
20417 ret = base64Write(this, string, offset, length)
20423 ret = utf16leWrite(this, string, offset, length)
20426 throw new Error('Unknown encoding')
20431 Buffer.prototype.toString = function (encoding, start, end) {
20434 encoding = String(encoding || 'utf8').toLowerCase()
20435 start = Number(start) ||
0
20436 end = (end === undefined) ? self.length : Number(end)
20438 // Fastpath empty strings
20443 switch (encoding) {
20445 ret = hexSlice(self, start, end)
20449 ret = utf8Slice(self, start, end)
20452 ret = asciiSlice(self, start, end)
20455 ret = binarySlice(self, start, end)
20458 ret = base64Slice(self, start, end)
20464 ret = utf16leSlice(self, start, end)
20467 throw new Error('Unknown encoding')
20472 Buffer.prototype.toJSON = function () {
20475 data: Array.prototype.slice.call(this._arr || this,
0)
20479 Buffer.prototype.equals = function (b) {
20480 assert(Buffer.isBuffer(b), 'Argument must be a Buffer')
20481 return Buffer.compare(this, b) ===
0
20484 Buffer.prototype.compare = function (b) {
20485 assert(Buffer.isBuffer(b), 'Argument must be a Buffer')
20486 return Buffer.compare(this, b)
20489 // copy(targetBuffer, targetStart=
0, sourceStart=
0, sourceEnd=buffer.length)
20490 Buffer.prototype.copy = function (target, target_start, start, end) {
20493 if (!start) start =
0
20494 if (!end && end !==
0) end = this.length
20495 if (!target_start) target_start =
0
20497 // Copy
0 bytes; we're done
20498 if (end === start) return
20499 if (target.length ===
0 || source.length ===
0) return
20501 // Fatal error conditions
20502 assert(end
>= start, 'sourceEnd < sourceStart')
20503 assert(target_start
>=
0 && target_start < target.length,
20504 'targetStart out of bounds')
20505 assert(start
>=
0 && start < source.length, 'sourceStart out of bounds')
20506 assert(end
>=
0 && end <= source.length, 'sourceEnd out of bounds')
20509 if (end
> this.length)
20511 if (target.length - target_start < end - start)
20512 end = target.length - target_start + start
20514 var len = end - start
20516 if (len <
100 || !Buffer._useTypedArrays) {
20517 for (var i =
0; i < len; i++) {
20518 target[i + target_start] = this[i + start]
20521 target._set(this.subarray(start, start + len), target_start)
20525 function base64Slice (buf, start, end) {
20526 if (start ===
0 && end === buf.length) {
20527 return base64.fromByteArray(buf)
20529 return base64.fromByteArray(buf.slice(start, end))
20533 function utf8Slice (buf, start, end) {
20536 end = Math.min(buf.length, end)
20538 for (var i = start; i < end; i++) {
20539 if (buf[i] <=
0x7F) {
20540 res += decodeUtf8Char(tmp) + String.fromCharCode(buf[i])
20543 tmp += '%' + buf[i].toString(
16)
20547 return res + decodeUtf8Char(tmp)
20550 function asciiSlice (buf, start, end) {
20552 end = Math.min(buf.length, end)
20554 for (var i = start; i < end; i++) {
20555 ret += String.fromCharCode(buf[i])
20560 function binarySlice (buf, start, end) {
20561 return asciiSlice(buf, start, end)
20564 function hexSlice (buf, start, end) {
20565 var len = buf.length
20567 if (!start || start <
0) start =
0
20568 if (!end || end <
0 || end
> len) end = len
20571 for (var i = start; i < end; i++) {
20572 out += toHex(buf[i])
20577 function utf16leSlice (buf, start, end) {
20578 var bytes = buf.slice(start, end)
20580 for (var i =
0; i < bytes.length; i +=
2) {
20581 res += String.fromCharCode(bytes[i] + bytes[i +
1] *
256)
20586 Buffer.prototype.slice = function (start, end) {
20587 var len = this.length
20588 start = clamp(start, len,
0)
20589 end = clamp(end, len, len)
20591 if (Buffer._useTypedArrays) {
20592 return Buffer._augment(this.subarray(start, end))
20594 var sliceLen = end - start
20595 var newBuf = new Buffer(sliceLen, undefined, true)
20596 for (var i =
0; i < sliceLen; i++) {
20597 newBuf[i] = this[i + start]
20603 // `get` will be removed in Node
0.13+
20604 Buffer.prototype.get = function (offset) {
20605 console.log('.get() is deprecated. Access using array indexes instead.')
20606 return this.readUInt8(offset)
20609 // `set` will be removed in Node
0.13+
20610 Buffer.prototype.set = function (v, offset) {
20611 console.log('.set() is deprecated. Access using array indexes instead.')
20612 return this.writeUInt8(v, offset)
20615 Buffer.prototype.readUInt8 = function (offset, noAssert) {
20617 assert(offset !== undefined && offset !== null, 'missing offset')
20618 assert(offset < this.length, 'Trying to read beyond buffer length')
20621 if (offset
>= this.length)
20624 return this[offset]
20627 function readUInt16 (buf, offset, littleEndian, noAssert) {
20629 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20630 assert(offset !== undefined && offset !== null, 'missing offset')
20631 assert(offset +
1 < buf.length, 'Trying to read beyond buffer length')
20634 var len = buf.length
20639 if (littleEndian) {
20641 if (offset +
1 < len)
20642 val |= buf[offset +
1] <<
8
20644 val = buf[offset] <<
8
20645 if (offset +
1 < len)
20646 val |= buf[offset +
1]
20651 Buffer.prototype.readUInt16LE = function (offset, noAssert) {
20652 return readUInt16(this, offset, true, noAssert)
20655 Buffer.prototype.readUInt16BE = function (offset, noAssert) {
20656 return readUInt16(this, offset, false, noAssert)
20659 function readUInt32 (buf, offset, littleEndian, noAssert) {
20661 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20662 assert(offset !== undefined && offset !== null, 'missing offset')
20663 assert(offset +
3 < buf.length, 'Trying to read beyond buffer length')
20666 var len = buf.length
20671 if (littleEndian) {
20672 if (offset +
2 < len)
20673 val = buf[offset +
2] <<
16
20674 if (offset +
1 < len)
20675 val |= buf[offset +
1] <<
8
20677 if (offset +
3 < len)
20678 val = val + (buf[offset +
3] <<
24 >>> 0)
20680 if (offset +
1 < len)
20681 val = buf[offset +
1] <<
16
20682 if (offset +
2 < len)
20683 val |= buf[offset +
2] <<
8
20684 if (offset +
3 < len)
20685 val |= buf[offset +
3]
20686 val = val + (buf[offset] <<
24 >>> 0)
20691 Buffer.prototype.readUInt32LE = function (offset, noAssert) {
20692 return readUInt32(this, offset, true, noAssert)
20695 Buffer.prototype.readUInt32BE = function (offset, noAssert) {
20696 return readUInt32(this, offset, false, noAssert)
20699 Buffer.prototype.readInt8 = function (offset, noAssert) {
20701 assert(offset !== undefined && offset !== null,
20703 assert(offset < this.length, 'Trying to read beyond buffer length')
20706 if (offset
>= this.length)
20709 var neg = this[offset] &
0x80
20711 return (
0xff - this[offset] +
1) * -
1
20713 return this[offset]
20716 function readInt16 (buf, offset, littleEndian, noAssert) {
20718 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20719 assert(offset !== undefined && offset !== null, 'missing offset')
20720 assert(offset +
1 < buf.length, 'Trying to read beyond buffer length')
20723 var len = buf.length
20727 var val = readUInt16(buf, offset, littleEndian, true)
20728 var neg = val &
0x8000
20730 return (
0xffff - val +
1) * -
1
20735 Buffer.prototype.readInt16LE = function (offset, noAssert) {
20736 return readInt16(this, offset, true, noAssert)
20739 Buffer.prototype.readInt16BE = function (offset, noAssert) {
20740 return readInt16(this, offset, false, noAssert)
20743 function readInt32 (buf, offset, littleEndian, noAssert) {
20745 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20746 assert(offset !== undefined && offset !== null, 'missing offset')
20747 assert(offset +
3 < buf.length, 'Trying to read beyond buffer length')
20750 var len = buf.length
20754 var val = readUInt32(buf, offset, littleEndian, true)
20755 var neg = val &
0x80000000
20757 return (
0xffffffff - val +
1) * -
1
20762 Buffer.prototype.readInt32LE = function (offset, noAssert) {
20763 return readInt32(this, offset, true, noAssert)
20766 Buffer.prototype.readInt32BE = function (offset, noAssert) {
20767 return readInt32(this, offset, false, noAssert)
20770 function readFloat (buf, offset, littleEndian, noAssert) {
20772 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20773 assert(offset +
3 < buf.length, 'Trying to read beyond buffer length')
20776 return ieee754.read(buf, offset, littleEndian,
23,
4)
20779 Buffer.prototype.readFloatLE = function (offset, noAssert) {
20780 return readFloat(this, offset, true, noAssert)
20783 Buffer.prototype.readFloatBE = function (offset, noAssert) {
20784 return readFloat(this, offset, false, noAssert)
20787 function readDouble (buf, offset, littleEndian, noAssert) {
20789 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20790 assert(offset +
7 < buf.length, 'Trying to read beyond buffer length')
20793 return ieee754.read(buf, offset, littleEndian,
52,
8)
20796 Buffer.prototype.readDoubleLE = function (offset, noAssert) {
20797 return readDouble(this, offset, true, noAssert)
20800 Buffer.prototype.readDoubleBE = function (offset, noAssert) {
20801 return readDouble(this, offset, false, noAssert)
20804 Buffer.prototype.writeUInt8 = function (value, offset, noAssert) {
20806 assert(value !== undefined && value !== null, 'missing value')
20807 assert(offset !== undefined && offset !== null, 'missing offset')
20808 assert(offset < this.length, 'trying to write beyond buffer length')
20809 verifuint(value,
0xff)
20812 if (offset
>= this.length) return
20814 this[offset] = value
20818 function writeUInt16 (buf, value, offset, littleEndian, noAssert) {
20820 assert(value !== undefined && value !== null, 'missing value')
20821 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20822 assert(offset !== undefined && offset !== null, 'missing offset')
20823 assert(offset +
1 < buf.length, 'trying to write beyond buffer length')
20824 verifuint(value,
0xffff)
20827 var len = buf.length
20831 for (var i =
0, j = Math.min(len - offset,
2); i < j; i++) {
20833 (value & (
0xff << (
8 * (littleEndian ? i :
1 - i))))
>>>
20834 (littleEndian ? i :
1 - i) *
8
20839 Buffer.prototype.writeUInt16LE = function (value, offset, noAssert) {
20840 return writeUInt16(this, value, offset, true, noAssert)
20843 Buffer.prototype.writeUInt16BE = function (value, offset, noAssert) {
20844 return writeUInt16(this, value, offset, false, noAssert)
20847 function writeUInt32 (buf, value, offset, littleEndian, noAssert) {
20849 assert(value !== undefined && value !== null, 'missing value')
20850 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20851 assert(offset !== undefined && offset !== null, 'missing offset')
20852 assert(offset +
3 < buf.length, 'trying to write beyond buffer length')
20853 verifuint(value,
0xffffffff)
20856 var len = buf.length
20860 for (var i =
0, j = Math.min(len - offset,
4); i < j; i++) {
20862 (value
>>> (littleEndian ? i :
3 - i) *
8) &
0xff
20867 Buffer.prototype.writeUInt32LE = function (value, offset, noAssert) {
20868 return writeUInt32(this, value, offset, true, noAssert)
20871 Buffer.prototype.writeUInt32BE = function (value, offset, noAssert) {
20872 return writeUInt32(this, value, offset, false, noAssert)
20875 Buffer.prototype.writeInt8 = function (value, offset, noAssert) {
20877 assert(value !== undefined && value !== null, 'missing value')
20878 assert(offset !== undefined && offset !== null, 'missing offset')
20879 assert(offset < this.length, 'Trying to write beyond buffer length')
20880 verifsint(value,
0x7f, -
0x80)
20883 if (offset
>= this.length)
20887 this.writeUInt8(value, offset, noAssert)
20889 this.writeUInt8(
0xff + value +
1, offset, noAssert)
20893 function writeInt16 (buf, value, offset, littleEndian, noAssert) {
20895 assert(value !== undefined && value !== null, 'missing value')
20896 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20897 assert(offset !== undefined && offset !== null, 'missing offset')
20898 assert(offset +
1 < buf.length, 'Trying to write beyond buffer length')
20899 verifsint(value,
0x7fff, -
0x8000)
20902 var len = buf.length
20907 writeUInt16(buf, value, offset, littleEndian, noAssert)
20909 writeUInt16(buf,
0xffff + value +
1, offset, littleEndian, noAssert)
20913 Buffer.prototype.writeInt16LE = function (value, offset, noAssert) {
20914 return writeInt16(this, value, offset, true, noAssert)
20917 Buffer.prototype.writeInt16BE = function (value, offset, noAssert) {
20918 return writeInt16(this, value, offset, false, noAssert)
20921 function writeInt32 (buf, value, offset, littleEndian, noAssert) {
20923 assert(value !== undefined && value !== null, 'missing value')
20924 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20925 assert(offset !== undefined && offset !== null, 'missing offset')
20926 assert(offset +
3 < buf.length, 'Trying to write beyond buffer length')
20927 verifsint(value,
0x7fffffff, -
0x80000000)
20930 var len = buf.length
20935 writeUInt32(buf, value, offset, littleEndian, noAssert)
20937 writeUInt32(buf,
0xffffffff + value +
1, offset, littleEndian, noAssert)
20941 Buffer.prototype.writeInt32LE = function (value, offset, noAssert) {
20942 return writeInt32(this, value, offset, true, noAssert)
20945 Buffer.prototype.writeInt32BE = function (value, offset, noAssert) {
20946 return writeInt32(this, value, offset, false, noAssert)
20949 function writeFloat (buf, value, offset, littleEndian, noAssert) {
20951 assert(value !== undefined && value !== null, 'missing value')
20952 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20953 assert(offset !== undefined && offset !== null, 'missing offset')
20954 assert(offset +
3 < buf.length, 'Trying to write beyond buffer length')
20955 verifIEEE754(value,
3.4028234663852886e+38, -
3.4028234663852886e+38)
20958 var len = buf.length
20962 ieee754.write(buf, value, offset, littleEndian,
23,
4)
20966 Buffer.prototype.writeFloatLE = function (value, offset, noAssert) {
20967 return writeFloat(this, value, offset, true, noAssert)
20970 Buffer.prototype.writeFloatBE = function (value, offset, noAssert) {
20971 return writeFloat(this, value, offset, false, noAssert)
20974 function writeDouble (buf, value, offset, littleEndian, noAssert) {
20976 assert(value !== undefined && value !== null, 'missing value')
20977 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20978 assert(offset !== undefined && offset !== null, 'missing offset')
20979 assert(offset +
7 < buf.length,
20980 'Trying to write beyond buffer length')
20981 verifIEEE754(value,
1.7976931348623157E+308, -
1.7976931348623157E+308)
20984 var len = buf.length
20988 ieee754.write(buf, value, offset, littleEndian,
52,
8)
20992 Buffer.prototype.writeDoubleLE = function (value, offset, noAssert) {
20993 return writeDouble(this, value, offset, true, noAssert)
20996 Buffer.prototype.writeDoubleBE = function (value, offset, noAssert) {
20997 return writeDouble(this, value, offset, false, noAssert)
21000 // fill(value, start=
0, end=buffer.length)
21001 Buffer.prototype.fill = function (value, start, end) {
21002 if (!value) value =
0
21003 if (!start) start =
0
21004 if (!end) end = this.length
21006 assert(end
>= start, 'end < start')
21008 // Fill
0 bytes; we're done
21009 if (end === start) return
21010 if (this.length ===
0) return
21012 assert(start
>=
0 && start < this.length, 'start out of bounds')
21013 assert(end
>=
0 && end <= this.length, 'end out of bounds')
21016 if (typeof value === 'number') {
21017 for (i = start; i < end; i++) {
21021 var bytes = utf8ToBytes(value.toString())
21022 var len = bytes.length
21023 for (i = start; i < end; i++) {
21024 this[i] = bytes[i % len]
21031 Buffer.prototype.inspect = function () {
21033 var len = this.length
21034 for (var i =
0; i < len; i++) {
21035 out[i] = toHex(this[i])
21036 if (i === exports.INSPECT_MAX_BYTES) {
21041 return '
<Buffer ' + out.join(' ') + '
>'
21045 * Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance.
21046 * Added in Node
0.12. Only available in browsers that support ArrayBuffer.
21048 Buffer.prototype.toArrayBuffer = function () {
21049 if (typeof Uint8Array !== 'undefined') {
21050 if (Buffer._useTypedArrays) {
21051 return (new Buffer(this)).buffer
21053 var buf = new Uint8Array(this.length)
21054 for (var i =
0, len = buf.length; i < len; i +=
1) {
21060 throw new Error('Buffer.toArrayBuffer not supported in this browser')
21064 // HELPER FUNCTIONS
21065 // ================
21067 var BP = Buffer.prototype
21070 * Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods
21072 Buffer._augment = function (arr) {
21073 arr._isBuffer = true
21075 // save reference to original Uint8Array get/set methods before overwriting
21079 // deprecated, will be removed in node
0.13+
21083 arr.write = BP.write
21084 arr.toString = BP.toString
21085 arr.toLocaleString = BP.toString
21086 arr.toJSON = BP.toJSON
21087 arr.equals = BP.equals
21088 arr.compare = BP.compare
21090 arr.slice = BP.slice
21091 arr.readUInt8 = BP.readUInt8
21092 arr.readUInt16LE = BP.readUInt16LE
21093 arr.readUInt16BE = BP.readUInt16BE
21094 arr.readUInt32LE = BP.readUInt32LE
21095 arr.readUInt32BE = BP.readUInt32BE
21096 arr.readInt8 = BP.readInt8
21097 arr.readInt16LE = BP.readInt16LE
21098 arr.readInt16BE = BP.readInt16BE
21099 arr.readInt32LE = BP.readInt32LE
21100 arr.readInt32BE = BP.readInt32BE
21101 arr.readFloatLE = BP.readFloatLE
21102 arr.readFloatBE = BP.readFloatBE
21103 arr.readDoubleLE = BP.readDoubleLE
21104 arr.readDoubleBE = BP.readDoubleBE
21105 arr.writeUInt8 = BP.writeUInt8
21106 arr.writeUInt16LE = BP.writeUInt16LE
21107 arr.writeUInt16BE = BP.writeUInt16BE
21108 arr.writeUInt32LE = BP.writeUInt32LE
21109 arr.writeUInt32BE = BP.writeUInt32BE
21110 arr.writeInt8 = BP.writeInt8
21111 arr.writeInt16LE = BP.writeInt16LE
21112 arr.writeInt16BE = BP.writeInt16BE
21113 arr.writeInt32LE = BP.writeInt32LE
21114 arr.writeInt32BE = BP.writeInt32BE
21115 arr.writeFloatLE = BP.writeFloatLE
21116 arr.writeFloatBE = BP.writeFloatBE
21117 arr.writeDoubleLE = BP.writeDoubleLE
21118 arr.writeDoubleBE = BP.writeDoubleBE
21120 arr.inspect = BP.inspect
21121 arr.toArrayBuffer = BP.toArrayBuffer
21126 var INVALID_BASE64_RE = /[^+\/
0-
9A-z]/g
21128 function base64clean (str) {
21129 // Node strips out invalid characters like \n and \t from the string, base64-js does not
21130 str = stringtrim(str).replace(INVALID_BASE64_RE, '')
21131 // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
21132 while (str.length %
4 !==
0) {
21138 function stringtrim (str) {
21139 if (str.trim) return str.trim()
21140 return str.replace(/^\s+|\s+$/g, '')
21143 // slice(start, end)
21144 function clamp (index, len, defaultValue) {
21145 if (typeof index !== 'number') return defaultValue
21146 index = ~~index; // Coerce to integer.
21147 if (index
>= len) return len
21148 if (index
>=
0) return index
21150 if (index
>=
0) return index
21154 function coerce (length) {
21155 // Coerce length to a number (possibly NaN), round up
21156 // in case it's fractional (e.g.
123.456) then do a
21157 // double negate to coerce a NaN to
0. Easy, right?
21158 length = ~~Math.ceil(+length)
21159 return length <
0 ?
0 : length
21162 function isArray (subject) {
21163 return (Array.isArray || function (subject) {
21164 return Object.prototype.toString.call(subject) === '[object Array]'
21168 function isArrayish (subject) {
21169 return isArray(subject) || Buffer.isBuffer(subject) ||
21170 subject && typeof subject === 'object' &&
21171 typeof subject.length === 'number'
21174 function toHex (n) {
21175 if (n <
16) return '
0' + n.toString(
16)
21176 return n.toString(
16)
21179 function utf8ToBytes (str) {
21181 for (var i =
0; i < str.length; i++) {
21182 var b = str.charCodeAt(i)
21187 if (b
>=
0xD800 && b <=
0xDFFF) i++
21188 var h = encodeURIComponent(str.slice(start, i+
1)).substr(
1).split('%')
21189 for (var j =
0; j < h.length; j++) {
21190 byteArray.push(parseInt(h[j],
16))
21197 function asciiToBytes (str) {
21199 for (var i =
0; i < str.length; i++) {
21200 // Node's code seems to be doing this and not &
0x7F..
21201 byteArray.push(str.charCodeAt(i) &
0xFF)
21206 function utf16leToBytes (str) {
21209 for (var i =
0; i < str.length; i++) {
21210 c = str.charCodeAt(i)
21220 function base64ToBytes (str) {
21221 return base64.toByteArray(str)
21224 function blitBuffer (src, dst, offset, length) {
21225 for (var i =
0; i < length; i++) {
21226 if ((i + offset
>= dst.length) || (i
>= src.length))
21228 dst[i + offset] = src[i]
21233 function decodeUtf8Char (str) {
21235 return decodeURIComponent(str)
21237 return String.fromCharCode(
0xFFFD) // UTF
8 invalid char
21242 * We have to make sure that the value is a valid integer. This means that it
21243 * is non-negative. It has no fractional component and that it does not
21244 * exceed the maximum allowed value.
21246 function verifuint (value, max) {
21247 assert(typeof value === 'number', 'cannot write a non-number as a number')
21248 assert(value
>=
0, 'specified a negative value for writing an unsigned value')
21249 assert(value <= max, 'value is larger than maximum value for type')
21250 assert(Math.floor(value) === value, 'value has a fractional component')
21253 function verifsint (value, max, min) {
21254 assert(typeof value === 'number', 'cannot write a non-number as a number')
21255 assert(value <= max, 'value larger than maximum allowed value')
21256 assert(value
>= min, 'value smaller than minimum allowed value')
21257 assert(Math.floor(value) === value, 'value has a fractional component')
21260 function verifIEEE754 (value, max, min) {
21261 assert(typeof value === 'number', 'cannot write a non-number as a number')
21262 assert(value <= max, 'value larger than maximum allowed value')
21263 assert(value
>= min, 'value smaller than minimum allowed value')
21266 function assert (test, message) {
21267 if (!test) throw new Error(message || 'Failed assertion')
21270 },{"base64-js":
9,"ieee754":
10}],
9:[function(_dereq_,module,exports){
21271 var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
21273 ;(function (exports) {
21276 var Arr = (typeof Uint8Array !== 'undefined')
21280 var PLUS = '+'.charCodeAt(
0)
21281 var SLASH = '/'.charCodeAt(
0)
21282 var NUMBER = '
0'.charCodeAt(
0)
21283 var LOWER = 'a'.charCodeAt(
0)
21284 var UPPER = 'A'.charCodeAt(
0)
21286 function decode (elt) {
21287 var code = elt.charCodeAt(
0)
21290 if (code === SLASH)
21293 return -
1 //no match
21294 if (code < NUMBER +
10)
21295 return code - NUMBER +
26 +
26
21296 if (code < UPPER +
26)
21297 return code - UPPER
21298 if (code < LOWER +
26)
21299 return code - LOWER +
26
21302 function b64ToByteArray (b64) {
21303 var i, j, l, tmp, placeHolders, arr
21305 if (b64.length %
4 > 0) {
21306 throw new Error('Invalid string. Length must be a multiple of
4')
21309 // the number of equal signs (place holders)
21310 // if there are two placeholders, than the two characters before it
21311 // represent one byte
21312 // if there is only one, then the three characters before it represent
2 bytes
21313 // this is just a cheap hack to not do indexOf twice
21314 var len = b64.length
21315 placeHolders = '=' === b64.charAt(len -
2) ?
2 : '=' === b64.charAt(len -
1) ?
1 :
0
21317 // base64 is
4/
3 + up to two characters of the original data
21318 arr = new Arr(b64.length *
3 /
4 - placeHolders)
21320 // if there are placeholders, only get up to the last complete
4 chars
21321 l = placeHolders
> 0 ? b64.length -
4 : b64.length
21325 function push (v) {
21329 for (i =
0, j =
0; i < l; i +=
4, j +=
3) {
21330 tmp = (decode(b64.charAt(i)) <<
18) | (decode(b64.charAt(i +
1)) <<
12) | (decode(b64.charAt(i +
2)) <<
6) | decode(b64.charAt(i +
3))
21331 push((tmp &
0xFF0000)
>> 16)
21332 push((tmp &
0xFF00)
>> 8)
21336 if (placeHolders ===
2) {
21337 tmp = (decode(b64.charAt(i)) <<
2) | (decode(b64.charAt(i +
1))
>> 4)
21339 } else if (placeHolders ===
1) {
21340 tmp = (decode(b64.charAt(i)) <<
10) | (decode(b64.charAt(i +
1)) <<
4) | (decode(b64.charAt(i +
2))
>> 2)
21341 push((tmp
>> 8) &
0xFF)
21348 function uint8ToBase64 (uint8) {
21350 extraBytes = uint8.length %
3, // if we have
1 byte left, pad
2 bytes
21354 function encode (num) {
21355 return lookup.charAt(num)
21358 function tripletToBase64 (num) {
21359 return encode(num
>> 18 &
0x3F) + encode(num
>> 12 &
0x3F) + encode(num
>> 6 &
0x3F) + encode(num &
0x3F)
21362 // go through the array every three bytes, we'll deal with trailing stuff later
21363 for (i =
0, length = uint8.length - extraBytes; i < length; i +=
3) {
21364 temp = (uint8[i] <<
16) + (uint8[i +
1] <<
8) + (uint8[i +
2])
21365 output += tripletToBase64(temp)
21368 // pad the end with zeros, but make sure to not forget the extra bytes
21369 switch (extraBytes) {
21371 temp = uint8[uint8.length -
1]
21372 output += encode(temp
>> 2)
21373 output += encode((temp <<
4) &
0x3F)
21377 temp = (uint8[uint8.length -
2] <<
8) + (uint8[uint8.length -
1])
21378 output += encode(temp
>> 10)
21379 output += encode((temp
>> 4) &
0x3F)
21380 output += encode((temp <<
2) &
0x3F)
21388 exports.toByteArray = b64ToByteArray
21389 exports.fromByteArray = uint8ToBase64
21390 }(typeof exports === 'undefined' ? (this.base64js = {}) : exports))
21392 },{}],
10:[function(_dereq_,module,exports){
21393 exports.read = function(buffer, offset, isLE, mLen, nBytes) {
21395 eLen = nBytes *
8 - mLen -
1,
21396 eMax = (
1 << eLen) -
1,
21399 i = isLE ? (nBytes -
1) :
0,
21401 s = buffer[offset + i];
21405 e = s & ((
1 << (-nBits)) -
1);
21408 for (; nBits
> 0; e = e *
256 + buffer[offset + i], i += d, nBits -=
8){};
21410 m = e & ((
1 << (-nBits)) -
1);
21413 for (; nBits
> 0; m = m *
256 + buffer[offset + i], i += d, nBits -=
8){};
21417 } else if (e === eMax) {
21418 return m ? NaN : ((s ? -
1 :
1) * Infinity);
21420 m = m + Math.pow(
2, mLen);
21423 return (s ? -
1 :
1) * m * Math.pow(
2, e - mLen);
21426 exports.write = function(buffer, value, offset, isLE, mLen, nBytes) {
21428 eLen = nBytes *
8 - mLen -
1,
21429 eMax = (
1 << eLen) -
1,
21431 rt = (mLen ===
23 ? Math.pow(
2, -
24) - Math.pow(
2, -
77) :
0),
21432 i = isLE ?
0 : (nBytes -
1),
21434 s = value <
0 || (value ===
0 &&
1 / value <
0) ?
1 :
0;
21436 value = Math.abs(value);
21438 if (isNaN(value) || value === Infinity) {
21439 m = isNaN(value) ?
1 :
0;
21442 e = Math.floor(Math.log(value) / Math.LN2);
21443 if (value * (c = Math.pow(
2, -e)) <
1) {
21447 if (e + eBias
>=
1) {
21450 value += rt * Math.pow(
2,
1 - eBias);
21452 if (value * c
>=
2) {
21457 if (e + eBias
>= eMax) {
21460 } else if (e + eBias
>=
1) {
21461 m = (value * c -
1) * Math.pow(
2, mLen);
21464 m = value * Math.pow(
2, eBias -
1) * Math.pow(
2, mLen);
21469 for (; mLen
>=
8; buffer[offset + i] = m &
0xff, i += d, m /=
256, mLen -=
8){};
21471 e = (e << mLen) | m;
21473 for (; eLen
> 0; buffer[offset + i] = e &
0xff, i += d, e /=
256, eLen -=
8){};
21475 buffer[offset + i - d] |= s *
128;
21478 },{}],
11:[function(_dereq_,module,exports){
21479 if (typeof Object.create === 'function') {
21480 // implementation from standard node.js 'util' module
21481 module.exports = function inherits(ctor, superCtor) {
21482 ctor.super_ = superCtor
21483 ctor.prototype = Object.create(superCtor.prototype, {
21493 // old school shim for old browsers
21494 module.exports = function inherits(ctor, superCtor) {
21495 ctor.super_ = superCtor
21496 var TempCtor = function () {}
21497 TempCtor.prototype = superCtor.prototype
21498 ctor.prototype = new TempCtor()
21499 ctor.prototype.constructor = ctor
21503 },{}],
12:[function(_dereq_,module,exports){
21504 // shim for using process in browser
21506 var process = module.exports = {};
21508 process.nextTick = (function () {
21509 var canSetImmediate = typeof window !== 'undefined'
21510 && window.setImmediate;
21511 var canPost = typeof window !== 'undefined'
21512 && window.postMessage && window.addEventListener
21515 if (canSetImmediate) {
21516 return function (f) { return window.setImmediate(f) };
21521 window.addEventListener('message', function (ev) {
21522 var source = ev.source;
21523 if ((source === window || source === null) && ev.data === 'process-tick') {
21524 ev.stopPropagation();
21525 if (queue.length
> 0) {
21526 var fn = queue.shift();
21532 return function nextTick(fn) {
21534 window.postMessage('process-tick', '*');
21538 return function nextTick(fn) {
21543 process.title = 'browser';
21544 process.browser = true;
21551 process.addListener = noop;
21552 process.once = noop;
21553 process.off = noop;
21554 process.removeListener = noop;
21555 process.removeAllListeners = noop;
21556 process.emit = noop;
21558 process.binding = function (name) {
21559 throw new Error('process.binding is not supported');
21563 process.cwd = function () { return '/' };
21564 process.chdir = function (dir) {
21565 throw new Error('process.chdir is not supported');
21568 },{}],
13:[function(_dereq_,module,exports){
21569 module.exports=_dereq_(
5)
21570 },{}],
14:[function(_dereq_,module,exports){
21571 module.exports=_dereq_(
6)
21572 },{
"./support/isBuffer":
13,
"FWaASH":
12,
"inherits":
11}],
15:[function(_dereq_,module,exports){
21573 (function (Buffer){
21574 // Base58 encoding/decoding
21575 // Originally written by Mike Hearn for BitcoinJ
21576 // Copyright (c)
2011 Google Inc
21577 // Ported to JavaScript by Stefan Thomas
21578 // Merged Buffer refactorings from base58-native by Stephen Pair
21579 // Copyright (c)
2013 BitPay Inc
21581 var assert = _dereq_('assert')
21582 var BigInteger = _dereq_('bigi')
21584 var ALPHABET = '
123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
21585 var ALPHABET_BUF = new Buffer(ALPHABET, 'ascii')
21586 var ALPHABET_MAP = {}
21587 for(var i =
0; i < ALPHABET.length; i++) {
21588 ALPHABET_MAP[ALPHABET.charAt(i)] = BigInteger.valueOf(i)
21590 var BASE = new BigInteger('
58')
21592 function encode(buffer) {
21593 var bi = BigInteger.fromBuffer(buffer)
21594 var result = new Buffer(buffer.length <<
1)
21596 var i = result.length -
1
21597 while (bi.signum()
> 0) {
21598 var remainder = bi.mod(BASE)
21599 bi = bi.divide(BASE)
21601 result[i] = ALPHABET_BUF[remainder.intValue()]
21605 // deal with leading zeros
21607 while (buffer[j] ===
0) {
21608 result[i] = ALPHABET_BUF[
0]
21613 return result.slice(i +
1, result.length).toString('ascii')
21616 function decode(string) {
21617 if (string.length ===
0) return new Buffer(
0)
21619 var num = BigInteger.ZERO
21621 for (var i =
0; i < string.length; i++) {
21622 num = num.multiply(BASE)
21624 var figure = ALPHABET_MAP[string.charAt(i)]
21625 assert.notEqual(figure, undefined, 'Non-base58 character')
21627 num = num.add(figure)
21630 // deal with leading zeros
21632 while ((j < string.length) && (string[j] === ALPHABET[
0])) {
21636 var buffer = num.toBuffer()
21637 var leadingZeros = new Buffer(j)
21638 leadingZeros.fill(
0)
21640 return Buffer.concat([leadingZeros, buffer])
21648 }).call(this,_dereq_(
"buffer").Buffer)
21649 },{
"assert":
4,
"bigi":
3,
"buffer":
8}],
16:[function(_dereq_,module,exports){
21650 (function (Buffer){
21651 var createHash = _dereq_('sha.js')
21653 var md5 = toConstructor(_dereq_('./md5'))
21654 var rmd160 = toConstructor(_dereq_('ripemd160'))
21656 function toConstructor (fn) {
21657 return function () {
21660 update: function (data, enc) {
21661 if(!Buffer.isBuffer(data)) data = new Buffer(data, enc)
21665 digest: function (enc) {
21666 var buf = Buffer.concat(buffers)
21669 return enc ? r.toString(enc) : r
21676 module.exports = function (alg) {
21677 if('md5' === alg) return new md5()
21678 if('rmd160' === alg) return new rmd160()
21679 return createHash(alg)
21682 }).call(this,_dereq_(
"buffer").Buffer)
21683 },{
"./md5":
20,
"buffer":
8,
"ripemd160":
21,
"sha.js":
23}],
17:[function(_dereq_,module,exports){
21684 (function (Buffer){
21685 var createHash = _dereq_('./create-hash')
21688 var zeroBuffer = new Buffer(blocksize); zeroBuffer.fill(
0)
21690 module.exports = Hmac
21692 function Hmac (alg, key) {
21693 if(!(this instanceof Hmac)) return new Hmac(alg, key)
21697 key = this._key = !Buffer.isBuffer(key) ? new Buffer(key) : key
21699 if(key.length
> blocksize) {
21700 key = createHash(alg).update(key).digest()
21701 } else if(key.length < blocksize) {
21702 key = Buffer.concat([key, zeroBuffer], blocksize)
21705 var ipad = this._ipad = new Buffer(blocksize)
21706 var opad = this._opad = new Buffer(blocksize)
21708 for(var i =
0; i < blocksize; i++) {
21709 ipad[i] = key[i] ^
0x36
21710 opad[i] = key[i] ^
0x5C
21713 this._hash = createHash(alg).update(ipad)
21716 Hmac.prototype.update = function (data, enc) {
21717 this._hash.update(data, enc)
21721 Hmac.prototype.digest = function (enc) {
21722 var h = this._hash.digest()
21723 return createHash(this._alg).update(this._opad).update(h).digest(enc)
21727 }).call(this,_dereq_("buffer").Buffer)
21728 },{"./create-hash":
16,"buffer":
8}],
18:[function(_dereq_,module,exports){
21729 (function (Buffer){
21731 var zeroBuffer = new Buffer(intSize); zeroBuffer.fill(
0);
21734 function toArray(buf, bigEndian) {
21735 if ((buf.length % intSize) !==
0) {
21736 var len = buf.length + (intSize - (buf.length % intSize));
21737 buf = Buffer.concat([buf, zeroBuffer], len);
21741 var fn = bigEndian ? buf.readInt32BE : buf.readInt32LE;
21742 for (var i =
0; i < buf.length; i += intSize) {
21743 arr.push(fn.call(buf, i));
21748 function toBuffer(arr, size, bigEndian) {
21749 var buf = new Buffer(size);
21750 var fn = bigEndian ? buf.writeInt32BE : buf.writeInt32LE;
21751 for (var i =
0; i < arr.length; i++) {
21752 fn.call(buf, arr[i], i *
4, true);
21757 function hash(buf, fn, hashSize, bigEndian) {
21758 if (!Buffer.isBuffer(buf)) buf = new Buffer(buf);
21759 var arr = fn(toArray(buf, bigEndian), buf.length * chrsz);
21760 return toBuffer(arr, hashSize, bigEndian);
21763 module.exports = { hash: hash };
21765 }).call(this,_dereq_("buffer").Buffer)
21766 },{"buffer":
8}],
19:[function(_dereq_,module,exports){
21767 (function (Buffer){
21768 var rng = _dereq_('./rng')
21770 function error () {
21771 var m = [].slice.call(arguments).join(' ')
21774 'we accept pull requests',
21775 'http://github.com/dominictarr/crypto-browserify'
21779 exports.createHash = _dereq_('./create-hash')
21781 exports.createHmac = _dereq_('./create-hmac')
21783 exports.randomBytes = function(size, callback) {
21784 if (callback && callback.call) {
21786 callback.call(this, undefined, new Buffer(rng(size)))
21787 } catch (err) { callback(err) }
21789 return new Buffer(rng(size))
21793 function each(a, f) {
21798 exports.getHashes = function () {
21799 return ['sha1', 'sha256', 'md5', 'rmd160']
21803 var p = _dereq_('./pbkdf2')(exports.createHmac)
21804 exports.pbkdf2 = p.pbkdf2
21805 exports.pbkdf2Sync = p.pbkdf2Sync
21808 // the least I can do is make error messages for the rest of the node.js/crypto api.
21809 each(['createCredentials'
21813 , 'createDecipheriv'
21816 , 'createDiffieHellman'
21817 ], function (name) {
21818 exports[name] = function () {
21819 error('sorry,', name, 'is not implemented yet')
21823 }).call(this,_dereq_("buffer").Buffer)
21824 },{"./create-hash":
16,"./create-hmac":
17,"./pbkdf2":
27,"./rng":
28,"buffer":
8}],
20:[function(_dereq_,module,exports){
21826 * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
21827 * Digest Algorithm, as defined in RFC
1321.
21828 * Version
2.1 Copyright (C) Paul Johnston
1999 -
2002.
21829 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
21830 * Distributed under the BSD License
21831 * See http://pajhome.org.uk/crypt/md5 for more info.
21834 var helpers = _dereq_('./helpers');
21837 * Calculate the MD5 of an array of little-endian words, and a bit length
21839 function core_md5(x, len)
21841 /* append padding */
21842 x[len
>> 5] |=
0x80 << ((len) %
32);
21843 x[(((len +
64)
>>> 9) <<
4) +
14] = len;
21845 var a =
1732584193;
21846 var b = -
271733879;
21847 var c = -
1732584194;
21850 for(var i =
0; i < x.length; i +=
16)
21857 a = md5_ff(a, b, c, d, x[i+
0],
7 , -
680876936);
21858 d = md5_ff(d, a, b, c, x[i+
1],
12, -
389564586);
21859 c = md5_ff(c, d, a, b, x[i+
2],
17,
606105819);
21860 b = md5_ff(b, c, d, a, x[i+
3],
22, -
1044525330);
21861 a = md5_ff(a, b, c, d, x[i+
4],
7 , -
176418897);
21862 d = md5_ff(d, a, b, c, x[i+
5],
12,
1200080426);
21863 c = md5_ff(c, d, a, b, x[i+
6],
17, -
1473231341);
21864 b = md5_ff(b, c, d, a, x[i+
7],
22, -
45705983);
21865 a = md5_ff(a, b, c, d, x[i+
8],
7 ,
1770035416);
21866 d = md5_ff(d, a, b, c, x[i+
9],
12, -
1958414417);
21867 c = md5_ff(c, d, a, b, x[i+
10],
17, -
42063);
21868 b = md5_ff(b, c, d, a, x[i+
11],
22, -
1990404162);
21869 a = md5_ff(a, b, c, d, x[i+
12],
7 ,
1804603682);
21870 d = md5_ff(d, a, b, c, x[i+
13],
12, -
40341101);
21871 c = md5_ff(c, d, a, b, x[i+
14],
17, -
1502002290);
21872 b = md5_ff(b, c, d, a, x[i+
15],
22,
1236535329);
21874 a = md5_gg(a, b, c, d, x[i+
1],
5 , -
165796510);
21875 d = md5_gg(d, a, b, c, x[i+
6],
9 , -
1069501632);
21876 c = md5_gg(c, d, a, b, x[i+
11],
14,
643717713);
21877 b = md5_gg(b, c, d, a, x[i+
0],
20, -
373897302);
21878 a = md5_gg(a, b, c, d, x[i+
5],
5 , -
701558691);
21879 d = md5_gg(d, a, b, c, x[i+
10],
9 ,
38016083);
21880 c = md5_gg(c, d, a, b, x[i+
15],
14, -
660478335);
21881 b = md5_gg(b, c, d, a, x[i+
4],
20, -
405537848);
21882 a = md5_gg(a, b, c, d, x[i+
9],
5 ,
568446438);
21883 d = md5_gg(d, a, b, c, x[i+
14],
9 , -
1019803690);
21884 c = md5_gg(c, d, a, b, x[i+
3],
14, -
187363961);
21885 b = md5_gg(b, c, d, a, x[i+
8],
20,
1163531501);
21886 a = md5_gg(a, b, c, d, x[i+
13],
5 , -
1444681467);
21887 d = md5_gg(d, a, b, c, x[i+
2],
9 , -
51403784);
21888 c = md5_gg(c, d, a, b, x[i+
7],
14,
1735328473);
21889 b = md5_gg(b, c, d, a, x[i+
12],
20, -
1926607734);
21891 a = md5_hh(a, b, c, d, x[i+
5],
4 , -
378558);
21892 d = md5_hh(d, a, b, c, x[i+
8],
11, -
2022574463);
21893 c = md5_hh(c, d, a, b, x[i+
11],
16,
1839030562);
21894 b = md5_hh(b, c, d, a, x[i+
14],
23, -
35309556);
21895 a = md5_hh(a, b, c, d, x[i+
1],
4 , -
1530992060);
21896 d = md5_hh(d, a, b, c, x[i+
4],
11,
1272893353);
21897 c = md5_hh(c, d, a, b, x[i+
7],
16, -
155497632);
21898 b = md5_hh(b, c, d, a, x[i+
10],
23, -
1094730640);
21899 a = md5_hh(a, b, c, d, x[i+
13],
4 ,
681279174);
21900 d = md5_hh(d, a, b, c, x[i+
0],
11, -
358537222);
21901 c = md5_hh(c, d, a, b, x[i+
3],
16, -
722521979);
21902 b = md5_hh(b, c, d, a, x[i+
6],
23,
76029189);
21903 a = md5_hh(a, b, c, d, x[i+
9],
4 , -
640364487);
21904 d = md5_hh(d, a, b, c, x[i+
12],
11, -
421815835);
21905 c = md5_hh(c, d, a, b, x[i+
15],
16,
530742520);
21906 b = md5_hh(b, c, d, a, x[i+
2],
23, -
995338651);
21908 a = md5_ii(a, b, c, d, x[i+
0],
6 , -
198630844);
21909 d = md5_ii(d, a, b, c, x[i+
7],
10,
1126891415);
21910 c = md5_ii(c, d, a, b, x[i+
14],
15, -
1416354905);
21911 b = md5_ii(b, c, d, a, x[i+
5],
21, -
57434055);
21912 a = md5_ii(a, b, c, d, x[i+
12],
6 ,
1700485571);
21913 d = md5_ii(d, a, b, c, x[i+
3],
10, -
1894986606);
21914 c = md5_ii(c, d, a, b, x[i+
10],
15, -
1051523);
21915 b = md5_ii(b, c, d, a, x[i+
1],
21, -
2054922799);
21916 a = md5_ii(a, b, c, d, x[i+
8],
6 ,
1873313359);
21917 d = md5_ii(d, a, b, c, x[i+
15],
10, -
30611744);
21918 c = md5_ii(c, d, a, b, x[i+
6],
15, -
1560198380);
21919 b = md5_ii(b, c, d, a, x[i+
13],
21,
1309151649);
21920 a = md5_ii(a, b, c, d, x[i+
4],
6 , -
145523070);
21921 d = md5_ii(d, a, b, c, x[i+
11],
10, -
1120210379);
21922 c = md5_ii(c, d, a, b, x[i+
2],
15,
718787259);
21923 b = md5_ii(b, c, d, a, x[i+
9],
21, -
343485551);
21925 a = safe_add(a, olda);
21926 b = safe_add(b, oldb);
21927 c = safe_add(c, oldc);
21928 d = safe_add(d, oldd);
21930 return Array(a, b, c, d);
21935 * These functions implement the four basic operations the algorithm uses.
21937 function md5_cmn(q, a, b, x, s, t)
21939 return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
21941 function md5_ff(a, b, c, d, x, s, t)
21943 return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
21945 function md5_gg(a, b, c, d, x, s, t)
21947 return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
21949 function md5_hh(a, b, c, d, x, s, t)
21951 return md5_cmn(b ^ c ^ d, a, b, x, s, t);
21953 function md5_ii(a, b, c, d, x, s, t)
21955 return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
21959 * Add integers, wrapping at
2^
32. This uses
16-bit operations internally
21960 * to work around bugs in some JS interpreters.
21962 function safe_add(x, y)
21964 var lsw = (x &
0xFFFF) + (y &
0xFFFF);
21965 var msw = (x
>> 16) + (y
>> 16) + (lsw
>> 16);
21966 return (msw <<
16) | (lsw &
0xFFFF);
21970 * Bitwise rotate a
32-bit number to the left.
21972 function bit_rol(num, cnt)
21974 return (num << cnt) | (num
>>> (
32 - cnt));
21977 module.exports = function md5(buf) {
21978 return helpers.hash(buf, core_md5,
16);
21981 },{"./helpers":
18}],
21:[function(_dereq_,module,exports){
21982 (function (Buffer){
21984 module.exports = ripemd160
21990 code.google.com/p/crypto-js
21991 (c)
2009-
2013 by Jeff Mott. All rights reserved.
21992 code.google.com/p/crypto-js/wiki/License
21995 (c)
2012 by Cédric Mesnil. All rights reserved.
21997 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
21999 - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
22000 - 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.
22002 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.
22007 0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
22008 7,
4,
13,
1,
10,
6,
15,
3,
12,
0,
9,
5,
2,
14,
11,
8,
22009 3,
10,
14,
4,
9,
15,
8,
1,
2,
7,
0,
6,
13,
11,
5,
12,
22010 1,
9,
11,
10,
0,
8,
12,
4,
13,
3,
7,
15,
14,
5,
6,
2,
22011 4,
0,
5,
9,
7,
12,
2,
10,
14,
1,
3,
8,
11,
6,
15,
13];
22013 5,
14,
7,
0,
9,
2,
11,
4,
13,
6,
15,
8,
1,
10,
3,
12,
22014 6,
11,
3,
7,
0,
13,
5,
10,
14,
15,
8,
12,
4,
9,
1,
2,
22015 15,
5,
1,
3,
7,
14,
6,
9,
11,
8,
12,
2,
10,
0,
4,
13,
22016 8,
6,
4,
1,
3,
11,
15,
0,
5,
12,
2,
13,
9,
7,
10,
14,
22017 12,
15,
10,
4,
1,
5,
8,
7,
6,
2,
13,
14,
0,
3,
9,
11];
22019 11,
14,
15,
12,
5,
8,
7,
9,
11,
13,
14,
15,
6,
7,
9,
8,
22020 7,
6,
8,
13,
11,
9,
7,
15,
7,
12,
15,
9,
11,
7,
13,
12,
22021 11,
13,
6,
7,
14,
9,
13,
15,
14,
8,
13,
6,
5,
12,
7,
5,
22022 11,
12,
14,
15,
14,
15,
9,
8,
9,
14,
5,
6,
8,
6,
5,
12,
22023 9,
15,
5,
11,
6,
8,
13,
12,
5,
12,
13,
14,
11,
8,
5,
6 ];
22025 8,
9,
9,
11,
13,
15,
15,
5,
7,
7,
8,
11,
14,
14,
12,
6,
22026 9,
13,
15,
7,
12,
8,
9,
11,
7,
7,
12,
7,
6,
15,
13,
11,
22027 9,
7,
15,
11,
8,
6,
6,
14,
12,
13,
5,
14,
13,
13,
7,
5,
22028 15,
5,
8,
11,
14,
14,
6,
14,
6,
9,
12,
9,
12,
5,
15,
8,
22029 8,
5,
12,
9,
12,
5,
14,
6,
8,
13,
6,
5,
15,
13,
11,
11 ];
22031 var hl = [
0x00000000,
0x5A827999,
0x6ED9EBA1,
0x8F1BBCDC,
0xA953FD4E];
22032 var hr = [
0x50A28BE6,
0x5C4DD124,
0x6D703EF3,
0x7A6D76E9,
0x00000000];
22034 var bytesToWords = function (bytes) {
22036 for (var i =
0, b =
0; i < bytes.length; i++, b +=
8) {
22037 words[b
>>> 5] |= bytes[i] << (
24 - b %
32);
22042 var wordsToBytes = function (words) {
22044 for (var b =
0; b < words.length *
32; b +=
8) {
22045 bytes.push((words[b
>>> 5]
>>> (
24 - b %
32)) &
0xFF);
22050 var processBlock = function (H, M, offset) {
22053 for (var i =
0; i <
16; i++) {
22054 var offset_i = offset + i;
22055 var M_offset_i = M[offset_i];
22059 (((M_offset_i <<
8) | (M_offset_i
>>> 24)) &
0x00ff00ff) |
22060 (((M_offset_i <<
24) | (M_offset_i
>>> 8)) &
0xff00ff00)
22064 // Working variables
22065 var al, bl, cl, dl, el;
22066 var ar, br, cr, dr, er;
22075 for (var i =
0; i <
80; i +=
1) {
22076 t = (al + M[offset+zl[i]])|
0;
22078 t += f1(bl,cl,dl) + hl[
0];
22080 t += f2(bl,cl,dl) + hl[
1];
22082 t += f3(bl,cl,dl) + hl[
2];
22084 t += f4(bl,cl,dl) + hl[
3];
22085 } else {// if (i
<80) {
22086 t += f5(bl,cl,dl) + hl[
4];
22097 t = (ar + M[offset+zr[i]])|
0;
22099 t += f5(br,cr,dr) + hr[
0];
22101 t += f4(br,cr,dr) + hr[
1];
22103 t += f3(br,cr,dr) + hr[
2];
22105 t += f2(br,cr,dr) + hr[
3];
22106 } else {// if (i
<80) {
22107 t += f1(br,cr,dr) + hr[
4];
22110 t = rotl(t,sr[i]) ;
22118 // Intermediate hash value
22119 t = (H[
1] + cl + dr)|
0;
22120 H[
1] = (H[
2] + dl + er)|
0;
22121 H[
2] = (H[
3] + el + ar)|
0;
22122 H[
3] = (H[
4] + al + br)|
0;
22123 H[
4] = (H[
0] + bl + cr)|
0;
22127 function f1(x, y, z) {
22128 return ((x) ^ (y) ^ (z));
22131 function f2(x, y, z) {
22132 return (((x)&(y)) | ((~x)&(z)));
22135 function f3(x, y, z) {
22136 return (((x) | (~(y))) ^ (z));
22139 function f4(x, y, z) {
22140 return (((x) & (z)) | ((y)&(~(z))));
22143 function f5(x, y, z) {
22144 return ((x) ^ ((y) |(~(z))));
22147 function rotl(x,n) {
22148 return (x<
<n) | (x
>>>(
32-n));
22151 function ripemd160(message) {
22152 var H = [
0x67452301,
0xEFCDAB89,
0x98BADCFE,
0x10325476,
0xC3D2E1F0];
22154 if (typeof message == 'string')
22155 message = new Buffer(message, 'utf8');
22157 var m = bytesToWords(message);
22159 var nBitsLeft = message.length *
8;
22160 var nBitsTotal = message.length *
8;
22163 m[nBitsLeft
>>> 5] |=
0x80 << (
24 - nBitsLeft %
32);
22164 m[(((nBitsLeft +
64)
>>> 9) <<
4) +
14] = (
22165 (((nBitsTotal <<
8) | (nBitsTotal
>>> 24)) &
0x00ff00ff) |
22166 (((nBitsTotal <<
24) | (nBitsTotal
>>> 8)) &
0xff00ff00)
22169 for (var i=
0 ; i
<m.length; i +=
16) {
22170 processBlock(H, m, i);
22174 for (var i =
0; i <
5; i++) {
22179 H[i] = (((H_i <<
8) | (H_i
>>> 24)) &
0x00ff00ff) |
22180 (((H_i <<
24) | (H_i
>>> 8)) &
0xff00ff00);
22183 var digestbytes = wordsToBytes(H);
22184 return new Buffer(digestbytes);
22189 }).call(this,_dereq_(
"buffer").Buffer)
22190 },{
"buffer":
8}],
22:[function(_dereq_,module,exports){
22191 var u = _dereq_('./util')
22192 var write = u.write
22193 var fill = u.zeroFill
22195 module.exports = function (Buffer) {
22197 //prototype class for hash functions
22198 function Hash (blockSize, finalSize) {
22199 this._block = new Buffer(blockSize) //new Uint32Array(blockSize/
4)
22200 this._finalSize = finalSize
22201 this._blockSize = blockSize
22206 Hash.prototype.init = function () {
22211 function lengthOf(data, enc) {
22212 if(enc == null) return data.byteLength || data.length
22213 if(enc == 'ascii' || enc == 'binary') return data.length
22214 if(enc == 'hex') return data.length/
2
22215 if(enc == 'base64') return data.length/
3
22218 Hash.prototype.update = function (data, enc) {
22219 var bl = this._blockSize
22221 //I'd rather do this with a streaming encoder, like the opposite of
22222 //http://nodejs.org/api/string_decoder.html
22224 if(!enc && 'string' === typeof data)
22228 if(enc === 'utf-
8')
22231 if(enc === 'base64' || enc === 'utf8')
22232 data = new Buffer(data, enc), enc = null
22234 length = lengthOf(data, enc)
22236 length = data.byteLength || data.length
22238 var l = this._len += length
22239 var s = this._s = (this._s ||
0)
22241 var buffer = this._block
22243 var t = Math.min(length, f + bl)
22244 write(buffer, data, enc, s%bl, f, t)
22249 this._update(buffer)
22257 Hash.prototype.digest = function (enc) {
22258 var bl = this._blockSize
22259 var fl = this._finalSize
22260 var len = this._len*
8
22262 var x = this._block
22264 var bits = len % (bl*
8)
22266 //add end marker, so that appending
0's creats a different hash.
22267 x[this._len % bl] =
0x80
22268 fill(this._block, this._len % bl +
1)
22271 this._update(this._block)
22272 u.zeroFill(this._block,
0)
22275 //TODO: handle case where the bit length is
> Math.pow(
2,
29)
22276 x.writeInt32BE(len, fl +
4) //big endian
22278 var hash = this._update(this._block) || this._hash()
22279 if(enc == null) return hash
22280 return hash.toString(enc)
22283 Hash.prototype._update = function () {
22284 throw new Error('_update must be implemented by subclass')
22290 },{"./util":
26}],
23:[function(_dereq_,module,exports){
22291 var exports = module.exports = function (alg) {
22292 var Alg = exports[alg]
22293 if(!Alg) throw new Error(alg + ' is not supported (we accept pull requests)')
22297 var Buffer = _dereq_('buffer').Buffer
22298 var Hash = _dereq_('./hash')(Buffer)
22301 exports.sha1 = _dereq_('./sha1')(Buffer, Hash)
22302 exports.sha256 = _dereq_('./sha256')(Buffer, Hash)
22304 },{"./hash":
22,"./sha1":
24,"./sha256":
25,"buffer":
8}],
24:[function(_dereq_,module,exports){
22306 * A JavaScript implementation of the Secure Hash Algorithm, SHA-
1, as defined
22307 * in FIPS PUB
180-
1
22308 * Version
2.1a Copyright Paul Johnston
2000 -
2002.
22309 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
22310 * Distributed under the BSD License
22311 * See http://pajhome.org.uk/crypt/md5 for details.
22313 module.exports = function (Buffer, Hash) {
22315 var inherits = _dereq_('util').inherits
22317 inherits(Sha1, Hash)
22328 var W = new Int32Array(
80)
22334 return POOL.pop().init()
22336 if(!(this instanceof Sha1)) return new Sha1()
22338 Hash.call(this,
16*
4,
14*
4)
22344 Sha1.prototype.init = function () {
22345 this._a =
0x67452301
22346 this._b =
0xefcdab89
22347 this._c =
0x98badcfe
22348 this._d =
0x10325476
22349 this._e =
0xc3d2e1f0
22351 Hash.prototype.init.call(this)
22355 Sha1.prototype._POOL = POOL
22357 // assume that array is a Uint32Array with length=
16,
22358 // and that if it is the last block, it already has the length and the
1 bit appended.
22361 var isDV = new Buffer(
1) instanceof DataView
22362 function readInt32BE (X, i) {
22364 ? X.getInt32(i, false)
22368 Sha1.prototype._update = function (array) {
22370 var X = this._block
22372 var a, b, c, d, e, _a, _b, _c, _d, _e
22382 for(var j =
0; j <
80; j++) {
22385 //? X.getInt32(j*
4, false)
22386 //? readInt32BE(X, j*
4) //*/ X.readInt32BE(j*
4) //*/
22387 ? X.readInt32BE(j*
4)
22388 : rol(w[j -
3] ^ w[j -
8] ^ w[j -
14] ^ w[j -
16],
1)
22392 add(rol(a,
5), sha1_ft(j, b, c, d)),
22393 add(add(e, W), sha1_kt(j))
22403 this._a = add(a, _a)
22404 this._b = add(b, _b)
22405 this._c = add(c, _c)
22406 this._d = add(d, _d)
22407 this._e = add(e, _e)
22410 Sha1.prototype._hash = function () {
22411 if(POOL.length <
100) POOL.push(this)
22412 var H = new Buffer(
20)
22413 //console.log(this._a|
0, this._b|
0, this._c|
0, this._d|
0, this._e|
0)
22414 H.writeInt32BE(this._a|
0, A)
22415 H.writeInt32BE(this._b|
0, B)
22416 H.writeInt32BE(this._c|
0, C)
22417 H.writeInt32BE(this._d|
0, D)
22418 H.writeInt32BE(this._e|
0, E)
22423 * Perform the appropriate triplet combination function for the current
22426 function sha1_ft(t, b, c, d) {
22427 if(t <
20) return (b & c) | ((~b) & d);
22428 if(t <
40) return b ^ c ^ d;
22429 if(t <
60) return (b & c) | (b & d) | (c & d);
22434 * Determine the appropriate additive constant for the current iteration
22436 function sha1_kt(t) {
22437 return (t <
20) ?
1518500249 : (t <
40) ?
1859775393 :
22438 (t <
60) ? -
1894007588 : -
899497514;
22442 * Add integers, wrapping at
2^
32. This uses
16-bit operations internally
22443 * to work around bugs in some JS interpreters.
22444 * //dominictarr: this is
10 years old, so maybe this can be dropped?)
22447 function add(x, y) {
22448 return (x + y ) |
0
22449 //lets see how this goes on testling.
22450 // var lsw = (x &
0xFFFF) + (y &
0xFFFF);
22451 // var msw = (x
>> 16) + (y
>> 16) + (lsw
>> 16);
22452 // return (msw <<
16) | (lsw &
0xFFFF);
22456 * Bitwise rotate a
32-bit number to the left.
22458 function rol(num, cnt) {
22459 return (num << cnt) | (num
>>> (
32 - cnt));
22465 },{"util":
14}],
25:[function(_dereq_,module,exports){
22468 * A JavaScript implementation of the Secure Hash Algorithm, SHA-
256, as defined
22470 * Version
2.2-beta Copyright Angel Marin, Paul Johnston
2000 -
2009.
22471 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
22475 var inherits = _dereq_('util').inherits
22478 var u = _dereq_('./util')
22480 module.exports = function (Buffer, Hash) {
22483 0x428A2F98,
0x71374491,
0xB5C0FBCF,
0xE9B5DBA5,
22484 0x3956C25B,
0x59F111F1,
0x923F82A4,
0xAB1C5ED5,
22485 0xD807AA98,
0x12835B01,
0x243185BE,
0x550C7DC3,
22486 0x72BE5D74,
0x80DEB1FE,
0x9BDC06A7,
0xC19BF174,
22487 0xE49B69C1,
0xEFBE4786,
0x0FC19DC6,
0x240CA1CC,
22488 0x2DE92C6F,
0x4A7484AA,
0x5CB0A9DC,
0x76F988DA,
22489 0x983E5152,
0xA831C66D,
0xB00327C8,
0xBF597FC7,
22490 0xC6E00BF3,
0xD5A79147,
0x06CA6351,
0x14292967,
22491 0x27B70A85,
0x2E1B2138,
0x4D2C6DFC,
0x53380D13,
22492 0x650A7354,
0x766A0ABB,
0x81C2C92E,
0x92722C85,
22493 0xA2BFE8A1,
0xA81A664B,
0xC24B8B70,
0xC76C51A3,
22494 0xD192E819,
0xD6990624,
0xF40E3585,
0x106AA070,
22495 0x19A4C116,
0x1E376C08,
0x2748774C,
0x34B0BCB5,
22496 0x391C0CB3,
0x4ED8AA4A,
0x5B9CCA4F,
0x682E6FF3,
22497 0x748F82EE,
0x78A5636F,
0x84C87814,
0x8CC70208,
22498 0x90BEFFFA,
0xA4506CEB,
0xBEF9A3F7,
0xC67178F2
22501 inherits(Sha256, Hash)
22502 var W = new Array(
64)
22504 function Sha256() {
22505 // Closure compiler warning - this code lacks side effects - thus commented out
22506 // if(POOL.length) {
22507 // return POOL.shift().init()
22509 //this._data = new Buffer(
32)
22513 this._w = W //new Array(
64)
22515 Hash.call(this,
16*
4,
14*
4)
22518 Sha256.prototype.init = function () {
22520 this._a =
0x6a09e667|
0
22521 this._b =
0xbb67ae85|
0
22522 this._c =
0x3c6ef372|
0
22523 this._d =
0xa54ff53a|
0
22524 this._e =
0x510e527f|
0
22525 this._f =
0x9b05688c|
0
22526 this._g =
0x1f83d9ab|
0
22527 this._h =
0x5be0cd19|
0
22529 this._len = this._s =
0
22534 var safe_add = function(x, y) {
22535 var lsw = (x &
0xFFFF) + (y &
0xFFFF);
22536 var msw = (x
>> 16) + (y
>> 16) + (lsw
>> 16);
22537 return (msw <<
16) | (lsw &
0xFFFF);
22540 function S (X, n) {
22541 return (X
>>> n) | (X << (
32 - n));
22544 function R (X, n) {
22548 function Ch (x, y, z) {
22549 return ((x & y) ^ ((~x) & z));
22552 function Maj (x, y, z) {
22553 return ((x & y) ^ (x & z) ^ (y & z));
22556 function Sigma0256 (x) {
22557 return (S(x,
2) ^ S(x,
13) ^ S(x,
22));
22560 function Sigma1256 (x) {
22561 return (S(x,
6) ^ S(x,
11) ^ S(x,
25));
22564 function Gamma0256 (x) {
22565 return (S(x,
7) ^ S(x,
18) ^ R(x,
3));
22568 function Gamma1256 (x) {
22569 return (S(x,
17) ^ S(x,
19) ^ R(x,
10));
22572 Sha256.prototype._update = function(m) {
22573 var M = this._block
22575 var a, b, c, d, e, f, g, h
22587 for (var j =
0; j <
64; j++) {
22588 var w = W[j] = j <
16
22589 ? M.readInt32BE(j *
4)
22590 : Gamma1256(W[j -
2]) + W[j -
7] + Gamma0256(W[j -
15]) + W[j -
16]
22592 T1 = h + Sigma1256(e) + Ch(e, f, g) + K[j] + w
22594 T2 = Sigma0256(a) + Maj(a, b, c);
22595 h = g; g = f; f = e; e = d + T1; d = c; c = b; b = a; a = T1 + T2;
22598 this._a = (a + this._a) |
0
22599 this._b = (b + this._b) |
0
22600 this._c = (c + this._c) |
0
22601 this._d = (d + this._d) |
0
22602 this._e = (e + this._e) |
0
22603 this._f = (f + this._f) |
0
22604 this._g = (g + this._g) |
0
22605 this._h = (h + this._h) |
0
22609 Sha256.prototype._hash = function () {
22610 if(POOL.length <
10)
22613 var H = new Buffer(
32)
22615 H.writeInt32BE(this._a,
0)
22616 H.writeInt32BE(this._b,
4)
22617 H.writeInt32BE(this._c,
8)
22618 H.writeInt32BE(this._d,
12)
22619 H.writeInt32BE(this._e,
16)
22620 H.writeInt32BE(this._f,
20)
22621 H.writeInt32BE(this._g,
24)
22622 H.writeInt32BE(this._h,
28)
22631 },{"./util":
26,"util":
14}],
26:[function(_dereq_,module,exports){
22632 exports.write = write
22633 exports.zeroFill = zeroFill
22635 exports.toString = toString
22637 function write (buffer, string, enc, start, from, to, LE) {
22638 var l = (to - from)
22639 if(enc === 'ascii' || enc === 'binary') {
22640 for( var i =
0; i < l; i++) {
22641 buffer[start + i] = string.charCodeAt(i + from)
22644 else if(enc == null) {
22645 for( var i =
0; i < l; i++) {
22646 buffer[start + i] = string[i + from]
22649 else if(enc === 'hex') {
22650 for(var i =
0; i < l; i++) {
22652 buffer[start + i] = parseInt(string[j*
2] + string[(j*
2)+
1],
16)
22655 else if(enc === 'base64') {
22656 throw new Error('base64 encoding not yet supported')
22659 throw new Error(enc +' encoding not yet supported')
22662 //always fill to the end!
22663 function zeroFill(buf, from) {
22664 for(var i = from; i < buf.length; i++)
22669 },{}],
27:[function(_dereq_,module,exports){
22670 (function (Buffer){
22671 // JavaScript PBKDF2 Implementation
22672 // Based on http://git.io/qsv2zw
22673 // Licensed under LGPL v3
22674 // Copyright (c)
2013 jduncanator
22677 var zeroBuffer = new Buffer(blocksize); zeroBuffer.fill(
0)
22679 module.exports = function (createHmac, exports) {
22680 exports = exports || {}
22682 exports.pbkdf2 = function(password, salt, iterations, keylen, cb) {
22683 if('function' !== typeof cb)
22684 throw new Error('No callback provided to pbkdf2');
22685 setTimeout(function () {
22686 cb(null, exports.pbkdf2Sync(password, salt, iterations, keylen))
22690 exports.pbkdf2Sync = function(key, salt, iterations, keylen) {
22691 if('number' !== typeof iterations)
22692 throw new TypeError('Iterations not a number')
22694 throw new TypeError('Bad iterations')
22695 if('number' !== typeof keylen)
22696 throw new TypeError('Key length not a number')
22698 throw new TypeError('Bad key length')
22700 //stretch key to the correct length that hmac wants it,
22701 //otherwise this will happen every time hmac is called
22702 //twice per iteration.
22703 var key = !Buffer.isBuffer(key) ? new Buffer(key) : key
22705 if(key.length
> blocksize) {
22706 key = createHash(alg).update(key).digest()
22707 } else if(key.length < blocksize) {
22708 key = Buffer.concat([key, zeroBuffer], blocksize)
22712 var cplen, p =
0, i =
1, itmp = new Buffer(
4), digtmp;
22713 var out = new Buffer(keylen);
22721 /* We are unlikely to ever use more than
256 blocks (
5120 bits!)
22722 * but just in case...
22724 itmp[
0] = (i
>> 24) &
0xff;
22725 itmp[
1] = (i
>> 16) &
0xff;
22726 itmp[
2] = (i
>> 8) &
0xff;
22727 itmp[
3] = i &
0xff;
22729 HMAC = createHmac('sha1', key);
22732 digtmp = HMAC.digest();
22733 digtmp.copy(out, p,
0, cplen);
22735 for(var j =
1; j < iterations; j++) {
22736 HMAC = createHmac('sha1', key);
22737 HMAC.update(digtmp);
22738 digtmp = HMAC.digest();
22739 for(var k =
0; k < cplen; k++) {
22740 out[k] ^= digtmp[k];
22754 }).call(this,_dereq_(
"buffer").Buffer)
22755 },{
"buffer":
8}],
28:[function(_dereq_,module,exports){
22756 (function (Buffer){
22757 // Original code adapted from Robert Kieffer.
22758 // details at https://github.com/broofa/node-uuid
22762 var _global = this;
22764 var mathRNG, whatwgRNG;
22766 // NOTE: Math.random() does not guarantee
"cryptographic quality"
22767 mathRNG = function(size) {
22768 var bytes = new Buffer(size);
22771 for (var i =
0, r; i < size; i++) {
22772 if ((i &
0x03) ==
0) r = Math.random() *
0x100000000;
22773 bytes[i] = r
>>> ((i &
0x03) <<
3) &
0xff;
22779 if (_global.crypto && crypto.getRandomValues) {
22780 whatwgRNG = function(size) {
22781 var bytes = new Buffer(size); //in browserify, this is an extended Uint8Array
22782 crypto.getRandomValues(bytes);
22787 module.exports = whatwgRNG || mathRNG;
22791 }).call(this,_dereq_("buffer").Buffer)
22792 },{"buffer":
8}],
29:[function(_dereq_,module,exports){
22793 ;(function (root, factory, undef) {
22794 if (typeof exports === "object") {
22796 module.exports = exports = factory(_dereq_("./core"), _dereq_("./enc-base64"), _dereq_("./md5"), _dereq_("./evpkdf"), _dereq_("./cipher-core"));
22798 else if (typeof define === "function" && define.amd) {
22800 define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
22803 // Global (browser)
22804 factory(root.CryptoJS);
22806 }(this, function (CryptoJS) {
22812 var BlockCipher = C_lib.BlockCipher;
22813 var C_algo = C.algo;
22818 var SUB_MIX_0 = [];
22819 var SUB_MIX_1 = [];
22820 var SUB_MIX_2 = [];
22821 var SUB_MIX_3 = [];
22822 var INV_SUB_MIX_0 = [];
22823 var INV_SUB_MIX_1 = [];
22824 var INV_SUB_MIX_2 = [];
22825 var INV_SUB_MIX_3 = [];
22827 // Compute lookup tables
22829 // Compute double table
22831 for (var i =
0; i <
256; i++) {
22835 d[i] = (i <<
1) ^
0x11b;
22842 for (var i =
0; i <
256; i++) {
22844 var sx = xi ^ (xi <<
1) ^ (xi <<
2) ^ (xi <<
3) ^ (xi <<
4);
22845 sx = (sx
>>> 8) ^ (sx &
0xff) ^
0x63;
22849 // Compute multiplication
22854 // Compute sub bytes, mix columns tables
22855 var t = (d[sx] *
0x101) ^ (sx *
0x1010100);
22856 SUB_MIX_0[x] = (t <<
24) | (t
>>> 8);
22857 SUB_MIX_1[x] = (t <<
16) | (t
>>> 16);
22858 SUB_MIX_2[x] = (t <<
8) | (t
>>> 24);
22861 // Compute inv sub bytes, inv mix columns tables
22862 var t = (x8 *
0x1010101) ^ (x4 *
0x10001) ^ (x2 *
0x101) ^ (x *
0x1010100);
22863 INV_SUB_MIX_0[sx] = (t <<
24) | (t
>>> 8);
22864 INV_SUB_MIX_1[sx] = (t <<
16) | (t
>>> 16);
22865 INV_SUB_MIX_2[sx] = (t <<
8) | (t
>>> 24);
22866 INV_SUB_MIX_3[sx] = t;
22868 // Compute next counter
22872 x = x2 ^ d[d[d[x8 ^ x2]]];
22878 // Precomputed Rcon lookup
22879 var RCON = [
0x00,
0x01,
0x02,
0x04,
0x08,
0x10,
0x20,
0x40,
0x80,
0x1b,
0x36];
22882 * AES block cipher algorithm.
22884 var AES = C_algo.AES = BlockCipher.extend({
22885 _doReset: function () {
22887 var key = this._key;
22888 var keyWords = key.words;
22889 var keySize = key.sigBytes /
4;
22891 // Compute number of rounds
22892 var nRounds = this._nRounds = keySize +
6
22894 // Compute number of key schedule rows
22895 var ksRows = (nRounds +
1) *
4;
22897 // Compute key schedule
22898 var keySchedule = this._keySchedule = [];
22899 for (var ksRow =
0; ksRow < ksRows; ksRow++) {
22900 if (ksRow < keySize) {
22901 keySchedule[ksRow] = keyWords[ksRow];
22903 var t = keySchedule[ksRow -
1];
22905 if (!(ksRow % keySize)) {
22907 t = (t <<
8) | (t
>>> 24);
22910 t = (SBOX[t
>>> 24] <<
24) | (SBOX[(t
>>> 16) &
0xff] <<
16) | (SBOX[(t
>>> 8) &
0xff] <<
8) | SBOX[t &
0xff];
22913 t ^= RCON[(ksRow / keySize) |
0] <<
24;
22914 } else if (keySize
> 6 && ksRow % keySize ==
4) {
22916 t = (SBOX[t
>>> 24] <<
24) | (SBOX[(t
>>> 16) &
0xff] <<
16) | (SBOX[(t
>>> 8) &
0xff] <<
8) | SBOX[t &
0xff];
22919 keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t;
22923 // Compute inv key schedule
22924 var invKeySchedule = this._invKeySchedule = [];
22925 for (var invKsRow =
0; invKsRow < ksRows; invKsRow++) {
22926 var ksRow = ksRows - invKsRow;
22928 if (invKsRow %
4) {
22929 var t = keySchedule[ksRow];
22931 var t = keySchedule[ksRow -
4];
22934 if (invKsRow <
4 || ksRow <=
4) {
22935 invKeySchedule[invKsRow] = t;
22937 invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t
>>> 24]] ^ INV_SUB_MIX_1[SBOX[(t
>>> 16) &
0xff]] ^
22938 INV_SUB_MIX_2[SBOX[(t
>>> 8) &
0xff]] ^ INV_SUB_MIX_3[SBOX[t &
0xff]];
22943 encryptBlock: function (M, offset) {
22944 this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX);
22947 decryptBlock: function (M, offset) {
22948 // Swap
2nd and
4th rows
22949 var t = M[offset +
1];
22950 M[offset +
1] = M[offset +
3];
22953 this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX);
22955 // Inv swap
2nd and
4th rows
22956 var t = M[offset +
1];
22957 M[offset +
1] = M[offset +
3];
22961 _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) {
22963 var nRounds = this._nRounds;
22965 // Get input, add round key
22966 var s0 = M[offset] ^ keySchedule[
0];
22967 var s1 = M[offset +
1] ^ keySchedule[
1];
22968 var s2 = M[offset +
2] ^ keySchedule[
2];
22969 var s3 = M[offset +
3] ^ keySchedule[
3];
22971 // Key schedule row counter
22975 for (var round =
1; round < nRounds; round++) {
22976 // Shift rows, sub bytes, mix columns, add round key
22977 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++];
22978 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++];
22979 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++];
22980 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++];
22989 // Shift rows, sub bytes, add round key
22990 var t0 = ((SBOX[s0
>>> 24] <<
24) | (SBOX[(s1
>>> 16) &
0xff] <<
16) | (SBOX[(s2
>>> 8) &
0xff] <<
8) | SBOX[s3 &
0xff]) ^ keySchedule[ksRow++];
22991 var t1 = ((SBOX[s1
>>> 24] <<
24) | (SBOX[(s2
>>> 16) &
0xff] <<
16) | (SBOX[(s3
>>> 8) &
0xff] <<
8) | SBOX[s0 &
0xff]) ^ keySchedule[ksRow++];
22992 var t2 = ((SBOX[s2
>>> 24] <<
24) | (SBOX[(s3
>>> 16) &
0xff] <<
16) | (SBOX[(s0
>>> 8) &
0xff] <<
8) | SBOX[s1 &
0xff]) ^ keySchedule[ksRow++];
22993 var t3 = ((SBOX[s3
>>> 24] <<
24) | (SBOX[(s0
>>> 16) &
0xff] <<
16) | (SBOX[(s1
>>> 8) &
0xff] <<
8) | SBOX[s2 &
0xff]) ^ keySchedule[ksRow++];
22997 M[offset +
1] = t1;
22998 M[offset +
2] = t2;
22999 M[offset +
3] = t3;
23006 * Shortcut functions to the cipher's object interface.
23010 * var ciphertext = CryptoJS.AES.encrypt(message, key, cfg);
23011 * var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg);
23013 C.AES = BlockCipher._createHelper(AES);
23017 return CryptoJS.AES;
23020 },{
"./cipher-core":
30,
"./core":
31,
"./enc-base64":
32,
"./evpkdf":
34,
"./md5":
39}],
30:[function(_dereq_,module,exports){
23021 ;(function (root, factory) {
23022 if (typeof exports ===
"object") {
23024 module.exports = exports = factory(_dereq_(
"./core"));
23026 else if (typeof define ===
"function" && define.amd) {
23028 define([
"./core"], factory);
23031 // Global (browser)
23032 factory(root.CryptoJS);
23034 }(this, function (CryptoJS) {
23037 * Cipher core components.
23039 CryptoJS.lib.Cipher || (function (undefined) {
23043 var Base = C_lib.Base;
23044 var WordArray = C_lib.WordArray;
23045 var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm;
23047 var Utf8 = C_enc.Utf8;
23048 var Base64 = C_enc.Base64;
23049 var C_algo = C.algo;
23050 var EvpKDF = C_algo.EvpKDF;
23053 * Abstract base cipher template.
23055 * @property {number} keySize This cipher's key size. Default:
4 (
128 bits)
23056 * @property {number} ivSize This cipher's IV size. Default:
4 (
128 bits)
23057 * @property {number} _ENC_XFORM_MODE A constant representing encryption mode.
23058 * @property {number} _DEC_XFORM_MODE A constant representing decryption mode.
23060 var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({
23062 * Configuration options.
23064 * @property {WordArray} iv The IV to use for this operation.
23066 cfg: Base.extend(),
23069 * Creates this cipher in encryption mode.
23071 * @param {WordArray} key The key.
23072 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23074 * @return {Cipher} A cipher instance.
23080 * var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray });
23082 createEncryptor: function (key, cfg) {
23083 return this.create(this._ENC_XFORM_MODE, key, cfg);
23087 * Creates this cipher in decryption mode.
23089 * @param {WordArray} key The key.
23090 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23092 * @return {Cipher} A cipher instance.
23098 * var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray });
23100 createDecryptor: function (key, cfg) {
23101 return this.create(this._DEC_XFORM_MODE, key, cfg);
23105 * Initializes a newly created cipher.
23107 * @param {number} xformMode Either the encryption or decryption transormation mode constant.
23108 * @param {WordArray} key The key.
23109 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23113 * var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray });
23115 init: function (xformMode, key, cfg) {
23116 // Apply config defaults
23117 this.cfg = this.cfg.extend(cfg);
23119 // Store transform mode and key
23120 this._xformMode = xformMode;
23123 // Set initial values
23128 * Resets this cipher to its initial state.
23134 reset: function () {
23135 // Reset data buffer
23136 BufferedBlockAlgorithm.reset.call(this);
23138 // Perform concrete-cipher logic
23143 * Adds data to be encrypted or decrypted.
23145 * @param {WordArray|string} dataUpdate The data to encrypt or decrypt.
23147 * @return {WordArray} The data after processing.
23151 * var encrypted = cipher.process('data');
23152 * var encrypted = cipher.process(wordArray);
23154 process: function (dataUpdate) {
23156 this._append(dataUpdate);
23158 // Process available blocks
23159 return this._process();
23163 * Finalizes the encryption or decryption process.
23164 * Note that the finalize operation is effectively a destructive, read-once operation.
23166 * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt.
23168 * @return {WordArray} The data after final processing.
23172 * var encrypted = cipher.finalize();
23173 * var encrypted = cipher.finalize('data');
23174 * var encrypted = cipher.finalize(wordArray);
23176 finalize: function (dataUpdate) {
23177 // Final data update
23179 this._append(dataUpdate);
23182 // Perform concrete-cipher logic
23183 var finalProcessedData = this._doFinalize();
23185 return finalProcessedData;
23192 _ENC_XFORM_MODE:
1,
23194 _DEC_XFORM_MODE:
2,
23197 * Creates shortcut functions to a cipher's object interface.
23199 * @param {Cipher} cipher The cipher to create a helper for.
23201 * @return {Object} An object with encrypt and decrypt shortcut functions.
23207 * var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES);
23209 _createHelper: (function () {
23210 function selectCipherStrategy(key) {
23211 if (typeof key == 'string') {
23212 return PasswordBasedCipher;
23214 return SerializableCipher;
23218 return function (cipher) {
23220 encrypt: function (message, key, cfg) {
23221 return selectCipherStrategy(key).encrypt(cipher, message, key, cfg);
23224 decrypt: function (ciphertext, key, cfg) {
23225 return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg);
23233 * Abstract base stream cipher template.
23235 * @property {number} blockSize The number of
32-bit words this cipher operates on. Default:
1 (
32 bits)
23237 var StreamCipher = C_lib.StreamCipher = Cipher.extend({
23238 _doFinalize: function () {
23239 // Process partial blocks
23240 var finalProcessedBlocks = this._process(!!'flush');
23242 return finalProcessedBlocks;
23251 var C_mode = C.mode = {};
23254 * Abstract base block cipher mode template.
23256 var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({
23258 * Creates this mode for encryption.
23260 * @param {Cipher} cipher A block cipher instance.
23261 * @param {Array} iv The IV words.
23267 * var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words);
23269 createEncryptor: function (cipher, iv) {
23270 return this.Encryptor.create(cipher, iv);
23274 * Creates this mode for decryption.
23276 * @param {Cipher} cipher A block cipher instance.
23277 * @param {Array} iv The IV words.
23283 * var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words);
23285 createDecryptor: function (cipher, iv) {
23286 return this.Decryptor.create(cipher, iv);
23290 * Initializes a newly created mode.
23292 * @param {Cipher} cipher A block cipher instance.
23293 * @param {Array} iv The IV words.
23297 * var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words);
23299 init: function (cipher, iv) {
23300 this._cipher = cipher;
23306 * Cipher Block Chaining mode.
23308 var CBC = C_mode.CBC = (function () {
23310 * Abstract base CBC mode.
23312 var CBC = BlockCipherMode.extend();
23317 CBC.Encryptor = CBC.extend({
23319 * Processes the data block at offset.
23321 * @param {Array} words The data words to operate on.
23322 * @param {number} offset The offset where the block starts.
23326 * mode.processBlock(data.words, offset);
23328 processBlock: function (words, offset) {
23330 var cipher = this._cipher;
23331 var blockSize = cipher.blockSize;
23334 xorBlock.call(this, words, offset, blockSize);
23335 cipher.encryptBlock(words, offset);
23337 // Remember this block to use with next block
23338 this._prevBlock = words.slice(offset, offset + blockSize);
23345 CBC.Decryptor = CBC.extend({
23347 * Processes the data block at offset.
23349 * @param {Array} words The data words to operate on.
23350 * @param {number} offset The offset where the block starts.
23354 * mode.processBlock(data.words, offset);
23356 processBlock: function (words, offset) {
23358 var cipher = this._cipher;
23359 var blockSize = cipher.blockSize;
23361 // Remember this block to use with next block
23362 var thisBlock = words.slice(offset, offset + blockSize);
23365 cipher.decryptBlock(words, offset);
23366 xorBlock.call(this, words, offset, blockSize);
23368 // This block becomes the previous block
23369 this._prevBlock = thisBlock;
23373 function xorBlock(words, offset, blockSize) {
23377 // Choose mixing block
23381 // Remove IV for subsequent blocks
23382 this._iv = undefined;
23384 var block = this._prevBlock;
23388 for (var i =
0; i < blockSize; i++) {
23389 words[offset + i] ^= block[i];
23397 * Padding namespace.
23399 var C_pad = C.pad = {};
23402 * PKCS #
5/
7 padding strategy.
23404 var Pkcs7 = C_pad.Pkcs7 = {
23406 * Pads data using the algorithm defined in PKCS #
5/
7.
23408 * @param {WordArray} data The data to pad.
23409 * @param {number} blockSize The multiple that the data should be padded to.
23415 * CryptoJS.pad.Pkcs7.pad(wordArray,
4);
23417 pad: function (data, blockSize) {
23419 var blockSizeBytes = blockSize *
4;
23421 // Count padding bytes
23422 var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
23424 // Create padding word
23425 var paddingWord = (nPaddingBytes <<
24) | (nPaddingBytes <<
16) | (nPaddingBytes <<
8) | nPaddingBytes;
23428 var paddingWords = [];
23429 for (var i =
0; i < nPaddingBytes; i +=
4) {
23430 paddingWords.push(paddingWord);
23432 var padding = WordArray.create(paddingWords, nPaddingBytes);
23435 data.concat(padding);
23439 * Unpads data that had been padded using the algorithm defined in PKCS #
5/
7.
23441 * @param {WordArray} data The data to unpad.
23447 * CryptoJS.pad.Pkcs7.unpad(wordArray);
23449 unpad: function (data) {
23450 // Get number of padding bytes from last byte
23451 var nPaddingBytes = data.words[(data.sigBytes -
1)
>>> 2] &
0xff;
23454 data.sigBytes -= nPaddingBytes;
23459 * Abstract base block cipher template.
23461 * @property {number} blockSize The number of
32-bit words this cipher operates on. Default:
4 (
128 bits)
23463 var BlockCipher = C_lib.BlockCipher = Cipher.extend({
23465 * Configuration options.
23467 * @property {Mode} mode The block mode to use. Default: CBC
23468 * @property {Padding} padding The padding strategy to use. Default: Pkcs7
23470 cfg: Cipher.cfg.extend({
23475 reset: function () {
23477 Cipher.reset.call(this);
23480 var cfg = this.cfg;
23482 var mode = cfg.mode;
23484 // Reset block mode
23485 if (this._xformMode == this._ENC_XFORM_MODE) {
23486 var modeCreator = mode.createEncryptor;
23487 } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
23488 var modeCreator = mode.createDecryptor;
23490 // Keep at least one block in the buffer for unpadding
23491 this._minBufferSize =
1;
23493 this._mode = modeCreator.call(mode, this, iv && iv.words);
23496 _doProcessBlock: function (words, offset) {
23497 this._mode.processBlock(words, offset);
23500 _doFinalize: function () {
23502 var padding = this.cfg.padding;
23505 if (this._xformMode == this._ENC_XFORM_MODE) {
23507 padding.pad(this._data, this.blockSize);
23509 // Process final blocks
23510 var finalProcessedBlocks = this._process(!!'flush');
23511 } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
23512 // Process final blocks
23513 var finalProcessedBlocks = this._process(!!'flush');
23516 padding.unpad(finalProcessedBlocks);
23519 return finalProcessedBlocks;
23526 * A collection of cipher parameters.
23528 * @property {WordArray} ciphertext The raw ciphertext.
23529 * @property {WordArray} key The key to this ciphertext.
23530 * @property {WordArray} iv The IV used in the ciphering operation.
23531 * @property {WordArray} salt The salt used with a key derivation function.
23532 * @property {Cipher} algorithm The cipher algorithm.
23533 * @property {Mode} mode The block mode used in the ciphering operation.
23534 * @property {Padding} padding The padding scheme used in the ciphering operation.
23535 * @property {number} blockSize The block size of the cipher.
23536 * @property {Format} formatter The default formatting strategy to convert this cipher params object to a string.
23538 var CipherParams = C_lib.CipherParams = Base.extend({
23540 * Initializes a newly created cipher params object.
23542 * @param {Object} cipherParams An object with any of the possible cipher parameters.
23546 * var cipherParams = CryptoJS.lib.CipherParams.create({
23547 * ciphertext: ciphertextWordArray,
23548 * key: keyWordArray,
23550 * salt: saltWordArray,
23551 * algorithm: CryptoJS.algo.AES,
23552 * mode: CryptoJS.mode.CBC,
23553 * padding: CryptoJS.pad.PKCS7,
23555 * formatter: CryptoJS.format.OpenSSL
23558 init: function (cipherParams) {
23559 this.mixIn(cipherParams);
23563 * Converts this cipher params object to a string.
23565 * @param {Format} formatter (Optional) The formatting strategy to use.
23567 * @return {string} The stringified cipher params.
23569 * @throws Error If neither the formatter nor the default formatter is set.
23573 * var string = cipherParams + '';
23574 * var string = cipherParams.toString();
23575 * var string = cipherParams.toString(CryptoJS.format.OpenSSL);
23577 toString: function (formatter) {
23578 return (formatter || this.formatter).stringify(this);
23583 * Format namespace.
23585 var C_format = C.format = {};
23588 * OpenSSL formatting strategy.
23590 var OpenSSLFormatter = C_format.OpenSSL = {
23592 * Converts a cipher params object to an OpenSSL-compatible string.
23594 * @param {CipherParams} cipherParams The cipher params object.
23596 * @return {string} The OpenSSL-compatible string.
23602 * var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams);
23604 stringify: function (cipherParams) {
23606 var ciphertext = cipherParams.ciphertext;
23607 var salt = cipherParams.salt;
23611 var wordArray = WordArray.create([
0x53616c74,
0x65645f5f]).concat(salt).concat(ciphertext);
23613 var wordArray = ciphertext;
23616 return wordArray.toString(Base64);
23620 * Converts an OpenSSL-compatible string to a cipher params object.
23622 * @param {string} openSSLStr The OpenSSL-compatible string.
23624 * @return {CipherParams} The cipher params object.
23630 * var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString);
23632 parse: function (openSSLStr) {
23634 var ciphertext = Base64.parse(openSSLStr);
23637 var ciphertextWords = ciphertext.words;
23640 if (ciphertextWords[
0] ==
0x53616c74 && ciphertextWords[
1] ==
0x65645f5f) {
23642 var salt = WordArray.create(ciphertextWords.slice(
2,
4));
23644 // Remove salt from ciphertext
23645 ciphertextWords.splice(
0,
4);
23646 ciphertext.sigBytes -=
16;
23649 return CipherParams.create({ ciphertext: ciphertext, salt: salt });
23654 * A cipher wrapper that returns ciphertext as a serializable cipher params object.
23656 var SerializableCipher = C_lib.SerializableCipher = Base.extend({
23658 * Configuration options.
23660 * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL
23663 format: OpenSSLFormatter
23667 * Encrypts a message.
23669 * @param {Cipher} cipher The cipher algorithm to use.
23670 * @param {WordArray|string} message The message to encrypt.
23671 * @param {WordArray} key The key.
23672 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23674 * @return {CipherParams} A cipher params object.
23680 * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key);
23681 * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv });
23682 * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL });
23684 encrypt: function (cipher, message, key, cfg) {
23685 // Apply config defaults
23686 cfg = this.cfg.extend(cfg);
23689 var encryptor = cipher.createEncryptor(key, cfg);
23690 var ciphertext = encryptor.finalize(message);
23693 var cipherCfg = encryptor.cfg;
23695 // Create and return serializable cipher params
23696 return CipherParams.create({
23697 ciphertext: ciphertext,
23701 mode: cipherCfg.mode,
23702 padding: cipherCfg.padding,
23703 blockSize: cipher.blockSize,
23704 formatter: cfg.format
23709 * Decrypts serialized ciphertext.
23711 * @param {Cipher} cipher The cipher algorithm to use.
23712 * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
23713 * @param {WordArray} key The key.
23714 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23716 * @return {WordArray} The plaintext.
23722 * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL });
23723 * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL });
23725 decrypt: function (cipher, ciphertext, key, cfg) {
23726 // Apply config defaults
23727 cfg = this.cfg.extend(cfg);
23729 // Convert string to CipherParams
23730 ciphertext = this._parse(ciphertext, cfg.format);
23733 var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext);
23739 * Converts serialized ciphertext to CipherParams,
23740 * else assumed CipherParams already and returns ciphertext unchanged.
23742 * @param {CipherParams|string} ciphertext The ciphertext.
23743 * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext.
23745 * @return {CipherParams} The unserialized ciphertext.
23751 * var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format);
23753 _parse: function (ciphertext, format) {
23754 if (typeof ciphertext == 'string') {
23755 return format.parse(ciphertext, this);
23763 * Key derivation function namespace.
23765 var C_kdf = C.kdf = {};
23768 * OpenSSL key derivation function.
23770 var OpenSSLKdf = C_kdf.OpenSSL = {
23772 * Derives a key and IV from a password.
23774 * @param {string} password The password to derive from.
23775 * @param {number} keySize The size in words of the key to generate.
23776 * @param {number} ivSize The size in words of the IV to generate.
23777 * @param {WordArray|string} salt (Optional) A
64-bit salt to use. If omitted, a salt will be generated randomly.
23779 * @return {CipherParams} A cipher params object with the key, IV, and salt.
23785 * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password',
256/
32,
128/
32);
23786 * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password',
256/
32,
128/
32, 'saltsalt');
23788 execute: function (password, keySize, ivSize, salt) {
23789 // Generate random salt
23791 salt = WordArray.random(
64/
8);
23794 // Derive key and IV
23795 var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt);
23797 // Separate key and IV
23798 var iv = WordArray.create(key.words.slice(keySize), ivSize *
4);
23799 key.sigBytes = keySize *
4;
23802 return CipherParams.create({ key: key, iv: iv, salt: salt });
23807 * A serializable cipher wrapper that derives the key from a password,
23808 * and returns ciphertext as a serializable cipher params object.
23810 var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({
23812 * Configuration options.
23814 * @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL
23816 cfg: SerializableCipher.cfg.extend({
23821 * Encrypts a message using a password.
23823 * @param {Cipher} cipher The cipher algorithm to use.
23824 * @param {WordArray|string} message The message to encrypt.
23825 * @param {string} password The password.
23826 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23828 * @return {CipherParams} A cipher params object.
23834 * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password');
23835 * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL });
23837 encrypt: function (cipher, message, password, cfg) {
23838 // Apply config defaults
23839 cfg = this.cfg.extend(cfg);
23841 // Derive key and other params
23842 var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize);
23844 // Add IV to config
23845 cfg.iv = derivedParams.iv;
23848 var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg);
23850 // Mix in derived params
23851 ciphertext.mixIn(derivedParams);
23857 * Decrypts serialized ciphertext using a password.
23859 * @param {Cipher} cipher The cipher algorithm to use.
23860 * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
23861 * @param {string} password The password.
23862 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23864 * @return {WordArray} The plaintext.
23870 * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL });
23871 * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL });
23873 decrypt: function (cipher, ciphertext, password, cfg) {
23874 // Apply config defaults
23875 cfg = this.cfg.extend(cfg);
23877 // Convert string to CipherParams
23878 ciphertext = this._parse(ciphertext, cfg.format);
23880 // Derive key and other params
23881 var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt);
23883 // Add IV to config
23884 cfg.iv = derivedParams.iv;
23887 var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg);
23896 },{
"./core":
31}],
31:[function(_dereq_,module,exports){
23897 ;(function (root, factory) {
23898 if (typeof exports ===
"object") {
23900 module.exports = exports = factory();
23902 else if (typeof define ===
"function" && define.amd) {
23904 define([], factory);
23907 // Global (browser)
23908 root.CryptoJS = factory();
23910 }(this, function () {
23913 * CryptoJS core components.
23915 var CryptoJS = CryptoJS || (function (Math, undefined) {
23917 * CryptoJS namespace.
23922 * Library namespace.
23924 var C_lib = C.lib = {};
23927 * Base object for prototypal inheritance.
23929 var Base = C_lib.Base = (function () {
23934 * Creates a new object that inherits from this object.
23936 * @param {Object} overrides Properties to copy into the new object.
23938 * @return {Object} The new object.
23944 * var MyType = CryptoJS.lib.Base.extend({
23947 * method: function () {
23951 extend: function (overrides) {
23953 F.prototype = this;
23954 var subtype = new F();
23958 subtype.mixIn(overrides);
23961 // Create default initializer
23962 if (!subtype.hasOwnProperty('init')) {
23963 subtype.init = function () {
23964 subtype.$super.init.apply(this, arguments);
23968 // Initializer's prototype is the subtype object
23969 subtype.init.prototype = subtype;
23971 // Reference supertype
23972 subtype.$super = this;
23978 * Extends this object and runs the init method.
23979 * Arguments to create() will be passed to init().
23981 * @return {Object} The new object.
23987 * var instance = MyType.create();
23989 create: function () {
23990 var instance = this.extend();
23991 instance.init.apply(instance, arguments);
23997 * Initializes a newly created object.
23998 * Override this method to add some logic when your objects are created.
24002 * var MyType = CryptoJS.lib.Base.extend({
24003 * init: function () {
24008 init: function () {
24012 * Copies properties into this object.
24014 * @param {Object} properties The properties to mix in.
24022 mixIn: function (properties) {
24023 for (var propertyName in properties) {
24024 if (properties.hasOwnProperty(propertyName)) {
24025 this[propertyName] = properties[propertyName];
24029 // IE won't copy toString using the loop above
24030 if (properties.hasOwnProperty('toString')) {
24031 this.toString = properties.toString;
24036 * Creates a copy of this object.
24038 * @return {Object} The clone.
24042 * var clone = instance.clone();
24044 clone: function () {
24045 return this.init.prototype.extend(this);
24051 * An array of
32-bit words.
24053 * @property {Array} words The array of
32-bit words.
24054 * @property {number} sigBytes The number of significant bytes in this word array.
24056 var WordArray = C_lib.WordArray = Base.extend({
24058 * Initializes a newly created word array.
24060 * @param {Array} words (Optional) An array of
32-bit words.
24061 * @param {number} sigBytes (Optional) The number of significant bytes in the words.
24065 * var wordArray = CryptoJS.lib.WordArray.create();
24066 * var wordArray = CryptoJS.lib.WordArray.create([
0x00010203,
0x04050607]);
24067 * var wordArray = CryptoJS.lib.WordArray.create([
0x00010203,
0x04050607],
6);
24069 init: function (words, sigBytes) {
24070 words = this.words = words || [];
24072 if (sigBytes != undefined) {
24073 this.sigBytes = sigBytes;
24075 this.sigBytes = words.length *
4;
24080 * Converts this word array to a string.
24082 * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
24084 * @return {string} The stringified word array.
24088 * var string = wordArray + '';
24089 * var string = wordArray.toString();
24090 * var string = wordArray.toString(CryptoJS.enc.Utf8);
24092 toString: function (encoder) {
24093 return (encoder || Hex).stringify(this);
24097 * Concatenates a word array to this word array.
24099 * @param {WordArray} wordArray The word array to append.
24101 * @return {WordArray} This word array.
24105 * wordArray1.concat(wordArray2);
24107 concat: function (wordArray) {
24109 var thisWords = this.words;
24110 var thatWords = wordArray.words;
24111 var thisSigBytes = this.sigBytes;
24112 var thatSigBytes = wordArray.sigBytes;
24114 // Clamp excess bits
24118 if (thisSigBytes %
4) {
24119 // Copy one byte at a time
24120 for (var i =
0; i < thatSigBytes; i++) {
24121 var thatByte = (thatWords[i
>>> 2]
>>> (
24 - (i %
4) *
8)) &
0xff;
24122 thisWords[(thisSigBytes + i)
>>> 2] |= thatByte << (
24 - ((thisSigBytes + i) %
4) *
8);
24124 } else if (thatWords.length
> 0xffff) {
24125 // Copy one word at a time
24126 for (var i =
0; i < thatSigBytes; i +=
4) {
24127 thisWords[(thisSigBytes + i)
>>> 2] = thatWords[i
>>> 2];
24130 // Copy all words at once
24131 thisWords.push.apply(thisWords, thatWords);
24133 this.sigBytes += thatSigBytes;
24140 * Removes insignificant bits.
24144 * wordArray.clamp();
24146 clamp: function () {
24148 var words = this.words;
24149 var sigBytes = this.sigBytes;
24152 words[sigBytes
>>> 2] &=
0xffffffff << (
32 - (sigBytes %
4) *
8);
24153 words.length = Math.ceil(sigBytes /
4);
24157 * Creates a copy of this word array.
24159 * @return {WordArray} The clone.
24163 * var clone = wordArray.clone();
24165 clone: function () {
24166 var clone = Base.clone.call(this);
24167 clone.words = this.words.slice(
0);
24173 * Creates a word array filled with random bytes.
24175 * @param {number} nBytes The number of random bytes to generate.
24177 * @return {WordArray} The random word array.
24183 * var wordArray = CryptoJS.lib.WordArray.random(
16);
24185 random: function (nBytes) {
24187 for (var i =
0; i < nBytes; i +=
4) {
24188 words.push((Math.random() *
0x100000000) |
0);
24191 return new WordArray.init(words, nBytes);
24196 * Encoder namespace.
24198 var C_enc = C.enc = {};
24201 * Hex encoding strategy.
24203 var Hex = C_enc.Hex = {
24205 * Converts a word array to a hex string.
24207 * @param {WordArray} wordArray The word array.
24209 * @return {string} The hex string.
24215 * var hexString = CryptoJS.enc.Hex.stringify(wordArray);
24217 stringify: function (wordArray) {
24219 var words = wordArray.words;
24220 var sigBytes = wordArray.sigBytes;
24224 for (var i =
0; i < sigBytes; i++) {
24225 var bite = (words[i
>>> 2]
>>> (
24 - (i %
4) *
8)) &
0xff;
24226 hexChars.push((bite
>>> 4).toString(
16));
24227 hexChars.push((bite &
0x0f).toString(
16));
24230 return hexChars.join('');
24234 * Converts a hex string to a word array.
24236 * @param {string} hexStr The hex string.
24238 * @return {WordArray} The word array.
24244 * var wordArray = CryptoJS.enc.Hex.parse(hexString);
24246 parse: function (hexStr) {
24248 var hexStrLength = hexStr.length;
24252 for (var i =
0; i < hexStrLength; i +=
2) {
24253 words[i
>>> 3] |= parseInt(hexStr.substr(i,
2),
16) << (
24 - (i %
8) *
4);
24256 return new WordArray.init(words, hexStrLength /
2);
24261 * Latin1 encoding strategy.
24263 var Latin1 = C_enc.Latin1 = {
24265 * Converts a word array to a Latin1 string.
24267 * @param {WordArray} wordArray The word array.
24269 * @return {string} The Latin1 string.
24275 * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
24277 stringify: function (wordArray) {
24279 var words = wordArray.words;
24280 var sigBytes = wordArray.sigBytes;
24283 var latin1Chars = [];
24284 for (var i =
0; i < sigBytes; i++) {
24285 var bite = (words[i
>>> 2]
>>> (
24 - (i %
4) *
8)) &
0xff;
24286 latin1Chars.push(String.fromCharCode(bite));
24289 return latin1Chars.join('');
24293 * Converts a Latin1 string to a word array.
24295 * @param {string} latin1Str The Latin1 string.
24297 * @return {WordArray} The word array.
24303 * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
24305 parse: function (latin1Str) {
24307 var latin1StrLength = latin1Str.length;
24311 for (var i =
0; i < latin1StrLength; i++) {
24312 words[i
>>> 2] |= (latin1Str.charCodeAt(i) &
0xff) << (
24 - (i %
4) *
8);
24315 return new WordArray.init(words, latin1StrLength);
24320 * UTF-
8 encoding strategy.
24322 var Utf8 = C_enc.Utf8 = {
24324 * Converts a word array to a UTF-
8 string.
24326 * @param {WordArray} wordArray The word array.
24328 * @return {string} The UTF-
8 string.
24334 * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
24336 stringify: function (wordArray) {
24338 return decodeURIComponent(escape(Latin1.stringify(wordArray)));
24340 throw new Error('Malformed UTF-
8 data');
24345 * Converts a UTF-
8 string to a word array.
24347 * @param {string} utf8Str The UTF-
8 string.
24349 * @return {WordArray} The word array.
24355 * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
24357 parse: function (utf8Str) {
24358 return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
24363 * Abstract buffered block algorithm template.
24365 * The property blockSize must be implemented in a concrete subtype.
24367 * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default:
0
24369 var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
24371 * Resets this block algorithm's data buffer to its initial state.
24375 * bufferedBlockAlgorithm.reset();
24377 reset: function () {
24379 this._data = new WordArray.init();
24380 this._nDataBytes =
0;
24384 * Adds new data to this block algorithm's buffer.
24386 * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-
8.
24390 * bufferedBlockAlgorithm._append('data');
24391 * bufferedBlockAlgorithm._append(wordArray);
24393 _append: function (data) {
24394 // Convert string to WordArray, else assume WordArray already
24395 if (typeof data == 'string') {
24396 data = Utf8.parse(data);
24400 this._data.concat(data);
24401 this._nDataBytes += data.sigBytes;
24405 * Processes available data blocks.
24407 * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
24409 * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
24411 * @return {WordArray} The processed data.
24415 * var processedData = bufferedBlockAlgorithm._process();
24416 * var processedData = bufferedBlockAlgorithm._process(!!'flush');
24418 _process: function (doFlush) {
24420 var data = this._data;
24421 var dataWords = data.words;
24422 var dataSigBytes = data.sigBytes;
24423 var blockSize = this.blockSize;
24424 var blockSizeBytes = blockSize *
4;
24426 // Count blocks ready
24427 var nBlocksReady = dataSigBytes / blockSizeBytes;
24429 // Round up to include partial blocks
24430 nBlocksReady = Math.ceil(nBlocksReady);
24432 // Round down to include only full blocks,
24433 // less the number of blocks that must remain in the buffer
24434 nBlocksReady = Math.max((nBlocksReady |
0) - this._minBufferSize,
0);
24437 // Count words ready
24438 var nWordsReady = nBlocksReady * blockSize;
24440 // Count bytes ready
24441 var nBytesReady = Math.min(nWordsReady *
4, dataSigBytes);
24445 for (var offset =
0; offset < nWordsReady; offset += blockSize) {
24446 // Perform concrete-algorithm logic
24447 this._doProcessBlock(dataWords, offset);
24450 // Remove processed words
24451 var processedWords = dataWords.splice(
0, nWordsReady);
24452 data.sigBytes -= nBytesReady;
24455 // Return processed words
24456 return new WordArray.init(processedWords, nBytesReady);
24460 * Creates a copy of this object.
24462 * @return {Object} The clone.
24466 * var clone = bufferedBlockAlgorithm.clone();
24468 clone: function () {
24469 var clone = Base.clone.call(this);
24470 clone._data = this._data.clone();
24479 * Abstract hasher template.
24481 * @property {number} blockSize The number of
32-bit words this hasher operates on. Default:
16 (
512 bits)
24483 var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
24485 * Configuration options.
24487 cfg: Base.extend(),
24490 * Initializes a newly created hasher.
24492 * @param {Object} cfg (Optional) The configuration options to use for this hash computation.
24496 * var hasher = CryptoJS.algo.SHA256.create();
24498 init: function (cfg) {
24499 // Apply config defaults
24500 this.cfg = this.cfg.extend(cfg);
24502 // Set initial values
24507 * Resets this hasher to its initial state.
24513 reset: function () {
24514 // Reset data buffer
24515 BufferedBlockAlgorithm.reset.call(this);
24517 // Perform concrete-hasher logic
24522 * Updates this hasher with a message.
24524 * @param {WordArray|string} messageUpdate The message to append.
24526 * @return {Hasher} This hasher.
24530 * hasher.update('message');
24531 * hasher.update(wordArray);
24533 update: function (messageUpdate) {
24535 this._append(messageUpdate);
24545 * Finalizes the hash computation.
24546 * Note that the finalize operation is effectively a destructive, read-once operation.
24548 * @param {WordArray|string} messageUpdate (Optional) A final message update.
24550 * @return {WordArray} The hash.
24554 * var hash = hasher.finalize();
24555 * var hash = hasher.finalize('message');
24556 * var hash = hasher.finalize(wordArray);
24558 finalize: function (messageUpdate) {
24559 // Final message update
24560 if (messageUpdate) {
24561 this._append(messageUpdate);
24564 // Perform concrete-hasher logic
24565 var hash = this._doFinalize();
24573 * Creates a shortcut function to a hasher's object interface.
24575 * @param {Hasher} hasher The hasher to create a helper for.
24577 * @return {Function} The shortcut function.
24583 * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
24585 _createHelper: function (hasher) {
24586 return function (message, cfg) {
24587 return new hasher.init(cfg).finalize(message);
24592 * Creates a shortcut function to the HMAC's object interface.
24594 * @param {Hasher} hasher The hasher to use in this HMAC helper.
24596 * @return {Function} The shortcut function.
24602 * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
24604 _createHmacHelper: function (hasher) {
24605 return function (message, key) {
24606 return new C_algo.HMAC.init(hasher, key).finalize(message);
24612 * Algorithm namespace.
24614 var C_algo = C.algo = {};
24623 },{}],
32:[function(_dereq_,module,exports){
24624 ;(function (root, factory) {
24625 if (typeof exports ===
"object") {
24627 module.exports = exports = factory(_dereq_(
"./core"));
24629 else if (typeof define ===
"function" && define.amd) {
24631 define([
"./core"], factory);
24634 // Global (browser)
24635 factory(root.CryptoJS);
24637 }(this, function (CryptoJS) {
24643 var WordArray = C_lib.WordArray;
24647 * Base64 encoding strategy.
24649 var Base64 = C_enc.Base64 = {
24651 * Converts a word array to a Base64 string.
24653 * @param {WordArray} wordArray The word array.
24655 * @return {string} The Base64 string.
24661 * var base64String = CryptoJS.enc.Base64.stringify(wordArray);
24663 stringify: function (wordArray) {
24665 var words = wordArray.words;
24666 var sigBytes = wordArray.sigBytes;
24667 var map = this._map;
24669 // Clamp excess bits
24673 var base64Chars = [];
24674 for (var i =
0; i < sigBytes; i +=
3) {
24675 var byte1 = (words[i
>>> 2]
>>> (
24 - (i %
4) *
8)) &
0xff;
24676 var byte2 = (words[(i +
1)
>>> 2]
>>> (
24 - ((i +
1) %
4) *
8)) &
0xff;
24677 var byte3 = (words[(i +
2)
>>> 2]
>>> (
24 - ((i +
2) %
4) *
8)) &
0xff;
24679 var triplet = (byte1 <<
16) | (byte2 <<
8) | byte3;
24681 for (var j =
0; (j <
4) && (i + j *
0.75 < sigBytes); j++) {
24682 base64Chars.push(map.charAt((triplet
>>> (
6 * (
3 - j))) &
0x3f));
24687 var paddingChar = map.charAt(
64);
24689 while (base64Chars.length %
4) {
24690 base64Chars.push(paddingChar);
24694 return base64Chars.join('');
24698 * Converts a Base64 string to a word array.
24700 * @param {string} base64Str The Base64 string.
24702 * @return {WordArray} The word array.
24708 * var wordArray = CryptoJS.enc.Base64.parse(base64String);
24710 parse: function (base64Str) {
24712 var base64StrLength = base64Str.length;
24713 var map = this._map;
24716 var paddingChar = map.charAt(
64);
24718 var paddingIndex = base64Str.indexOf(paddingChar);
24719 if (paddingIndex != -
1) {
24720 base64StrLength = paddingIndex;
24727 for (var i =
0; i < base64StrLength; i++) {
24729 var bits1 = map.indexOf(base64Str.charAt(i -
1)) << ((i %
4) *
2);
24730 var bits2 = map.indexOf(base64Str.charAt(i))
>>> (
6 - (i %
4) *
2);
24731 words[nBytes
>>> 2] |= (bits1 | bits2) << (
24 - (nBytes %
4) *
8);
24736 return WordArray.create(words, nBytes);
24739 _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
24744 return CryptoJS.enc.Base64;
24747 },{
"./core":
31}],
33:[function(_dereq_,module,exports){
24748 ;(function (root, factory) {
24749 if (typeof exports ===
"object") {
24751 module.exports = exports = factory(_dereq_(
"./core"));
24753 else if (typeof define ===
"function" && define.amd) {
24755 define([
"./core"], factory);
24758 // Global (browser)
24759 factory(root.CryptoJS);
24761 }(this, function (CryptoJS) {
24767 var WordArray = C_lib.WordArray;
24771 * UTF-
16 BE encoding strategy.
24773 var Utf16BE = C_enc.Utf16 = C_enc.Utf16BE = {
24775 * Converts a word array to a UTF-
16 BE string.
24777 * @param {WordArray} wordArray The word array.
24779 * @return {string} The UTF-
16 BE string.
24785 * var utf16String = CryptoJS.enc.Utf16.stringify(wordArray);
24787 stringify: function (wordArray) {
24789 var words = wordArray.words;
24790 var sigBytes = wordArray.sigBytes;
24793 var utf16Chars = [];
24794 for (var i =
0; i < sigBytes; i +=
2) {
24795 var codePoint = (words[i
>>> 2]
>>> (
16 - (i %
4) *
8)) &
0xffff;
24796 utf16Chars.push(String.fromCharCode(codePoint));
24799 return utf16Chars.join('');
24803 * Converts a UTF-
16 BE string to a word array.
24805 * @param {string} utf16Str The UTF-
16 BE string.
24807 * @return {WordArray} The word array.
24813 * var wordArray = CryptoJS.enc.Utf16.parse(utf16String);
24815 parse: function (utf16Str) {
24817 var utf16StrLength = utf16Str.length;
24821 for (var i =
0; i < utf16StrLength; i++) {
24822 words[i
>>> 1] |= utf16Str.charCodeAt(i) << (
16 - (i %
2) *
16);
24825 return WordArray.create(words, utf16StrLength *
2);
24830 * UTF-
16 LE encoding strategy.
24834 * Converts a word array to a UTF-
16 LE string.
24836 * @param {WordArray} wordArray The word array.
24838 * @return {string} The UTF-
16 LE string.
24844 * var utf16Str = CryptoJS.enc.Utf16LE.stringify(wordArray);
24846 stringify: function (wordArray) {
24848 var words = wordArray.words;
24849 var sigBytes = wordArray.sigBytes;
24852 var utf16Chars = [];
24853 for (var i =
0; i < sigBytes; i +=
2) {
24854 var codePoint = swapEndian((words[i
>>> 2]
>>> (
16 - (i %
4) *
8)) &
0xffff);
24855 utf16Chars.push(String.fromCharCode(codePoint));
24858 return utf16Chars.join('');
24862 * Converts a UTF-
16 LE string to a word array.
24864 * @param {string} utf16Str The UTF-
16 LE string.
24866 * @return {WordArray} The word array.
24872 * var wordArray = CryptoJS.enc.Utf16LE.parse(utf16Str);
24874 parse: function (utf16Str) {
24876 var utf16StrLength = utf16Str.length;
24880 for (var i =
0; i < utf16StrLength; i++) {
24881 words[i
>>> 1] |= swapEndian(utf16Str.charCodeAt(i) << (
16 - (i %
2) *
16));
24884 return WordArray.create(words, utf16StrLength *
2);
24888 function swapEndian(word) {
24889 return ((word <<
8) &
0xff00ff00) | ((word
>>> 8) &
0x00ff00ff);
24894 return CryptoJS.enc.Utf16;
24897 },{
"./core":
31}],
34:[function(_dereq_,module,exports){
24898 ;(function (root, factory, undef) {
24899 if (typeof exports ===
"object") {
24901 module.exports = exports = factory(_dereq_(
"./core"), _dereq_(
"./sha1"), _dereq_(
"./hmac"));
24903 else if (typeof define ===
"function" && define.amd) {
24905 define([
"./core",
"./sha1",
"./hmac"], factory);
24908 // Global (browser)
24909 factory(root.CryptoJS);
24911 }(this, function (CryptoJS) {
24917 var Base = C_lib.Base;
24918 var WordArray = C_lib.WordArray;
24919 var C_algo = C.algo;
24920 var MD5 = C_algo.MD5;
24923 * This key derivation function is meant to conform with EVP_BytesToKey.
24924 * www.openssl.org/docs/crypto/EVP_BytesToKey.html
24926 var EvpKDF = C_algo.EvpKDF = Base.extend({
24928 * Configuration options.
24930 * @property {number} keySize The key size in words to generate. Default:
4 (
128 bits)
24931 * @property {Hasher} hasher The hash algorithm to use. Default: MD5
24932 * @property {number} iterations The number of iterations to perform. Default:
1
24941 * Initializes a newly created key derivation function.
24943 * @param {Object} cfg (Optional) The configuration options to use for the derivation.
24947 * var kdf = CryptoJS.algo.EvpKDF.create();
24948 * var kdf = CryptoJS.algo.EvpKDF.create({ keySize:
8 });
24949 * var kdf = CryptoJS.algo.EvpKDF.create({ keySize:
8, iterations:
1000 });
24951 init: function (cfg) {
24952 this.cfg = this.cfg.extend(cfg);
24956 * Derives a key from a password.
24958 * @param {WordArray|string} password The password.
24959 * @param {WordArray|string} salt A salt.
24961 * @return {WordArray} The derived key.
24965 * var key = kdf.compute(password, salt);
24967 compute: function (password, salt) {
24969 var cfg = this.cfg;
24972 var hasher = cfg.hasher.create();
24975 var derivedKey = WordArray.create();
24978 var derivedKeyWords = derivedKey.words;
24979 var keySize = cfg.keySize;
24980 var iterations = cfg.iterations;
24983 while (derivedKeyWords.length < keySize) {
24985 hasher.update(block);
24987 var block = hasher.update(password).finalize(salt);
24991 for (var i =
1; i < iterations; i++) {
24992 block = hasher.finalize(block);
24996 derivedKey.concat(block);
24998 derivedKey.sigBytes = keySize *
4;
25005 * Derives a key from a password.
25007 * @param {WordArray|string} password The password.
25008 * @param {WordArray|string} salt A salt.
25009 * @param {Object} cfg (Optional) The configuration options to use for this computation.
25011 * @return {WordArray} The derived key.
25017 * var key = CryptoJS.EvpKDF(password, salt);
25018 * var key = CryptoJS.EvpKDF(password, salt, { keySize:
8 });
25019 * var key = CryptoJS.EvpKDF(password, salt, { keySize:
8, iterations:
1000 });
25021 C.EvpKDF = function (password, salt, cfg) {
25022 return EvpKDF.create(cfg).compute(password, salt);
25027 return CryptoJS.EvpKDF;
25030 },{
"./core":
31,
"./hmac":
36,
"./sha1":
55}],
35:[function(_dereq_,module,exports){
25031 ;(function (root, factory, undef) {
25032 if (typeof exports ===
"object") {
25034 module.exports = exports = factory(_dereq_(
"./core"), _dereq_(
"./cipher-core"));
25036 else if (typeof define ===
"function" && define.amd) {
25038 define([
"./core",
"./cipher-core"], factory);
25041 // Global (browser)
25042 factory(root.CryptoJS);
25044 }(this, function (CryptoJS) {
25046 (function (undefined) {
25050 var CipherParams = C_lib.CipherParams;
25052 var Hex = C_enc.Hex;
25053 var C_format = C.format;
25055 var HexFormatter = C_format.Hex = {
25057 * Converts the ciphertext of a cipher params object to a hexadecimally encoded string.
25059 * @param {CipherParams} cipherParams The cipher params object.
25061 * @return {string} The hexadecimally encoded string.
25067 * var hexString = CryptoJS.format.Hex.stringify(cipherParams);
25069 stringify: function (cipherParams) {
25070 return cipherParams.ciphertext.toString(Hex);
25074 * Converts a hexadecimally encoded ciphertext string to a cipher params object.
25076 * @param {string} input The hexadecimally encoded string.
25078 * @return {CipherParams} The cipher params object.
25084 * var cipherParams = CryptoJS.format.Hex.parse(hexString);
25086 parse: function (input) {
25087 var ciphertext = Hex.parse(input);
25088 return CipherParams.create({ ciphertext: ciphertext });
25094 return CryptoJS.format.Hex;
25097 },{
"./cipher-core":
30,
"./core":
31}],
36:[function(_dereq_,module,exports){
25098 ;(function (root, factory) {
25099 if (typeof exports ===
"object") {
25101 module.exports = exports = factory(_dereq_(
"./core"));
25103 else if (typeof define ===
"function" && define.amd) {
25105 define([
"./core"], factory);
25108 // Global (browser)
25109 factory(root.CryptoJS);
25111 }(this, function (CryptoJS) {
25117 var Base = C_lib.Base;
25119 var Utf8 = C_enc.Utf8;
25120 var C_algo = C.algo;
25125 var HMAC = C_algo.HMAC = Base.extend({
25127 * Initializes a newly created HMAC.
25129 * @param {Hasher} hasher The hash algorithm to use.
25130 * @param {WordArray|string} key The secret key.
25134 * var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
25136 init: function (hasher, key) {
25138 hasher = this._hasher = new hasher.init();
25140 // Convert string to WordArray, else assume WordArray already
25141 if (typeof key == 'string') {
25142 key = Utf8.parse(key);
25146 var hasherBlockSize = hasher.blockSize;
25147 var hasherBlockSizeBytes = hasherBlockSize *
4;
25149 // Allow arbitrary length keys
25150 if (key.sigBytes
> hasherBlockSizeBytes) {
25151 key = hasher.finalize(key);
25154 // Clamp excess bits
25157 // Clone key for inner and outer pads
25158 var oKey = this._oKey = key.clone();
25159 var iKey = this._iKey = key.clone();
25162 var oKeyWords = oKey.words;
25163 var iKeyWords = iKey.words;
25165 // XOR keys with pad constants
25166 for (var i =
0; i < hasherBlockSize; i++) {
25167 oKeyWords[i] ^=
0x5c5c5c5c;
25168 iKeyWords[i] ^=
0x36363636;
25170 oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes;
25172 // Set initial values
25177 * Resets this HMAC to its initial state.
25181 * hmacHasher.reset();
25183 reset: function () {
25185 var hasher = this._hasher;
25189 hasher.update(this._iKey);
25193 * Updates this HMAC with a message.
25195 * @param {WordArray|string} messageUpdate The message to append.
25197 * @return {HMAC} This HMAC instance.
25201 * hmacHasher.update('message');
25202 * hmacHasher.update(wordArray);
25204 update: function (messageUpdate) {
25205 this._hasher.update(messageUpdate);
25212 * Finalizes the HMAC computation.
25213 * Note that the finalize operation is effectively a destructive, read-once operation.
25215 * @param {WordArray|string} messageUpdate (Optional) A final message update.
25217 * @return {WordArray} The HMAC.
25221 * var hmac = hmacHasher.finalize();
25222 * var hmac = hmacHasher.finalize('message');
25223 * var hmac = hmacHasher.finalize(wordArray);
25225 finalize: function (messageUpdate) {
25227 var hasher = this._hasher;
25230 var innerHash = hasher.finalize(messageUpdate);
25232 var hmac = hasher.finalize(this._oKey.clone().concat(innerHash));
25241 },{"./core":
31}],
37:[function(_dereq_,module,exports){
25242 ;(function (root, factory, undef) {
25243 if (typeof exports === "object") {
25245 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"));
25247 else if (typeof define === "function" && define.amd) {
25249 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);
25252 // Global (browser)
25253 factory(root.CryptoJS);
25255 }(this, function (CryptoJS) {
25260 },{"./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){
25261 ;(function (root, factory) {
25262 if (typeof exports === "object") {
25264 module.exports = exports = factory(_dereq_("./core"));
25266 else if (typeof define === "function" && define.amd) {
25268 define(["./core"], factory);
25271 // Global (browser)
25272 factory(root.CryptoJS);
25274 }(this, function (CryptoJS) {
25277 // Check if typed arrays are supported
25278 if (typeof ArrayBuffer != 'function') {
25285 var WordArray = C_lib.WordArray;
25287 // Reference original init
25288 var superInit = WordArray.init;
25290 // Augment WordArray.init to handle typed arrays
25291 var subInit = WordArray.init = function (typedArray) {
25292 // Convert buffers to uint8
25293 if (typedArray instanceof ArrayBuffer) {
25294 typedArray = new Uint8Array(typedArray);
25297 // Convert other array views to uint8
25299 typedArray instanceof Int8Array ||
25300 typedArray instanceof Uint8ClampedArray ||
25301 typedArray instanceof Int16Array ||
25302 typedArray instanceof Uint16Array ||
25303 typedArray instanceof Int32Array ||
25304 typedArray instanceof Uint32Array ||
25305 typedArray instanceof Float32Array ||
25306 typedArray instanceof Float64Array
25308 typedArray = new Uint8Array(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength);
25311 // Handle Uint8Array
25312 if (typedArray instanceof Uint8Array) {
25314 var typedArrayByteLength = typedArray.byteLength;
25318 for (var i =
0; i < typedArrayByteLength; i++) {
25319 words[i
>>> 2] |= typedArray[i] << (
24 - (i %
4) *
8);
25322 // Initialize this word array
25323 superInit.call(this, words, typedArrayByteLength);
25325 // Else call normal init
25326 superInit.apply(this, arguments);
25330 subInit.prototype = WordArray;
25334 return CryptoJS.lib.WordArray;
25337 },{
"./core":
31}],
39:[function(_dereq_,module,exports){
25338 ;(function (root, factory) {
25339 if (typeof exports ===
"object") {
25341 module.exports = exports = factory(_dereq_(
"./core"));
25343 else if (typeof define ===
"function" && define.amd) {
25345 define([
"./core"], factory);
25348 // Global (browser)
25349 factory(root.CryptoJS);
25351 }(this, function (CryptoJS) {
25357 var WordArray = C_lib.WordArray;
25358 var Hasher = C_lib.Hasher;
25359 var C_algo = C.algo;
25364 // Compute constants
25366 for (var i =
0; i <
64; i++) {
25367 T[i] = (Math.abs(Math.sin(i +
1)) *
0x100000000) |
0;
25372 * MD5 hash algorithm.
25374 var MD5 = C_algo.MD5 = Hasher.extend({
25375 _doReset: function () {
25376 this._hash = new WordArray.init([
25377 0x67452301,
0xefcdab89,
25378 0x98badcfe,
0x10325476
25382 _doProcessBlock: function (M, offset) {
25384 for (var i =
0; i <
16; i++) {
25386 var offset_i = offset + i;
25387 var M_offset_i = M[offset_i];
25390 (((M_offset_i <<
8) | (M_offset_i
>>> 24)) &
0x00ff00ff) |
25391 (((M_offset_i <<
24) | (M_offset_i
>>> 8)) &
0xff00ff00)
25396 var H = this._hash.words;
25398 var M_offset_0 = M[offset +
0];
25399 var M_offset_1 = M[offset +
1];
25400 var M_offset_2 = M[offset +
2];
25401 var M_offset_3 = M[offset +
3];
25402 var M_offset_4 = M[offset +
4];
25403 var M_offset_5 = M[offset +
5];
25404 var M_offset_6 = M[offset +
6];
25405 var M_offset_7 = M[offset +
7];
25406 var M_offset_8 = M[offset +
8];
25407 var M_offset_9 = M[offset +
9];
25408 var M_offset_10 = M[offset +
10];
25409 var M_offset_11 = M[offset +
11];
25410 var M_offset_12 = M[offset +
12];
25411 var M_offset_13 = M[offset +
13];
25412 var M_offset_14 = M[offset +
14];
25413 var M_offset_15 = M[offset +
15];
25415 // Working varialbes
25422 a = FF(a, b, c, d, M_offset_0,
7, T[
0]);
25423 d = FF(d, a, b, c, M_offset_1,
12, T[
1]);
25424 c = FF(c, d, a, b, M_offset_2,
17, T[
2]);
25425 b = FF(b, c, d, a, M_offset_3,
22, T[
3]);
25426 a = FF(a, b, c, d, M_offset_4,
7, T[
4]);
25427 d = FF(d, a, b, c, M_offset_5,
12, T[
5]);
25428 c = FF(c, d, a, b, M_offset_6,
17, T[
6]);
25429 b = FF(b, c, d, a, M_offset_7,
22, T[
7]);
25430 a = FF(a, b, c, d, M_offset_8,
7, T[
8]);
25431 d = FF(d, a, b, c, M_offset_9,
12, T[
9]);
25432 c = FF(c, d, a, b, M_offset_10,
17, T[
10]);
25433 b = FF(b, c, d, a, M_offset_11,
22, T[
11]);
25434 a = FF(a, b, c, d, M_offset_12,
7, T[
12]);
25435 d = FF(d, a, b, c, M_offset_13,
12, T[
13]);
25436 c = FF(c, d, a, b, M_offset_14,
17, T[
14]);
25437 b = FF(b, c, d, a, M_offset_15,
22, T[
15]);
25439 a = GG(a, b, c, d, M_offset_1,
5, T[
16]);
25440 d = GG(d, a, b, c, M_offset_6,
9, T[
17]);
25441 c = GG(c, d, a, b, M_offset_11,
14, T[
18]);
25442 b = GG(b, c, d, a, M_offset_0,
20, T[
19]);
25443 a = GG(a, b, c, d, M_offset_5,
5, T[
20]);
25444 d = GG(d, a, b, c, M_offset_10,
9, T[
21]);
25445 c = GG(c, d, a, b, M_offset_15,
14, T[
22]);
25446 b = GG(b, c, d, a, M_offset_4,
20, T[
23]);
25447 a = GG(a, b, c, d, M_offset_9,
5, T[
24]);
25448 d = GG(d, a, b, c, M_offset_14,
9, T[
25]);
25449 c = GG(c, d, a, b, M_offset_3,
14, T[
26]);
25450 b = GG(b, c, d, a, M_offset_8,
20, T[
27]);
25451 a = GG(a, b, c, d, M_offset_13,
5, T[
28]);
25452 d = GG(d, a, b, c, M_offset_2,
9, T[
29]);
25453 c = GG(c, d, a, b, M_offset_7,
14, T[
30]);
25454 b = GG(b, c, d, a, M_offset_12,
20, T[
31]);
25456 a = HH(a, b, c, d, M_offset_5,
4, T[
32]);
25457 d = HH(d, a, b, c, M_offset_8,
11, T[
33]);
25458 c = HH(c, d, a, b, M_offset_11,
16, T[
34]);
25459 b = HH(b, c, d, a, M_offset_14,
23, T[
35]);
25460 a = HH(a, b, c, d, M_offset_1,
4, T[
36]);
25461 d = HH(d, a, b, c, M_offset_4,
11, T[
37]);
25462 c = HH(c, d, a, b, M_offset_7,
16, T[
38]);
25463 b = HH(b, c, d, a, M_offset_10,
23, T[
39]);
25464 a = HH(a, b, c, d, M_offset_13,
4, T[
40]);
25465 d = HH(d, a, b, c, M_offset_0,
11, T[
41]);
25466 c = HH(c, d, a, b, M_offset_3,
16, T[
42]);
25467 b = HH(b, c, d, a, M_offset_6,
23, T[
43]);
25468 a = HH(a, b, c, d, M_offset_9,
4, T[
44]);
25469 d = HH(d, a, b, c, M_offset_12,
11, T[
45]);
25470 c = HH(c, d, a, b, M_offset_15,
16, T[
46]);
25471 b = HH(b, c, d, a, M_offset_2,
23, T[
47]);
25473 a = II(a, b, c, d, M_offset_0,
6, T[
48]);
25474 d = II(d, a, b, c, M_offset_7,
10, T[
49]);
25475 c = II(c, d, a, b, M_offset_14,
15, T[
50]);
25476 b = II(b, c, d, a, M_offset_5,
21, T[
51]);
25477 a = II(a, b, c, d, M_offset_12,
6, T[
52]);
25478 d = II(d, a, b, c, M_offset_3,
10, T[
53]);
25479 c = II(c, d, a, b, M_offset_10,
15, T[
54]);
25480 b = II(b, c, d, a, M_offset_1,
21, T[
55]);
25481 a = II(a, b, c, d, M_offset_8,
6, T[
56]);
25482 d = II(d, a, b, c, M_offset_15,
10, T[
57]);
25483 c = II(c, d, a, b, M_offset_6,
15, T[
58]);
25484 b = II(b, c, d, a, M_offset_13,
21, T[
59]);
25485 a = II(a, b, c, d, M_offset_4,
6, T[
60]);
25486 d = II(d, a, b, c, M_offset_11,
10, T[
61]);
25487 c = II(c, d, a, b, M_offset_2,
15, T[
62]);
25488 b = II(b, c, d, a, M_offset_9,
21, T[
63]);
25490 // Intermediate hash value
25491 H[
0] = (H[
0] + a) |
0;
25492 H[
1] = (H[
1] + b) |
0;
25493 H[
2] = (H[
2] + c) |
0;
25494 H[
3] = (H[
3] + d) |
0;
25497 _doFinalize: function () {
25499 var data = this._data;
25500 var dataWords = data.words;
25502 var nBitsTotal = this._nDataBytes *
8;
25503 var nBitsLeft = data.sigBytes *
8;
25506 dataWords[nBitsLeft
>>> 5] |=
0x80 << (
24 - nBitsLeft %
32);
25508 var nBitsTotalH = Math.floor(nBitsTotal /
0x100000000);
25509 var nBitsTotalL = nBitsTotal;
25510 dataWords[(((nBitsLeft +
64)
>>> 9) <<
4) +
15] = (
25511 (((nBitsTotalH <<
8) | (nBitsTotalH
>>> 24)) &
0x00ff00ff) |
25512 (((nBitsTotalH <<
24) | (nBitsTotalH
>>> 8)) &
0xff00ff00)
25514 dataWords[(((nBitsLeft +
64)
>>> 9) <<
4) +
14] = (
25515 (((nBitsTotalL <<
8) | (nBitsTotalL
>>> 24)) &
0x00ff00ff) |
25516 (((nBitsTotalL <<
24) | (nBitsTotalL
>>> 8)) &
0xff00ff00)
25519 data.sigBytes = (dataWords.length +
1) *
4;
25521 // Hash final blocks
25525 var hash = this._hash;
25526 var H = hash.words;
25529 for (var i =
0; i <
4; i++) {
25533 H[i] = (((H_i <<
8) | (H_i
>>> 24)) &
0x00ff00ff) |
25534 (((H_i <<
24) | (H_i
>>> 8)) &
0xff00ff00);
25537 // Return final computed hash
25541 clone: function () {
25542 var clone = Hasher.clone.call(this);
25543 clone._hash = this._hash.clone();
25549 function FF(a, b, c, d, x, s, t) {
25550 var n = a + ((b & c) | (~b & d)) + x + t;
25551 return ((n << s) | (n
>>> (
32 - s))) + b;
25554 function GG(a, b, c, d, x, s, t) {
25555 var n = a + ((b & d) | (c & ~d)) + x + t;
25556 return ((n << s) | (n
>>> (
32 - s))) + b;
25559 function HH(a, b, c, d, x, s, t) {
25560 var n = a + (b ^ c ^ d) + x + t;
25561 return ((n << s) | (n
>>> (
32 - s))) + b;
25564 function II(a, b, c, d, x, s, t) {
25565 var n = a + (c ^ (b | ~d)) + x + t;
25566 return ((n << s) | (n
>>> (
32 - s))) + b;
25570 * Shortcut function to the hasher's object interface.
25572 * @param {WordArray|string} message The message to hash.
25574 * @return {WordArray} The hash.
25580 * var hash = CryptoJS.MD5('message');
25581 * var hash = CryptoJS.MD5(wordArray);
25583 C.MD5 = Hasher._createHelper(MD5);
25586 * Shortcut function to the HMAC's object interface.
25588 * @param {WordArray|string} message The message to hash.
25589 * @param {WordArray|string} key The secret key.
25591 * @return {WordArray} The HMAC.
25597 * var hmac = CryptoJS.HmacMD5(message, key);
25599 C.HmacMD5 = Hasher._createHmacHelper(MD5);
25603 return CryptoJS.MD5;
25606 },{"./core":
31}],
40:[function(_dereq_,module,exports){
25607 ;(function (root, factory, undef) {
25608 if (typeof exports === "object") {
25610 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
25612 else if (typeof define === "function" && define.amd) {
25614 define(["./core", "./cipher-core"], factory);
25617 // Global (browser)
25618 factory(root.CryptoJS);
25620 }(this, function (CryptoJS) {
25623 * Cipher Feedback block mode.
25625 CryptoJS.mode.CFB = (function () {
25626 var CFB = CryptoJS.lib.BlockCipherMode.extend();
25628 CFB.Encryptor = CFB.extend({
25629 processBlock: function (words, offset) {
25631 var cipher = this._cipher;
25632 var blockSize = cipher.blockSize;
25634 generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
25636 // Remember this block to use with next block
25637 this._prevBlock = words.slice(offset, offset + blockSize);
25641 CFB.Decryptor = CFB.extend({
25642 processBlock: function (words, offset) {
25644 var cipher = this._cipher;
25645 var blockSize = cipher.blockSize;
25647 // Remember this block to use with next block
25648 var thisBlock = words.slice(offset, offset + blockSize);
25650 generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
25652 // This block becomes the previous block
25653 this._prevBlock = thisBlock;
25657 function generateKeystreamAndEncrypt(words, offset, blockSize, cipher) {
25661 // Generate keystream
25663 var keystream = iv.slice(
0);
25665 // Remove IV for subsequent blocks
25666 this._iv = undefined;
25668 var keystream = this._prevBlock;
25670 cipher.encryptBlock(keystream,
0);
25673 for (var i =
0; i < blockSize; i++) {
25674 words[offset + i] ^= keystream[i];
25682 return CryptoJS.mode.CFB;
25685 },{"./cipher-core":
30,"./core":
31}],
41:[function(_dereq_,module,exports){
25686 ;(function (root, factory, undef) {
25687 if (typeof exports === "object") {
25689 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
25691 else if (typeof define === "function" && define.amd) {
25693 define(["./core", "./cipher-core"], factory);
25696 // Global (browser)
25697 factory(root.CryptoJS);
25699 }(this, function (CryptoJS) {
25702 * Counter block mode compatible with Dr Brian Gladman fileenc.c
25703 * derived from CryptoJS.mode.CTR
25704 * Jan Hruby jhruby.web@gmail.com
25706 CryptoJS.mode.CTRGladman = (function () {
25707 var CTRGladman = CryptoJS.lib.BlockCipherMode.extend();
25709 function incWord(word)
25711 if (((word
>> 24) &
0xff) ===
0xff) { //overflow
25712 var b1 = (word
>> 16)
&0xff;
25713 var b2 = (word
>> 8)
&0xff;
25714 var b3 = word &
0xff;
25716 if (b1 ===
0xff) // overflow b1
25742 word += (b1 <<
16);
25748 word += (
0x01 <<
24);
25753 function incCounter(counter)
25755 if ((counter[
0] = incWord(counter[
0])) ===
0)
25757 // encr_data in fileenc.c from Dr Brian Gladman's counts only with DWORD j <
8
25758 counter[
1] = incWord(counter[
1]);
25763 var Encryptor = CTRGladman.Encryptor = CTRGladman.extend({
25764 processBlock: function (words, offset) {
25766 var cipher = this._cipher
25767 var blockSize = cipher.blockSize;
25769 var counter = this._counter;
25771 // Generate keystream
25773 counter = this._counter = iv.slice(
0);
25775 // Remove IV for subsequent blocks
25776 this._iv = undefined;
25779 incCounter(counter);
25781 var keystream = counter.slice(
0);
25782 cipher.encryptBlock(keystream,
0);
25785 for (var i =
0; i < blockSize; i++) {
25786 words[offset + i] ^= keystream[i];
25791 CTRGladman.Decryptor = Encryptor;
25799 return CryptoJS.mode.CTRGladman;
25802 },{
"./cipher-core":
30,
"./core":
31}],
42:[function(_dereq_,module,exports){
25803 ;(function (root, factory, undef) {
25804 if (typeof exports ===
"object") {
25806 module.exports = exports = factory(_dereq_(
"./core"), _dereq_(
"./cipher-core"));
25808 else if (typeof define ===
"function" && define.amd) {
25810 define([
"./core",
"./cipher-core"], factory);
25813 // Global (browser)
25814 factory(root.CryptoJS);
25816 }(this, function (CryptoJS) {
25819 * Counter block mode.
25821 CryptoJS.mode.CTR = (function () {
25822 var CTR = CryptoJS.lib.BlockCipherMode.extend();
25824 var Encryptor = CTR.Encryptor = CTR.extend({
25825 processBlock: function (words, offset) {
25827 var cipher = this._cipher
25828 var blockSize = cipher.blockSize;
25830 var counter = this._counter;
25832 // Generate keystream
25834 counter = this._counter = iv.slice(
0);
25836 // Remove IV for subsequent blocks
25837 this._iv = undefined;
25839 var keystream = counter.slice(
0);
25840 cipher.encryptBlock(keystream,
0);
25842 // Increment counter
25843 counter[blockSize -
1] = (counter[blockSize -
1] +
1) |
0
25846 for (var i =
0; i < blockSize; i++) {
25847 words[offset + i] ^= keystream[i];
25852 CTR.Decryptor = Encryptor;
25858 return CryptoJS.mode.CTR;
25861 },{
"./cipher-core":
30,
"./core":
31}],
43:[function(_dereq_,module,exports){
25862 ;(function (root, factory, undef) {
25863 if (typeof exports ===
"object") {
25865 module.exports = exports = factory(_dereq_(
"./core"), _dereq_(
"./cipher-core"));
25867 else if (typeof define ===
"function" && define.amd) {
25869 define([
"./core",
"./cipher-core"], factory);
25872 // Global (browser)
25873 factory(root.CryptoJS);
25875 }(this, function (CryptoJS) {
25878 * Electronic Codebook block mode.
25880 CryptoJS.mode.ECB = (function () {
25881 var ECB = CryptoJS.lib.BlockCipherMode.extend();
25883 ECB.Encryptor = ECB.extend({
25884 processBlock: function (words, offset) {
25885 this._cipher.encryptBlock(words, offset);
25889 ECB.Decryptor = ECB.extend({
25890 processBlock: function (words, offset) {
25891 this._cipher.decryptBlock(words, offset);
25899 return CryptoJS.mode.ECB;
25902 },{
"./cipher-core":
30,
"./core":
31}],
44:[function(_dereq_,module,exports){
25903 ;(function (root, factory, undef) {
25904 if (typeof exports ===
"object") {
25906 module.exports = exports = factory(_dereq_(
"./core"), _dereq_(
"./cipher-core"));
25908 else if (typeof define ===
"function" && define.amd) {
25910 define([
"./core",
"./cipher-core"], factory);
25913 // Global (browser)
25914 factory(root.CryptoJS);
25916 }(this, function (CryptoJS) {
25919 * Output Feedback block mode.
25921 CryptoJS.mode.OFB = (function () {
25922 var OFB = CryptoJS.lib.BlockCipherMode.extend();
25924 var Encryptor = OFB.Encryptor = OFB.extend({
25925 processBlock: function (words, offset) {
25927 var cipher = this._cipher
25928 var blockSize = cipher.blockSize;
25930 var keystream = this._keystream;
25932 // Generate keystream
25934 keystream = this._keystream = iv.slice(
0);
25936 // Remove IV for subsequent blocks
25937 this._iv = undefined;
25939 cipher.encryptBlock(keystream,
0);
25942 for (var i =
0; i < blockSize; i++) {
25943 words[offset + i] ^= keystream[i];
25948 OFB.Decryptor = Encryptor;
25954 return CryptoJS.mode.OFB;
25957 },{
"./cipher-core":
30,
"./core":
31}],
45:[function(_dereq_,module,exports){
25958 ;(function (root, factory, undef) {
25959 if (typeof exports ===
"object") {
25961 module.exports = exports = factory(_dereq_(
"./core"), _dereq_(
"./cipher-core"));
25963 else if (typeof define ===
"function" && define.amd) {
25965 define([
"./core",
"./cipher-core"], factory);
25968 // Global (browser)
25969 factory(root.CryptoJS);
25971 }(this, function (CryptoJS) {
25974 * ANSI X
.923 padding strategy.
25976 CryptoJS.pad.AnsiX923 = {
25977 pad: function (data, blockSize) {
25979 var dataSigBytes = data.sigBytes;
25980 var blockSizeBytes = blockSize *
4;
25982 // Count padding bytes
25983 var nPaddingBytes = blockSizeBytes - dataSigBytes % blockSizeBytes;
25985 // Compute last byte position
25986 var lastBytePos = dataSigBytes + nPaddingBytes -
1;
25990 data.words[lastBytePos
>>> 2] |= nPaddingBytes << (
24 - (lastBytePos %
4) *
8);
25991 data.sigBytes += nPaddingBytes;
25994 unpad: function (data) {
25995 // Get number of padding bytes from last byte
25996 var nPaddingBytes = data.words[(data.sigBytes -
1)
>>> 2] &
0xff;
25999 data.sigBytes -= nPaddingBytes;
26004 return CryptoJS.pad.Ansix923;
26007 },{
"./cipher-core":
30,
"./core":
31}],
46:[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 * ISO
10126 padding strategy.
26026 CryptoJS.pad.Iso10126 = {
26027 pad: function (data, blockSize) {
26029 var blockSizeBytes = blockSize *
4;
26031 // Count padding bytes
26032 var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
26035 data.concat(CryptoJS.lib.WordArray.random(nPaddingBytes -
1)).
26036 concat(CryptoJS.lib.WordArray.create([nPaddingBytes <<
24],
1));
26039 unpad: function (data) {
26040 // Get number of padding bytes from last byte
26041 var nPaddingBytes = data.words[(data.sigBytes -
1)
>>> 2] &
0xff;
26044 data.sigBytes -= nPaddingBytes;
26049 return CryptoJS.pad.Iso10126;
26052 },{
"./cipher-core":
30,
"./core":
31}],
47:[function(_dereq_,module,exports){
26053 ;(function (root, factory, undef) {
26054 if (typeof exports ===
"object") {
26056 module.exports = exports = factory(_dereq_(
"./core"), _dereq_(
"./cipher-core"));
26058 else if (typeof define ===
"function" && define.amd) {
26060 define([
"./core",
"./cipher-core"], factory);
26063 // Global (browser)
26064 factory(root.CryptoJS);
26066 }(this, function (CryptoJS) {
26069 * ISO/IEC
9797-
1 Padding Method
2.
26071 CryptoJS.pad.Iso97971 = {
26072 pad: function (data, blockSize) {
26074 data.concat(CryptoJS.lib.WordArray.create([
0x80000000],
1));
26076 // Zero pad the rest
26077 CryptoJS.pad.ZeroPadding.pad(data, blockSize);
26080 unpad: function (data) {
26081 // Remove zero padding
26082 CryptoJS.pad.ZeroPadding.unpad(data);
26084 // Remove one more byte -- the
0x80 byte
26090 return CryptoJS.pad.Iso97971;
26093 },{
"./cipher-core":
30,
"./core":
31}],
48:[function(_dereq_,module,exports){
26094 ;(function (root, factory, undef) {
26095 if (typeof exports ===
"object") {
26097 module.exports = exports = factory(_dereq_(
"./core"), _dereq_(
"./cipher-core"));
26099 else if (typeof define ===
"function" && define.amd) {
26101 define([
"./core",
"./cipher-core"], factory);
26104 // Global (browser)
26105 factory(root.CryptoJS);
26107 }(this, function (CryptoJS) {
26110 * A noop padding strategy.
26112 CryptoJS.pad.NoPadding = {
26116 unpad: function () {
26121 return CryptoJS.pad.NoPadding;
26124 },{
"./cipher-core":
30,
"./core":
31}],
49:[function(_dereq_,module,exports){
26125 ;(function (root, factory, undef) {
26126 if (typeof exports ===
"object") {
26128 module.exports = exports = factory(_dereq_(
"./core"), _dereq_(
"./cipher-core"));
26130 else if (typeof define ===
"function" && define.amd) {
26132 define([
"./core",
"./cipher-core"], factory);
26135 // Global (browser)
26136 factory(root.CryptoJS);
26138 }(this, function (CryptoJS) {
26141 * Zero padding strategy.
26143 CryptoJS.pad.ZeroPadding = {
26144 pad: function (data, blockSize) {
26146 var blockSizeBytes = blockSize *
4;
26150 data.sigBytes += blockSizeBytes - ((data.sigBytes % blockSizeBytes) || blockSizeBytes);
26153 unpad: function (data) {
26155 var dataWords = data.words;
26158 var i = data.sigBytes -
1;
26159 while (!((dataWords[i
>>> 2]
>>> (
24 - (i %
4) *
8)) &
0xff)) {
26162 data.sigBytes = i +
1;
26167 return CryptoJS.pad.ZeroPadding;
26170 },{"./cipher-core":
30,"./core":
31}],
50:[function(_dereq_,module,exports){
26171 ;(function (root, factory, undef) {
26172 if (typeof exports === "object") {
26174 module.exports = exports = factory(_dereq_("./core"), _dereq_("./sha1"), _dereq_("./hmac"));
26176 else if (typeof define === "function" && define.amd) {
26178 define(["./core", "./sha1", "./hmac"], factory);
26181 // Global (browser)
26182 factory(root.CryptoJS);
26184 }(this, function (CryptoJS) {
26190 var Base = C_lib.Base;
26191 var WordArray = C_lib.WordArray;
26192 var C_algo = C.algo;
26193 var SHA1 = C_algo.SHA1;
26194 var HMAC = C_algo.HMAC;
26197 * Password-Based Key Derivation Function
2 algorithm.
26199 var PBKDF2 = C_algo.PBKDF2 = Base.extend({
26201 * Configuration options.
26203 * @property {number} keySize The key size in words to generate. Default:
4 (
128 bits)
26204 * @property {Hasher} hasher The hasher to use. Default: SHA1
26205 * @property {number} iterations The number of iterations to perform. Default:
1
26214 * Initializes a newly created key derivation function.
26216 * @param {Object} cfg (Optional) The configuration options to use for the derivation.
26220 * var kdf = CryptoJS.algo.PBKDF2.create();
26221 * var kdf = CryptoJS.algo.PBKDF2.create({ keySize:
8 });
26222 * var kdf = CryptoJS.algo.PBKDF2.create({ keySize:
8, iterations:
1000 });
26224 init: function (cfg) {
26225 this.cfg = this.cfg.extend(cfg);
26229 * Computes the Password-Based Key Derivation Function
2.
26231 * @param {WordArray|string} password The password.
26232 * @param {WordArray|string} salt A salt.
26234 * @return {WordArray} The derived key.
26238 * var key = kdf.compute(password, salt);
26240 compute: function (password, salt) {
26242 var cfg = this.cfg;
26245 var hmac = HMAC.create(cfg.hasher, password);
26248 var derivedKey = WordArray.create();
26249 var blockIndex = WordArray.create([
0x00000001]);
26252 var derivedKeyWords = derivedKey.words;
26253 var blockIndexWords = blockIndex.words;
26254 var keySize = cfg.keySize;
26255 var iterations = cfg.iterations;
26258 while (derivedKeyWords.length < keySize) {
26259 var block = hmac.update(salt).finalize(blockIndex);
26263 var blockWords = block.words;
26264 var blockWordsLength = blockWords.length;
26267 var intermediate = block;
26268 for (var i =
1; i < iterations; i++) {
26269 intermediate = hmac.finalize(intermediate);
26273 var intermediateWords = intermediate.words;
26275 // XOR intermediate with block
26276 for (var j =
0; j < blockWordsLength; j++) {
26277 blockWords[j] ^= intermediateWords[j];
26281 derivedKey.concat(block);
26282 blockIndexWords[
0]++;
26284 derivedKey.sigBytes = keySize *
4;
26291 * Computes the Password-Based Key Derivation Function
2.
26293 * @param {WordArray|string} password The password.
26294 * @param {WordArray|string} salt A salt.
26295 * @param {Object} cfg (Optional) The configuration options to use for this computation.
26297 * @return {WordArray} The derived key.
26303 * var key = CryptoJS.PBKDF2(password, salt);
26304 * var key = CryptoJS.PBKDF2(password, salt, { keySize:
8 });
26305 * var key = CryptoJS.PBKDF2(password, salt, { keySize:
8, iterations:
1000 });
26307 C.PBKDF2 = function (password, salt, cfg) {
26308 return PBKDF2.create(cfg).compute(password, salt);
26313 return CryptoJS.PBKDF2;
26316 },{"./core":
31,"./hmac":
36,"./sha1":
55}],
51:[function(_dereq_,module,exports){
26317 ;(function (root, factory, undef) {
26318 if (typeof exports === "object") {
26320 module.exports = exports = factory(_dereq_("./core"), _dereq_("./enc-base64"), _dereq_("./md5"), _dereq_("./evpkdf"), _dereq_("./cipher-core"));
26322 else if (typeof define === "function" && define.amd) {
26324 define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
26327 // Global (browser)
26328 factory(root.CryptoJS);
26330 }(this, function (CryptoJS) {
26336 var StreamCipher = C_lib.StreamCipher;
26337 var C_algo = C.algo;
26339 // Reusable objects
26345 * Rabbit stream cipher algorithm.
26347 * This is a legacy version that neglected to convert the key to little-endian.
26348 * This error doesn't affect the cipher's security,
26349 * but it does affect its compatibility with other implementations.
26351 var RabbitLegacy = C_algo.RabbitLegacy = StreamCipher.extend({
26352 _doReset: function () {
26354 var K = this._key.words;
26355 var iv = this.cfg.iv;
26357 // Generate initial state values
26358 var X = this._X = [
26359 K[
0], (K[
3] <<
16) | (K[
2]
>>> 16),
26360 K[
1], (K[
0] <<
16) | (K[
3]
>>> 16),
26361 K[
2], (K[
1] <<
16) | (K[
0]
>>> 16),
26362 K[
3], (K[
2] <<
16) | (K[
1]
>>> 16)
26365 // Generate initial counter values
26366 var C = this._C = [
26367 (K[
2] <<
16) | (K[
2]
>>> 16), (K[
0] &
0xffff0000) | (K[
1] &
0x0000ffff),
26368 (K[
3] <<
16) | (K[
3]
>>> 16), (K[
1] &
0xffff0000) | (K[
2] &
0x0000ffff),
26369 (K[
0] <<
16) | (K[
0]
>>> 16), (K[
2] &
0xffff0000) | (K[
3] &
0x0000ffff),
26370 (K[
1] <<
16) | (K[
1]
>>> 16), (K[
3] &
0xffff0000) | (K[
0] &
0x0000ffff)
26376 // Iterate the system four times
26377 for (var i =
0; i <
4; i++) {
26378 nextState.call(this);
26381 // Modify the counters
26382 for (var i =
0; i <
8; i++) {
26383 C[i] ^= X[(i +
4) &
7];
26393 // Generate four subvectors
26394 var i0 = (((IV_0 <<
8) | (IV_0
>>> 24)) &
0x00ff00ff) | (((IV_0 <<
24) | (IV_0
>>> 8)) &
0xff00ff00);
26395 var i2 = (((IV_1 <<
8) | (IV_1
>>> 24)) &
0x00ff00ff) | (((IV_1 <<
24) | (IV_1
>>> 8)) &
0xff00ff00);
26396 var i1 = (i0
>>> 16) | (i2 &
0xffff0000);
26397 var i3 = (i2 <<
16) | (i0 &
0x0000ffff);
26399 // Modify counter values
26409 // Iterate the system four times
26410 for (var i =
0; i <
4; i++) {
26411 nextState.call(this);
26416 _doProcessBlock: function (M, offset) {
26420 // Iterate the system
26421 nextState.call(this);
26423 // Generate four keystream words
26424 S[
0] = X[
0] ^ (X[
5]
>>> 16) ^ (X[
3] <<
16);
26425 S[
1] = X[
2] ^ (X[
7]
>>> 16) ^ (X[
5] <<
16);
26426 S[
2] = X[
4] ^ (X[
1]
>>> 16) ^ (X[
7] <<
16);
26427 S[
3] = X[
6] ^ (X[
3]
>>> 16) ^ (X[
1] <<
16);
26429 for (var i =
0; i <
4; i++) {
26431 S[i] = (((S[i] <<
8) | (S[i]
>>> 24)) &
0x00ff00ff) |
26432 (((S[i] <<
24) | (S[i]
>>> 8)) &
0xff00ff00);
26435 M[offset + i] ^= S[i];
26444 function nextState() {
26449 // Save old counter values
26450 for (var i =
0; i <
8; i++) {
26454 // Calculate new counter values
26455 C[
0] = (C[
0] +
0x4d34d34d + this._b) |
0;
26456 C[
1] = (C[
1] +
0xd34d34d3 + ((C[
0]
>>> 0) < (C_[
0]
>>> 0) ?
1 :
0)) |
0;
26457 C[
2] = (C[
2] +
0x34d34d34 + ((C[
1]
>>> 0) < (C_[
1]
>>> 0) ?
1 :
0)) |
0;
26458 C[
3] = (C[
3] +
0x4d34d34d + ((C[
2]
>>> 0) < (C_[
2]
>>> 0) ?
1 :
0)) |
0;
26459 C[
4] = (C[
4] +
0xd34d34d3 + ((C[
3]
>>> 0) < (C_[
3]
>>> 0) ?
1 :
0)) |
0;
26460 C[
5] = (C[
5] +
0x34d34d34 + ((C[
4]
>>> 0) < (C_[
4]
>>> 0) ?
1 :
0)) |
0;
26461 C[
6] = (C[
6] +
0x4d34d34d + ((C[
5]
>>> 0) < (C_[
5]
>>> 0) ?
1 :
0)) |
0;
26462 C[
7] = (C[
7] +
0xd34d34d3 + ((C[
6]
>>> 0) < (C_[
6]
>>> 0) ?
1 :
0)) |
0;
26463 this._b = (C[
7]
>>> 0) < (C_[
7]
>>> 0) ?
1 :
0;
26465 // Calculate the g-values
26466 for (var i =
0; i <
8; i++) {
26467 var gx = X[i] + C[i];
26469 // Construct high and low argument for squaring
26470 var ga = gx &
0xffff;
26471 var gb = gx
>>> 16;
26473 // Calculate high and low result of squaring
26474 var gh = ((((ga * ga)
>>> 17) + ga * gb)
>>> 15) + gb * gb;
26475 var gl = (((gx &
0xffff0000) * gx) |
0) + (((gx &
0x0000ffff) * gx) |
0);
26481 // Calculate new state values
26482 X[
0] = (G[
0] + ((G[
7] <<
16) | (G[
7]
>>> 16)) + ((G[
6] <<
16) | (G[
6]
>>> 16))) |
0;
26483 X[
1] = (G[
1] + ((G[
0] <<
8) | (G[
0]
>>> 24)) + G[
7]) |
0;
26484 X[
2] = (G[
2] + ((G[
1] <<
16) | (G[
1]
>>> 16)) + ((G[
0] <<
16) | (G[
0]
>>> 16))) |
0;
26485 X[
3] = (G[
3] + ((G[
2] <<
8) | (G[
2]
>>> 24)) + G[
1]) |
0;
26486 X[
4] = (G[
4] + ((G[
3] <<
16) | (G[
3]
>>> 16)) + ((G[
2] <<
16) | (G[
2]
>>> 16))) |
0;
26487 X[
5] = (G[
5] + ((G[
4] <<
8) | (G[
4]
>>> 24)) + G[
3]) |
0;
26488 X[
6] = (G[
6] + ((G[
5] <<
16) | (G[
5]
>>> 16)) + ((G[
4] <<
16) | (G[
4]
>>> 16))) |
0;
26489 X[
7] = (G[
7] + ((G[
6] <<
8) | (G[
6]
>>> 24)) + G[
5]) |
0;
26493 * Shortcut functions to the cipher's object interface.
26497 * var ciphertext = CryptoJS.RabbitLegacy.encrypt(message, key, cfg);
26498 * var plaintext = CryptoJS.RabbitLegacy.decrypt(ciphertext, key, cfg);
26500 C.RabbitLegacy = StreamCipher._createHelper(RabbitLegacy);
26504 return CryptoJS.RabbitLegacy;
26507 },{
"./cipher-core":
30,
"./core":
31,
"./enc-base64":
32,
"./evpkdf":
34,
"./md5":
39}],
52:[function(_dereq_,module,exports){
26508 ;(function (root, factory, undef) {
26509 if (typeof exports ===
"object") {
26511 module.exports = exports = factory(_dereq_(
"./core"), _dereq_(
"./enc-base64"), _dereq_(
"./md5"), _dereq_(
"./evpkdf"), _dereq_(
"./cipher-core"));
26513 else if (typeof define ===
"function" && define.amd) {
26515 define([
"./core",
"./enc-base64",
"./md5",
"./evpkdf",
"./cipher-core"], factory);
26518 // Global (browser)
26519 factory(root.CryptoJS);
26521 }(this, function (CryptoJS) {
26527 var StreamCipher = C_lib.StreamCipher;
26528 var C_algo = C.algo;
26530 // Reusable objects
26536 * Rabbit stream cipher algorithm
26538 var Rabbit = C_algo.Rabbit = StreamCipher.extend({
26539 _doReset: function () {
26541 var K = this._key.words;
26542 var iv = this.cfg.iv;
26545 for (var i =
0; i <
4; i++) {
26546 K[i] = (((K[i] <<
8) | (K[i]
>>> 24)) &
0x00ff00ff) |
26547 (((K[i] <<
24) | (K[i]
>>> 8)) &
0xff00ff00);
26550 // Generate initial state values
26551 var X = this._X = [
26552 K[
0], (K[
3] <<
16) | (K[
2]
>>> 16),
26553 K[
1], (K[
0] <<
16) | (K[
3]
>>> 16),
26554 K[
2], (K[
1] <<
16) | (K[
0]
>>> 16),
26555 K[
3], (K[
2] <<
16) | (K[
1]
>>> 16)
26558 // Generate initial counter values
26559 var C = this._C = [
26560 (K[
2] <<
16) | (K[
2]
>>> 16), (K[
0] &
0xffff0000) | (K[
1] &
0x0000ffff),
26561 (K[
3] <<
16) | (K[
3]
>>> 16), (K[
1] &
0xffff0000) | (K[
2] &
0x0000ffff),
26562 (K[
0] <<
16) | (K[
0]
>>> 16), (K[
2] &
0xffff0000) | (K[
3] &
0x0000ffff),
26563 (K[
1] <<
16) | (K[
1]
>>> 16), (K[
3] &
0xffff0000) | (K[
0] &
0x0000ffff)
26569 // Iterate the system four times
26570 for (var i =
0; i <
4; i++) {
26571 nextState.call(this);
26574 // Modify the counters
26575 for (var i =
0; i <
8; i++) {
26576 C[i] ^= X[(i +
4) &
7];
26586 // Generate four subvectors
26587 var i0 = (((IV_0 <<
8) | (IV_0
>>> 24)) &
0x00ff00ff) | (((IV_0 <<
24) | (IV_0
>>> 8)) &
0xff00ff00);
26588 var i2 = (((IV_1 <<
8) | (IV_1
>>> 24)) &
0x00ff00ff) | (((IV_1 <<
24) | (IV_1
>>> 8)) &
0xff00ff00);
26589 var i1 = (i0
>>> 16) | (i2 &
0xffff0000);
26590 var i3 = (i2 <<
16) | (i0 &
0x0000ffff);
26592 // Modify counter values
26602 // Iterate the system four times
26603 for (var i =
0; i <
4; i++) {
26604 nextState.call(this);
26609 _doProcessBlock: function (M, offset) {
26613 // Iterate the system
26614 nextState.call(this);
26616 // Generate four keystream words
26617 S[
0] = X[
0] ^ (X[
5]
>>> 16) ^ (X[
3] <<
16);
26618 S[
1] = X[
2] ^ (X[
7]
>>> 16) ^ (X[
5] <<
16);
26619 S[
2] = X[
4] ^ (X[
1]
>>> 16) ^ (X[
7] <<
16);
26620 S[
3] = X[
6] ^ (X[
3]
>>> 16) ^ (X[
1] <<
16);
26622 for (var i =
0; i <
4; i++) {
26624 S[i] = (((S[i] <<
8) | (S[i]
>>> 24)) &
0x00ff00ff) |
26625 (((S[i] <<
24) | (S[i]
>>> 8)) &
0xff00ff00);
26628 M[offset + i] ^= S[i];
26637 function nextState() {
26642 // Save old counter values
26643 for (var i =
0; i <
8; i++) {
26647 // Calculate new counter values
26648 C[
0] = (C[
0] +
0x4d34d34d + this._b) |
0;
26649 C[
1] = (C[
1] +
0xd34d34d3 + ((C[
0]
>>> 0) < (C_[
0]
>>> 0) ?
1 :
0)) |
0;
26650 C[
2] = (C[
2] +
0x34d34d34 + ((C[
1]
>>> 0) < (C_[
1]
>>> 0) ?
1 :
0)) |
0;
26651 C[
3] = (C[
3] +
0x4d34d34d + ((C[
2]
>>> 0) < (C_[
2]
>>> 0) ?
1 :
0)) |
0;
26652 C[
4] = (C[
4] +
0xd34d34d3 + ((C[
3]
>>> 0) < (C_[
3]
>>> 0) ?
1 :
0)) |
0;
26653 C[
5] = (C[
5] +
0x34d34d34 + ((C[
4]
>>> 0) < (C_[
4]
>>> 0) ?
1 :
0)) |
0;
26654 C[
6] = (C[
6] +
0x4d34d34d + ((C[
5]
>>> 0) < (C_[
5]
>>> 0) ?
1 :
0)) |
0;
26655 C[
7] = (C[
7] +
0xd34d34d3 + ((C[
6]
>>> 0) < (C_[
6]
>>> 0) ?
1 :
0)) |
0;
26656 this._b = (C[
7]
>>> 0) < (C_[
7]
>>> 0) ?
1 :
0;
26658 // Calculate the g-values
26659 for (var i =
0; i <
8; i++) {
26660 var gx = X[i] + C[i];
26662 // Construct high and low argument for squaring
26663 var ga = gx &
0xffff;
26664 var gb = gx
>>> 16;
26666 // Calculate high and low result of squaring
26667 var gh = ((((ga * ga)
>>> 17) + ga * gb)
>>> 15) + gb * gb;
26668 var gl = (((gx &
0xffff0000) * gx) |
0) + (((gx &
0x0000ffff) * gx) |
0);
26674 // Calculate new state values
26675 X[
0] = (G[
0] + ((G[
7] <<
16) | (G[
7]
>>> 16)) + ((G[
6] <<
16) | (G[
6]
>>> 16))) |
0;
26676 X[
1] = (G[
1] + ((G[
0] <<
8) | (G[
0]
>>> 24)) + G[
7]) |
0;
26677 X[
2] = (G[
2] + ((G[
1] <<
16) | (G[
1]
>>> 16)) + ((G[
0] <<
16) | (G[
0]
>>> 16))) |
0;
26678 X[
3] = (G[
3] + ((G[
2] <<
8) | (G[
2]
>>> 24)) + G[
1]) |
0;
26679 X[
4] = (G[
4] + ((G[
3] <<
16) | (G[
3]
>>> 16)) + ((G[
2] <<
16) | (G[
2]
>>> 16))) |
0;
26680 X[
5] = (G[
5] + ((G[
4] <<
8) | (G[
4]
>>> 24)) + G[
3]) |
0;
26681 X[
6] = (G[
6] + ((G[
5] <<
16) | (G[
5]
>>> 16)) + ((G[
4] <<
16) | (G[
4]
>>> 16))) |
0;
26682 X[
7] = (G[
7] + ((G[
6] <<
8) | (G[
6]
>>> 24)) + G[
5]) |
0;
26686 * Shortcut functions to the cipher's object interface.
26690 * var ciphertext = CryptoJS.Rabbit.encrypt(message, key, cfg);
26691 * var plaintext = CryptoJS.Rabbit.decrypt(ciphertext, key, cfg);
26693 C.Rabbit = StreamCipher._createHelper(Rabbit);
26697 return CryptoJS.Rabbit;
26700 },{
"./cipher-core":
30,
"./core":
31,
"./enc-base64":
32,
"./evpkdf":
34,
"./md5":
39}],
53:[function(_dereq_,module,exports){
26701 ;(function (root, factory, undef) {
26702 if (typeof exports ===
"object") {
26704 module.exports = exports = factory(_dereq_(
"./core"), _dereq_(
"./enc-base64"), _dereq_(
"./md5"), _dereq_(
"./evpkdf"), _dereq_(
"./cipher-core"));
26706 else if (typeof define ===
"function" && define.amd) {
26708 define([
"./core",
"./enc-base64",
"./md5",
"./evpkdf",
"./cipher-core"], factory);
26711 // Global (browser)
26712 factory(root.CryptoJS);
26714 }(this, function (CryptoJS) {
26720 var StreamCipher = C_lib.StreamCipher;
26721 var C_algo = C.algo;
26724 * RC4 stream cipher algorithm.
26726 var RC4 = C_algo.RC4 = StreamCipher.extend({
26727 _doReset: function () {
26729 var key = this._key;
26730 var keyWords = key.words;
26731 var keySigBytes = key.sigBytes;
26734 var S = this._S = [];
26735 for (var i =
0; i <
256; i++) {
26740 for (var i =
0, j =
0; i <
256; i++) {
26741 var keyByteIndex = i % keySigBytes;
26742 var keyByte = (keyWords[keyByteIndex
>>> 2]
>>> (
24 - (keyByteIndex %
4) *
8)) &
0xff;
26744 j = (j + S[i] + keyByte) %
256;
26753 this._i = this._j =
0;
26756 _doProcessBlock: function (M, offset) {
26757 M[offset] ^= generateKeystreamWord.call(this);
26765 function generateKeystreamWord() {
26771 // Generate keystream word
26772 var keystreamWord =
0;
26773 for (var n =
0; n <
4; n++) {
26775 j = (j + S[i]) %
256;
26782 keystreamWord |= S[(S[i] + S[j]) %
256] << (
24 - n *
8);
26789 return keystreamWord;
26793 * Shortcut functions to the cipher's object interface.
26797 * var ciphertext = CryptoJS.RC4.encrypt(message, key, cfg);
26798 * var plaintext = CryptoJS.RC4.decrypt(ciphertext, key, cfg);
26800 C.RC4 = StreamCipher._createHelper(RC4);
26803 * Modified RC4 stream cipher algorithm.
26805 var RC4Drop = C_algo.RC4Drop = RC4.extend({
26807 * Configuration options.
26809 * @property {number} drop The number of keystream words to drop. Default
192
26811 cfg: RC4.cfg.extend({
26815 _doReset: function () {
26816 RC4._doReset.call(this);
26819 for (var i = this.cfg.drop; i
> 0; i--) {
26820 generateKeystreamWord.call(this);
26826 * Shortcut functions to the cipher's object interface.
26830 * var ciphertext = CryptoJS.RC4Drop.encrypt(message, key, cfg);
26831 * var plaintext = CryptoJS.RC4Drop.decrypt(ciphertext, key, cfg);
26833 C.RC4Drop = StreamCipher._createHelper(RC4Drop);
26837 return CryptoJS.RC4;
26840 },{
"./cipher-core":
30,
"./core":
31,
"./enc-base64":
32,
"./evpkdf":
34,
"./md5":
39}],
54:[function(_dereq_,module,exports){
26841 ;(function (root, factory) {
26842 if (typeof exports ===
"object") {
26844 module.exports = exports = factory(_dereq_(
"./core"));
26846 else if (typeof define ===
"function" && define.amd) {
26848 define([
"./core"], factory);
26851 // Global (browser)
26852 factory(root.CryptoJS);
26854 }(this, function (CryptoJS) {
26857 (c)
2012 by Cédric Mesnil. All rights reserved.
26859 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
26861 - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
26862 - 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.
26864 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.
26871 var WordArray = C_lib.WordArray;
26872 var Hasher = C_lib.Hasher;
26873 var C_algo = C.algo;
26876 var _zl = WordArray.create([
26877 0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
26878 7,
4,
13,
1,
10,
6,
15,
3,
12,
0,
9,
5,
2,
14,
11,
8,
26879 3,
10,
14,
4,
9,
15,
8,
1,
2,
7,
0,
6,
13,
11,
5,
12,
26880 1,
9,
11,
10,
0,
8,
12,
4,
13,
3,
7,
15,
14,
5,
6,
2,
26881 4,
0,
5,
9,
7,
12,
2,
10,
14,
1,
3,
8,
11,
6,
15,
13]);
26882 var _zr = WordArray.create([
26883 5,
14,
7,
0,
9,
2,
11,
4,
13,
6,
15,
8,
1,
10,
3,
12,
26884 6,
11,
3,
7,
0,
13,
5,
10,
14,
15,
8,
12,
4,
9,
1,
2,
26885 15,
5,
1,
3,
7,
14,
6,
9,
11,
8,
12,
2,
10,
0,
4,
13,
26886 8,
6,
4,
1,
3,
11,
15,
0,
5,
12,
2,
13,
9,
7,
10,
14,
26887 12,
15,
10,
4,
1,
5,
8,
7,
6,
2,
13,
14,
0,
3,
9,
11]);
26888 var _sl = WordArray.create([
26889 11,
14,
15,
12,
5,
8,
7,
9,
11,
13,
14,
15,
6,
7,
9,
8,
26890 7,
6,
8,
13,
11,
9,
7,
15,
7,
12,
15,
9,
11,
7,
13,
12,
26891 11,
13,
6,
7,
14,
9,
13,
15,
14,
8,
13,
6,
5,
12,
7,
5,
26892 11,
12,
14,
15,
14,
15,
9,
8,
9,
14,
5,
6,
8,
6,
5,
12,
26893 9,
15,
5,
11,
6,
8,
13,
12,
5,
12,
13,
14,
11,
8,
5,
6 ]);
26894 var _sr = WordArray.create([
26895 8,
9,
9,
11,
13,
15,
15,
5,
7,
7,
8,
11,
14,
14,
12,
6,
26896 9,
13,
15,
7,
12,
8,
9,
11,
7,
7,
12,
7,
6,
15,
13,
11,
26897 9,
7,
15,
11,
8,
6,
6,
14,
12,
13,
5,
14,
13,
13,
7,
5,
26898 15,
5,
8,
11,
14,
14,
6,
14,
6,
9,
12,
9,
12,
5,
15,
8,
26899 8,
5,
12,
9,
12,
5,
14,
6,
8,
13,
6,
5,
15,
13,
11,
11 ]);
26901 var _hl = WordArray.create([
0x00000000,
0x5A827999,
0x6ED9EBA1,
0x8F1BBCDC,
0xA953FD4E]);
26902 var _hr = WordArray.create([
0x50A28BE6,
0x5C4DD124,
0x6D703EF3,
0x7A6D76E9,
0x00000000]);
26905 * RIPEMD160 hash algorithm.
26907 var RIPEMD160 = C_algo.RIPEMD160 = Hasher.extend({
26908 _doReset: function () {
26909 this._hash = WordArray.create([
0x67452301,
0xEFCDAB89,
0x98BADCFE,
0x10325476,
0xC3D2E1F0]);
26912 _doProcessBlock: function (M, offset) {
26915 for (var i =
0; i <
16; i++) {
26917 var offset_i = offset + i;
26918 var M_offset_i = M[offset_i];
26922 (((M_offset_i <<
8) | (M_offset_i
>>> 24)) &
0x00ff00ff) |
26923 (((M_offset_i <<
24) | (M_offset_i
>>> 8)) &
0xff00ff00)
26927 var H = this._hash.words;
26928 var hl = _hl.words;
26929 var hr = _hr.words;
26930 var zl = _zl.words;
26931 var zr = _zr.words;
26932 var sl = _sl.words;
26933 var sr = _sr.words;
26935 // Working variables
26936 var al, bl, cl, dl, el;
26937 var ar, br, cr, dr, er;
26946 for (var i =
0; i <
80; i +=
1) {
26947 t = (al + M[offset+zl[i]])|
0;
26949 t += f1(bl,cl,dl) + hl[
0];
26951 t += f2(bl,cl,dl) + hl[
1];
26953 t += f3(bl,cl,dl) + hl[
2];
26955 t += f4(bl,cl,dl) + hl[
3];
26956 } else {// if (i
<80) {
26957 t += f5(bl,cl,dl) + hl[
4];
26968 t = (ar + M[offset+zr[i]])|
0;
26970 t += f5(br,cr,dr) + hr[
0];
26972 t += f4(br,cr,dr) + hr[
1];
26974 t += f3(br,cr,dr) + hr[
2];
26976 t += f2(br,cr,dr) + hr[
3];
26977 } else {// if (i
<80) {
26978 t += f1(br,cr,dr) + hr[
4];
26981 t = rotl(t,sr[i]) ;
26989 // Intermediate hash value
26990 t = (H[
1] + cl + dr)|
0;
26991 H[
1] = (H[
2] + dl + er)|
0;
26992 H[
2] = (H[
3] + el + ar)|
0;
26993 H[
3] = (H[
4] + al + br)|
0;
26994 H[
4] = (H[
0] + bl + cr)|
0;
26998 _doFinalize: function () {
27000 var data = this._data;
27001 var dataWords = data.words;
27003 var nBitsTotal = this._nDataBytes *
8;
27004 var nBitsLeft = data.sigBytes *
8;
27007 dataWords[nBitsLeft
>>> 5] |=
0x80 << (
24 - nBitsLeft %
32);
27008 dataWords[(((nBitsLeft +
64)
>>> 9) <<
4) +
14] = (
27009 (((nBitsTotal <<
8) | (nBitsTotal
>>> 24)) &
0x00ff00ff) |
27010 (((nBitsTotal <<
24) | (nBitsTotal
>>> 8)) &
0xff00ff00)
27012 data.sigBytes = (dataWords.length +
1) *
4;
27014 // Hash final blocks
27018 var hash = this._hash;
27019 var H = hash.words;
27022 for (var i =
0; i <
5; i++) {
27027 H[i] = (((H_i <<
8) | (H_i
>>> 24)) &
0x00ff00ff) |
27028 (((H_i <<
24) | (H_i
>>> 8)) &
0xff00ff00);
27031 // Return final computed hash
27035 clone: function () {
27036 var clone = Hasher.clone.call(this);
27037 clone._hash = this._hash.clone();
27044 function f1(x, y, z) {
27045 return ((x) ^ (y) ^ (z));
27049 function f2(x, y, z) {
27050 return (((x)&(y)) | ((~x)&(z)));
27053 function f3(x, y, z) {
27054 return (((x) | (~(y))) ^ (z));
27057 function f4(x, y, z) {
27058 return (((x) & (z)) | ((y)&(~(z))));
27061 function f5(x, y, z) {
27062 return ((x) ^ ((y) |(~(z))));
27066 function rotl(x,n) {
27067 return (x<
<n) | (x
>>>(
32-n));
27072 * Shortcut function to the hasher's object interface.
27074 * @param {WordArray|string} message The message to hash.
27076 * @return {WordArray} The hash.
27082 * var hash = CryptoJS.RIPEMD160('message');
27083 * var hash = CryptoJS.RIPEMD160(wordArray);
27085 C.RIPEMD160 = Hasher._createHelper(RIPEMD160);
27088 * Shortcut function to the HMAC's object interface.
27090 * @param {WordArray|string} message The message to hash.
27091 * @param {WordArray|string} key The secret key.
27093 * @return {WordArray} The HMAC.
27099 * var hmac = CryptoJS.HmacRIPEMD160(message, key);
27101 C.HmacRIPEMD160 = Hasher._createHmacHelper(RIPEMD160);
27105 return CryptoJS.RIPEMD160;
27108 },{"./core":
31}],
55:[function(_dereq_,module,exports){
27109 ;(function (root, factory) {
27110 if (typeof exports === "object") {
27112 module.exports = exports = factory(_dereq_("./core"));
27114 else if (typeof define === "function" && define.amd) {
27116 define(["./core"], factory);
27119 // Global (browser)
27120 factory(root.CryptoJS);
27122 }(this, function (CryptoJS) {
27128 var WordArray = C_lib.WordArray;
27129 var Hasher = C_lib.Hasher;
27130 var C_algo = C.algo;
27136 * SHA-
1 hash algorithm.
27138 var SHA1 = C_algo.SHA1 = Hasher.extend({
27139 _doReset: function () {
27140 this._hash = new WordArray.init([
27141 0x67452301,
0xefcdab89,
27142 0x98badcfe,
0x10325476,
27147 _doProcessBlock: function (M, offset) {
27149 var H = this._hash.words;
27151 // Working variables
27159 for (var i =
0; i <
80; i++) {
27161 W[i] = M[offset + i] |
0;
27163 var n = W[i -
3] ^ W[i -
8] ^ W[i -
14] ^ W[i -
16];
27164 W[i] = (n <<
1) | (n
>>> 31);
27167 var t = ((a <<
5) | (a
>>> 27)) + e + W[i];
27169 t += ((b & c) | (~b & d)) +
0x5a827999;
27170 } else if (i <
40) {
27171 t += (b ^ c ^ d) +
0x6ed9eba1;
27172 } else if (i <
60) {
27173 t += ((b & c) | (b & d) | (c & d)) -
0x70e44324;
27174 } else /* if (i <
80) */ {
27175 t += (b ^ c ^ d) -
0x359d3e2a;
27180 c = (b <<
30) | (b
>>> 2);
27185 // Intermediate hash value
27186 H[
0] = (H[
0] + a) |
0;
27187 H[
1] = (H[
1] + b) |
0;
27188 H[
2] = (H[
2] + c) |
0;
27189 H[
3] = (H[
3] + d) |
0;
27190 H[
4] = (H[
4] + e) |
0;
27193 _doFinalize: function () {
27195 var data = this._data;
27196 var dataWords = data.words;
27198 var nBitsTotal = this._nDataBytes *
8;
27199 var nBitsLeft = data.sigBytes *
8;
27202 dataWords[nBitsLeft
>>> 5] |=
0x80 << (
24 - nBitsLeft %
32);
27203 dataWords[(((nBitsLeft +
64)
>>> 9) <<
4) +
14] = Math.floor(nBitsTotal /
0x100000000);
27204 dataWords[(((nBitsLeft +
64)
>>> 9) <<
4) +
15] = nBitsTotal;
27205 data.sigBytes = dataWords.length *
4;
27207 // Hash final blocks
27210 // Return final computed hash
27214 clone: function () {
27215 var clone = Hasher.clone.call(this);
27216 clone._hash = this._hash.clone();
27223 * Shortcut function to the hasher's object interface.
27225 * @param {WordArray|string} message The message to hash.
27227 * @return {WordArray} The hash.
27233 * var hash = CryptoJS.SHA1('message');
27234 * var hash = CryptoJS.SHA1(wordArray);
27236 C.SHA1 = Hasher._createHelper(SHA1);
27239 * Shortcut function to the HMAC's object interface.
27241 * @param {WordArray|string} message The message to hash.
27242 * @param {WordArray|string} key The secret key.
27244 * @return {WordArray} The HMAC.
27250 * var hmac = CryptoJS.HmacSHA1(message, key);
27252 C.HmacSHA1 = Hasher._createHmacHelper(SHA1);
27256 return CryptoJS.SHA1;
27259 },{
"./core":
31}],
56:[function(_dereq_,module,exports){
27260 ;(function (root, factory, undef) {
27261 if (typeof exports ===
"object") {
27263 module.exports = exports = factory(_dereq_(
"./core"), _dereq_(
"./sha256"));
27265 else if (typeof define ===
"function" && define.amd) {
27267 define([
"./core",
"./sha256"], factory);
27270 // Global (browser)
27271 factory(root.CryptoJS);
27273 }(this, function (CryptoJS) {
27279 var WordArray = C_lib.WordArray;
27280 var C_algo = C.algo;
27281 var SHA256 = C_algo.SHA256;
27284 * SHA-
224 hash algorithm.
27286 var SHA224 = C_algo.SHA224 = SHA256.extend({
27287 _doReset: function () {
27288 this._hash = new WordArray.init([
27289 0xc1059ed8,
0x367cd507,
0x3070dd17,
0xf70e5939,
27290 0xffc00b31,
0x68581511,
0x64f98fa7,
0xbefa4fa4
27294 _doFinalize: function () {
27295 var hash = SHA256._doFinalize.call(this);
27297 hash.sigBytes -=
4;
27304 * Shortcut function to the hasher's object interface.
27306 * @param {WordArray|string} message The message to hash.
27308 * @return {WordArray} The hash.
27314 * var hash = CryptoJS.SHA224('message');
27315 * var hash = CryptoJS.SHA224(wordArray);
27317 C.SHA224 = SHA256._createHelper(SHA224);
27320 * Shortcut function to the HMAC's object interface.
27322 * @param {WordArray|string} message The message to hash.
27323 * @param {WordArray|string} key The secret key.
27325 * @return {WordArray} The HMAC.
27331 * var hmac = CryptoJS.HmacSHA224(message, key);
27333 C.HmacSHA224 = SHA256._createHmacHelper(SHA224);
27337 return CryptoJS.SHA224;
27340 },{
"./core":
31,
"./sha256":
57}],
57:[function(_dereq_,module,exports){
27341 ;(function (root, factory) {
27342 if (typeof exports ===
"object") {
27344 module.exports = exports = factory(_dereq_(
"./core"));
27346 else if (typeof define ===
"function" && define.amd) {
27348 define([
"./core"], factory);
27351 // Global (browser)
27352 factory(root.CryptoJS);
27354 }(this, function (CryptoJS) {
27360 var WordArray = C_lib.WordArray;
27361 var Hasher = C_lib.Hasher;
27362 var C_algo = C.algo;
27364 // Initialization and round constants tables
27368 // Compute constants
27370 function isPrime(n) {
27371 var sqrtN = Math.sqrt(n);
27372 for (var factor =
2; factor <= sqrtN; factor++) {
27373 if (!(n % factor)) {
27381 function getFractionalBits(n) {
27382 return ((n - (n |
0)) *
0x100000000) |
0;
27387 while (nPrime <
64) {
27390 H[nPrime] = getFractionalBits(Math.pow(n,
1 /
2));
27392 K[nPrime] = getFractionalBits(Math.pow(n,
1 /
3));
27405 * SHA-
256 hash algorithm.
27407 var SHA256 = C_algo.SHA256 = Hasher.extend({
27408 _doReset: function () {
27409 this._hash = new WordArray.init(H.slice(
0));
27412 _doProcessBlock: function (M, offset) {
27414 var H = this._hash.words;
27416 // Working variables
27427 for (var i =
0; i <
64; i++) {
27429 W[i] = M[offset + i] |
0;
27431 var gamma0x = W[i -
15];
27432 var gamma0 = ((gamma0x <<
25) | (gamma0x
>>> 7)) ^
27433 ((gamma0x <<
14) | (gamma0x
>>> 18)) ^
27436 var gamma1x = W[i -
2];
27437 var gamma1 = ((gamma1x <<
15) | (gamma1x
>>> 17)) ^
27438 ((gamma1x <<
13) | (gamma1x
>>> 19)) ^
27441 W[i] = gamma0 + W[i -
7] + gamma1 + W[i -
16];
27444 var ch = (e & f) ^ (~e & g);
27445 var maj = (a & b) ^ (a & c) ^ (b & c);
27447 var sigma0 = ((a <<
30) | (a
>>> 2)) ^ ((a <<
19) | (a
>>> 13)) ^ ((a <<
10) | (a
>>> 22));
27448 var sigma1 = ((e <<
26) | (e
>>> 6)) ^ ((e <<
21) | (e
>>> 11)) ^ ((e <<
7) | (e
>>> 25));
27450 var t1 = h + sigma1 + ch + K[i] + W[i];
27451 var t2 = sigma0 + maj;
27463 // Intermediate hash value
27464 H[
0] = (H[
0] + a) |
0;
27465 H[
1] = (H[
1] + b) |
0;
27466 H[
2] = (H[
2] + c) |
0;
27467 H[
3] = (H[
3] + d) |
0;
27468 H[
4] = (H[
4] + e) |
0;
27469 H[
5] = (H[
5] + f) |
0;
27470 H[
6] = (H[
6] + g) |
0;
27471 H[
7] = (H[
7] + h) |
0;
27474 _doFinalize: function () {
27476 var data = this._data;
27477 var dataWords = data.words;
27479 var nBitsTotal = this._nDataBytes *
8;
27480 var nBitsLeft = data.sigBytes *
8;
27483 dataWords[nBitsLeft
>>> 5] |=
0x80 << (
24 - nBitsLeft %
32);
27484 dataWords[(((nBitsLeft +
64)
>>> 9) <<
4) +
14] = Math.floor(nBitsTotal /
0x100000000);
27485 dataWords[(((nBitsLeft +
64)
>>> 9) <<
4) +
15] = nBitsTotal;
27486 data.sigBytes = dataWords.length *
4;
27488 // Hash final blocks
27491 // Return final computed hash
27495 clone: function () {
27496 var clone = Hasher.clone.call(this);
27497 clone._hash = this._hash.clone();
27504 * Shortcut function to the hasher's object interface.
27506 * @param {WordArray|string} message The message to hash.
27508 * @return {WordArray} The hash.
27514 * var hash = CryptoJS.SHA256('message');
27515 * var hash = CryptoJS.SHA256(wordArray);
27517 C.SHA256 = Hasher._createHelper(SHA256);
27520 * Shortcut function to the HMAC's object interface.
27522 * @param {WordArray|string} message The message to hash.
27523 * @param {WordArray|string} key The secret key.
27525 * @return {WordArray} The HMAC.
27531 * var hmac = CryptoJS.HmacSHA256(message, key);
27533 C.HmacSHA256 = Hasher._createHmacHelper(SHA256);
27537 return CryptoJS.SHA256;
27540 },{
"./core":
31}],
58:[function(_dereq_,module,exports){
27541 ;(function (root, factory, undef) {
27542 if (typeof exports ===
"object") {
27544 module.exports = exports = factory(_dereq_(
"./core"), _dereq_(
"./x64-core"));
27546 else if (typeof define ===
"function" && define.amd) {
27548 define([
"./core",
"./x64-core"], factory);
27551 // Global (browser)
27552 factory(root.CryptoJS);
27554 }(this, function (CryptoJS) {
27560 var WordArray = C_lib.WordArray;
27561 var Hasher = C_lib.Hasher;
27563 var X64Word = C_x64.Word;
27564 var C_algo = C.algo;
27566 // Constants tables
27567 var RHO_OFFSETS = [];
27568 var PI_INDEXES = [];
27569 var ROUND_CONSTANTS = [];
27571 // Compute Constants
27573 // Compute rho offset constants
27575 for (var t =
0; t <
24; t++) {
27576 RHO_OFFSETS[x +
5 * y] = ((t +
1) * (t +
2) /
2) %
64;
27579 var newY = (
2 * x +
3 * y) %
5;
27584 // Compute pi index constants
27585 for (var x =
0; x <
5; x++) {
27586 for (var y =
0; y <
5; y++) {
27587 PI_INDEXES[x +
5 * y] = y + ((
2 * x +
3 * y) %
5) *
5;
27591 // Compute round constants
27593 for (var i =
0; i <
24; i++) {
27594 var roundConstantMsw =
0;
27595 var roundConstantLsw =
0;
27597 for (var j =
0; j <
7; j++) {
27599 var bitPosition = (
1 << j) -
1;
27600 if (bitPosition <
32) {
27601 roundConstantLsw ^=
1 << bitPosition;
27602 } else /* if (bitPosition
>=
32) */ {
27603 roundConstantMsw ^=
1 << (bitPosition -
32);
27607 // Compute next LFSR
27609 // Primitive polynomial over GF(
2): x^
8 + x^
6 + x^
5 + x^
4 +
1
27610 LFSR = (LFSR <<
1) ^
0x71;
27616 ROUND_CONSTANTS[i] = X64Word.create(roundConstantMsw, roundConstantLsw);
27620 // Reusable objects for temporary values
27623 for (var i =
0; i <
25; i++) {
27624 T[i] = X64Word.create();
27629 * SHA-
3 hash algorithm.
27631 var SHA3 = C_algo.SHA3 = Hasher.extend({
27633 * Configuration options.
27635 * @property {number} outputLength
27636 * The desired number of bits in the output hash.
27637 * Only values permitted are:
224,
256,
384,
512.
27640 cfg: Hasher.cfg.extend({
27644 _doReset: function () {
27645 var state = this._state = []
27646 for (var i =
0; i <
25; i++) {
27647 state[i] = new X64Word.init();
27650 this.blockSize = (
1600 -
2 * this.cfg.outputLength) /
32;
27653 _doProcessBlock: function (M, offset) {
27655 var state = this._state;
27656 var nBlockSizeLanes = this.blockSize /
2;
27659 for (var i =
0; i < nBlockSizeLanes; i++) {
27661 var M2i = M[offset +
2 * i];
27662 var M2i1 = M[offset +
2 * i +
1];
27666 (((M2i <<
8) | (M2i
>>> 24)) &
0x00ff00ff) |
27667 (((M2i <<
24) | (M2i
>>> 8)) &
0xff00ff00)
27670 (((M2i1 <<
8) | (M2i1
>>> 24)) &
0x00ff00ff) |
27671 (((M2i1 <<
24) | (M2i1
>>> 8)) &
0xff00ff00)
27674 // Absorb message into state
27675 var lane = state[i];
27681 for (var round =
0; round <
24; round++) {
27683 for (var x =
0; x <
5; x++) {
27684 // Mix column lanes
27685 var tMsw =
0, tLsw =
0;
27686 for (var y =
0; y <
5; y++) {
27687 var lane = state[x +
5 * y];
27692 // Temporary values
27697 for (var x =
0; x <
5; x++) {
27699 var Tx4 = T[(x +
4) %
5];
27700 var Tx1 = T[(x +
1) %
5];
27701 var Tx1Msw = Tx1.high;
27702 var Tx1Lsw = Tx1.low;
27704 // Mix surrounding columns
27705 var tMsw = Tx4.high ^ ((Tx1Msw <<
1) | (Tx1Lsw
>>> 31));
27706 var tLsw = Tx4.low ^ ((Tx1Lsw <<
1) | (Tx1Msw
>>> 31));
27707 for (var y =
0; y <
5; y++) {
27708 var lane = state[x +
5 * y];
27715 for (var laneIndex =
1; laneIndex <
25; laneIndex++) {
27717 var lane = state[laneIndex];
27718 var laneMsw = lane.high;
27719 var laneLsw = lane.low;
27720 var rhoOffset = RHO_OFFSETS[laneIndex];
27723 if (rhoOffset <
32) {
27724 var tMsw = (laneMsw << rhoOffset) | (laneLsw
>>> (
32 - rhoOffset));
27725 var tLsw = (laneLsw << rhoOffset) | (laneMsw
>>> (
32 - rhoOffset));
27726 } else /* if (rhoOffset
>=
32) */ {
27727 var tMsw = (laneLsw << (rhoOffset -
32)) | (laneMsw
>>> (
64 - rhoOffset));
27728 var tLsw = (laneMsw << (rhoOffset -
32)) | (laneLsw
>>> (
64 - rhoOffset));
27732 var TPiLane = T[PI_INDEXES[laneIndex]];
27733 TPiLane.high = tMsw;
27734 TPiLane.low = tLsw;
27737 // Rho pi at x = y =
0
27739 var state0 = state[
0];
27740 T0.high = state0.high;
27741 T0.low = state0.low;
27744 for (var x =
0; x <
5; x++) {
27745 for (var y =
0; y <
5; y++) {
27747 var laneIndex = x +
5 * y;
27748 var lane = state[laneIndex];
27749 var TLane = T[laneIndex];
27750 var Tx1Lane = T[((x +
1) %
5) +
5 * y];
27751 var Tx2Lane = T[((x +
2) %
5) +
5 * y];
27754 lane.high = TLane.high ^ (~Tx1Lane.high & Tx2Lane.high);
27755 lane.low = TLane.low ^ (~Tx1Lane.low & Tx2Lane.low);
27760 var lane = state[
0];
27761 var roundConstant = ROUND_CONSTANTS[round];
27762 lane.high ^= roundConstant.high;
27763 lane.low ^= roundConstant.low;;
27767 _doFinalize: function () {
27769 var data = this._data;
27770 var dataWords = data.words;
27771 var nBitsTotal = this._nDataBytes *
8;
27772 var nBitsLeft = data.sigBytes *
8;
27773 var blockSizeBits = this.blockSize *
32;
27776 dataWords[nBitsLeft
>>> 5] |=
0x1 << (
24 - nBitsLeft %
32);
27777 dataWords[((Math.ceil((nBitsLeft +
1) / blockSizeBits) * blockSizeBits)
>>> 5) -
1] |=
0x80;
27778 data.sigBytes = dataWords.length *
4;
27780 // Hash final blocks
27784 var state = this._state;
27785 var outputLengthBytes = this.cfg.outputLength /
8;
27786 var outputLengthLanes = outputLengthBytes /
8;
27789 var hashWords = [];
27790 for (var i =
0; i < outputLengthLanes; i++) {
27792 var lane = state[i];
27793 var laneMsw = lane.high;
27794 var laneLsw = lane.low;
27798 (((laneMsw <<
8) | (laneMsw
>>> 24)) &
0x00ff00ff) |
27799 (((laneMsw <<
24) | (laneMsw
>>> 8)) &
0xff00ff00)
27802 (((laneLsw <<
8) | (laneLsw
>>> 24)) &
0x00ff00ff) |
27803 (((laneLsw <<
24) | (laneLsw
>>> 8)) &
0xff00ff00)
27806 // Squeeze state to retrieve hash
27807 hashWords.push(laneLsw);
27808 hashWords.push(laneMsw);
27811 // Return final computed hash
27812 return new WordArray.init(hashWords, outputLengthBytes);
27815 clone: function () {
27816 var clone = Hasher.clone.call(this);
27818 var state = clone._state = this._state.slice(
0);
27819 for (var i =
0; i <
25; i++) {
27820 state[i] = state[i].clone();
27828 * Shortcut function to the hasher's object interface.
27830 * @param {WordArray|string} message The message to hash.
27832 * @return {WordArray} The hash.
27838 * var hash = CryptoJS.SHA3('message');
27839 * var hash = CryptoJS.SHA3(wordArray);
27841 C.SHA3 = Hasher._createHelper(SHA3);
27844 * Shortcut function to the HMAC's object interface.
27846 * @param {WordArray|string} message The message to hash.
27847 * @param {WordArray|string} key The secret key.
27849 * @return {WordArray} The HMAC.
27855 * var hmac = CryptoJS.HmacSHA3(message, key);
27857 C.HmacSHA3 = Hasher._createHmacHelper(SHA3);
27861 return CryptoJS.SHA3;
27864 },{
"./core":
31,
"./x64-core":
62}],
59:[function(_dereq_,module,exports){
27865 ;(function (root, factory, undef) {
27866 if (typeof exports ===
"object") {
27868 module.exports = exports = factory(_dereq_(
"./core"), _dereq_(
"./x64-core"), _dereq_(
"./sha512"));
27870 else if (typeof define ===
"function" && define.amd) {
27872 define([
"./core",
"./x64-core",
"./sha512"], factory);
27875 // Global (browser)
27876 factory(root.CryptoJS);
27878 }(this, function (CryptoJS) {
27884 var X64Word = C_x64.Word;
27885 var X64WordArray = C_x64.WordArray;
27886 var C_algo = C.algo;
27887 var SHA512 = C_algo.SHA512;
27890 * SHA-
384 hash algorithm.
27892 var SHA384 = C_algo.SHA384 = SHA512.extend({
27893 _doReset: function () {
27894 this._hash = new X64WordArray.init([
27895 new X64Word.init(
0xcbbb9d5d,
0xc1059ed8), new X64Word.init(
0x629a292a,
0x367cd507),
27896 new X64Word.init(
0x9159015a,
0x3070dd17), new X64Word.init(
0x152fecd8,
0xf70e5939),
27897 new X64Word.init(
0x67332667,
0xffc00b31), new X64Word.init(
0x8eb44a87,
0x68581511),
27898 new X64Word.init(
0xdb0c2e0d,
0x64f98fa7), new X64Word.init(
0x47b5481d,
0xbefa4fa4)
27902 _doFinalize: function () {
27903 var hash = SHA512._doFinalize.call(this);
27905 hash.sigBytes -=
16;
27912 * Shortcut function to the hasher's object interface.
27914 * @param {WordArray|string} message The message to hash.
27916 * @return {WordArray} The hash.
27922 * var hash = CryptoJS.SHA384('message');
27923 * var hash = CryptoJS.SHA384(wordArray);
27925 C.SHA384 = SHA512._createHelper(SHA384);
27928 * Shortcut function to the HMAC's object interface.
27930 * @param {WordArray|string} message The message to hash.
27931 * @param {WordArray|string} key The secret key.
27933 * @return {WordArray} The HMAC.
27939 * var hmac = CryptoJS.HmacSHA384(message, key);
27941 C.HmacSHA384 = SHA512._createHmacHelper(SHA384);
27945 return CryptoJS.SHA384;
27948 },{
"./core":
31,
"./sha512":
60,
"./x64-core":
62}],
60:[function(_dereq_,module,exports){
27949 ;(function (root, factory, undef) {
27950 if (typeof exports ===
"object") {
27952 module.exports = exports = factory(_dereq_(
"./core"), _dereq_(
"./x64-core"));
27954 else if (typeof define ===
"function" && define.amd) {
27956 define([
"./core",
"./x64-core"], factory);
27959 // Global (browser)
27960 factory(root.CryptoJS);
27962 }(this, function (CryptoJS) {
27968 var Hasher = C_lib.Hasher;
27970 var X64Word = C_x64.Word;
27971 var X64WordArray = C_x64.WordArray;
27972 var C_algo = C.algo;
27974 function X64Word_create() {
27975 return X64Word.create.apply(X64Word, arguments);
27980 X64Word_create(
0x428a2f98,
0xd728ae22), X64Word_create(
0x71374491,
0x23ef65cd),
27981 X64Word_create(
0xb5c0fbcf,
0xec4d3b2f), X64Word_create(
0xe9b5dba5,
0x8189dbbc),
27982 X64Word_create(
0x3956c25b,
0xf348b538), X64Word_create(
0x59f111f1,
0xb605d019),
27983 X64Word_create(
0x923f82a4,
0xaf194f9b), X64Word_create(
0xab1c5ed5,
0xda6d8118),
27984 X64Word_create(
0xd807aa98,
0xa3030242), X64Word_create(
0x12835b01,
0x45706fbe),
27985 X64Word_create(
0x243185be,
0x4ee4b28c), X64Word_create(
0x550c7dc3,
0xd5ffb4e2),
27986 X64Word_create(
0x72be5d74,
0xf27b896f), X64Word_create(
0x80deb1fe,
0x3b1696b1),
27987 X64Word_create(
0x9bdc06a7,
0x25c71235), X64Word_create(
0xc19bf174,
0xcf692694),
27988 X64Word_create(
0xe49b69c1,
0x9ef14ad2), X64Word_create(
0xefbe4786,
0x384f25e3),
27989 X64Word_create(
0x0fc19dc6,
0x8b8cd5b5), X64Word_create(
0x240ca1cc,
0x77ac9c65),
27990 X64Word_create(
0x2de92c6f,
0x592b0275), X64Word_create(
0x4a7484aa,
0x6ea6e483),
27991 X64Word_create(
0x5cb0a9dc,
0xbd41fbd4), X64Word_create(
0x76f988da,
0x831153b5),
27992 X64Word_create(
0x983e5152,
0xee66dfab), X64Word_create(
0xa831c66d,
0x2db43210),
27993 X64Word_create(
0xb00327c8,
0x98fb213f), X64Word_create(
0xbf597fc7,
0xbeef0ee4),
27994 X64Word_create(
0xc6e00bf3,
0x3da88fc2), X64Word_create(
0xd5a79147,
0x930aa725),
27995 X64Word_create(
0x06ca6351,
0xe003826f), X64Word_create(
0x14292967,
0x0a0e6e70),
27996 X64Word_create(
0x27b70a85,
0x46d22ffc), X64Word_create(
0x2e1b2138,
0x5c26c926),
27997 X64Word_create(
0x4d2c6dfc,
0x5ac42aed), X64Word_create(
0x53380d13,
0x9d95b3df),
27998 X64Word_create(
0x650a7354,
0x8baf63de), X64Word_create(
0x766a0abb,
0x3c77b2a8),
27999 X64Word_create(
0x81c2c92e,
0x47edaee6), X64Word_create(
0x92722c85,
0x1482353b),
28000 X64Word_create(
0xa2bfe8a1,
0x4cf10364), X64Word_create(
0xa81a664b,
0xbc423001),
28001 X64Word_create(
0xc24b8b70,
0xd0f89791), X64Word_create(
0xc76c51a3,
0x0654be30),
28002 X64Word_create(
0xd192e819,
0xd6ef5218), X64Word_create(
0xd6990624,
0x5565a910),
28003 X64Word_create(
0xf40e3585,
0x5771202a), X64Word_create(
0x106aa070,
0x32bbd1b8),
28004 X64Word_create(
0x19a4c116,
0xb8d2d0c8), X64Word_create(
0x1e376c08,
0x5141ab53),
28005 X64Word_create(
0x2748774c,
0xdf8eeb99), X64Word_create(
0x34b0bcb5,
0xe19b48a8),
28006 X64Word_create(
0x391c0cb3,
0xc5c95a63), X64Word_create(
0x4ed8aa4a,
0xe3418acb),
28007 X64Word_create(
0x5b9cca4f,
0x7763e373), X64Word_create(
0x682e6ff3,
0xd6b2b8a3),
28008 X64Word_create(
0x748f82ee,
0x5defb2fc), X64Word_create(
0x78a5636f,
0x43172f60),
28009 X64Word_create(
0x84c87814,
0xa1f0ab72), X64Word_create(
0x8cc70208,
0x1a6439ec),
28010 X64Word_create(
0x90befffa,
0x23631e28), X64Word_create(
0xa4506ceb,
0xde82bde9),
28011 X64Word_create(
0xbef9a3f7,
0xb2c67915), X64Word_create(
0xc67178f2,
0xe372532b),
28012 X64Word_create(
0xca273ece,
0xea26619c), X64Word_create(
0xd186b8c7,
0x21c0c207),
28013 X64Word_create(
0xeada7dd6,
0xcde0eb1e), X64Word_create(
0xf57d4f7f,
0xee6ed178),
28014 X64Word_create(
0x06f067aa,
0x72176fba), X64Word_create(
0x0a637dc5,
0xa2c898a6),
28015 X64Word_create(
0x113f9804,
0xbef90dae), X64Word_create(
0x1b710b35,
0x131c471b),
28016 X64Word_create(
0x28db77f5,
0x23047d84), X64Word_create(
0x32caab7b,
0x40c72493),
28017 X64Word_create(
0x3c9ebe0a,
0x15c9bebc), X64Word_create(
0x431d67c4,
0x9c100d4c),
28018 X64Word_create(
0x4cc5d4be,
0xcb3e42b6), X64Word_create(
0x597f299c,
0xfc657e2a),
28019 X64Word_create(
0x5fcb6fab,
0x3ad6faec), X64Word_create(
0x6c44198c,
0x4a475817)
28022 // Reusable objects
28025 for (var i =
0; i <
80; i++) {
28026 W[i] = X64Word_create();
28031 * SHA-
512 hash algorithm.
28033 var SHA512 = C_algo.SHA512 = Hasher.extend({
28034 _doReset: function () {
28035 this._hash = new X64WordArray.init([
28036 new X64Word.init(
0x6a09e667,
0xf3bcc908), new X64Word.init(
0xbb67ae85,
0x84caa73b),
28037 new X64Word.init(
0x3c6ef372,
0xfe94f82b), new X64Word.init(
0xa54ff53a,
0x5f1d36f1),
28038 new X64Word.init(
0x510e527f,
0xade682d1), new X64Word.init(
0x9b05688c,
0x2b3e6c1f),
28039 new X64Word.init(
0x1f83d9ab,
0xfb41bd6b), new X64Word.init(
0x5be0cd19,
0x137e2179)
28043 _doProcessBlock: function (M, offset) {
28045 var H = this._hash.words;
28073 // Working variables
28092 for (var i =
0; i <
80; i++) {
28098 var Wih = Wi.high = M[offset + i *
2] |
0;
28099 var Wil = Wi.low = M[offset + i *
2 +
1] |
0;
28102 var gamma0x = W[i -
15];
28103 var gamma0xh = gamma0x.high;
28104 var gamma0xl = gamma0x.low;
28105 var gamma0h = ((gamma0xh
>>> 1) | (gamma0xl <<
31)) ^ ((gamma0xh
>>> 8) | (gamma0xl <<
24)) ^ (gamma0xh
>>> 7);
28106 var gamma0l = ((gamma0xl
>>> 1) | (gamma0xh <<
31)) ^ ((gamma0xl
>>> 8) | (gamma0xh <<
24)) ^ ((gamma0xl
>>> 7) | (gamma0xh <<
25));
28109 var gamma1x = W[i -
2];
28110 var gamma1xh = gamma1x.high;
28111 var gamma1xl = gamma1x.low;
28112 var gamma1h = ((gamma1xh
>>> 19) | (gamma1xl <<
13)) ^ ((gamma1xh <<
3) | (gamma1xl
>>> 29)) ^ (gamma1xh
>>> 6);
28113 var gamma1l = ((gamma1xl
>>> 19) | (gamma1xh <<
13)) ^ ((gamma1xl <<
3) | (gamma1xh
>>> 29)) ^ ((gamma1xl
>>> 6) | (gamma1xh <<
26));
28115 // W[i] = gamma0 + W[i -
7] + gamma1 + W[i -
16]
28116 var Wi7 = W[i -
7];
28117 var Wi7h = Wi7.high;
28118 var Wi7l = Wi7.low;
28120 var Wi16 = W[i -
16];
28121 var Wi16h = Wi16.high;
28122 var Wi16l = Wi16.low;
28124 var Wil = gamma0l + Wi7l;
28125 var Wih = gamma0h + Wi7h + ((Wil
>>> 0) < (gamma0l
>>> 0) ?
1 :
0);
28126 var Wil = Wil + gamma1l;
28127 var Wih = Wih + gamma1h + ((Wil
>>> 0) < (gamma1l
>>> 0) ?
1 :
0);
28128 var Wil = Wil + Wi16l;
28129 var Wih = Wih + Wi16h + ((Wil
>>> 0) < (Wi16l
>>> 0) ?
1 :
0);
28135 var chh = (eh & fh) ^ (~eh & gh);
28136 var chl = (el & fl) ^ (~el & gl);
28137 var majh = (ah & bh) ^ (ah & ch) ^ (bh & ch);
28138 var majl = (al & bl) ^ (al & cl) ^ (bl & cl);
28140 var sigma0h = ((ah
>>> 28) | (al <<
4)) ^ ((ah <<
30) | (al
>>> 2)) ^ ((ah <<
25) | (al
>>> 7));
28141 var sigma0l = ((al
>>> 28) | (ah <<
4)) ^ ((al <<
30) | (ah
>>> 2)) ^ ((al <<
25) | (ah
>>> 7));
28142 var sigma1h = ((eh
>>> 14) | (el <<
18)) ^ ((eh
>>> 18) | (el <<
14)) ^ ((eh <<
23) | (el
>>> 9));
28143 var sigma1l = ((el
>>> 14) | (eh <<
18)) ^ ((el
>>> 18) | (eh <<
14)) ^ ((el <<
23) | (eh
>>> 9));
28145 // t1 = h + sigma1 + ch + K[i] + W[i]
28150 var t1l = hl + sigma1l;
28151 var t1h = hh + sigma1h + ((t1l
>>> 0) < (hl
>>> 0) ?
1 :
0);
28152 var t1l = t1l + chl;
28153 var t1h = t1h + chh + ((t1l
>>> 0) < (chl
>>> 0) ?
1 :
0);
28154 var t1l = t1l + Kil;
28155 var t1h = t1h + Kih + ((t1l
>>> 0) < (Kil
>>> 0) ?
1 :
0);
28156 var t1l = t1l + Wil;
28157 var t1h = t1h + Wih + ((t1l
>>> 0) < (Wil
>>> 0) ?
1 :
0);
28159 // t2 = sigma0 + maj
28160 var t2l = sigma0l + majl;
28161 var t2h = sigma0h + majh + ((t2l
>>> 0) < (sigma0l
>>> 0) ?
1 :
0);
28163 // Update working variables
28170 el = (dl + t1l) |
0;
28171 eh = (dh + t1h + ((el
>>> 0) < (dl
>>> 0) ?
1 :
0)) |
0;
28178 al = (t1l + t2l) |
0;
28179 ah = (t1h + t2h + ((al
>>> 0) < (t1l
>>> 0) ?
1 :
0)) |
0;
28182 // Intermediate hash value
28183 H0l = H0.low = (H0l + al);
28184 H0.high = (H0h + ah + ((H0l
>>> 0) < (al
>>> 0) ?
1 :
0));
28185 H1l = H1.low = (H1l + bl);
28186 H1.high = (H1h + bh + ((H1l
>>> 0) < (bl
>>> 0) ?
1 :
0));
28187 H2l = H2.low = (H2l + cl);
28188 H2.high = (H2h + ch + ((H2l
>>> 0) < (cl
>>> 0) ?
1 :
0));
28189 H3l = H3.low = (H3l + dl);
28190 H3.high = (H3h + dh + ((H3l
>>> 0) < (dl
>>> 0) ?
1 :
0));
28191 H4l = H4.low = (H4l + el);
28192 H4.high = (H4h + eh + ((H4l
>>> 0) < (el
>>> 0) ?
1 :
0));
28193 H5l = H5.low = (H5l + fl);
28194 H5.high = (H5h + fh + ((H5l
>>> 0) < (fl
>>> 0) ?
1 :
0));
28195 H6l = H6.low = (H6l + gl);
28196 H6.high = (H6h + gh + ((H6l
>>> 0) < (gl
>>> 0) ?
1 :
0));
28197 H7l = H7.low = (H7l + hl);
28198 H7.high = (H7h + hh + ((H7l
>>> 0) < (hl
>>> 0) ?
1 :
0));
28201 _doFinalize: function () {
28203 var data = this._data;
28204 var dataWords = data.words;
28206 var nBitsTotal = this._nDataBytes *
8;
28207 var nBitsLeft = data.sigBytes *
8;
28210 dataWords[nBitsLeft
>>> 5] |=
0x80 << (
24 - nBitsLeft %
32);
28211 dataWords[(((nBitsLeft +
128)
>>> 10) <<
5) +
30] = Math.floor(nBitsTotal /
0x100000000);
28212 dataWords[(((nBitsLeft +
128)
>>> 10) <<
5) +
31] = nBitsTotal;
28213 data.sigBytes = dataWords.length *
4;
28215 // Hash final blocks
28218 // Convert hash to
32-bit word array before returning
28219 var hash = this._hash.toX32();
28221 // Return final computed hash
28225 clone: function () {
28226 var clone = Hasher.clone.call(this);
28227 clone._hash = this._hash.clone();
28236 * Shortcut function to the hasher's object interface.
28238 * @param {WordArray|string} message The message to hash.
28240 * @return {WordArray} The hash.
28246 * var hash = CryptoJS.SHA512('message');
28247 * var hash = CryptoJS.SHA512(wordArray);
28249 C.SHA512 = Hasher._createHelper(SHA512);
28252 * Shortcut function to the HMAC's object interface.
28254 * @param {WordArray|string} message The message to hash.
28255 * @param {WordArray|string} key The secret key.
28257 * @return {WordArray} The HMAC.
28263 * var hmac = CryptoJS.HmacSHA512(message, key);
28265 C.HmacSHA512 = Hasher._createHmacHelper(SHA512);
28269 return CryptoJS.SHA512;
28272 },{
"./core":
31,
"./x64-core":
62}],
61:[function(_dereq_,module,exports){
28273 ;(function (root, factory, undef) {
28274 if (typeof exports ===
"object") {
28276 module.exports = exports = factory(_dereq_(
"./core"), _dereq_(
"./enc-base64"), _dereq_(
"./md5"), _dereq_(
"./evpkdf"), _dereq_(
"./cipher-core"));
28278 else if (typeof define ===
"function" && define.amd) {
28280 define([
"./core",
"./enc-base64",
"./md5",
"./evpkdf",
"./cipher-core"], factory);
28283 // Global (browser)
28284 factory(root.CryptoJS);
28286 }(this, function (CryptoJS) {
28292 var WordArray = C_lib.WordArray;
28293 var BlockCipher = C_lib.BlockCipher;
28294 var C_algo = C.algo;
28296 // Permuted Choice
1 constants
28298 57,
49,
41,
33,
25,
17,
9,
1,
28299 58,
50,
42,
34,
26,
18,
10,
2,
28300 59,
51,
43,
35,
27,
19,
11,
3,
28301 60,
52,
44,
36,
63,
55,
47,
39,
28302 31,
23,
15,
7,
62,
54,
46,
38,
28303 30,
22,
14,
6,
61,
53,
45,
37,
28304 29,
21,
13,
5,
28,
20,
12,
4
28307 // Permuted Choice
2 constants
28309 14,
17,
11,
24,
1,
5,
28310 3,
28,
15,
6,
21,
10,
28311 23,
19,
12,
4,
26,
8,
28312 16,
7,
27,
20,
13,
2,
28313 41,
52,
31,
37,
47,
55,
28314 30,
40,
51,
45,
33,
48,
28315 44,
49,
39,
56,
34,
53,
28316 46,
42,
50,
36,
29,
32
28319 // Cumulative bit shift constants
28320 var BIT_SHIFTS = [
1,
2,
4,
6,
8,
10,
12,
14,
15,
17,
19,
21,
23,
25,
27,
28];
28322 // SBOXes and round permutation constants
28326 0x10000000:
0x8000,
28327 0x20000000:
0x808002,
28330 0x50000000:
0x808202,
28331 0x60000000:
0x800202,
28332 0x70000000:
0x800000,
28334 0x90000000:
0x800200,
28335 0xa0000000:
0x8200,
28336 0xb0000000:
0x808000,
28337 0xc0000000:
0x8002,
28338 0xd0000000:
0x800002,
28340 0xf0000000:
0x8202,
28342 0x18000000:
0x808202,
28343 0x28000000:
0x8202,
28344 0x38000000:
0x8000,
28345 0x48000000:
0x808200,
28347 0x68000000:
0x808002,
28349 0x88000000:
0x800200,
28350 0x98000000:
0x8200,
28351 0xa8000000:
0x808000,
28352 0xb8000000:
0x800202,
28353 0xc8000000:
0x800002,
28354 0xd8000000:
0x8002,
28356 0xf8000000:
0x800000,
28359 0x20000001:
0x808200,
28360 0x30000001:
0x800000,
28361 0x40000001:
0x808002,
28362 0x50000001:
0x8200,
28364 0x70000001:
0x800202,
28365 0x80000001:
0x808202,
28366 0x90000001:
0x808000,
28367 0xa0000001:
0x800002,
28368 0xb0000001:
0x8202,
28370 0xd0000001:
0x800200,
28371 0xe0000001:
0x8002,
28373 0x8000001:
0x808202,
28374 0x18000001:
0x808000,
28375 0x28000001:
0x800000,
28377 0x48000001:
0x8000,
28378 0x58000001:
0x800002,
28380 0x78000001:
0x8202,
28381 0x88000001:
0x8002,
28382 0x98000001:
0x800202,
28384 0xb8000001:
0x808200,
28385 0xc8000001:
0x800200,
28387 0xe8000001:
0x8200,
28388 0xf8000001:
0x808002
28393 0x2000000:
0x80000,
28394 0x3000000:
0x40080010,
28395 0x4000000:
0x40000010,
28396 0x5000000:
0x40084000,
28397 0x6000000:
0x40004000,
28399 0x8000000:
0x84000,
28400 0x9000000:
0x40004010,
28401 0xa000000:
0x40000000,
28402 0xb000000:
0x84010,
28403 0xc000000:
0x80010,
28406 0xf000000:
0x40080000,
28407 0x800000:
0x40004000,
28408 0x1800000:
0x84010,
28410 0x3800000:
0x40004010,
28411 0x4800000:
0x40084010,
28412 0x5800000:
0x40000000,
28413 0x6800000:
0x80000,
28414 0x7800000:
0x40080010,
28415 0x8800000:
0x80010,
28418 0xb800000:
0x40080000,
28419 0xc800000:
0x40000010,
28420 0xd800000:
0x84000,
28421 0xe800000:
0x40084000,
28424 0x11000000:
0x40080010,
28425 0x12000000:
0x40004010,
28426 0x13000000:
0x40084000,
28427 0x14000000:
0x40080000,
28429 0x16000000:
0x84010,
28430 0x17000000:
0x4000,
28431 0x18000000:
0x4010,
28432 0x19000000:
0x80000,
28433 0x1a000000:
0x80010,
28434 0x1b000000:
0x40000010,
28435 0x1c000000:
0x84000,
28436 0x1d000000:
0x40004000,
28437 0x1e000000:
0x40000000,
28438 0x1f000000:
0x40084010,
28439 0x10800000:
0x84010,
28440 0x11800000:
0x80000,
28441 0x12800000:
0x40080000,
28442 0x13800000:
0x4000,
28443 0x14800000:
0x40004000,
28444 0x15800000:
0x40084010,
28446 0x17800000:
0x40000000,
28447 0x18800000:
0x40084000,
28448 0x19800000:
0x40000010,
28449 0x1a800000:
0x40004010,
28450 0x1b800000:
0x80010,
28452 0x1d800000:
0x4010,
28453 0x1e800000:
0x40080010,
28454 0x1f800000:
0x84000
28459 0x200000:
0x4000100,
28462 0x500000:
0x4000004,
28463 0x600000:
0x4010104,
28464 0x700000:
0x4010000,
28465 0x800000:
0x4000000,
28466 0x900000:
0x4010100,
28468 0xb00000:
0x4010004,
28469 0xc00000:
0x4000104,
28473 0x80000:
0x4010100,
28474 0x180000:
0x4010004,
28476 0x380000:
0x4000100,
28477 0x480000:
0x4000004,
28483 0xa80000:
0x4010000,
28486 0xd80000:
0x4000104,
28487 0xe80000:
0x4010104,
28488 0xf80000:
0x4000000,
28489 0x1000000:
0x4010100,
28490 0x1100000:
0x10004,
28491 0x1200000:
0x10000,
28492 0x1300000:
0x4000100,
28494 0x1500000:
0x4010104,
28495 0x1600000:
0x4000004,
28497 0x1800000:
0x4000104,
28498 0x1900000:
0x4000000,
28500 0x1b00000:
0x10100,
28501 0x1c00000:
0x4010000,
28503 0x1e00000:
0x10104,
28504 0x1f00000:
0x4010004,
28505 0x1080000:
0x4000000,
28507 0x1280000:
0x4010100,
28509 0x1480000:
0x10004,
28510 0x1580000:
0x4000100,
28512 0x1780000:
0x4010004,
28513 0x1880000:
0x10000,
28514 0x1980000:
0x4010104,
28515 0x1a80000:
0x10104,
28516 0x1b80000:
0x4000004,
28517 0x1c80000:
0x4000104,
28518 0x1d80000:
0x4010000,
28524 0x10000:
0x80001040,
28526 0x30000:
0x80400000,
28529 0x60000:
0x80000040,
28531 0x80000:
0x80000000,
28534 0xb0000:
0x80001000,
28535 0xc0000:
0x80400040,
28538 0xf0000:
0x80401040,
28539 0x8000:
0x80001040,
28541 0x28000:
0x80400040,
28542 0x38000:
0x80001000,
28544 0x58000:
0x80401040,
28546 0x78000:
0x80400000,
28548 0x98000:
0x80401000,
28551 0xc8000:
0x80000000,
28554 0xf8000:
0x80000040,
28555 0x100000:
0x400040,
28556 0x110000:
0x401000,
28557 0x120000:
0x80000040,
28560 0x150000:
0x80400040,
28561 0x160000:
0x80401000,
28562 0x170000:
0x80001040,
28563 0x180000:
0x80401040,
28564 0x190000:
0x80000000,
28565 0x1a0000:
0x80400000,
28566 0x1b0000:
0x401040,
28567 0x1c0000:
0x80001000,
28568 0x1d0000:
0x400000,
28571 0x108000:
0x80400000,
28572 0x118000:
0x80401040,
28574 0x138000:
0x401000,
28575 0x148000:
0x400040,
28576 0x158000:
0x80000000,
28577 0x168000:
0x80001040,
28579 0x188000:
0x80000040,
28581 0x1a8000:
0x80001000,
28582 0x1b8000:
0x80400040,
28584 0x1d8000:
0x80401000,
28585 0x1e8000:
0x400000,
28592 0x3000:
0x20000000,
28593 0x4000:
0x20040080,
28595 0x6000:
0x21000080,
28598 0x9000:
0x20040000,
28599 0xa000:
0x20000080,
28600 0xb000:
0x21040080,
28601 0xc000:
0x21040000,
28604 0xf000:
0x21000000,
28606 0x1800:
0x21000080,
28610 0x5800:
0x20040080,
28611 0x6800:
0x21040000,
28612 0x7800:
0x20000000,
28613 0x8800:
0x20040000,
28615 0xa800:
0x21040080,
28617 0xc800:
0x20000080,
28618 0xd800:
0x21000000,
28623 0x12000:
0x20000000,
28624 0x13000:
0x21000080,
28625 0x14000:
0x1000080,
28626 0x15000:
0x21040000,
28627 0x16000:
0x20040080,
28628 0x17000:
0x1000000,
28629 0x18000:
0x21040080,
28630 0x19000:
0x21000000,
28631 0x1a000:
0x1040000,
28632 0x1b000:
0x20040000,
28634 0x1d000:
0x20000080,
28636 0x1f000:
0x1040080,
28637 0x10800:
0x21000080,
28638 0x11800:
0x1000000,
28639 0x12800:
0x1040000,
28640 0x13800:
0x20040080,
28641 0x14800:
0x20000000,
28642 0x15800:
0x1040080,
28644 0x17800:
0x21040000,
28646 0x19800:
0x21040080,
28648 0x1b800:
0x21000000,
28649 0x1c800:
0x1000080,
28651 0x1e800:
0x20040000,
28652 0x1f800:
0x20000080
28687 0x1000:
0x10002000,
28688 0x1100:
0x10200008,
28689 0x1200:
0x10202008,
28692 0x1500:
0x10000000,
28693 0x1600:
0x10000008,
28698 0x1b00:
0x10200000,
28700 0x1d00:
0x10002008,
28701 0x1e00:
0x10202000,
28706 0x1380:
0x10000008,
28707 0x1480:
0x10002000,
28709 0x1680:
0x10202008,
28710 0x1780:
0x10200000,
28711 0x1880:
0x10202000,
28712 0x1980:
0x10200008,
28717 0x1e80:
0x10000000,
28804 0x80000001:
0x8020820,
28805 0x80000002:
0x8000820,
28806 0x80000003:
0x8000000,
28807 0x80000004:
0x8020000,
28808 0x80000005:
0x20800,
28809 0x80000006:
0x20820,
28811 0x80000008:
0x8000020,
28813 0x8000000a:
0x20020,
28814 0x8000000b:
0x8020800,
28816 0x8000000d:
0x8020020,
28817 0x8000000e:
0x8000800,
28818 0x8000000f:
0x20000,
28835 0x80000010:
0x20000,
28837 0x80000012:
0x8020020,
28838 0x80000013:
0x20820,
28840 0x80000015:
0x8020000,
28841 0x80000016:
0x8000000,
28842 0x80000017:
0x8000820,
28843 0x80000018:
0x8020820,
28844 0x80000019:
0x8000020,
28845 0x8000001a:
0x8000800,
28847 0x8000001c:
0x20800,
28849 0x8000001e:
0x20020,
28850 0x8000001f:
0x8020800
28854 // Masks that select the SBOX input
28856 0xf8000001,
0x1f800000,
0x01f80000,
0x001f8000,
28857 0x0001f800,
0x00001f80,
0x000001f8,
0x8000001f
28861 * DES block cipher algorithm.
28863 var DES = C_algo.DES = BlockCipher.extend({
28864 _doReset: function () {
28866 var key = this._key;
28867 var keyWords = key.words;
28869 // Select
56 bits according to PC1
28871 for (var i =
0; i <
56; i++) {
28872 var keyBitPos = PC1[i] -
1;
28873 keyBits[i] = (keyWords[keyBitPos
>>> 5]
>>> (
31 - keyBitPos %
32)) &
1;
28876 // Assemble
16 subkeys
28877 var subKeys = this._subKeys = [];
28878 for (var nSubKey =
0; nSubKey <
16; nSubKey++) {
28880 var subKey = subKeys[nSubKey] = [];
28883 var bitShift = BIT_SHIFTS[nSubKey];
28885 // Select
48 bits according to PC2
28886 for (var i =
0; i <
24; i++) {
28887 // Select from the left
28 key bits
28888 subKey[(i /
6) |
0] |= keyBits[((PC2[i] -
1) + bitShift) %
28] << (
31 - i %
6);
28890 // Select from the right
28 key bits
28891 subKey[
4 + ((i /
6) |
0)] |= keyBits[
28 + (((PC2[i +
24] -
1) + bitShift) %
28)] << (
31 - i %
6);
28894 // Since each subkey is applied to an expanded
32-bit input,
28895 // the subkey can be broken into
8 values scaled to
32-bits,
28896 // which allows the key to be used without expansion
28897 subKey[
0] = (subKey[
0] <<
1) | (subKey[
0]
>>> 31);
28898 for (var i =
1; i <
7; i++) {
28899 subKey[i] = subKey[i]
>>> ((i -
1) *
4 +
3);
28901 subKey[
7] = (subKey[
7] <<
5) | (subKey[
7]
>>> 27);
28904 // Compute inverse subkeys
28905 var invSubKeys = this._invSubKeys = [];
28906 for (var i =
0; i <
16; i++) {
28907 invSubKeys[i] = subKeys[
15 - i];
28911 encryptBlock: function (M, offset) {
28912 this._doCryptBlock(M, offset, this._subKeys);
28915 decryptBlock: function (M, offset) {
28916 this._doCryptBlock(M, offset, this._invSubKeys);
28919 _doCryptBlock: function (M, offset, subKeys) {
28921 this._lBlock = M[offset];
28922 this._rBlock = M[offset +
1];
28924 // Initial permutation
28925 exchangeLR.call(this,
4,
0x0f0f0f0f);
28926 exchangeLR.call(this,
16,
0x0000ffff);
28927 exchangeRL.call(this,
2,
0x33333333);
28928 exchangeRL.call(this,
8,
0x00ff00ff);
28929 exchangeLR.call(this,
1,
0x55555555);
28932 for (var round =
0; round <
16; round++) {
28934 var subKey = subKeys[round];
28935 var lBlock = this._lBlock;
28936 var rBlock = this._rBlock;
28938 // Feistel function
28940 for (var i =
0; i <
8; i++) {
28941 f |= SBOX_P[i][((rBlock ^ subKey[i]) & SBOX_MASK[i])
>>> 0];
28943 this._lBlock = rBlock;
28944 this._rBlock = lBlock ^ f;
28947 // Undo swap from last round
28948 var t = this._lBlock;
28949 this._lBlock = this._rBlock;
28952 // Final permutation
28953 exchangeLR.call(this,
1,
0x55555555);
28954 exchangeRL.call(this,
8,
0x00ff00ff);
28955 exchangeRL.call(this,
2,
0x33333333);
28956 exchangeLR.call(this,
16,
0x0000ffff);
28957 exchangeLR.call(this,
4,
0x0f0f0f0f);
28960 M[offset] = this._lBlock;
28961 M[offset +
1] = this._rBlock;
28971 // Swap bits across the left and right words
28972 function exchangeLR(offset, mask) {
28973 var t = ((this._lBlock
>>> offset) ^ this._rBlock) & mask;
28975 this._lBlock ^= t << offset;
28978 function exchangeRL(offset, mask) {
28979 var t = ((this._rBlock
>>> offset) ^ this._lBlock) & mask;
28981 this._rBlock ^= t << offset;
28985 * Shortcut functions to the cipher's object interface.
28989 * var ciphertext = CryptoJS.DES.encrypt(message, key, cfg);
28990 * var plaintext = CryptoJS.DES.decrypt(ciphertext, key, cfg);
28992 C.DES = BlockCipher._createHelper(DES);
28995 * Triple-DES block cipher algorithm.
28997 var TripleDES = C_algo.TripleDES = BlockCipher.extend({
28998 _doReset: function () {
29000 var key = this._key;
29001 var keyWords = key.words;
29003 // Create DES instances
29004 this._des1 = DES.createEncryptor(WordArray.create(keyWords.slice(
0,
2)));
29005 this._des2 = DES.createEncryptor(WordArray.create(keyWords.slice(
2,
4)));
29006 this._des3 = DES.createEncryptor(WordArray.create(keyWords.slice(
4,
6)));
29009 encryptBlock: function (M, offset) {
29010 this._des1.encryptBlock(M, offset);
29011 this._des2.decryptBlock(M, offset);
29012 this._des3.encryptBlock(M, offset);
29015 decryptBlock: function (M, offset) {
29016 this._des3.decryptBlock(M, offset);
29017 this._des2.encryptBlock(M, offset);
29018 this._des1.decryptBlock(M, offset);
29029 * Shortcut functions to the cipher's object interface.
29033 * var ciphertext = CryptoJS.TripleDES.encrypt(message, key, cfg);
29034 * var plaintext = CryptoJS.TripleDES.decrypt(ciphertext, key, cfg);
29036 C.TripleDES = BlockCipher._createHelper(TripleDES);
29040 return CryptoJS.TripleDES;
29043 },{"./cipher-core":
30,"./core":
31,"./enc-base64":
32,"./evpkdf":
34,"./md5":
39}],
62:[function(_dereq_,module,exports){
29044 ;(function (root, factory) {
29045 if (typeof exports === "object") {
29047 module.exports = exports = factory(_dereq_("./core"));
29049 else if (typeof define === "function" && define.amd) {
29051 define(["./core"], factory);
29054 // Global (browser)
29055 factory(root.CryptoJS);
29057 }(this, function (CryptoJS) {
29059 (function (undefined) {
29063 var Base = C_lib.Base;
29064 var X32WordArray = C_lib.WordArray;
29069 var C_x64 = C.x64 = {};
29074 var X64Word = C_x64.Word = Base.extend({
29076 * Initializes a newly created
64-bit word.
29078 * @param {number} high The high
32 bits.
29079 * @param {number} low The low
32 bits.
29083 * var x64Word = CryptoJS.x64.Word.create(
0x00010203,
0x04050607);
29085 init: function (high, low) {
29091 * Bitwise NOTs this word.
29093 * @return {X64Word} A new x64-Word object after negating.
29097 * var negated = x64Word.not();
29099 // not: function () {
29100 // var high = ~this.high;
29101 // var low = ~this.low;
29103 // return X64Word.create(high, low);
29107 * Bitwise ANDs this word with the passed word.
29109 * @param {X64Word} word The x64-Word to AND with this word.
29111 * @return {X64Word} A new x64-Word object after ANDing.
29115 * var anded = x64Word.and(anotherX64Word);
29117 // and: function (word) {
29118 // var high = this.high & word.high;
29119 // var low = this.low & word.low;
29121 // return X64Word.create(high, low);
29125 * Bitwise ORs this word with the passed word.
29127 * @param {X64Word} word The x64-Word to OR with this word.
29129 * @return {X64Word} A new x64-Word object after ORing.
29133 * var ored = x64Word.or(anotherX64Word);
29135 // or: function (word) {
29136 // var high = this.high | word.high;
29137 // var low = this.low | word.low;
29139 // return X64Word.create(high, low);
29143 * Bitwise XORs this word with the passed word.
29145 * @param {X64Word} word The x64-Word to XOR with this word.
29147 * @return {X64Word} A new x64-Word object after XORing.
29151 * var xored = x64Word.xor(anotherX64Word);
29153 // xor: function (word) {
29154 // var high = this.high ^ word.high;
29155 // var low = this.low ^ word.low;
29157 // return X64Word.create(high, low);
29161 * Shifts this word n bits to the left.
29163 * @param {number} n The number of bits to shift.
29165 * @return {X64Word} A new x64-Word object after shifting.
29169 * var shifted = x64Word.shiftL(
25);
29171 // shiftL: function (n) {
29173 // var high = (this.high << n) | (this.low
>>> (
32 - n));
29174 // var low = this.low << n;
29176 // var high = this.low << (n -
32);
29180 // return X64Word.create(high, low);
29184 * Shifts this word n bits to the right.
29186 * @param {number} n The number of bits to shift.
29188 * @return {X64Word} A new x64-Word object after shifting.
29192 * var shifted = x64Word.shiftR(
7);
29194 // shiftR: function (n) {
29196 // var low = (this.low
>>> n) | (this.high << (
32 - n));
29197 // var high = this.high
>>> n;
29199 // var low = this.high
>>> (n -
32);
29203 // return X64Word.create(high, low);
29207 * Rotates this word n bits to the left.
29209 * @param {number} n The number of bits to rotate.
29211 * @return {X64Word} A new x64-Word object after rotating.
29215 * var rotated = x64Word.rotL(
25);
29217 // rotL: function (n) {
29218 // return this.shiftL(n).or(this.shiftR(
64 - n));
29222 * Rotates this word n bits to the right.
29224 * @param {number} n The number of bits to rotate.
29226 * @return {X64Word} A new x64-Word object after rotating.
29230 * var rotated = x64Word.rotR(
7);
29232 // rotR: function (n) {
29233 // return this.shiftR(n).or(this.shiftL(
64 - n));
29237 * Adds this word with the passed word.
29239 * @param {X64Word} word The x64-Word to add with this word.
29241 * @return {X64Word} A new x64-Word object after adding.
29245 * var added = x64Word.add(anotherX64Word);
29247 // add: function (word) {
29248 // var low = (this.low + word.low) |
0;
29249 // var carry = (low
>>> 0) < (this.low
>>> 0) ?
1 :
0;
29250 // var high = (this.high + word.high + carry) |
0;
29252 // return X64Word.create(high, low);
29257 * An array of
64-bit words.
29259 * @property {Array} words The array of CryptoJS.x64.Word objects.
29260 * @property {number} sigBytes The number of significant bytes in this word array.
29262 var X64WordArray = C_x64.WordArray = Base.extend({
29264 * Initializes a newly created word array.
29266 * @param {Array} words (Optional) An array of CryptoJS.x64.Word objects.
29267 * @param {number} sigBytes (Optional) The number of significant bytes in the words.
29271 * var wordArray = CryptoJS.x64.WordArray.create();
29273 * var wordArray = CryptoJS.x64.WordArray.create([
29274 * CryptoJS.x64.Word.create(
0x00010203,
0x04050607),
29275 * CryptoJS.x64.Word.create(
0x18191a1b,
0x1c1d1e1f)
29278 * var wordArray = CryptoJS.x64.WordArray.create([
29279 * CryptoJS.x64.Word.create(
0x00010203,
0x04050607),
29280 * CryptoJS.x64.Word.create(
0x18191a1b,
0x1c1d1e1f)
29283 init: function (words, sigBytes) {
29284 words = this.words = words || [];
29286 if (sigBytes != undefined) {
29287 this.sigBytes = sigBytes;
29289 this.sigBytes = words.length *
8;
29294 * Converts this
64-bit word array to a
32-bit word array.
29296 * @return {CryptoJS.lib.WordArray} This word array's data as a
32-bit word array.
29300 * var x32WordArray = x64WordArray.toX32();
29302 toX32: function () {
29304 var x64Words = this.words;
29305 var x64WordsLength = x64Words.length;
29309 for (var i =
0; i < x64WordsLength; i++) {
29310 var x64Word = x64Words[i];
29311 x32Words.push(x64Word.high);
29312 x32Words.push(x64Word.low);
29315 return X32WordArray.create(x32Words, this.sigBytes);
29319 * Creates a copy of this word array.
29321 * @return {X64WordArray} The clone.
29325 * var clone = x64WordArray.clone();
29327 clone: function () {
29328 var clone = Base.clone.call(this);
29330 // Clone
"words" array
29331 var words = clone.words = this.words.slice(
0);
29333 // Clone each X64Word object
29334 var wordsLength = words.length;
29335 for (var i =
0; i < wordsLength; i++) {
29336 words[i] = words[i].clone();
29348 },{
"./core":
31}],
63:[function(_dereq_,module,exports){
29349 var assert = _dereq_('assert')
29350 var BigInteger = _dereq_('bigi')
29352 var Point = _dereq_('./point')
29354 function Curve(p, a, b, Gx, Gy, n, h) {
29358 this.G = Point.fromAffine(this, Gx, Gy)
29362 this.infinity = new Point(this, null, null, BigInteger.ZERO)
29365 this.pOverFour = p.add(BigInteger.ONE).shiftRight(
2)
29368 Curve.prototype.pointFromX = function(isOdd, x) {
29369 var alpha = x.pow(
3).add(this.a.multiply(x)).add(this.b).mod(this.p)
29370 var beta = alpha.modPow(this.pOverFour, this.p)
29373 if (beta.isEven() ^ !isOdd) {
29374 y = this.p.subtract(y) // -y % p
29377 return Point.fromAffine(this, x, y)
29380 Curve.prototype.isInfinity = function(Q) {
29381 if (Q === this.infinity) return true
29383 return Q.z.signum() ===
0 && Q.y.signum() !==
0
29386 Curve.prototype.isOnCurve = function(Q) {
29387 if (this.isInfinity(Q)) return true
29395 // Check that xQ and yQ are integers in the interval [
0, p -
1]
29396 if (x.signum() <
0 || x.compareTo(p)
>=
0) return false
29397 if (y.signum() <
0 || y.compareTo(p)
>=
0) return false
29399 // and check that y^
2 = x^
3 + ax + b (mod p)
29400 var lhs = y.square().mod(p)
29401 var rhs = x.pow(
3).add(a.multiply(x)).add(b).mod(p)
29402 return lhs.equals(rhs)
29406 * Validate an elliptic curve point.
29408 * See SEC
1, section
3.2.2.1: Elliptic Curve Public Key Validation Primitive
29410 Curve.prototype.validate = function(Q) {
29412 assert(!this.isInfinity(Q), 'Point is at infinity')
29413 assert(this.isOnCurve(Q), 'Point is not on the curve')
29415 // Check nQ = O (where Q is a scalar multiple of G)
29416 var nQ = Q.multiply(this.n)
29417 assert(this.isInfinity(nQ), 'Point is not a scalar multiple of G')
29422 module.exports = Curve
29424 },{"./point":
67,"assert":
4,"bigi":
3}],
64:[function(_dereq_,module,exports){
29427 "p": "fffffffdffffffffffffffffffffffff",
29428 "a": "fffffffdfffffffffffffffffffffffc",
29429 "b": "e87579c11079f43dd824993c2cee5ed3",
29430 "n": "fffffffe0000000075a30d1b9038a115",
29432 "Gx": "
161ff7528b899b2d0c28607ca52c5b86",
29433 "Gy": "cf5ac8395bafeb13c02da292dded7a83"
29436 "p": "fffffffffffffffffffffffffffffffeffffac73",
29439 "n": "
0100000000000000000001b8fa16dfab9aca16b6b3",
29441 "Gx": "
3b4c382ce37aa192a4019e763036f4f5dd4d7ebb",
29442 "Gy": "
938cf935318fdced6bc28286531733c3f03c4fee"
29445 "p": "ffffffffffffffffffffffffffffffff7fffffff",
29446 "a": "ffffffffffffffffffffffffffffffff7ffffffc",
29447 "b": "
1c97befc54bd7a8b65acf89f81d4d4adc565fa45",
29448 "n": "
0100000000000000000001f4c8f927aed3ca752257",
29450 "Gx": "
4a96b5688ef573284664698968c38bb913cbfc82",
29451 "Gy": "
23a628553168947d59dcc912042351377ac5fb32"
29454 "p": "fffffffffffffffffffffffffffffffffffffffeffffee37",
29457 "n": "fffffffffffffffffffffffe26f2fc170f69466a74defd8d",
29459 "Gx": "db4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d",
29460 "Gy": "
9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d"
29463 "p": "fffffffffffffffffffffffffffffffeffffffffffffffff",
29464 "a": "fffffffffffffffffffffffffffffffefffffffffffffffc",
29465 "b": "
64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1",
29466 "n": "ffffffffffffffffffffffff99def836146bc9b1b4d22831",
29468 "Gx": "
188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012",
29469 "Gy": "
07192b95ffc8da78631011ed6b24cdd573f977a11e794811"
29472 "p": "ffffffffffffffffffffffffffffffff000000000000000000000001",
29473 "a": "fffffffffffffffffffffffffffffffefffffffffffffffffffffffe",
29474 "b": "b4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4",
29475 "n": "ffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3d",
29477 "Gx": "b70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21",
29478 "Gy": "bd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34"
29481 "p": "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f",
29484 "n": "fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",
29486 "Gx": "
79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",
29487 "Gy": "
483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"
29490 "p": "ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",
29491 "a": "ffffffff00000001000000000000000000000000fffffffffffffffffffffffc",
29492 "b": "
5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b",
29493 "n": "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",
29495 "Gx": "
6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296",
29496 "Gy": "
4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"
29500 },{}],
65:[function(_dereq_,module,exports){
29501 var Point = _dereq_('./point')
29502 var Curve = _dereq_('./curve')
29504 var getCurveByName = _dereq_('./names')
29509 getCurveByName: getCurveByName
29512 },{"./curve":
63,"./names":
66,"./point":
67}],
66:[function(_dereq_,module,exports){
29513 var BigInteger = _dereq_('bigi')
29515 var curves = _dereq_('./curves')
29516 var Curve = _dereq_('./curve')
29518 function getCurveByName(name) {
29519 var curve = curves[name]
29520 if (!curve) return null
29522 var p = new BigInteger(curve.p,
16)
29523 var a = new BigInteger(curve.a,
16)
29524 var b = new BigInteger(curve.b,
16)
29525 var n = new BigInteger(curve.n,
16)
29526 var h = new BigInteger(curve.h,
16)
29527 var Gx = new BigInteger(curve.Gx,
16)
29528 var Gy = new BigInteger(curve.Gy,
16)
29530 return new Curve(p, a, b, Gx, Gy, n, h)
29533 module.exports = getCurveByName
29535 },{"./curve":
63,"./curves":
64,"bigi":
3}],
67:[function(_dereq_,module,exports){
29536 (function (Buffer){
29537 var assert = _dereq_('assert')
29538 var BigInteger = _dereq_('bigi')
29540 var THREE = BigInteger.valueOf(
3)
29542 function Point(curve, x, y, z) {
29543 assert.notStrictEqual(z, undefined, 'Missing Z coordinate')
29551 this.compressed = true
29554 Object.defineProperty(Point.prototype, 'zInv', {
29556 if (this._zInv === null) {
29557 this._zInv = this.z.modInverse(this.curve.p)
29564 Object.defineProperty(Point.prototype, 'affineX', {
29566 return this.x.multiply(this.zInv).mod(this.curve.p)
29570 Object.defineProperty(Point.prototype, 'affineY', {
29572 return this.y.multiply(this.zInv).mod(this.curve.p)
29576 Point.fromAffine = function(curve, x, y) {
29577 return new Point(curve, x, y, BigInteger.ONE)
29580 Point.prototype.equals = function(other) {
29581 if (other === this) return true
29582 if (this.curve.isInfinity(this)) return this.curve.isInfinity(other)
29583 if (this.curve.isInfinity(other)) return this.curve.isInfinity(this)
29585 // u = Y2 * Z1 - Y1 * Z2
29586 var u = other.y.multiply(this.z).subtract(this.y.multiply(other.z)).mod(this.curve.p)
29588 if (u.signum() !==
0) return false
29590 // v = X2 * Z1 - X1 * Z2
29591 var v = other.x.multiply(this.z).subtract(this.x.multiply(other.z)).mod(this.curve.p)
29593 return v.signum() ===
0
29596 Point.prototype.negate = function() {
29597 var y = this.curve.p.subtract(this.y)
29599 return new Point(this.curve, this.x, y, this.z)
29602 Point.prototype.add = function(b) {
29603 if (this.curve.isInfinity(this)) return b
29604 if (this.curve.isInfinity(b)) return this
29611 // u = Y2 * Z1 - Y1 * Z2
29612 var u = y2.multiply(this.z).subtract(y1.multiply(b.z)).mod(this.curve.p)
29613 // v = X2 * Z1 - X1 * Z2
29614 var v = x2.multiply(this.z).subtract(x1.multiply(b.z)).mod(this.curve.p)
29616 if (v.signum() ===
0) {
29617 if (u.signum() ===
0) {
29618 return this.twice() // this == b, so double
29621 return this.curve.infinity // this = -b, so infinity
29624 var v2 = v.square()
29625 var v3 = v2.multiply(v)
29626 var x1v2 = x1.multiply(v2)
29627 var zu2 = u.square().multiply(this.z)
29629 // x3 = v * (z2 * (z1 * u^
2 -
2 * x1 * v^
2) - v^
3)
29630 var x3 = zu2.subtract(x1v2.shiftLeft(
1)).multiply(b.z).subtract(v3).multiply(v).mod(this.curve.p)
29631 // y3 = z2 * (
3 * x1 * u * v^
2 - y1 * v^
3 - z1 * u^
3) + u * v^
3
29632 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)
29633 // z3 = v^
3 * z1 * z2
29634 var z3 = v3.multiply(this.z).multiply(b.z).mod(this.curve.p)
29636 return new Point(this.curve, x3, y3, z3)
29639 Point.prototype.twice = function() {
29640 if (this.curve.isInfinity(this)) return this
29641 if (this.y.signum() ===
0) return this.curve.infinity
29646 var y1z1 = y1.multiply(this.z)
29647 var y1sqz1 = y1z1.multiply(y1).mod(this.curve.p)
29648 var a = this.curve.a
29650 // w =
3 * x1^
2 + a * z1^
2
29651 var w = x1.square().multiply(THREE)
29653 if (a.signum() !==
0) {
29654 w = w.add(this.z.square().multiply(a))
29657 w = w.mod(this.curve.p)
29658 // x3 =
2 * y1 * z1 * (w^
2 -
8 * x1 * y1^
2 * z1)
29659 var x3 = w.square().subtract(x1.shiftLeft(
3).multiply(y1sqz1)).shiftLeft(
1).multiply(y1z1).mod(this.curve.p)
29660 // y3 =
4 * y1^
2 * z1 * (
3 * w * x1 -
2 * y1^
2 * z1) - w^
3
29661 var y3 = w.multiply(THREE).multiply(x1).subtract(y1sqz1.shiftLeft(
1)).shiftLeft(
2).multiply(y1sqz1).subtract(w.pow(
3)).mod(this.curve.p)
29662 // z3 =
8 * (y1 * z1)^
3
29663 var z3 = y1z1.pow(
3).shiftLeft(
3).mod(this.curve.p)
29665 return new Point(this.curve, x3, y3, z3)
29668 // Simple NAF (Non-Adjacent Form) multiplication algorithm
29669 // TODO: modularize the multiplication algorithm
29670 Point.prototype.multiply = function(k) {
29671 if (this.curve.isInfinity(this)) return this
29672 if (k.signum() ===
0) return this.curve.infinity
29675 var h = e.multiply(THREE)
29677 var neg = this.negate()
29680 for (var i = h.bitLength() -
2; i
> 0; --i) {
29683 var hBit = h.testBit(i)
29684 var eBit = e.testBit(i)
29686 if (hBit != eBit) {
29687 R = R.add(hBit ? this : neg)
29694 // Compute this*j + x*k (simultaneous multiplication)
29695 Point.prototype.multiplyTwo = function(j, x, k) {
29698 if (j.bitLength()
> k.bitLength())
29699 i = j.bitLength() -
1
29701 i = k.bitLength() -
1
29703 var R = this.curve.infinity
29704 var both = this.add(x)
29709 var jBit = j.testBit(i)
29710 var kBit = k.testBit(i)
29731 Point.prototype.getEncoded = function(compressed) {
29732 if (compressed == undefined) compressed = this.compressed
29733 if (this.curve.isInfinity(this)) return new Buffer('
00', 'hex') // Infinity point encoded is simply '
00'
29735 var x = this.affineX
29736 var y = this.affineY
29740 // Determine size of q in bytes
29741 var byteLength = Math.floor((this.curve.p.bitLength() +
7) /
8)
29745 buffer = new Buffer(
1 + byteLength)
29746 buffer.writeUInt8(y.isEven() ?
0x02 :
0x03,
0)
29750 buffer = new Buffer(
1 + byteLength + byteLength)
29751 buffer.writeUInt8(
0x04,
0)
29753 y.toBuffer(byteLength).copy(buffer,
1 + byteLength)
29756 x.toBuffer(byteLength).copy(buffer,
1)
29761 Point.decodeFrom = function(curve, buffer) {
29762 var type = buffer.readUInt8(
0)
29763 var compressed = (type !==
4)
29765 var x = BigInteger.fromBuffer(buffer.slice(
1,
33))
29766 var byteLength = Math.floor((curve.p.bitLength() +
7) /
8)
29770 assert.equal(buffer.length, byteLength +
1, 'Invalid sequence length')
29771 assert(type ===
0x02 || type ===
0x03, 'Invalid sequence tag')
29773 var isOdd = (type ===
0x03)
29774 Q = curve.pointFromX(isOdd, x)
29777 assert.equal(buffer.length,
1 + byteLength + byteLength, 'Invalid sequence length')
29779 var y = BigInteger.fromBuffer(buffer.slice(
1 + byteLength))
29780 Q = Point.fromAffine(curve, x, y)
29783 Q.compressed = compressed
29787 Point.prototype.toString = function () {
29788 if (this.curve.isInfinity(this)) return '(INFINITY)'
29790 return '(' + this.affineX.toString() + ',' + this.affineY.toString() + ')'
29793 module.exports = Point
29795 }).call(this,_dereq_("buffer").Buffer)
29796 },{"assert":
4,"bigi":
3,"buffer":
8}],
68:[function(_dereq_,module,exports){
29797 (function (process,Buffer){
29798 // Closure compiler error - result of 'not' operator not being used
29799 //!function(globals){
29800 (function(globals){
29804 if (typeof define !== 'undefined' && define.amd) { //require.js / AMD
29805 define([], function() {
29806 return secureRandom
29808 } else if (typeof module !== 'undefined' && module.exports) { //CommonJS
29809 module.exports = secureRandom
29810 } else { //script / browser
29811 globals.secureRandom = secureRandom
29815 //options.type is the only valid option
29816 function secureRandom(count, options) {
29817 options = options || {type: 'Array'}
29818 //we check for process.pid to prevent browserify from tricking us
29819 if (typeof process != 'undefined' && typeof process.pid == 'number') {
29820 return nodeRandom(count, options)
29822 var crypto = window.crypto || window.msCrypto
29823 if (!crypto) throw new Error("Your browser does not support window.crypto.")
29824 return browserRandom(count, options)
29828 function nodeRandom(count, options) {
29829 var crypto = _dereq_('crypto')
29830 var buf = crypto.randomBytes(count)
29832 switch (options.type) {
29834 return [].slice.call(buf)
29838 var arr = new Uint8Array(count)
29839 for (var i =
0; i < count; ++i) { arr[i] = buf.readUInt8(i) }
29842 throw new Error(options.type + " is unsupported.")
29846 function browserRandom(count, options) {
29847 var nativeArr = new Uint8Array(count)
29848 var crypto = window.crypto || window.msCrypto
29849 crypto.getRandomValues(nativeArr)
29851 switch (options.type) {
29853 return [].slice.call(nativeArr)
29855 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.')}
29856 return new Buffer(nativeArr)
29860 throw new Error(options.type + " is unsupported.")
29864 secureRandom.randomArray = function(byteCount) {
29865 return secureRandom(byteCount, {type: 'Array'})
29868 secureRandom.randomUint8Array = function(byteCount) {
29869 return secureRandom(byteCount, {type: 'Uint8Array'})
29872 secureRandom.randomBuffer = function(byteCount) {
29873 return secureRandom(byteCount, {type: 'Buffer'})
29879 }).call(this,_dereq_("FWaASH"),_dereq_("buffer").Buffer)
29880 },{"FWaASH":
12,"buffer":
8,"crypto":
7}],
69:[function(_dereq_,module,exports){
29881 (function (Buffer){
29882 var assert = _dereq_('assert')
29883 var base58check = _dereq_('./base58check')
29884 var networks = _dereq_('./networks')
29885 var scripts = _dereq_('./scripts')
29887 function findScriptTypeByVersion(version) {
29888 for (var networkName in networks) {
29889 var network = networks[networkName]
29891 if (version === network.pubKeyHash) return 'pubkeyhash'
29892 if (version === network.scriptHash) return 'scripthash'
29896 function Address(hash, version) {
29897 assert(Buffer.isBuffer(hash), 'Expected Buffer, got ' + hash)
29898 assert.strictEqual(hash.length,
20, 'Invalid hash length')
29899 assert.strictEqual(version &
0xff, version, 'Invalid version byte')
29902 this.version = version
29905 // Import functions
29906 Address.fromBase58Check = function(string) {
29907 var payload = base58check.decode(string)
29908 var version = payload.readUInt8(
0)
29909 var hash = payload.slice(
1)
29911 return new Address(hash, version)
29914 Address.fromOutputScript = function(script, network) {
29915 network = network || networks.bitcoin
29917 var type = scripts.classifyOutput(script)
29919 if (type === 'pubkeyhash') return new Address(script.chunks[
2], network.pubKeyHash)
29920 if (type === 'scripthash') return new Address(script.chunks[
1], network.scriptHash)
29922 assert(false, type + ' has no matching Address')
29925 // Export functions
29926 Address.prototype.toBase58Check = function () {
29927 var payload = new Buffer(
21)
29928 payload.writeUInt8(this.version,
0)
29929 this.hash.copy(payload,
1)
29931 return base58check.encode(payload)
29934 Address.prototype.toOutputScript = function() {
29935 var scriptType = findScriptTypeByVersion(this.version)
29937 if (scriptType === 'pubkeyhash') return scripts.pubKeyHashOutput(this.hash)
29938 if (scriptType === 'scripthash') return scripts.scriptHashOutput(this.hash)
29940 assert(false, this.toString() + ' has no matching Script')
29943 Address.prototype.toString = Address.prototype.toBase58Check
29945 module.exports = Address
29947 }).call(this,_dereq_("buffer").Buffer)
29948 },{"./base58check":
70,"./networks":
81,"./scripts":
84,"assert":
4,"buffer":
8}],
70:[function(_dereq_,module,exports){
29949 (function (Buffer){
29950 // https://en.bitcoin.it/wiki/Base58Check_encoding
29951 var assert = _dereq_('assert')
29952 var base58 = _dereq_('bs58')
29953 var crypto = _dereq_('./crypto')
29955 // Encode a buffer as a base58-check-encoded string
29956 function encode(payload) {
29957 var checksum = crypto.hash256(payload).slice(
0,
4)
29959 return base58.encode(Buffer.concat([
29965 // Decode a base58-check-encoded string to a buffer
29966 function decode(string) {
29967 var buffer = base58.decode(string)
29969 var payload = buffer.slice(
0, -
4)
29970 var checksum = buffer.slice(-
4)
29971 var newChecksum = crypto.hash256(payload).slice(
0,
4)
29973 assert.deepEqual(newChecksum, checksum, 'Invalid checksum')
29983 }).call(this,_dereq_("buffer").Buffer)
29984 },{"./crypto":
73,"assert":
4,"bs58":
15,"buffer":
8}],
71:[function(_dereq_,module,exports){
29985 var assert = _dereq_('assert')
29986 var opcodes = _dereq_('./opcodes')
29988 // https://github.com/feross/buffer/blob/master/index.js#L1127
29989 function verifuint(value, max) {
29990 assert(typeof value === 'number', 'cannot write a non-number as a number')
29991 assert(value
>=
0, 'specified a negative value for writing an unsigned value')
29992 assert(value <= max, 'value is larger than maximum value for type')
29993 assert(Math.floor(value) === value, 'value has a fractional component')
29996 function pushDataSize(i) {
29997 return i < opcodes.OP_PUSHDATA1 ?
1
30003 function readPushDataInt(buffer, offset) {
30004 var opcode = buffer.readUInt8(offset)
30008 if (opcode < opcodes.OP_PUSHDATA1) {
30013 } else if (opcode === opcodes.OP_PUSHDATA1) {
30014 number = buffer.readUInt8(offset +
1)
30018 } else if (opcode === opcodes.OP_PUSHDATA2) {
30019 number = buffer.readUInt16LE(offset +
1)
30024 assert.equal(opcode, opcodes.OP_PUSHDATA4, 'Unexpected opcode')
30026 number = buffer.readUInt32LE(offset +
1)
30038 function readUInt64LE(buffer, offset) {
30039 var a = buffer.readUInt32LE(offset)
30040 var b = buffer.readUInt32LE(offset +
4)
30043 verifuint(b + a,
0x001fffffffffffff)
30048 function readVarInt(buffer, offset) {
30049 var t = buffer.readUInt8(offset)
30058 } else if (t <
254) {
30059 number = buffer.readUInt16LE(offset +
1)
30063 } else if (t <
255) {
30064 number = buffer.readUInt32LE(offset +
1)
30069 number = readUInt64LE(buffer, offset +
1)
30079 function writePushDataInt(buffer, number, offset) {
30080 var size = pushDataSize(number)
30084 buffer.writeUInt8(number, offset)
30087 } else if (size ===
2) {
30088 buffer.writeUInt8(opcodes.OP_PUSHDATA1, offset)
30089 buffer.writeUInt8(number, offset +
1)
30092 } else if (size ===
3) {
30093 buffer.writeUInt8(opcodes.OP_PUSHDATA2, offset)
30094 buffer.writeUInt16LE(number, offset +
1)
30098 buffer.writeUInt8(opcodes.OP_PUSHDATA4, offset)
30099 buffer.writeUInt32LE(number, offset +
1)
30106 function writeUInt64LE(buffer, value, offset) {
30107 verifuint(value,
0x001fffffffffffff)
30109 buffer.writeInt32LE(value & -
1, offset)
30110 buffer.writeUInt32LE(Math.floor(value /
0x100000000), offset +
4)
30113 function varIntSize(i) {
30116 : i <
0x100000000 ?
5
30120 function writeVarInt(buffer, number, offset) {
30121 var size = varIntSize(number)
30125 buffer.writeUInt8(number, offset)
30128 } else if (size ===
3) {
30129 buffer.writeUInt8(
253, offset)
30130 buffer.writeUInt16LE(number, offset +
1)
30133 } else if (size ===
5) {
30134 buffer.writeUInt8(
254, offset)
30135 buffer.writeUInt32LE(number, offset +
1)
30139 buffer.writeUInt8(
255, offset)
30140 writeUInt64LE(buffer, number, offset +
1)
30147 pushDataSize: pushDataSize,
30148 readPushDataInt: readPushDataInt,
30149 readUInt64LE: readUInt64LE,
30150 readVarInt: readVarInt,
30151 varIntSize: varIntSize,
30152 writePushDataInt: writePushDataInt,
30153 writeUInt64LE: writeUInt64LE,
30154 writeVarInt: writeVarInt
30157 },{"./opcodes":
82,"assert":
4}],
72:[function(_dereq_,module,exports){
30158 (function (Buffer){
30159 var assert = _dereq_('assert')
30160 var Crypto = _dereq_('crypto-js')
30161 var WordArray = Crypto.lib.WordArray
30163 function bufferToWordArray(buffer) {
30164 assert(Buffer.isBuffer(buffer), 'Expected Buffer, got', buffer)
30167 for (var i =
0, b =
0; i < buffer.length; i++, b +=
8) {
30168 words[b
>>> 5] |= buffer[i] << (
24 - b %
32)
30171 return new WordArray.init(words, buffer.length)
30174 function wordArrayToBuffer(wordArray) {
30175 assert(Array.isArray(wordArray.words), 'Expected WordArray, got' + wordArray)
30177 var words = wordArray.words
30178 var buffer = new Buffer(words.length *
4)
30180 words.forEach(function(value, i) {
30181 buffer.writeInt32BE(value & -
1, i *
4)
30188 bufferToWordArray: bufferToWordArray,
30189 wordArrayToBuffer: wordArrayToBuffer
30192 }).call(this,_dereq_(
"buffer").Buffer)
30193 },{
"assert":
4,
"buffer":
8,
"crypto-js":
37}],
73:[function(_dereq_,module,exports){
30194 (function (Buffer){
30195 // Crypto, crypto, where art thou crypto
30196 var assert = _dereq_('assert')
30197 var CryptoJS = _dereq_('crypto-js')
30198 var crypto = _dereq_('crypto')
30199 var convert = _dereq_('./convert')
30201 function hash160(buffer) {
30202 return ripemd160(sha256(buffer))
30205 function hash256(buffer) {
30206 return sha256(sha256(buffer))
30209 function ripemd160(buffer) {
30210 return crypto.createHash('rmd160').update(buffer).digest()
30213 function sha1(buffer) {
30214 return crypto.createHash('sha1').update(buffer).digest()
30217 function sha256(buffer) {
30218 return crypto.createHash('sha256').update(buffer).digest()
30221 // FIXME: Name not consistent with others
30222 function HmacSHA256(buffer, secret) {
30223 return crypto.createHmac('sha256', secret).update(buffer).digest()
30226 function HmacSHA512(data, secret) {
30227 assert(Buffer.isBuffer(data), 'Expected Buffer for data, got ' + data)
30228 assert(Buffer.isBuffer(secret), 'Expected Buffer for secret, got ' + secret)
30230 var dataWords = convert.bufferToWordArray(data)
30231 var secretWords = convert.bufferToWordArray(secret)
30233 var hash = CryptoJS.HmacSHA512(dataWords, secretWords)
30235 return convert.wordArrayToBuffer(hash)
30239 ripemd160: ripemd160,
30244 HmacSHA256: HmacSHA256,
30245 HmacSHA512: HmacSHA512
30248 }).call(this,_dereq_(
"buffer").Buffer)
30249 },{
"./convert":
72,
"assert":
4,
"buffer":
8,
"crypto":
19,
"crypto-js":
37}],
74:[function(_dereq_,module,exports){
30250 (function (Buffer){
30251 var assert = _dereq_('assert')
30252 var crypto = _dereq_('./crypto')
30254 var BigInteger = _dereq_('bigi')
30255 var ECSignature = _dereq_('./ecsignature')
30256 var Point = _dereq_('ecurve').Point
30258 // https://tools.ietf.org/html/rfc6979#section-
3.2
30259 function deterministicGenerateK(curve, hash, d) {
30260 assert(Buffer.isBuffer(hash), 'Hash must be a Buffer, not ' + hash)
30261 assert.equal(hash.length,
32, 'Hash must be
256 bit')
30262 assert(d instanceof BigInteger, 'Private key must be a BigInteger')
30264 var x = d.toBuffer(
32)
30265 var k = new Buffer(
32)
30266 var v = new Buffer(
32)
30275 k = crypto.HmacSHA256(Buffer.concat([v, new Buffer([
0]), x, hash]), k)
30278 v = crypto.HmacSHA256(v, k)
30281 k = crypto.HmacSHA256(Buffer.concat([v, new Buffer([
1]), x, hash]), k)
30284 v = crypto.HmacSHA256(v, k)
30286 // Step H1/H2a, ignored as tlen === qlen (
256 bit)
30288 v = crypto.HmacSHA256(v, k)
30290 var T = BigInteger.fromBuffer(v)
30292 // Step H3, repeat until T is within the interval [
1, n -
1]
30293 while ((T.signum() <=
0) || (T.compareTo(curve.n)
>=
0)) {
30294 k = crypto.HmacSHA256(Buffer.concat([v, new Buffer([
0])]), k)
30295 v = crypto.HmacSHA256(v, k)
30297 T = BigInteger.fromBuffer(v)
30303 function sign(curve, hash, d) {
30304 var k = deterministicGenerateK(curve, hash, d)
30308 var Q = G.multiply(k)
30309 var e = BigInteger.fromBuffer(hash)
30311 var r = Q.affineX.mod(n)
30312 assert.notEqual(r.signum(),
0, 'Invalid R value')
30314 var s = k.modInverse(n).multiply(e.add(d.multiply(r))).mod(n)
30315 assert.notEqual(s.signum(),
0, 'Invalid S value')
30317 var N_OVER_TWO = n.shiftRight(
1)
30319 // enforce low S values, see bip62: 'low s values in signatures'
30320 if (s.compareTo(N_OVER_TWO)
> 0) {
30324 return new ECSignature(r, s)
30327 function verify(curve, hash, signature, Q) {
30328 var e = BigInteger.fromBuffer(hash)
30330 return verifyRaw(curve, e, signature, Q)
30333 function verifyRaw(curve, e, signature, Q) {
30337 var r = signature.r
30338 var s = signature.s
30340 if (r.signum() ===
0 || r.compareTo(n)
>=
0) return false
30341 if (s.signum() ===
0 || s.compareTo(n)
>=
0) return false
30343 var c = s.modInverse(n)
30345 var u1 = e.multiply(c).mod(n)
30346 var u2 = r.multiply(c).mod(n)
30348 var point = G.multiplyTwo(u1, Q, u2)
30349 var v = point.affineX.mod(n)
30355 * Recover a public key from a signature.
30357 * See SEC
1: Elliptic Curve Cryptography, section
4.1.6, "Public
30358 * Key Recovery Operation".
30360 * http://www.secg.org/download/aid-
780/sec1-v2.pdf
30362 function recoverPubKey(curve, e, signature, i) {
30363 assert.strictEqual(i &
3, i, 'Recovery param is more than two bits')
30365 var r = signature.r
30366 var s = signature.s
30368 // A set LSB signifies that the y-coordinate is odd
30371 // The more significant bit specifies whether we should use the
30372 // first or second candidate key.
30373 var isSecondKey = i
>> 1
30378 //
1.1 Let x = r + jn
30379 var x = isSecondKey ? r.add(n) : r
30380 var R = curve.pointFromX(isYOdd, x)
30382 //
1.4 Check that nR is at infinity
30383 var nR = R.multiply(n)
30384 assert(curve.isInfinity(nR), 'nR is not a valid curve point')
30386 // Compute -e from e
30387 var eNeg = e.negate().mod(n)
30389 //
1.6.1 Compute Q = r^-
1 (sR - eG)
30390 // Q = r^-
1 (sR + -eG)
30391 var rInv = r.modInverse(n)
30393 var Q = R.multiplyTwo(s, G, eNeg).multiply(rInv)
30400 * Calculate pubkey extraction parameter.
30402 * When extracting a pubkey from a signature, we have to
30403 * distinguish four different cases. Rather than putting this
30404 * burden on the verifier, Bitcoin includes a
2-bit value with the
30407 * This function simply tries all four cases and returns the value
30408 * that resulted in a successful pubkey recovery.
30410 function calcPubKeyRecoveryParam(curve, e, signature, Q) {
30411 for (var i =
0; i <
4; i++) {
30412 var Qprime = recoverPubKey(curve, e, signature, i)
30415 if (Qprime.equals(Q)) {
30420 throw new Error('Unable to find valid recovery factor')
30424 calcPubKeyRecoveryParam: calcPubKeyRecoveryParam,
30425 deterministicGenerateK: deterministicGenerateK,
30426 recoverPubKey: recoverPubKey,
30429 verifyRaw: verifyRaw
30432 }).call(this,_dereq_(
"buffer").Buffer)
30433 },{
"./crypto":
73,
"./ecsignature":
77,
"assert":
4,
"bigi":
3,
"buffer":
8,
"ecurve":
65}],
75:[function(_dereq_,module,exports){
30434 (function (Buffer){
30435 var assert = _dereq_('assert')
30436 var base58check = _dereq_('./base58check')
30437 var ecdsa = _dereq_('./ecdsa')
30438 var networks = _dereq_('./networks')
30439 var secureRandom = _dereq_('secure-random')
30441 var BigInteger = _dereq_('bigi')
30442 var ECPubKey = _dereq_('./ecpubkey')
30444 var ecurve = _dereq_('ecurve')
30445 var curve = ecurve.getCurveByName('secp256k1')
30447 function ECKey(d, compressed) {
30448 assert(d.signum()
> 0, 'Private key must be greater than
0')
30449 assert(d.compareTo(curve.n) <
0, 'Private key must be less than the curve order')
30451 var Q = curve.G.multiply(d)
30454 this.pub = new ECPubKey(Q, compressed)
30457 // Static constructors
30458 ECKey.fromWIF = function(string) {
30459 var payload = base58check.decode(string)
30460 var compressed = false
30462 // Ignore the version byte
30463 payload = payload.slice(
1)
30465 if (payload.length ===
33) {
30466 assert.strictEqual(payload[
32],
0x01, 'Invalid compression flag')
30468 // Truncate the compression flag
30469 payload = payload.slice(
0, -
1)
30473 assert.equal(payload.length,
32, 'Invalid WIF payload length')
30475 var d = BigInteger.fromBuffer(payload)
30476 return new ECKey(d, compressed)
30479 ECKey.makeRandom = function(compressed, rng) {
30480 rng = rng || secureRandom.randomBuffer
30482 var buffer = rng(
32)
30483 assert(Buffer.isBuffer(buffer), 'Expected Buffer, got ' + buffer)
30485 var d = BigInteger.fromBuffer(buffer)
30488 return new ECKey(d, compressed)
30491 // Export functions
30492 ECKey.prototype.toWIF = function(network) {
30493 network = network || networks.bitcoin
30495 var bufferLen = this.pub.compressed ?
34 :
33
30496 var buffer = new Buffer(bufferLen)
30498 buffer.writeUInt8(network.wif,
0)
30499 this.d.toBuffer(
32).copy(buffer,
1)
30501 if (this.pub.compressed) {
30502 buffer.writeUInt8(
0x01,
33)
30505 return base58check.encode(buffer)
30509 ECKey.prototype.sign = function(hash) {
30510 return ecdsa.sign(curve, hash, this.d)
30513 module.exports = ECKey
30515 }).call(this,_dereq_(
"buffer").Buffer)
30516 },{
"./base58check":
70,
"./ecdsa":
74,
"./ecpubkey":
76,
"./networks":
81,
"assert":
4,
"bigi":
3,
"buffer":
8,
"ecurve":
65,
"secure-random":
68}],
76:[function(_dereq_,module,exports){
30517 (function (Buffer){
30518 var assert = _dereq_('assert')
30519 var crypto = _dereq_('./crypto')
30520 var ecdsa = _dereq_('./ecdsa')
30521 var networks = _dereq_('./networks')
30523 var Address = _dereq_('./address')
30525 var ecurve = _dereq_('ecurve')
30526 var curve = ecurve.getCurveByName('secp256k1')
30528 function ECPubKey(Q, compressed) {
30529 assert(Q instanceof ecurve.Point, 'Expected Point, got ' + Q)
30531 if (compressed == undefined) compressed = true
30532 assert.strictEqual(typeof compressed, 'boolean', 'Expected boolean, got ' + compressed)
30534 this.compressed = compressed
30538 // Static constructors
30539 ECPubKey.fromBuffer = function(buffer) {
30540 var Q = ecurve.Point.decodeFrom(curve, buffer)
30541 return new ECPubKey(Q, Q.compressed)
30544 ECPubKey.fromHex = function(hex) {
30545 return ECPubKey.fromBuffer(new Buffer(hex, 'hex'))
30549 ECPubKey.prototype.getAddress = function(network) {
30550 network = network || networks.bitcoin
30552 return new Address(crypto.hash160(this.toBuffer()), network.pubKeyHash)
30555 ECPubKey.prototype.verify = function(hash, signature) {
30556 return ecdsa.verify(curve, hash, signature, this.Q)
30559 // Export functions
30560 ECPubKey.prototype.toBuffer = function() {
30561 return this.Q.getEncoded(this.compressed)
30564 ECPubKey.prototype.toHex = function() {
30565 return this.toBuffer().toString('hex')
30568 module.exports = ECPubKey
30570 }).call(this,_dereq_(
"buffer").Buffer)
30571 },{
"./address":
69,
"./crypto":
73,
"./ecdsa":
74,
"./networks":
81,
"assert":
4,
"buffer":
8,
"ecurve":
65}],
77:[function(_dereq_,module,exports){
30572 (function (Buffer){
30573 var assert = _dereq_('assert')
30574 var BigInteger = _dereq_('bigi')
30576 function ECSignature(r, s) {
30577 assert(r instanceof BigInteger, 'Expected BigInteger, got ' + r)
30578 assert(s instanceof BigInteger, 'Expected BigInteger, got ' + s)
30583 // Import operations
30584 ECSignature.parseCompact = function(buffer) {
30585 assert.equal(buffer.length,
65, 'Invalid signature length')
30586 var i = buffer.readUInt8(
0) -
27
30589 assert.equal(i, i &
7, 'Invalid signature parameter')
30590 var compressed = !!(i &
4)
30592 // Recovery param only
30595 var r = BigInteger.fromBuffer(buffer.slice(
1,
33))
30596 var s = BigInteger.fromBuffer(buffer.slice(
33))
30599 compressed: compressed,
30601 signature: new ECSignature(r, s)
30605 ECSignature.fromDER = function(buffer) {
30606 assert.equal(buffer.readUInt8(
0),
0x30, 'Not a DER sequence')
30607 assert.equal(buffer.readUInt8(
1), buffer.length -
2, 'Invalid sequence length')
30608 assert.equal(buffer.readUInt8(
2),
0x02, 'Expected a DER integer')
30610 var rLen = buffer.readUInt8(
3)
30611 assert(rLen
> 0, 'R length is zero')
30613 var offset =
4 + rLen
30614 assert.equal(buffer.readUInt8(offset),
0x02, 'Expected a DER integer (
2)')
30616 var sLen = buffer.readUInt8(offset +
1)
30617 assert(sLen
> 0, 'S length is zero')
30619 var rB = buffer.slice(
4, offset)
30620 var sB = buffer.slice(offset +
2)
30623 if (rLen
> 1 && rB.readUInt8(
0) ===
0x00) {
30624 assert(rB.readUInt8(
1) &
0x80, 'R value excessively padded')
30627 if (sLen
> 1 && sB.readUInt8(
0) ===
0x00) {
30628 assert(sB.readUInt8(
1) &
0x80, 'S value excessively padded')
30631 assert.equal(offset, buffer.length, 'Invalid DER encoding')
30632 var r = BigInteger.fromDERInteger(rB)
30633 var s = BigInteger.fromDERInteger(sB)
30635 assert(r.signum()
>=
0, 'R value is negative')
30636 assert(s.signum()
>=
0, 'S value is negative')
30638 return new ECSignature(r, s)
30641 // FIXME:
0x00,
0x04,
0x80 are SIGHASH_* boundary constants, importing Transaction causes a circular dependency
30642 ECSignature.parseScriptSignature = function(buffer) {
30643 var hashType = buffer.readUInt8(buffer.length -
1)
30644 var hashTypeMod = hashType & ~
0x80
30646 assert(hashTypeMod
> 0x00 && hashTypeMod <
0x04, 'Invalid hashType')
30649 signature: ECSignature.fromDER(buffer.slice(
0, -
1)),
30654 // Export operations
30655 ECSignature.prototype.toCompact = function(i, compressed) {
30656 if (compressed) i +=
4
30659 var buffer = new Buffer(
65)
30660 buffer.writeUInt8(i,
0)
30662 this.r.toBuffer(
32).copy(buffer,
1)
30663 this.s.toBuffer(
32).copy(buffer,
33)
30668 ECSignature.prototype.toDER = function() {
30669 var rBa = this.r.toDERInteger()
30670 var sBa = this.s.toDERInteger()
30673 sequence.push(
0x02) // INTEGER
30674 sequence.push(rBa.length)
30675 sequence = sequence.concat(rBa)
30677 sequence.push(
0x02) // INTEGER
30678 sequence.push(sBa.length)
30679 sequence = sequence.concat(sBa)
30681 sequence.unshift(sequence.length)
30682 sequence.unshift(
0x30) // SEQUENCE
30684 return new Buffer(sequence)
30687 ECSignature.prototype.toScriptSignature = function(hashType) {
30688 var hashTypeBuffer = new Buffer(
1)
30689 hashTypeBuffer.writeUInt8(hashType,
0)
30691 return Buffer.concat([this.toDER(), hashTypeBuffer])
30694 module.exports = ECSignature
30696 }).call(this,_dereq_(
"buffer").Buffer)
30697 },{
"assert":
4,
"bigi":
3,
"buffer":
8}],
78:[function(_dereq_,module,exports){
30698 (function (Buffer){
30699 var assert = _dereq_('assert')
30700 var base58check = _dereq_('./base58check')
30701 var crypto = _dereq_('./crypto')
30702 var networks = _dereq_('./networks')
30704 var BigInteger = _dereq_('bigi')
30705 var ECKey = _dereq_('./eckey')
30706 var ECPubKey = _dereq_('./ecpubkey')
30708 var ecurve = _dereq_('ecurve')
30709 var curve = ecurve.getCurveByName('secp256k1')
30711 function findBIP32ParamsByVersion(version) {
30712 for (var name in networks) {
30713 var network = networks[name]
30715 for (var type in network.bip32) {
30716 if (version != network.bip32[type]) continue
30719 isPrivate: (type === 'private'),
30725 assert(false, 'Could not find version ' + version.toString(
16))
30728 function HDNode(K, chainCode, network) {
30729 network = network || networks.bitcoin
30731 assert(Buffer.isBuffer(chainCode), 'Expected Buffer, got ' + chainCode)
30732 assert(network.bip32, 'Unknown BIP32 constants for network')
30734 this.chainCode = chainCode
30737 this.network = network
30739 if (K instanceof BigInteger) {
30740 this.privKey = new ECKey(K, true)
30741 this.pubKey = this.privKey.pub
30743 this.pubKey = new ECPubKey(K, true)
30747 HDNode.MASTER_SECRET = new Buffer('Bitcoin seed')
30748 HDNode.HIGHEST_BIT =
0x80000000
30751 HDNode.fromSeedBuffer = function(seed, network) {
30752 var I = crypto.HmacSHA512(seed, HDNode.MASTER_SECRET)
30753 var IL = I.slice(
0,
32)
30754 var IR = I.slice(
32)
30756 // In case IL is
0 or
>= n, the master key is invalid
30757 // This is handled by `new ECKey` in the HDNode constructor
30758 var pIL = BigInteger.fromBuffer(IL)
30760 return new HDNode(pIL, IR, network)
30763 HDNode.fromSeedHex = function(hex, network) {
30764 return HDNode.fromSeedBuffer(new Buffer(hex, 'hex'), network)
30767 HDNode.fromBase58 = function(string) {
30768 return HDNode.fromBuffer(base58check.decode(string))
30771 HDNode.fromBuffer = function(buffer) {
30772 assert.strictEqual(buffer.length, HDNode.LENGTH, 'Invalid buffer length')
30774 //
4 byte: version bytes
30775 var version = buffer.readUInt32BE(
0)
30776 var params = findBIP32ParamsByVersion(version)
30778 //
1 byte: depth:
0x00 for master nodes,
0x01 for level-
1 descendants, ...
30779 var depth = buffer.readUInt8(
4)
30781 //
4 bytes: the fingerprint of the parent's key (
0x00000000 if master key)
30782 var parentFingerprint = buffer.readUInt32BE(
5)
30784 assert.strictEqual(parentFingerprint,
0x00000000, 'Invalid parent fingerprint')
30787 //
4 bytes: child number. This is the number i in xi = xpar/i, with xi the key being serialized.
30788 // This is encoded in MSB order. (
0x00000000 if master key)
30789 var index = buffer.readUInt32BE(
9)
30790 assert(depth
> 0 || index ===
0, 'Invalid index')
30792 //
32 bytes: the chain code
30793 var chainCode = buffer.slice(
13,
45)
30796 //
33 bytes: private key data (
0x00 + k)
30797 if (params.isPrivate) {
30798 assert.strictEqual(buffer.readUInt8(
45),
0x00, 'Invalid private key')
30799 var data = buffer.slice(
46,
78)
30800 var d = BigInteger.fromBuffer(data)
30801 hd = new HDNode(d, chainCode, params.network)
30803 //
33 bytes: public key data (
0x02 + X or
0x03 + X)
30805 var data = buffer.slice(
45,
78)
30806 var Q = ecurve.Point.decodeFrom(curve, data)
30807 assert.equal(Q.compressed, true, 'Invalid public key')
30809 // Verify that the X coordinate in the public point corresponds to a point on the curve.
30810 // If not, the extended public key is invalid.
30813 hd = new HDNode(Q, chainCode, params.network)
30818 hd.parentFingerprint = parentFingerprint
30823 HDNode.fromHex = function(hex) {
30824 return HDNode.fromBuffer(new Buffer(hex, 'hex'))
30827 HDNode.prototype.getIdentifier = function() {
30828 return crypto.hash160(this.pubKey.toBuffer())
30831 HDNode.prototype.getFingerprint = function() {
30832 return this.getIdentifier().slice(
0,
4)
30835 HDNode.prototype.getAddress = function() {
30836 return this.pubKey.getAddress(this.network)
30839 HDNode.prototype.toBase58 = function(isPrivate) {
30840 return base58check.encode(this.toBuffer(isPrivate))
30843 HDNode.prototype.toBuffer = function(isPrivate) {
30844 if (isPrivate == undefined) isPrivate = !!this.privKey
30847 var version = isPrivate ? this.network.bip32.private : this.network.bip32.public
30848 var buffer = new Buffer(HDNode.LENGTH)
30850 //
4 bytes: version bytes
30851 buffer.writeUInt32BE(version,
0)
30854 //
1 byte: depth:
0x00 for master nodes,
0x01 for level-
1 descendants, ....
30855 buffer.writeUInt8(this.depth,
4)
30857 //
4 bytes: the fingerprint of the parent's key (
0x00000000 if master key)
30858 var fingerprint = (this.depth ===
0) ?
0x00000000 : this.parentFingerprint
30859 buffer.writeUInt32BE(fingerprint,
5)
30861 //
4 bytes: child number. This is the number i in xi = xpar/i, with xi the key being serialized.
30862 // This is encoded in Big endian. (
0x00000000 if master key)
30863 buffer.writeUInt32BE(this.index,
9)
30865 //
32 bytes: the chain code
30866 this.chainCode.copy(buffer,
13)
30868 //
33 bytes: the public key or private key data
30870 assert(this.privKey, 'Missing private key')
30872 //
0x00 + k for private keys
30873 buffer.writeUInt8(
0,
45)
30874 this.privKey.d.toBuffer(
32).copy(buffer,
46)
30877 // X9.62 encoding for public keys
30878 this.pubKey.toBuffer().copy(buffer,
45)
30884 HDNode.prototype.toHex = function(isPrivate) {
30885 return this.toBuffer(isPrivate).toString('hex')
30888 // https://github.com/bitcoin/bips/blob/master/bip-
0032.mediawiki#child-key-derivation-ckd-functions
30889 HDNode.prototype.derive = function(index) {
30890 var isHardened = index
>= HDNode.HIGHEST_BIT
30891 var indexBuffer = new Buffer(
4)
30892 indexBuffer.writeUInt32BE(index,
0)
30898 assert(this.privKey, 'Could not derive hardened child key')
30900 // data =
0x00 || ser256(kpar) || ser32(index)
30901 data = Buffer.concat([
30902 this.privKey.d.toBuffer(
33),
30908 // data = serP(point(kpar)) || ser32(index)
30909 // = serP(Kpar) || ser32(index)
30910 data = Buffer.concat([
30911 this.pubKey.toBuffer(),
30916 var I = crypto.HmacSHA512(data, this.chainCode)
30917 var IL = I.slice(
0,
32)
30918 var IR = I.slice(
32)
30920 var pIL = BigInteger.fromBuffer(IL)
30922 // In case parse256(IL)
>= n, proceed with the next value for i
30923 if (pIL.compareTo(curve.n)
>=
0) {
30924 return this.derive(index +
1)
30927 // Private parent key -
> private child key
30929 if (this.privKey) {
30930 // ki = parse256(IL) + kpar (mod n)
30931 var ki = pIL.add(this.privKey.d).mod(curve.n)
30933 // In case ki ==
0, proceed with the next value for i
30934 if (ki.signum() ===
0) {
30935 return this.derive(index +
1)
30938 hd = new HDNode(ki, IR, this.network)
30940 // Public parent key -
> public child key
30942 // Ki = point(parse256(IL)) + Kpar
30944 var Ki = curve.G.multiply(pIL).add(this.pubKey.Q)
30946 // In case Ki is the point at infinity, proceed with the next value for i
30947 if (curve.isInfinity(Ki)) {
30948 return this.derive(index +
1)
30951 hd = new HDNode(Ki, IR, this.network)
30954 hd.depth = this.depth +
1
30956 hd.parentFingerprint = this.getFingerprint().readUInt32BE(
0)
30961 HDNode.prototype.deriveHardened = function(index) {
30962 // Only derives hardened private keys by default
30963 return this.derive(index + HDNode.HIGHEST_BIT)
30966 HDNode.prototype.toString = HDNode.prototype.toBase58
30968 module.exports = HDNode
30970 }).call(this,_dereq_("buffer").Buffer)
30971 },{"./base58check":
70,"./crypto":
73,"./eckey":
75,"./ecpubkey":
76,"./networks":
81,"assert":
4,"bigi":
3,"buffer":
8,"ecurve":
65}],
79:[function(_dereq_,module,exports){
30973 Address: _dereq_('./address'),
30974 base58check: _dereq_('./base58check'),
30975 bufferutils: _dereq_('./bufferutils'),
30976 convert: _dereq_('./convert'),
30977 crypto: _dereq_('./crypto'),
30978 ecdsa: _dereq_('./ecdsa'),
30979 ECKey: _dereq_('./eckey'),
30980 ECPubKey: _dereq_('./ecpubkey'),
30981 ECSignature: _dereq_('./ecsignature'),
30982 Message: _dereq_('./message'),
30983 opcodes: _dereq_('./opcodes'),
30984 HDNode: _dereq_('./hdnode'),
30985 Script: _dereq_('./script'),
30986 scripts: _dereq_('./scripts'),
30987 Transaction: _dereq_('./transaction'),
30988 networks: _dereq_('./networks'),
30989 Wallet: _dereq_('./wallet')
30992 },{"./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){
30993 (function (Buffer){
30994 /// Implements Bitcoin's feature for signing arbitrary messages.
30995 var Address = _dereq_('./address')
30996 var BigInteger = _dereq_('bigi')
30997 var bufferutils = _dereq_('./bufferutils')
30998 var crypto = _dereq_('./crypto')
30999 var ecdsa = _dereq_('./ecdsa')
31000 var networks = _dereq_('./networks')
31002 var Address = _dereq_('./address')
31003 var ECPubKey = _dereq_('./ecpubkey')
31004 var ECSignature = _dereq_('./ecsignature')
31006 var ecurve = _dereq_('ecurve')
31007 var ecparams = ecurve.getCurveByName('secp256k1')
31009 function magicHash(message, network) {
31010 var magicPrefix = new Buffer(network.magicPrefix)
31011 var messageBuffer = new Buffer(message)
31012 var lengthBuffer = new Buffer(bufferutils.varIntSize(messageBuffer.length))
31013 bufferutils.writeVarInt(lengthBuffer, messageBuffer.length,
0)
31015 var buffer = Buffer.concat([magicPrefix, lengthBuffer, messageBuffer])
31016 return crypto.hash256(buffer)
31019 function sign(privKey, message, network) {
31020 network = network || networks.bitcoin
31022 var hash = magicHash(message, network)
31023 var signature = privKey.sign(hash)
31024 var e = BigInteger.fromBuffer(hash)
31025 var i = ecdsa.calcPubKeyRecoveryParam(ecparams, e, signature, privKey.pub.Q)
31027 return signature.toCompact(i, privKey.pub.compressed)
31030 // TODO: network could be implied from address
31031 function verify(address, signatureBuffer, message, network) {
31032 if (address instanceof Address) {
31033 address = address.toString()
31035 network = network || networks.bitcoin
31037 var hash = magicHash(message, network)
31038 var parsed = ECSignature.parseCompact(signatureBuffer)
31039 var e = BigInteger.fromBuffer(hash)
31040 var Q = ecdsa.recoverPubKey(ecparams, e, parsed.signature, parsed.i)
31042 var pubKey = new ECPubKey(Q, parsed.compressed)
31043 return pubKey.getAddress(network).toString() === address
31047 magicHash: magicHash,
31052 }).call(this,_dereq_("buffer").Buffer)
31053 },{"./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){
31054 // https://en.bitcoin.it/wiki/List_of_address_prefixes
31055 // Dogecoin BIP32 is a proposed standard: https://bitcointalk.org/index.php?topic=
409731
31059 magicPrefix: '\x18Bitcoin Signed Message:\n',
31061 public:
0x0488b21e,
31062 private:
0x0488ade4
31067 dustThreshold:
546, // https://github.com/bitcoin/bitcoin/blob/v0.9
.2/src/core.h#L151-L162
31068 feePerKb:
10000, // https://github.com/bitcoin/bitcoin/blob/v0.9
.2/src/main.cpp#L53
31069 estimateFee: estimateFee('bitcoin')
31072 magicPrefix: '\x19Dogecoin Signed Message:\n',
31074 public:
0x02facafd,
31075 private:
0x02fac398
31080 dustThreshold:
0, // https://github.com/dogecoin/dogecoin/blob/v1.7
.1/src/core.h#L155-L160
31081 dustSoftThreshold:
100000000, // https://github.com/dogecoin/dogecoin/blob/v1.7
.1/src/main.h#L62
31082 feePerKb:
100000000, // https://github.com/dogecoin/dogecoin/blob/v1.7
.1/src/main.cpp#L58
31083 estimateFee: estimateFee('dogecoin')
31086 magicPrefix: '\x19Litecoin Signed Message:\n',
31088 public:
0x019da462,
31089 private:
0x019d9cfe
31094 dustThreshold:
0, // https://github.com/litecoin-project/litecoin/blob/v0.8
.7.2/src/main.cpp#L360-L365
31095 dustSoftThreshold:
100000, // https://github.com/litecoin-project/litecoin/blob/v0.8
.7.2/src/main.h#L53
31096 feePerKb:
100000, // https://github.com/litecoin-project/litecoin/blob/v0.8
.7.2/src/main.cpp#L56
31097 estimateFee: estimateFee('litecoin')
31100 magicPrefix: '\x18Bitcoin Signed Message:\n',
31102 public:
0x043587cf,
31103 private:
0x04358394
31108 dustThreshold:
546,
31110 estimateFee: estimateFee('testnet')
31114 function estimateFee(type) {
31115 return function(tx) {
31116 var network = networks[type]
31117 var baseFee = network.feePerKb
31118 var byteSize = tx.toBuffer().length
31120 var fee = baseFee * Math.ceil(byteSize /
1000)
31121 if (network.dustSoftThreshold == undefined) return fee
31123 tx.outs.forEach(function(e){
31124 if (e.value < network.dustSoftThreshold) {
31133 module.exports = networks
31135 },{}],
82:[function(_dereq_,module,exports){
31176 OP_TOALTSTACK :
107,
31177 OP_FROMALTSTACK :
108,
31209 OP_EQUALVERIFY :
136,
31210 OP_RESERVED1 :
137,
31211 OP_RESERVED2 :
138,
31221 OP_0NOTEQUAL :
146,
31234 OP_NUMEQUALVERIFY :
157,
31235 OP_NUMNOTEQUAL :
158,
31237 OP_GREATERTHAN :
160,
31238 OP_LESSTHANOREQUAL :
161,
31239 OP_GREATERTHANOREQUAL :
162,
31246 OP_RIPEMD160 :
166,
31251 OP_CODESEPARATOR :
171,
31253 OP_CHECKSIGVERIFY :
173,
31254 OP_CHECKMULTISIG :
174,
31255 OP_CHECKMULTISIGVERIFY :
175,
31269 // template matching params
31270 OP_PUBKEYHASH :
253,
31272 OP_INVALIDOPCODE :
255
31275 },{}],
83:[function(_dereq_,module,exports){
31276 (function (Buffer){
31277 var assert = _dereq_('assert')
31278 var bufferutils = _dereq_('./bufferutils')
31279 var crypto = _dereq_('./crypto')
31280 var opcodes = _dereq_('./opcodes')
31282 function Script(buffer, chunks) {
31283 assert(Buffer.isBuffer(buffer), 'Expected Buffer, got ' + buffer)
31284 assert(Array.isArray(chunks), 'Expected Array, got ' + chunks)
31286 this.buffer = buffer
31287 this.chunks = chunks
31290 // Import operations
31291 Script.fromASM = function(asm) {
31292 var strChunks = asm.split(' ')
31294 var chunks = strChunks.map(function(strChunk) {
31295 if (strChunk in opcodes) {
31296 return opcodes[strChunk]
31299 return new Buffer(strChunk, 'hex')
31303 return Script.fromChunks(chunks)
31306 Script.fromBuffer = function(buffer) {
31311 while (i < buffer.length) {
31312 var opcode = buffer.readUInt8(i)
31314 if ((opcode
> opcodes.OP_0) && (opcode <= opcodes.OP_PUSHDATA4)) {
31315 var d = bufferutils.readPushDataInt(buffer, i)
31318 var data = buffer.slice(i, i + d.number)
31324 chunks.push(opcode)
31330 return new Script(buffer, chunks)
31333 Script.fromChunks = function(chunks) {
31334 assert(Array.isArray(chunks), 'Expected Array, got ' + chunks)
31336 var bufferSize = chunks.reduce(function(accum, chunk) {
31337 if (Buffer.isBuffer(chunk)) {
31338 return accum + bufferutils.pushDataSize(chunk.length) + chunk.length
31344 var buffer = new Buffer(bufferSize)
31347 chunks.forEach(function(chunk) {
31348 if (Buffer.isBuffer(chunk)) {
31349 offset += bufferutils.writePushDataInt(buffer, chunk.length, offset)
31351 chunk.copy(buffer, offset)
31352 offset += chunk.length
31355 buffer.writeUInt8(chunk, offset)
31360 assert.equal(offset, buffer.length, 'Could not decode chunks')
31361 return new Script(buffer, chunks)
31364 Script.fromHex = function(hex) {
31365 return Script.fromBuffer(new Buffer(hex, 'hex'))
31369 Script.EMPTY = Script.fromChunks([])
31372 Script.prototype.getHash = function() {
31373 return crypto.hash160(this.buffer)
31376 // FIXME: doesn't work for data chunks, maybe time to use buffertools.compare...
31377 Script.prototype.without = function(needle) {
31378 return Script.fromChunks(this.chunks.filter(function(op) {
31379 return op !== needle
31383 // Export operations
31384 var reverseOps = []
31385 for (var op in opcodes) {
31386 var code = opcodes[op]
31387 reverseOps[code] = op
31390 Script.prototype.toASM = function() {
31391 return this.chunks.map(function(chunk) {
31392 if (Buffer.isBuffer(chunk)) {
31393 return chunk.toString('hex')
31396 return reverseOps[chunk]
31401 Script.prototype.toBuffer = function() {
31405 Script.prototype.toHex = function() {
31406 return this.toBuffer().toString('hex')
31409 module.exports = Script
31411 }).call(this,_dereq_("buffer").Buffer)
31412 },{"./bufferutils":
71,"./crypto":
73,"./opcodes":
82,"assert":
4,"buffer":
8}],
84:[function(_dereq_,module,exports){
31413 (function (Buffer){
31414 var assert = _dereq_('assert')
31415 var opcodes = _dereq_('./opcodes')
31417 // FIXME: use ECPubKey, currently the circular dependency breaks everything.
31420 // * Remove ECPubKey.getAddress
31421 // - Minimal change, but likely unpopular
31422 // * Move all script related functionality out of Address
31423 // - Means a lot of changes to Transaction/Wallet
31424 // * Ignore it (existing solution)
31425 // * Some form of hackery with commonjs
31427 var ecurve = _dereq_('ecurve')
31428 var curve = ecurve.getCurveByName('secp256k1')
31430 var ECSignature = _dereq_('./ecsignature')
31431 var Script = _dereq_('./script')
31433 function classifyOutput(script) {
31434 assert(script instanceof Script, 'Expected Script, got ', script)
31436 if (isPubKeyHashOutput.call(script)) {
31437 return 'pubkeyhash'
31438 } else if (isScriptHashOutput.call(script)) {
31439 return 'scripthash'
31440 } else if (isMultisigOutput.call(script)) {
31442 } else if (isPubKeyOutput.call(script)) {
31444 } else if (isNulldataOutput.call(script)) {
31447 return 'nonstandard'
31451 function classifyInput(script) {
31452 assert(script instanceof Script, 'Expected Script, got ', script)
31454 if (isPubKeyHashInput.call(script)) {
31455 return 'pubkeyhash'
31456 } else if (isScriptHashInput.call(script)) {
31457 return 'scripthash'
31458 } else if (isMultisigInput.call(script)) {
31460 } else if (isPubKeyInput.call(script)) {
31463 return 'nonstandard'
31467 function isCanonicalPubKey(buffer) {
31468 if (!Buffer.isBuffer(buffer)) return false
31472 ecurve.Point.decodeFrom(curve, buffer)
31474 if (!(e.message.match(/Invalid sequence (length|tag)/))) throw e
31482 function isCanonicalSignature(buffer) {
31483 if (!Buffer.isBuffer(buffer)) return false
31486 ECSignature.parseScriptSignature(buffer)
31488 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
31496 function isPubKeyHashInput() {
31497 return this.chunks.length ===
2 &&
31498 isCanonicalSignature(this.chunks[
0]) &&
31499 isCanonicalPubKey(this.chunks[
1])
31502 function isPubKeyHashOutput() {
31503 return this.chunks.length ===
5 &&
31504 this.chunks[
0] === opcodes.OP_DUP &&
31505 this.chunks[
1] === opcodes.OP_HASH160 &&
31506 Buffer.isBuffer(this.chunks[
2]) &&
31507 this.chunks[
2].length ===
20 &&
31508 this.chunks[
3] === opcodes.OP_EQUALVERIFY &&
31509 this.chunks[
4] === opcodes.OP_CHECKSIG
31512 function isPubKeyInput() {
31513 return this.chunks.length ===
1 &&
31514 isCanonicalSignature(this.chunks[
0])
31517 function isPubKeyOutput() {
31518 return this.chunks.length ===
2 &&
31519 isCanonicalPubKey(this.chunks[
0]) &&
31520 this.chunks[
1] === opcodes.OP_CHECKSIG
31523 function isScriptHashInput() {
31524 if (this.chunks.length <
2) return false
31525 var lastChunk = this.chunks[this.chunks.length -
1]
31527 if (!Buffer.isBuffer(lastChunk)) return false
31529 var scriptSig = Script.fromChunks(this.chunks.slice(
0, -
1))
31530 var scriptPubKey = Script.fromBuffer(lastChunk)
31532 return classifyInput(scriptSig) === classifyOutput(scriptPubKey)
31535 function isScriptHashOutput() {
31536 return this.chunks.length ===
3 &&
31537 this.chunks[
0] === opcodes.OP_HASH160 &&
31538 Buffer.isBuffer(this.chunks[
1]) &&
31539 this.chunks[
1].length ===
20 &&
31540 this.chunks[
2] === opcodes.OP_EQUAL
31543 function isMultisigInput() {
31544 return this.chunks[
0] === opcodes.OP_0 &&
31545 this.chunks.slice(
1).every(isCanonicalSignature)
31548 function isMultisigOutput() {
31549 if (this.chunks <
4) return false
31550 if (this.chunks[this.chunks.length -
1] !== opcodes.OP_CHECKMULTISIG) return false
31552 var mOp = this.chunks[
0]
31553 if (mOp === opcodes.OP_0) return false
31554 if (mOp < opcodes.OP_1) return false
31555 if (mOp
> opcodes.OP_16) return false
31557 var nOp = this.chunks[this.chunks.length -
2]
31558 if (nOp === opcodes.OP_0) return false
31559 if (nOp < opcodes.OP_1) return false
31560 if (nOp
> opcodes.OP_16) return false
31562 var m = mOp - (opcodes.OP_1 -
1)
31563 var n = nOp - (opcodes.OP_1 -
1)
31564 if (n < m) return false
31566 var pubKeys = this.chunks.slice(
1, -
2)
31567 if (n < pubKeys.length) return false
31569 return pubKeys.every(isCanonicalPubKey)
31572 function isNulldataOutput() {
31573 return this.chunks[
0] === opcodes.OP_RETURN
31576 // Standard Script Templates
31577 // {pubKey} OP_CHECKSIG
31578 function pubKeyOutput(pubKey) {
31579 return Script.fromChunks([
31581 opcodes.OP_CHECKSIG
31585 // OP_DUP OP_HASH160 {pubKeyHash} OP_EQUALVERIFY OP_CHECKSIG
31586 function pubKeyHashOutput(hash) {
31587 assert(Buffer.isBuffer(hash), 'Expected Buffer, got ' + hash)
31589 return Script.fromChunks([
31591 opcodes.OP_HASH160,
31593 opcodes.OP_EQUALVERIFY,
31594 opcodes.OP_CHECKSIG
31598 // OP_HASH160 {scriptHash} OP_EQUAL
31599 function scriptHashOutput(hash) {
31600 assert(Buffer.isBuffer(hash), 'Expected Buffer, got ' + hash)
31602 return Script.fromChunks([
31603 opcodes.OP_HASH160,
31609 // m [pubKeys ...] n OP_CHECKMULTISIG
31610 function multisigOutput(m, pubKeys) {
31611 assert(Array.isArray(pubKeys), 'Expected Array, got ' + pubKeys)
31612 assert(pubKeys.length
>= m, 'Not enough pubKeys provided')
31614 var pubKeyBuffers = pubKeys.map(function(pubKey) {
31615 return pubKey.toBuffer()
31617 var n = pubKeys.length
31619 return Script.fromChunks([].concat(
31620 (opcodes.OP_1 -
1) + m,
31622 (opcodes.OP_1 -
1) + n,
31623 opcodes.OP_CHECKMULTISIG
31628 function pubKeyInput(signature) {
31629 assert(Buffer.isBuffer(signature), 'Expected Buffer, got ' + signature)
31631 return Script.fromChunks([signature])
31634 // {signature} {pubKey}
31635 function pubKeyHashInput(signature, pubKey) {
31636 assert(Buffer.isBuffer(signature), 'Expected Buffer, got ' + signature)
31638 return Script.fromChunks([signature, pubKey.toBuffer()])
31641 //
<scriptSig> {serialized scriptPubKey script}
31642 function scriptHashInput(scriptSig, scriptPubKey) {
31643 return Script.fromChunks([].concat(
31645 scriptPubKey.toBuffer()
31649 // OP_0 [signatures ...]
31650 function multisigInput(signatures, scriptPubKey) {
31651 if (scriptPubKey) {
31652 assert(isMultisigOutput.call(scriptPubKey))
31654 var m = scriptPubKey.chunks[
0]
31655 var k = m - (opcodes.OP_1 -
1)
31656 assert(k <= signatures.length, 'Not enough signatures provided')
31659 return Script.fromChunks([].concat(opcodes.OP_0, signatures))
31663 classifyInput: classifyInput,
31664 classifyOutput: classifyOutput,
31665 multisigInput: multisigInput,
31666 multisigOutput: multisigOutput,
31667 pubKeyHashInput: pubKeyHashInput,
31668 pubKeyHashOutput: pubKeyHashOutput,
31669 pubKeyInput: pubKeyInput,
31670 pubKeyOutput: pubKeyOutput,
31671 scriptHashInput: scriptHashInput,
31672 scriptHashOutput: scriptHashOutput
31675 }).call(this,_dereq_("buffer").Buffer)
31676 },{"./ecsignature":
77,"./opcodes":
82,"./script":
83,"assert":
4,"buffer":
8,"ecurve":
65}],
85:[function(_dereq_,module,exports){
31677 (function (Buffer){
31678 var assert = _dereq_('assert')
31679 var bufferutils = _dereq_('./bufferutils')
31680 var crypto = _dereq_('./crypto')
31681 var opcodes = _dereq_('./opcodes')
31682 var scripts = _dereq_('./scripts')
31684 var Address = _dereq_('./address')
31685 var ECKey = _dereq_('./eckey')
31686 var ECSignature = _dereq_('./ecsignature')
31687 var Script = _dereq_('./script')
31689 Transaction.DEFAULT_SEQUENCE =
0xffffffff
31690 Transaction.SIGHASH_ALL =
0x01
31691 Transaction.SIGHASH_NONE =
0x02
31692 Transaction.SIGHASH_SINGLE =
0x03
31693 Transaction.SIGHASH_ANYONECANPAY =
0x80
31695 function Transaction() {
31703 * Create a new txin.
31705 * Can be called with any of:
31707 * - A transaction and an index
31708 * - A transaction hash and an index
31710 * Note that this method does not sign the created input.
31712 Transaction.prototype.addInput = function(tx, index, sequence) {
31713 if (sequence == undefined) sequence = Transaction.DEFAULT_SEQUENCE
31717 if (typeof tx === 'string') {
31718 hash = new Buffer(tx, 'hex')
31720 // TxId hex is big-endian, we need little-endian
31721 Array.prototype.reverse.call(hash)
31723 } else if (tx instanceof Transaction) {
31724 hash = tx.getHash()
31730 assert(Buffer.isBuffer(hash), 'Expected Transaction, txId or txHash, got ' + tx)
31731 assert.equal(hash.length,
32, 'Expected hash length of
32, got ' + hash.length)
31732 assert.equal(typeof index, 'number', 'Expected number index, got ' + index)
31734 return (this.ins.push({
31737 script: Script.EMPTY,
31743 * Create a new txout.
31745 * Can be called with:
31747 * - A base58 address string and a value
31748 * - An Address object and a value
31749 * - A scriptPubKey Script and a value
31751 Transaction.prototype.addOutput = function(scriptPubKey, value) {
31752 // Attempt to get a valid address if it's a base58 address string
31753 if (typeof scriptPubKey === 'string') {
31754 scriptPubKey = Address.fromBase58Check(scriptPubKey)
31757 // Attempt to get a valid script if it's an Address object
31758 if (scriptPubKey instanceof Address) {
31759 var address = scriptPubKey
31761 scriptPubKey = address.toOutputScript()
31764 return (this.outs.push({
31765 script: scriptPubKey,
31770 Transaction.prototype.toBuffer = function () {
31771 var txInSize = this.ins.reduce(function(a, x) {
31772 return a + (
40 + bufferutils.varIntSize(x.script.buffer.length) + x.script.buffer.length)
31775 var txOutSize = this.outs.reduce(function(a, x) {
31776 return a + (
8 + bufferutils.varIntSize(x.script.buffer.length) + x.script.buffer.length)
31779 var buffer = new Buffer(
31781 bufferutils.varIntSize(this.ins.length) +
31782 bufferutils.varIntSize(this.outs.length) +
31788 function writeSlice(slice) {
31789 slice.copy(buffer, offset)
31790 offset += slice.length
31792 function writeUInt32(i) {
31793 buffer.writeUInt32LE(i, offset)
31796 function writeUInt64(i) {
31797 bufferutils.writeUInt64LE(buffer, i, offset)
31800 function writeVarInt(i) {
31801 var n = bufferutils.writeVarInt(buffer, i, offset)
31805 writeUInt32(this.version)
31806 writeVarInt(this.ins.length)
31808 this.ins.forEach(function(txin) {
31809 writeSlice(txin.hash)
31810 writeUInt32(txin.index)
31811 writeVarInt(txin.script.buffer.length)
31812 writeSlice(txin.script.buffer)
31813 writeUInt32(txin.sequence)
31816 writeVarInt(this.outs.length)
31817 this.outs.forEach(function(txout) {
31818 writeUInt64(txout.value)
31819 writeVarInt(txout.script.buffer.length)
31820 writeSlice(txout.script.buffer)
31823 writeUInt32(this.locktime)
31828 Transaction.prototype.toHex = function() {
31829 return this.toBuffer().toString('hex')
31833 * Hash transaction for signing a specific input.
31835 * Bitcoin uses a different hash for each signed transaction input. This
31836 * method copies the transaction, makes the necessary changes based on the
31837 * hashType, serializes and finally hashes the result. This hash can then be
31838 * used to sign the transaction input in question.
31840 Transaction.prototype.hashForSignature = function(prevOutScript, inIndex, hashType) {
31841 assert(inIndex
>=
0, 'Invalid vin index')
31842 assert(inIndex < this.ins.length, 'Invalid vin index')
31843 assert(prevOutScript instanceof Script, 'Invalid Script object')
31845 var txTmp = this.clone()
31846 var hashScript = prevOutScript.without(opcodes.OP_CODESEPARATOR)
31848 // Blank out other inputs' signatures
31849 txTmp.ins.forEach(function(txin) {
31850 txin.script = Script.EMPTY
31852 txTmp.ins[inIndex].script = hashScript
31854 var hashTypeModifier = hashType &
0x1f
31855 if (hashTypeModifier === Transaction.SIGHASH_NONE) {
31856 assert(false, 'SIGHASH_NONE not yet supported')
31858 } else if (hashTypeModifier === Transaction.SIGHASH_SINGLE) {
31859 assert(false, 'SIGHASH_SINGLE not yet supported')
31863 if (hashType & Transaction.SIGHASH_ANYONECANPAY) {
31864 assert(false, 'SIGHASH_ANYONECANPAY not yet supported')
31867 var hashTypeBuffer = new Buffer(
4)
31868 hashTypeBuffer.writeInt32LE(hashType,
0)
31870 var buffer = Buffer.concat([txTmp.toBuffer(), hashTypeBuffer])
31871 return crypto.hash256(buffer)
31874 Transaction.prototype.getHash = function () {
31875 return crypto.hash256(this.toBuffer())
31878 Transaction.prototype.getId = function () {
31879 var buffer = this.getHash()
31881 // Big-endian is used for TxHash
31882 Array.prototype.reverse.call(buffer)
31884 return buffer.toString('hex')
31887 Transaction.prototype.clone = function () {
31888 var newTx = new Transaction()
31889 newTx.version = this.version
31890 newTx.locktime = this.locktime
31892 newTx.ins = this.ins.map(function(txin) {
31896 script: txin.script,
31897 sequence: txin.sequence
31901 newTx.outs = this.outs.map(function(txout) {
31903 script: txout.script,
31911 Transaction.fromBuffer = function(buffer) {
31913 function readSlice(n) {
31915 return buffer.slice(offset - n, offset)
31917 function readUInt32() {
31918 var i = buffer.readUInt32LE(offset)
31922 function readUInt64() {
31923 var i = bufferutils.readUInt64LE(buffer, offset)
31927 function readVarInt() {
31928 var vi = bufferutils.readVarInt(buffer, offset)
31933 var tx = new Transaction()
31934 tx.version = readUInt32()
31936 var vinLen = readVarInt()
31937 for (var i =
0; i < vinLen; ++i) {
31938 var hash = readSlice(
32)
31939 var vout = readUInt32()
31940 var scriptLen = readVarInt()
31941 var script = readSlice(scriptLen)
31942 var sequence = readUInt32()
31947 script: Script.fromBuffer(script),
31952 var voutLen = readVarInt()
31953 for (i =
0; i < voutLen; ++i) {
31954 var value = readUInt64()
31955 var scriptLen = readVarInt()
31956 var script = readSlice(scriptLen)
31960 script: Script.fromBuffer(script)
31964 tx.locktime = readUInt32()
31965 assert.equal(offset, buffer.length, 'Transaction has unexpected data')
31970 Transaction.fromHex = function(hex) {
31971 return Transaction.fromBuffer(new Buffer(hex, 'hex'))
31975 * Signs a pubKeyHash output at some index with the given key
31977 Transaction.prototype.sign = function(index, privKey, hashType) {
31978 var prevOutScript = privKey.pub.getAddress().toOutputScript()
31979 var signature = this.signInput(index, prevOutScript, privKey, hashType)
31981 // FIXME: Assumed prior TX was pay-to-pubkey-hash
31982 var scriptSig = scripts.pubKeyHashInput(signature, privKey.pub)
31983 this.setInputScript(index, scriptSig)
31986 Transaction.prototype.signInput = function(index, prevOutScript, privKey, hashType) {
31987 hashType = hashType || Transaction.SIGHASH_ALL
31989 var hash = this.hashForSignature(prevOutScript, index, hashType)
31990 var signature = privKey.sign(hash)
31992 return signature.toScriptSignature(hashType)
31995 Transaction.prototype.setInputScript = function(index, script) {
31996 this.ins[index].script = script
31999 // FIXME: could be validateInput(index, prevTxOut, pub)
32000 Transaction.prototype.validateInput = function(index, prevOutScript, pubKey, buffer) {
32001 var parsed = ECSignature.parseScriptSignature(buffer)
32002 var hash = this.hashForSignature(prevOutScript, index, parsed.hashType)
32004 return pubKey.verify(hash, parsed.signature)
32007 module.exports = Transaction
32009 }).call(this,_dereq_("buffer").Buffer)
32010 },{"./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){
32011 (function (Buffer){
32012 var assert = _dereq_('assert')
32013 var networks = _dereq_('./networks')
32014 var rng = _dereq_('secure-random')
32016 var Address = _dereq_('./address')
32017 var HDNode = _dereq_('./hdnode')
32018 var Transaction = _dereq_('./transaction')
32020 function Wallet(seed, network) {
32021 network = network || networks.bitcoin
32023 // Stored in a closure to make accidental serialization less likely
32024 var masterkey = null
32026 var accountZero = null
32027 var internalAccount = null
32028 var externalAccount = null
32031 this.addresses = []
32032 this.changeAddresses = []
32034 // Transaction output data
32037 // Make a new master key
32038 this.newMasterKey = function(seed) {
32039 seed = seed || new Buffer(rng(
32))
32040 masterkey = HDNode.fromSeedBuffer(seed, network)
32042 // HD first-level child derivation method should be hardened
32043 // See https://bitcointalk.org/index.php?topic=
405179.msg4415254#msg4415254
32044 accountZero = masterkey.deriveHardened(
0)
32045 externalAccount = accountZero.derive(
0)
32046 internalAccount = accountZero.derive(
1)
32049 me.changeAddresses = []
32054 this.newMasterKey(seed)
32056 this.generateAddress = function() {
32057 var key = externalAccount.derive(this.addresses.length)
32058 this.addresses.push(key.getAddress().toString())
32059 return this.addresses[this.addresses.length -
1]
32062 this.generateChangeAddress = function() {
32063 var key = internalAccount.derive(this.changeAddresses.length)
32064 this.changeAddresses.push(key.getAddress().toString())
32065 return this.changeAddresses[this.changeAddresses.length -
1]
32068 this.getBalance = function() {
32069 return this.getUnspentOutputs().reduce(function(memo, output){
32070 return memo + output.value
32074 this.getUnspentOutputs = function() {
32077 for(var key in this.outputs){
32078 var output = this.outputs[key]
32079 if(!output.to) utxo.push(outputToUnspentOutput(output))
32085 this.setUnspentOutputs = function(utxo) {
32088 utxo.forEach(function(uo){
32089 validateUnspentOutput(uo)
32090 var o = unspentOutputToOutput(uo)
32091 outputs[o.from] = o
32094 this.outputs = outputs
32097 function outputToUnspentOutput(output){
32098 var hashAndIndex = output.from.split(":")
32101 hash: hashAndIndex[
0],
32102 outputIndex: parseInt(hashAndIndex[
1]),
32103 address: output.address,
32104 value: output.value,
32105 pending: output.pending
32109 function unspentOutputToOutput(o) {
32111 var key = hash + ":" + o.outputIndex
32114 address: o.address,
32120 function validateUnspentOutput(uo) {
32123 if (isNullOrUndefined(uo.hash)) {
32124 missingField = "hash"
32127 var requiredKeys = ['outputIndex', 'address', 'value']
32128 requiredKeys.forEach(function (key) {
32129 if (isNullOrUndefined(uo[key])){
32134 if (missingField) {
32136 'Invalid unspent output: key', missingField, 'is missing.',
32137 'A valid unspent output must contain'
32139 message.push(requiredKeys.join(', '))
32140 message.push("and hash")
32141 throw new Error(message.join(' '))
32145 function isNullOrUndefined(value) {
32146 return value == undefined
32149 this.processPendingTx = function(tx){
32150 processTx(tx, true)
32153 this.processConfirmedTx = function(tx){
32154 processTx(tx, false)
32157 function processTx(tx, isPending) {
32158 var txid = tx.getId()
32160 tx.outs.forEach(function(txOut, i) {
32164 address = Address.fromOutputScript(txOut.script, network).toString()
32166 if (!(e.message.match(/has no matching Address/))) throw e
32169 if (isMyAddress(address)) {
32170 var output = txid + ':' + i
32172 me.outputs[output] = {
32174 value: txOut.value,
32181 tx.ins.forEach(function(txIn, i) {
32182 // copy and convert to big-endian hex
32183 var txinId = new Buffer(txIn.hash)
32184 Array.prototype.reverse.call(txinId)
32185 txinId = txinId.toString('hex')
32187 var output = txinId + ':' + txIn.index
32189 if (!(output in me.outputs)) return
32192 me.outputs[output].to = txid + ':' + i
32193 me.outputs[output].pending = true
32195 delete me.outputs[output]
32200 this.createTx = function(to, value, fixedFee, changeAddress) {
32201 assert(value
> network.dustThreshold, value + ' must be above dust threshold (' + network.dustThreshold + ' Satoshis)')
32203 var utxos = getCandidateOutputs(value)
32205 var subTotal = value
32208 var tx = new Transaction()
32209 tx.addOutput(to, value)
32211 for (var i =
0; i < utxos.length; ++i) {
32212 var utxo = utxos[i]
32213 addresses.push(utxo.address)
32215 var outpoint = utxo.from.split(':')
32216 tx.addInput(outpoint[
0], parseInt(outpoint[
1]))
32218 var fee = fixedFee == undefined ? estimateFeePadChangeOutput(tx) : fixedFee
32220 accum += utxo.value
32221 subTotal = value + fee
32222 if (accum
>= subTotal) {
32223 var change = accum - subTotal
32225 if (change
> network.dustThreshold) {
32226 tx.addOutput(changeAddress || getChangeAddress(), change)
32233 assert(accum
>= subTotal, 'Not enough funds (incl. fee): ' + accum + ' < ' + subTotal)
32235 this.signWith(tx, addresses)
32239 function getCandidateOutputs() {
32242 for (var key in me.outputs) {
32243 var output = me.outputs[key]
32244 if (!output.pending) unspent.push(output)
32247 var sortByValueDesc = unspent.sort(function(o1, o2){
32248 return o2.value - o1.value
32251 return sortByValueDesc
32254 function estimateFeePadChangeOutput(tx) {
32255 var tmpTx = tx.clone()
32256 tmpTx.addOutput(getChangeAddress(), network.dustSoftThreshold ||
0)
32258 return network.estimateFee(tmpTx)
32261 function getChangeAddress() {
32262 if(me.changeAddresses.length ===
0) me.generateChangeAddress();
32263 return me.changeAddresses[me.changeAddresses.length -
1]
32266 this.signWith = function(tx, addresses) {
32267 assert.equal(tx.ins.length, addresses.length, 'Number of addresses must match number of transaction inputs')
32269 addresses.forEach(function(address, i) {
32270 var key = me.getPrivateKeyForAddress(address)
32278 this.getMasterKey = function() { return masterkey }
32279 this.getAccountZero = function() { return accountZero }
32280 this.getInternalAccount = function() { return internalAccount }
32281 this.getExternalAccount = function() { return externalAccount }
32283 this.getPrivateKey = function(index) {
32284 return externalAccount.derive(index).privKey
32287 this.getInternalPrivateKey = function(index) {
32288 return internalAccount.derive(index).privKey
32291 this.getPrivateKeyForAddress = function(address) {
32293 if((index = this.addresses.indexOf(address))
> -
1) {
32294 return this.getPrivateKey(index)
32295 } else if((index = this.changeAddresses.indexOf(address))
> -
1) {
32296 return this.getInternalPrivateKey(index)
32298 throw new Error('Unknown address. Make sure the address is from the keychain and has been generated.')
32302 function isReceiveAddress(address){
32303 return me.addresses.indexOf(address)
> -
1
32306 function isChangeAddress(address){
32307 return me.changeAddresses.indexOf(address)
> -
1
32310 function isMyAddress(address) {
32311 return isReceiveAddress(address) || isChangeAddress(address)
32315 module.exports = Wallet
32317 }).call(this,_dereq_("buffer").Buffer)
32318 },{"./address":
69,"./hdnode":
78,"./networks":
81,"./transaction":
85,"assert":
4,"buffer":
8,"secure-random":
68}]},{},[
79])
32323 // Select components from sjcl to suit the crypto operations bip39 requires.
32327 /** @fileOverview Javascript cryptography implementation.
32329 * Crush to remove comments, shorten variable names and
32330 * generally reduce transmission size.
32332 * @author Emily Stark
32333 * @author Mike Hamburg
32334 * @author Dan Boneh
32338 /*jslint indent:
2, bitwise: false, nomen: false, plusplus: false, white: false, regexp: false */
32339 /*global document, window, escape, unescape, module, require, Uint32Array */
32341 /** @namespace The Stanford Javascript Crypto Library, top-level namespace. */
32343 /** @namespace Symmetric ciphers. */
32346 /** @namespace Hash functions. Right now only SHA256 is implemented. */
32349 /** @namespace Key exchange functions. Right now only SRP is implemented. */
32352 /** @namespace Block cipher modes of operation. */
32355 /** @namespace Miscellaneous. HMAC and PBKDF2. */
32359 * @namespace Bit array encoders and decoders.
32362 * The members of this namespace are functions which translate between
32363 * SJCL's bitArrays and other objects (usually strings). Because it
32364 * isn't always clear which direction is encoding and which is decoding,
32365 * the method names are "fromBits" and "toBits".
32369 /** @namespace Exceptions. */
32371 /** @constructor Ciphertext is corrupt. */
32372 corrupt: function(message) {
32373 this.toString = function() { return "CORRUPT: "+this.message; };
32374 this.message = message;
32377 /** @constructor Invalid parameter. */
32378 invalid: function(message) {
32379 this.toString = function() { return "INVALID: "+this.message; };
32380 this.message = message;
32383 /** @constructor Bug or missing feature in SJCL. @constructor */
32384 bug: function(message) {
32385 this.toString = function() { return "BUG: "+this.message; };
32386 this.message = message;
32389 /** @constructor Something isn't ready. */
32390 notReady: function(message) {
32391 this.toString = function() { return "NOT READY: "+this.message; };
32392 this.message = message;
32397 if(typeof module !== 'undefined' && module.exports){
32398 module.exports = sjcl;
32400 if (typeof define === "function") {
32401 define([], function () {
32409 /** @fileOverview Arrays of bits, encoded as arrays of Numbers.
32411 * @author Emily Stark
32412 * @author Mike Hamburg
32413 * @author Dan Boneh
32416 /** @namespace Arrays of bits, encoded as arrays of Numbers.
32420 * These objects are the currency accepted by SJCL's crypto functions.
32424 * Most of our crypto primitives operate on arrays of
4-byte words internally,
32425 * but many of them can take arguments that are not a multiple of
4 bytes.
32426 * This library encodes arrays of bits (whose size need not be a multiple of
8
32427 * bits) as arrays of
32-bit words. The bits are packed, big-endian, into an
32428 * array of words,
32 bits at a time. Since the words are double-precision
32429 * floating point numbers, they fit some extra data. We use this (in a private,
32430 * possibly-changing manner) to encode the number of bits actually present
32431 * in the last word of the array.
32435 * Because bitwise ops clear this out-of-band data, these arrays can be passed
32436 * to ciphers like AES which want arrays of words.
32441 * Array slices in units of bits.
32442 * @param {bitArray} a The array to slice.
32443 * @param {Number} bstart The offset to the start of the slice, in bits.
32444 * @param {Number} bend The offset to the end of the slice, in bits. If this is undefined,
32445 * slice until the end of the array.
32446 * @return {bitArray} The requested slice.
32448 bitSlice: function (a, bstart, bend) {
32449 a = sjcl.bitArray._shiftRight(a.slice(bstart/
32),
32 - (bstart &
31)).slice(
1);
32450 return (bend === undefined) ? a : sjcl.bitArray.clamp(a, bend-bstart);
32454 * Extract a number packed into a bit array.
32455 * @param {bitArray} a The array to slice.
32456 * @param {Number} bstart The offset to the start of the slice, in bits.
32457 * @param {Number} length The length of the number to extract.
32458 * @return {Number} The requested slice.
32460 extract: function(a, bstart, blength) {
32461 // FIXME: this Math.floor is not necessary at all, but for some reason
32462 // seems to suppress a bug in the Chromium JIT.
32463 var x, sh = Math.floor((-bstart-blength) &
31);
32464 if ((bstart + blength -
1 ^ bstart) & -
32) {
32465 // it crosses a boundary
32466 x = (a[bstart/
32|
0] << (
32 - sh)) ^ (a[bstart/
32+
1|
0]
>>> sh);
32468 // within a single word
32469 x = a[bstart/
32|
0]
>>> sh;
32471 return x & ((
1<
<blength) -
1);
32475 * Concatenate two bit arrays.
32476 * @param {bitArray} a1 The first array.
32477 * @param {bitArray} a2 The second array.
32478 * @return {bitArray} The concatenation of a1 and a2.
32480 concat: function (a1, a2) {
32481 if (a1.length ===
0 || a2.length ===
0) {
32482 return a1.concat(a2);
32485 var last = a1[a1.length-
1], shift = sjcl.bitArray.getPartial(last);
32486 if (shift ===
32) {
32487 return a1.concat(a2);
32489 return sjcl.bitArray._shiftRight(a2, shift, last|
0, a1.slice(
0,a1.length-
1));
32494 * Find the length of an array of bits.
32495 * @param {bitArray} a The array.
32496 * @return {Number} The length of a, in bits.
32498 bitLength: function (a) {
32499 var l = a.length, x;
32500 if (l ===
0) { return
0; }
32502 return (l-
1) *
32 + sjcl.bitArray.getPartial(x);
32506 * Truncate an array.
32507 * @param {bitArray} a The array.
32508 * @param {Number} len The length to truncate to, in bits.
32509 * @return {bitArray} A new array, truncated to len bits.
32511 clamp: function (a, len) {
32512 if (a.length *
32 < len) { return a; }
32513 a = a.slice(
0, Math.ceil(len /
32));
32516 if (l
> 0 && len) {
32517 a[l-
1] = sjcl.bitArray.partial(len, a[l-
1] &
0x80000000 >> (len-
1),
1);
32523 * Make a partial word for a bit array.
32524 * @param {Number} len The number of bits in the word.
32525 * @param {Number} x The bits.
32526 * @param {Number} [
0] _end Pass
1 if x has already been shifted to the high side.
32527 * @return {Number} The partial word.
32529 partial: function (len, x, _end) {
32530 if (len ===
32) { return x; }
32531 return (_end ? x|
0 : x << (
32-len)) + len *
0x10000000000;
32535 * Get the number of bits used by a partial word.
32536 * @param {Number} x The partial word.
32537 * @return {Number} The number of bits used by the partial word.
32539 getPartial: function (x) {
32540 return Math.round(x/
0x10000000000) ||
32;
32544 * Compare two arrays for equality in a predictable amount of time.
32545 * @param {bitArray} a The first array.
32546 * @param {bitArray} b The second array.
32547 * @return {boolean} true if a == b; false otherwise.
32549 equal: function (a, b) {
32550 if (sjcl.bitArray.bitLength(a) !== sjcl.bitArray.bitLength(b)) {
32554 for (i=
0; i
<a.length; i++) {
32560 /** Shift an array right.
32561 * @param {bitArray} a The array to shift.
32562 * @param {Number} shift The number of bits to shift.
32563 * @param {Number} [carry=
0] A byte to carry in
32564 * @param {bitArray} [out=[]] An array to prepend to the output.
32567 _shiftRight: function (a, shift, carry, out) {
32568 var i, last2=
0, shift2;
32569 if (out === undefined) { out = []; }
32571 for (; shift
>=
32; shift -=
32) {
32576 return out.concat(a);
32579 for (i=
0; i
<a.length; i++) {
32580 out.push(carry | a[i]
>>>shift);
32581 carry = a[i] << (
32-shift);
32583 last2 = a.length ? a[a.length-
1] :
0;
32584 shift2 = sjcl.bitArray.getPartial(last2);
32585 out.push(sjcl.bitArray.partial(shift+shift2 &
31, (shift + shift2
> 32) ? carry : out.pop(),
1));
32589 /** xor a block of
4 words together.
32592 _xor4: function(x,y) {
32593 return [x[
0]^y[
0],x[
1]^y[
1],x[
2]^y[
2],x[
3]^y[
3]];
32596 /** byteswap a word array inplace.
32597 * (does not handle partial words)
32598 * @param {sjcl.bitArray} a word array
32599 * @return {sjcl.bitArray} byteswapped array
32601 byteswapM: function(a) {
32602 var i, v, m =
0xff00;
32603 for (i =
0; i < a.length; ++i) {
32605 a[i] = (v
>>> 24) | ((v
>>> 8) & m) | ((v & m) <<
8) | (v <<
24);
32612 //// codecString.js
32614 /** @fileOverview Bit array codec implementations.
32616 * @author Emily Stark
32617 * @author Mike Hamburg
32618 * @author Dan Boneh
32621 /** @namespace UTF-
8 strings */
32622 sjcl.codec.utf8String = {
32623 /** Convert from a bitArray to a UTF-
8 string. */
32624 fromBits: function (arr) {
32625 var out =
"", bl = sjcl.bitArray.bitLength(arr), i, tmp;
32626 for (i=
0; i
<bl/
8; i++) {
32630 out += String.fromCharCode(tmp
>>> 24);
32633 return decodeURIComponent(escape(out));
32636 /** Convert from a UTF-
8 string to a bitArray. */
32637 toBits: function (str) {
32638 str = unescape(encodeURIComponent(str));
32639 var out = [], i, tmp=
0;
32640 for (i=
0; i
<str.length; i++) {
32641 tmp = tmp <<
8 | str.charCodeAt(i);
32648 out.push(sjcl.bitArray.partial(
8*(i&
3), tmp));
32657 /** @fileOverview Bit array codec implementations.
32659 * @author Emily Stark
32660 * @author Mike Hamburg
32661 * @author Dan Boneh
32664 /** @namespace Hexadecimal */
32666 /** Convert from a bitArray to a hex string. */
32667 fromBits: function (arr) {
32669 for (i=
0; i
<arr.length; i++) {
32670 out += ((arr[i]|
0)+
0xF00000000000).toString(
16).substr(
4);
32672 return out.substr(
0, sjcl.bitArray.bitLength(arr)/
4);//.replace(/(.{
8})/g,
"$1 ");
32674 /** Convert from a hex string to a bitArray. */
32675 toBits: function (str) {
32676 var i, out=[], len;
32677 str = str.replace(/\s|
0x/g,
"");
32679 str = str +
"00000000";
32680 for (i=
0; i
<str.length; i+=
8) {
32681 out.push(parseInt(str.substr(i,
8),
16)^
0);
32683 return sjcl.bitArray.clamp(out, len*
4);
32690 /** @fileOverview Javascript SHA-
512 implementation.
32692 * This implementation was written for CryptoJS by Jeff Mott and adapted for
32693 * SJCL by Stefan Thomas.
32695 * CryptoJS (c)
2009–
2012 by Jeff Mott. All rights reserved.
32696 * Released with New BSD License
32698 * @author Emily Stark
32699 * @author Mike Hamburg
32700 * @author Dan Boneh
32701 * @author Jeff Mott
32702 * @author Stefan Thomas
32706 * Context for a SHA-
512 operation in progress.
32708 * @class Secure Hash Algorithm,
512 bits.
32710 sjcl.hash.sha512 = function (hash) {
32711 if (!this._key[
0]) { this._precompute(); }
32713 this._h = hash._h.slice(
0);
32714 this._buffer = hash._buffer.slice(
0);
32715 this._length = hash._length;
32722 * Hash a string or an array of words.
32724 * @param {bitArray|String} data the data to hash.
32725 * @return {bitArray} The hash value, an array of
16 big-endian words.
32727 sjcl.hash.sha512.hash = function (data) {
32728 return (new sjcl.hash.sha512()).update(data).finalize();
32731 sjcl.hash.sha512.prototype = {
32733 * The hash's block size, in bits.
32739 * Reset the hash state.
32742 reset:function () {
32743 this._h = this._init.slice(
0);
32750 * Input several words to the hash.
32751 * @param {bitArray|String} data the data to hash.
32754 update: function (data) {
32755 if (typeof data ===
"string") {
32756 data = sjcl.codec.utf8String.toBits(data);
32758 var i, b = this._buffer = sjcl.bitArray.concat(this._buffer, data),
32760 nl = this._length = ol + sjcl.bitArray.bitLength(data);
32761 for (i =
1024+ol & -
1024; i <= nl; i+=
1024) {
32762 this._block(b.splice(
0,
32));
32768 * Complete hashing and output the hash value.
32769 * @return {bitArray} The hash value, an array of
16 big-endian words.
32771 finalize:function () {
32772 var i, b = this._buffer, h = this._h;
32774 // Round out and push the buffer
32775 b = sjcl.bitArray.concat(b, [sjcl.bitArray.partial(
1,
1)]);
32777 // Round out the buffer to a multiple of
32 words, less the
4 length words.
32778 for (i = b.length +
4; i &
31; i++) {
32782 // append the length
32785 b.push(Math.floor(this._length /
0x100000000));
32786 b.push(this._length |
0);
32789 this._block(b.splice(
0,
32));
32797 * The SHA-
512 initialization vector, to be precomputed.
32803 * Least significant
24 bits of SHA512 initialization values.
32805 * Javascript only has
53 bits of precision, so we compute the
40 most
32806 * significant bits and add the remaining
24 bits as constants.
32810 _initr: [
0xbcc908,
0xcaa73b,
0x94f82b,
0x1d36f1,
0xe682d1,
0x3e6c1f,
0x41bd6b,
0x7e2179 ],
32814 [
0x6a09e667,
0xf3bcc908,
0xbb67ae85,
0x84caa73b,
0x3c6ef372,
0xfe94f82b,
0xa54ff53a,
0x5f1d36f1,
32815 0x510e527f,
0xade682d1,
0x9b05688c,
0x2b3e6c1f,
0x1f83d9ab,
0xfb41bd6b,
0x5be0cd19,
0x137e2179],
32819 * The SHA-
512 hash key, to be precomputed.
32825 * Least significant
24 bits of SHA512 key values.
32829 [
0x28ae22,
0xef65cd,
0x4d3b2f,
0x89dbbc,
0x48b538,
0x05d019,
0x194f9b,
0x6d8118,
32830 0x030242,
0x706fbe,
0xe4b28c,
0xffb4e2,
0x7b896f,
0x1696b1,
0xc71235,
0x692694,
32831 0xf14ad2,
0x4f25e3,
0x8cd5b5,
0xac9c65,
0x2b0275,
0xa6e483,
0x41fbd4,
0x1153b5,
32832 0x66dfab,
0xb43210,
0xfb213f,
0xef0ee4,
0xa88fc2,
0x0aa725,
0x03826f,
0x0e6e70,
32833 0xd22ffc,
0x26c926,
0xc42aed,
0x95b3df,
0xaf63de,
0x77b2a8,
0xedaee6,
0x82353b,
32834 0xf10364,
0x423001,
0xf89791,
0x54be30,
0xef5218,
0x65a910,
0x71202a,
0xbbd1b8,
32835 0xd2d0c8,
0x41ab53,
0x8eeb99,
0x9b48a8,
0xc95a63,
0x418acb,
0x63e373,
0xb2b8a3,
32836 0xefb2fc,
0x172f60,
0xf0ab72,
0x6439ec,
0x631e28,
0x82bde9,
0xc67915,
0x72532b,
32837 0x26619c,
0xc0c207,
0xe0eb1e,
0x6ed178,
0x176fba,
0xc898a6,
0xf90dae,
0x1c471b,
32838 0x047d84,
0xc72493,
0xc9bebc,
0x100d4c,
0x3e42b6,
0x657e2a,
0xd6faec,
0x475817],
32842 [
0x428a2f98,
0xd728ae22,
0x71374491,
0x23ef65cd,
0xb5c0fbcf,
0xec4d3b2f,
0xe9b5dba5,
0x8189dbbc,
32843 0x3956c25b,
0xf348b538,
0x59f111f1,
0xb605d019,
0x923f82a4,
0xaf194f9b,
0xab1c5ed5,
0xda6d8118,
32844 0xd807aa98,
0xa3030242,
0x12835b01,
0x45706fbe,
0x243185be,
0x4ee4b28c,
0x550c7dc3,
0xd5ffb4e2,
32845 0x72be5d74,
0xf27b896f,
0x80deb1fe,
0x3b1696b1,
0x9bdc06a7,
0x25c71235,
0xc19bf174,
0xcf692694,
32846 0xe49b69c1,
0x9ef14ad2,
0xefbe4786,
0x384f25e3,
0x0fc19dc6,
0x8b8cd5b5,
0x240ca1cc,
0x77ac9c65,
32847 0x2de92c6f,
0x592b0275,
0x4a7484aa,
0x6ea6e483,
0x5cb0a9dc,
0xbd41fbd4,
0x76f988da,
0x831153b5,
32848 0x983e5152,
0xee66dfab,
0xa831c66d,
0x2db43210,
0xb00327c8,
0x98fb213f,
0xbf597fc7,
0xbeef0ee4,
32849 0xc6e00bf3,
0x3da88fc2,
0xd5a79147,
0x930aa725,
0x06ca6351,
0xe003826f,
0x14292967,
0x0a0e6e70,
32850 0x27b70a85,
0x46d22ffc,
0x2e1b2138,
0x5c26c926,
0x4d2c6dfc,
0x5ac42aed,
0x53380d13,
0x9d95b3df,
32851 0x650a7354,
0x8baf63de,
0x766a0abb,
0x3c77b2a8,
0x81c2c92e,
0x47edaee6,
0x92722c85,
0x1482353b,
32852 0xa2bfe8a1,
0x4cf10364,
0xa81a664b,
0xbc423001,
0xc24b8b70,
0xd0f89791,
0xc76c51a3,
0x0654be30,
32853 0xd192e819,
0xd6ef5218,
0xd6990624,
0x5565a910,
0xf40e3585,
0x5771202a,
0x106aa070,
0x32bbd1b8,
32854 0x19a4c116,
0xb8d2d0c8,
0x1e376c08,
0x5141ab53,
0x2748774c,
0xdf8eeb99,
0x34b0bcb5,
0xe19b48a8,
32855 0x391c0cb3,
0xc5c95a63,
0x4ed8aa4a,
0xe3418acb,
0x5b9cca4f,
0x7763e373,
0x682e6ff3,
0xd6b2b8a3,
32856 0x748f82ee,
0x5defb2fc,
0x78a5636f,
0x43172f60,
0x84c87814,
0xa1f0ab72,
0x8cc70208,
0x1a6439ec,
32857 0x90befffa,
0x23631e28,
0xa4506ceb,
0xde82bde9,
0xbef9a3f7,
0xb2c67915,
0xc67178f2,
0xe372532b,
32858 0xca273ece,
0xea26619c,
0xd186b8c7,
0x21c0c207,
0xeada7dd6,
0xcde0eb1e,
0xf57d4f7f,
0xee6ed178,
32859 0x06f067aa,
0x72176fba,
0x0a637dc5,
0xa2c898a6,
0x113f9804,
0xbef90dae,
0x1b710b35,
0x131c471b,
32860 0x28db77f5,
0x23047d84,
0x32caab7b,
0x40c72493,
0x3c9ebe0a,
0x15c9bebc,
0x431d67c4,
0x9c100d4c,
32861 0x4cc5d4be,
0xcb3e42b6,
0x597f299c,
0xfc657e2a,
0x5fcb6fab,
0x3ad6faec,
0x6c44198c,
0x4a475817],
32865 * Function to precompute _init and _key.
32868 _precompute: function () {
32869 // XXX: This code is for precomputing the SHA256 constants, change for
32870 // SHA512 and re-enable.
32871 var i =
0, prime =
2, factor;
32873 function frac(x) { return (x-Math.floor(x)) *
0x100000000 |
0; }
32874 function frac2(x) { return (x-Math.floor(x)) *
0x10000000000 &
0xff; }
32876 outer: for (; i
<80; prime++) {
32877 for (factor=
2; factor*factor <= prime; factor++) {
32878 if (prime % factor ===
0) {
32885 this._init[i*
2] = frac(Math.pow(prime,
1/
2));
32886 this._init[i*
2+
1] = (frac2(Math.pow(prime,
1/
2)) <<
24) | this._initr[i];
32888 this._key[i*
2] = frac(Math.pow(prime,
1/
3));
32889 this._key[i*
2+
1] = (frac2(Math.pow(prime,
1/
3)) <<
24) | this._keyr[i];
32895 * Perform one cycle of SHA-
512.
32896 * @param {bitArray} words one block of words.
32899 _block:function (words) {
32901 w = words.slice(
0),
32904 h0h = h[
0], h0l = h[
1], h1h = h[
2], h1l = h[
3],
32905 h2h = h[
4], h2l = h[
5], h3h = h[
6], h3l = h[
7],
32906 h4h = h[
8], h4l = h[
9], h5h = h[
10], h5l = h[
11],
32907 h6h = h[
12], h6l = h[
13], h7h = h[
14], h7l = h[
15];
32909 // Working variables
32910 var ah = h0h, al = h0l, bh = h1h, bl = h1l,
32911 ch = h2h, cl = h2l, dh = h3h, dl = h3l,
32912 eh = h4h, el = h4l, fh = h5h, fl = h5l,
32913 gh = h6h, gl = h6l, hh = h7h, hl = h7l;
32915 for (i=
0; i
<80; i++) {
32916 // load up the input word for this round
32919 wrl = w[i *
2 +
1];
32922 var gamma0xh = w[(i-
15) *
2];
32923 var gamma0xl = w[(i-
15) *
2 +
1];
32925 ((gamma0xl <<
31) | (gamma0xh
>>> 1)) ^
32926 ((gamma0xl <<
24) | (gamma0xh
>>> 8)) ^
32929 ((gamma0xh <<
31) | (gamma0xl
>>> 1)) ^
32930 ((gamma0xh <<
24) | (gamma0xl
>>> 8)) ^
32931 ((gamma0xh <<
25) | (gamma0xl
>>> 7));
32934 var gamma1xh = w[(i-
2) *
2];
32935 var gamma1xl = w[(i-
2) *
2 +
1];
32937 ((gamma1xl <<
13) | (gamma1xh
>>> 19)) ^
32938 ((gamma1xh <<
3) | (gamma1xl
>>> 29)) ^
32941 ((gamma1xh <<
13) | (gamma1xl
>>> 19)) ^
32942 ((gamma1xl <<
3) | (gamma1xh
>>> 29)) ^
32943 ((gamma1xh <<
26) | (gamma1xl
>>> 6));
32946 var wr7h = w[(i-
7) *
2];
32947 var wr7l = w[(i-
7) *
2 +
1];
32949 var wr16h = w[(i-
16) *
2];
32950 var wr16l = w[(i-
16) *
2 +
1];
32952 // W(round) = gamma0 + W(round -
7) + gamma1 + W(round -
16)
32953 wrl = gamma0l + wr7l;
32954 wrh = gamma0h + wr7h + ((wrl
>>> 0) < (gamma0l
>>> 0) ?
1 :
0);
32956 wrh += gamma1h + ((wrl
>>> 0) < (gamma1l
>>> 0) ?
1 :
0);
32958 wrh += wr16h + ((wrl
>>> 0) < (wr16l
>>> 0) ?
1 :
0);
32962 w[i*
2 +
1] = wrl |=
0;
32965 var chh = (eh & fh) ^ (~eh & gh);
32966 var chl = (el & fl) ^ (~el & gl);
32969 var majh = (ah & bh) ^ (ah & ch) ^ (bh & ch);
32970 var majl = (al & bl) ^ (al & cl) ^ (bl & cl);
32973 var sigma0h = ((al <<
4) | (ah
>>> 28)) ^ ((ah <<
30) | (al
>>> 2)) ^ ((ah <<
25) | (al
>>> 7));
32974 var sigma0l = ((ah <<
4) | (al
>>> 28)) ^ ((al <<
30) | (ah
>>> 2)) ^ ((al <<
25) | (ah
>>> 7));
32977 var sigma1h = ((el <<
18) | (eh
>>> 14)) ^ ((el <<
14) | (eh
>>> 18)) ^ ((eh <<
23) | (el
>>> 9));
32978 var sigma1l = ((eh <<
18) | (el
>>> 14)) ^ ((eh <<
14) | (el
>>> 18)) ^ ((el <<
23) | (eh
>>> 9));
32982 var krl = k[i*
2+
1];
32984 // t1 = h + sigma1 + ch + K(round) + W(round)
32985 var t1l = hl + sigma1l;
32986 var t1h = hh + sigma1h + ((t1l
>>> 0) < (hl
>>> 0) ?
1 :
0);
32988 t1h += chh + ((t1l
>>> 0) < (chl
>>> 0) ?
1 :
0);
32990 t1h += krh + ((t1l
>>> 0) < (krl
>>> 0) ?
1 :
0);
32991 t1l = t1l + wrl|
0; // FF32..FF34 perf issue https://bugzilla.mozilla.org/show_bug.cgi?id=
1054972
32992 t1h += wrh + ((t1l
>>> 0) < (wrl
>>> 0) ?
1 :
0);
32994 // t2 = sigma0 + maj
32995 var t2l = sigma0l + majl;
32996 var t2h = sigma0h + majh + ((t2l
>>> 0) < (sigma0l
>>> 0) ?
1 :
0);
32998 // Update working variables
33005 el = (dl + t1l) |
0;
33006 eh = (dh + t1h + ((el
>>> 0) < (dl
>>> 0) ?
1 :
0)) |
0;
33013 al = (t1l + t2l) |
0;
33014 ah = (t1h + t2h + ((al
>>> 0) < (t1l
>>> 0) ?
1 :
0)) |
0;
33017 // Intermediate hash
33018 h0l = h[
1] = (h0l + al) |
0;
33019 h[
0] = (h0h + ah + ((h0l
>>> 0) < (al
>>> 0) ?
1 :
0)) |
0;
33020 h1l = h[
3] = (h1l + bl) |
0;
33021 h[
2] = (h1h + bh + ((h1l
>>> 0) < (bl
>>> 0) ?
1 :
0)) |
0;
33022 h2l = h[
5] = (h2l + cl) |
0;
33023 h[
4] = (h2h + ch + ((h2l
>>> 0) < (cl
>>> 0) ?
1 :
0)) |
0;
33024 h3l = h[
7] = (h3l + dl) |
0;
33025 h[
6] = (h3h + dh + ((h3l
>>> 0) < (dl
>>> 0) ?
1 :
0)) |
0;
33026 h4l = h[
9] = (h4l + el) |
0;
33027 h[
8] = (h4h + eh + ((h4l
>>> 0) < (el
>>> 0) ?
1 :
0)) |
0;
33028 h5l = h[
11] = (h5l + fl) |
0;
33029 h[
10] = (h5h + fh + ((h5l
>>> 0) < (fl
>>> 0) ?
1 :
0)) |
0;
33030 h6l = h[
13] = (h6l + gl) |
0;
33031 h[
12] = (h6h + gh + ((h6l
>>> 0) < (gl
>>> 0) ?
1 :
0)) |
0;
33032 h7l = h[
15] = (h7l + hl) |
0;
33033 h[
14] = (h7h + hh + ((h7l
>>> 0) < (hl
>>> 0) ?
1 :
0)) |
0;
33040 /** @fileOverview HMAC implementation.
33042 * @author Emily Stark
33043 * @author Mike Hamburg
33044 * @author Dan Boneh
33047 /** HMAC with the specified hash function.
33049 * @param {bitArray} key the key for HMAC.
33050 * @param {Object} [hash=sjcl.hash.sha256] The hash function to use.
33052 sjcl.misc.hmac = function (key, Hash) {
33053 this._hash = Hash = Hash || sjcl.hash.sha256;
33054 var exKey = [[],[]], i,
33055 bs = Hash.prototype.blockSize /
32;
33056 this._baseHash = [new Hash(), new Hash()];
33058 if (key.length
> bs) {
33059 key = Hash.hash(key);
33062 for (i=
0; i
<bs; i++) {
33063 exKey[
0][i] = key[i]^
0x36363636;
33064 exKey[
1][i] = key[i]^
0x5C5C5C5C;
33067 this._baseHash[
0].update(exKey[
0]);
33068 this._baseHash[
1].update(exKey[
1]);
33069 this._resultHash = new Hash(this._baseHash[
0]);
33072 /** HMAC with the specified hash function. Also called encrypt since it's a prf.
33073 * @param {bitArray|String} data The data to mac.
33075 sjcl.misc.hmac.prototype.encrypt = sjcl.misc.hmac.prototype.mac = function (data) {
33076 if (!this._updated) {
33078 return this.digest(data);
33080 throw new sjcl.exception.invalid(
"encrypt on already updated hmac called!");
33084 sjcl.misc.hmac.prototype.reset = function () {
33085 this._resultHash = new this._hash(this._baseHash[
0]);
33086 this._updated = false;
33089 sjcl.misc.hmac.prototype.update = function (data) {
33090 this._updated = true;
33091 this._resultHash.update(data);
33094 sjcl.misc.hmac.prototype.digest = function () {
33095 var w = this._resultHash.finalize(), result = new (this._hash)(this._baseHash[
1]).update(w).finalize();
33106 /** @fileOverview Password-based key-derivation function, version
2.0.
33108 * @author Emily Stark
33109 * @author Mike Hamburg
33110 * @author Dan Boneh
33113 /** Password-Based Key-Derivation Function, version
2.0.
33115 * Generate keys from passwords using PBKDF2-HMAC-SHA256.
33117 * This is the method specified by RSA's PKCS #
5 standard.
33119 * @param {bitArray|String} password The password.
33120 * @param {bitArray|String} salt The salt. Should have lots of entropy.
33121 * @param {Number} [count=
1000] The number of iterations. Higher numbers make the function slower but more secure.
33122 * @param {Number} [length] The length of the derived key. Defaults to the
33123 output size of the hash function.
33124 * @param {Object} [Prff=sjcl.misc.hmac] The pseudorandom function family.
33125 * @return {bitArray} the derived key.
33127 sjcl.misc.pbkdf2 = function (password, salt, count, length, Prff) {
33128 count = count ||
1000;
33130 if (length <
0 || count <
0) {
33131 throw sjcl.exception.invalid(
"invalid params to pbkdf2");
33134 if (typeof password ===
"string") {
33135 password = sjcl.codec.utf8String.toBits(password);
33138 if (typeof salt ===
"string") {
33139 salt = sjcl.codec.utf8String.toBits(salt);
33142 Prff = Prff || sjcl.misc.hmac;
33144 var prf = new Prff(password),
33145 u, ui, i, j, k, out = [], b = sjcl.bitArray;
33147 for (k =
1;
32 * out.length < (length ||
1); k++) {
33148 u = ui = prf.encrypt(b.concat(salt,[k]));
33150 for (i=
1; i
<count; i++) {
33151 ui = prf.encrypt(ui);
33152 for (j=
0; j
<ui.length; j++) {
33157 out = out.concat(u);
33160 if (length) { out = b.clamp(out, length); }
33168 /** @fileOverview Javascript SHA-
256 implementation.
33170 * An older version of this implementation is available in the public
33171 * domain, but this one is (c) Emily Stark, Mike Hamburg, Dan Boneh,
33172 * Stanford University
2008-
2010 and BSD-licensed for liability
33175 * Special thanks to Aldo Cortesi for pointing out several bugs in
33178 * @author Emily Stark
33179 * @author Mike Hamburg
33180 * @author Dan Boneh
33184 * Context for a SHA-
256 operation in progress.
33186 * @class Secure Hash Algorithm,
256 bits.
33188 sjcl.hash.sha256 = function (hash) {
33189 if (!this._key[
0]) { this._precompute(); }
33191 this._h = hash._h.slice(
0);
33192 this._buffer = hash._buffer.slice(
0);
33193 this._length = hash._length;
33200 * Hash a string or an array of words.
33202 * @param {bitArray|String} data the data to hash.
33203 * @return {bitArray} The hash value, an array of
16 big-endian words.
33205 sjcl.hash.sha256.hash = function (data) {
33206 return (new sjcl.hash.sha256()).update(data).finalize();
33209 sjcl.hash.sha256.prototype = {
33211 * The hash's block size, in bits.
33217 * Reset the hash state.
33220 reset:function () {
33221 this._h = this._init.slice(
0);
33228 * Input several words to the hash.
33229 * @param {bitArray|String} data the data to hash.
33232 update: function (data) {
33233 if (typeof data ===
"string") {
33234 data = sjcl.codec.utf8String.toBits(data);
33236 var i, b = this._buffer = sjcl.bitArray.concat(this._buffer, data),
33238 nl = this._length = ol + sjcl.bitArray.bitLength(data);
33239 for (i =
512+ol & -
512; i <= nl; i+=
512) {
33240 this._block(b.splice(
0,
16));
33246 * Complete hashing and output the hash value.
33247 * @return {bitArray} The hash value, an array of
8 big-endian words.
33249 finalize:function () {
33250 var i, b = this._buffer, h = this._h;
33252 // Round out and push the buffer
33253 b = sjcl.bitArray.concat(b, [sjcl.bitArray.partial(
1,
1)]);
33255 // Round out the buffer to a multiple of
16 words, less the
2 length words.
33256 for (i = b.length +
2; i &
15; i++) {
33260 // append the length
33261 b.push(Math.floor(this._length /
0x100000000));
33262 b.push(this._length |
0);
33265 this._block(b.splice(
0,
16));
33273 * The SHA-
256 initialization vector, to be precomputed.
33278 _init:[
0x6a09e667,
0xbb67ae85,
0x3c6ef372,
0xa54ff53a,
0x510e527f,
0x9b05688c,
0x1f83d9ab,
0x5be0cd19],
33282 * The SHA-
256 hash key, to be precomputed.
33288 [
0x428a2f98,
0x71374491,
0xb5c0fbcf,
0xe9b5dba5,
0x3956c25b,
0x59f111f1,
0x923f82a4,
0xab1c5ed5,
33289 0xd807aa98,
0x12835b01,
0x243185be,
0x550c7dc3,
0x72be5d74,
0x80deb1fe,
0x9bdc06a7,
0xc19bf174,
33290 0xe49b69c1,
0xefbe4786,
0x0fc19dc6,
0x240ca1cc,
0x2de92c6f,
0x4a7484aa,
0x5cb0a9dc,
0x76f988da,
33291 0x983e5152,
0xa831c66d,
0xb00327c8,
0xbf597fc7,
0xc6e00bf3,
0xd5a79147,
0x06ca6351,
0x14292967,
33292 0x27b70a85,
0x2e1b2138,
0x4d2c6dfc,
0x53380d13,
0x650a7354,
0x766a0abb,
0x81c2c92e,
0x92722c85,
33293 0xa2bfe8a1,
0xa81a664b,
0xc24b8b70,
0xc76c51a3,
0xd192e819,
0xd6990624,
0xf40e3585,
0x106aa070,
33294 0x19a4c116,
0x1e376c08,
0x2748774c,
0x34b0bcb5,
0x391c0cb3,
0x4ed8aa4a,
0x5b9cca4f,
0x682e6ff3,
33295 0x748f82ee,
0x78a5636f,
0x84c87814,
0x8cc70208,
0x90befffa,
0xa4506ceb,
0xbef9a3f7,
0xc67178f2],
33300 * Function to precompute _init and _key.
33303 _precompute: function () {
33304 var i =
0, prime =
2, factor;
33306 function frac(x) { return (x-Math.floor(x)) *
0x100000000 |
0; }
33308 outer: for (; i
<64; prime++) {
33309 for (factor=
2; factor*factor <= prime; factor++) {
33310 if (prime % factor ===
0) {
33317 this._init[i] = frac(Math.pow(prime,
1/
2));
33319 this._key[i] = frac(Math.pow(prime,
1/
3));
33325 * Perform one cycle of SHA-
256.
33326 * @param {bitArray} words one block of words.
33329 _block:function (words) {
33331 w = words.slice(
0),
33334 h0 = h[
0], h1 = h[
1], h2 = h[
2], h3 = h[
3],
33335 h4 = h[
4], h5 = h[
5], h6 = h[
6], h7 = h[
7];
33337 /* Rationale for placement of |
0 :
33338 * If a value can overflow is original
32 bits by a factor of more than a few
33339 * million (
2^
23 ish), there is a possibility that it might overflow the
33340 *
53-bit mantissa and lose precision.
33342 * To avoid this, we clamp back to
32 bits by |'ing with
0 on any value that
33343 * propagates around the loop, and on the hash state h[]. I don't believe
33344 * that the clamps on h4 and on h0 are strictly necessary, but it's close
33345 * (for h4 anyway), and better safe than sorry.
33347 * The clamps on h[] are necessary for the output to be correct even in the
33348 * common case and for short inputs.
33350 for (i=
0; i
<64; i++) {
33351 // load up the input word for this round
33355 a = w[(i+
1 ) &
15];
33356 b = w[(i+
14) &
15];
33357 tmp = w[i&
15] = ((a
>>>7 ^ a
>>>18 ^ a
>>>3 ^ a<
<25 ^ a<
<14) +
33358 (b
>>>17 ^ b
>>>19 ^ b
>>>10 ^ b<
<15 ^ b<
<13) +
33359 w[i&
15] + w[(i+
9) &
15]) |
0;
33362 tmp = (tmp + h7 + (h4
>>>6 ^ h4
>>>11 ^ h4
>>>25 ^ h4<
<26 ^ h4<
<21 ^ h4<
<7) + (h6 ^ h4&(h5^h6)) + k[i]); // |
0;
33365 h7 = h6; h6 = h5; h5 = h4;
33367 h3 = h2; h2 = h1; h1 = h0;
33369 h0 = (tmp + ((h1&h2) ^ (h3&(h1^h2))) + (h1
>>>2 ^ h1
>>>13 ^ h1
>>>22 ^ h1<
<30 ^ h1<
<19 ^ h1<
<10)) |
0;
33372 h[
0] = h[
0]+h0 |
0;
33373 h[
1] = h[
1]+h1 |
0;
33374 h[
2] = h[
2]+h2 |
0;
33375 h[
3] = h[
3]+h3 |
0;
33376 h[
4] = h[
4]+h4 |
0;
33377 h[
5] = h[
5]+h5 |
0;
33378 h[
6] = h[
6]+h6 |
0;
33379 h[
7] = h[
7]+h7 |
0;
33387 WORDLISTS["english"] = [
33388 "abandon","ability","able","about","above","absent","absorb","abstract","absurd","abuse",
33389 "access","accident","account","accuse","achieve","acid","acoustic","acquire","across","act",
33390 "action","actor","actress","actual","adapt","add","addict","address","adjust","admit",
33391 "adult","advance","advice","aerobic","affair","afford","afraid","again","age","agent",
33392 "agree","ahead","aim","air","airport","aisle","alarm","album","alcohol","alert",
33393 "alien","all","alley","allow","almost","alone","alpha","already","also","alter",
33394 "always","amateur","amazing","among","amount","amused","analyst","anchor","ancient","anger",
33395 "angle","angry","animal","ankle","announce","annual","another","answer","antenna","antique",
33396 "anxiety","any","apart","apology","appear","apple","approve","april","arch","arctic",
33397 "area","arena","argue","arm","armed","armor","army","around","arrange","arrest",
33398 "arrive","arrow","art","artefact","artist","artwork","ask","aspect","assault","asset",
33399 "assist","assume","asthma","athlete","atom","attack","attend","attitude","attract","auction",
33400 "audit","august","aunt","author","auto","autumn","average","avocado","avoid","awake",
33401 "aware","away","awesome","awful","awkward","axis","baby","bachelor","bacon","badge",
33402 "bag","balance","balcony","ball","bamboo","banana","banner","bar","barely","bargain",
33403 "barrel","base","basic","basket","battle","beach","bean","beauty","because","become",
33404 "beef","before","begin","behave","behind","believe","below","belt","bench","benefit",
33405 "best","betray","better","between","beyond","bicycle","bid","bike","bind","biology",
33406 "bird","birth","bitter","black","blade","blame","blanket","blast","bleak","bless",
33407 "blind","blood","blossom","blouse","blue","blur","blush","board","boat","body",
33408 "boil","bomb","bone","bonus","book","boost","border","boring","borrow","boss",
33409 "bottom","bounce","box","boy","bracket","brain","brand","brass","brave","bread",
33410 "breeze","brick","bridge","brief","bright","bring","brisk","broccoli","broken","bronze",
33411 "broom","brother","brown","brush","bubble","buddy","budget","buffalo","build","bulb",
33412 "bulk","bullet","bundle","bunker","burden","burger","burst","bus","business","busy",
33413 "butter","buyer","buzz","cabbage","cabin","cable","cactus","cage","cake","call",
33414 "calm","camera","camp","can","canal","cancel","candy","cannon","canoe","canvas",
33415 "canyon","capable","capital","captain","car","carbon","card","cargo","carpet","carry",
33416 "cart","case","cash","casino","castle","casual","cat","catalog","catch","category",
33417 "cattle","caught","cause","caution","cave","ceiling","celery","cement","census","century",
33418 "cereal","certain","chair","chalk","champion","change","chaos","chapter","charge","chase",
33419 "chat","cheap","check","cheese","chef","cherry","chest","chicken","chief","child",
33420 "chimney","choice","choose","chronic","chuckle","chunk","churn","cigar","cinnamon","circle",
33421 "citizen","city","civil","claim","clap","clarify","claw","clay","clean","clerk",
33422 "clever","click","client","cliff","climb","clinic","clip","clock","clog","close",
33423 "cloth","cloud","clown","club","clump","cluster","clutch","coach","coast","coconut",
33424 "code","coffee","coil","coin","collect","color","column","combine","come","comfort",
33425 "comic","common","company","concert","conduct","confirm","congress","connect","consider","control",
33426 "convince","cook","cool","copper","copy","coral","core","corn","correct","cost",
33427 "cotton","couch","country","couple","course","cousin","cover","coyote","crack","cradle",
33428 "craft","cram","crane","crash","crater","crawl","crazy","cream","credit","creek",
33429 "crew","cricket","crime","crisp","critic","crop","cross","crouch","crowd","crucial",
33430 "cruel","cruise","crumble","crunch","crush","cry","crystal","cube","culture","cup",
33431 "cupboard","curious","current","curtain","curve","cushion","custom","cute","cycle","dad",
33432 "damage","damp","dance","danger","daring","dash","daughter","dawn","day","deal",
33433 "debate","debris","decade","december","decide","decline","decorate","decrease","deer","defense",
33434 "define","defy","degree","delay","deliver","demand","demise","denial","dentist","deny",
33435 "depart","depend","deposit","depth","deputy","derive","describe","desert","design","desk",
33436 "despair","destroy","detail","detect","develop","device","devote","diagram","dial","diamond",
33437 "diary","dice","diesel","diet","differ","digital","dignity","dilemma","dinner","dinosaur",
33438 "direct","dirt","disagree","discover","disease","dish","dismiss","disorder","display","distance",
33439 "divert","divide","divorce","dizzy","doctor","document","dog","doll","dolphin","domain",
33440 "donate","donkey","donor","door","dose","double","dove","draft","dragon","drama",
33441 "drastic","draw","dream","dress","drift","drill","drink","drip","drive","drop",
33442 "drum","dry","duck","dumb","dune","during","dust","dutch","duty","dwarf",
33443 "dynamic","eager","eagle","early","earn","earth","easily","east","easy","echo",
33444 "ecology","economy","edge","edit","educate","effort","egg","eight","either","elbow",
33445 "elder","electric","elegant","element","elephant","elevator","elite","else","embark","embody",
33446 "embrace","emerge","emotion","employ","empower","empty","enable","enact","end","endless",
33447 "endorse","enemy","energy","enforce","engage","engine","enhance","enjoy","enlist","enough",
33448 "enrich","enroll","ensure","enter","entire","entry","envelope","episode","equal","equip",
33449 "era","erase","erode","erosion","error","erupt","escape","essay","essence","estate",
33450 "eternal","ethics","evidence","evil","evoke","evolve","exact","example","excess","exchange",
33451 "excite","exclude","excuse","execute","exercise","exhaust","exhibit","exile","exist","exit",
33452 "exotic","expand","expect","expire","explain","expose","express","extend","extra","eye",
33453 "eyebrow","fabric","face","faculty","fade","faint","faith","fall","false","fame",
33454 "family","famous","fan","fancy","fantasy","farm","fashion","fat","fatal","father",
33455 "fatigue","fault","favorite","feature","february","federal","fee","feed","feel","female",
33456 "fence","festival","fetch","fever","few","fiber","fiction","field","figure","file",
33457 "film","filter","final","find","fine","finger","finish","fire","firm","first",
33458 "fiscal","fish","fit","fitness","fix","flag","flame","flash","flat","flavor",
33459 "flee","flight","flip","float","flock","floor","flower","fluid","flush","fly",
33460 "foam","focus","fog","foil","fold","follow","food","foot","force","forest",
33461 "forget","fork","fortune","forum","forward","fossil","foster","found","fox","fragile",
33462 "frame","frequent","fresh","friend","fringe","frog","front","frost","frown","frozen",
33463 "fruit","fuel","fun","funny","furnace","fury","future","gadget","gain","galaxy",
33464 "gallery","game","gap","garage","garbage","garden","garlic","garment","gas","gasp",
33465 "gate","gather","gauge","gaze","general","genius","genre","gentle","genuine","gesture",
33466 "ghost","giant","gift","giggle","ginger","giraffe","girl","give","glad","glance",
33467 "glare","glass","glide","glimpse","globe","gloom","glory","glove","glow","glue",
33468 "goat","goddess","gold","good","goose","gorilla","gospel","gossip","govern","gown",
33469 "grab","grace","grain","grant","grape","grass","gravity","great","green","grid",
33470 "grief","grit","grocery","group","grow","grunt","guard","guess","guide","guilt",
33471 "guitar","gun","gym","habit","hair","half","hammer","hamster","hand","happy",
33472 "harbor","hard","harsh","harvest","hat","have","hawk","hazard","head","health",
33473 "heart","heavy","hedgehog","height","hello","helmet","help","hen","hero","hidden",
33474 "high","hill","hint","hip","hire","history","hobby","hockey","hold","hole",
33475 "holiday","hollow","home","honey","hood","hope","horn","horror","horse","hospital",
33476 "host","hotel","hour","hover","hub","huge","human","humble","humor","hundred",
33477 "hungry","hunt","hurdle","hurry","hurt","husband","hybrid","ice","icon","idea",
33478 "identify","idle","ignore","ill","illegal","illness","image","imitate","immense","immune",
33479 "impact","impose","improve","impulse","inch","include","income","increase","index","indicate",
33480 "indoor","industry","infant","inflict","inform","inhale","inherit","initial","inject","injury",
33481 "inmate","inner","innocent","input","inquiry","insane","insect","inside","inspire","install",
33482 "intact","interest","into","invest","invite","involve","iron","island","isolate","issue",
33483 "item","ivory","jacket","jaguar","jar","jazz","jealous","jeans","jelly","jewel",
33484 "job","join","joke","journey","joy","judge","juice","jump","jungle","junior",
33485 "junk","just","kangaroo","keen","keep","ketchup","key","kick","kid","kidney",
33486 "kind","kingdom","kiss","kit","kitchen","kite","kitten","kiwi","knee","knife",
33487 "knock","know","lab","label","labor","ladder","lady","lake","lamp","language",
33488 "laptop","large","later","latin","laugh","laundry","lava","law","lawn","lawsuit",
33489 "layer","lazy","leader","leaf","learn","leave","lecture","left","leg","legal",
33490 "legend","leisure","lemon","lend","length","lens","leopard","lesson","letter","level",
33491 "liar","liberty","library","license","life","lift","light","like","limb","limit",
33492 "link","lion","liquid","list","little","live","lizard","load","loan","lobster",
33493 "local","lock","logic","lonely","long","loop","lottery","loud","lounge","love",
33494 "loyal","lucky","luggage","lumber","lunar","lunch","luxury","lyrics","machine","mad",
33495 "magic","magnet","maid","mail","main","major","make","mammal","man","manage",
33496 "mandate","mango","mansion","manual","maple","marble","march","margin","marine","market",
33497 "marriage","mask","mass","master","match","material","math","matrix","matter","maximum",
33498 "maze","meadow","mean","measure","meat","mechanic","medal","media","melody","melt",
33499 "member","memory","mention","menu","mercy","merge","merit","merry","mesh","message",
33500 "metal","method","middle","midnight","milk","million","mimic","mind","minimum","minor",
33501 "minute","miracle","mirror","misery","miss","mistake","mix","mixed","mixture","mobile",
33502 "model","modify","mom","moment","monitor","monkey","monster","month","moon","moral",
33503 "more","morning","mosquito","mother","motion","motor","mountain","mouse","move","movie",
33504 "much","muffin","mule","multiply","muscle","museum","mushroom","music","must","mutual",
33505 "myself","mystery","myth","naive","name","napkin","narrow","nasty","nation","nature",
33506 "near","neck","need","negative","neglect","neither","nephew","nerve","nest","net",
33507 "network","neutral","never","news","next","nice","night","noble","noise","nominee",
33508 "noodle","normal","north","nose","notable","note","nothing","notice","novel","now",
33509 "nuclear","number","nurse","nut","oak","obey","object","oblige","obscure","observe",
33510 "obtain","obvious","occur","ocean","october","odor","off","offer","office","often",
33511 "oil","okay","old","olive","olympic","omit","once","one","onion","online",
33512 "only","open","opera","opinion","oppose","option","orange","orbit","orchard","order",
33513 "ordinary","organ","orient","original","orphan","ostrich","other","outdoor","outer","output",
33514 "outside","oval","oven","over","own","owner","oxygen","oyster","ozone","pact",
33515 "paddle","page","pair","palace","palm","panda","panel","panic","panther","paper",
33516 "parade","parent","park","parrot","party","pass","patch","path","patient","patrol",
33517 "pattern","pause","pave","payment","peace","peanut","pear","peasant","pelican","pen",
33518 "penalty","pencil","people","pepper","perfect","permit","person","pet","phone","photo",
33519 "phrase","physical","piano","picnic","picture","piece","pig","pigeon","pill","pilot",
33520 "pink","pioneer","pipe","pistol","pitch","pizza","place","planet","plastic","plate",
33521 "play","please","pledge","pluck","plug","plunge","poem","poet","point","polar",
33522 "pole","police","pond","pony","pool","popular","portion","position","possible","post",
33523 "potato","pottery","poverty","powder","power","practice","praise","predict","prefer","prepare",
33524 "present","pretty","prevent","price","pride","primary","print","priority","prison","private",
33525 "prize","problem","process","produce","profit","program","project","promote","proof","property",
33526 "prosper","protect","proud","provide","public","pudding","pull","pulp","pulse","pumpkin",
33527 "punch","pupil","puppy","purchase","purity","purpose","purse","push","put","puzzle",
33528 "pyramid","quality","quantum","quarter","question","quick","quit","quiz","quote","rabbit",
33529 "raccoon","race","rack","radar","radio","rail","rain","raise","rally","ramp",
33530 "ranch","random","range","rapid","rare","rate","rather","raven","raw","razor",
33531 "ready","real","reason","rebel","rebuild","recall","receive","recipe","record","recycle",
33532 "reduce","reflect","reform","refuse","region","regret","regular","reject","relax","release",
33533 "relief","rely","remain","remember","remind","remove","render","renew","rent","reopen",
33534 "repair","repeat","replace","report","require","rescue","resemble","resist","resource","response",
33535 "result","retire","retreat","return","reunion","reveal","review","reward","rhythm","rib",
33536 "ribbon","rice","rich","ride","ridge","rifle","right","rigid","ring","riot",
33537 "ripple","risk","ritual","rival","river","road","roast","robot","robust","rocket",
33538 "romance","roof","rookie","room","rose","rotate","rough","round","route","royal",
33539 "rubber","rude","rug","rule","run","runway","rural","sad","saddle","sadness",
33540 "safe","sail","salad","salmon","salon","salt","salute","same","sample","sand",
33541 "satisfy","satoshi","sauce","sausage","save","say","scale","scan","scare","scatter",
33542 "scene","scheme","school","science","scissors","scorpion","scout","scrap","screen","script",
33543 "scrub","sea","search","season","seat","second","secret","section","security","seed",
33544 "seek","segment","select","sell","seminar","senior","sense","sentence","series","service",
33545 "session","settle","setup","seven","shadow","shaft","shallow","share","shed","shell",
33546 "sheriff","shield","shift","shine","ship","shiver","shock","shoe","shoot","shop",
33547 "short","shoulder","shove","shrimp","shrug","shuffle","shy","sibling","sick","side",
33548 "siege","sight","sign","silent","silk","silly","silver","similar","simple","since",
33549 "sing","siren","sister","situate","six","size","skate","sketch","ski","skill",
33550 "skin","skirt","skull","slab","slam","sleep","slender","slice","slide","slight",
33551 "slim","slogan","slot","slow","slush","small","smart","smile","smoke","smooth",
33552 "snack","snake","snap","sniff","snow","soap","soccer","social","sock","soda",
33553 "soft","solar","soldier","solid","solution","solve","someone","song","soon","sorry",
33554 "sort","soul","sound","soup","source","south","space","spare","spatial","spawn",
33555 "speak","special","speed","spell","spend","sphere","spice","spider","spike","spin",
33556 "spirit","split","spoil","sponsor","spoon","sport","spot","spray","spread","spring",
33557 "spy","square","squeeze","squirrel","stable","stadium","staff","stage","stairs","stamp",
33558 "stand","start","state","stay","steak","steel","stem","step","stereo","stick",
33559 "still","sting","stock","stomach","stone","stool","story","stove","strategy","street",
33560 "strike","strong","struggle","student","stuff","stumble","style","subject","submit","subway",
33561 "success","such","sudden","suffer","sugar","suggest","suit","summer","sun","sunny",
33562 "sunset","super","supply","supreme","sure","surface","surge","surprise","surround","survey",
33563 "suspect","sustain","swallow","swamp","swap","swarm","swear","sweet","swift","swim",
33564 "swing","switch","sword","symbol","symptom","syrup","system","table","tackle","tag",
33565 "tail","talent","talk","tank","tape","target","task","taste","tattoo","taxi",
33566 "teach","team","tell","ten","tenant","tennis","tent","term","test","text",
33567 "thank","that","theme","then","theory","there","they","thing","this","thought",
33568 "three","thrive","throw","thumb","thunder","ticket","tide","tiger","tilt","timber",
33569 "time","tiny","tip","tired","tissue","title","toast","tobacco","today","toddler",
33570 "toe","together","toilet","token","tomato","tomorrow","tone","tongue","tonight","tool",
33571 "tooth","top","topic","topple","torch","tornado","tortoise","toss","total","tourist",
33572 "toward","tower","town","toy","track","trade","traffic","tragic","train","transfer",
33573 "trap","trash","travel","tray","treat","tree","trend","trial","tribe","trick",
33574 "trigger","trim","trip","trophy","trouble","truck","true","truly","trumpet","trust",
33575 "truth","try","tube","tuition","tumble","tuna","tunnel","turkey","turn","turtle",
33576 "twelve","twenty","twice","twin","twist","two","type","typical","ugly","umbrella",
33577 "unable","unaware","uncle","uncover","under","undo","unfair","unfold","unhappy","uniform",
33578 "unique","unit","universe","unknown","unlock","until","unusual","unveil","update","upgrade",
33579 "uphold","upon","upper","upset","urban","urge","usage","use","used","useful",
33580 "useless","usual","utility","vacant","vacuum","vague","valid","valley","valve","van",
33581 "vanish","vapor","various","vast","vault","vehicle","velvet","vendor","venture","venue",
33582 "verb","verify","version","very","vessel","veteran","viable","vibrant","vicious","victory",
33583 "video","view","village","vintage","violin","virtual","virus","visa","visit","visual",
33584 "vital","vivid","vocal","voice","void","volcano","volume","vote","voyage","wage",
33585 "wagon","wait","walk","wall","walnut","want","warfare","warm","warrior","wash",
33586 "wasp","waste","water","wave","way","wealth","weapon","wear","weasel","weather",
33587 "web","wedding","weekend","weird","welcome","west","wet","whale","what","wheat",
33588 "wheel","when","where","whip","whisper","wide","width","wife","wild","will",
33589 "win","window","wine","wing","wink","winner","winter","wire","wisdom","wise",
33590 "wish","witness","wolf","woman","wonder","wood","wool","word","work","world",
33591 "worry","worth","wrap","wreck","wrestle","wrist","write","wrong","yard","year",
33592 "yellow","you","young","youth","zebra","zero","zone","zoo"]
33596 * Copyright (c)
2013 Pavol Rusnak
33598 * Permission is hereby granted, free of charge, to any person obtaining a copy of
33599 * this software and associated documentation files (the "Software"), to deal in
33600 * the Software without restriction, including without limitation the rights to
33601 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
33602 * of the Software, and to permit persons to whom the Software is furnished to do
33603 * so, subject to the following conditions:
33605 * The above copyright notice and this permission notice shall be included in all
33606 * copies or substantial portions of the Software.
33608 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
33609 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33610 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
33611 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
33612 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
33613 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33617 * Javascript port from python by Ian Coleman
33619 * Requires code from sjcl
33620 * https://github.com/bitwiseshiftleft/sjcl
33623 var Mnemonic = function(language) {
33625 var PBKDF2_ROUNDS =
2048;
33631 var hmacSHA512 = function(key) {
33632 var hasher = new sjcl.misc.hmac(key, sjcl.hash.sha512);
33633 this.encrypt = function() {
33634 return hasher.encrypt.apply(hasher, arguments);
33639 wordlist = WORDLISTS[language];
33640 if (wordlist.length != RADIX) {
33641 err = 'Wordlist should contain ' + RADIX + ' words, but it contains ' + wordlist.length + ' words.';
33646 self.generate = function(strength) {
33647 strength = strength ||
128;
33648 var r = strength %
32;
33650 throw 'Strength should be divisible by
32, but it is not (' + r + ').';
33652 var hasStrongCrypto = 'crypto' in window && window['crypto'] !== null;
33653 if (!hasStrongCrypto) {
33654 throw 'Mnemonic should be generated with strong randomness, but crypto.getRandomValues is unavailable';
33656 var buffer = new Uint8Array(strength /
8);
33657 var data = crypto.getRandomValues(buffer);
33658 return self.toMnemonic(data);
33661 self.toMnemonic = function(byteArray) {
33662 if (byteArray.length %
4 > 0) {
33663 throw 'Data length in bits should be divisible by
32, but it is not (' + byteArray.length + ' bytes = ' + byteArray.length*
8 + ' bits).'
33666 //h = hashlib.sha256(data).hexdigest()
33667 var data = byteArrayToWordArray(byteArray);
33668 var hash = sjcl.hash.sha256.hash(data);
33669 var h = sjcl.codec.hex.fromBits(hash);
33671 // b is a binary string, eg '
00111010101100...'
33672 //b = bin(int(binascii.hexlify(data),
16))[
2:].zfill(len(data) *
8) + \
33673 // bin(int(h,
16))[
2:].zfill(
256)[:len(data) *
8 /
32]
33675 // a = bin(int(binascii.hexlify(data),
16))[
2:].zfill(len(data) *
8)
33676 // c = bin(int(h,
16))[
2:].zfill(
256)
33677 // d = c[:len(data) *
8 /
32]
33678 var a = byteArrayToBinaryString(byteArray);
33679 var c = zfill(hexStringToBinaryString(h),
256);
33680 var d = c.substring(
0, byteArray.length *
8 /
32);
33681 // b = line1 + line2
33685 var blen = b.length /
11;
33686 for (var i=
0; i
<blen; i++) {
33687 var idx = parseInt(b.substring(i *
11, (i +
1) *
11),
2);
33688 result.push(wordlist[idx]);
33690 return result.join(' ');
33693 self.check = function(mnemonic) {
33694 var mnemonic = mnemonic.split(' ')
33695 if (mnemonic.length %
3 > 0) {
33698 // idx = map(lambda x: bin(self.wordlist.index(x))[
2:].zfill(
11), mnemonic)
33700 for (var i=
0; i
<mnemonic.length; i++) {
33701 var word = mnemonic[i];
33702 var wordIndex = wordlist.indexOf(word);
33703 if (wordIndex == -
1) {
33706 var binaryIndex = zfill(wordIndex.toString(
2),
11);
33707 idx.push(binaryIndex);
33709 var b = idx.join('');
33711 //d = b[:l /
33 *
32]
33713 var d = b.substring(
0, l /
33 *
32);
33714 var h = b.substring(l - l /
33, l);
33715 //nd = binascii.unhexlify(hex(int(d,
2))[
2:].rstrip('L').zfill(l /
33 *
8))
33716 var nd = binaryStringToWordArray(d);
33717 //nh = bin(int(hashlib.sha256(nd).hexdigest(),
16))[
2:].zfill(
256)[:l /
33]
33718 var ndHash = sjcl.hash.sha256.hash(nd);
33719 var ndHex = sjcl.codec.hex.fromBits(ndHash);
33720 var ndBstr = zfill(hexStringToBinaryString(ndHex),
256);
33721 var nh = ndBstr.substring(
0,l/
33);
33725 self.toSeed = function(mnemonic, passphrase) {
33726 passphrase = passphrase || '';
33727 mnemonic = self.normalizeString(mnemonic)
33728 passphrase = self.normalizeString(passphrase)
33729 passphrase =
"mnemonic" + passphrase;
33730 var mnemonicBits = sjcl.codec.utf8String.toBits(mnemonic);
33731 var passphraseBits = sjcl.codec.utf8String.toBits(passphrase);
33732 var result = sjcl.misc.pbkdf2(mnemonicBits, passphraseBits, PBKDF2_ROUNDS,
512, hmacSHA512);
33733 var hashHex = sjcl.codec.hex.fromBits(result);
33737 self.normalizeString = function(str) {
33738 if (typeof str.normalize ==
"function") {
33739 return str.normalize(
"NFKD");
33742 // TODO decide how to handle this in the future.
33743 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize
33748 function byteArrayToWordArray(data) {
33750 for (var i=
0; i
<data.length/
4; i++) {
33752 v += data[i*
4 +
0] <<
8 *
3;
33753 v += data[i*
4 +
1] <<
8 *
2;
33754 v += data[i*
4 +
2] <<
8 *
1;
33755 v += data[i*
4 +
3] <<
8 *
0;
33761 function byteArrayToBinaryString(data) {
33763 for (var i=
0; i
<data.length; i++) {
33764 bin += zfill(data[i].toString(
2),
8);
33769 function hexStringToBinaryString(hexString) {
33771 for (var i=
0; i
<hexString.length; i++) {
33772 binaryString += zfill(parseInt(hexString[i],
16).toString(
2),
4);
33774 return binaryString;
33777 function binaryStringToWordArray(binary) {
33778 var aLen = binary.length /
32;
33780 for (var i=
0; i
<aLen; i++) {
33781 var valueStr = binary.substring(
0,
32);
33782 var value = parseInt(valueStr,
2);
33784 binary = binary.slice(
32);
33789 // Pad a numeric string on the left with zero digits until the given width
33791 // Note this differs to the python implementation because it does not
33792 // handle numbers starting with a sign.
33793 function zfill(source, length) {
33794 source = source.toString();
33795 while (source.length < length) {
33796 source = '
0' + source;
33808 var mnemonic = new Mnemonic("english");
33809 var bip32RootKey = null;
33810 var bip32ExtendedKey = null;
33811 var network = Bitcoin.networks.bitcoin;
33812 var addressRowTemplate = $("#address-row-template");
33814 var showIndex = true;
33815 var showAddress = true;
33816 var showPrivKey = true;
33818 var phraseChangeTimeoutEvent = null;
33821 DOM.phrase = $(".phrase");
33822 DOM.passphrase = $(".passphrase");
33823 DOM.generate = $(".generate");
33824 DOM.rootKey = $(".root-key");
33825 DOM.extendedPrivKey = $(".extended-priv-key");
33826 DOM.extendedPubKey = $(".extended-pub-key");
33827 DOM.bip32path = $("#bip32-path");
33828 DOM.bip44path = $("#bip44-path");
33829 DOM.bip44purpose = $("#bip44 .purpose");
33830 DOM.bip44coin = $("#bip44 .coin");
33831 DOM.bip44account = $("#bip44 .account");
33832 DOM.bip44change = $("#bip44 .change");
33833 DOM.strength = $(".strength");
33834 DOM.addresses = $(".addresses");
33835 DOM.rowsToAdd = $(".rows-to-add");
33836 DOM.more = $(".more");
33837 DOM.feedback = $(".feedback");
33838 DOM.tab = $(".derivation-type a");
33839 DOM.indexToggle = $(".index-toggle");
33840 DOM.addressToggle = $(".address-toggle");
33841 DOM.privateKeyToggle = $(".private-key-toggle");
33843 var derivationPath = DOM.bip44path.val();
33847 DOM.phrase.on("input", delayedPhraseChanged);
33848 DOM.passphrase.on("input", delayedPhraseChanged);
33849 DOM.generate.on("click", generateClicked);
33850 DOM.more.on("click", showMore);
33851 DOM.bip32path.on("input", bip32Changed);
33852 DOM.bip44purpose.on("input", bip44Changed);
33853 DOM.bip44coin.on("input", bip44Changed);
33854 DOM.bip44account.on("input", bip44Changed);
33855 DOM.bip44change.on("input", bip44Changed);
33856 DOM.tab.on("click", tabClicked);
33857 DOM.indexToggle.on("click", toggleIndexes);
33858 DOM.addressToggle.on("click", toggleAddresses);
33859 DOM.privateKeyToggle.on("click", togglePrivateKeys);
33862 hideValidationError();
33867 function delayedPhraseChanged() {
33868 hideValidationError();
33870 if (phraseChangeTimeoutEvent != null) {
33871 clearTimeout(phraseChangeTimeoutEvent);
33873 phraseChangeTimeoutEvent = setTimeout(phraseChanged,
400);
33876 function phraseChanged() {
33878 hideValidationError();
33879 // Get the mnemonic phrase
33880 var phrase = DOM.phrase.val();
33881 var passphrase = DOM.passphrase.val();
33882 var errorText = findPhraseErrors(phrase);
33884 showValidationError(errorText);
33887 // Get the derivation path
33888 var errorText = findDerivationPathErrors();
33890 showValidationError(errorText);
33893 // Calculate and display
33894 calcBip32Seed(phrase, passphrase, derivationPath);
33895 displayBip32Info();
33899 function generateClicked() {
33902 setTimeout(function() {
33903 var phrase = generateRandomPhrase();
33911 function tabClicked(e) {
33912 var activePath = $(e.target.getAttribute("href") + " .path");
33913 derivationPath = activePath.val();
33914 derivationChanged();
33917 function derivationChanged() {
33918 delayedPhraseChanged();
33921 function bip32Changed() {
33922 derivationPath = DOM.bip32path.val();
33923 derivationChanged();
33926 function bip44Changed() {
33927 setBip44DerivationPath();
33928 derivationPath = DOM.bip44path.val();
33929 derivationChanged();
33932 function toggleIndexes() {
33933 showIndex = !showIndex;
33934 $("td.index span").toggleClass("invisible");
33937 function toggleAddresses() {
33938 showAddress = !showAddress;
33939 $("td.address span").toggleClass("invisible");
33942 function togglePrivateKeys() {
33943 showPrivKey = !showPrivKey;
33944 $("td.privkey span").toggleClass("invisible");
33949 function generateRandomPhrase() {
33950 if (!hasStrongRandom()) {
33951 var errorText = "This browser does not support strong randomness";
33952 showValidationError(errorText);
33955 var numWords = parseInt(DOM.strength.val());
33956 // Check strength is an integer
33957 if (isNaN(numWords)) {
33958 DOM.strength.val("
12");
33961 // Check strength is a multiple of
32, if not round it down
33962 if (numWords %
3 !=
0) {
33963 numWords = Math.floor(numWords /
3) *
3;
33964 DOM.strength.val(numWords);
33966 // Check strength is at least
32
33967 if (numWords ==
0) {
33969 DOM.strength.val(numWords);
33971 var strength = numWords /
3 *
32;
33972 var words = mnemonic.generate(strength);
33973 DOM.phrase.val(words);
33977 function calcBip32Seed(phrase, passphrase, path) {
33978 var seed = mnemonic.toSeed(phrase, passphrase);
33979 bip32RootKey = Bitcoin.HDNode.fromSeedHex(seed, network);
33980 bip32ExtendedKey = bip32RootKey;
33981 // Derive the key from the path
33982 var pathBits = path.split("/");
33983 for (var i=
0; i
<pathBits.length; i++) {
33984 var bit = pathBits[i];
33985 var index = parseInt(bit);
33986 if (isNaN(index)) {
33989 var hardened = bit[bit.length-
1] ==
"'";
33991 bip32ExtendedKey = bip32ExtendedKey.deriveHardened(index);
33994 bip32ExtendedKey = bip32ExtendedKey.derive(index);
33999 function showValidationError(errorText) {
34005 function hideValidationError() {
34011 function findPhraseErrors(phrase) {
34012 // TODO make this right
34013 // Preprocess the words
34014 phrase = mnemonic.normalizeString(phrase);
34015 var parts = phrase.split(
" ");
34017 for (var i=
0; i
<parts.length; i++) {
34018 var part = parts[i];
34019 if (part.length
> 0) {
34020 // TODO check that lowercasing is always valid to do
34021 proper.push(part.toLowerCase());
34024 // TODO some levenstein on the words
34025 var properPhrase = proper.join(' ');
34026 // Check the words are valid
34027 var isValid = mnemonic.check(properPhrase);
34029 return
"Invalid mnemonic";
34034 function findDerivationPathErrors(path) {
34039 function displayBip32Info() {
34041 var rootKey = bip32RootKey.toBase58();
34042 DOM.rootKey.val(rootKey);
34043 var extendedPrivKey = bip32ExtendedKey.toBase58();
34044 DOM.extendedPrivKey.val(extendedPrivKey);
34045 var extendedPubKey = bip32ExtendedKey.toBase58(false);
34046 DOM.extendedPubKey.val(extendedPubKey);
34047 // Display the addresses and privkeys
34048 clearAddressesList();
34049 displayAddresses(
0,
20);
34052 function displayAddresses(start, total) {
34053 for (var i=
0; i
<total; i++) {
34054 var index = i + start;
34055 new TableRow(index);
34059 function TableRow(index) {
34065 function calculateValues() {
34066 setTimeout(function() {
34067 var key = bip32ExtendedKey.derive(index);
34068 var address = key.getAddress().toString();
34069 var privkey = key.privKey.toWIF(network);
34070 addAddressToList(index, address, privkey);
34078 function showMore() {
34079 var start = DOM.addresses.children().length;
34080 var rowsToAdd = parseInt(DOM.rowsToAdd.val());
34081 if (isNaN(rowsToAdd)) {
34083 DOM.rowsToAdd.val(
"20");
34085 if (rowsToAdd
> 200) {
34086 var msg =
"Generating " + rowsToAdd +
" rows could take a while. ";
34087 msg +=
"Do you want to continue?";
34088 if (!confirm(msg)) {
34092 displayAddresses(start, rowsToAdd);
34095 function clearDisplay() {
34096 clearAddressesList();
34098 hideValidationError();
34101 function clearAddressesList() {
34102 DOM.addresses.empty();
34105 function clearKey() {
34106 DOM.rootKey.val(
"");
34107 DOM.extendedPrivKey.val(
"");
34108 DOM.extendedPubKey.val(
"");
34111 function addAddressToList(index, address, privkey) {
34112 var row = $(addressRowTemplate.html());
34114 var indexCell = row.find(
".index span");
34115 var addressCell = row.find(
".address span");
34116 var privkeyCell = row.find(
".privkey span");
34118 indexCell.text(index);
34119 addressCell.text(address);
34120 privkeyCell.text(privkey);
34123 indexCell.addClass(
"invisible");
34125 if (!showAddress) {
34126 addressCell.addClass(
"invisible");
34128 if (!showPrivKey) {
34129 privkeCell.addClass(
"invisible");
34131 DOM.addresses.append(row);
34134 function hasStrongRandom() {
34135 return 'crypto' in window && window['crypto'] !== null;
34138 function disableForms() {
34139 $(
"form").on(
"submit", function(e) {
34140 e.preventDefault();
34144 function setBip44DerivationPath() {
34145 var purpose = parseIntNoNaN(DOM.bip44purpose.val(),
44);
34146 var coin = parseIntNoNaN(DOM.bip44coin.val(),
0);
34147 var account = parseIntNoNaN(DOM.bip44account.val(),
0);
34148 var change = parseIntNoNaN(DOM.bip44change.val(),
0);
34150 path += purpose +
"'/";
34151 path += coin +
"'/";
34152 path += account +
"'/";
34154 DOM.bip44path.val(path);
34157 function parseIntNoNaN(val, defaultVal) {
34158 var v = parseInt(val);
34165 function showPending() {
34167 .text(
"Calculating...")
34171 function hidePending() {