Created
August 8, 2011 10:22
-
-
Save ramannanda9/1131534 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/dojo/1.4/dojo/dojo.xd.js" djconfig="parseOnLoad:true"></script> | |
<script type="text/javascript"> | |
dojo.require("dojo.fx"); | |
dojo.require("dojo.fx.easing"); | |
dojo.require("dojox.widget.Toaster"); | |
dojo.require("dojo.parser"); | |
dojo.require("dojo.io.script"); | |
var doAddInfo=true; | |
var intervalId; | |
var statusCallback=function(response) | |
{ | |
dojo.fx.slideTo({node:dojo.byId('feedback'), | |
top:800,left:-30,duration:1500, | |
onEnd:function(){dojo.fx.slideTo({node:dojo.byId('feedback'), | |
top:250,left:-30,duration:1200,onEnd:function(){ | |
dojo.style(dojo.byId('feedback'),{"position":"fixed","top":"250px","left":"-30px"}); | |
},easing:dojo.fx.easing.elasticIn()}).play(); },easing:dojo.fx.easing.elasticOut()}).play(); | |
dojo.style(dojo.byId('feedback'),{"position":"fixed","top":"300px","left":"-30px"}); | |
if(doAddInfo){ | |
addInfo(response[0].user.name,response[0].user.screen_name, | |
response[0].user.description, | |
response[0].user.profile_image_url); | |
} | |
doAddInfo=false; | |
addBird(); | |
for(var i=0;(i<response.length)&&(i<20);i++){ | |
display_tweet(response[i],i,response); | |
} | |
} | |
var addInfo= function(username,screen_name,description,image){ | |
dojo.create("div",{id:'bigtext',align:'left',innerHTML:"<a href='http://www.twitter.com/"+screen_name+"'>"+"<img class='myimg' src='"+image+"' width=50 height=50 /> </img></a>"+"<p align:'left'>"+username+"</p>"+"<p align='left' id='bio'>Bio:"+description+"</p>"},dojo.query("#twitter")[0],'first'); | |
} | |
var addBird=function(){ | |
if(dojo.byId('plainimg')==null){ | |
dojo.create("div",{id:'plainimg',innerHTML:"<img src='http://ramannanda9.fileave.com/sparkle_bird.png' width='50' height='50' />"},dojo.query("#bigtext")[0]); | |
} | |
else | |
{ | |
dojo.attr('plainimg',{innerHTML:"<img src='http://ramannanda9.fileave.com/sparkle_bird.png' width='50' height='50' />"}); | |
} | |
var mainbox=dojo.marginBox(dojo.byId("twitter")); | |
var imgbox=dojo.marginBox(dojo.byId("plainimg")); | |
dojo.fx.slideTo({node:dojo.byId('plainimg'), | |
left:mainbox.w-imgbox.w-50,duration:1500, | |
onEnd:function(){dojo.byId('plainimg').innerHTML="<img src='http://ramannanda9.fileave.com/flying_bird_right_sparkles.png' align:'left' width='50' height='50' />";dojo.fx.slideTo({node:dojo.byId('plainimg'), | |
left:0,duration:1200,easing:dojo.fx.easing.elasticIn()}).play(); },easing:dojo.fx.easing.elasticOut()}).play();} | |
var init=function(){ | |
dojo.io.script.get({ | |
url:'http://twitter.com/statuses/user_timeline/ramannanda9.json?callback=statusCallback', | |
timeout:15000, | |
error:errorHandler | |
}); | |
} | |
var display_tweet=function(element,index){ | |
var a='index'+index; | |
if(dojo.byId(a)==null){ | |
dojo.create('div',{id:a,align:'left',innerHTML:"<p align='left'>"+element.text+"</p>"+"<a class='special' href='http://twitter.com/?status=@"+element.user.screen_name+"&in_reply_to_status_id="+element.id+"&in_reply_to="+element.user.screen_name+"'> reply"+"</a>"+"<hr/>"},dojo.query('#tweetbox')[0]); | |
} | |
else{ | |
dojo.attr(a,{innerHTML:"<p align='left'>"+element.text+"</p>"+"<a class='special' href='http://twitter.com/?status=@"+element.user.screen_name+"&in_reply_to_status_id="+element.id+"&in_reply_to="+element.user.screen_name+"'> reply"+"</a>"+"<hr/>"} ); | |
} | |
dojo.fadeOut({ node : a , duration : 5000 , easing: dojo.fx.easing.quintInOut,onEnd:function(event){dojo.fadeIn({ node : a , duration : 2000 , easing: dojo.fx.easing.quintInOut}).play(index*300)} }).play(index*300); | |
} | |
var errorHandler= function(err){ | |
dojo.publish("error", [{message:"Twitter is too 'Busy' cant render tweets",type:"error",duration:0}]); | |
window.clearInterval(intervalId); | |
} | |
dojo.addOnLoad(function (){ | |
intervalId=window.setInterval(init,1000*60*5); | |
init(); | |
}); | |
</script> | |
<div id="twitter"><div id="tweetbox"></div></div> | |
<div dojotype="dojox.widget.Toaster" duration="0" messagetopic="error" positiondirection="tr-left" > | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment