Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bhikandeshmukh
GitHub Repository: bhikandeshmukh/shark
Path: blob/master/phs/ola-otpbypass/otp_files/ow-ajax.d7ec024b.js.download
996 views
"use strict";Vue.component("ow-ajax",{render:function(){var t=this.$createElement;return(this._self._c||t)("div")},staticRenderFns:[],name:"ow-ajax",props:["method","url","body","params","trigger","headers"],data:function(){return{xhr:null}},methods:{rxReadCookie:function(t){var e=new RegExp(t+"=([^;]+)\\;?","i").exec(document.cookie?unescape(document.cookie):"");return e?e[1]:""},responseHandler:function(e,t,s){var r=!1;switch(s.toLowerCase()){case"post":case"put":r=-1<[200,201,202].indexOf(this.xhr.status);break;case"get":case"delete":r=200===this.xhr.status}try{r?e.$emit("success",{response:JSON.parse(this.xhr.response),status:this.xhr.status}):e.$emit("error",{xhr:{response:this.xhr.response&&JSON.parse(this.xhr.response),status:this.xhr.status}})}catch(t){e.$emit("error",{xhr:{response:this.xhr.response&&JSON.parse(this.xhr.response),status:this.xhr.status}})}},abortXHR:function(){this.xhr&&this.xhr.abort&&-1<[1,2,3].indexOf(this.xhr.readyState)&&this.xhr.abort()},makeXHR:function(){var r=this,t=this;this.abortXHR();var e=Object.keys(this.params||{}).reduce(function(t,e,s){return 0===s?t+"?"+e+"="+r.params[e]:t+"&"+e+"="+r.params[e]},this.url),s=this.method||"GET";this.xhr=new XMLHttpRequest,this.xhr.open(s||"GET",e),this.xhr.timeout=18e3;var i={"X-Requested-With":"XMLHttpRequest","csrf-token":this.rxReadCookie("XSRF-TOKEN"),"Content-Type":"application/json","X-FINGERPRINT-ID":new Fingerprint({canvas:!0}).get()};this.headers&&Object.keys(this.headers).forEach(function(t){return i[t]=r.headers[t]}),Object.keys(i).forEach(function(t){return r.xhr.setRequestHeader(t,i[t])}),this.xhr.addEventListener("readystatechange",function(){this.readyState===XMLHttpRequest.DONE&&t.responseHandler(t,this,s)}),this.xhr.send(JSON.stringify(this.body))},triggerAjaxEvent:function(t){switch(t){case"fire":this.makeXHR();break;case"dormant":this.abortXHR()}}},mounted:function(){this.triggerAjaxEvent(this.trigger)},watch:{trigger:function(t){this.triggerAjaxEvent(t)}}});
//# sourceMappingURL=../sourcemap/ow-components/ow-ajax.d7ec024b.js.map