|
|
|
@ -3,7 +3,7 @@
@@ -3,7 +3,7 @@
|
|
|
|
|
|
|
|
|
|
// Checking if the typed arrays are supported
|
|
|
|
|
(function() { |
|
|
|
|
if (typeof Uint8Array !== "undefined") |
|
|
|
|
if (typeof Uint8Array !== 'undefined') |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
function subarray(start, end) { |
|
|
|
@ -18,7 +18,7 @@
@@ -18,7 +18,7 @@
|
|
|
|
|
|
|
|
|
|
function TypedArray(arg1) { |
|
|
|
|
var result; |
|
|
|
|
if (typeof arg1 === "number") { |
|
|
|
|
if (typeof arg1 === 'number') { |
|
|
|
|
result = new Array(arg1); |
|
|
|
|
for (var i = 0; i < arg1; ++i) |
|
|
|
|
result[i] = 0; |
|
|
|
@ -28,7 +28,7 @@
@@ -28,7 +28,7 @@
|
|
|
|
|
result.buffer = result; |
|
|
|
|
result.byteLength = result.length; |
|
|
|
|
result.set = set_; |
|
|
|
|
if (typeof arg1 === "object" && arg1.buffer) |
|
|
|
|
if (typeof arg1 === 'object' && arg1.buffer) |
|
|
|
|
result.buffer = arg1.buffer; |
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
@ -44,7 +44,7 @@
@@ -44,7 +44,7 @@
|
|
|
|
|
|
|
|
|
|
// Object.create() ?
|
|
|
|
|
(function() { |
|
|
|
|
if (typeof Object.create !== "undefined") |
|
|
|
|
if (typeof Object.create !== 'undefined') |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
Object.create = function(proto) { |
|
|
|
@ -56,16 +56,16 @@
@@ -56,16 +56,16 @@
|
|
|
|
|
|
|
|
|
|
// Object.defineProperty() ?
|
|
|
|
|
(function() { |
|
|
|
|
if (typeof Object.defineProperty !== "undefined") |
|
|
|
|
if (typeof Object.defineProperty !== 'undefined') |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
Object.defineProperty = function(obj, name, def) { |
|
|
|
|
delete obj[name]; |
|
|
|
|
if ("get" in def) |
|
|
|
|
obj.__defineGetter__(name, def["get"]); |
|
|
|
|
if ("set" in def) |
|
|
|
|
obj.__defineSetter__(name, def["set"]); |
|
|
|
|
if ("value" in def) { |
|
|
|
|
if ('get' in def) |
|
|
|
|
obj.__defineGetter__(name, def['get']); |
|
|
|
|
if ('set' in def) |
|
|
|
|
obj.__defineSetter__(name, def['set']); |
|
|
|
|
if ('value' in def) { |
|
|
|
|
obj.__defineSetter__(name, function(value) { |
|
|
|
|
this.__defineGetter__(name, function() { |
|
|
|
|
return value; |
|
|
|
@ -80,16 +80,16 @@
@@ -80,16 +80,16 @@
|
|
|
|
|
// No XMLHttpRequest.response ?
|
|
|
|
|
(function() { |
|
|
|
|
var xhrPrototype = XMLHttpRequest.prototype; |
|
|
|
|
if ("response" in xhrPrototype || |
|
|
|
|
"mozResponseArrayBuffer" in xhrPrototype || |
|
|
|
|
"mozResponse" in xhrPrototype || |
|
|
|
|
"responseArrayBuffer" in xhrPrototype) |
|
|
|
|
if ('response' in xhrPrototype || |
|
|
|
|
'mozResponseArrayBuffer' in xhrPrototype || |
|
|
|
|
'mozResponse' in xhrPrototype || |
|
|
|
|
'responseArrayBuffer' in xhrPrototype) |
|
|
|
|
return; |
|
|
|
|
// IE ?
|
|
|
|
|
if (typeof VBArray !== "undefined") { |
|
|
|
|
Object.defineProperty(xhrPrototype, "response", { |
|
|
|
|
if (typeof VBArray !== 'undefined') { |
|
|
|
|
Object.defineProperty(xhrPrototype, 'response', { |
|
|
|
|
get: function() { |
|
|
|
|
return new Uint8Array( new VBArray(this.responseBody).toArray() ); |
|
|
|
|
return new Uint8Array(new VBArray(this.responseBody).toArray()); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
return; |
|
|
|
@ -98,10 +98,11 @@
@@ -98,10 +98,11 @@
|
|
|
|
|
// other browsers
|
|
|
|
|
function responseTypeSetter() { |
|
|
|
|
// will be only called to set "arraybuffer"
|
|
|
|
|
this.overrideMimeType("text/plain; charset=x-user-defined"); |
|
|
|
|
this.overrideMimeType('text/plain; charset=x-user-defined'); |
|
|
|
|
} |
|
|
|
|
if (typeof xhrPrototype.overrideMimeType === "function") { |
|
|
|
|
Object.defineProperty(xhrPrototype, "responseType", { set: responseTypeSetter }); |
|
|
|
|
if (typeof xhrPrototype.overrideMimeType === 'function') { |
|
|
|
|
Object.defineProperty(xhrPrototype, 'responseType', |
|
|
|
|
{ set: responseTypeSetter }); |
|
|
|
|
} |
|
|
|
|
function responseGetter() { |
|
|
|
|
var text = this.responseText; |
|
|
|
@ -111,18 +112,19 @@
@@ -111,18 +112,19 @@
|
|
|
|
|
result[i] = text.charCodeAt(i) & 0xFF; |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
Object.defineProperty(xhrPrototype, "response", { get: responseGetter }); |
|
|
|
|
Object.defineProperty(xhrPrototype, 'response', { get: responseGetter }); |
|
|
|
|
})(); |
|
|
|
|
|
|
|
|
|
// window.btoa (base64 encode function) ?
|
|
|
|
|
(function() { |
|
|
|
|
if ("btoa" in window) |
|
|
|
|
if ('btoa' in window) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
var digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; |
|
|
|
|
var digits = |
|
|
|
|
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; |
|
|
|
|
|
|
|
|
|
window.btoa = function(chars) { |
|
|
|
|
var buffer = ""; |
|
|
|
|
var buffer = ''; |
|
|
|
|
var i, n; |
|
|
|
|
for (i = 0, n = chars.length; i < n; i += 3) { |
|
|
|
|
var b1 = chars.charCodeAt(i) & 0xFF; |
|
|
|
@ -131,7 +133,8 @@
@@ -131,7 +133,8 @@
|
|
|
|
|
var d1 = b1 >> 2, d2 = ((b1 & 3) << 4) | (b2 >> 4); |
|
|
|
|
var d3 = i + 1 < n ? ((b2 & 0xF) << 2) | (b3 >> 6) : 64; |
|
|
|
|
var d4 = i + 2 < n ? (b3 & 0x3F) : 64; |
|
|
|
|
buffer += digits.charAt(d1) + digits.charAt(d2) + digits.charAt(d3) + digits.charAt(d4); |
|
|
|
|
buffer += (digits.charAt(d1) + digits.charAt(d2) + |
|
|
|
|
digits.charAt(d3) + digits.charAt(d4)); |
|
|
|
|
} |
|
|
|
|
return buffer; |
|
|
|
|
}; |
|
|
|
@ -139,7 +142,7 @@
@@ -139,7 +142,7 @@
|
|
|
|
|
|
|
|
|
|
// Function.prototype.bind ?
|
|
|
|
|
(function() { |
|
|
|
|
if (typeof Function.prototype.bind !== "undefined") |
|
|
|
|
if (typeof Function.prototype.bind !== 'undefined') |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
Function.prototype.bind = function(obj) { |
|
|
|
|