-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.min.js
1 lines (1 loc) · 1.44 KB
/
index.min.js
1
var SpaceCat=function(){};SpaceCat.prototype.config={},SpaceCat.prototype.ajax=function(){var e,t,o,n=this.config,s=[],a=[];if(n.url||1==n.debugLog&&console.log("No Url!"),n.type||1==n.debugLog&&console.log("No Default type (GET/POST) given!"),n.method|=!0,n.debugLog|=!1,e=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP"),e.onreadystatechange=function(){4==this.readyState&&200==this.status?(n.success&&n.success(this.responseText,this.readyState),1==n.debugLog&&console.log("SuccessResponse \nResponse Data:"+this.responseText)):1==n.debugLog&&console.log("FailureResponse --> State:"+this.readyState+"Status:"+this.status)},t=n.data,"string"==typeof t){a=String.prototype.split.call(t,"&");for(var p=0,c=a.length;p<c;p++)o=a[p].split("="),s.push(encodeURIComponent(o[0])+"="+encodeURIComponent(o[1]))}else if("object"==typeof t&&!(t instanceof String||FormData&&t instanceof FormData))for(var r in t)if(o=t[r],"[object Array]"==Object.prototype.toString.call(o))for(var p=0,c=o.length;p<c;p++)s.push(encodeURIComponent(r)+"[]="+encodeURIComponent(o[p]));else s.push(encodeURIComponent(r)+"="+encodeURIComponent(o));s=s.join("&"),"GET"==n.type&&(e.open("GET",n.url+"?"+s,n.method),e.send(),1==n.debugLog&&console.log("GET fired at:"+n.url+"?"+s)),"POST"==n.type&&(e.open("POST",n.url,n.method),e.setRequestHeader("Content-type","application/x-www-form-urlencoded"),e.send(s),1==n.debugLog&&console.log("POST fired at:"+n.url+" || Data:"+s))};