/** Helper Functions */ function readIEEE754(buf, idx, isLE, nl, ml) { if(isLE === undefined) isLE = true; if(!nl) nl = 8; if(!ml && nl === 8) ml = 52; var e, m, el = nl * 8 - ml - 1, eMax = (1 << el) - 1, eBias = eMax >> 1; var bits = -7, d = isLE ? -1 : 1, i = isLE ? (nl - 1) : 0, s = buf[idx + i]; i += d; e = s & ((1 << (-bits)) - 1); s >>>= (-bits); bits += el; for (; bits > 0; e = e * 256 + buf[idx + i], i += d, bits -= 8); m = e & ((1 << (-bits)) - 1); e >>>= (-bits); bits += ml; for (; bits > 0; m = m * 256 + buf[idx + i], i += d, bits -= 8); if (e === eMax) return m ? NaN : ((s ? -1 : 1) * Infinity); else if (e === 0) e = 1 - eBias; else { m = m + Math.pow(2, ml); e = e - eBias; } return (s ? -1 : 1) * m * Math.pow(2, e - ml); } var Base64 = (function(){ var map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; return { encode: function(input, utf8) { var o = ""; var c1, c2, c3, e1, e2, e3, e4; for(var i = 0; i < input.length; ) { c1 = input.charCodeAt(i++); c2 = input.charCodeAt(i++); c3 = input.charCodeAt(i++); e1 = c1 >> 2; e2 = (c1 & 3) << 4 | c2 >> 4; e3 = (c2 & 15) << 2 | c3 >> 6; e4 = c3 & 63; if (isNaN(c2)) { e3 = e4 = 64; } else if (isNaN(c3)) { e4 = 64; } o += map.charAt(e1) + map.charAt(e2) + map.charAt(e3) + map.charAt(e4); } return o; }, decode: function(input, utf8) { var o = ""; var c1, c2, c3; var e1, e2, e3, e4; input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); for(var i = 0; i < input.length;) { e1 = map.indexOf(input.charAt(i++)); e2 = map.indexOf(input.charAt(i++)); e3 = map.indexOf(input.charAt(i++)); e4 = map.indexOf(input.charAt(i++)); c1 = e1 << 2 | e2 >> 4; c2 = (e2 & 15) << 4 | e3 >> 2; c3 = (e3 & 3) << 6 | e4; o += String.fromCharCode(c1); if (e3 != 64) { o += String.fromCharCode(c2); } if (e4 != 64) { o += String.fromCharCode(c3); } } return o; } }; })(); function s2a(s) { if(typeof Buffer !== 'undefined') return new Buffer(s, "binary"); var w = s.split("").map(function(x){ return x.charCodeAt(0) & 0xff; }); return w; } if(typeof Buffer !== "undefined") { Buffer.prototype.hexlify= function() { return this.toString('hex'); }; Buffer.prototype.utf16le= function(s,e){return this.toString('utf16le',s,e).replace(/\u0000/,'').replace(/[\u0001-\u0006]/,'!');}; Buffer.prototype.utf8 = function(s,e) { return this.toString('utf8',s,e); }; } Array.prototype.readUInt8 = function(idx) { return this[idx]; }; Array.prototype.readUInt16LE = function(idx) { return this[idx+1]*(1<<8)+this[idx]; }; Array.prototype.readInt16LE = function(idx) { var u = this.readUInt16LE(idx); if(!(u & 0x8000)) return u; return (0xffff - u + 1) * -1; }; Array.prototype.readUInt32LE = function(idx) { return this[idx+3]*(1<<24)+this[idx+2]*(1<<16)+this[idx+1]*(1<<8)+this[idx]; }; Array.prototype.readDoubleLE = function(idx) { return readIEEE754(this, idx||0);}; Array.prototype.hexlify = function() { return this.map(function(x){return (x<16?"0":"") + x.toString(16);}).join(""); }; Array.prototype.utf16le = function(s,e) { var str = ""; for(var i=s; i