diff --git a/Gruntfile.js b/Gruntfile.js index 4439d3d..96ce411 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -5,7 +5,7 @@ module.exports = function(grunt) { pkg: grunt.file.readJSON('package.json'), uglify: { options: { - banner: '/*! <%= pkg.name %> | Built on <%= grunt.template.today("yyyy-mm-dd HH:MM:ss") %> */\n' + banner: '/*! <%= pkg.name %> | Built on <%= grunt.template.today("yyyy-mm-dd HH:MM:sso") %> */\n' }, build: { files: { diff --git a/README.md b/README.md index b84b645..741b4b6 100644 --- a/README.md +++ b/README.md @@ -30,11 +30,12 @@ The minified wrapper is self-contained. It includes all required dependencies in addition to the ADL Verbs and the XAPIStatement module. For production sites, this version of the wrapper is recommended. -Compiling the minified version is easy. Install Node.js and NPM if you don't already have them. -Then install the build system, Grunt: +Compiling the minified version is easy. Install Node.js and NPM if you don't already have them +(download them [here](http://nodejs.org/download/)). Then install the build system, Grunt. This +may require root/admin privileges on your system. ```bash -$ npm install -g grunt +$ sudo npm install -g grunt ``` Install the xAPIWrapper dependencies: diff --git a/xapiwrapper.min.js b/xapiwrapper.min.js index 52dd39d..d54e286 100644 --- a/xapiwrapper.min.js +++ b/xapiwrapper.min.js @@ -1,2 +1,2 @@ -/*! xAPIWrapper | Built on 2014-05-28 10:26:57 */ +/*! xAPIWrapper | Built on 2014-05-28 11:41:07-0400 */ function toBase64(a){return CryptoJS&&CryptoJS.enc.Base64?CryptoJS.enc.Base64.stringify(CryptoJS.enc.Latin1.parse(a)):Base64.encode(a)}function toSHA1(a){return CryptoJS&&CryptoJS.SHA1?CryptoJS.SHA1(a).toString():Crypto.util.bytesToHex(Crypto.SHA1(a,{asBytes:!0}))}var CryptoJS=CryptoJS||function(a,b){var c={},d=c.lib={},e=d.Base=function(){function a(){}return{extend:function(b){a.prototype=this;var c=new a;return b&&c.mixIn(b),c.hasOwnProperty("init")||(c.init=function(){c.$super.init.apply(this,arguments)}),c.init.prototype=c,c.$super=this,c},create:function(){var a=this.extend();return a.init.apply(a,arguments),a},init:function(){},mixIn:function(a){for(var b in a)a.hasOwnProperty(b)&&(this[b]=a[b]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),f=d.WordArray=e.extend({init:function(a,c){a=this.words=a||[],this.sigBytes=c!=b?c:4*a.length},toString:function(a){return(a||h).stringify(this)},concat:function(a){var b=this.words,c=a.words,d=this.sigBytes,e=a.sigBytes;if(this.clamp(),d%4)for(var f=0;e>f;f++){var g=c[f>>>2]>>>24-f%4*8&255;b[d+f>>>2]|=g<<24-(d+f)%4*8}else if(c.length>65535)for(var f=0;e>f;f+=4)b[d+f>>>2]=c[f>>>2];else b.push.apply(b,c);return this.sigBytes+=e,this},clamp:function(){var b=this.words,c=this.sigBytes;b[c>>>2]&=4294967295<<32-c%4*8,b.length=a.ceil(c/4)},clone:function(){var a=e.clone.call(this);return a.words=this.words.slice(0),a},random:function(b){for(var c=[],d=0;b>d;d+=4)c.push(4294967296*a.random()|0);return new f.init(c,b)}}),g=c.enc={},h=g.Hex={stringify:function(a){for(var b=a.words,c=a.sigBytes,d=[],e=0;c>e;e++){var f=b[e>>>2]>>>24-e%4*8&255;d.push((f>>>4).toString(16)),d.push((15&f).toString(16))}return d.join("")},parse:function(a){for(var b=a.length,c=[],d=0;b>d;d+=2)c[d>>>3]|=parseInt(a.substr(d,2),16)<<24-d%8*4;return new f.init(c,b/2)}},i=g.Latin1={stringify:function(a){for(var b=a.words,c=a.sigBytes,d=[],e=0;c>e;e++){var f=b[e>>>2]>>>24-e%4*8&255;d.push(String.fromCharCode(f))}return d.join("")},parse:function(a){for(var b=a.length,c=[],d=0;b>d;d++)c[d>>>2]|=(255&a.charCodeAt(d))<<24-d%4*8;return new f.init(c,b)}},j=g.Utf8={stringify:function(a){try{return decodeURIComponent(escape(i.stringify(a)))}catch(b){throw new Error("Malformed UTF-8 data")}},parse:function(a){return i.parse(unescape(encodeURIComponent(a)))}},k=(g.Base64={stringify:function(a){var b=a.words,c=a.sigBytes,d=this._map;a.clamp();for(var e=[],f=0;c>f;f+=3)for(var g=b[f>>>2]>>>24-f%4*8&255,h=b[f+1>>>2]>>>24-(f+1)%4*8&255,i=b[f+2>>>2]>>>24-(f+2)%4*8&255,j=g<<16|h<<8|i,k=0;4>k&&c>f+.75*k;k++)e.push(d.charAt(j>>>6*(3-k)&63));var l=d.charAt(64);if(l)for(;e.length%4;)e.push(l);return e.join("")},parse:function(a){var b=a.length,c=this._map,d=c.charAt(64);if(d){var e=a.indexOf(d);-1!=e&&(b=e)}for(var g=[],h=0,i=0;b>i;i++)if(i%4){var j=c.indexOf(a.charAt(i-1))<>>6-i%4*2;g[h>>>2]|=(j|k)<<24-h%4*8,h++}return f.create(g,h)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},d.BufferedBlockAlgorithm=e.extend({reset:function(){this._data=new f.init,this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=j.parse(a)),this._data.concat(a),this._nDataBytes+=a.sigBytes},_process:function(b){var c=this._data,d=c.words,e=c.sigBytes,g=this.blockSize,h=4*g,i=e/h;i=b?a.ceil(i):a.max((0|i)-this._minBufferSize,0);var j=i*g,k=a.min(4*j,e);if(j){for(var l=0;j>l;l+=g)this._doProcessBlock(d,l);var m=d.splice(0,j);c.sigBytes-=k}return new f.init(m,k)},clone:function(){var a=e.clone.call(this);return a._data=this._data.clone(),a},_minBufferSize:0})),l=d.Hasher=k.extend({cfg:e.extend(),init:function(a){this.cfg=this.cfg.extend(a),this.reset()},reset:function(){k.reset.call(this),this._doReset()},update:function(a){return this._append(a),this._process(),this},finalize:function(a){a&&this._append(a);var b=this._doFinalize();return b},blockSize:16,_createHelper:function(a){return function(b,c){return new a.init(c).finalize(b)}},_createHmacHelper:function(a){return function(b,c){return new m.HMAC.init(a,c).finalize(b)}}}),m=c.algo={},n=[],o=m.SHA1=l.extend({_doReset:function(){this._hash=new f.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(a,b){for(var c=this._hash.words,d=c[0],e=c[1],f=c[2],g=c[3],h=c[4],i=0;80>i;i++){if(16>i)n[i]=0|a[b+i];else{var j=n[i-3]^n[i-8]^n[i-14]^n[i-16];n[i]=j<<1|j>>>31}var k=(d<<5|d>>>27)+h+n[i];k+=20>i?(e&f|~e&g)+1518500249:40>i?(e^f^g)+1859775393:60>i?(e&f|e&g|f&g)-1894007588:(e^f^g)-899497514,h=g,g=f,f=e<<30|e>>>2,e=d,d=k}c[0]=c[0]+d|0,c[1]=c[1]+e|0,c[2]=c[2]+f|0,c[3]=c[3]+g|0,c[4]=c[4]+h|0},_doFinalize:function(){var b=this._data,c=b.words,d=8*this._nDataBytes,e=8*b.sigBytes;return c[e>>>5]|=128<<24-e%32,c[(e+64>>>9<<4)+14]=a.floor(d/4294967296),c[(e+64>>>9<<4)+15]=d,b.sigBytes=4*c.length,this._process(),this._hash},clone:function(){var a=l.clone.call(this);return a._hash=this._hash.clone(),a}});return c.SHA1=l._createHelper(o),c.HmacSHA1=l._createHmacHelper(o),c}(Math);!function(a){a.verbs={answered:{id:"http://adlnet.gov/expapi/verbs/answered",display:{"en-US":"answered"}},asked:{id:"http://adlnet.gov/expapi/verbs/asked",display:{"en-US":"asked"}},attempted:{id:"http://adlnet.gov/expapi/verbs/attempted",display:{"en-US":"attempted"}},attended:{id:"http://adlnet.gov/expapi/verbs/attended",display:{"en-US":"attended"}},commented:{id:"http://adlnet.gov/expapi/verbs/commented",display:{"en-US":"commented"}},completed:{id:"http://adlnet.gov/expapi/verbs/completed",display:{"en-US":"completed"}},exited:{id:"http://adlnet.gov/expapi/verbs/exited",display:{"en-US":"exited"}},experienced:{id:"http://adlnet.gov/expapi/verbs/experienced",display:{"en-US":"experienced"}},failed:{id:"http://adlnet.gov/expapi/verbs/failed",display:{"en-US":"failed"}},imported:{id:"http://adlnet.gov/expapi/verbs/imported",display:{"en-US":"imported"}},initialized:{id:"http://adlnet.gov/expapi/verbs/initialized",display:{"en-US":"initialized"}},interacted:{id:"http://adlnet.gov/expapi/verbs/interacted",display:{"en-US":"interacted"}},launched:{id:"http://adlnet.gov/expapi/verbs/launched",display:{"en-US":"launched"}},mastered:{id:"http://adlnet.gov/expapi/verbs/mastered",display:{"en-US":"mastered"}},passed:{id:"http://adlnet.gov/expapi/verbs/passed",display:{"en-US":"passed"}},preferred:{id:"http://adlnet.gov/expapi/verbs/preferred",display:{"en-US":"preferred"}},progressed:{id:"http://adlnet.gov/expapi/verbs/progressed",display:{"en-US":"progressed"}},registered:{id:"http://adlnet.gov/expapi/verbs/registered",display:{"en-US":"registered"}},responded:{id:"http://adlnet.gov/expapi/verbs/responded",display:{"en-US":"responded"}},resumed:{id:"http://adlnet.gov/expapi/verbs/resumed",display:{"en-US":"resumed"}},scored:{id:"http://adlnet.gov/expapi/verbs/scored",display:{"en-US":"scored"}},shared:{id:"http://adlnet.gov/expapi/verbs/shared",display:{"en-US":"shared"}},suspended:{id:"http://adlnet.gov/expapi/verbs/suspended",display:{"en-US":"suspended"}},terminated:{id:"http://adlnet.gov/expapi/verbs/terminated",display:{"en-US":"terminated"}},voided:{id:"http://adlnet.gov/expapi/verbs/voided",display:{"en-US":"voided"}}}}(window.ADL=window.ADL||{}),Date.prototype.toISOString||!function(){function a(a){var b=String(a);return 1===b.length&&(b="0"+b),b}Date.prototype.toISOString=function(){return this.getUTCFullYear()+"-"+a(this.getUTCMonth()+1)+"-"+a(this.getUTCDate())+"T"+a(this.getUTCHours())+":"+a(this.getUTCMinutes())+":"+a(this.getUTCSeconds())+"."+String((this.getUTCMilliseconds()/1e3).toFixed(3)).slice(2,5)+"Z"}}(),function(a){function b(){try{return void 0!=this.lrs.endpoint&&""!=this.lrs.endpoint}catch(a){return!1}}function c(a){if(!c.debug)return!1;try{return console.log(a),!0}catch(b){return!1}}function d(a,b){for(var c in b){prop=b[c],console.log(c+" : "+prop);try{b[c].constructor==Object?a[c]=d(a[c],b[c]):(void 0==a&&(a=new Object),a[c]=b[c])}catch(e){void 0==a&&(a=new Object),a[c]=b[c]}}return a}function e(a){var b,c,e=["endpoint","auth","actor","registration","activity_id","grouping","activity_platform"],g=new Object;if(b=f(),void 0!==b&&0!==Object.keys(b).length){for(var h=0;h0&&(f.push(e.substr(g+1)),e=e.substr(0,g)),e=e+"?method="+a,null!==c)for(var h in c)f.push(h+"="+encodeURIComponent(c[h]));return null!==d&&f.push("content="+encodeURIComponent(d)),{method:"POST",url:e,headers:{},data:f.join("&")}}c.debug=!0;var i=function(){var a={};a.endpoint="http://localhost:8000/xapi/";try{a.auth="Basic "+toBase64("tom:1234")}catch(b){c("Exception in Config trying to encode auth: "+b)}return a}();XAPIWrapper=function(c,f){function g(b){var c=document.createElement("a");return c.href=b,c.protocol&&c.host?c.protocol+"//"+c.host:void a.XAPIWrapper.log("Couldn't create base url from endpoint: "+this.lrs.endpoint)}function h(a,b,c){a.auth="Basic "+toBase64(b+":"+c)}this.lrs=e(c||{}),this.lrs.user&&this.lrs.password&&h(this.lrs,this.lrs.user,this.lrs.password),this.base=g(this.lrs.endpoint),f&&b.call(this)&&window.ADL.XHR_request(this.lrs,this.lrs.endpoint+"about","GET",null,null,function(b){if(200==b.status)try{var c=JSON.parse(b.response),d=!1;for(var e in c.version)if(c.version[e]==a.XAPIWrapper.xapiVersion){d=!0;break}d||a.XAPIWrapper.log("The lrs version ["+c.version+"] does not match this wrapper's XAPI version ["+a.XAPIWrapper.xapiVersion+"]")}catch(f){a.XAPIWrapper.log("The response was not an about object")}else a.XAPIWrapper.log("The request to get information about the LRS failed: "+b)}),this.searchParams=function(){var a={format:"exact"};return a},this.hash=function(b){if(!b)return null;try{return toSHA1(b)}catch(c){return a.XAPIWrapper.log("Error trying to hash -- "+c),null}},this.changeConfig=function(b){try{a.XAPIWrapper.log("updating lrs object with new configuration"),this.lrs=d(this.lrs,b),b.user&&b.password&&this.updateAuth(this.lrs,b.user,b.password),this.base=g(this.lrs.endpoint)}catch(c){a.XAPIWrapper.log("error while changing configuration -- "+c)}},this.updateAuth=h},XAPIWrapper.prototype.xapiVersion="1.0.1",XAPIWrapper.prototype.prepareStatement=function(a){void 0===a.actor?a.actor=JSON.parse(this.lrs.actor):"string"==typeof a.actor&&(a.actor=JSON.parse(a.actor)),(this.lrs.grouping||this.lrs.registration||this.lrs.activity_platform)&&(a.context||(a.context={})),this.lrs.grouping&&(a.context.contextActivities||(a.context.contextActivities={}),a.context.contextActivities.grouping=[{id:this.lrs.grouping}]),this.lrs.registration&&(a.context.registration=this.lrs.registration),this.lrs.activity_platform&&(a.context.platform=this.lrs.activity_platform)},XAPIWrapper.prototype.testConfig=b,XAPIWrapper.prototype.log=c,XAPIWrapper.prototype.sendStatement=function(b,c){if(this.testConfig()){this.prepareStatement(b);var d;b.id?d=b.id:(d=a.ruuid(),b.id=d);var e=a.XHR_request(this.lrs,this.lrs.endpoint+"statements","POST",JSON.stringify(b),this.lrs.auth,c,{id:d});if(!c)return{xhr:e,id:d}}},XAPIWrapper.prototype.sendStatements=function(b,c){if(this.testConfig()){for(var d in b)this.prepareStatement(b[d]);var e=a.XHR_request(this.lrs,this.lrs.endpoint+"statements","POST",JSON.stringify(b),this.lrs.auth,c);if(!c)return e}},XAPIWrapper.prototype.getStatements=function(b,c,d){if(this.testConfig()){var e=this.lrs.endpoint+"statements";if(c)e=this.base+c;else{var f=new Array;for(s in b)f.push(s+"="+encodeURIComponent(b[s]));f.length>0&&(e=e+"?"+f.join("&"))}var g=a.XHR_request(this.lrs,e,"GET",null,this.lrs.auth,d);if(void 0===g||404==g.status)return null;try{return JSON.parse(g.response)}catch(h){return g.response}}},XAPIWrapper.prototype.getActivities=function(b,c){if(this.testConfig()){var d=this.lrs.endpoint+"activities?activityId=";d=d.replace("",encodeURIComponent(b));var e=a.XHR_request(this.lrs,d,"GET",null,this.lrs.auth,c,null,!0);if(void 0===e||404==e.status)return null;try{return JSON.parse(e.response)}catch(f){return e.response}}},XAPIWrapper.prototype.sendState=function(b,d,e,f,g,h,i,j){if(this.testConfig()){var k=this.lrs.endpoint+"activities/state?activityId=&agent=&stateId=";k=k.replace("",encodeURIComponent(b)),k=k.replace("",encodeURIComponent(JSON.stringify(d))),k=k.replace("",encodeURIComponent(e)),f&&(k+="®istration="+encodeURIComponent(f));var l=null;h&&i?c("Can't have both If-Match and If-None-Match"):h?l={"If-Match":'"'+h+'"'}:i&&(l={"If-None-Match":'"'+i+'"'});var m="PUT";if(!g)return this.log("No activity state was included."),!1;g instanceof Array?(g=JSON.stringify(g),l=l||{},l["Content-Type"]="application/json"):g instanceof Object?(g=JSON.stringify(g),l=l||{},l["Content-Type"]="application/json",m="POST"):(l=l||{},l["Content-Type"]="application/octect-stream"),a.XHR_request(this.lrs,k,m,g,this.lrs.auth,j,null,null,l)}},XAPIWrapper.prototype.getState=function(b,c,d,e,f,g){if(this.testConfig()){var h=this.lrs.endpoint+"activities/state?activityId=&agent=";h=h.replace("",encodeURIComponent(b)),h=h.replace("",encodeURIComponent(JSON.stringify(c))),d&&(h+="&stateId="+encodeURIComponent(d)),e&&(h+="®istration="+encodeURIComponent(e)),f&&(h+="&since="+encodeURIComponent(f.toISOString()));var i=a.XHR_request(this.lrs,h,"GET",null,this.lrs.auth,g,null,!0);if(void 0===i||404==i.status)return null;try{return JSON.parse(i.response)}catch(j){return i.response}}},XAPIWrapper.prototype.sendActivityProfile=function(b,d,e,f,g,h){if(this.testConfig()){var i=this.lrs.endpoint+"activities/profile?activityId=&profileId=";i=i.replace("",encodeURIComponent(b)),i=i.replace("",encodeURIComponent(d));var j=null;f&&g?c("Can't have both If-Match and If-None-Match"):f?j={"If-Match":'"'+f+'"'}:g&&(j={"If-None-Match":'"'+g+'"'});var k="PUT";if(!e)return this.log("No activity profile was included."),!1;e instanceof Array?(e=JSON.stringify(e),j=j||{},j["Content-Type"]="application/json"):e instanceof Object?(e=JSON.stringify(e),j=j||{},j["Content-Type"]="application/json",k="POST"):(j=j||{},j["Content-Type"]="application/octect-stream"),a.XHR_request(this.lrs,i,k,e,this.lrs.auth,h,null,!1,j)}},XAPIWrapper.prototype.getActivityProfile=function(b,c,d,e){if(this.testConfig()){var f=this.lrs.endpoint+"activities/profile?activityId=";f=f.replace("",encodeURIComponent(b)),c&&(f+="&profileId="+encodeURIComponent(c)),d&&(f+="&since="+encodeURIComponent(d.toISOString()));var g=a.XHR_request(this.lrs,f,"GET",null,this.lrs.auth,e,null,!0);if(void 0===g||404==g.status)return null;try{return JSON.parse(g.response)}catch(h){return g.response}}},XAPIWrapper.prototype.getAgents=function(b,c){if(this.testConfig()){var d=this.lrs.endpoint+"agents?agent=";d=d.replace("",encodeURIComponent(JSON.stringify(b)));var e=a.XHR_request(this.lrs,d,"GET",null,this.lrs.auth,c,null,!0);if(void 0===e||404==e.status)return null;try{return JSON.parse(e.response)}catch(f){return e.response}}},XAPIWrapper.prototype.sendAgentProfile=function(b,d,e,f,g,h){if(this.testConfig()){var i=this.lrs.endpoint+"agents/profile?agent=&profileId=";i=i.replace("",encodeURIComponent(JSON.stringify(b))),i=i.replace("",encodeURIComponent(d));var j=null;f&&g?c("Can't have both If-Match and If-None-Match"):f?j={"If-Match":'"'+f+'"'}:g&&(j={"If-None-Match":'"'+g+'"'});var k="PUT";if(!e)return this.log("No agent profile was included."),!1;e instanceof Array?(e=JSON.stringify(e),j=j||{},j["Content-Type"]="application/json"):e instanceof Object?(e=JSON.stringify(e),j=j||{},j["Content-Type"]="application/json",k="POST"):(j=j||{},j["Content-Type"]="application/octect-stream"),a.XHR_request(this.lrs,i,k,e,this.lrs.auth,h,null,!1,j)}},XAPIWrapper.prototype.getAgentProfile=function(b,c,d,e){if(this.testConfig()){var f=this.lrs.endpoint+"agents/profile?agent=";f=f.replace("",encodeURIComponent(JSON.stringify(b))),f=f.replace("",encodeURIComponent(c)),c&&(f+="&profileId="+encodeURIComponent(c)),d&&(f+="&since="+encodeURIComponent(d.toISOString()));var g=a.XHR_request(this.lrs,f,"GET",null,this.lrs.auth,e,null,!0);if(void 0===g||404==g.status)return null;try{return JSON.parse(g.response)}catch(h){return g.response}}},a.ruuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=16*Math.random()|0,c="x"==a?b:3&b|8;return c.toString(16)})},a.dateFromISOString=function(a){var b="([0-9]{4})(-([0-9]{2})(-([0-9]{2})([T| ]([0-9]{2}):([0-9]{2})(:([0-9]{2})(.([0-9]+))?)?(Z|(([-+])([0-9]{2}):([0-9]{2})))?)?)?)?",c=a.match(new RegExp(b)),d=0,e=new Date(c[1],0,1);c[3]&&e.setMonth(c[3]-1),c[5]&&e.setDate(c[5]),c[7]&&e.setHours(c[7]),c[8]&&e.setMinutes(c[8]),c[10]&&e.setSeconds(c[10]),c[12]&&e.setMilliseconds(1e3*Number("0."+c[12])),c[14]&&(d=60*Number(c[16])+Number(c[17]),d*="-"==c[15]?1:-1),d-=e.getTimezoneOffset(),time=Number(e)+60*d*1e3;var f=new Date;return f.setTime(Number(time)),f},a.XHR_request=function(b,c,d,e,f,i,j,k,l){"use strict";function m(){if(s)return q;s=!0;var a=k&&404===n.status;if(!(void 0===n.status||n.status>=200&&n.status<400||a)){try{console.warn("There was a problem communicating with the Learning Record Store. ( "+n.status+" | "+n.response+" )"+c)}catch(b){console.warn(b.toString())}return q=n,n}if(!i)return q=n,n;if(j)i(n,j);else try{var d=JSON.parse(n.responseText);i(n,d)}catch(e){i(n,n.responseText)}}var n,o,p,q,r,s=!1,t=!1,u=!1,v=c.toLowerCase().match(/^(.+):\/\/([^:\/]*):?(\d+)?(\/.*)?$/),w=window.location,x={};if(x["Content-Type"]="application/json",x.Authorization=f,x["X-Experience-API-Version"]=a.XAPIWrapper.xapiVersion,null!==l)for(var y in l)x[y]=l[y];if(t=w.protocol.toLowerCase()!==v[1]||w.hostname.toLowerCase()!==v[2],t||(p=null===v[3]?"http"===v[1]?"80":"443":v[3],t=p===w.port),t&&"undefined"!=typeof XDomainRequest)u=!0,o=h(d,c,x,e),n=new XDomainRequest,n.open(o.method,o.url);else{n=new XMLHttpRequest,n.open(d,c,null!=i);for(var y in x)n.setRequestHeader(y,x[y])}if(n.onreadystatechange=function(){return 4===n.readyState?m():void 0},n.onload=m,n.onerror=m,n.send(u?o.data:e),!i){if(u)for(r=1e3+new Date;new Date