constructor facility added
[statusbox:statusbox.git] / dist / min / statusNet.min.js
1 /* Build-Status.net Everywhere 0.1: begin.js connector/additional.js connector/crypt.js connector/store.js connector/oauth.js connector/communicator.js api/APIBase.js api/user.js api/currentUser.js api/status.js api/directMessage.js api/search.js api/statusNet.js api/eventManager.js end.js */
2 var net={};net.status={};net.status.js={};
3 /*
4  * Crypto-JS v2.0.0
5  * http://code.google.com/p/crypto-js/
6  * Copyright (c) 2009, Jeff Mott. All rights reserved.
7  * http://code.google.com/p/crypto-js/wiki/License
8  */
9 (function(){var c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";var d=window.Crypto={};var a=d.util={rotl:function(h,g){return(h<<g)|(h>>>(32-g))},rotr:function(h,g){return(h<<(32-g))|(h>>>g)},endian:function(h){if(h.constructor==Number){return a.rotl(h,8)&16711935|a.rotl(h,24)&4278255360}for(var g=0;g<h.length;g++){h[g]=a.endian(h[g])}return h},randomBytes:function(h){for(var g=[];h>0;h--){g.push(Math.floor(Math.random()*256))}return g},bytesToWords:function(h){for(var k=[],j=0,g=0;j<h.length;j++,g+=8){k[g>>>5]|=h[j]<<(24-g%32)}return k},wordsToBytes:function(j){for(var h=[],g=0;g<j.length*32;g+=8){h.push((j[g>>>5]>>>(24-g%32))&255)}return h},bytesToHex:function(g){for(var j=[],h=0;h<g.length;h++){j.push((g[h]>>>4).toString(16));j.push((g[h]&15).toString(16))}return j.join("")},hexToBytes:function(h){for(var g=[],j=0;j<h.length;j+=2){g.push(parseInt(h.substr(j,2),16))}return g},bytesToBase64:function(h){if(typeof btoa=="function"){return btoa(e.bytesToString(h))}for(var g=[],l=0;l<h.length;l+=3){var m=(h[l]<<16)|(h[l+1]<<8)|h[l+2];for(var k=0;k<4;k++){if(l*8+k*6<=h.length*8){g.push(c.charAt((m>>>6*(3-k))&63))}else{g.push("=")}}}return g.join("")},base64ToBytes:function(h){if(typeof atob=="function"){return e.stringToBytes(atob(h))}h=h.replace(/[^A-Z0-9+\/]/ig,"");for(var g=[],j=0,k=0;j<h.length;k=++j%4){if(k==0){continue}g.push(((c.indexOf(h.charAt(j-1))&(Math.pow(2,-2*k+8)-1))<<(k*2))|(c.indexOf(h.charAt(j))>>>(6-k*2)))}return g}};d.mode={};var b=d.charenc={};var f=b.UTF8={stringToBytes:function(g){return e.stringToBytes(unescape(encodeURIComponent(g)))},bytesToString:function(g){return decodeURIComponent(escape(e.bytesToString(g)))}};var e=b.Binary={stringToBytes:function(j){for(var g=[],h=0;h<j.length;h++){g.push(j.charCodeAt(h))}return g},bytesToString:function(g){for(var j=[],h=0;h<g.length;h++){j.push(String.fromCharCode(g[h]))}return j.join("")}}})();
10 /*
11  * Crypto-JS v2.0.0
12  * http://code.google.com/p/crypto-js/
13  * Copyright (c) 2009, Jeff Mott. All rights reserved.
14  * http://code.google.com/p/crypto-js/wiki/License
15  */
16 (function(){var e=Crypto,a=e.util,b=e.charenc,d=b.UTF8,c=b.Binary;e.HMAC=function(l,m,k,h){if(m.constructor==String){m=d.stringToBytes(m)}if(k.constructor==String){k=d.stringToBytes(k)}if(k.length>l._blocksize*4){k=l(k,{asBytes:true})}var g=k.slice(0),n=k.slice(0);for(var j=0;j<l._blocksize*4;j++){g[j]^=92;n[j]^=54}var f=l(g.concat(l(n.concat(m),{asBytes:true})),{asBytes:true});return h&&h.asBytes?f:h&&h.asString?c.bytesToString(f):a.bytesToHex(f)}})();
17 /*
18  * Crypto-JS v2.0.0
19  * http://code.google.com/p/crypto-js/
20  * Copyright (c) 2009, Jeff Mott. All rights reserved.
21  * http://code.google.com/p/crypto-js/wiki/License
22  */
23 (function(){var f=Crypto,a=f.util,b=f.charenc,e=b.UTF8,d=b.Binary;var c=f.SHA1=function(j,g){var h=a.wordsToBytes(c._sha1(j));return g&&g.asBytes?h:g&&g.asString?d.bytesToString(h):a.bytesToHex(h)};c._sha1=function(o){if(o.constructor==String){o=e.stringToBytes(o)}var v=a.bytesToWords(o),x=o.length*8,p=[],r=1732584193,q=-271733879,k=-1732584194,h=271733878,g=-1009589776;v[x>>5]|=128<<(24-x%32);v[((x+64>>>9)<<4)+15]=x;for(var z=0;z<v.length;z+=16){var E=r,D=q,C=k,B=h,A=g;for(var y=0;y<80;y++){if(y<16){p[y]=v[z+y]}else{var u=p[y-3]^p[y-8]^p[y-14]^p[y-16];p[y]=(u<<1)|(u>>>31)}var s=((r<<5)|(r>>>27))+g+(p[y]>>>0)+(y<20?(q&k|~q&h)+1518500249:y<40?(q^k^h)+1859775393:y<60?(q&k|q&h|k&h)-1894007588:(q^k^h)-899497514);g=h;h=k;k=(q<<30)|(q>>>2);q=r;r=s}r+=E;q+=D;k+=C;h+=B;g+=A}return[r,q,k,h,g]};c._blocksize=16})();function Store(b){this.prefix=(b)?b:"";var a=365;this.setToken=function(c){this.cookie(this.prefix+"oauth_token",c,{expires:a})};this.setTokenSecret=function(c){this.cookie(this.prefix+"oauth_token_secret",c,{expires:a})};this.getToken=function(){return this.cookie(this.prefix+"oauth_token")};this.getTokenSecret=function(){return this.cookie(this.prefix+"oauth_token_secret")};this.cookie=function(d,l,o){if(typeof l!="undefined"){o=o||{};if(l===null){l="";o.expires=-1}var g="";if(o.expires&&(typeof o.expires=="number"||o.expires.toUTCString)){var h;if(typeof o.expires=="number"){h=new Date();h.setTime(h.getTime()+(o.expires*24*60*60*1000))}else{h=o.expires}g="; expires="+h.toUTCString()}var n=o.path?"; path="+(o.path):"";var j=o.domain?"; domain="+(o.domain):"";var c=o.secure?"; secure":"";document.cookie=[d,"=",encodeURIComponent(l),g,n,j,c].join("")}else{var f=undefined;if(document.cookie&&document.cookie!=""){var m=document.cookie.split(";");for(var k=0;k<m.length;k++){var e=m[k].replace(/^\s*/,"").replace(/\s*$/,"");if(e.substring(0,d.length+1)==(d+"=")){f=decodeURIComponent(e.substring(d.length+1));break}}}return f}}}function OAuth(b){var c=b;this.method="GET";this.endpoint;this.oauthParams={oauth_consumer_key:"",oauth_nonce:"",oauth_signature_method:"HMAC-SHA1",oauth_timestamp:"",oauth_token:"",oauth_version:"1.0"};this.consumerSecret;this.init=function(g,f,h){this.oauthParams.oauth_consumer_key=g;this.consumerSecret=f;this.endpoint=h;this.oauthParams.oauth_nonce=a();this.oauthParams.oauth_timestamp=e()};this.getRequestTokenUrl=function(){c.setToken(null);c.setTokenSecret(null);this.refreshOAuthTokens();var f=this.endpoint+"/oauth/request_token";return this.getURL(f)};this.getAuthorizationUrl=function(){var f=this.endpoint+"/oauth/authorize";f+="?oauth_token="+c.getToken();return f};this.getAccessTokenUrl=function(){this.refreshOAuthTokens();var f=this.endpoint+"/oauth/access_token";return this.getURL(f)};this.getAuthorizedMessageUrl=function(g,j,k){var h="callback_"+Math.floor(Math.random()*10000);jQuery.globalEval("var "+h+"="+k);if(!j){j={callback:h}}else{j.callback=h}this.refreshOAuthTokens();var f=this.endpoint+g;return this.getURL(f,j)};this.getRequestAPIUrl=function(j,k,h){this.refreshOAuthTokens();if(h){this.method="POST"}else{this.method="GET"}var g=this.endpoint+j;var f=this.getURL(g,k);return f};var a=function(l){l=l||64;var n=l/8;var m="";var j=n/4;var h=n%4;var k=["20","21","22","23","24","25","26","27","28","29","2A","2B","2C","2D","2E","2F","30","31","32","33","34","35","36","37","38","39","3A","3B","3C","3D","3E","3F","40","41","42","43","44","45","46","47","48","49","4A","4B","4C","4D","4E","4F","50","51","52","53","54","55","56","57","58","59","5A","5B","5C","5D","5E","5F","60","61","62","63","64","65","66","67","68","69","6A","6B","6C","6D","6E","6F","70","71","72","73","74","75","76","77","78","79","7A","7B","7C","7D","7E"];for(var f=0;f<j;f++){m+=k[g()]+k[g()]+k[g()]+k[g()]}for(var f=0;f<h;f++){m+=k[g()]}return m;function g(){return Math.floor(Math.random()*k.length)}};var e=function(){return parseInt(+new Date/1000)};var d=function(g){var h=[];for(var f in g){h.push(f)}var j=g;g={};h.sort();for(var f=0;f<h.length;f++){g[h[f]]=j[h[f]]}return j};this.toSignatureBaseString=function(h,j){var f=[];var k=d(this.oauthParams);var g=d(j);for(i in k){if(k[i]&&k[i]!=undefined){f.push(OAuthUtilities.urlEncode(i)+"="+OAuthUtilities.urlEncode(k[i]+"").replace(/\+/g,"%20"))}}for(i in g){if(g[i]&&g[i]!=undefined){f.push(OAuthUtilities.urlEncode(i)+"="+OAuthUtilities.urlEncode(g[i]+"").replace(/\+/g,"%20"))}}return[this.method,OAuthUtilities.urlEncode(h),OAuthUtilities.urlEncode(f.sort().join("&"))].join("&")};this.getSignature=function(h,k){var f=OAuthUtilities.urlEncode(this.consumerSecret);var j=OAuthUtilities.urlEncode(c.getTokenSecret()||"");var m=f+"&"+j;var l=this.toSignatureBaseString(h,k);var g=Crypto.HMAC(Crypto.SHA1,l,f+"&"+j,{asBytes:true});return Crypto.util.bytesToBase64(g)};this.getURL=function(h,j){var k=d(this.oauthParams);var g=d(j);var f=this.getSignature(h,g);for(i in g){if(g[i]==undefined){continue}h+="&"+i+"="+OAuthUtilities.urlEncode(""+g[i])}for(i in k){if(k[i]==undefined){continue}h+="&"+i+"="+OAuthUtilities.urlEncode(""+k[i])}h+="&oauth_signature="+OAuthUtilities.urlEncode(f);return h.replace("&","?")};this.refreshOAuthTokens=function(){this.oauthParams.oauth_nonce=a();this.oauthParams.oauth_timestamp=e();this.oauthParams.oauth_token=c.getToken()}}OAuth.parseToken=function(a){var b=a.split("&");var d={};for(index in b){var c=b[index].split("=");d[c[0]]=c[1]}return d};function OAuthUtilities(){}OAuthUtilities.urlEncode=function(a){a=(a+"").toString();return encodeURIComponent(a).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A").replace(/%20/g,"+")};OAuthUtilities.urlDecode=function(a){return decodeURIComponent(a.replace(/\+/g,"%20"))};net.status.js.Communicator=function(a){this.oauth=a;this.requestAPI=function(b,f,j,k,d,h,c){var e="if("+j+") response=net.status.js.Communicator.buildObject(response,'"+j+"',"+c+");";if(d){e+=d}if(h){var g=(h=="POST")?true:false;this.requestAPIWithAlteredResponseProxy(b,f,k,e,g)}else{this.requestAPIWithAlteredResponse(b,f,k,e)}};this.requestAPIWithAlteredResponse=function(g,e,f,d){if(f){var c=net.status.js.Communicator.createGlobalFunctionWithAlteration(f,d);if(!e){e={callback:c}}else{e.callback=c}}var b=this.oauth.getRequestAPIUrl(g,e);jQuery.getScript(b)};this.requestAPIWithAlteredResponseProxy=function(h,f,g,e,d){var c="";if(g){c=net.status.js.Communicator.createGlobalFunctionWithAlteration(g,e)}var b=this.oauth.getRequestAPIUrl(h,f,d);net.status.js.Communicator.sendJSON(b,c,d)}};net.status.js.Communicator.createGlobalFunction=function(a){var b="callback_"+Math.floor(Math.random()*10000);jQuery.globalEval("var "+b+"="+a);return b};net.status.js.Communicator.createDynamicFunction=function(a){var c="callback_"+Math.floor(Math.random()*10000);var b="function "+c+"(){"+a+"} ";jQuery.globalEval(b);return c};net.status.js.Communicator.createGlobalFunctionWithAlteration=function(e,b){if(e){var d="callback_"+Math.floor(Math.random()*10000);jQuery.globalEval("var "+d+"="+e);var a=d+"_m";var c="function "+a+"(response){ "+b+"   "+d+"(response);}";jQuery.globalEval(c)}return a};net.status.js.Communicator.sendJSON=function(b,d,c){b=OAuthUtilities.urlEncode(b);var a="http://127.0.0.1/gsoc/statusbox/test/proxy.php?action=json&url="+b+"&callback="+d;if(c){a+="&isPost=1"}jQuery.getScript(a)};net.status.js.Communicator.buildObject=function(response,type,parentAPI){if(response instanceof Array){var users=[];for(item in response){users[item]=builtSingle(response[item],parentAPI)}return users}else{return builtSingle(response,parentAPI)}function builtSingle(data,parentAPI){var item;var addslashes=function(str){if(typeof str!="string"){return str}str=str.replace(/\\/g,"\\\\");str=str.replace(/\'/g,"\\'");str=str.replace(/\"/g,'\\"');str=str.replace(/\0/g,"\\0");return str};eval("item=new "+type+"()");jQuery.extend(item,data);if(item.api){item.api(parentAPI)}item.construct();return item}};net.status.js.APIBase=function(){this.method=null;this.params=null;this.type=null;this.alteration="";this.auth=false;this.offlineError=null;this.additionalParams={};this.proxy=null;this.API=null;this.construct=function(){this.additionalParams={};this.auth=false};this.ready=function(f){if(this.auth){var c=this.alteration;this.alteration=null;this.API.communicator.requestAPI(this.method,this.getParamObject(this.params),this.type,f,c,this.proxy,this.API.instance_name);this.proxy=null}else{var d="if("+this.type+") response=net.status.js.Communicator.buildObject(response,'"+this.type+"',"+this.API.instance_name+");";var b=net.status.js.Communicator.createGlobalFunctionWithAlteration(f,d);var e=net.status.js.APIBase.getParamString(this.getParamObject(this.params));e+="callback="+b;var a=SN.endpoint+this.method;if(a.lastIndexOf("?")>=0){a+="&"+e}else{a+="?"+e}jQuery.getScript(a)}};this.count=function(a){this.additionalParams.count=a;return this};this.since=function(a){this.additionalParams.since_id=a;return this};this.max=function(a){this.additionalParams.max_id=a;return this};this.page=function(a){this.additionalParams.page=a;return this};this.getParamObject=function(b){var a={};for(index in b){if(!b[index]){continue}a[index]=b[index]}for(index in this.additionalParams){if(!this.additionalParams[index]){continue}a[index]=this.additionalParams[index]}return a};this.validateOnline=function(){if(!this.API.isConnected()){throw"You must be connected in order to use this method"}};this.api=function(a){this.API=a;return this}};net.status.js.APIBase.getParamString=function(a){var b="";for(item in a){b+=item+"="+a[item]+"&"}return b};net.status.js.User=function(a){this.user_id=null;this.screen_name=null;this.id=null;this.API=a;this.construct=function(){this.__proto__.construct()};this.init=function(b){this.construct();if(isNaN(b)){this.screen_name=b}else{this.user_id=b}this.id=b;this.method="/users/show.json";this.params={id:this.id};this.type="net.status.js.User"};this.favorites=function(){this.method="/favorites.json";this.params={id:this.screen_name};this.type="net.status.js.Status";return this};this.userTimeline=function(){this.method="/statuses/user_timeline.json";this.params=this.getUserParams();this.type="net.status.js.Status";return this};this.followers=function(){this.method="/statuses/followers.json";this.params=this.getUserParams();this.type="net.status.js.User";return this};this.friends=function(){this.method="/statuses/friends.json";this.params=this.getUserParams();this.type="net.status.js.User";return this};this.isFollowing=function(){this.validateOnline();this.method="/friendships/exists.json";this.params={user_b:this.id,user_a:net.status.js.User.current().screen_name};this.type="null";return this};this.isFriend=function(){this.validateOnline();this.method="/friendships/exists.json";this.params={user_a:this.id,user_b:net.status.js.User.current().screen_name};this.type="null";return this};this.isMutual=function(){this.validateOnline();this.alteration="var isMutual=false;if(response.relationship && response.relationship.source.following && response.relationship.source.followed_by) {      isMutual=true;}response=isMutual;";this.method="/friendships/show.json";if(this.screen_name){this.params={source_screen_name:this.screen_name,target_screen_name:net.status.js.User.current().screen_name}}else{if(this.user_id){this.params={source_id:this.user_id,target_screen_name:net.status.js.User.current().screen_name}}}this.type="null";return this};this.block=function(){this.validateOnline();this.proxy="POST";this.method="/blocks/create.json";this.params={id:this.id};this.type="null";return this};this.unblock=function(){this.validateOnline();this.proxy="POST";this.method="/blocks/destroy.json";this.params={id:this.id};this.type="null";return this};this.directMessage=this.dm=function(b){return net.status.js.DirectMessage.send(this.id,b)};this.follow=function(){this.validateOnline();this.proxy="POST";this.method="/friendships/create.json";this.params={id:this.id};this.type="net.status.js.User";return this};this.unfollow=function(){this.validateOnline();this.proxy="POST";this.method="/friendships/destroy.json";this.params={id:this.id};this.type="net.status.js.User";return this};this.getUserParams=function(c){var b={screen_name:this.screen_name,user_id:this.user_id};jQuery.extend(b,c);return b}};net.status.js.User.prototype=new net.status.js.APIBase();net.status.js.User.find=function(b){if(!b){throw"Please enter an ID"}var a=new net.status.js.User(this.parent);a.init(b);return a};net.status.js.User.findAll=function(a){console.error("Not Implemented Yet! Finding a API endpoing")};net.status.js.User.current=function(){var a=this.parent.currentUser;return a};net.status.js.CurrentUser=function(){this.directMessages=this.dms=this.receivedMessages=function(){this.validateOnline();this.proxy="POST";this.method="/direct_messages.json";this.type=null;return this};this.sentMessages=function(){this.validateOnline();this.proxy="POST";this.method="/direct_messages/sent.json";this.type=null;return this};this.homeTimeline=function(){this.validateOnline();this.method="/statuses/home_timeline.json";this.type="net.status.js.Status";return this};this.mentions=function(){this.validateOnline();this.method="/statuses/mentions.json";this.type="net.status.js.Status";return this};this.retweeting=function(){this.validateOnline();this.method="/statuses/retweeted_by_me.json";this.type="net.status.js.Status";return this};this.retweets=function(){this.validateOnline();this.method="/statuses/retweeted_to_me.json";this.type="net.status.js.Status";return this};this.retweeted=function(){this.validateOnline();this.method="/statuses/retweeted_of_me.json";this.type=null;return this};this.blocks=function(){this.validateOnline();this.method="/blocks/blocking.json";this.type="net.status.js.User";return this};this.logout=function(){return this.parent.logout()}};net.status.js.CurrentUser.prototype=new net.status.js.User();net.status.js.Status=function(){this.id=null;this.init=function(a){this.id=a;this.method="/statuses/show.json";this.params={id:this.id};this.type="net.status.js.Status";return this};this.retweet=function(){return this.retweet(this.id)};this.favorite=function(){return this.favorite(this.id)};this.unfavorite=function(){return this.unfavorite(this.id)};this.reply=function(a){return this.reply(a,this.id)};this.destroy=function(){this.proxy="POST";this.validateOnline();this.method="/statuses/destroy.json";this.params={id:this.id};this.type="net.status.js.Status";return this};this.retweets=function(){this.validateOnline();this.method="/statuses/retweets.json";this.params={id:this.id};this.type="net.status.js.Status";return this};this.retweeters=function(){this.validateOnline();this.method="/statuses/"+this.id+"/retweeted_by.json";this.params=null;this.type="net.status.js.User";return this};this.inReplyTo=function(){return net.status.js.User.find(this.in_reply_to_user_id)}};net.status.js.Status.prototype=new net.status.js.APIBase();net.status.js.Status.find=function(b){var a=new net.status.js.Status();a.api(this.parent);a.init(b);return a};net.status.js.Status.update=function(c,a){var b=new net.status.js.APIBase();b.api(this.parent);b.proxy="POST";b.method="/statuses/update.json";var d={status:c};jQuery.extend(d,a);b.params=d;b.type="net.status.js.Status";return b};net.status.js.Status.publicTimeline=function(){var a=new net.status.js.APIBase();a.api(this.parent);a.method="/statuses/public_timeline.json";a.params=null;a.type="net.status.js.Status";return a};net.status.js.Status.retweet=function(a){var b=new net.status.js.APIBase();b.api(this.parent);b.validateOnline();b.proxy="POST";b.method="/statuses/retweet.json";b.params={id:a};b.type="net.status.js.Status";return b};net.status.js.Status.favorite=function(a){var b=new net.status.js.APIBase();b.api(this.parent);b.validateOnline();b.proxy="POST";b.method="/favorites/create/"+a+".json";b.type="net.status.js.Status";return b};net.status.js.Status.unfavorite=function(a){var b=new net.status.js.APIBase();b.api(this.parent);b.validateOnline();b.proxy="POST";b.method="/favorites/destroy/"+a+".json";b.type="net.status.js.Status";return b};net.status.js.Status.reply=function(b,a){return net.status.js.Status.update(b,{in_reply_to_status_id:a})};net.status.js.DirectMessage=function(){this.destroy=function(){this.validateOnline();this.proxy="POST";this.method="/direct_messages/destroy/"+this.id+".format";this.type="net.status.js.DirectMessage";return this}};net.status.js.DirectMessage.prototype=new net.status.js.APIBase();net.status.js.DirectMessage.send=function(a,c){var b=new net.status.js.APIBase();b.validateOnline();b.proxy="POST";b.method="/direct_messages/new.json";b.params={user:a,text:c};b.type="net.status.js.DirectMessage";return b};net.status.js.Search=function(b){this.q="";this.API=b;this.additionalParams={};this.next=function(){if(!this.next_page){a()}var c=new net.status.js.Search(this.API);c.method="/search.json"+this.next_page;c.type="net.status.js.Search";c.auth=false;return c};this.previous=function(){if(!this.previous_page){a()}var c=new net.status.js.Search(this.API);c.method="/search.json"+this.previous_page;c.type="net.status.js.Search";c.auth=false;return c};this.refresh=function(){var c=new net.status.js.Search(this.API);c.method="/search.json"+this.refresh_url;c.type="net.status.js.Search";c.auth=false;return c};this.rpp=function(c){this.additionalParams.rpp=c;return this};var a=function(){throw"There is no such search page to access"}};net.status.js.Search.prototype=new net.status.js.APIBase();net.status.js.Search.query=function(b){var a=new net.status.js.Search(this.parent);a.q=b;a.method="/search.json";a.type="net.status.js.Search";a.params={q:b};a.auth=false;return a};net.status.js.StatusNet=function(d){this.oauth=null;this.store=null;this.endpoint="http://me.arunoda.com/api";this.currentUser=null;var c=null;this.instance_name=d;this.init=function(h,f){this.store=new Store(this.instance_name);this.oauth=new OAuth(this.store);this.oauth.init(h,f,this.endpoint);this.communicator=new net.status.js.Communicator(this.oauth);this.User=net.status.js.User;this.CurrentUser=net.status.js.CurrentUser;this.Status=net.status.js.Status;this.DirectMessage=net.status.js.DirectMessage;this.Search=net.status.js.Search;this.User.parent=this;this.CurrentUser.parent=this;this.Status.parent=this;this.DirectMessage.parent=this;this.Search.parent=this;if(location.href.search("oauth_token")>0){var e=this.oauth.getAccessTokenUrl();var g=OAuthUtilities.urlEncode(e);net.status.js.Communicator.sendJSON(g,this.instance_name+".handleInitCallback")}else{this.registerEvents()}};this.handleInitCallback=function(f){var g=OAuth.parseToken(f);var e=this.store;e.setToken(g.oauth_token);e.setTokenSecret(g.oauth_token_secret);window.opener.SN.triggerEvent("oauthVerified");window.close()};this.connect=function(){c=a("",500,500);c.document.write("wait...");c.document.close();var g=this.oauth.getRequestTokenUrl();var h=OAuthUtilities.urlEncode(g);var e=this.store;var f=this.oauth;net.status.js.Communicator.sendJSON(h,this.instance_name+".handleConnectCallback")};this.handleConnectCallback=function(f){var h=OAuth.parseToken(f);var e=this.store;e.setToken(h.oauth_token);e.setTokenSecret(h.oauth_token_secret);var g=this.oauth.getAuthorizationUrl();c.location.href=g};this.ready=function(e){if(location.href.search("oauth_token")>0){return}this.loadUser(e)};var b=null;this.loadUser=function(f){b=f;if(!this.store.getToken()||!this.store.getTokenSecret()){this.currentUser=null;jQuery(document).ready(function(){b()})}else{var e=SN.oauth.getRequestAPIUrl("/account/verify_credentials.json",null);net.status.js.Communicator.sendJSON(e,this.instance_name+".handleLoadUserCallback")}};this.handleLoadUserCallback=function(e){if(e.screen_name){this.currentUser=net.status.js.Communicator.buildObject(e,this.instance_name+".CurrentUser",this);this.triggerEvent("loggedIn");jQuery(document).ready(function(){b()})}else{this.currentUser=null;jQuery(document).ready(function(){b()})}};this.isConnected=function(){return(this.currentUser)?true:false};this.logout=function(){this.store.setToken(null);this.store.setTokenSecret(null);this.currentUser=null;this.triggerEvent("loggedOut");return true};this.registerEvents=function(){var e=net.status.js.Communicator.createDynamicFunction(this.instance_name+".loadUser(function(){});");this.registerEvent("oauthVerified",e)};var a=function(f,g,e){var j=screen.height/2-e/2;var h=screen.width/2-g/2;var k=window.open(f,"Login","left="+h+",scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no");return k}};net.status.js.EventManager=function(){this.events=[];this.registerEvent=function(eventName,callback){if(!this.events[eventName]){this.events[eventName]=[]}this.events[eventName][this.events[eventName].length]=callback};this.triggerEvent=function(eventName){var events=this.events[eventName];if(events){for(id in events){var func=events[id];if(typeof func=="string"){eval(func+"()")}else{func()}}}}};net.status.js.StatusNet.prototype=new net.status.js.EventManager();var SN=new net.status.js.StatusNet("SN");