You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
8 lines
2.9 KiB
JavaScript
8 lines
2.9 KiB
JavaScript
/*
|
|
Copyright (c) 2004-2016, The JS Foundation All Rights Reserved.
|
|
Available via Academic Free License >= 2.1 OR the modified BSD license.
|
|
see: http://dojotoolkit.org/license for details
|
|
*/
|
|
|
|
//>>built
|
|
define("dojo/request/util",["exports","../errors/RequestError","../errors/CancelError","../Deferred","../io-query","../_base/array","../_base/lang","../promise/Promise","../has"],function(_1,_2,_3,_4,_5,_6,_7,_8,_9){_1.deepCopy=function(_a,_b){for(var _c in _b){var _d=_a[_c],_e=_b[_c];if(_d!==_e){if(_e&&typeof _e==="object"&&!(_9("native-formdata")&&_e instanceof FormData)){if(Object.prototype.toString.call(_e)==="[object Date]"){_a[_c]=new Date(_e);}else{if(_7.isArray(_e)){_a[_c]=_1.deepCopyArray(_e);}else{if(_d&&typeof _d==="object"){_1.deepCopy(_d,_e);}else{_a[_c]=_1.deepCopy({},_e);}}}}else{_a[_c]=_e;}}}return _a;};_1.deepCopyArray=function(_f){var _10=[];_f.forEach(function(_11){if(typeof _11==="object"){_10.push(_1.deepCopy({},_11));}else{_10.push(_11);}});return _10;};_1.deepCreate=function deepCreate(_12,_13){_13=_13||{};var _14=_7.delegate(_12),_15,_16;for(_15 in _12){_16=_12[_15];if(_16&&typeof _16==="object"){_14[_15]=_1.deepCreate(_16,_13[_15]);}}return _1.deepCopy(_14,_13);};var _17=Object.freeze||function(obj){return obj;};function _18(_19){return _17(_19);};function _1a(_1b){return _1b.data!==undefined?_1b.data:_1b.text;};_1.deferred=function deferred(_1c,_1d,_1e,_1f,_20,_21){var def=new _4(function(_22){_1d&&_1d(def,_1c);if(!_22||!(_22 instanceof _2)&&!(_22 instanceof _3)){return new _3("Request canceled",_1c);}return _22;});def.response=_1c;def.isValid=_1e;def.isReady=_1f;def.handleResponse=_20;function _23(_24){_24.response=_1c;throw _24;};var _25=def.then(_18).otherwise(_23);if(_1.notify){_25.then(_7.hitch(_1.notify,"emit","load"),_7.hitch(_1.notify,"emit","error"));}var _26=_25.then(_1a);var _27=new _8();for(var _28 in _26){if(_26.hasOwnProperty(_28)){_27[_28]=_26[_28];}}_27.response=_25;_17(_27);if(_21){def.then(function(_29){_21.call(def,_29);},function(_2a){_21.call(def,_1c,_2a);});}def.promise=_27;def.then=_27.then;return def;};_1.addCommonMethods=function addCommonMethods(_2b,_2c){_6.forEach(_2c||["GET","POST","PUT","DELETE"],function(_2d){_2b[(_2d==="DELETE"?"DEL":_2d).toLowerCase()]=function(url,_2e){_2e=_7.delegate(_2e||{});_2e.method=_2d;return _2b(url,_2e);};});};_1.parseArgs=function parseArgs(url,_2f,_30){var _31=_2f.data,_32=_2f.query;if(_31&&!_30){if(typeof _31==="object"&&(!(_9("native-xhr2"))||!(_31 instanceof ArrayBuffer||_31 instanceof Blob))){_2f.data=_5.objectToQuery(_31);}}if(_32){if(typeof _32==="object"){_32=_5.objectToQuery(_32);}if(_2f.preventCache){_32+=(_32?"&":"")+"request.preventCache="+(+(new Date));}}else{if(_2f.preventCache){_32="request.preventCache="+(+(new Date));}}if(url&&_32){url+=(~url.indexOf("?")?"&":"?")+_32;}return {url:url,options:_2f,getHeader:function(_33){return null;}};};_1.checkStatus=function(_34){_34=_34||0;return (_34>=200&&_34<300)||_34===304||_34===1223||!_34;};}); |