123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- !function (e) {
- "object" == typeof exports ? module.exports = e() : "function" == typeof define && define.amd ? define(e) : "undefined" != typeof window ? window.JSZipUtils = e() : "undefined" != typeof global ? global.JSZipUtils = e() : "undefined" != typeof self && (self.JSZipUtils = 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 (require, module, exports) {
- var JSZipUtils = {};
- JSZipUtils._getBinaryFromXHR = function (xhr) {
- return xhr.response || xhr.responseText
- };
- function createStandardXHR() {
- try {
- return new window.XMLHttpRequest()
- } catch (e) {
- }
- }
- function createActiveXHR() {
- try {
- return new window.ActiveXObject("Microsoft.XMLHTTP")
- } catch (e) {
- }
- }
- var createXHR = (typeof window !== "undefined" && window.ActiveXObject) ? function () {
- return createStandardXHR() || createActiveXHR()
- } : createStandardXHR;
- JSZipUtils.getBinaryContent = function (path, options) {
- var promise, resolve, reject;
- var callback;
- if (!options) {
- options = {}
- }
- if (typeof options === "function") {
- callback = options;
- options = {}
- } else {
- if (typeof options.callback === "function") {
- callback = options.callback
- }
- }
- if (!callback && typeof Promise !== "undefined") {
- promise = new Promise(function (_resolve, _reject) {
- resolve = _resolve;
- reject = _reject
- })
- } else {
- resolve = function (data) {
- callback(null, data)
- };
- reject = function (err) {
- callback(err, null)
- }
- }
- try {
- var xhr = createXHR();
- xhr.open("GET", path, true);
- if ("responseType" in xhr) {
- xhr.responseType = "arraybuffer"
- }
- if (xhr.overrideMimeType) {
- xhr.overrideMimeType("text/plain; charset=x-user-defined")
- }
- xhr.onreadystatechange = function (event) {
- if (xhr.readyState === 4) {
- if (xhr.status === 200 || xhr.status === 0) {
- try {
- resolve(JSZipUtils._getBinaryFromXHR(xhr))
- } catch (err) {
- reject(new Error(err))
- }
- } else {
- reject(new Error("Ajax error for " + path + " : " + this.status + " " + this.statusText))
- }
- }
- };
- if (options.progress) {
- xhr.onprogress = function (e) {
- options.progress({
- path: path,
- originalEvent: e,
- percent: e.loaded / e.total * 100,
- loaded: e.loaded,
- total: e.total
- })
- }
- }
- xhr.withCredentials = true;
- xhr.send()
- } catch (e) {
- reject(new Error(e), null)
- }
- return promise
- };
- module.exports = JSZipUtils
- }, {}]
- }, {}, [1])(1)
- });
|