1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 | var JSZip = function(data, options) {
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 | this.files = {};
|
36 |
|
37 |
|
38 | this.root = "";
|
39 |
|
40 | if (data) {
|
41 | this.load(data, options);
|
42 | }
|
43 | };
|
44 |
|
45 | JSZip.signature = {
|
46 | LOCAL_FILE_HEADER : "\x50\x4b\x03\x04",
|
47 | CENTRAL_FILE_HEADER : "\x50\x4b\x01\x02",
|
48 | CENTRAL_DIRECTORY_END : "\x50\x4b\x05\x06",
|
49 | ZIP64_CENTRAL_DIRECTORY_LOCATOR : "\x50\x4b\x06\x07",
|
50 | ZIP64_CENTRAL_DIRECTORY_END : "\x50\x4b\x06\x06",
|
51 | DATA_DESCRIPTOR : "\x50\x4b\x07\x08"
|
52 | };
|
53 |
|
54 |
|
55 | JSZip.defaults = {
|
56 | base64: false,
|
57 | binary: false,
|
58 | dir: false,
|
59 | date: null,
|
60 | compression: null
|
61 | };
|
62 |
|
63 |
|
64 |
|
65 |
|
66 | JSZip.support = {
|
67 |
|
68 | arraybuffer : (function(){
|
69 | return typeof ArrayBuffer !== "undefined" && typeof Uint8Array !== "undefined";
|
70 | })(),
|
71 |
|
72 | nodebuffer : (function(){
|
73 | return typeof Buffer !== "undefined";
|
74 | })(),
|
75 |
|
76 | uint8array : (function(){
|
77 | return typeof Uint8Array !== "undefined";
|
78 | })(),
|
79 |
|
80 | blob : (function(){
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 | if (typeof ArrayBuffer === "undefined") {
|
89 | return false;
|
90 | }
|
91 | var buffer = new ArrayBuffer(0);
|
92 | try {
|
93 | return new Blob([buffer], { type: "application/zip" }).size === 0;
|
94 | }
|
95 | catch(e) {}
|
96 |
|
97 | try {
|
98 | var BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder || window.MSBlobBuilder;
|
99 | var builder = new BlobBuilder();
|
100 | builder.append(buffer);
|
101 | return builder.getBlob('application/zip').size === 0;
|
102 | }
|
103 | catch(e) {}
|
104 |
|
105 | return false;
|
106 | })()
|
107 | };
|
108 |
|
109 | JSZip.prototype = (function () {
|
110 | var textEncoder, textDecoder;
|
111 | if (
|
112 | JSZip.support.uint8array &&
|
113 | typeof TextEncoder === "function" &&
|
114 | typeof TextDecoder === "function"
|
115 | ) {
|
116 | textEncoder = new TextEncoder("utf-8");
|
117 | textDecoder = new TextDecoder("utf-8");
|
118 | }
|
119 |
|
120 | |
121 |
|
122 |
|
123 |
|
124 |
|
125 | var getRawData = function (file) {
|
126 | if (file._data instanceof JSZip.CompressedObject) {
|
127 | file._data = file._data.getContent();
|
128 | file.options.binary = true;
|
129 | file.options.base64 = false;
|
130 |
|
131 | if (JSZip.utils.getTypeOf(file._data) === "uint8array") {
|
132 | var copy = file._data;
|
133 |
|
134 |
|
135 | file._data = new Uint8Array(copy.length);
|
136 |
|
137 | if (copy.length !== 0) {
|
138 | file._data.set(copy, 0);
|
139 | }
|
140 | }
|
141 | }
|
142 | return file._data;
|
143 | };
|
144 |
|
145 | |
146 |
|
147 |
|
148 |
|
149 |
|
150 | var getBinaryData = function (file) {
|
151 | var result = getRawData(file), type = JSZip.utils.getTypeOf(result);
|
152 | if (type === "string") {
|
153 | if (!file.options.binary) {
|
154 |
|
155 |
|
156 | if (textEncoder) {
|
157 | return textEncoder.encode(result);
|
158 | }
|
159 | if (JSZip.support.nodebuffer) {
|
160 | return new Buffer(result, "utf-8");
|
161 | }
|
162 | }
|
163 | return file.asBinary();
|
164 | }
|
165 | return result;
|
166 | };
|
167 |
|
168 | |
169 |
|
170 |
|
171 |
|
172 |
|
173 | var dataToString = function (asUTF8) {
|
174 | var result = getRawData(this);
|
175 | if (result === null || typeof result === "undefined") {
|
176 | return "";
|
177 | }
|
178 |
|
179 | if (this.options.base64) {
|
180 | result = JSZip.base64.decode(result);
|
181 | }
|
182 | if (asUTF8 && this.options.binary) {
|
183 |
|
184 |
|
185 | result = JSZip.prototype.utf8decode(result);
|
186 | } else {
|
187 |
|
188 | result = JSZip.utils.transformTo("string", result);
|
189 | }
|
190 |
|
191 | if (!asUTF8 && !this.options.binary) {
|
192 | result = JSZip.prototype.utf8encode(result);
|
193 | }
|
194 | return result;
|
195 | };
|
196 | |
197 |
|
198 |
|
199 |
|
200 |
|
201 |
|
202 |
|
203 | var ZipObject = function (name, data, options) {
|
204 | this.name = name;
|
205 | this._data = data;
|
206 | this.options = options;
|
207 | };
|
208 |
|
209 | ZipObject.prototype = {
|
210 | |
211 |
|
212 |
|
213 |
|
214 | asText : function () {
|
215 | return dataToString.call(this, true);
|
216 | },
|
217 | |
218 |
|
219 |
|
220 |
|
221 | asBinary : function () {
|
222 | return dataToString.call(this, false);
|
223 | },
|
224 | |
225 |
|
226 |
|
227 |
|
228 | asNodeBuffer : function () {
|
229 | var result = getBinaryData(this);
|
230 | return JSZip.utils.transformTo("nodebuffer", result);
|
231 | },
|
232 | |
233 |
|
234 |
|
235 |
|
236 | asUint8Array : function () {
|
237 | var result = getBinaryData(this);
|
238 | return JSZip.utils.transformTo("uint8array", result);
|
239 | },
|
240 | |
241 |
|
242 |
|
243 |
|
244 | asArrayBuffer : function () {
|
245 | return this.asUint8Array().buffer;
|
246 | }
|
247 | };
|
248 |
|
249 | |
250 |
|
251 |
|
252 |
|
253 |
|
254 |
|
255 |
|
256 | var decToHex = function(dec, bytes) {
|
257 | var hex = "", i;
|
258 | for(i = 0; i < bytes; i++) {
|
259 | hex += String.fromCharCode(dec&0xff);
|
260 | dec=dec>>>8;
|
261 | }
|
262 | return hex;
|
263 | };
|
264 |
|
265 | |
266 |
|
267 |
|
268 |
|
269 |
|
270 |
|
271 | var extend = function () {
|
272 | var result = {}, i, attr;
|
273 | for (i = 0; i < arguments.length; i++) {
|
274 | for (attr in arguments[i]) {
|
275 | if (arguments[i].hasOwnProperty(attr) && typeof result[attr] === "undefined") {
|
276 | result[attr] = arguments[i][attr];
|
277 | }
|
278 | }
|
279 | }
|
280 | return result;
|
281 | };
|
282 |
|
283 | |
284 |
|
285 |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 | var prepareFileAttrs = function (o) {
|
291 | o = o || {};
|
292 |
|
293 | if (o.base64 === true && o.binary == null) {
|
294 | o.binary = true;
|
295 | }
|
296 |
|
297 | o = extend(o, JSZip.defaults);
|
298 | o.date = o.date || new Date();
|
299 | if (o.compression !== null) o.compression = o.compression.toUpperCase();
|
300 |
|
301 | return o;
|
302 | };
|
303 |
|
304 | |
305 |
|
306 |
|
307 |
|
308 |
|
309 |
|
310 |
|
311 |
|
312 | var fileAdd = function (name, data, o) {
|
313 |
|
314 | var parent = parentFolder(name), dataType = JSZip.utils.getTypeOf(data);
|
315 | if (parent) {
|
316 | folderAdd.call(this, parent);
|
317 | }
|
318 |
|
319 | o = prepareFileAttrs(o);
|
320 |
|
321 | if (o.dir || data === null || typeof data === "undefined") {
|
322 | o.base64 = false;
|
323 | o.binary = false;
|
324 | data = null;
|
325 | } else if (dataType === "string") {
|
326 | if (o.binary && !o.base64) {
|
327 |
|
328 | if (o.optimizedBinaryString !== true) {
|
329 |
|
330 |
|
331 | data = JSZip.utils.string2binary(data);
|
332 | }
|
333 | }
|
334 | } else {
|
335 | o.base64 = false;
|
336 | o.binary = true;
|
337 |
|
338 | if (!dataType && !(data instanceof JSZip.CompressedObject)) {
|
339 | throw new Error("The data of '" + name + "' is in an unsupported format !");
|
340 | }
|
341 |
|
342 |
|
343 | if (dataType === "arraybuffer") {
|
344 | data = JSZip.utils.transformTo("uint8array", data);
|
345 | }
|
346 | }
|
347 |
|
348 | var object = new ZipObject(name, data, o);
|
349 | this.files[name] = object;
|
350 | return object;
|
351 | };
|
352 |
|
353 |
|
354 | |
355 |
|
356 |
|
357 |
|
358 |
|
359 |
|
360 | var parentFolder = function (path) {
|
361 | if (path.slice(-1) == '/') {
|
362 | path = path.substring(0, path.length - 1);
|
363 | }
|
364 | var lastSlash = path.lastIndexOf('/');
|
365 | return (lastSlash > 0) ? path.substring(0, lastSlash) : "";
|
366 | };
|
367 |
|
368 | |
369 |
|
370 |
|
371 |
|
372 |
|
373 |
|
374 | var folderAdd = function (name) {
|
375 |
|
376 | if (name.slice(-1) != "/") {
|
377 | name += "/";
|
378 | }
|
379 |
|
380 |
|
381 | if (!this.files[name]) {
|
382 | fileAdd.call(this, name, null, {dir:true});
|
383 | }
|
384 | return this.files[name];
|
385 | };
|
386 |
|
387 | |
388 |
|
389 |
|
390 |
|
391 |
|
392 |
|
393 | var generateCompressedObjectFrom = function (file, compression) {
|
394 | var result = new JSZip.CompressedObject(), content;
|
395 |
|
396 |
|
397 | if (file._data instanceof JSZip.CompressedObject) {
|
398 | result.uncompressedSize = file._data.uncompressedSize;
|
399 | result.crc32 = file._data.crc32;
|
400 |
|
401 | if (result.uncompressedSize === 0 || file.options.dir) {
|
402 | compression = JSZip.compressions['STORE'];
|
403 | result.compressedContent = "";
|
404 | result.crc32 = 0;
|
405 | } else if (file._data.compressionMethod === compression.magic) {
|
406 | result.compressedContent = file._data.getCompressedContent();
|
407 | } else {
|
408 | content = file._data.getContent();
|
409 |
|
410 | result.compressedContent = compression.compress(JSZip.utils.transformTo(compression.compressInputType, content));
|
411 | }
|
412 | } else {
|
413 |
|
414 | content = getBinaryData(file);
|
415 | if (!content || content.length === 0 || file.options.dir) {
|
416 | compression = JSZip.compressions['STORE'];
|
417 | content = "";
|
418 | }
|
419 | result.uncompressedSize = content.length;
|
420 | result.crc32 = this.crc32(content);
|
421 | result.compressedContent = compression.compress(JSZip.utils.transformTo(compression.compressInputType, content));
|
422 | }
|
423 |
|
424 | result.compressedSize = result.compressedContent.length;
|
425 | result.compressionMethod = compression.magic;
|
426 |
|
427 | return result;
|
428 | };
|
429 |
|
430 | |
431 |
|
432 |
|
433 |
|
434 |
|
435 |
|
436 |
|
437 |
|
438 | var generateZipParts = function(name, file, compressedObject, offset) {
|
439 | var data = compressedObject.compressedContent,
|
440 | utfEncodedFileName = this.utf8encode(file.name),
|
441 | useUTF8 = utfEncodedFileName !== file.name,
|
442 | o = file.options,
|
443 | dosTime,
|
444 | dosDate;
|
445 |
|
446 |
|
447 |
|
448 |
|
449 |
|
450 |
|
451 | dosTime = o.date.getHours();
|
452 | dosTime = dosTime << 6;
|
453 | dosTime = dosTime | o.date.getMinutes();
|
454 | dosTime = dosTime << 5;
|
455 | dosTime = dosTime | o.date.getSeconds() / 2;
|
456 |
|
457 | dosDate = o.date.getFullYear() - 1980;
|
458 | dosDate = dosDate << 4;
|
459 | dosDate = dosDate | (o.date.getMonth() + 1);
|
460 | dosDate = dosDate << 5;
|
461 | dosDate = dosDate | o.date.getDate();
|
462 |
|
463 |
|
464 | var header = "";
|
465 |
|
466 |
|
467 | header += "\x0A\x00";
|
468 |
|
469 |
|
470 | header += useUTF8 ? "\x00\x08" : "\x00\x00";
|
471 |
|
472 | header += compressedObject.compressionMethod;
|
473 |
|
474 | header += decToHex(dosTime, 2);
|
475 |
|
476 | header += decToHex(dosDate, 2);
|
477 |
|
478 | header += decToHex(compressedObject.crc32, 4);
|
479 |
|
480 | header += decToHex(compressedObject.compressedSize, 4);
|
481 |
|
482 | header += decToHex(compressedObject.uncompressedSize, 4);
|
483 |
|
484 | header += decToHex(utfEncodedFileName.length, 2);
|
485 |
|
486 | header += "\x00\x00";
|
487 |
|
488 |
|
489 | var fileRecord = JSZip.signature.LOCAL_FILE_HEADER + header + utfEncodedFileName;
|
490 |
|
491 | var dirRecord = JSZip.signature.CENTRAL_FILE_HEADER +
|
492 |
|
493 | "\x14\x00" +
|
494 |
|
495 | header +
|
496 |
|
497 | "\x00\x00" +
|
498 |
|
499 | "\x00\x00" +
|
500 |
|
501 | "\x00\x00" +
|
502 |
|
503 | (file.options.dir===true?"\x10\x00\x00\x00":"\x00\x00\x00\x00")+
|
504 |
|
505 | decToHex(offset, 4) +
|
506 |
|
507 | utfEncodedFileName;
|
508 |
|
509 |
|
510 | return {
|
511 | fileRecord : fileRecord,
|
512 | dirRecord : dirRecord,
|
513 | compressedObject : compressedObject
|
514 | };
|
515 | };
|
516 |
|
517 | |
518 |
|
519 |
|
520 |
|
521 | var StringWriter = function () {
|
522 | this.data = [];
|
523 | };
|
524 | StringWriter.prototype = {
|
525 | |
526 |
|
527 |
|
528 |
|
529 | append : function (input) {
|
530 | input = JSZip.utils.transformTo("string", input);
|
531 | this.data.push(input);
|
532 | },
|
533 | |
534 |
|
535 |
|
536 |
|
537 | finalize : function () {
|
538 | return this.data.join("");
|
539 | }
|
540 | };
|
541 | |
542 |
|
543 |
|
544 |
|
545 |
|
546 | var Uint8ArrayWriter = function (length) {
|
547 | this.data = new Uint8Array(length);
|
548 | this.index = 0;
|
549 | };
|
550 | Uint8ArrayWriter.prototype = {
|
551 | |
552 |
|
553 |
|
554 |
|
555 | append : function (input) {
|
556 | if (input.length !== 0) {
|
557 |
|
558 | input = JSZip.utils.transformTo("uint8array", input);
|
559 | this.data.set(input, this.index);
|
560 | this.index += input.length;
|
561 | }
|
562 | },
|
563 | |
564 |
|
565 |
|
566 |
|
567 | finalize : function () {
|
568 | return this.data;
|
569 | }
|
570 | };
|
571 |
|
572 |
|
573 | return {
|
574 | |
575 |
|
576 |
|
577 |
|
578 |
|
579 |
|
580 |
|
581 |
|
582 | load : function (stream, options) {
|
583 | throw new Error("Load method is not defined. Is the file jszip-load.js included ?");
|
584 | },
|
585 |
|
586 | |
587 |
|
588 |
|
589 |
|
590 |
|
591 |
|
592 |
|
593 | filter : function (search) {
|
594 | var result = [], filename, relativePath, file, fileClone;
|
595 | for (filename in this.files) {
|
596 | if ( !this.files.hasOwnProperty(filename) ) { continue; }
|
597 | file = this.files[filename];
|
598 |
|
599 | fileClone = new ZipObject(file.name, file._data, extend(file.options));
|
600 | relativePath = filename.slice(this.root.length, filename.length);
|
601 | if (filename.slice(0, this.root.length) === this.root &&
|
602 | search(relativePath, fileClone)) {
|
603 | result.push(fileClone);
|
604 | }
|
605 | }
|
606 | return result;
|
607 | },
|
608 |
|
609 | |
610 |
|
611 |
|
612 |
|
613 |
|
614 |
|
615 |
|
616 |
|
617 |
|
618 | file : function(name, data, o) {
|
619 | if (arguments.length === 1) {
|
620 | if (JSZip.utils.isRegExp(name)) {
|
621 | var regexp = name;
|
622 | return this.filter(function(relativePath, file) {
|
623 | return !file.options.dir && regexp.test(relativePath);
|
624 | });
|
625 | } else {
|
626 | return this.filter(function (relativePath, file) {
|
627 | return !file.options.dir && relativePath === name;
|
628 | })[0]||null;
|
629 | }
|
630 | } else {
|
631 | name = this.root+name;
|
632 | fileAdd.call(this, name, data, o);
|
633 | }
|
634 | return this;
|
635 | },
|
636 |
|
637 | |
638 |
|
639 |
|
640 |
|
641 |
|
642 | folder : function(arg) {
|
643 | if (!arg) {
|
644 | return this;
|
645 | }
|
646 |
|
647 | if (JSZip.utils.isRegExp(arg)) {
|
648 | return this.filter(function(relativePath, file) {
|
649 | return file.options.dir && arg.test(relativePath);
|
650 | });
|
651 | }
|
652 |
|
653 |
|
654 | var name = this.root + arg;
|
655 | var newFolder = folderAdd.call(this, name);
|
656 |
|
657 |
|
658 | var ret = this.clone();
|
659 | ret.root = newFolder.name;
|
660 | return ret;
|
661 | },
|
662 |
|
663 | |
664 |
|
665 |
|
666 |
|
667 |
|
668 | remove : function(name) {
|
669 | name = this.root + name;
|
670 | var file = this.files[name];
|
671 | if (!file) {
|
672 |
|
673 | if (name.slice(-1) != "/") {
|
674 | name += "/";
|
675 | }
|
676 | file = this.files[name];
|
677 | }
|
678 |
|
679 | if (file) {
|
680 | if (!file.options.dir) {
|
681 |
|
682 | delete this.files[name];
|
683 | } else {
|
684 |
|
685 | var kids = this.filter(function (relativePath, file) {
|
686 | return file.name.slice(0, name.length) === name;
|
687 | });
|
688 | for (var i = 0; i < kids.length; i++) {
|
689 | delete this.files[kids[i].name];
|
690 | }
|
691 | }
|
692 | }
|
693 |
|
694 | return this;
|
695 | },
|
696 |
|
697 | |
698 |
|
699 |
|
700 |
|
701 |
|
702 |
|
703 |
|
704 |
|
705 | generate : function(options) {
|
706 | options = extend(options || {}, {
|
707 | base64 : true,
|
708 | compression : "STORE",
|
709 | type : "base64"
|
710 | });
|
711 |
|
712 | JSZip.utils.checkSupport(options.type);
|
713 |
|
714 | var zipData = [], localDirLength = 0, centralDirLength = 0, writer, i;
|
715 |
|
716 |
|
717 |
|
718 | for (var name in this.files) {
|
719 | if ( !this.files.hasOwnProperty(name) ) { continue; }
|
720 | var file = this.files[name];
|
721 |
|
722 | var compressionName = file.options.compression || options.compression.toUpperCase();
|
723 | var compression = JSZip.compressions[compressionName];
|
724 | if (!compression) {
|
725 | throw new Error(compressionName + " is not a valid compression method !");
|
726 | }
|
727 |
|
728 | var compressedObject = generateCompressedObjectFrom.call(this, file, compression);
|
729 |
|
730 | var zipPart = generateZipParts.call(this, name, file, compressedObject, localDirLength);
|
731 | localDirLength += zipPart.fileRecord.length + compressedObject.compressedSize;
|
732 | centralDirLength += zipPart.dirRecord.length;
|
733 | zipData.push(zipPart);
|
734 | }
|
735 |
|
736 | var dirEnd = "";
|
737 |
|
738 |
|
739 | dirEnd = JSZip.signature.CENTRAL_DIRECTORY_END +
|
740 |
|
741 | "\x00\x00" +
|
742 |
|
743 | "\x00\x00" +
|
744 |
|
745 | decToHex(zipData.length, 2) +
|
746 |
|
747 | decToHex(zipData.length, 2) +
|
748 |
|
749 | decToHex(centralDirLength, 4) +
|
750 |
|
751 | decToHex(localDirLength, 4) +
|
752 |
|
753 | "\x00\x00";
|
754 |
|
755 |
|
756 |
|
757 |
|
758 | switch(options.type.toLowerCase()) {
|
759 | case "uint8array" :
|
760 | case "arraybuffer" :
|
761 | case "blob" :
|
762 | case "nodebuffer" :
|
763 | writer = new Uint8ArrayWriter(localDirLength + centralDirLength + dirEnd.length);
|
764 | break;
|
765 |
|
766 |
|
767 | default :
|
768 | writer = new StringWriter(localDirLength + centralDirLength + dirEnd.length);
|
769 | break;
|
770 | }
|
771 |
|
772 | for (i = 0; i < zipData.length; i++) {
|
773 | writer.append(zipData[i].fileRecord);
|
774 | writer.append(zipData[i].compressedObject.compressedContent);
|
775 | }
|
776 | for (i = 0; i < zipData.length; i++) {
|
777 | writer.append(zipData[i].dirRecord);
|
778 | }
|
779 |
|
780 | writer.append(dirEnd);
|
781 |
|
782 | var zip = writer.finalize();
|
783 |
|
784 |
|
785 |
|
786 | switch(options.type.toLowerCase()) {
|
787 |
|
788 | case "uint8array" :
|
789 | case "arraybuffer" :
|
790 | case "nodebuffer" :
|
791 | return JSZip.utils.transformTo(options.type.toLowerCase(), zip);
|
792 | case "blob" :
|
793 | return JSZip.utils.arrayBuffer2Blob(JSZip.utils.transformTo("arraybuffer", zip));
|
794 |
|
795 |
|
796 | case "base64" :
|
797 | return (options.base64) ? JSZip.base64.encode(zip) : zip;
|
798 | default :
|
799 | return zip;
|
800 | }
|
801 | },
|
802 |
|
803 | |
804 |
|
805 |
|
806 |
|
807 |
|
808 |
|
809 | crc32 : function crc32(input, crc) {
|
810 | if (typeof input === "undefined" || !input.length) {
|
811 | return 0;
|
812 | }
|
813 |
|
814 | var isArray = JSZip.utils.getTypeOf(input) !== "string";
|
815 |
|
816 | var table = [
|
817 | 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA,
|
818 | 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,
|
819 | 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,
|
820 | 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,
|
821 | 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE,
|
822 | 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
|
823 | 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC,
|
824 | 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,
|
825 | 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172,
|
826 | 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,
|
827 | 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940,
|
828 | 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
|
829 | 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116,
|
830 | 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,
|
831 | 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924,
|
832 | 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
|
833 | 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A,
|
834 | 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
|
835 | 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818,
|
836 | 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,
|
837 | 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E,
|
838 | 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,
|
839 | 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C,
|
840 | 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
|
841 | 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2,
|
842 | 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,
|
843 | 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0,
|
844 | 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,
|
845 | 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086,
|
846 | 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
|
847 | 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4,
|
848 | 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
|
849 | 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A,
|
850 | 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,
|
851 | 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8,
|
852 | 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
|
853 | 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE,
|
854 | 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,
|
855 | 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC,
|
856 | 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,
|
857 | 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252,
|
858 | 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
|
859 | 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60,
|
860 | 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,
|
861 | 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236,
|
862 | 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,
|
863 | 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04,
|
864 | 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
|
865 | 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A,
|
866 | 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,
|
867 | 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38,
|
868 | 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,
|
869 | 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E,
|
870 | 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
|
871 | 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C,
|
872 | 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,
|
873 | 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2,
|
874 | 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,
|
875 | 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0,
|
876 | 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
|
877 | 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6,
|
878 | 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,
|
879 | 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
|
880 | 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
|
881 | ];
|
882 |
|
883 | if (typeof(crc) == "undefined") { crc = 0; }
|
884 | var x = 0;
|
885 | var y = 0;
|
886 | var byte = 0;
|
887 |
|
888 | crc = crc ^ (-1);
|
889 | for( var i = 0, iTop = input.length; i < iTop; i++ ) {
|
890 | byte = isArray ? input[i] : input.charCodeAt(i);
|
891 | y = ( crc ^ byte ) & 0xFF;
|
892 | x = table[y];
|
893 | crc = ( crc >>> 8 ) ^ x;
|
894 | }
|
895 |
|
896 | return crc ^ (-1);
|
897 | },
|
898 |
|
899 |
|
900 | clone : function() {
|
901 | var newObj = new JSZip();
|
902 | for (var i in this) {
|
903 | if (typeof this[i] !== "function") {
|
904 | newObj[i] = this[i];
|
905 | }
|
906 | }
|
907 | return newObj;
|
908 | },
|
909 |
|
910 |
|
911 | |
912 |
|
913 |
|
914 | utf8encode : function (string) {
|
915 |
|
916 |
|
917 |
|
918 | if (textEncoder) {
|
919 | var u8 = textEncoder.encode(string);
|
920 | return JSZip.utils.transformTo("string", u8);
|
921 | }
|
922 | if (JSZip.support.nodebuffer) {
|
923 | return JSZip.utils.transformTo("string", new Buffer(string, "utf-8"));
|
924 | }
|
925 |
|
926 |
|
927 |
|
928 | var result = [], resIndex = 0;
|
929 |
|
930 | for (var n = 0; n < string.length; n++) {
|
931 |
|
932 | var c = string.charCodeAt(n);
|
933 |
|
934 | if (c < 128) {
|
935 | result[resIndex++] = String.fromCharCode(c);
|
936 | } else if ((c > 127) && (c < 2048)) {
|
937 | result[resIndex++] = String.fromCharCode((c >> 6) | 192);
|
938 | result[resIndex++] = String.fromCharCode((c & 63) | 128);
|
939 | } else {
|
940 | result[resIndex++] = String.fromCharCode((c >> 12) | 224);
|
941 | result[resIndex++] = String.fromCharCode(((c >> 6) & 63) | 128);
|
942 | result[resIndex++] = String.fromCharCode((c & 63) | 128);
|
943 | }
|
944 |
|
945 | }
|
946 |
|
947 | return result.join("");
|
948 | },
|
949 |
|
950 | |
951 |
|
952 |
|
953 | utf8decode : function (input) {
|
954 | var result = [], resIndex = 0;
|
955 | var type = JSZip.utils.getTypeOf(input);
|
956 | var isArray = type !== "string";
|
957 | var i = 0;
|
958 | var c = 0, c1 = 0, c2 = 0, c3 = 0;
|
959 |
|
960 |
|
961 |
|
962 | if (textDecoder) {
|
963 | return textDecoder.decode(
|
964 | JSZip.utils.transformTo("uint8array", input)
|
965 | );
|
966 | }
|
967 | if (JSZip.support.nodebuffer) {
|
968 | return JSZip.utils.transformTo("nodebuffer", input).toString("utf-8");
|
969 | }
|
970 |
|
971 | while ( i < input.length ) {
|
972 |
|
973 | c = isArray ? input[i] : input.charCodeAt(i);
|
974 |
|
975 | if (c < 128) {
|
976 | result[resIndex++] = String.fromCharCode(c);
|
977 | i++;
|
978 | } else if ((c > 191) && (c < 224)) {
|
979 | c2 = isArray ? input[i+1] : input.charCodeAt(i+1);
|
980 | result[resIndex++] = String.fromCharCode(((c & 31) << 6) | (c2 & 63));
|
981 | i += 2;
|
982 | } else {
|
983 | c2 = isArray ? input[i+1] : input.charCodeAt(i+1);
|
984 | c3 = isArray ? input[i+2] : input.charCodeAt(i+2);
|
985 | result[resIndex++] = String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
|
986 | i += 3;
|
987 | }
|
988 |
|
989 | }
|
990 |
|
991 | return result.join("");
|
992 | }
|
993 | };
|
994 | }());
|
995 |
|
996 |
|
997 |
|
998 |
|
999 |
|
1000 |
|
1001 |
|
1002 |
|
1003 |
|
1004 |
|
1005 |
|
1006 |
|
1007 |
|
1008 |
|
1009 |
|
1010 | JSZip.compressions = {
|
1011 | "STORE" : {
|
1012 | magic : "\x00\x00",
|
1013 | compress : function (content) {
|
1014 | return content;
|
1015 | },
|
1016 | uncompress : function (content) {
|
1017 | return content;
|
1018 | },
|
1019 | compressInputType : null,
|
1020 | uncompressInputType : null
|
1021 | }
|
1022 | };
|
1023 |
|
1024 | (function () {
|
1025 | JSZip.utils = {
|
1026 | |
1027 |
|
1028 |
|
1029 |
|
1030 |
|
1031 | string2binary : function (str) {
|
1032 | var result = "";
|
1033 | for (var i = 0; i < str.length; i++) {
|
1034 | result += String.fromCharCode(str.charCodeAt(i) & 0xff);
|
1035 | }
|
1036 | return result;
|
1037 | },
|
1038 | |
1039 |
|
1040 |
|
1041 |
|
1042 |
|
1043 |
|
1044 |
|
1045 | string2Uint8Array : function (str) {
|
1046 | return JSZip.utils.transformTo("uint8array", str);
|
1047 | },
|
1048 |
|
1049 | |
1050 |
|
1051 |
|
1052 |
|
1053 |
|
1054 |
|
1055 |
|
1056 | uint8Array2String : function (array) {
|
1057 | return JSZip.utils.transformTo("string", array);
|
1058 | },
|
1059 | |
1060 |
|
1061 |
|
1062 |
|
1063 |
|
1064 |
|
1065 | arrayBuffer2Blob : function (buffer) {
|
1066 | JSZip.utils.checkSupport("blob");
|
1067 |
|
1068 | try {
|
1069 |
|
1070 | return new Blob([buffer], { type: "application/zip" });
|
1071 | }
|
1072 | catch(e) {}
|
1073 |
|
1074 | try {
|
1075 |
|
1076 | var BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder || window.MSBlobBuilder;
|
1077 | var builder = new BlobBuilder();
|
1078 | builder.append(buffer);
|
1079 | return builder.getBlob('application/zip');
|
1080 | }
|
1081 | catch(e) {}
|
1082 |
|
1083 |
|
1084 | throw new Error("Bug : can't construct the Blob.");
|
1085 | },
|
1086 | |
1087 |
|
1088 |
|
1089 |
|
1090 |
|
1091 |
|
1092 | string2Blob : function (str) {
|
1093 | var buffer = JSZip.utils.transformTo("arraybuffer", str);
|
1094 | return JSZip.utils.arrayBuffer2Blob(buffer);
|
1095 | }
|
1096 | };
|
1097 |
|
1098 | |
1099 |
|
1100 |
|
1101 |
|
1102 |
|
1103 | function identity(input) {
|
1104 | return input;
|
1105 | }
|
1106 |
|
1107 | |
1108 |
|
1109 |
|
1110 |
|
1111 |
|
1112 |
|
1113 | function stringToArrayLike(str, array) {
|
1114 | for (var i = 0; i < str.length; ++i) {
|
1115 | array[i] = str.charCodeAt(i) & 0xFF;
|
1116 | }
|
1117 | return array;
|
1118 | }
|
1119 |
|
1120 | |
1121 |
|
1122 |
|
1123 |
|
1124 |
|
1125 | function arrayLikeToString(array) {
|
1126 |
|
1127 |
|
1128 |
|
1129 |
|
1130 |
|
1131 |
|
1132 |
|
1133 |
|
1134 |
|
1135 | var chunk = 65536;
|
1136 | var result = [], len = array.length, type = JSZip.utils.getTypeOf(array), k = 0;
|
1137 |
|
1138 | var canUseApply = true;
|
1139 | try {
|
1140 | switch(type) {
|
1141 | case "uint8array":
|
1142 | String.fromCharCode.apply(null, new Uint8Array(0));
|
1143 | break;
|
1144 | case "nodebuffer":
|
1145 | String.fromCharCode.apply(null, new Buffer(0));
|
1146 | break;
|
1147 | }
|
1148 | } catch(e) {
|
1149 | canUseApply = false;
|
1150 | }
|
1151 |
|
1152 |
|
1153 |
|
1154 | if (!canUseApply) {
|
1155 | var resultStr = "";
|
1156 | for(var i = 0; i < array.length;i++) {
|
1157 | resultStr += String.fromCharCode(array[i]);
|
1158 | }
|
1159 | return resultStr;
|
1160 | }
|
1161 |
|
1162 | while (k < len && chunk > 1) {
|
1163 | try {
|
1164 | if (type === "array" || type === "nodebuffer") {
|
1165 | result.push(String.fromCharCode.apply(null, array.slice(k, Math.min(k + chunk, len))));
|
1166 | } else {
|
1167 | result.push(String.fromCharCode.apply(null, array.subarray(k, Math.min(k + chunk, len))));
|
1168 | }
|
1169 | k += chunk;
|
1170 | } catch (e) {
|
1171 | chunk = Math.floor(chunk / 2);
|
1172 | }
|
1173 | }
|
1174 | return result.join("");
|
1175 | }
|
1176 |
|
1177 | |
1178 |
|
1179 |
|
1180 |
|
1181 |
|
1182 |
|
1183 | function arrayLikeToArrayLike(arrayFrom, arrayTo) {
|
1184 | for(var i = 0; i < arrayFrom.length; i++) {
|
1185 | arrayTo[i] = arrayFrom[i];
|
1186 | }
|
1187 | return arrayTo;
|
1188 | }
|
1189 |
|
1190 |
|
1191 | var transform = {};
|
1192 |
|
1193 |
|
1194 | transform["string"] = {
|
1195 | "string" : identity,
|
1196 | "array" : function (input) {
|
1197 | return stringToArrayLike(input, new Array(input.length));
|
1198 | },
|
1199 | "arraybuffer" : function (input) {
|
1200 | return transform["string"]["uint8array"](input).buffer;
|
1201 | },
|
1202 | "uint8array" : function (input) {
|
1203 | return stringToArrayLike(input, new Uint8Array(input.length));
|
1204 | },
|
1205 | "nodebuffer" : function (input) {
|
1206 | return stringToArrayLike(input, new Buffer(input.length));
|
1207 | }
|
1208 | };
|
1209 |
|
1210 |
|
1211 | transform["array"] = {
|
1212 | "string" : arrayLikeToString,
|
1213 | "array" : identity,
|
1214 | "arraybuffer" : function (input) {
|
1215 | return (new Uint8Array(input)).buffer;
|
1216 | },
|
1217 | "uint8array" : function (input) {
|
1218 | return new Uint8Array(input);
|
1219 | },
|
1220 | "nodebuffer" : function (input) {
|
1221 | return new Buffer(input);
|
1222 | }
|
1223 | };
|
1224 |
|
1225 |
|
1226 | transform["arraybuffer"] = {
|
1227 | "string" : function (input) {
|
1228 | return arrayLikeToString(new Uint8Array(input));
|
1229 | },
|
1230 | "array" : function (input) {
|
1231 | return arrayLikeToArrayLike(new Uint8Array(input), new Array(input.byteLength));
|
1232 | },
|
1233 | "arraybuffer" : identity,
|
1234 | "uint8array" : function (input) {
|
1235 | return new Uint8Array(input);
|
1236 | },
|
1237 | "nodebuffer" : function (input) {
|
1238 | return new Buffer(new Uint8Array(input));
|
1239 | }
|
1240 | };
|
1241 |
|
1242 |
|
1243 | transform["uint8array"] = {
|
1244 | "string" : arrayLikeToString,
|
1245 | "array" : function (input) {
|
1246 | return arrayLikeToArrayLike(input, new Array(input.length));
|
1247 | },
|
1248 | "arraybuffer" : function (input) {
|
1249 | return input.buffer;
|
1250 | },
|
1251 | "uint8array" : identity,
|
1252 | "nodebuffer" : function(input) {
|
1253 | return new Buffer(input);
|
1254 | }
|
1255 | };
|
1256 |
|
1257 |
|
1258 | transform["nodebuffer"] = {
|
1259 | "string" : arrayLikeToString,
|
1260 | "array" : function (input) {
|
1261 | return arrayLikeToArrayLike(input, new Array(input.length));
|
1262 | },
|
1263 | "arraybuffer" : function (input) {
|
1264 | return transform["nodebuffer"]["uint8array"](input).buffer;
|
1265 | },
|
1266 | "uint8array" : function (input) {
|
1267 | return arrayLikeToArrayLike(input, new Uint8Array(input.length));
|
1268 | },
|
1269 | "nodebuffer" : identity
|
1270 | };
|
1271 |
|
1272 | |
1273 |
|
1274 |
|
1275 |
|
1276 |
|
1277 |
|
1278 |
|
1279 |
|
1280 | JSZip.utils.transformTo = function (outputType, input) {
|
1281 | if (!input) {
|
1282 |
|
1283 |
|
1284 | input = "";
|
1285 | }
|
1286 | if (!outputType) {
|
1287 | return input;
|
1288 | }
|
1289 | JSZip.utils.checkSupport(outputType);
|
1290 | var inputType = JSZip.utils.getTypeOf(input);
|
1291 | var result = transform[inputType][outputType](input);
|
1292 | return result;
|
1293 | };
|
1294 |
|
1295 | |
1296 |
|
1297 |
|
1298 |
|
1299 |
|
1300 |
|
1301 | JSZip.utils.getTypeOf = function (input) {
|
1302 | if (typeof input === "string") {
|
1303 | return "string";
|
1304 | }
|
1305 | if (Object.prototype.toString.call(input) === "[object Array]") {
|
1306 | return "array";
|
1307 | }
|
1308 | if (JSZip.support.nodebuffer && Buffer.isBuffer(input)) {
|
1309 | return "nodebuffer";
|
1310 | }
|
1311 | if (JSZip.support.uint8array && input instanceof Uint8Array) {
|
1312 | return "uint8array";
|
1313 | }
|
1314 | if (JSZip.support.arraybuffer && input instanceof ArrayBuffer) {
|
1315 | return "arraybuffer";
|
1316 | }
|
1317 | };
|
1318 |
|
1319 | |
1320 |
|
1321 |
|
1322 |
|
1323 |
|
1324 |
|
1325 | JSZip.utils.isRegExp = function (object) {
|
1326 | return Object.prototype.toString.call(object) === "[object RegExp]";
|
1327 | };
|
1328 |
|
1329 | |
1330 |
|
1331 |
|
1332 |
|
1333 |
|
1334 | JSZip.utils.checkSupport = function (type) {
|
1335 | var supported = true;
|
1336 | switch (type.toLowerCase()) {
|
1337 | case "uint8array":
|
1338 | supported = JSZip.support.uint8array;
|
1339 | break;
|
1340 | case "arraybuffer":
|
1341 | supported = JSZip.support.arraybuffer;
|
1342 | break;
|
1343 | case "nodebuffer":
|
1344 | supported = JSZip.support.nodebuffer;
|
1345 | break;
|
1346 | case "blob":
|
1347 | supported = JSZip.support.blob;
|
1348 | break;
|
1349 | }
|
1350 | if (!supported) {
|
1351 | throw new Error(type + " is not supported by this browser");
|
1352 | }
|
1353 | };
|
1354 |
|
1355 |
|
1356 | })();
|
1357 |
|
1358 | (function (){
|
1359 | |
1360 |
|
1361 |
|
1362 |
|
1363 |
|
1364 | JSZip.CompressedObject = function () {
|
1365 | this.compressedSize = 0;
|
1366 | this.uncompressedSize = 0;
|
1367 | this.crc32 = 0;
|
1368 | this.compressionMethod = null;
|
1369 | this.compressedContent = null;
|
1370 | };
|
1371 |
|
1372 | JSZip.CompressedObject.prototype = {
|
1373 | |
1374 |
|
1375 |
|
1376 |
|
1377 |
|
1378 | getContent : function () {
|
1379 | return null;
|
1380 | },
|
1381 | |
1382 |
|
1383 |
|
1384 |
|
1385 |
|
1386 | getCompressedContent : function () {
|
1387 | return null;
|
1388 | }
|
1389 | };
|
1390 | })();
|
1391 |
|
1392 |
|
1393 |
|
1394 |
|
1395 |
|
1396 |
|
1397 |
|
1398 |
|
1399 | JSZip.base64 = (function() {
|
1400 |
|
1401 | var _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
1402 |
|
1403 | return {
|
1404 |
|
1405 | encode : function(input, utf8) {
|
1406 | var output = "";
|
1407 | var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
|
1408 | var i = 0;
|
1409 |
|
1410 | while (i < input.length) {
|
1411 |
|
1412 | chr1 = input.charCodeAt(i++);
|
1413 | chr2 = input.charCodeAt(i++);
|
1414 | chr3 = input.charCodeAt(i++);
|
1415 |
|
1416 | enc1 = chr1 >> 2;
|
1417 | enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
|
1418 | enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
|
1419 | enc4 = chr3 & 63;
|
1420 |
|
1421 | if (isNaN(chr2)) {
|
1422 | enc3 = enc4 = 64;
|
1423 | } else if (isNaN(chr3)) {
|
1424 | enc4 = 64;
|
1425 | }
|
1426 |
|
1427 | output = output +
|
1428 | _keyStr.charAt(enc1) + _keyStr.charAt(enc2) +
|
1429 | _keyStr.charAt(enc3) + _keyStr.charAt(enc4);
|
1430 |
|
1431 | }
|
1432 |
|
1433 | return output;
|
1434 | },
|
1435 |
|
1436 |
|
1437 | decode : function(input, utf8) {
|
1438 | var output = "";
|
1439 | var chr1, chr2, chr3;
|
1440 | var enc1, enc2, enc3, enc4;
|
1441 | var i = 0;
|
1442 |
|
1443 | input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
|
1444 |
|
1445 | while (i < input.length) {
|
1446 |
|
1447 | enc1 = _keyStr.indexOf(input.charAt(i++));
|
1448 | enc2 = _keyStr.indexOf(input.charAt(i++));
|
1449 | enc3 = _keyStr.indexOf(input.charAt(i++));
|
1450 | enc4 = _keyStr.indexOf(input.charAt(i++));
|
1451 |
|
1452 | chr1 = (enc1 << 2) | (enc2 >> 4);
|
1453 | chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
|
1454 | chr3 = ((enc3 & 3) << 6) | enc4;
|
1455 |
|
1456 | output = output + String.fromCharCode(chr1);
|
1457 |
|
1458 | if (enc3 != 64) {
|
1459 | output = output + String.fromCharCode(chr2);
|
1460 | }
|
1461 | if (enc4 != 64) {
|
1462 | output = output + String.fromCharCode(chr3);
|
1463 | }
|
1464 |
|
1465 | }
|
1466 |
|
1467 | return output;
|
1468 |
|
1469 | }
|
1470 | };
|
1471 | }());
|
1472 |
|
1473 |
|
1474 |
|