This repository has been archived on 2019-05-14. You can view files and clone it, but cannot push or open issues or pull requests.
Typertext/build/typertext.min.js

2 lines
9.7 KiB
JavaScript

var Typertext;!function(a){var b=function(){function a(a,b,c){this.message=a,this.code=b,this.custom=c}return a.prototype.GetCode=function(){return this.code},a.prototype.GetMessage=function(){return this.message},a.prototype.GetCustom=function(){return this.custom},a}();a.BaseException=b}(Typertext||(Typertext={}));var Typertext;!function(a){var b=function(){function a(a,b,c,d){this.status=a,this.headers=b,this.httpStatus=c,this.content=d}return a.prototype.GetContent=function(){return this.content},a.prototype.GetContentType=function(){return this.GetHeader("Content-Type")},a.prototype.GetHeader=function(a){return this.headers(a)},a.prototype.GetHttpStatus=function(){return this.httpStatus},a.prototype.GetStatus=function(){return this.status},a}();a.GenericResponse=b}(Typertext||(Typertext={}));var Typertext;!function(a){!function(a){!function(a){a[a.DELETE=0]="DELETE",a[a.GET=1]="GET",a[a.HEAD=2]="HEAD",a[a.OPTIONS=3]="OPTIONS",a[a.POST=4]="POST",a[a.PUT=5]="PUT",a[a.TRACE=6]="TRACE"}(a.HttpMethod||(a.HttpMethod={}));a.HttpMethod}(a.Http||(a.Http={}));a.Http}(Typertext||(Typertext={}));var Typertext;!function(a){!function(b){var c=function(){function b(a,c,d,e,f){"undefined"==typeof c&&(c=0),"undefined"==typeof d&&(d="/"),"undefined"==typeof e&&(e={}),"undefined"==typeof f&&(f=0),(1>f||f>65535||isNaN(f))&&(f=b.DefaultPort(c)),0!=d.indexOf("/")&&(d="/"+d),this.domain=a,this.protocol=c,this.path=d,this.queryString=e,this.port=f}return b.DefaultPort=function(a){switch(a){case 0:return 80;case 1:return 443;default:return-1}},b.FromUrl=function(c){var d=document.createElement("a");return d.href=c,d.hostname&&d.protocol&&d.pathname&&d.search&&d.port||(d.href=d.href),new b(d.hostname,a.Http.HttpProtocol[d.protocol.slice(0,-1)],d.pathname,b.DecodeQueryString(d.search),parseInt(d.port))},b.DecodeQueryString=function(a){return 0==a.indexOf("?")&&(a=a.substring(1)),b.UrlDecodeString(a)},b.EncodeQueryString=function(a){var c="?"+b.UrlEncodeObject(a);return 1==c.length?"":c},b.UrlEncodeObject=function(a){var b,c="";for(b in a){var d=a[b];if("object"==typeof d||"function"==typeof d){if(d instanceof Array)for(var e=0;e<d.length;e++)("object"!=typeof d[e]||"function"==typeof d[e])&&(c+=encodeURIComponent(b)+"="+encodeURIComponent(d[e])+"&")}else c+=encodeURIComponent(b)+"="+encodeURIComponent(d)+"&"}return c.slice(0,-1)},b.UrlDecodeString=function(a){for(var c={},d=b.splitString(a,"&"),e=0;e<d.length;e++)if(""!=d[e]){var f=b.splitString(d[e],"=",2),g=decodeURIComponent(f[0]);c[g]=1!=f.length?decodeURIComponent(f[1]):""}return c},b.splitString=function(a,b,c){"undefined"==typeof c&&(c=-1),c++;var d=a.split(b);if(c>0&&d.length>c){var e=d.splice(0,c);return e.push(d.join(b)),e}return d},b.prototype.ToString=function(){return a.Http.HttpProtocol[this.protocol]+"://"+this.domain+(this.port==b.DefaultPort(this.protocol)?"":":"+this.port)+this.path+b.EncodeQueryString(this.queryString)},b.prototype.GetPort=function(){return this.port},b.prototype.GetDomain=function(){return this.domain},b.prototype.GetProtocol=function(){return this.protocol},b.prototype.SameOriginCheck=function(a){return this.domain===a.GetDomain()&&this.port===a.GetPort()&&this.protocol===a.GetProtocol()},b}();b.HttpUrl=c}(a.Http||(a.Http={}));a.Http}(Typertext||(Typertext={}));var Typertext;!function(a){!function(){}(a.Transport||(a.Transport={}));a.Transport}(Typertext||(Typertext={}));var Typertext;!function(){}(Typertext||(Typertext={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},Typertext;!function(a){!function(b){var c=function(a){function b(){a.apply(this,arguments)}return __extends(b,a),b}(a.BaseException);b.HttpException=c}(a.Http||(a.Http={}));a.Http}(Typertext||(Typertext={}));var Typertext;!function(a){!function(a){!function(a){a[a.http=0]="http",a[a.https=1]="https"}(a.HttpProtocol||(a.HttpProtocol={}));a.HttpProtocol}(a.Http||(a.Http={}));a.Http}(Typertext||(Typertext={}));var Typertext;!function(a){!function(b){var c=a.Http.HttpUrl,d=function(){function b(){}return b.Transport=function(b,d){var e=document.createElement("div");if(e.innerHTML="<!--[if lte IE 7]><i></i><![endif]-->",1===e.getElementsByTagName("i").length)throw{};e.innerHTML="<!--[if lte IE 9]><i></i><![endif]-->";var f=1===e.getElementsByTagName("i").length,g=c.FromUrl(window.location.href);if(g.SameOriginCheck(g)||!f)return a.Transport.XHR;if(g.GetProtocol()===d.GetProtocol())return a.Transport.XDR;throw{}},b}();b.TransportChooser=d}(a.Transport||(a.Transport={}));a.Transport}(Typertext||(Typertext={}));var Typertext;!function(a){!function(b){var c=a.Transport.TransportChooser,d=function(){function a(){}return a.prototype.Delete=function(a,b){this.RawRequest(5,a,{},b)},a.prototype.Get=function(a,b){this.RawRequest(1,a,{},b)},a.prototype.Post=function(a,b,c){this.RawRequest(4,a,b,c)},a.prototype.Put=function(a,b,c){this.RawRequest(5,a,b,c)},a.prototype.RawRequest=function(a,b,d,e,f){"undefined"==typeof d&&(d={}),e||(e=function(){return null}),f||(f=c.Transport(a,b,d,e));var g=new f(a,b,d,e);g.Send()},a}();b.HttpRequest=d}(a.Http||(a.Http={}));a.Http}(Typertext||(Typertext={}));var Typertext;!function(a){!function(b){var c=function(a){function b(b,c,d,e){a.call(this,b,c,d,e)}return __extends(b,a),b}(a.GenericResponse);b.HttpResponse=c}(a.Http||(a.Http={}));a.Http}(Typertext||(Typertext={}));var Typertext;!function(a){!function(a){!function(a){a[a.success=0]="success",a[a.serverError=1]="serverError",a[a.clientError=2]="clientError",a[a.responseError=3]="responseError",a[a.unknownError=4]="unknownError",a[a.timeout=5]="timeout"}(a.HttpResponseStatus||(a.HttpResponseStatus={}));a.HttpResponseStatus}(a.Http||(a.Http={}));a.Http}(Typertext||(Typertext={}));var Typertext;!function(a){!function(b){var c=function(a){function b(b,c){a.call(this,b,c,null)}return __extends(b,a),b}(a.BaseException);b.JsonException=c}(a.Json||(a.Json={}));a.Json}(Typertext||(Typertext={}));var Typertext;!function(a){!function(b){var c=a.Http.HttpRequest,d=(a.Http.HttpMethod,function(){function b(a){"undefined"==typeof a&&(a="application/json"),this.request=new c,this.jsonType=a}return b.prototype.Delete=function(a,b){this.RawRequest(0,a,{},b)},b.prototype.Get=function(a,b){this.RawRequest(1,a,{},b)},b.prototype.Post=function(a,b,c){this.RawRequest(4,a,b,c)},b.prototype.Put=function(a,b,c){this.RawRequest(5,a,b,c)},b.prototype.RawRequest=function(b,c,d,e,f){var g=this;return"undefined"==typeof d&&(d={}),"function"!=typeof e?void this.request.RawRequest(b,c,d,function(){}):void this.request.RawRequest(b,c,d,function(b){return b.GetContentType()!=g.jsonType?void e(a.Json.JsonResponse.fromInvalidHttpResponse(b)):void e(a.Json.JsonResponse.fromHttpResponse(b))},f)},b}());b.JsonRequest=d}(a.Json||(a.Json={}));a.Json}(Typertext||(Typertext={}));var Typertext;!function(a){!function(b){var c=(a.Http.HttpResponseStatus,function(a){function b(b,c,d,e,f){a.call(this,b,c,d,e),f=!!f||!1,this.parseSuccess=f}return __extends(b,a),b.fromHttpResponse=function(a){try{return new b(a.GetStatus(),a.GetHeader,a.GetHttpStatus(),window.JSON.parse(a.GetContent()),!0)}catch(c){return new b(a.GetStatus(),a.GetHeader,a.GetHttpStatus(),null)}},b.fromInvalidHttpResponse=function(a){return new b(3,a.GetHeader,a.GetHttpStatus())},b.prototype.GetParseStatus=function(){return this.parseSuccess},b}(a.GenericResponse));b.JsonResponse=c}(a.Json||(a.Json={}));a.Json}(Typertext||(Typertext={}));var Typertext;!function(a){!function(b){var c=a.Http.HttpMethod,d=a.Http.HttpUrl,e=(a.Http.HttpResponseStatus,a.Http.HttpResponse),f=function(){function a(a,b,c,d){"undefined"==typeof c&&(c={}),"undefined"==typeof d&&(d=function(){return null}),this.postData=c,this.method=a,this.request=b,this.callback=d,this.xdr=new XDomainRequest}return a.prototype.Send=function(){var a=this,b=function(b){return"content-type"===b.toLowerCase()?a.xdr.contentType:void 0};return this.xdr.ontimeout=function(){a.callback(new e(5,function(){return""},-1,""))},this.xdr.onerror=function(){a.callback(new e(4,b,-1,a.xdr.responseText))},this.xdr.onload=function(){a.callback(new e(0,b,200,a.xdr.responseText))},this.xdr.onprogress=function(){return null},this.xdr.open(c[this.method],this.request.ToString()),1==this.method?void this.xdr.send():void this.xdr.send(d.UrlEncodeObject(this.postData))},a.prototype.Destroy=function(){this.xdr.ontimeout=this.xdr.onerror=this.xdr.onload=this.xdr.onprogress=null,this.xdr=null},a}();b.XDR=f}(a.Transport||(a.Transport={}));a.Transport}(Typertext||(Typertext={}));var Typertext;!function(a){!function(b){var c=a.Http.HttpMethod,d=a.Http.HttpUrl,e=(a.Http.HttpResponseStatus,a.Http.HttpResponse),f=function(){function a(a,b,c,d){"undefined"==typeof c&&(c={}),"undefined"==typeof d&&(d=function(){return null});var f=this;this.postData=c,this.method=a,this.request=b,this.callback=d,this.xhr=new XMLHttpRequest,this.xhr.onreadystatechange=function(){if(4==f.xhr.readyState){var a=function(a){return f.xhr.getResponseHeader(a)};f.callback(200==f.xhr.status?new e(0,a,f.xhr.status,f.xhr.responseText):f.xhr.status>=400&&f.xhr.status<500?new e(2,a,f.xhr.status,f.xhr.responseText):f.xhr.status>=500&&f.xhr.status<600?new e(1,a,f.xhr.status,f.xhr.responseText):new e(4,a,f.xhr.status,f.xhr.responseText))}},this.xhr.ontimeout=function(){f.callback(new e(5,function(){return""},-1,""))}}return a.prototype.Send=function(){return this.xhr.open(c[this.method],this.request.ToString(),!0),1==this.method?void this.xhr.send():(this.xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),void this.xhr.send(d.UrlEncodeObject(this.postData)))},a.prototype.Destroy=function(){this.xhr.onreadystatechange=this.xhr.ontimeout=null,this.xhr=null},a}();b.XHR=f}(a.Transport||(a.Transport={}));a.Transport}(Typertext||(Typertext={}));
//# sourceMappingURL=typertext.min.js.map