469,934 Members | 1,861 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,934 developers. It's quick & easy.

Trying to update template html to properly pull in a twitter feed.

I'm trying to get a blog template set up. It is supposed to pull in my twitter feed. I followed the instructions which only said to input my username into one place...it's not working...it just says it's loading the entire time. Can anyone tell what's not working in this code?


Expand|Select|Wrap|Line Numbers
  1. <div class='twitbox'> <script type='text/javascript'>
  2. //<![CDATA[
  3.  
  4. //jtwt.js by Harbor (http://jtwt.hrbor.com)
  5. (function($){$.fn.extend({jtwt:function(options){var defaults={username:"harborco",count:4,image_size:48,convert_links:1,loader_text:"loading new tweets"};var options=$.extend(defaults,options);return this.each(function(){var o=options;var obj=$(this);$(obj).append('<ul id="jtwt"></ul>');$("#jtwt",obj).append('<li id="jtwt_loader" style="display:none;">'+o.loader_text+"</li>");$("#jtwt_loader").fadeIn("slow");function prettyDate(date_str){date_str=date_str.replace(/\+[0-9]{4}/,"");date_str=date_str.substr(4);
  6. var month=new Array;month["Jan"]="1";month["Feb"]="2";month["Mar"]="3";month["Apr"]="4";month["May"]="5";month["Jun"]="6";month["Jul"]="7";month["Aug"]="8";month["Sep"]="9";month["Oct"]="10";month["Nov"]="11";month["Dec"]="12";var date_str_split=date_str.split(" ");date_str=date_str_split[4];date_str=date_str_split[4]+"-"+month[date_str_split[0]]+"-"+date_str_split[1]+"T"+date_str_split[2]+"Z";var time_formats=[[120,"1 minute ago","1 minute from now"],[3600,"minutes",60],[7200,"1 hour ago","1 hour from now"],
  7. [86400,"hours",3600],[604800,"days",86400],[2419200,"weeks",604800],[29030400,"months",2419200],[58060800,"last year","next year"],[290304E4,"years",29030400],[580608E4,"last century","next century"],[580608E5,"centuries",290304E4]];var time=(""+date_str).replace(/-/g,"/").replace(/[TZ]/g," ").replace(/^\s\s*/,"").replace(/\s\s*$/,"");if(time.substr(time.length-4,1)==".")time=time.substr(0,time.length-4);var seconds=(new Date-new Date(time))/1E3;var token="ago",list_choice=1;if(seconds<0){seconds=
  8. Math.abs(seconds);token="from now";list_choice=2}var i=0,format;while(format=time_formats[i++])if(seconds<format[0])if(typeof format[2]=="string")return format[list_choice];else return Math.floor(seconds/format[2])+" "+format[1]+" "+token;return time}$.getJSON("http://api.twitter.com/1/statuses/user_timeline/"+o.username+".json?count="+o.count+"&include_rts=true&callback=?",function(data){$.each(data,function(i,item){jtweet='<li class="jtwt_tweet">';if(o.image_size!=0){today=new Date;jtweet+='<div class="jtwt_picture">';
  9. jtweet+='<a href="http://twitter.com/'+item.user["screen_name"]+'">';jtweet+='<img width="'+o.image_size+'" height="'+o.image_size+'" src="'+item.user["profile_image_url"]+'" />';jtweet+="</a><br />";jtweet+="</div>"}var tweettext=item.text;var tweetdate=prettyDate(item.created_at);if(o.convert_links!=0){tweettext=tweettext.replace(/(http\:\/\/[A-Za-z0-9\/\.\?\=\-]*)/g,'<a href="http://bytes.com/$1">http://bytes.com/$1</a>');tweettext=tweettext.replace(/@([A-Za-z0-9\/_]*)/g,'<a rel="nofollow" href="http://twitter.com/$1">@$1</a>');tweettext=tweettext.replace(/#([A-Za-z0-9\/\.]*)/g,
  10. '<a rel="nofollow" href="http://twitter.com/search?q=$1">#$1</a>')}jtweet+='<p class="jtwt_tweet_text">';jtweet+=tweettext;jtweet+="</p>";jtweet+='<a href="http://twitter.com/'+item.user["screen_name"]+"/statuses/"+item.id+'" class="jtwt_date">';jtweet+=tweetdate;jtweet+="</a>";jtweet+="</li>";$("#jtwt",obj).append(jtweet)});$("#jtwt_loader").fadeOut("fast")})})}})})(jQuery);
  11.  
  12. //]]> </script> <script type='text/javascript'>
  13. $(window).load(function() {
  14. $('#twitter').jtwt({
  15.     count : 1, // The number of displayed tweets.
  16.     username : 'ErinRWoods', // Your username.
  17.     image_size : 0, // The size of your avatar.
  18.     loader_text : 'twitterpating', // loading text
  19. });
  20. });
  21. </script> <div id='twitter'/> </div>
Apr 26 '14 #1
1 1415
nomad
664 Expert 512MB
Start over the script is very messed up and not worth anyone time to fix it.

damon
Jul 17 '14 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

16 posts views Thread by Andrea A | last post: by
reply views Thread by Martin | last post: by
6 posts views Thread by Sean Schertell | last post: by
3 posts views Thread by Hymer | last post: by
4 posts views Thread by Jeff | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.