hellojs-xiaotian
Version:
A clientside Javascript library for standardizing requests to OAuth2 web services (and OAuth1 - with a shim)
13 lines (11 loc) • 7.23 kB
HTML
<html><head><script>
window.addEventListener('message', function(e){
console.debug(e.origin, e.data);
});
var gapi={};gapi._bs=new Date().getTime();(function(){var f=encodeURIComponent,g=decodeURIComponent,k="push",m="test",n="shift",s="replace",t="length",x="split",A="join";var B=window,C=document,D=B.location,F=function(){},aa=/\[native code\]/,G=function(a,b,c){return a[b]=a[b]||c},ba=function(a){for(var b=0;b<this[t];b++)if(this[b]===a)return b;return-1},ca=function(a){a=a.sort();for(var b=[],c=void 0,d=0;d<a[t];d++){var e=a[d];e!=c&&b[k](e);c=e}return b},H=function(){var a;if((a=Object.create)&&aa[m](a))a=a(null);else{a={};for(var b in a)a[b]=void 0}return a},I=G(B,"gapi",{});var J;J=G(B,"___jsl",H());G(J,"I",0);G(J,"hel",10);var K=function(){var a=D.href,b;if(J.dpo)b=J.h;else{b=J.h;var c=RegExp("([#].*&|[#])jsh=([^&#]*)","g"),d=RegExp("([?#].*&|[?#])jsh=([^&#]*)","g");if(a=a&&(c.exec(a)||d.exec(a)))try{b=g(a[2])}catch(e){}}return b},da=function(a){var b=G(J,"PQ",[]);J.PQ=[];var c=b[t];if(0===c)a();else for(var d=0,e=function(){++d===c&&a()},h=0;h<c;h++)b[h](e)},L=function(a){return G(G(J,"H",H()),a,H())};var M=G(J,"perf",H());G(M,"g",H());var ea=G(M,"i",H());G(M,"r",[]);H();H();var P=function(a,b,c){b&&0<b[t]&&(b=N(b),c&&0<c[t]&&(b+="___"+N(c)),28<b[t]&&(b=b.substr(0,28)+(b[t]-28)),c=b,b=G(ea,"_p",H()),G(b,c,H())[a]=(new Date).getTime(),b=M.r,"function"===typeof b?b(a,"_p",c):b[k]([a,"_p",c]))},N=function(a){return a[A]("__")[s](/\./g,"_")[s](/\-/g,"_")[s](/\,/g,"_")};var Q=H(),R=[],S=function(a){throw Error("Bad hint"+(a?": "+a:""));};R[k](["jsl",function(a){for(var b in a)if(Object.prototype.hasOwnProperty.call(a,b)){var c=a[b];"object"==typeof c?J[b]=G(J,b,[]).concat(c):G(J,b,c)}if(b=a.u)a=G(J,"us",[]),a[k](b),(b=/^https:(.*)$/.exec(b))&&a[k]("http:"+b[1])}]);var fa=/^(\/[a-zA-Z0-9_\-]+)+$/,ga=/^[a-zA-Z0-9\-_\.!]+$/,ha=/^gapi\.loaded_[0-9]+$/,ia=/^[a-zA-Z0-9,._-]+$/,ma=function(a,b,c,d){var e=a[x](";"),h=Q[e[n]()],l=null;h&&(l=h(e,b,c,d));if(b=l)b=l,c=b.match(ja),d=b.match(ka),b=!!d&&1===d[t]&&la[m](b)&&!!c&&1===c[t];b||S(a);return l},oa=function(a,b,c,d){a=na(a);ha[m](c)||S("invalid_callback");b=T(b);d=d&&d[t]?T(d):null;var e=function(a){return f(a)[s](/%2C/g,",")};return[f(a.d)[s](/%2C/g,",")[s](/%2F/g,"/"),"/k=",e(a.version),"/m=",e(b),d?"/exm="+e(d):
"","/rt=j/sv=1/d=1/ed=1",a.a?"/am="+e(a.a):"",a.b?"/rs="+e(a.b):"","/cb=",e(c)][A]("")},na=function(a){"/"!==a.charAt(0)&&S("relative path");for(var b=a.substring(1)[x]("/"),c=[];b[t];){a=b[n]();if(!a[t]||0==a.indexOf("."))S("empty/relative directory");else if(0<a.indexOf("=")){b.unshift(a);break}c[k](a)}a={};for(var d=0,e=b[t];d<e;++d){var h=b[d][x]("="),l=g(h[0]),p=g(h[1]);2==h[t]&&l&&p&&(a[l]=a[l]||p)}b="/"+c[A]("/");fa[m](b)||S("invalid_prefix");c=U(a,"k",!0);d=U(a,"am");a=U(a,"rs");return{d:b,
version:c,a:d,b:a}},T=function(a){for(var b=[],c=0,d=a[t];c<d;++c){var e=a[c][s](/\./g,"_")[s](/-/g,"_");ia[m](e)&&b[k](e)}return b[A](",")},U=function(a,b,c){a=a[b];!a&&c&&S("missing: "+b);if(a){if(ga[m](a))return a;S("invalid: "+b)}return null},la=/^https?:\/\/[a-z0-9_.-]+\.google\.com(:\d+)?\/[a-zA-Z0-9_.,!=\-\/]+$/,ka=/\/cb=/g,ja=/\/\//g,pa=function(){var a=K();if(!a)throw Error("Bad hint");return a};Q.m=function(a,b,c,d){(a=a[0])||S("missing_hint");return"https://apis.google.com"+oa(a,b,c,d)};var V=decodeURI("%73cript"),W=function(a,b){for(var c=[],d=0;d<a[t];++d){var e=a[d];e&&0>ba.call(b,e)&&c[k](e)}return c},qa=function(a){"loading"!=C.readyState?X(a):C.write("<"+V+' src="'+encodeURI(a)+'"></'+V+">")},X=function(a){var b=C.createElement(V);b.setAttribute("src",a);b.async="true";(a=C.getElementsByTagName(V)[0])?a.parentNode.insertBefore(b,a):(C.head||C.body||C.documentElement).appendChild(b)},ra=function(a,b){var c=b&&b._c;if(c)for(var d=0;d<R[t];d++){var e=R[d][0],h=R[d][1];h&&Object.prototype.hasOwnProperty.call(c,
e)&&h(c[e],a,b)}},sa=function(a,b){Y(function(){var c;c=b===K()?G(I,"_",H()):H();c=G(L(b),"_",c);a(c)})},$=function(a,b){var c=b||{};"function"==typeof b&&(c={},c.callback=b);ra(a,c);var d=a?a[x](":"):[],e=c.h||pa(),h=G(J,"ah",H());if(h["::"]&&d[t]){for(var l=[],p=null;p=d[n]();){var u=p[x]("."),u=h[p]||h[u[1]&&"ns:"+u[0]||""]||e,r=l[t]&&l[l[t]-1]||null,y=r;r&&r.hint==u||(y={hint:u,c:[]},l[k](y));y.c[k](p)}var z=l[t];if(1<z){var E=c.callback;E&&(c.callback=function(){0==--z&&E()})}for(;d=l[n]();)Z(d.c,
c,d.hint)}else Z(d||[],c,e)},Z=function(a,b,c){a=ca(a)||[];var d=b.callback,e=b.config,h=b.timeout,l=b.ontimeout,p=null,u=!1;if(h&&!l||!h&&l)throw"Timeout requires both the timeout parameter and ontimeout parameter to be set";var r=G(L(c),"r",[]).sort(),y=G(L(c),"L",[]).sort(),z=[].concat(r),E=function(a,b){if(u)return 0;B.clearTimeout(p);y[k].apply(y,q);var d=((I||{}).config||{}).update;d?d(e):e&&G(J,"cu",[])[k](e);if(b){P("me0",a,z);try{sa(b,c)}finally{P("me1",a,z)}}return 1};0<h&&(p=B.setTimeout(function(){u=
!0;l()},h));var q=W(a,y);if(q[t]){var q=W(a,r),v=G(J,"CP",[]),w=v[t];v[w]=function(a){if(!a)return 0;P("ml1",q,z);var b=function(b){v[w]=null;E(q,a)&&da(function(){d&&d();b()})},c=function(){var a=v[w+1];a&&a()};0<w&&v[w-1]?v[w]=function(){b(c)}:b(c)};if(q[t]){var O="loaded_"+J.I++;I[O]=function(a){v[w](a);I[O]=null};a=ma(c,q,"gapi."+O,r);r[k].apply(r,q);P("ml0",q,z);b.sync||B.___gapisync?qa(a):X(a)}else v[w](F)}else E(q)&&d&&d()};var Y=function(a){if(J.hee&&0<J.hel)try{return a()}catch(b){J.hel--,$("debug_error",function(){try{window.___jsl.hefn(b)}catch(a){throw b;}})}else return a()};I.load=function(a,b){return Y(function(){return $(a,b)})};})();
gapi.load('googleapis.proxy',{callback:function(){return window['googleapis']['server']['init'].call(this);},config:{"googleapis":{"headers":{"request":["Accept","Accept-Language","Authorization","Cache-Control","Content-Disposition","Content-Encoding","Content-Language","Content-Length","Content-MD5","Content-Range","Content-Type","Date","GData-Version","Host","If-Match","If-Modified-Since","If-None-Match","If-Unmodified-Since","Origin","OriginToken","Pragma","Range","Slug","Transfer-Encoding","X-ClientDetails","X-GData-Client","X-GData-Key","X-Goog-AuthUser","X-Goog-Encode-Response-If-Executable","X-Goog-Correlation-Id","X-Goog-Upload-Command","X-Goog-Upload-Content-Disposition","X-Goog-Upload-Content-Length","X-Goog-Upload-Content-Type","X-Goog-Upload-Offset","X-Goog-Upload-Protocol","X-Goog-Visitor-Id","X-HTTP-Method-Override","X-JavaScript-User-Agent","X-Origin","X-Referer","X-Upload-Content-Length","X-Upload-Content-Type","X-Use-HTTP-Status-Code-Override","X-YouTube-VVT","X-YouTube-Page-CL","X-YouTube-Page-Timestamp"],"response":["Cache-Control","Content-Disposition","Content-Encoding","Content-Language","Content-Length","Content-MD5","Content-Range","Content-Type","Date","ETag","Expires","Last-Modified","Location","Pragma","Range","Server","Transfer-Encoding","WWW-Authenticate","X-Goog-Safety-Content-Type","X-Goog-Safety-Encoding","X-Goog-Upload-Chunk-Granularity","X-Goog-Upload-Control-URL","X-Goog-Upload-Size-Received","X-Goog-Upload-Status","X-Goog-Upload-URL","X-Guploader-Customer","X-Guploader-Upload-Result","X-Guploader-Uploadid"]}}}});</script></head><body><div id="lcsclient" style="position:absolute;left:-10000px;"></div></body></html>