Move channel API into extension for robustness.

This commit is contained in:
burke.davey
2011-05-12 20:14:39 +00:00
parent 5ab82b3dcb
commit b6ddd2925a
4 changed files with 89 additions and 3 deletions

View File

@@ -17,7 +17,7 @@
<html>
<script src="http://chrometophone.appspot.com/_ah/channel/jsapi"></script>
<script src="channel.js"></script>
<script src="chrome_ex_oauthsimple.js"></script>
<script src="chrome_ex_oauth.js"></script>
<script src="send_logic.js"></script>

85
extension/channel.js Normal file
View File

@@ -0,0 +1,85 @@
// Snapshot on 05/12/2011 of http://chrometophone.appspot.com/_ah/channel/jsapi
(function() { function h(a){throw a;}
var i=void 0,k=null,n,o=this,aa=function(a){for(var a=a.split("."),b=o,c;c=a.shift();)if(b[c]!=k)b=b[c];else return k;return b},ba=function(){},ca=function(a){var b=typeof a;if(b=="object")if(a){if(a instanceof Array)return"array";else if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if(c=="[object Window]")return"object";if(c=="[object Array]"||typeof a.length=="number"&&typeof a.splice!="undefined"&&typeof a.propertyIsEnumerable!="undefined"&&!a.propertyIsEnumerable("splice"))return"array";if(c==
"[object Function]"||typeof a.call!="undefined"&&typeof a.propertyIsEnumerable!="undefined"&&!a.propertyIsEnumerable("call"))return"function"}else return"null";else if(b=="function"&&typeof a.call=="undefined")return"object";return b},p=function(a){return ca(a)=="array"},q=function(a){var b=ca(a);return b=="array"||b=="object"&&typeof a.length=="number"},s=function(a){return typeof a=="string"},da=function(a){return ca(a)=="function"},ea=function(a){a=ca(a);return a=="object"||a=="array"||a=="function"},
ha=function(a){return a[fa]||(a[fa]=++ga)},fa="closure_uid_"+Math.floor(Math.random()*2147483648).toString(36),ga=0,ia=function(a){return a.call.apply(a.bind,arguments)},ja=function(a,b){var c=b||o;if(arguments.length>2){var d=Array.prototype.slice.call(arguments,2);return function(){var b=Array.prototype.slice.call(arguments);Array.prototype.unshift.apply(b,d);return a.apply(c,b)}}else return function(){return a.apply(c,arguments)}},t=function(){t=Function.prototype.bind&&Function.prototype.bind.toString().indexOf("native code")!=
-1?ia:ja;return t.apply(k,arguments)},ka=function(a){var b=Array.prototype.slice.call(arguments,1);return function(){var c=Array.prototype.slice.call(arguments);c.unshift.apply(c,b);return a.apply(this,c)}},la=Date.now||function(){return+new Date},v=function(a,b){var c=a.split("."),d=o;!(c[0]in d)&&d.execScript&&d.execScript("var "+c[0]);for(var e;c.length&&(e=c.shift());)!c.length&&b!==i?d[e]=b:d=d[e]?d[e]:d[e]={}},w=function(a,b){function c(){}c.prototype=b.prototype;a.A=b.prototype;a.prototype=
new c;a.prototype.constructor=a};Function.prototype.bind=Function.prototype.bind||function(a){if(arguments.length>1){var b=Array.prototype.slice.call(arguments,1);b.unshift(this,a);return t.apply(k,b)}else return t(this,a)};var x=function(){};x.prototype.ia=!1;x.prototype.H=function(){if(!this.ia)this.ia=!0,this.i()};x.prototype.i=function(){};var ma=function(a){this.stack=Error().stack||"";if(a)this.message=String(a)};w(ma,Error);ma.prototype.name="CustomError";var na=function(a){for(var b=1;b<arguments.length;b++)var c=String(arguments[b]).replace(/\$/g,"$$$$"),a=a.replace(/\%s/,c);return a},oa=/^[a-zA-Z0-9\-_.!~*'()]*$/,pa=function(a){a=String(a);if(!oa.test(a))return encodeURIComponent(a);return a},va=function(a){if(!qa.test(a))return a;a.indexOf("&")!=-1&&(a=a.replace(ra,"&amp;"));a.indexOf("<")!=-1&&(a=a.replace(sa,"&lt;"));a.indexOf(">")!=-1&&(a=a.replace(ta,"&gt;"));a.indexOf('"')!=-1&&(a=a.replace(ua,"&quot;"));return a},ra=/&/g,sa=/</g,ta=/>/g,
ua=/\"/g,qa=/[&<>\"]/,xa=function(a,b){for(var c=0,d=String(a).replace(/^[\s\xa0]+|[\s\xa0]+$/g,"").split("."),e=String(b).replace(/^[\s\xa0]+|[\s\xa0]+$/g,"").split("."),f=Math.max(d.length,e.length),g=0;c==0&&g<f;g++){var j=d[g]||"",l=e[g]||"",m=RegExp("(\\d*)(\\D*)","g"),u=RegExp("(\\d*)(\\D*)","g");do{var r=m.exec(j)||["","",""],D=u.exec(l)||["","",""];if(r[0].length==0&&D[0].length==0)break;c=wa(r[1].length==0?0:parseInt(r[1],10),D[1].length==0?0:parseInt(D[1],10))||wa(r[2].length==0,D[2].length==
0)||wa(r[2],D[2])}while(c==0)}return c},wa=function(a,b){if(a<b)return-1;else if(a>b)return 1;return 0};var ya=function(a,b){b.unshift(a);ma.call(this,na.apply(k,b));b.shift();this.sc=a};w(ya,ma);ya.prototype.name="AssertionError";var za=function(a,b){if(!a){var c=Array.prototype.slice.call(arguments,2),d="Assertion failed";if(b){d+=": "+b;var e=c}h(new ya(""+d,e||[]))}},Aa=function(a){h(new ya("Failure"+(a?": "+a:""),Array.prototype.slice.call(arguments,1)))};var y=Array.prototype,Ba=y.indexOf?function(a,b,c){za(a.length!=k);return y.indexOf.call(a,b,c)}:function(a,b,c){c=c==k?0:c<0?Math.max(0,a.length+c):c;if(s(a)){if(!s(b)||b.length!=1)return-1;return a.indexOf(b,c)}for(;c<a.length;c++)if(c in a&&a[c]===b)return c;return-1},Ca=y.forEach?function(a,b,c){za(a.length!=k);y.forEach.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=s(a)?a.split(""):a,f=0;f<d;f++)f in e&&b.call(c,e[f],f,a)},Da=function(a,b){var c=Ba(a,b);c>=0&&(za(a.length!=k),y.splice.call(a,
c,1))},Ea=function(){return y.concat.apply(y,arguments)},Fa=function(a){if(p(a))return Ea(a);else{for(var b=[],c=0,d=a.length;c<d;c++)b[c]=a[c];return b}},Ga=function(a){for(var b=1;b<arguments.length;b++){var c=arguments[b],d;if(p(c)||(d=q(c))&&c.hasOwnProperty("callee"))a.push.apply(a,c);else if(d)for(var e=a.length,f=c.length,g=0;g<f;g++)a[e+g]=c[g];else a.push(c)}},Ha=function(a,b,c){za(a.length!=k);return arguments.length<=2?y.slice.call(a,b):y.slice.call(a,b,c)};var Ia=function(a,b){for(var c in a)b.call(i,a[c],c,a)},Ja=function(a){var b=[],c=0,d;for(d in a)b[c++]=a[d];return b},Ka=function(a){var b=[],c=0,d;for(d in a)b[c++]=d;return b},La=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Ma=function(a){for(var b,c,d=1;d<arguments.length;d++){c=arguments[d];for(b in c)a[b]=c[b];for(var e=0;e<La.length;e++)b=La[e],Object.prototype.hasOwnProperty.call(c,b)&&(a[b]=c[b])}};var Na,Oa,Pa,Qa,Ra=function(){return o.navigator?o.navigator.userAgent:k};Qa=Pa=Oa=Na=!1;var Sa;if(Sa=Ra()){var Ta=o.navigator;Na=Sa.indexOf("Opera")==0;Oa=!Na&&Sa.indexOf("MSIE")!=-1;Pa=!Na&&Sa.indexOf("WebKit")!=-1;Qa=!Na&&!Pa&&Ta.product=="Gecko"}var z=Oa,Ua=Qa,A=Pa,Va=o.navigator,Wa=(Va&&Va.platform||"").indexOf("Mac")!=-1,Xa;
a:{var Ya="",Za;if(Na&&o.opera)var $a=o.opera.version,Ya=typeof $a=="function"?$a():$a;else if(Ua?Za=/rv\:([^\);]+)(\)|;)/:z?Za=/MSIE\s+([^\);]+)(\)|;)/:A&&(Za=/WebKit\/(\S+)/),Za)var ab=Za.exec(Ra()),Ya=ab?ab[1]:"";if(z){var bb,cb=o.document;bb=cb?cb.documentMode:i;if(bb>parseFloat(Ya)){Xa=String(bb);break a}}Xa=Ya}var db=Xa,eb={},B=function(a){return eb[a]||(eb[a]=xa(db,a)>=0)};var fb,gb=!z||B("9");!Ua&&!z||z&&B("9")||Ua&&B("1.9.1");z&&B("9");var hb=function(a){var b;b=(b=a.className)&&typeof b.split=="function"?b.split(/\s+/):[];var c=Ha(arguments,1),d;d=b;for(var e=0,f=0;f<c.length;f++)Ba(d,c[f])>=0||(d.push(c[f]),e++);d=e==c.length;a.className=b.join(" ");return d};var C=function(a){return a?new ib(a.nodeType==9?a:a.ownerDocument||a.document):fb||(fb=new ib)},jb=function(a,b){var c=b&&b!="*"?b.toUpperCase():"";if(a.querySelectorAll&&a.querySelector&&(!A||document.compatMode=="CSS1Compat"||B("528"))&&c)return a.querySelectorAll(c+"");return a.getElementsByTagName(c||"*")},lb=function(a,b){Ia(b,function(b,d){d=="style"?a.style.cssText=b:d=="class"?a.className=b:d=="for"?a.htmlFor=b:d in kb?a.setAttribute(kb[d],b):a[d]=b})},kb={cellpadding:"cellPadding",cellspacing:"cellSpacing",
colspan:"colSpan",rowspan:"rowSpan",valign:"vAlign",height:"height",width:"width",usemap:"useMap",frameborder:"frameBorder",maxlength:"maxLength",type:"type"},nb=function(a,b,c){function d(c){c&&b.appendChild(s(c)?a.createTextNode(c):c)}for(var e=2;e<c.length;e++){var f=c[e];q(f)&&!(ea(f)&&f.nodeType>0)?Ca(mb(f)?Fa(f):f,d):d(f)}},ob=function(a){return a&&a.parentNode?a.parentNode.removeChild(a):k},mb=function(a){if(a&&typeof a.length=="number")if(ea(a))return typeof a.item=="function"||typeof a.item==
"string";else if(da(a))return typeof a.item=="function";return!1},ib=function(a){this.u=a||o.document||document};n=ib.prototype;n.rb=function(){var a=this.u,b=arguments,c=b[0],d=b[1];if(!gb&&d&&(d.name||d.type)){c=["<",c];d.name&&c.push(' name="',va(d.name),'"');if(d.type){c.push(' type="',va(d.type),'"');var e={};Ma(e,d);d=e;delete d.type}c.push(">");c=c.join("")}c=a.createElement(c);if(d)s(d)?c.className=d:p(d)?hb.apply(k,[c].concat(d)):lb(c,d);b.length>2&&nb(a,c,b);return c};n.createElement=function(a){return this.u.createElement(a)};
n.createTextNode=function(a){return this.u.createTextNode(a)};n.e=function(){return this.u.parentWindow||this.u.defaultView};n.appendChild=function(a,b){a.appendChild(b)};n.removeNode=ob;var pb=new Function("a","return a"),qb=function(a,b){try{return pb(a[b]),!0}catch(c){}return!1};var rb;!z||B("9");z&&B("8");var sb=function(a,b){this.type=a;this.currentTarget=this.target=b};w(sb,x);sb.prototype.i=function(){delete this.type;delete this.target;delete this.currentTarget};sb.prototype.Na=!1;sb.prototype.hc=!0;var tb=function(a,b){a&&this.oa(a,b)};w(tb,sb);n=tb.prototype;n.target=k;n.relatedTarget=k;n.offsetX=0;n.offsetY=0;n.clientX=0;n.clientY=0;n.screenX=0;n.screenY=0;n.button=0;n.keyCode=0;n.charCode=0;n.ctrlKey=!1;n.altKey=!1;n.shiftKey=!1;n.metaKey=!1;n.gc=!1;n.qa=k;
n.oa=function(a,b){var c=this.type=a.type;sb.call(this,c);this.target=a.target||a.srcElement;this.currentTarget=b;var d=a.relatedTarget;if(d)Ua&&(qb(d,"nodeName")||(d=k));else if(c=="mouseover")d=a.fromElement;else if(c=="mouseout")d=a.toElement;this.relatedTarget=d;this.offsetX=a.offsetX!==i?a.offsetX:a.layerX;this.offsetY=a.offsetY!==i?a.offsetY:a.layerY;this.clientX=a.clientX!==i?a.clientX:a.pageX;this.clientY=a.clientY!==i?a.clientY:a.pageY;this.screenX=a.screenX||0;this.screenY=a.screenY||0;
this.button=a.button;this.keyCode=a.keyCode||0;this.charCode=a.charCode||(c=="keypress"?a.keyCode:0);this.ctrlKey=a.ctrlKey;this.altKey=a.altKey;this.shiftKey=a.shiftKey;this.metaKey=a.metaKey;this.gc=Wa?a.metaKey:a.ctrlKey;this.state=a.state;this.qa=a;delete this.hc;delete this.Na};n.i=function(){tb.A.i.call(this);this.relatedTarget=this.currentTarget=this.target=this.qa=k};var E=function(a,b){this.Bb=b;this.N=[];a>this.Bb&&h(Error("[goog.structs.SimplePool] Initial cannot be greater than max"));for(var c=0;c<a;c++)this.N.push(this.D?this.D():{})};w(E,x);E.prototype.D=k;E.prototype.Eb=k;E.prototype.getObject=function(){if(this.N.length)return this.N.pop();return this.D?this.D():{}};var vb=function(a,b){a.N.length<a.Bb?a.N.push(b):ub(a,b)},ub=function(a,b){if(a.Eb)a.Eb(b);else if(ea(b))if(da(b.H))b.H();else for(var c in b)delete b[c]};
E.prototype.i=function(){E.A.i.call(this);for(var a=this.N;a.length;)ub(this,a.pop());delete this.N};var wb,xb=(wb="ScriptEngine"in o&&o.ScriptEngine()=="JScript")?o.ScriptEngineMajorVersion()+"."+o.ScriptEngineMinorVersion()+"."+o.ScriptEngineBuildVersion():"0";var yb=function(){},zb=0;n=yb.prototype;n.key=0;n.Y=!1;n.zb=!1;n.oa=function(a,b,c,d,e,f){da(a)?this.yb=!0:a&&a.handleEvent&&da(a.handleEvent)?this.yb=!1:h(Error("Invalid listener argument"));this.ga=a;this.pb=b;this.src=c;this.type=d;this.capture=!!e;this.Ka=f;this.zb=!1;this.key=++zb;this.Y=!1};n.handleEvent=function(a){if(this.yb)return this.ga.call(this.Ka||this.src,a);return this.ga.handleEvent.call(this.ga,a)};var Ab,Bb,Cb,Db,Eb,Fb,Gb,Hb,Ib,Jb,Kb;
(function(){function a(){return{g:0,W:0}}function b(){return[]}function c(){var a=function(b){return g.call(a.src,a.key,b)};return a}function d(){return new yb}function e(){return new tb}var f=wb&&!(xa(xb,"5.7")>=0),g;Fb=function(a){g=a};if(f){Ab=function(){return j.getObject()};Bb=function(a){vb(j,a)};Cb=function(){return l.getObject()};Db=function(a){vb(l,a)};Eb=function(){return m.getObject()};Gb=function(){vb(m,c())};Hb=function(){return u.getObject()};Ib=function(a){vb(u,a)};Jb=function(){return r.getObject()};
Kb=function(a){vb(r,a)};var j=new E(0,600);j.D=a;var l=new E(0,600);l.D=b;var m=new E(0,600);m.D=c;var u=new E(0,600);u.D=d;var r=new E(0,600);r.D=e}else Ab=a,Bb=ba,Cb=b,Db=ba,Eb=c,Gb=ba,Hb=d,Ib=ba,Jb=e,Kb=ba})();var Lb={},G={},Mb={},Nb={},Ob=function(a,b,c,d,e){if(b)if(p(b))for(var f=0;f<b.length;f++)Ob(a,b[f],c,d,e);else{var d=!!d,g=G;b in g||(g[b]=Ab());g=g[b];d in g||(g[d]=Ab(),g.g++);var g=g[d],j=ha(a),l;g.W++;if(g[j]){l=g[j];for(f=0;f<l.length;f++)if(g=l[f],g.ga==c&&g.Ka==e){if(g.Y)break;return}}else l=g[j]=Cb(),g.g++;f=Eb();f.src=a;g=Hb();g.oa(c,f,a,b,d,e);c=g.key;f.key=c;l.push(g);Lb[c]=g;Mb[j]||(Mb[j]=Cb());Mb[j].push(g);a.addEventListener?(a==o||!a.Yb)&&a.addEventListener(b,f,d):a.attachEvent(Pb(b),
f)}else h(Error("Invalid event type"))},Qb=function(a,b,c,d,e){if(p(b))for(var f=0;f<b.length;f++)Qb(a,b[f],c,d,e);else{d=!!d;a:{f=G;if(b in f&&(f=f[b],d in f&&(f=f[d],a=ha(a),f[a]))){a=f[a];break a}a=k}if(a)for(f=0;f<a.length;f++)if(a[f].ga==c&&a[f].capture==d&&a[f].Ka==e){Rb(a[f].key);break}}},Rb=function(a){if(Lb[a]){var b=Lb[a];if(!b.Y){var c=b.src,d=b.type,e=b.pb,f=b.capture;c.removeEventListener?(c==o||!c.Yb)&&c.removeEventListener(d,e,f):c.detachEvent&&c.detachEvent(Pb(d),e);c=ha(c);e=G[d][f][c];
if(Mb[c]){var g=Mb[c];Da(g,b);g.length==0&&delete Mb[c]}b.Y=!0;e.sb=!0;Sb(d,f,c,e);delete Lb[a]}}},Sb=function(a,b,c,d){if(!d.va&&d.sb){for(var e=0,f=0;e<d.length;e++)if(d[e].Y){var g=d[e].pb;g.src=k;Gb(g);Ib(d[e])}else e!=f&&(d[f]=d[e]),f++;d.length=f;d.sb=!1;f==0&&(Db(d),delete G[a][b][c],G[a][b].g--,G[a][b].g==0&&(Bb(G[a][b]),delete G[a][b],G[a].g--),G[a].g==0&&(Bb(G[a]),delete G[a]))}},Pb=function(a){if(a in Nb)return Nb[a];return Nb[a]="on"+a},Ub=function(a,b,c,d,e){var f=1,b=ha(b);if(a[b]){a.W--;
a=a[b];a.va?a.va++:a.va=1;try{for(var g=a.length,j=0;j<g;j++){var l=a[j];l&&!l.Y&&(f&=Tb(l,e)!==!1)}}finally{a.va--,Sb(c,d,b,a)}}return Boolean(f)},Tb=function(a,b){var c=a.handleEvent(b);a.zb&&Rb(a.key);return c};
Fb(function(a,b){if(!Lb[a])return!0;var c=Lb[a],d=c.type,e=G;if(!(d in e))return!0;var e=e[d],f,g;rb===i&&(rb=z&&!o.addEventListener);if(rb){f=b||aa("window.event");var j=!0 in e,l=!1 in e;if(j){if(f.keyCode<0||f.returnValue!=i)return!0;a:{var m=!1;if(f.keyCode==0)try{f.keyCode=-1;break a}catch(u){m=!0}if(m||f.returnValue==i)f.returnValue=!0}}m=Jb();m.oa(f,this);f=!0;try{if(j){for(var r=Cb(),D=m.currentTarget;D;D=D.parentNode)r.push(D);g=e[!0];g.W=g.g;for(var F=r.length-1;!m.Na&&F>=0&&g.W;F--)m.currentTarget=
r[F],f&=Ub(g,r[F],d,!0,m);if(l){g=e[!1];g.W=g.g;for(F=0;!m.Na&&F<r.length&&g.W;F++)m.currentTarget=r[F],f&=Ub(g,r[F],d,!1,m)}}else f=Tb(c,m)}finally{if(r)r.length=0,Db(r);m.H();Kb(m)}return f}d=new tb(b,this);try{f=Tb(c,d)}finally{d.H()}return f});var Vb=function(a){var a=String(a),b;b=/^\s*$/.test(a)?!1:/^[\],:{}\s\u2028\u2029]*$/.test(a.replace(/\\["\\\/bfnrtu]/g,"@").replace(/"[^"\\\n\r\u2028\u2029\x00-\x08\x10-\x1f\x80-\x9f]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:[\s\u2028\u2029]*\[)+/g,""));if(b)try{return eval("("+a+")")}catch(c){}h(Error("Invalid JSON string: "+a))},Wb=function(){},Yb=function(a,b){var c=[];Xb(a,b,c);return c.join("")},Xb=function(a,b,c){switch(typeof b){case "string":Zb(b,c);
break;case "number":c.push(isFinite(b)&&!isNaN(b)?b:"null");break;case "boolean":c.push(b);break;case "undefined":c.push("null");break;case "object":if(b==k){c.push("null");break}if(p(b)){var d=b.length;c.push("[");for(var e="",f=0;f<d;f++)c.push(e),Xb(a,b[f],c),e=",";c.push("]");break}c.push("{");d="";for(e in b)Object.prototype.hasOwnProperty.call(b,e)&&(f=b[e],typeof f!="function"&&(c.push(d),Zb(e,c),c.push(":"),Xb(a,f,c),d=","));c.push("}");break;case "function":break;default:h(Error("Unknown type: "+
typeof b))}},$b={'"':'\\"',"\\":"\\\\","/":"\\/","\u0008":"\\b","\u000c":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\u000b":"\\u000b"},ac=/\uffff/.test("\uffff")?/[\\\"\x00-\x1f\x7f-\uffff]/g:/[\\\"\x00-\x1f\x7f-\xff]/g,Zb=function(a,b){b.push('"',a.replace(ac,function(a){if(a in $b)return $b[a];var b=a.charCodeAt(0),e="\\u";b<16?e+="000":b<256?e+="00":b<4096&&(e+="0");return $b[a]=e+b.toString(16)}),'"')};var bc="StopIteration"in o?o.StopIteration:Error("StopIteration"),cc=function(){};cc.prototype.next=function(){h(bc)};cc.prototype.kc=function(){return this};var dc=function(a){if(typeof a.K=="function")return a.K();if(s(a))return a.split("");if(q(a)){for(var b=[],c=a.length,d=0;d<c;d++)b.push(a[d]);return b}return Ja(a)},ec=function(a,b,c){if(typeof a.forEach=="function")a.forEach(b,c);else if(q(a)||s(a))Ca(a,b,c);else{var d;if(typeof a.Z=="function")d=a.Z();else if(typeof a.K!="function")if(q(a)||s(a)){d=[];for(var e=a.length,f=0;f<e;f++)d.push(f)}else d=Ka(a);else d=i;for(var e=dc(a),f=e.length,g=0;g<f;g++)b.call(c,e[g],d&&d[g],a)}};var H=function(a){this.z={};this.j=[];var b=arguments.length;if(b>1){b%2&&h(Error("Uneven number of arguments"));for(var c=0;c<b;c+=2)this.set(arguments[c],arguments[c+1])}else if(a){a instanceof H?(b=a.Z(),c=a.K()):(b=Ka(a),c=Ja(a));for(var d=0;d<b.length;d++)this.set(b[d],c[d])}};n=H.prototype;n.g=0;n.pa=0;n.K=function(){fc(this);for(var a=[],b=0;b<this.j.length;b++)a.push(this.z[this.j[b]]);return a};n.Z=function(){fc(this);return this.j.concat()};n.L=function(a){return gc(this.z,a)};
n.remove=function(a){if(gc(this.z,a))return delete this.z[a],this.g--,this.pa++,this.j.length>2*this.g&&fc(this),!0;return!1};var fc=function(a){if(a.g!=a.j.length){for(var b=0,c=0;b<a.j.length;){var d=a.j[b];gc(a.z,d)&&(a.j[c++]=d);b++}a.j.length=c}if(a.g!=a.j.length){for(var e={},c=b=0;b<a.j.length;)d=a.j[b],gc(e,d)||(a.j[c++]=d,e[d]=1),b++;a.j.length=c}};H.prototype.get=function(a,b){if(gc(this.z,a))return this.z[a];return b};
H.prototype.set=function(a,b){gc(this.z,a)||(this.g++,this.j.push(a),this.pa++);this.z[a]=b};H.prototype.ca=function(){return new H(this)};H.prototype.kc=function(a){fc(this);var b=0,c=this.j,d=this.z,e=this.pa,f=this,g=new cc;g.next=function(){for(;;){e!=f.pa&&h(Error("The map has changed since the iterator was created"));b>=c.length&&h(bc);var g=c[b++];return a?g:d[g]}};return g};var gc=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)};var ic=function(a){return hc(a||arguments.callee.caller,[])},hc=function(a,b){var c=[];if(Ba(b,a)>=0)c.push("[...circular reference...]");else if(a&&b.length<50){c.push(jc(a)+"(");for(var d=a.arguments,e=0;e<d.length;e++){e>0&&c.push(", ");var f;f=d[e];switch(typeof f){case "object":f=f?"object":"null";break;case "string":break;case "number":f=String(f);break;case "boolean":f=f?"true":"false";break;case "function":f=(f=jc(f))?f:"[fn]";break;default:f=typeof f}f.length>40&&(f=f.substr(0,40)+"...");
c.push(f)}b.push(a);c.push(")\n");try{c.push(hc(a.caller,b))}catch(g){c.push("[exception trying to get caller]\n")}}else a?c.push("[...long stack...]"):c.push("[end]");return c.join("")},jc=function(a){a=String(a);if(!kc[a]){var b=/function ([^\(]+)/.exec(a);kc[a]=b?b[1]:"[Anonymous]"}return kc[a]},kc={};var lc=function(a,b,c,d,e){this.reset(a,b,c,d,e)};lc.prototype.sa=0;lc.prototype.xb=k;lc.prototype.wb=k;var mc=0;lc.prototype.reset=function(a,b,c,d,e){this.sa=typeof e=="number"?e:mc++;this.pc=d||la();this.ha=a;this.fc=b;this.oc=c;delete this.xb;delete this.wb};lc.prototype.Db=function(a){this.ha=a};var I=function(a){this.Fb=a};I.prototype.ya=k;I.prototype.ha=k;I.prototype.Ra=k;I.prototype.Jb=k;var nc=function(a,b){this.name=a;this.value=b};nc.prototype.toString=function(){return this.name};var J=new nc("SEVERE",1E3),oc=new nc("WARNING",900),pc=new nc("INFO",800),qc=new nc("CONFIG",700),rc=new nc("FINE",500),sc=new nc("FINEST",300);I.prototype.getName=function(){return this.Fb};I.prototype.getParent=function(){return this.ya};I.prototype.Db=function(a){this.ha=a};
var tc=function(a){if(a.ha)return a.ha;if(a.ya)return tc(a.ya);Aa("Root logger has no level set.");return k};I.prototype.log=function(a,b,c){if(a.value>=tc(this).value){a=this.jc(a,b,c);o.console&&o.console.markTimeline&&o.console.markTimeline("log:"+a.fc);for(b=this;b;){var c=b,d=a;if(c.Jb)for(var e=0,f=i;f=c.Jb[e];e++)f(d);b=b.getParent()}}};
I.prototype.jc=function(a,b,c){var d=new lc(a,String(b),this.Fb);if(c){d.xb=c;var e;var f=arguments.callee.caller;try{var g;var j=aa("window.location.href");if(s(c))g={message:c,name:"Unknown error",lineNumber:"Not available",fileName:j,stack:"Not available"};else{var l,m,u=!1;try{l=c.lineNumber||c.qc||"Not available"}catch(r){l="Not available",u=!0}try{m=c.fileName||c.filename||c.sourceURL||j}catch(D){m="Not available",u=!0}g=u||!c.lineNumber||!c.fileName||!c.stack?{message:c.message,name:c.name,
lineNumber:l,fileName:m,stack:c.stack||"Not available"}:c}e="Message: "+va(g.message)+'\nUrl: <a href="view-source:'+g.fileName+'" target="_new">'+g.fileName+"</a>\nLine: "+g.lineNumber+"\n\nBrowser stack:\n"+va(g.stack+"-> ")+"[end]\n\nJS stack traversal:\n"+va(ic(f)+"-> ")}catch(F){e="Exception trying to expose exception! You win, we lose. "+F}d.wb=e}return d};var K=function(a,b){a.log(oc,b,i)};I.prototype.info=function(a,b){this.log(pc,a,b)};
var L=function(a,b){a.log(rc,b,i)},M=function(a,b){a.log(sc,b,i)},uc={},vc=k,wc=function(a){vc||(vc=new I(""),uc[""]=vc,vc.Db(qc));var b;if(!(b=uc[a])){b=new I(a);var c=a.lastIndexOf("."),d=a.substr(c+1),c=wc(a.substr(0,c));if(!c.Ra)c.Ra={};c.Ra[d]=b;b.ya=c;uc[a]=b}return b};var xc=function(){this.ja={}};w(xc,x);xc.prototype.la=wc("goog.messaging.AbstractChannel");xc.prototype.t=function(a){a&&a()};xc.prototype.q=function(){return!0};var yc=function(a,b,c){a.ja[b]={kb:c,lb:!1}};xc.prototype.i=function(){xc.A.i.call(this);var a=this.la;a&&typeof a.H=="function"&&a.H();delete this.la;delete this.ja;delete this.Ya};var zc=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^/?#]*)@)?([\\w\\d\\-\\u0100-\\uffff.%]*)(?::([0-9]+))?)?([^?#]+)?(?:\\?([^#]*))?(?:#(.*))?$"),Ac=function(a){var b=a.match(zc),a=b[1],c=b[2],d=b[3],b=b[4],e=[];a&&e.push(a,":");d&&(e.push("//"),c&&e.push(c,"@"),e.push(d),b&&e.push(":",b));return e.join("")};var N=function(a,b){var c;a instanceof N?(this.V(b==k?a.v:b),O(this,a.n),Bc(this,a.fa),Cc(this,a.J),Dc(this,a.G),Ec(this,a.U),Fc(this,a.w.ca()),Gc(this,a.ea)):a&&(c=String(a).match(zc))?(this.V(!!b),O(this,c[1]||"",!0),Bc(this,c[2]||"",!0),Cc(this,c[3]||"",!0),Dc(this,c[4]),Ec(this,c[5]||"",!0),Fc(this,c[6]||"",!0),Gc(this,c[7]||"",!0)):(this.V(!!b),this.w=new Hc(k,this,this.v))};n=N.prototype;n.n="";n.fa="";n.J="";n.G=k;n.U="";n.ea="";n.lc=!1;n.v=!1;
n.toString=function(){if(this.r)return this.r;var a=[];this.n&&a.push(Ic(this.n,Jc),":");if(this.J){a.push("//");this.fa&&a.push(Ic(this.fa,Jc),"@");var b;b=this.J;b=s(b)?encodeURIComponent(b):k;a.push(b);this.G!=k&&a.push(":",String(this.G))}this.U&&(this.J&&this.U.charAt(0)!="/"&&a.push("/"),a.push(Ic(this.U,Kc)));(b=String(this.w))&&a.push("?",b);this.ea&&a.push("#",Ic(this.ea,Lc));return this.r=a.join("")};
n.ca=function(){var a=this.n,b=this.fa,c=this.J,d=this.G,e=this.U,f=this.w.ca(),g=this.ea,j=new N(k,this.v);a&&O(j,a);b&&Bc(j,b);c&&Cc(j,c);d&&Dc(j,d);e&&Ec(j,e);f&&Fc(j,f);g&&Gc(j,g);return j};
var O=function(a,b,c){P(a);delete a.r;a.n=c?b?decodeURIComponent(b):"":b;if(a.n)a.n=a.n.replace(/:$/,"")},Bc=function(a,b,c){P(a);delete a.r;a.fa=c?b?decodeURIComponent(b):"":b},Cc=function(a,b,c){P(a);delete a.r;a.J=c?b?decodeURIComponent(b):"":b},Dc=function(a,b){P(a);delete a.r;b?(b=Number(b),(isNaN(b)||b<0)&&h(Error("Bad port number "+b)),a.G=b):a.G=k},Ec=function(a,b,c){P(a);delete a.r;a.U=c?b?decodeURIComponent(b):"":b},Fc=function(a,b,c){P(a);delete a.r;b instanceof Hc?(a.w=b,a.w.La=a,a.w.V(a.v)):
(c||(b=Ic(b,Mc)),a.w=new Hc(b,a,a.v))},Nc=function(a,b,c){P(a);delete a.r;a.w.set(b,c)},Gc=function(a,b,c){P(a);delete a.r;a.ea=c?b?decodeURIComponent(b):"":b},P=function(a){a.lc&&h(Error("Tried to modify a read-only Uri"))};N.prototype.V=function(a){this.v=a;this.w&&this.w.V(a);return this};
var Oc=/^[a-zA-Z0-9\-_.!~*'():\/;?]*$/,Ic=function(a,b){var c=k;s(a)&&(c=a,Oc.test(c)||(c=encodeURI(a)),c.search(b)>=0&&(c=c.replace(b,Pc)));return c},Pc=function(a){a=a.charCodeAt(0);return"%"+(a>>4&15).toString(16)+(a&15).toString(16)},Jc=/[#\/\?@]/g,Kc=/[\#\?]/g,Mc=/[\#\?@]/g,Lc=/#/g,Hc=function(a,b,c){this.C=a||k;this.La=b||k;this.v=!!c},Q=function(a){if(!a.f&&(a.f=new H,a.C))for(var b=a.C.split("&"),c=0;c<b.length;c++){var d=b[c].indexOf("="),e=k,f=k;d>=0?(e=b[c].substring(0,d),f=b[c].substring(d+
1)):e=b[c];e=decodeURIComponent(e.replace(/\+/g," "));e=Qc(a,e);a.add(e,f?decodeURIComponent(f.replace(/\+/g," ")):"")}};n=Hc.prototype;n.f=k;n.g=k;n.add=function(a,b){Q(this);Rc(this);a=Qc(this,a);if(this.L(a)){var c=this.f.get(a);p(c)?c.push(b):this.f.set(a,[c,b])}else this.f.set(a,b);this.g++;return this};n.remove=function(a){Q(this);a=Qc(this,a);if(this.f.L(a)){Rc(this);var b=this.f.get(a);p(b)?this.g-=b.length:this.g--;return this.f.remove(a)}return!1};n.L=function(a){Q(this);a=Qc(this,a);return this.f.L(a)};
n.Z=function(){Q(this);for(var a=this.f.K(),b=this.f.Z(),c=[],d=0;d<b.length;d++){var e=a[d];if(p(e))for(var f=0;f<e.length;f++)c.push(b[d]);else c.push(b[d])}return c};n.K=function(a){Q(this);if(a)if(a=Qc(this,a),this.L(a)){var b=this.f.get(a);if(p(b))return b;else a=[],a.push(b)}else a=[];else for(var b=this.f.K(),a=[],c=0;c<b.length;c++){var d=b[c];p(d)?Ga(a,d):a.push(d)}return a};
n.set=function(a,b){Q(this);Rc(this);a=Qc(this,a);if(this.L(a)){var c=this.f.get(a);p(c)?this.g-=c.length:this.g--}this.f.set(a,b);this.g++;return this};n.get=function(a,b){Q(this);a=Qc(this,a);if(this.L(a)){var c=this.f.get(a);return p(c)?c[0]:c}else return b};
n.toString=function(){if(this.C)return this.C;if(!this.f)return"";for(var a=[],b=0,c=this.f.Z(),d=0;d<c.length;d++){var e=c[d],f=pa(e),e=this.f.get(e);if(p(e))for(var g=0;g<e.length;g++)b>0&&a.push("&"),a.push(f),e[g]!==""&&a.push("=",pa(e[g])),b++;else b>0&&a.push("&"),a.push(f),e!==""&&a.push("=",pa(e)),b++}return this.C=a.join("")};var Rc=function(a){delete a.Ma;delete a.C;a.La&&delete a.La.r};
Hc.prototype.ca=function(){var a=new Hc;if(this.Ma)a.Ma=this.Ma;if(this.C)a.C=this.C;if(this.f)a.f=this.f.ca();return a};var Qc=function(a,b){var c=String(b);a.v&&(c=c.toLowerCase());return c};Hc.prototype.V=function(a){a&&!this.v&&(Q(this),Rc(this),ec(this.f,function(a,c){var d=c.toLowerCase();c!=d&&(this.remove(c),this.add(d,a))},this));this.v=a};var Sc={"1":"NativeMessagingTransport","2":"FrameElementMethodTransport","3":"IframeRelayTransport","4":"IframePollingTransport","5":"FlashTransport","6":"NixTransport"},Tc=["pu","lru","pru","lpu","ppu"],R={},Vc=function(a){for(var b=Uc,c=b.length,d="";a-- >0;)d+=b.charAt(Math.floor(Math.random()*c));return d},Uc="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",S=wc("goog.net.xpc");var T=function(a){this.l=a||C()};w(T,x);T.prototype.aa=0;T.prototype.e=function(){return this.l.e()};T.prototype.getName=function(){return Sc[this.aa]||""};var Wc=function(a,b){this.l=b||C();this.a=a;this.da=[];this.Pb=t(this.Xb,this)};w(Wc,T);n=Wc.prototype;n.aa=2;n.Ga=!1;n.Tb=0;n.t=function(){Xc(this.a)==0?(this.B=this.a.P,this.B.XPC_toOuter=t(this.eb,this)):this.cb()};
n.cb=function(){var a=!0;try{if(!this.B)this.B=this.e().frameElement;if(this.B&&this.B.XPC_toOuter)this.Da=this.B.XPC_toOuter,this.B.XPC_toOuter.XPC_toInner=t(this.eb,this),a=!1,this.send("tp","SETUP_ACK"),U(this.a)}catch(b){S.log(J,"exception caught while attempting setup: "+b,i)}if(a){if(!this.ib)this.ib=t(this.cb,this);this.e().setTimeout(this.ib,100)}};n.Ia=function(a){Xc(this.a)==0&&!this.a.q()&&a=="SETUP_ACK"?(this.Da=this.B.XPC_toOuter.XPC_toInner,U(this.a)):h(Error("Got unexpected transport message."))};
n.eb=function(a,b){if(!this.Ga&&this.da.length==0)V(this.a,a,b);else if(this.da.push({Sb:a,Ea:b}),this.da.length==1)this.Tb=this.e().setTimeout(this.Pb,1)};n.Xb=function(){for(;this.da.length;){var a=this.da.shift();V(this.a,a.Sb,a.Ea)}};n.send=function(a,b){this.Ga=!0;this.Da(a,b);this.Ga=!1};n.i=function(){Wc.A.i.call(this);this.B=this.Da=k};var W=function(a,b){this.l=b||C();this.a=a;this.ba=this.a.b.ppu;this.Ob=this.a.b.lpu;this.ma=[]},Yc,Zc;w(W,T);W.prototype.aa=4;W.prototype.na=0;W.prototype.S=!1;W.prototype.I=!1;var $c=function(a){return"googlexpc_"+a.a.name+"_msg"},ad=function(a){return"googlexpc_"+a.a.name+"_ack"};
W.prototype.t=function(){L(S,"transport connect called");if(!this.I){L(S,"initializing...");var a=$c(this);this.R=bd(this,a);this.Ca=this.e().frames[a];a=ad(this);this.Q=bd(this,a);this.Ba=this.e().frames[a];this.I=!0}if(!cd(this,$c(this))||!cd(this,ad(this))){M(S,"foreign frames not (yet) present");if(Xc(this.a)==1&&!this.Mb)M(S,"innerPeerReconnect called"),this.a.name=Vc(10),M(S,"switching channels: "+this.a.name),dd(this),this.I=!1,this.Mb=bd(this,"googlexpc_reconnect_"+this.a.name);else if(Xc(this.a)==
0){M(S,"outerPeerReconnect called");for(var a=this.a.o.frames,b=a.length,c=0;c<b;c++){var d;try{if(a[c]&&a[c].name)d=a[c].name}catch(e){}if(d){var f=d.split("_");if(f.length==3&&f[0]=="googlexpc"&&f[1]=="reconnect"){this.a.name=f[2];dd(this);this.I=!1;break}}}}this.e().setTimeout(t(this.t,this),100)}else L(S,"foreign frames present"),this.Ta=new ed(this,this.a.o.frames[$c(this)],t(this.Lb,this)),this.Sa=new ed(this,this.a.o.frames[ad(this)],t(this.Kb,this)),this.Ua()};
var bd=function(a,b){M(S,"constructing sender frame: "+b);var c=document.createElement("iframe"),d=c.style;d.position="absolute";d.top="-10px";d.left="10px";d.width="1px";d.height="1px";c.id=c.name=b;c.src=a.ba+"#INITIAL";a.e().document.body.appendChild(c);return c},dd=function(a){M(S,"deconstructSenderFrames called");if(a.R)a.R.parentNode.removeChild(a.R),a.R=k,a.Ca=k;if(a.Q)a.Q.parentNode.removeChild(a.Q),a.Q=k,a.Ba=k},cd=function(a,b){M(S,"checking for receive frame: "+b);try{var c=a.a.o.frames[b];
if(!c||c.location.href.indexOf(a.Ob)!=0)return!1}catch(d){return!1}return!0};W.prototype.Ua=function(){var a=this.a.o.frames;if(!a[ad(this)]||!a[$c(this)]){if(!this.Za)this.Za=t(this.Ua,this);this.e().setTimeout(this.Za,100);L(S,"local frames not (yet) present")}else this.Va=new fd(this.ba,this.Ca),this.ka=new fd(this.ba,this.Ba),L(S,"local frames ready"),this.e().setTimeout(t(function(){this.Va.send("SETUP");this.S=this.nc=!0;L(S,"SETUP sent")},this),100)};
var gd=function(a){if(a.Ha&&a.jb){if(U(a.a),a.X){L(S,"delivering queued messages ("+a.X.length+")");for(var b=0,c;b<a.X.length;b++)c=a.X[b],V(a.a,c.Ub,c.Ea);delete a.X}}else M(S,"checking if connected: ack sent:"+a.Ha+", ack rcvd: "+a.jb)};
W.prototype.Lb=function(a){M(S,"msg received: "+a);if(a=="SETUP"){if(this.ka)this.ka.send("SETUP_ACK"),M(S,"SETUP_ACK sent"),this.Ha=!0,gd(this)}else if(this.a.q()||this.Ha){var b=a.indexOf("|"),c=a.substring(0,b),a=a.substring(b+1),b=c.indexOf(",");if(b==-1){var d;this.ka.send("ACK:"+c);hd(this,a)}else{d=c.substring(0,b);this.ka.send("ACK:"+d);c=c.substring(b+1).split("/");b=parseInt(c[0],10);c=parseInt(c[1],10);if(b==1)this.Ja=[];this.Ja.push(a);b==c&&(hd(this,this.Ja.join("")),delete this.Ja)}}else K(S,
"received msg, but channel is not connected")};W.prototype.Kb=function(a){M(S,"ack received: "+a);a=="SETUP_ACK"?(this.S=!1,this.jb=!0,gd(this)):this.a.q()?this.S?parseInt(a.split(":")[1],10)==this.na?(this.S=!1,id(this)):K(S,"got ack with wrong sequence"):K(S,"got unexpected ack"):K(S,"received ack, but channel not connected")};
var id=function(a){if(!a.S&&a.ma.length){var b=a.ma.shift();++a.na;a.Va.send(a.na+b);M(S,"msg sent: "+a.na+b);a.S=!0}},hd=function(a,b){var c=b.indexOf(":"),d=b.substr(0,c),c=b.substring(c+1);a.a.q()?V(a.a,d,c):((a.X||(a.X=[])).push({Ub:d,Ea:c}),M(S,"queued delivery"))};W.prototype.Aa=3800;
W.prototype.send=function(a,b){var c=a+":"+b;if(!z||b.length<=this.Aa)this.ma.push("|"+c);else for(var d=b.length,e=Math.ceil(d/this.Aa),f=0,g=1;f<d;)this.ma.push(","+g+"/"+e+"|"+c.substr(f,this.Aa)),g++,f+=this.Aa;id(this)};W.prototype.i=function(){W.A.i.call(this);var a=jd;Da(a,this.Ta);Da(a,this.Sa);this.Ta=this.Sa=k;ob(this.R);ob(this.Q);this.Ca=this.Ba=this.R=this.Q=k};
var jd=[],kd=t(function(){var a=!1;try{for(var b=0,c=jd.length;b<c;b++){var d;if(!(d=a)){var e=jd[b],f=e.ob.location.href;if(f!=e.nb){e.nb=f;var g=f.split("#")[1];g&&(g=g.substr(1),e.Wb(decodeURIComponent(g)));d=!0}else d=!1}a=d}}catch(j){if(S.info("receive_() failed: "+j),b=jd[b].k.a,S.info("Transport Error"),b.close(),!jd.length)return}b=la();a&&(Yc=b);Zc=window.setTimeout(kd,b-Yc<1E3?10:100)},W),ld=function(){L(S,"starting receive-timer");Yc=la();Zc&&window.clearTimeout(Zc);Zc=window.setTimeout(kd,
10)},fd=function(a,b){this.ba=a;this.Cb=b;this.Qa=0};fd.prototype.send=function(a){this.Qa=++this.Qa%2;a=this.ba+"#"+this.Qa+encodeURIComponent(a);try{A?this.Cb.location.href=a:this.Cb.location.replace(a)}catch(b){S.log(J,"sending failed",b)}ld()};var ed=function(a,b,c){this.k=a;this.ob=b;this.Wb=c;this.nb=this.ob.location.href.split("#")[0]+"#INITIAL";jd.push(this);ld()};var X=function(a,b){this.l=b||C();this.a=a;this.Nb=this.a.b.pru;this.$a=this.a.b.ifrid;A&&md()};w(X,T);if(A)var nd=[],od=0,md=function(){od||(od=window.setTimeout(function(){pd()},1E3))},pd=function(a){for(var b=la(),a=a||3E3;nd.length&&b-nd[0].timestamp>=a;){var c=nd.shift().Vb;ob(c);M(S,"iframe removed")}od=window.setTimeout(qd,1E3)},qd=function(){pd()};var rd={};X.prototype.aa=3;X.prototype.t=function(){this.e().xpcRelay||(this.e().xpcRelay=sd);this.send("tp","SETUP")};
var sd=function(a,b){var c=b.indexOf(":"),d=b.substr(0,c),e=b.substr(c+1);if(!z||(c=d.indexOf("|"))==-1)var f=d;else{var f=d.substr(0,c),d=d.substr(c+1),c=d.indexOf("+"),g=d.substr(0,c),c=parseInt(d.substr(c+1),10),j=rd[g];j||(j=rd[g]={Hb:[],Ib:0,Gb:0});if(d.indexOf("++")!=-1)j.Gb=c+1;j.Hb[c]=e;j.Ib++;if(j.Ib!=j.Gb)return;e=j.Hb.join("");delete rd[g]}V(R[a],f,decodeURIComponent(e))};X.prototype.Ia=function(a){a=="SETUP"?(this.send("tp","SETUP_ACK"),U(this.a)):a=="SETUP_ACK"&&U(this.a)};
X.prototype.send=function(a,b){var c=encodeURIComponent(b),d=c.length;if(z&&d>1800)for(var e=Math.floor(Math.random()*2147483648).toString(36)+Math.abs(Math.floor(Math.random()*2147483648)^la()).toString(36),f=0,g=0;f<d;g++){var j=c.substr(f,1800);f+=1800;td(this,a,j,e+(f>=d?"++":"+")+g)}else td(this,a,c)};
var td=function(a,b,c,d){if(z){var e=a.e().document.createElement("div");e.innerHTML='<iframe onload="this.xpcOnload()"></iframe>';e=e.childNodes[0];e.xpcOnload=ud}else e=a.e().document.createElement("iframe"),A?nd.push({timestamp:la(),Vb:e}):Ob(e,"load",ud);var f=e.style;f.visibility="hidden";f.width=e.style.height="0px";f.position="absolute";f=a.Nb;f+="#"+a.a.name;a.$a&&(f+=","+a.$a);f+="|"+b;d&&(f+="|"+d);f+=":"+c;e.src=f;a.e().document.body.appendChild(e);M(S,"msg sent: "+f)},ud=function(){M(S,
"iframe-load");ob(this);this.tc=k};X.prototype.i=function(){X.A.i.call(this);A&&pd(0)};var Y=function(a,b,c){this.l=c||C();this.a=a;this.mb=b||"*"};w(Y,T);Y.prototype.I=!1;Y.prototype.aa=1;
var vd={},wd=function(a){var b=a.qa.data,c=b.indexOf("|"),d=b.indexOf(":");if(c==-1||d==-1)return!1;var e=b.substring(0,c),c=b.substring(c+1,d),b=b.substring(d+1);L(S,"messageReceived: channel="+e+", service="+c+", payload="+b);if(d=R[e])return V(d,c,b,a.qa.origin),!0;for(var f in R)if(a=R[f],Xc(a)==1&&!a.q()&&c=="tp"&&b=="SETUP")return L(S,"changing channel name to "+e),a.name=e,delete R[f],R[e]=a,V(a,c,b),!0;S.info('channel name mismatch; message ignored"');return!1};n=Y.prototype;
n.Ia=function(a){switch(a){case "SETUP":this.send("tp","SETUP_ACK");break;case "SETUP_ACK":U(this.a)}};n.t=function(){var a=this.e(),b=ha(a),c=vd[b];typeof c=="number"||(c=0);c==0&&Ob(a.postMessage?a:a.document,"message",wd,!1,Y);vd[b]=c+1;this.I=!0;this.gb()};n.gb=function(){!this.a.q()&&!this.ia&&(this.send("tp","SETUP"),this.e().setTimeout(t(this.gb,this),100))};
n.send=function(a,b){var c=this.a.o;if(c){var d=c.postMessage?c:c.document;this.send=function(a,b){L(S,"send(): payload="+b+" to hostname="+this.mb);d.postMessage(this.a.name+"|"+a+":"+b,this.mb)};this.send(a,b)}else L(S,"send(): window not ready")};n.i=function(){Y.A.i.call(this);if(this.I){var a=this.e(),b=ha(a),c=vd[b];vd[b]=c-1;c==1&&Qb(a.postMessage?a:a.document,"message",wd,!1,Y)}};var xd=function(a,b){this.l=b||C();this.a=a;this.Wa=a.at||"";this.ab=a.rat||"";var c=this.e();if(!c.nix_setup_complete)try{c.execScript("Class GCXPC____NIXVBS_wrapper\n Private m_Transport\nPrivate m_Auth\nPublic Sub SetTransport(transport)\nIf isEmpty(m_Transport) Then\nSet m_Transport = transport\nEnd If\nEnd Sub\nPublic Sub SetAuth(auth)\nIf isEmpty(m_Auth) Then\nm_Auth = auth\nEnd If\nEnd Sub\nPublic Function GetAuthToken()\n GetAuthToken = m_Auth\nEnd Function\nPublic Sub SendMessage(service, payload)\n Call m_Transport.GCXPC____NIXJS_handle_message(service, payload)\nEnd Sub\nPublic Sub CreateChannel(channel)\n Call m_Transport.GCXPC____NIXJS_create_channel(channel)\nEnd Sub\nPublic Sub GCXPC____NIXVBS_container()\n End Sub\nEnd Class\n Function GCXPC____NIXVBS_get_wrapper(transport, auth)\nDim wrap\nSet wrap = New GCXPC____NIXVBS_wrapper\nwrap.SetTransport transport\nwrap.SetAuth auth\nSet GCXPC____NIXVBS_get_wrapper = wrap\nEnd Function",
"vbscript"),c.nix_setup_complete=!0}catch(d){S.log(J,"exception caught while attempting global setup: "+d,i)}this.GCXPC____NIXJS_handle_message=this.Rb;this.GCXPC____NIXJS_create_channel=this.Qb};w(xd,T);n=xd.prototype;n.aa=6;n.T=!1;n.F=k;n.t=function(){Xc(this.a)==0?this.hb():this.fb()};
n.hb=function(){if(!this.T){var a=this.a.P;try{a.contentWindow.opener=this.e().GCXPC____NIXVBS_get_wrapper(this,this.Wa),this.T=!0}catch(b){S.log(J,"exception caught while attempting setup: "+b,i)}this.T||this.e().setTimeout(t(this.hb,this),100)}};
n.fb=function(){if(!this.T){try{var a=this.e().opener;if(a&&"GCXPC____NIXVBS_container"in a){this.F=a;if(this.F.GetAuthToken()!=this.ab){S.log(J,"Invalid auth token from other party",i);return}this.F.CreateChannel(this.e().GCXPC____NIXVBS_get_wrapper(this,this.Wa));this.T=!0;U(this.a)}}catch(b){S.log(J,"exception caught while attempting setup: "+b,i);return}this.T||this.e().setTimeout(t(this.fb,this),100)}};
n.Qb=function(a){(typeof a!="unknown"||!("GCXPC____NIXVBS_container"in a))&&S.log(J,"Invalid NIX channel given to createChannel_",i);this.F=a;this.F.GetAuthToken()!=this.ab?S.log(J,"Invalid auth token from other party",i):U(this.a)};n.Rb=function(a,b){this.e().setTimeout(t(function(){V(this.a,a,b)},this),1)};n.send=function(a,b){typeof this.F!=="unknown"&&S.log(J,"NIX channel not connected",i);this.F.SendMessage(a,b)};n.i=function(){xd.A.i.call(this);this.F=k};var Z=function(a,b){this.ja={};for(var c=0,d;d=Tc[c];c++)d in a&&!/^https?:\/\//.test(a[d])&&h(Error("URI "+a[d]+" is invalid for field "+d));this.b=a;this.name=this.b.cn||Vc(10);this.l=b||C();a.lpu=a.lpu||Ac(this.l.e().location.href)+"/robots.txt";a.ppu=a.ppu||Ac(a.pu||"")+"/robots.txt";R[this.name]=this;Ob(window,"unload",yd);S.info("CrossPageChannel created: "+this.name)};w(Z,xc);var zd=/^%*tp$/,Ad=/^%+tp$/;n=Z.prototype;n.k=k;n.Pa=1;n.q=function(){return this.Pa==2};n.o=k;n.P=k;
var Bd=function(a){var b={};b.cn=a.name;b.tp=a.b.tp;a.b.lru&&(b.pru=a.b.lru);a.b.lpu&&(b.ppu=a.b.lpu);a.b.ppu&&(b.lpu=a.b.ppu);return b},Cd=function(a,b){var c=a.b.ifrid;c||(c=a.b.ifrid="xpcpeer"+Vc(4));var d=document.createElement("IFRAME");d.id=d.name=c;d.style.width=d.style.height="100%";var e=a.b.pu;s(e)&&(e=a.b.pu=new N(e));!0!==!1&&Nc(e,"xpc",Yb(new Wb,Bd(a)));Ua||A?(a.Fa=!0,window.setTimeout(t(function(){this.Fa=!1;b.appendChild(d);d.src=e.toString();S.info("peer iframe created ("+c+")");this.bb&&
this.t(this.Xa)},a),1)):(d.src=e.toString(),b.appendChild(d),S.info("peer iframe created ("+c+")"))};Z.prototype.Fa=!1;Z.prototype.bb=!1;
Z.prototype.t=function(a){this.Xa=a||ba;if(this.Fa)S.info("connect() deferred"),this.bb=!0;else{S.info("connect()");if(this.b.ifrid)this.P=s(this.b.ifrid)?this.l.u.getElementById(this.b.ifrid):this.b.ifrid;if(this.P)(a=this.P.contentWindow)||(a=window.frames[this.b.ifrid]),this.o=a;if(!this.o)window==top?h(Error("CrossPageChannel: Can't connect, peer window-object not set.")):this.o=window.parent;if(!this.k){if(!this.b.tp){var a=this.b,b;if(da(document.postMessage)||da(window.postMessage)||z&&window.postMessage)b=
1;else if(Ua)b=2;else if(z&&this.b.pru)b=3;else{var c;if(c=z){c=!1;try{b=window.opener,window.opener={},c=qb(window,"opener"),window.opener=b}catch(d){}}b=c?6:4}a.tp=b}switch(this.b.tp){case 1:this.k=new Y(this,this.b.ph,this.l);break;case 6:this.k=new xd(this,this.l);break;case 2:this.k=new Wc(this,this.l);break;case 3:this.k=new X(this,this.l);break;case 4:this.k=new W(this,this.l)}this.k?S.info("Transport created: "+this.k.getName()):h(Error("CrossPageChannel: No suitable transport found!"))}this.k.t()}};
Z.prototype.close=function(){if(this.q())this.Pa=3,this.k.H(),this.k=k,S.info('Channel "'+this.name+'" closed')};var U=function(a){if(!a.q())a.Pa=2,S.info('Channel "'+a.name+'" connected'),a.Xa()};Z.prototype.send=function(a,b){this.q()?this.o.closed?(S.log(J,"Peer has disappeared.",i),this.close()):(ea(b)&&(b=Yb(new Wb,b)),this.k.send(Dd(a),b)):S.log(J,"Can't send. Channel not connected.",i)};
var V=function(a,b,c,d){var e=a.b.ph;if(/^[\s\xa0]*$/.test(d==k?"":String(d))||/^[\s\xa0]*$/.test(e==k?"":String(e))||d==a.b.ph)if(a.ia)K(S,"CrossPageChannel::deliver_(): Disposed.");else if(!b||b=="tp")a.k.Ia(c);else if(a.q()){if(b=b.replace(/%[0-9a-f]{2}/gi,decodeURIComponent),b=Ad.test(b)?b.substring(1):b,d=c,(e=a.ja[b])?d=e:a.Ya?(e=ka(a.Ya,b),d=ea(d),d={kb:e,lb:d}):(K(a.la,'Unknown service name "'+b+'"'),d=k),d){a:{var e=c,f=d.lb;if(f&&s(e))try{c=Vb(e);break a}catch(g){K(a.la,"Expected JSON payload for "+
b+', was "'+e+'"');c=k;break a}else if(!f&&!s(e)){c=Yb(new Wb,e);break a}c=e}c!=k&&d.kb(c)}}else S.info("CrossPageChannel::deliver_(): Not connected.");else K(S,'Message received from unapproved origin "'+d+'" - rejected.')},Dd=function(a){zd.test(a)&&(a="%"+a);return a.replace(/[%:|]/g,encodeURIComponent)},Xc=function(a){return window.parent==a.o?1:0};Z.prototype.i=function(){Z.A.i.call(this);this.close();this.P=this.o=k;delete R[this.name]};var yd=function(){for(var a in R){var b=R[a];b&&b.H()}};var Ed=function(a,b){z?a.cssText=b:a[A?"innerText":"innerHTML"]=b};var Fd=function(a,b,c,d,e,f){var d=new N(d||window.location.href),g=new N;Cc(g,e||"talkgadget.google.com");Ec(g,"/talkgadget/d");Nc(g,"token",a);f&&Dc(g,f);var a=c||"wcs-iframe",c="#"+a+" { display: none; }",j=C(i),l=k;if(z)l=j.u.createStyleSheet(),Ed(l,c);else{var m=jb(j.u,"head")[0];m||(l=jb(j.u,"body")[0],m=j.rb("head"),l.parentNode.insertBefore(m,l));l=j.rb("style");Ed(l,c);j.appendChild(m,l)}c={};j=new N;Cc(j,e||"talkgadget.google.com");f&&Dc(j,f);Ec(j,"/talkgadget/xpc_blank");d.n=="http"||d.n==
"https"?(O(g,d.n),O(j,d.n),e=new N,O(e,d.n),Cc(e,d.J),d.G!=80&&Dc(e,d.G),Ec(e,b)):(O(g,"http"),O(j,"http"),e=new N("http://www.google.com/xpc_blank"));c.lpu=e.toString();c.ppu=j.toString();c.ifrid=a;c.pu=g.toString();Z.call(this,c)};w(Fd,Z);v("chat.WcsCrossPageChannel",Fd);var Gd=k,Hd=k,Id=k;var $=function(a,b,c,d,e){this.readyState=0;this.Oa=[];this.onopen=b.onopen;this.onmessage=b.onmessage;this.onerror=b.onerror;this.onclose=b.onclose;this.M=c||new Fd(a,"/_ah/channel/xpc_blank");this.ra=c?d:"wcs-iframe";this.qb=e||new Jd(a);document.body||h("document.body is not defined -- do not create socket from script in <head>.");Cd(this.M,document.body);yc(this.M,"opened",t(this.ac,this));yc(this.M,"onMessage",t(this.$b,this));yc(this.M,"onError",t(this.Zb,this));yc(this.M,"onClosed",t(this.tb,
this));this.M.t(t(function(){},this))};$.prototype.send=function(){return!1};$.prototype.close=function(){this.tb()};$.prototype.ic=function(){for(var a=0,b;b=this.Oa[a];a++)switch(b.type){case 0:this.onopen(b.za);break;case 1:this.onmessage(b.za);break;case 2:this.onerror(b.za);break;case 3:this.onclose(b.za)}this.Oa=[]};var Kd=function(a,b,c){a.Oa.push({type:b,za:c});window.setTimeout(t(a.ic,a),1)};
$.prototype.$b=function(a){for(var a=Vb(a),b=a.m,a=a.s,c=this.qb,d=[],e=0,f=0;f<b.length;f++){for(var g=b.charCodeAt(f);g>255;)d[e++]=g&255,g>>=8;d[e++]=g}d.push(c.sa);c=c.dc;c.reset();c.update(d);a:if(d=c.$(),!q(d)||!q(a)||d.length!=a.length)a=!1;else{c=d.length;for(e=0;e<c;e++)if(d[e]!==a[e]){a=!1;break a}a=!0}a&&Kd(this,1,{data:b});this.qb.sa++};$.prototype.Zb=function(a){a=Vb(a);Kd(this,2,{description:a.d,code:a.c})};$.prototype.ac=function(){this.readyState=1;Kd(this,0,{})};
$.prototype.tb=function(){this.M.close();this.readyState=3;Kd(this,3,{});if(this.ra){var a=new ib,b=s(this.ra)?a.u.getElementById(this.ra):this.ra;b&&a.removeNode(b)}};
var Jd=function(a){for(;a.length%4!=0;)a+=".";this.sa=0;try{if(!Gd){Gd={};Hd={};Id={};for(var b=0;b<65;b++)Gd[b]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(b),Hd[b]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.".charAt(b),Id[Hd[b]]=b}for(var b=Id,c=[],d=0;d<a.length;){var e=b[a.charAt(d++)],f=d<a.length?b[a.charAt(d)]:0;++d;var g=d<a.length?b[a.charAt(d)]:0;++d;var j=d<a.length?b[a.charAt(d)]:0;++d;(e==k||f==k||g==k||j==k)&&h(Error());c.push(e<<
2|f>>4);g!=64&&(c.push(f<<4&240|g>>2),j!=64&&c.push(g<<6&192|j))}this.Ab=c}catch(l){l.message?h(Error("The provided token is invalid ("+l.name+": "+l.message+")")):h(Error("The provided token is invalid."))}this.p=new SHA1;this.dc=new G_HMAC(this.p,this.Ab,this.Ab.length)};v("goog.appengine.Socket",$);v("goog.appengine.Socket.ReadyState",{CONNECTING:0,OPEN:1,rc:2,CLOSED:3});v("goog.appengine.Socket.ReadyState.CONNECTING",0);v("goog.appengine.Socket.ReadyState.OPEN",1);
v("goog.appengine.Socket.ReadyState.CLOSING",2);v("goog.appengine.Socket.ReadyState.CLOSED",3);v("goog.appengine.Socket.prototype.send",$.prototype.send);v("goog.appengine.Socket.prototype.close",$.prototype.close);var Ld=function(a){this.mc=a},Md={onopen:function(){},onclose:function(){},onerror:function(){},onmessage:function(){}};Ld.prototype.open=function(a){a=a||Md;return new $(this.mc,a)};v("goog.appengine.Channel",Ld);v("goog.appengine.Channel.prototype.open",Ld.prototype.open);SHA1=function(){this.h=Array(5);this.ta=Array(64);this.ec=Array(80);this.ua=Array(64);this.ua[0]=128;for(var a=1;a<64;++a)this.ua[a]=0;this.reset()};SHA1.prototype.reset=function(){this.h[0]=1732584193;this.h[1]=4023233417;this.h[2]=2562383102;this.h[3]=271733878;this.h[4]=3285377520;this.wa=this.O=0};
var Nd=function(a,b){return(a<<b|a>>>32-b)&4294967295},Od=function(a,b){for(var c=a.ec,d=0;d<64;d+=4)c[d/4]=b[d]<<24|b[d+1]<<16|b[d+2]<<8|b[d+3];for(d=16;d<80;++d)c[d]=Nd(c[d-3]^c[d-8]^c[d-14]^c[d-16],1);for(var e=a.h[0],f=a.h[1],g=a.h[2],j=a.h[3],l=a.h[4],m,u,d=0;d<80;++d)d<40?d<20?(m=j^f&(g^j),u=1518500249):(m=f^g^j,u=1859775393):d<60?(m=f&g|j&(f|g),u=2400959708):(m=f^g^j,u=3395469782),m=Nd(e,5)+m+l+u+c[d]&4294967295,l=j,j=g,g=Nd(f,30),f=e,e=m;a.h[0]=a.h[0]+e&4294967295;a.h[1]=a.h[1]+f&4294967295;
a.h[2]=a.h[2]+g&4294967295;a.h[3]=a.h[3]+j&4294967295;a.h[4]=a.h[4]+l&4294967295};SHA1.prototype.update=function(a,b){if(!b)b=a.length;var c=0;if(this.O==0)for(;c+64<b;)Od(this,a.slice(c,c+64)),c+=64,this.wa+=64;for(;c<b;)if(this.ta[this.O++]=a[c++],++this.wa,this.O==64){this.O=0;for(Od(this,this.ta);c+64<b;)Od(this,a.slice(c,c+64)),c+=64,this.wa+=64}};
SHA1.prototype.$=function(){var a=Array(20),b=this.wa*8;this.O<56?this.update(this.ua,56-this.O):this.update(this.ua,64-(this.O-56));for(var c=63;c>=56;--c)this.ta[c]=b&255,b>>>=8;Od(this,this.ta);for(c=b=0;c<5;++c)for(var d=24;d>=0;d-=8)a[b++]=this.h[c]>>d&255;return a};G_HMAC=function(a,b,c){(!a||typeof a!="object"||!a.reset||!a.update||!a.$)&&h(Error("Invalid hasher object. Hasher unspecified or does not implement expected interface."));b.constructor!=Array&&h(Error("Invalid key."));c&&typeof c!="number"&&h(Error("Invalid block size."));this.p=a;this.xa=c||16;this.ub=Array(this.xa);this.vb=Array(this.xa);b.length>this.xa&&(this.p.update(b),b=this.p.$());for(c=0;c<this.xa;c++)a=c<b.length?b[c]:0,this.ub[c]=a^G_HMAC.cc,this.vb[c]=a^G_HMAC.bc};G_HMAC.cc=92;
G_HMAC.bc=54;G_HMAC.prototype.reset=function(){this.p.reset();this.p.update(this.vb)};G_HMAC.prototype.update=function(a){a.constructor!=Array&&h(Error("Invalid data. Data must be an array."));this.p.update(a)};G_HMAC.prototype.$=function(){var a=this.p.$();this.p.reset();this.p.update(this.ub);this.p.update(a);return this.p.$()}; })()

View File

@@ -30,7 +30,7 @@ body {
}
</style>
<script src="http://chrometophone.appspot.com/_ah/channel/jsapi"></script>
<script src="channel.js"></script>
<script src="chrome_ex_oauthsimple.js"></script>
<script src="chrome_ex_oauth.js"></script>
<script src="send_logic.js"></script>

View File

@@ -131,6 +131,7 @@ function initializeBrowserChannel() {
socket.onerror = function(error) {
if (error.code == 401) { // token expiry
console.log(new Date().toTimeString() + ' Browser channel token expired - reconnecting');
// Reconnects in onclose()
} else {
console.log(new Date().toTimeString() + ' Browser channel error - reconnecting');
setTimeout('initializeBrowserChannel()', 0);
@@ -149,7 +150,7 @@ function initializeBrowserChannel() {
console.log(new Date().toTimeString() + ' Not initializing browser channel because user not logged in');
}
} else { // server not happy, random backoff
var delay = Math.random() * 20000;
var delay = Math.round(Math.random() * 20000);
console.log(new Date().toTimeString() + ' Failed to register browser channel (' + req.status + '), retrying in ' + delay + 'ms');
setTimeout('initializeBrowserChannel()', delay);
}