|
|
@ -167,35 +167,49 @@ if (typeof PDFJS === 'undefined') { |
|
|
|
// The worker will be using XHR, so we can save time and disable worker.
|
|
|
|
// The worker will be using XHR, so we can save time and disable worker.
|
|
|
|
PDFJS.disableWorker = true; |
|
|
|
PDFJS.disableWorker = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object.defineProperty(xhrPrototype, 'responseType', { |
|
|
|
|
|
|
|
get: function xmlHttpRequestGetResponseType() { |
|
|
|
|
|
|
|
return this._responseType || 'text'; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
set: function xmlHttpRequestSetResponseType(value) { |
|
|
|
|
|
|
|
if (value === 'text' || value === 'arraybuffer') { |
|
|
|
|
|
|
|
this._responseType = value; |
|
|
|
|
|
|
|
if (value === 'arraybuffer' && |
|
|
|
|
|
|
|
typeof this.overrideMimeType === 'function') { |
|
|
|
|
|
|
|
this.overrideMimeType('text/plain; charset=x-user-defined'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// Support: IE9
|
|
|
|
// Support: IE9
|
|
|
|
if (typeof VBArray !== 'undefined') { |
|
|
|
if (typeof VBArray !== 'undefined') { |
|
|
|
Object.defineProperty(xhrPrototype, 'response', { |
|
|
|
Object.defineProperty(xhrPrototype, 'response', { |
|
|
|
get: function xmlHttpRequestResponseGet() { |
|
|
|
get: function xmlHttpRequestResponseGet() { |
|
|
|
return new Uint8Array(new VBArray(this.responseBody).toArray()); |
|
|
|
if (this.responseType === 'arraybuffer') { |
|
|
|
|
|
|
|
return new Uint8Array(new VBArray(this.responseBody).toArray()); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return this.responseText; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// other browsers
|
|
|
|
Object.defineProperty(xhrPrototype, 'response', { |
|
|
|
function responseTypeSetter() { |
|
|
|
get: function xmlHttpRequestResponseGet() { |
|
|
|
// will be only called to set "arraybuffer"
|
|
|
|
if (this.responseType !== 'arraybuffer') { |
|
|
|
this.overrideMimeType('text/plain; charset=x-user-defined'); |
|
|
|
return this.responseText; |
|
|
|
} |
|
|
|
} |
|
|
|
if (typeof xhr.overrideMimeType === 'function') { |
|
|
|
var text = this.responseText; |
|
|
|
Object.defineProperty(xhrPrototype, 'responseType', |
|
|
|
var i, n = text.length; |
|
|
|
{ set: responseTypeSetter }); |
|
|
|
var result = new Uint8Array(n); |
|
|
|
} |
|
|
|
for (i = 0; i < n; ++i) { |
|
|
|
function responseGetter() { |
|
|
|
result[i] = text.charCodeAt(i) & 0xFF; |
|
|
|
var text = this.responseText; |
|
|
|
} |
|
|
|
var i, n = text.length; |
|
|
|
return result.buffer; |
|
|
|
var result = new Uint8Array(n); |
|
|
|
|
|
|
|
for (i = 0; i < n; ++i) { |
|
|
|
|
|
|
|
result[i] = text.charCodeAt(i) & 0xFF; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return result.buffer; |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
Object.defineProperty(xhrPrototype, 'response', { get: responseGetter }); |
|
|
|
|
|
|
|
})(); |
|
|
|
})(); |
|
|
|
|
|
|
|
|
|
|
|
// window.btoa (base64 encode function) ?
|
|
|
|
// window.btoa (base64 encode function) ?
|
|
|
@ -237,7 +251,7 @@ if (typeof PDFJS === 'undefined') { |
|
|
|
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; |
|
|
|
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; |
|
|
|
window.atob = function (input) { |
|
|
|
window.atob = function (input) { |
|
|
|
input = input.replace(/=+$/, ''); |
|
|
|
input = input.replace(/=+$/, ''); |
|
|
|
if (input.length % 4 == 1) { |
|
|
|
if (input.length % 4 === 1) { |
|
|
|
throw new Error('bad atob input'); |
|
|
|
throw new Error('bad atob input'); |
|
|
|
} |
|
|
|
} |
|
|
|
for ( |
|
|
|
for ( |
|
|
@ -293,7 +307,7 @@ if (typeof PDFJS === 'undefined') { |
|
|
|
var dataset = {}; |
|
|
|
var dataset = {}; |
|
|
|
for (var j = 0, jj = this.attributes.length; j < jj; j++) { |
|
|
|
for (var j = 0, jj = this.attributes.length; j < jj; j++) { |
|
|
|
var attribute = this.attributes[j]; |
|
|
|
var attribute = this.attributes[j]; |
|
|
|
if (attribute.name.substring(0, 5) != 'data-') { |
|
|
|
if (attribute.name.substring(0, 5) !== 'data-') { |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
var key = attribute.name.substring(5).replace(/\-([a-z])/g, |
|
|
|
var key = attribute.name.substring(5).replace(/\-([a-z])/g, |
|
|
@ -416,7 +430,7 @@ if (typeof PDFJS === 'undefined') { |
|
|
|
function isDisabled(node) { |
|
|
|
function isDisabled(node) { |
|
|
|
return node.disabled || (node.parentNode && isDisabled(node.parentNode)); |
|
|
|
return node.disabled || (node.parentNode && isDisabled(node.parentNode)); |
|
|
|
} |
|
|
|
} |
|
|
|
if (navigator.userAgent.indexOf('Opera') != -1) { |
|
|
|
if (navigator.userAgent.indexOf('Opera') !== -1) { |
|
|
|
// use browser detection since we cannot feature-check this bug
|
|
|
|
// use browser detection since we cannot feature-check this bug
|
|
|
|
document.addEventListener('click', ignoreIfTargetDisabled, true); |
|
|
|
document.addEventListener('click', ignoreIfTargetDisabled, true); |
|
|
|
} |
|
|
|
} |
|
|
@ -467,6 +481,7 @@ if (typeof PDFJS === 'undefined') { |
|
|
|
|
|
|
|
|
|
|
|
if (isSafari || isOldAndroid) { |
|
|
|
if (isSafari || isOldAndroid) { |
|
|
|
PDFJS.disableRange = true; |
|
|
|
PDFJS.disableRange = true; |
|
|
|
|
|
|
|
PDFJS.disableStream = true; |
|
|
|
} |
|
|
|
} |
|
|
|
})(); |
|
|
|
})(); |
|
|
|
|
|
|
|
|
|
|
@ -481,7 +496,7 @@ if (typeof PDFJS === 'undefined') { |
|
|
|
} |
|
|
|
} |
|
|
|
})(); |
|
|
|
})(); |
|
|
|
|
|
|
|
|
|
|
|
// Support: IE<11, Chrome<21, Android<4.4
|
|
|
|
// Support: IE<11, Chrome<21, Android<4.4, Safari<6
|
|
|
|
(function checkSetPresenceInImageData() { |
|
|
|
(function checkSetPresenceInImageData() { |
|
|
|
// IE < 11 will use window.CanvasPixelArray which lacks set function.
|
|
|
|
// IE < 11 will use window.CanvasPixelArray which lacks set function.
|
|
|
|
if (window.CanvasPixelArray) { |
|
|
|
if (window.CanvasPixelArray) { |
|
|
@ -495,21 +510,21 @@ if (typeof PDFJS === 'undefined') { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// Old Chrome and Android use an inaccessible CanvasPixelArray prototype.
|
|
|
|
// Old Chrome and Android use an inaccessible CanvasPixelArray prototype.
|
|
|
|
// Because we cannot feature detect it, we rely on user agent parsing.
|
|
|
|
// Because we cannot feature detect it, we rely on user agent parsing.
|
|
|
|
var polyfill = false; |
|
|
|
var polyfill = false, versionMatch; |
|
|
|
if (navigator.userAgent.indexOf('Chrom') >= 0) { |
|
|
|
if (navigator.userAgent.indexOf('Chrom') >= 0) { |
|
|
|
var versionMatch = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./); |
|
|
|
versionMatch = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./); |
|
|
|
if (versionMatch && parseInt(versionMatch[2]) < 21) { |
|
|
|
// Chrome < 21 lacks the set function.
|
|
|
|
// Chrome < 21 lacks the set function.
|
|
|
|
polyfill = versionMatch && parseInt(versionMatch[2]) < 21; |
|
|
|
polyfill = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else if (navigator.userAgent.indexOf('Android') >= 0) { |
|
|
|
} else if (navigator.userAgent.indexOf('Android') >= 0) { |
|
|
|
// Android < 4.4 lacks the set function.
|
|
|
|
// Android < 4.4 lacks the set function.
|
|
|
|
// Android >= 4.4 will contain Chrome in the user agent,
|
|
|
|
// Android >= 4.4 will contain Chrome in the user agent,
|
|
|
|
// thus pass the Chrome check above and not reach this block.
|
|
|
|
// thus pass the Chrome check above and not reach this block.
|
|
|
|
var isOldAndroid = /Android\s[0-4][^\d]/g.test(navigator.userAgent); |
|
|
|
polyfill = /Android\s[0-4][^\d]/g.test(navigator.userAgent); |
|
|
|
if (isOldAndroid) { |
|
|
|
} else if (navigator.userAgent.indexOf('Safari') >= 0) { |
|
|
|
polyfill = true; |
|
|
|
versionMatch = navigator.userAgent. |
|
|
|
} |
|
|
|
match(/Version\/([0-9]+)\.([0-9]+)\.([0-9]+) Safari\//); |
|
|
|
|
|
|
|
// Safari < 6 lacks the set function.
|
|
|
|
|
|
|
|
polyfill = versionMatch && parseInt(versionMatch[1]) < 6; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (polyfill) { |
|
|
|
if (polyfill) { |
|
|
|