juggle-httpfilter
Version:
1 lines • 1.05 kB
JavaScript
!function(l){l.juggle||(l.juggle={});var t=l.juggle.HttpClient,e=l.juggle.httpEventType;l.juggle.httpFilter=new function(){this.filterArray=[],this.addFilter=function(l){this.filterArray.push(l)},this.filter=function(l){for(var t=0;t<this.filterArray.length;t++)if(!this.filterArray[t].check(l))return!1;return!0},this.send=function(l,a,r,i,n,s,c,h,u){var d=new t;d.callObj=s,d.callSuccess=c,d.callError=h,d.callData=u,d.send(l,a,r,i,n),d.addEventListener(e.SUCCESS,this.successHandle,this),d.addEventListener(e.ERROR,this.errorHandle,this)},this.sendFile=function(l,a,r,i,n,s,c,h,u,d){var o=new t;o.callObj=c,o.callSuccess=h,o.callError=u,o.callData=d,o.sendFile(l,a,r,i,n,s),o.addEventListener(e.SUCCESS,this.successHandle,this),o.addEventListener(e.ERROR,this.errorHandle,this)},this.successHandle=function(l){var t=JSON.parse(l.mData),e=l.mTarget;this.filter(t)?e.callSuccess.call(e.callObj,t,e.callData):e.callError.call(e.callObj,t,e.callData)},this.errorHandle=function(l){var t=l.mTarget;t.callError.call(t.callObj,null,t.callData)}}}(window);