PageSourceSearch

https://collectie.hetnoordbrabantsmuseum.nl/Scripts/External/jszip/jszip-utils.js?v=1

js hetnoordbrabantsmuseum.nl collected 2026-10-02 04:27:14 UTC 5,964 bytes, 160 lines download raw bytes

vendor: 5,964 bytes, lines 1-160
1/*@preserve
2
3JSZipUtils - A collection of cross-browser utilities to go along with JSZip.
4<http://stuk.github.io/jszip-utils>
5
6(c) 2014-2019 Stuart Knightley, David Duponchel
7Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip-utils/master/LICENSE.markdown.
8
9*/
10!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){
11'use strict';
12/*globals Promise */
13
14var JSZipUtils = {};
15// just use the responseText with xhr1, response with xhr2.
16// The transformation doesn't throw away high-order byte (with responseText)
17// because JSZip handles that case. If not used with JSZip, you may need to
18// do it, see https://developer.mozilla.org/En/Using_XMLHttpRequest#Handling_binary_data
19JSZipUtils._getBinaryFromXHR = function (xhr) {
20    // for xhr.responseText, the 0xFF mask is applied by JSZip
21    return xhr.response || xhr.responseText;
22};
23
24// taken from jQuery
25function createStandardXHR() {
26    try {
27        return new window.XMLHttpRequest();
28    } catch( e ) {}
29}
30
31function createActiveXHR() {
32    try {
33        return new window.ActiveXObject("Microsoft.XMLHTTP");
34    } catch( e ) {}
35}
36
37// Create the request object
38var createXHR = (typeof window !== "undefined" && window.ActiveXObject) ?
39    /* Microsoft failed to properly
40     * implement the XMLHttpRequest in IE7 (can't request local files),
41     * so we use the ActiveXObject when it is available
42     * Additionally XMLHttpRequest can be disabled in IE7/IE8 so
43     * we need a fallback.
44     */
45    function() {
46    return createStandardXHR() || createActiveXHR();
47} :
48    // For all other browsers, use the standard XMLHttpRequest object
49    createStandardXHR;
50
51
52/**
53 * @param  {string} path    The path to the resource to GET.
54 * @param  {function|{callback: function, progress: function}} options
55 * @return {Promise|undefined} If no callback is passed then a promise is returned
56 */
57JSZipUtils.getBinaryContent = function (path, options) {
58    var promise, resolve, reject;
59    var callback;
60
61    if (!options) {
62        options = {};
63    }
64
65    // backward compatible callback
66    if (typeof options === "function") {
67        callback = options;
68        options = {};
69    } else if (typeof options.callback === 'function') {
70        // callback inside options object
71        callback = options.callback;
72    }
73
74    if (!callback && typeof Promise !== "undefined") {
75        promise = new Promise(function (_resolve, _reject) {
76            resolve = _resolve;
77            reject = _reject;
78        });
79    } else {
80        resolve = function (data) { callback(null, data); };
81        reject = function (err) { callback(err, null); };
82    }
83
84    /*
85     * Here is the tricky part : getting the data.
86     * In firefox/chrome/opera/... setting the mimeType to 'text/plain; charset=x-user-defined'
87     * is enough, the result is in the standard xhr.responseText.
88     * cf https://developer.mozilla.org/En/XMLHttpRequest/Using_XMLHttpRequest#Receiving_binary_data_in_older_browsers
89     * In IE <= 9, we must use (the IE only) attribute responseBody
90     * (for binary data, its content is different from responseText).
91     * In IE 10, the 'charset=x-user-defined' trick doesn't work, only the
92     * responseType will work :
93     * http://msdn.microsoft.com/en-us/library/ie/hh673569%28v=vs.85%29.aspx#Binary_Object_upload_and_download
94     *
95     * I'd like to use jQuery to avoid this XHR madness, but it doesn't support
96     * the responseType attribute : http://bugs.jquery.com/ticket/11461
97     */
98    try {
99        var xhr = createXHR();
100
101        xhr.open('GET', path, true);
102
103        // recent browsers
104        if ("responseType" in xhr) {
105            xhr.responseType = "arraybuffer";
106        }
107
108        // older browser
109        if(xhr.overrideMimeType) {
110            xhr.overrideMimeType("text/plain; charset=x-user-defined");
111        }
112
113        xhr.onreadystatechange = function (event) {
114            // use `xhr` and not `this`... thanks IE
115            if (xhr.readyState === 4) {
116                if (xhr.status === 200 || xhr.status === 0) {
117                    try {
118                        resolve(JSZipUtils._getBinaryFromXHR(xhr));
119                    } catch(err) {
120                        reject(new Error(err));
121                    }
122                } else {
123                    reject(new Error("Ajax error for " + path + " : " + this.status + " " + this.statusText));
124                }
125            }
126        };
127
128        if(options.progress) {
129            xhr.onprogress = function(e) {
130                options.progress({
131                    path: path,
132                    originalEvent: e,
133                    percent: e.loaded / e.total * 100,
134                    loaded: e.loaded,
135                    total: e.total
136                });
137            };
138        }
139
140        xhr.send();
141
142    } catch (e) {
143        reject(new Error(e), null);
144    }
145
146    // returns a promise or undefined depending on whether a callback was
147    // provided
148    return promise;
149};
150
151// export
152module.exports = JSZipUtils;
153
154// enforcing Stuk's coding style
155// vim: set shiftwidth=4 softtabstop=4:
156
157},{}]},{},[1])
158(1)
159});
160;

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.