// "PyukiWiki" version 0.1.9 $$
// $Id: twitter.js,v 1.4 2011/05/04 07:26:50 papu Exp $

var twitstat={lol:false,jsonp:function(){if(document.all&&document.getElementById("twitstat_badge_call")){document.getElementById("twitstat_badge_call").src=twitstat.updateurl}else{if(document.getElementById("twitstat_badge_call")){var a=document.getElementById("twitstat_badge_call");a.parentNode.removeChild(a)}else{var b=document.createElement("script");if(twitstat.updateurl==""){b.src=twitstat.url}else{b.src=twitstat.updateurl}b.id="twitstat_badge_call";document.body.appendChild(b)}}if(!twitstat.lol&&/reddit/.test(document.referrer)){twitstat.lol=true}},init:function(a){twitstat.props=a;twitstat.url=twitstat.searchurl+"&rpp="+a.max+"&callback=twitstat.construct&q="+encodeURIComponent(a.keywords);if(a.near){twitstat.url+="&near="+a.near}if(a.within&&a.units){twitstat.url+="&within="+a.within+"&units="+a.units}if(typeof window.attachEvent!="undefined"){window.attachEvent("onload",twitstat.jsonp)}else{if(typeof document.addEventListener!=="undefined"){document.addEventListener("DOMContentLoaded",twitstat.jsonp,false)}else{document.write(unescape('%3Cscript src="'+twitstat.url+'" type="text/javascript"%3E%3C/script%3E'))}}},loop:function(d,e){var a=twitter_popup();var b=[];for(var c=0;c<d.length;c++){var f='<li style="margin: 5px; font: normal 12px/14px helvetica, sans-serif; min-height: 54px; height: auto !important; height: 54px;">';f+='<img src="'+d[c].profile_image_url+'" style="float: left; margin: 0 5px 10px 0; width: 48px; height: 48px;">';f+="<div>";f+="<a"+a+' href="http://www.twitter.com/'+d[c].from_user+'" style="color: '+twitstat.props.link_color+'">'+d[c].from_user+"</a>: ";f+="<span>"+twitstat.convertUrls(d[c].text)+"</span></div></li>";b[c]=f}return(e&&d.length>0?'<div style="display: none;">'+b.join("")+"</div>":b.join(""))},construct:function(d){var c=document.getElementById(twitstat.props.badge_container),b=twitstat.loop(d.results,false),g=document.createDocumentFragment();c.style.width=twitstat.props.width+"px";twitstat.holder=document.createElement("div");refresh=d.refresh_url;refresh=refresh.replace("?since_id","&since_id");twitstat.updateurl=twitstat.searchurl+refresh+"&callback=twitstat.update";var a='<ul style="list-style-type: none; overflow: hidden; height: '+(twitstat.props.max*60)+"px; padding: 0; margin: 0; color:"+twitstat.props.content_font_color+"; border: 1px solid "+twitstat.props.border_color+"; background-color: "+twitstat.props.content_background_color+';">',f='<div style="font: normal 14px/16px helvetica, sans-serif; -moz-border-radius-topleft: 2px; -moz-border-radius-topright: 2px; -webkit-border-top-left-radius: 2px; -webkit-border-top-right-radius: 2px; color: '+twitstat.props.header_font_color+"; background-color: "+twitstat.props.header_background+'; margin: 0; padding: 4px 4px 2px;">'+twitstat.props.title+"</div>",e='<div style="font: normal 11px/12px helvetica, sans-serif; color: '+twitstat.props.header_font_color+"; -moz-border-radius-bottomright: 2px; -moz-border-radius-bottomleft: 2px; -webkit-border-bottom-left-radius: 2px; -webkit-border-bottom-right-radius: 2px;background-color: "+twitstat.props.header_background+'; margin: 0; padding: 4px; text-align: right;"></div>';twitstat.holder.innerHTML="<div>"+f+a+b+"</ul>"+e+"</div>";g.appendChild(twitstat.holder.firstChild);c.appendChild(g);twitstat.list=c.getElementsByTagName("UL")[0];return false},convertUrls:function(a){popup=twitter_popup();a=a.replace(twitstat.urlRE,function(b){return twitstat.replaceUrl(b)});a=a.replace(twitstat.twitterHashRE,"<a"+popup+' title="#$1" style="color: '+twitstat.props.link_color+'" href="http://twitter.com/search/%23$1">#$1</a>');a=a.replace(twitstat.twitterUsernameRE,"<a"+popup+' title="@$1" style="color: '+twitstat.props.link_color+'" href="http://twitter.com/$1">@$1</a>');a=a.replace(twitstat.linkcolortoRE,"#$1");return a},twitterUsernameRE:/@(\w+)/gm,twitterHashRE:/\#([A-Za-z0-9]+)/gm,urlRE:/((((ht|f){1}(tp:[/][/]){1})|((www.){1}))[-a-zA-Z0-9@:;%_\+.~#?\&//=]+)/gm,linkcolorfromRE:/\#([A-Za-z0-9]+)/gm,linkcolortoRE:/_C_([A-Za-z0-9]+)/gm,replaceUrl:function(a){popup=twitter_popup();tc=twitstat.props.link_color;tc=tc.replace(twitstat.linkcolorfromRE,"_C_$1");return"<a"+popup+' href="'+a+'" title="'+a+'" style="color: '+tc+'">'+((a.length>34)?(a.substring(0,20)+"&hellip;"):a)+"</a>"},badge:{init:function(a){twitstat.init(a)}},props:{},url:"",searchurl:"?cmd=twitter",updateurl:"",fxopac:0,list:{},holder:{}};function twitter_popup(){var a="";if(twitstat.props.popup==1){a=" target=_blank"}return a};
